Skip to content

refactor: simplify workflow log output - #2512

Merged
yohamta0 merged 7 commits into
mainfrom
improve-workflow-log-readability
Aug 6, 2026
Merged

yohamta0 merged 7 commits into
mainfrom
improve-workflow-log-readability

Conversation

@yohamta0

@yohamta0 yohamta0 commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add a readable Activity view for workflow execution logs while preserving raw log access
  • omit invariant run context from run-scoped files and UI presentation
  • retain canonical correlation fields in centralized logs and OpenTelemetry spans
  • emit the current attempt ID at attempt boundaries instead of repeating it on every run-file line
  • normalize workflow log keys and use distinct sub-DAG fields where parent and child context coexist

Why

Workflow log lines repeated DAG, run, attempt, worker, and trace identity even when the surrounding file or page already established that context. This made the useful event, step, and error information unnecessarily difficult to scan. Some paths also used aliases or repeated correlation keys, which made centralized search and aggregation less reliable.

Impact

Run files and the Activity UI now emphasize the event-specific fields. Centralized logs retain dag, run-id, attempt-id, worker identity, and valid trace context so records remain independently searchable. Existing raw text and JSON log formats remain supported.

Validation

  • go test ./internal/cmn/logger ./internal/runtime/agent ./internal/runtime ./internal/runtime/builtin/chat ./internal/runtime/builtin/dag ./internal/runtime/executor
  • go test ./internal/cmd ./internal/service/chatbridge ./internal/service/frontend/api/v1 ./internal/service/scheduler ./internal/subflow
  • go test ./internal/cmn/telemetry
  • pnpm test -- scheduler-log
  • pnpm exec vitest run src/lib/__tests__/scheduler-log.test.ts

Summary by cubic

Simplified workflow log output and added a readable Activity view that highlights event details. Step names are now easy to scan, and run-scoped files drop redundant context while centralized logs stay searchable.

  • New Features

    • Activity view in the DAG Execution UI with compact timestamps, level badges, a dedicated scannable step column, and expandable details; added ActivityLine.
    • parseSchedulerLogLine parses text/JSON scheduler logs, hiding run context and surfacing meaningful details.
    • Toggle between Activity and Raw; navigation controls appear only when needed; wrapping is Raw-only; tests cover the parser and Activity rendering.
  • Refactors

    • Added WithRunWriter to omit ambient run context (dag, run-id, attempt-id, worker-id, trace fields, parent/root) in run-scoped outputs; used for run files, restart path, and sub‑DAG scheduler logs.
    • Centralized logs use tag.DAG, tag.RunID, tag.SubDAG, and tag.SubRunID; include worker ID when present; attach trace context once; reduced telemetry debug noise.
    • Emit attempt ID only at attempt boundaries; updated agent context and span attributes accordingly.

Written for commit e09bbc5. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added Activity and Raw display modes for execution logs.
    • Activity mode shows timestamps, severity, steps, expandable details, and formatted output.
    • Added parsing for structured scheduler logs in JSON and text formats.
    • Added improved log navigation with pagination, line statistics, wrapping, and jump-to-line controls when applicable.
    • Activity mode is selected by default.
  • Bug Fixes

    • Improved log labels and context for workflows, sub-workflows, runs, attempts, and workers.
    • Reduced unnecessary trace details while preserving relevant event information.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds run-writer filtering, standardizes structured DAG and sub-DAG log fields, propagates execution context through agent logging, and adds Activity and Raw modes for execution-log display with scheduler-log parsing.

Changes

Execution logging and display

