This document describes how Sim Studio captures and displays execution telemetry in real-time. The logging system uses Server-Sent Events (SSE) to stream block execution progress from the server to the client, renders hierarchical execution trees in the Terminal UI for nested workflows (loops, parallels, child workflows), and persists logs both client-side (Zustand) and server-side (PostgreSQL).
The system architecture bridges high-level workflow concepts with low-level execution data through TraceSpan objects and ConsoleEntry records, ensuring that every token spent and every block executed is accounted for and visible to the user.
Sources: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:1-53, apps/sim/stores/terminal/store.ts1-20 apps/sim/lib/logs/execution/logger.ts1-37
The primary unit of execution telemetry is the TraceSpan. It represents a discrete unit of work, such as a block execution, a tool call, or a subflow iteration. Spans are built from execution logs after execution completes.
Sources: apps/sim/lib/logs/types.ts33 apps/sim/lib/logs/execution/logger.ts51-60
The Terminal UI stores logs as ConsoleEntry objects, which are derived from execution events and managed by useTerminalConsoleStore.
Sources: apps/sim/stores/terminal/store.ts61-68 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:98-156
Workflow execution triggers a stream of events (e.g., block:start, block:complete). These are handled on the client by the workflow execution hooks.
Diagram: Execution Event to UI Flow
Sources: apps/sim/lib/logs/execution/logger.ts135-156 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts:53-60, apps/sim/stores/terminal/store.ts59-70
Once execution finishes, the LoggingSession finalizes the outcome. This includes calculating costs based on token usage and model pricing.
calculateCostSummary to aggregate input/output tokens apps/sim/lib/logs/execution/logging-session.ts233-245workflow_execution_logs table in PostgreSQL apps/sim/lib/logs/execution/logging-session.ts35-47Sources: apps/sim/lib/logs/execution/logging-session.ts131-169 apps/sim/lib/logs/execution/logger.ts72-133 apps/sim/app/api/billing/update-cost/route.ts13-22
The Terminal component apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:1-36 renders a live feed of block executions. It uses a virtualized list via react-window to handle large logs efficiently.
| Component | Responsibility |
|---|---|
BlockRow | Renders a single block's status, duration, and icon apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:98-156. |
IterationNodeRow | Renders a collapsible group for loop or parallel iterations apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:161-224. |
OutputPanel | Displays JSON input/output for the selected log entry with collapsible regions apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/components/index.ts. |
StatusDisplay | Formats duration and shows running/canceled states apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:148-152. |
Sources: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:98-224, apps/sim/components/emcn/components/code/code.tsx92-167
The logs dashboard apps/sim/app/workspace/[workspaceId]/logs/logs.tsx:210-235 provides advanced filtering by time range, status, and trigger type.
parseQuery converts search strings into API parameters apps/sim/lib/logs/query-parser.ts29-30Sources: apps/sim/app/workspace/[workspaceId]/logs/logs.tsx:88-95, apps/sim/lib/logs/filters.ts23-27
The ExecutionLogger builds completed execution data by transforming raw logs into a TraceSpan tree.
Diagram: Trace Span Logic Mapping
Sources: apps/sim/lib/logs/execution/logger.ts73-133 apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx:1-20
Errors encountered during execution are captured and displayed with specific styling.
BlockRow uses text-[var(--text-error)] when an entry contains an error apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:134-137.extractErrorMessage is used to pull human-readable messages from various error objects apps/sim/tools/error-extractors.ts20LoggingSession ensures that even failed executions record their partial progress and error stacks apps/sim/lib/logs/execution/logging-session.ts91-101Sources: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx:108-112, apps/sim/apps/sim/tools/index.ts19-20 apps/sim/lib/logs/execution/logging-session.ts281-300
Refresh this wiki