Layer / File(s) Summary
Run-writer filtering and wiring
internal/cmn/logger/..., internal/cmd/..., internal/cmn/telemetry/propagation.go
The logger filters ambient run and tracing fields from run-writer output. Command logging uses the run writer. Trace injection logs only span presence.
Agent logging context propagation
internal/runtime/agent/..., internal/runtime/node.go, internal/runtime/runner.go
Agent logs and spans use centralized DAG, run, worker, attempt, and trace fields. Sub-DAG writer replacement restores the central logging context. Tests verify scheduler log context.
DAG and sub-DAG tag migration
internal/runtime/..., internal/service/..., internal/subflow/runner.go
Runtime and service logs use structured DAG, run, sub-DAG, and sub-run tags instead of generic attributes.
Parsed Activity-mode execution logs
ui/src/lib/..., ui/src/features/dags/components/dag-execution/...
The UI parses text and JSON scheduler logs. Activity mode renders structured entries. Raw mode retains numbered ANSI output and wrapping controls.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExecutionLog
  participant parseSchedulerLogLine
  participant ActivityLine
  ExecutionLog->>parseSchedulerLogLine: Parse each scheduler log line
  parseSchedulerLogLine-->>ExecutionLog: Return SchedulerLogLine
  ExecutionLog->>ActivityLine: Render parsed activity entry
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: simplifying workflow log output.
Description check ✅ Passed The description explains the changes, rationale, impact, and validation, but it does not use every template heading or include the checklist.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve-workflow-log-readability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/cmn/logger/logger.go`:
- Around line 150-156: Update isRunContext in internal/cmn/logger/logger.go to
classify both root and parent as run-context attributes. In
internal/cmn/logger/logger_test.go, extend baseContext with root and parent,
then verify run output omits both while central output retains them.

In `@internal/runtime/agent/agent.go`:
- Around line 685-700: Add an Agent regression test covering the sub-DAG
scheduler-writer path around withSubDAGRunSchedulerLog, including logger
replacement and central-field restoration. Verify normal scheduler output
excludes ambient run fields, while the attempt ID appears only in the captured
attemptBoundaryLogger lifecycle output.

In `@internal/service/frontend/api/v1/dagruns.go`:
- Around line 1055-1056: The failure log in GetDAGRunOutputs currently uses the
requested run ID, which may be "latest", instead of the resolved attempt ID.
Update the tag.RunID argument to use the resolved DAGRunAttempt’s run ID while
preserving the existing logging context and behavior.

In `@ui/src/features/dags/components/dag-execution/ExecutionLog.tsx`:
- Around line 61-63: Update both structured and unstructured message containers
in ExecutionLog, including the div containing AnsiLine, to add the
whitespace-normal and break-words classes so long unbroken Activity messages
wrap within the log panel.
- Around line 636-640: Restore Activity mode line targeting by passing
getLineNumber(index) from the activityLines.map call to ActivityLine, then
render that value as the data-line-number attribute in ActivityLine so
handleJumpToLine can locate, scroll to, and highlight the target. Add a
regression test covering jump-to-line behavior in Activity mode.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 30136b8f-8a86-4504-bfd6-6f67d970c73d

📥 Commits

Reviewing files that changed from the base of the PR and between 61bf24a and f1a81f7.

📒 Files selected for processing (26)
  • internal/cmd/agent_executor.go
  • internal/cmd/context.go
  • internal/cmd/restart.go
  • internal/cmn/logger/logger.go
  • internal/cmn/logger/logger_test.go
  • internal/cmn/telemetry/propagation.go
  • internal/runtime/agent/agent.go
  • internal/runtime/agent/dbclient.go
  • internal/runtime/builtin/chat/tool_executor.go
  • internal/runtime/builtin/dag/enqueue.go
  • internal/runtime/builtin/dag/parallel.go
  • internal/runtime/executor/dag_runner.go
  • internal/runtime/manager.go
  • internal/runtime/runner.go
  • internal/service/chatbridge/monitor.go
  • internal/service/frontend/api/v1/dagruns.go
  • internal/service/frontend/api/v1/humantasks.go
  • internal/service/frontend/api/v1/queues.go
  • internal/service/frontend/api/v1/webhooks.go
  • internal/service/scheduler/queue_dispatcher.go
  • internal/service/scheduler/zombie_detector.go
  • internal/subflow/runner.go
  • ui/src/features/dags/components/dag-execution/ExecutionLog.tsx
  • ui/src/features/dags/components/dag-execution/LogSideModal.tsx
  • ui/src/lib/__tests__/scheduler-log.test.ts
  • ui/src/lib/scheduler-log.ts
💤 Files with no reviewable changes (2)
  • internal/runtime/runner.go
  • ui/src/features/dags/components/dag-execution/LogSideModal.tsx

Comment thread internal/cmn/logger/logger.go
Comment thread internal/runtime/agent/agent.go
Comment thread internal/service/frontend/api/v1/dagruns.go Outdated
Comment thread ui/src/features/dags/components/dag-execution/ExecutionLog.tsx Outdated
Comment thread ui/src/features/dags/components/dag-execution/ExecutionLog.tsx
@yohamta0

yohamta0 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/runtime/agent/agent_test.go (1)

184-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Check context filtering on every step-scoped record.

The test checks only the "Step started" record. A later record with a "step" field can contain inherited context and this test will still pass. Check the filtered keys for every record that contains "step".

Proposed test update
 for _, record := range records {
   if _, ok := record["attempt-id"]; ok {
     attemptCount++
   }
+  if _, isStepRecord := record["step"]; isStepRecord {
+    for _, key := range []string{"dag", "run-id", "attempt-id", "worker-id", "trace-id", "span-id", "trace-flags", "root", "parent"} {
+      require.NotContains(t, record, key)
+    }
+  }
   switch record["msg"] {
   case "DAG run started":
     boundary = record
   case "Step started":
     step = record
   }
 }
 require.Equal(t, attemptID, boundary["attempt-id"])
 require.Equal(t, 1, attemptCount)
 require.Equal(t, "collect_metrics", step["step"])
-for _, key := range []string{"dag", "run-id", "attempt-id", "worker-id", "trace-id", "span-id", "trace-flags", "root", "parent"} {
-  require.NotContains(t, step, key)
-}

As per coding guidelines, “Add or update tests appropriate to the changed code.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/runtime/agent/agent_test.go` around lines 184 - 186, The test
currently validates filtered context only for the “Step started” record. Update
the assertions in the relevant agent test to iterate over every record
containing a “step” field and verify none includes the filtered keys, preserving
the existing key list and failure behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/runtime/agent/agent_test.go`:
- Around line 184-186: The test currently validates filtered context only for
the “Step started” record. Update the assertions in the relevant agent test to
iterate over every record containing a “step” field and verify none includes the
filtered keys, preserving the existing key list and failure behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 11350f7e-af06-413a-92b6-ada1b7c32cd8

📥 Commits

Reviewing files that changed from the base of the PR and between f1a81f7 and 63c31ae.

📒 Files selected for processing (8)
  • internal/cmn/logger/logger.go
  • internal/cmn/logger/logger_test.go
  • internal/runtime/agent/agent_test.go
  • internal/runtime/node.go
  • internal/service/frontend/api/v1/dagruns.go
  • ui/src/features/dags/components/dag-execution/ActivityLine.tsx
  • ui/src/features/dags/components/dag-execution/ExecutionLog.tsx
  • ui/src/features/dags/components/dag-execution/__tests__/ExecutionLog.test.tsx
💤 Files with no reviewable changes (1)
  • internal/runtime/node.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/cmn/logger/logger_test.go
  • internal/cmn/logger/logger.go
  • internal/service/frontend/api/v1/dagruns.go
  • ui/src/features/dags/components/dag-execution/ExecutionLog.tsx

@yohamta0

yohamta0 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Addressed the follow-up nitpick in f43fa52b: the regression now applies the filtered-context assertion to every captured step-scoped record. The focused Agent test and the repository formatting/lint workflow pass.

@yohamta0

yohamta0 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0
yohamta0 merged commit c01c18e into main Aug 6, 2026
14 checks passed
@yohamta0
yohamta0 deleted the improve-workflow-log-readability branch August 6, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant