Skip to content

fix(cli): send workflow dispatch/result messages for Web UI cards#1052

Merged
coleam00 merged 7 commits intodevfrom
archon/task-fix-github-issue-1775831868291
Apr 16, 2026
Merged

fix(cli): send workflow dispatch/result messages for Web UI cards#1052
coleam00 merged 7 commits intodevfrom
archon/task-fix-github-issue-1775831868291

Conversation

@coleam00
Copy link
Copy Markdown
Owner

@coleam00 coleam00 commented Apr 10, 2026

Summary

  • Problem: CLI-launched workflows show only plain text in the Web UI chat — no WorkflowProgressCard during execution, no WorkflowResultCard after completion, and no "View full logs" link.
  • Why it matters: Users who run workflows via CLI lose the rich interactive experience (progress tracking, result summary, log navigation) that Web UI-launched workflows provide. The workflow runs are stored in the DB and appear in the chat, but look broken.
  • What changed: Added two sendMessage() calls in packages/cli/src/commands/workflow.ts — one before executeWorkflow (dispatch) and one after (result) — mirroring the pattern in orchestrator.ts:dispatchBackgroundWorkflow.
  • What did NOT change: cli-adapter.ts, MessageList.tsx, the DAG executor, and all other packages are untouched. The CLI adapter already handled both metadata fields; it just needed to be called.

UX Journey

Before

User                        CLI                          Web UI Chat
────                        ───                          ───────────
bun cli workflow run ──▶  executeWorkflow()
                           console.log('completed')
                                                         [plain text message only]
                                                         [no progress card]
                                                         [no result card]
                                                         [no "View full logs" link]

After

User                        CLI                          Web UI Chat
────                        ───                          ───────────
bun cli workflow run ──▶  [sendMessage workflowDispatch]
                           executeWorkflow()             [WorkflowProgressCard ✅]
                          [sendMessage workflowResult]
                           console.log('completed')     [WorkflowResultCard ✅]
                                                         ["View full logs" link ✅]

Architecture Diagram

Before

workflow.ts
  └── executeWorkflow()        (result.workflowRunId ignored)
  └── console.log('done')

cli-adapter.ts
  └── sendMessage()            (supports workflowDispatch/workflowResult — NEVER CALLED)

MessageList.tsx
  └── if msg.workflowDispatch  → WorkflowProgressCard  ❌ never renders for CLI
  └── if msg.workflowResult    → WorkflowResultCard    ❌ never renders for CLI

After

workflow.ts
  └── [~] sendMessage(workflowDispatch)   ← NEW call before executeWorkflow
  └── executeWorkflow()
  └── [~] sendMessage(workflowResult)     ← NEW call after executeWorkflow succeeds
  └── console.log('done')

cli-adapter.ts
  └── sendMessage()            (unchanged — already persists both metadata fields)

MessageList.tsx
  └── if msg.workflowDispatch  → WorkflowProgressCard  ✅ now renders for CLI
  └── if msg.workflowResult    → WorkflowResultCard    ✅ now renders for CLI

Connection inventory:

From To Status Notes
workflow.ts cli-adapter.sendMessage() new (×2) dispatch before, result after
cli-adapter.ts DB messages table unchanged already persists workflowDispatch/workflowResult
MessageList.tsx WorkflowProgressCard unchanged already renders when metadata present
MessageList.tsx WorkflowResultCard unchanged already renders when metadata present

Label Snapshot

  • Risk: risk: low
  • Size: size: XS
  • Scope: cli
  • Module: cli:workflow-command

Change Metadata

  • Change type: bug
  • Primary scope: cli

Linked Issue

Validation Evidence (required)

bun run type-check   # ✅ 0 errors across all 9 packages
bun run lint         # ✅ 0 errors, 0 warnings (--max-warnings 0)
bun run format:check # ✅ all files formatted
bun run test         # ✅ all packages pass, 0 failures
  • All four validation commands passed on the first run.
  • Type narrowing deviation: used 'summary' in result && result.summary because TypeScript could not narrow the union type in the else if (result.success) branch with a direct property access.
  • Logger access deviation: used getLog().warn(...) instead of bare log to match the lazy-initialized logger pattern used by workflowRunCommand.

Security Impact (required)

  • New permissions/capabilities? No
  • New external network calls? No
  • Secrets/tokens handling changed? No
  • File system access scope changed? No

Compatibility / Migration

  • Backward compatible? Yes — additive only; existing CLI behavior (console output) is preserved
  • Config/env changes? No
  • Database migration needed? No

Human Verification (required)

  • Verified scenarios: Type check, lint, format, and tests all passed automated validation
  • Edge cases checked: Paused workflows do not receive a result card (guard is in the else if (result.success && !paused) branch); missing result.summary is guarded before calling sendMessage
  • What was not verified: End-to-end manual run of bun run cli workflow run with the Web UI open (automated validation only)

Side Effects / Blast Radius (required)

  • Affected subsystems/workflows: CLI workflow command only; no other packages changed
  • Potential unintended effects: None — cli-adapter.sendMessage() already handles both metadata fields and persists to the same DB table used by the web path
  • Guardrails/monitoring for early detection: Any DB write failure in sendMessage would surface as a logged error; the dispatch/result messages are non-critical (workflow execution continues regardless)

Rollback Plan (required)

  • Fast rollback command/path: Revert the two sendMessage() calls in packages/cli/src/commands/workflow.ts; no DB migration needed
  • Feature flags or config toggles: None
  • Observable failure symptoms: CLI workflow cards would disappear from Web UI chat (same as pre-fix behavior)

Risks and Mitigations

  • Risk: sendMessage throws after workflow completes, masking success
    • Mitigation: The result message send is wrapped in a try/catch with a warn log (mirroring orchestrator.ts:380-389); CLI console.log('completed') still runs

Summary by CodeRabbit

  • New Features

    • Web UI shows workflow dispatch and result messages when workflows run (result messages only when a summary is returned). Paused workflows suppress result cards and print a pause message.
  • Tests

    • Added tests for dispatch/result messaging, ordering, absent-summary behavior, paused workflows, and persistence-failure handling.
  • Improvements

    • Cleaner CLI output formatting and more consistent JSON for workflow status. CLI now logs warnings (non-fatal) if message persistence fails; UI is more resilient to partial run data.

)

CLI-launched workflows were visible in the Web UI chat but displayed as
plain text only — no WorkflowProgressCard or WorkflowResultCard. The CLI
adapter already handled both metadata fields; the sendMessage calls were
simply missing from workflowRunCommand.

Changes:
- Send workflowDispatch message before executeWorkflow (mirrors orchestrator.ts)
- Send workflowResult message after successful completion with summary
- Wrap result message in try/catch with warn log (same pattern as orchestrator)

Fixes #1017

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 838df824-54d3-4f84-871c-8f49f0b59f7e

📥 Commits

Reviewing files that changed from the base of the PR and between b620c04 and 51b8652.

📒 Files selected for processing (2)
  • packages/cli/src/commands/workflow.test.ts
  • packages/web/src/components/chat/WorkflowProgressCard.tsx

📝 Walkthrough

Walkthrough

Sends CLI-emitted workflow metadata messages: a workflow_dispatch_status before executing a workflow and a workflow_result after completion when a summary exists; adds tests for ordering, persistence, and failure resilience; tightens web chat guards to tolerate missing run in fetched data.

Changes

Cohort / File(s) Summary
CLI Workflow Command
packages/cli/src/commands/workflow.ts
Send workflow_dispatch_status before executeWorkflow and workflow_result after successful non-paused completion when summary exists; wrap sends in try/catch with warning logs; remove redundant String(...) wrappers; JSON status output adjusted to always emit { runs: runsOutput }.
CLI Workflow Tests
packages/cli/src/commands/workflow.test.ts
Add tests asserting dispatch message persisted before execution, result message persisted when summary exists, no workflow_result when no summary or paused, and that persistence failures do not abort execution but log cli_message_persist_failed.
Web chat guards & UI tolerance
packages/web/src/components/chat/ChatInterface.tsx, packages/web/src/components/chat/WorkflowProgressCard.tsx
Narrow hydration guard to require result?.run; use optional chaining for run fields so polling and derived run values tolerate missing run in responses.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI Command
    participant Adapter as CLI Adapter
    participant DB as Messages DB
    participant Executor as Workflow Executor
    participant UI as Web UI

    CLI->>Adapter: sendMessage(dispatch_status, {workflowDispatch})
    Adapter->>DB: persist message (category: workflow_dispatch_status)
    DB-->>Adapter: success / failure
    Adapter-->>CLI: resolved (errors logged as warnings)

    CLI->>Executor: executeWorkflow(...)
    Executor-->>CLI: result { summary?, workflowRunId, status }

    alt result.summary exists and not paused
        CLI->>Adapter: sendMessage(result.summary, {workflowResult})
        Adapter->>DB: persist message (category: workflow_result)
        DB-->>Adapter: success / failure
        Adapter-->>CLI: resolved (errors logged as warnings)
        DB->>UI: new message -> render WorkflowResultCard
    else no summary or paused
        CLI->>CLI: print completion / paused message (no result card sent)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through code and left a trace,

A dispatch hop, then a result in place.
The CLI chittered, the Web did see,
Cards and links now match with glee.
Hooray — workflows hop in unity!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% 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
Title check ✅ Passed The title 'fix(cli): send workflow dispatch/result messages for Web UI cards' directly summarizes the main change—adding dispatch/result message sends to enable Web UI cards for CLI workflows.
Description check ✅ Passed The PR description covers all template sections: summary (problem, why it matters, what changed, scope boundary), before/after UX journeys, architecture diagrams with connection inventory, risk/compatibility assessments, validation evidence, and rollback plan.
Linked Issues check ✅ Passed The code changes fully satisfy issue #1017 requirements: dispatch message sent before executeWorkflow, result message sent after success (guarded against paused workflows and missing summary), same adapter pattern as orchestrator, and all optional enhancements addressed via follow-up work.
Out of Scope Changes check ✅ Passed All changes are in-scope: workflow.ts dispatch/result sends (required), tests validating dispatch/result behavior (required), cli-adapter unchanged (as specified), and defensive null checks in web components to prevent crashes (minimal follow-up fix).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch archon/task-fix-github-issue-1775831868291

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 and usage tips.

@coleam00
Copy link
Copy Markdown
Owner Author

🔍 Comprehensive PR Review

PR: #1052 (fixes issue #1017)
Reviewed by: 4 specialized agents (code-review, error-handling, test-coverage, comment-quality)
Date: 2026-04-10


Summary

Minimal, well-scoped fix (+22 lines, 1 file) that adds two sendMessage() calls to workflowRunCommand in the CLI path, enabling Web UI dispatch and result cards for CLI-triggered workflows. The implementation is architecturally correct — proper TypeScript union narrowing, consistent orchestrator-mirroring pattern, and appropriate non-critical error handling for the result card. No critical or high-severity issues found.

Verdict: APPROVE WITH SUGGESTIONS

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 5
🟢 LOW 4

🟡 Medium Issues (Needs Decision)

M1: Unguarded Dispatch sendMessage Can Abort Workflow Execution

📍 packages/cli/src/commands/workflow.ts:594-599

The dispatch notification is awaited without a try/catch. If adapter.sendMessage throws (DB failure, future adapter regression), the exception propagates, the workflow never executes, and the user sees a cryptic error. The current CLIAdapter internally guards its DB path (so current risk is low), but IPlatformAdapter.sendMessage doesn't guarantee no-throw — this is a latent contract violation. The result card path (lines 624-635) already establishes the correct pattern.

Easy fix (4 lines):

try {
  await adapter.sendMessage(conversationId, `Dispatching workflow: **${workflow.name}**`, {
    category: 'workflow_dispatch_status',
    segment: 'new',
    workflowDispatch: { workerConversationId: conversationId, workflowName: workflow.name },
  });
} catch (dispatchError) {
  getLog().warn({ err: dispatchError as Error, conversationId }, 'workflow_dispatch_surface_failed');
}

Options: Fix now (recommended) | Create issue | Skip (consistent with orchestrator pattern)


M2: Dispatch sendMessage not verified in workflowRunCommand tests

📍 packages/cli/src/commands/workflow.ts:594-599 / workflow.test.ts

No existing test asserts the dispatch call fires before executeWorkflow with the correct category: 'workflow_dispatch_status' metadata. The addMessage DB mock is present but call args aren't verified for this new path. Note: cli-adapter.test.ts already has excellent unit coverage for the metadata shapes — the gap is at the integration layer.

Options: Fix now | Create issue (recommended) | Skip


M3: Result sendMessage not verified in workflowRunCommand tests

📍 packages/cli/src/commands/workflow.ts:622-636 / workflow.test.ts

Existing tests mock executeWorkflow returning { success: true, workflowRunId: 'run-123' } (no summary), so the result card path is never exercised. Three untested scenarios: result with summary (card sends), result without summary (card doesn't send), result card DB error (warn logged, no throw). The non-throwing try/catch means a regression here would be silent.

Options: Fix now | Create issue (recommended) | Skip


M4: Comment "mirrors orchestrator.ts dispatch message" is partially inaccurate

📍 packages/cli/src/commands/workflow.ts:594

Structure does mirror the orchestrator, but the display text intentionally differs: orchestrator sends 🚀 Dispatching workflow: **<name>** (background); CLI sends Dispatching workflow: **<name>** (no emoji, no "(background)" since CLI runs synchronously). Without noting this, a future developer could "fix" the CLI text to match the orchestrator, misleading end-users.

Easy fix (comment update):

// Notify Web UI that a workflow is dispatching.
// Mirrors the orchestrator dispatch message structure (category/segment/workflowDispatch),
// but omits the rocket emoji and "(background)" qualifier since the CLI runs synchronously.

Options: Fix now (recommended, low effort) | Skip


M5: workerConversationId: conversationId — architectural distinction not documented

📍 packages/cli/src/commands/workflow.ts:598

In the orchestrator, workerConversationId is a separate hidden worker conversation ID. In the CLI, there's no separate worker — the same conversationId is used for both roles. No comment explains why this is correct, which could mislead future developers.

Easy fix (comment addition):

// In the CLI path there is no separate worker conversation — the CLI itself
// is both the dispatcher and the executor, so workerConversationId === conversationId.

Options: Fix now (recommended, low effort) | Skip


🟢 Low Issues

View 4 low-priority notes
Issue Location Agent Note
Dispatch not wrapped in try/catch (informational) workflow.ts:595 code-review Consistent with orchestrator; deliberate fail-fast. No action needed.
surfaceError as Error cast workflow.ts:630 error-handling Pervasive codebase pattern, not introduced by this PR. Leave as-is.
Paused-check guard equivalence untested workflow.ts:619-623 test-coverage Low risk — else if structure is obvious. Optional test only.
Result-card comment could note paused exclusion workflow.ts:622 comment-quality Very minor. Optional.

✅ What's Good

  • Correct TypeScript union narrowing: 'summary' in result && result.summary properly handles the summary?: string optional field where direct access produces TS2339 in the union context.
  • Result card error handling is correct: try/catch correctly treats UI surfacing as non-critical; workflow success still reported to console even if DB write fails.
  • Logger pattern correct: getLog().warn(...) matches the module's lazy-initialized logger pattern.
  • workerConversationId semantics correct: Same ID is correct since CLI has no separate worker conversation.
  • Minimal diff: Exactly two sendMessage calls — no new abstractions, interfaces, or config. Pure YAGNI.
  • CLAUDE.md compliance: No any types, fail-fast for dispatch, warn-level logging for non-critical result failure.
  • CLIAdapter unit tests: cli-adapter.test.ts:122-155 already verifies both metadata shapes.
  • Consistent event naming: workflow_output_surface_failed matches the orchestrator's identical log event name.

📋 Suggested Follow-up Issue

"Add workflowRunCommand integration tests for dispatch/result sendMessage calls" (P2)
Covers: dispatch fires before executeWorkflow, result card with summary, result card without summary, result card DB error suppression.


Next Steps

  1. Easy wins before merge: M1 (4-line error wrap) + M4+M5 (2-line comment updates each)
  2. 📝 Decide on M2+M3: Fix tests now, or create a follow-up issue
  3. No action needed for LOW findings

Reviewed by Archon comprehensive-pr-review workflow (4 specialized agents)
Artifacts: ~/.archon/workspaces/coleam00/Archon/artifacts/runs/477c30179cdbaf6d4cfc4dd2df6b8399/review/

…for PR #1052

- Wrap dispatch sendMessage in try/catch (matches result card pattern) to
  prevent UI notification failures from blocking workflow execution
- Update dispatch comment to accurately describe structural similarity to
  orchestrator while noting synchronous CLI semantics and that
  workerConversationId === conversationId in the CLI path
- Add note to result card comment about paused-path exclusion
- Add 4 integration tests for workflowRunCommand: dispatch ordering and
  metadata shape, result card with summary, no result card without summary,
  and non-throwing DB failure on result persist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coleam00
Copy link
Copy Markdown
Owner Author

⚡ Self-Fix Report (Aggressive)

Status: COMPLETE
Pushed: ✅ Changes pushed to archon/task-fix-github-issue-1775831868291
Philosophy: Fix everything unless clearly a new concern


Fixes Applied (6 total)

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 5
🟢 LOW 1
View all fixes
  • M1: Guard dispatch sendMessage (workflow.ts:594) — Wrapped in try/catch matching result card pattern; dispatch failure now warns and continues rather than aborting workflow execution
  • M2: Test dispatch sendMessage call (workflow.test.ts) — Added test verifying dispatch message fires before executeWorkflow with correct category, workflowDispatch, and workflowName
  • M3: Test result sendMessage paths (workflow.test.ts) — Added 3 tests: result card sent with summary, no result card without summary, non-throwing DB failure on result persist
  • M4: Fix inaccurate dispatch comment (workflow.ts:594) — Rewrote to explain structural mirror vs. intentional text difference (no emoji, no "(background)" qualifier for synchronous CLI)
  • M5: Document workerConversationId === conversationId (workflow.ts:598) — Added comment explaining CLI is both dispatcher and executor so the IDs are equal by design
  • L4: Result card comment missing paused-path note (workflow.ts:622) — Extended comment to note paused workflows are handled above and do not get a result card

Tests Added

  • sends dispatch message before executeWorkflow with correct metadata
  • sends result card when executeWorkflow returns a summary
  • does not send result card when executeWorkflow has no summary
  • does not throw and logs warn when result message DB persist fails

Skipped (3)

Severity Finding Reason
🟢 LOW L1: Dispatch not guarded (informational) Addressed by M1 fix
🟢 LOW L2: surfaceError as Error cast Pervasive codebase pattern not introduced by this PR
🟢 LOW L3: Paused-check guard equivalence not tested Low risk; clear else-if structure; not introduced by this PR

Validation

✅ Type check | ✅ Lint | ✅ Tests (77 @archon/cli + all other packages passed)


Self-fix by Archon · aggressive mode · fixes pushed to archon/task-fix-github-issue-1775831868291

@coleam00
Copy link
Copy Markdown
Owner Author

Fix Report: PR #1052 Review Findings

All 5 MEDIUM findings from the consolidated review have been addressed in commit 7cae3a10. Full validation passes.

Fixes Applied

Severity Finding What Was Done
MEDIUM M1: Unguarded dispatch sendMessage can abort workflow Wrapped in try/catch with getLog().warn(..., 'workflow_dispatch_surface_failed') — matches result card pattern
MEDIUM M2: Dispatch sendMessage not verified in tests Added test verifying dispatch fires before executeWorkflow with correct category/workflowDispatch metadata shape
MEDIUM M3: Result sendMessage not verified in tests Added 3 tests: result card with summary, no result card without summary, non-throwing DB failure path
MEDIUM M4: Comment "mirrors orchestrator.ts dispatch message" inaccurate Updated to 3-line comment explaining structural mirror vs. intentional text differences (no emoji, no "(background)" qualifier)
MEDIUM M5: workerConversationId: conversationId distinction not documented Added comment explaining CLI has no separate worker conversation so IDs are equal

Skipped (LOW, no action needed)

  • L2: surfaceError as Error cast — pervasive codebase pattern, not introduced by this PR
  • L3: Paused-check guard equivalence — low risk, clear else if structure; not introduced by this PR

Validation

bun run type-check   PASS (all 9 packages)
bun run lint         PASS (0 warnings)
bun run test         PASS (all packages, 0 failures)

coleam00 and others added 2 commits April 10, 2026 10:13
Template literals automatically coerce numbers to strings; wrapping with
String() is redundant. Removed from formatAge, formatDuration, and all
console.log calls in workflow.ts. Also compacted a two-line object
spread in workflowStatusCommand to a single line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deduplicate JSON branch in workflowStatusCommand by computing the output
array once with a single console.log call, removing the duplicated
verbose/non-verbose conditional branches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coleam00
Copy link
Copy Markdown
Owner Author

Comprehensive PR Review

PR: #1052 — fix(cli): send workflow dispatch/result messages for Web UI cards
Reviewed by: 4 specialized agents (code-review, error-handling, test-coverage, comment-quality)
Date: 2026-04-10


Summary

Clean, well-scoped PR that adds two sendMessage() calls to the CLI workflow command to surface dispatch and result cards in the Web UI. Implementation correctly mirrors the orchestrator's metadata shape, includes proper defensive error handling, and ships with 4 well-structured tests. All agents unanimously recommend APPROVE.

Verdict: APPROVE

Severity Count
CRITICAL 0
HIGH 0
MEDIUM 0
LOW 4 (deduplicated from 7 raw)

LOW Issues

Only 1 of the 4 findings is actionable — the rest explicitly recommend no change:

# Issue Location Agent Action
1 Log event names missing cli. domain prefix workflow.ts catch blocks code-review Auto-fix: rename to cli.workflow_dispatch_surface_failed and cli.workflow_result_surface_failed
2 as Error cast vs toError() utility workflow.ts:603, :641 error-handling No change — defensive catch unlikely to fire; locally consistent
3 Dispatch error path not directly tested workflow.ts:603-608 test-coverage No change — identical pattern to tested result error path
4 Dispatch comment slightly verbose workflow.ts:594-598 comment-quality No change — cross-package context is valuable
View details for Finding 1 (log naming fix)

The two new log events use flat names instead of the {domain}.{action}_{state} format. The rest of the file uses cli.* prefix (cli.codebase_lookup_failed, cli.workflow_status_failed, etc.).

// Current
'workflow_dispatch_surface_failed'
'workflow_output_surface_failed'

// Should be
'cli.workflow_dispatch_surface_failed'
'cli.workflow_result_surface_failed'

What's Good

  • Excellent scope discipline — 2 files, stays within defined boundaries
  • Strong inline documentation — cross-package context (CLI vs orchestrator) clearly documented
  • Robust defensive error handling — non-blocking try/catch on both sendMessage calls
  • High-quality tests — call-order verification, metadata shape assertions, no-summary guard, DB failure resilience
  • Clean incidental cleanupString() wrapper removal and JSON branch simplification
  • Pragmatic TS workaround'summary' in result && result.summary pattern well-documented

Next Steps

  1. Auto-fix step will apply the cli. prefix to the two log event names
  2. PR is ready to merge after the log naming fix

Reviewed by Archon comprehensive-pr-review workflow

Apply review finding: rename flat log event names to use the
cli.{action}_{state} convention matching the rest of the file.

- workflow_dispatch_surface_failed → cli.workflow_dispatch_surface_failed
- workflow_output_surface_failed → cli.workflow_result_surface_failed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coleam00
Copy link
Copy Markdown
Owner Author

Auto-Fix Report

Status: COMPLETE
Pushed: Changes pushed to PR branch


Summary

No CRITICAL or HIGH issues found by the review. Applied 1 actionable LOW fix.

Severity Fixed Skipped
CRITICAL 0 0
HIGH 0 0
LOW 1 3 (all recommend no change)

What Was Fixed

  • Log event naming (packages/cli/src/commands/workflow.ts:608,645) — Added cli. domain prefix to match the {domain}.{action}_{state} convention used throughout the file:
    • workflow_dispatch_surface_failed -> cli.workflow_dispatch_surface_failed
    • workflow_output_surface_failed -> cli.workflow_result_surface_failed

LOW Issues (No Change Needed)

These were reviewed and explicitly accepted as-is:

Issue Reason
as Error cast vs toError() Locally consistent; catch blocks are belt-and-suspenders
Dispatch error path not tested Identical pattern to tested result error path
Dispatch comment slightly verbose Cross-package context is valuable

Validation

Check Status
Type check PASS
Lint PASS
Tests PASS (112 tests)

Auto-fixed by Archon comprehensive-pr-review workflow
Commit: 5685b41d pushed to archon/task-fix-github-issue-1775831868291

@coleam00 coleam00 marked this pull request as ready for review April 10, 2026 23:27
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/workflow.test.ts`:
- Around line 998-1008: The test sets persistent mock implementations on
messagesDb.addMessage and executeWorkflow using mockImplementation(), causing
subsequent tests to inherit behavior; change both to use
mockImplementationOnce() so the custom behaviors apply only to the next call
(i.e., replace the mockImplementation(...) on messagesDb.addMessage and the one
on executeWorkflow with mockImplementationOnce(...) to avoid cross-test
pollution).
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd76f045-b5a9-4163-92a1-8ff9a4bb7511

📥 Commits

Reviewing files that changed from the base of the PR and between 6048938 and 5685b41.

📒 Files selected for processing (2)
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts

Comment on lines +998 to +1008
(messagesDb.addMessage as ReturnType<typeof mock>).mockImplementation(
async (_dbId: unknown, role: unknown, content: unknown) => {
if (role === 'assistant') {
callOrder.push(`addMessage:${String(content)}`);
}
}
);
(executeWorkflow as ReturnType<typeof mock>).mockImplementation(async () => {
callOrder.push('executeWorkflow');
return { success: true, workflowRunId: 'run-1' };
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the test file around the specified lines
cd packages/cli/src/commands
wc -l workflow.test.ts

Repository: coleam00/Archon

Length of output: 80


🏁 Script executed:

# Read the specific lines mentioned in the review
sed -n '980,1020p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 1988


🏁 Script executed:

# Look for how these mocks are initially set up - search for messagesDb and executeWorkflow mocking
rg -n "mock.module.*messagesDb|spyOn.*messagesDb" packages/cli/src/commands/workflow.test.ts | head -20

Repository: coleam00/Archon

Length of output: 41


🏁 Script executed:

# Check for executeWorkflow mock setup
rg -n "mock.module.*executeWorkflow|spyOn.*executeWorkflow" packages/cli/src/commands/workflow.test.ts | head -20

Repository: coleam00/Archon

Length of output: 41


🏁 Script executed:

# Look at the broader context of the test to understand test structure and reset patterns
sed -n '950,1050p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 4585


🏁 Script executed:

# Look at the top of the test file to see how mocking is set up
head -100 packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 3235


🏁 Script executed:

# Search for mock.module() calls in the file
rg -n "mock\.module\(" packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 746


🏁 Script executed:

# Look for beforeEach/afterEach patterns
rg -n "beforeEach|afterEach" packages/cli/src/commands/workflow.test.ts | head -10

Repository: coleam00/Archon

Length of output: 371


🏁 Script executed:

# Look at the beforeEach/afterEach patterns
sed -n '148,160p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 503


🏁 Script executed:

# Also check other beforeEach/afterEach blocks
sed -n '344,355p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 441


🏁 Script executed:

# Look at the full mock.module for messages to understand the initial state
sed -n '124,128p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 208


🏁 Script executed:

# Check more context around lines 980-1050 to see all tests in this block
sed -n '920,1120p' packages/cli/src/commands/workflow.test.ts | head -150

Repository: coleam00/Archon

Length of output: 6924


🏁 Script executed:

# Check if there's any reset/clearing of these mocks between tests
sed -n '1060,1110p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 2506


🏁 Script executed:

# Look for any patterns where tests depend on mock state
rg -n "mockClear|mockRestore" packages/cli/src/commands/workflow.test.ts | grep -A 2 -B 2 "messagesDb\|executeWorkflow"

Repository: coleam00/Archon

Length of output: 354


🏁 Script executed:

# Look at the full test structure around line 998 to see the complete test case
sed -n '987,1045p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 2780


🏁 Script executed:

# Check if the next test properly resets or has its own implementations
sed -n '1045,1120p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 3524


🏁 Script executed:

# Verify exactly what mockClear does vs what's needed - check if there's any reset of executeWorkflow in test 2
sed -n '1049,1075p' packages/cli/src/commands/workflow.test.ts

Repository: coleam00/Archon

Length of output: 1279


Use mockImplementationOnce() to prevent test isolation violations.

The mockImplementation() calls at lines 998–1008 persist beyond this test case. Since mockClear() in subsequent tests only clears call history but preserves the implementation, later tests inherit these persistent behaviors and become order-dependent. Replace both with mockImplementationOnce() to ensure each mock applies only to the next call.

Suggested change
-    (messagesDb.addMessage as ReturnType<typeof mock>).mockImplementation(
+    (messagesDb.addMessage as ReturnType<typeof mock>).mockImplementationOnce(
       async (_dbId: unknown, role: unknown, content: unknown) => {
         if (role === 'assistant') {
           callOrder.push(`addMessage:${String(content)}`);
         }
       }
     );
-    (executeWorkflow as ReturnType<typeof mock>).mockImplementation(async () => {
+    (executeWorkflow as ReturnType<typeof mock>).mockImplementationOnce(async () => {
       callOrder.push('executeWorkflow');
       return { success: true, workflowRunId: 'run-1' };
     });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(messagesDb.addMessage as ReturnType<typeof mock>).mockImplementation(
async (_dbId: unknown, role: unknown, content: unknown) => {
if (role === 'assistant') {
callOrder.push(`addMessage:${String(content)}`);
}
}
);
(executeWorkflow as ReturnType<typeof mock>).mockImplementation(async () => {
callOrder.push('executeWorkflow');
return { success: true, workflowRunId: 'run-1' };
});
(messagesDb.addMessage as ReturnType<typeof mock>).mockImplementationOnce(
async (_dbId: unknown, role: unknown, content: unknown) => {
if (role === 'assistant') {
callOrder.push(`addMessage:${String(content)}`);
}
}
);
(executeWorkflow as ReturnType<typeof mock>).mockImplementationOnce(async () => {
callOrder.push('executeWorkflow');
return { success: true, workflowRunId: 'run-1' };
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/workflow.test.ts` around lines 998 - 1008, The test
sets persistent mock implementations on messagesDb.addMessage and
executeWorkflow using mockImplementation(), causing subsequent tests to inherit
behavior; change both to use mockImplementationOnce() so the custom behaviors
apply only to the next call (i.e., replace the mockImplementation(...) on
messagesDb.addMessage and the one on executeWorkflow with
mockImplementationOnce(...) to avoid cross-test pollution).

coleam00 and others added 2 commits April 10, 2026 20:09
Prevents "Cannot read properties of undefined (reading 'status')" crash
when navigating between chat and workflow execution views during race
conditions where run data may be transiently undefined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…1052

- Fix half-applied optional chaining in WorkflowProgressCard refetchInterval
  (query.state.data?.run.status → ?.run?.status) preventing TypeError in polling
- Add dispatch-failure test verifying executeWorkflow still runs when
  dispatch sendMessage fails
- Add paused-workflow test proving paused guard fires before summary check
- Strengthen dispatch metadata assertion to verify workerConversationId format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coleam00 coleam00 merged commit 68ecb75 into dev Apr 16, 2026
@coleam00 coleam00 deleted the archon/task-fix-github-issue-1775831868291 branch April 16, 2026 12:32
ztech-gthb pushed a commit to ztech-gthb/Archon that referenced this pull request Apr 18, 2026
…for PR coleam00#1052

- Wrap dispatch sendMessage in try/catch (matches result card pattern) to
  prevent UI notification failures from blocking workflow execution
- Update dispatch comment to accurately describe structural similarity to
  orchestrator while noting synchronous CLI semantics and that
  workerConversationId === conversationId in the CLI path
- Add note to result card comment about paused-path exclusion
- Add 4 integration tests for workflowRunCommand: dispatch ordering and
  metadata shape, result card with summary, no result card without summary,
  and non-throwing DB failure on result persist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ztech-gthb pushed a commit to ztech-gthb/Archon that referenced this pull request Apr 18, 2026
…oleam00#1052

- Fix half-applied optional chaining in WorkflowProgressCard refetchInterval
  (query.state.data?.run.status → ?.run?.status) preventing TypeError in polling
- Add dispatch-failure test verifying executeWorkflow still runs when
  dispatch sendMessage fails
- Add paused-workflow test proving paused guard fires before summary check
- Strengthen dispatch metadata assertion to verify workerConversationId format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…for PR coleam00#1052

- Wrap dispatch sendMessage in try/catch (matches result card pattern) to
  prevent UI notification failures from blocking workflow execution
- Update dispatch comment to accurately describe structural similarity to
  orchestrator while noting synchronous CLI semantics and that
  workerConversationId === conversationId in the CLI path
- Add note to result card comment about paused-path exclusion
- Add 4 integration tests for workflowRunCommand: dispatch ordering and
  metadata shape, result card with summary, no result card without summary,
  and non-throwing DB failure on result persist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…oleam00#1052

- Fix half-applied optional chaining in WorkflowProgressCard refetchInterval
  (query.state.data?.run.status → ?.run?.status) preventing TypeError in polling
- Add dispatch-failure test verifying executeWorkflow still runs when
  dispatch sendMessage fails
- Add paused-workflow test proving paused guard fires before summary check
- Strengthen dispatch metadata assertion to verify workerConversationId format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…-issue-1775831868291

fix(cli): send workflow dispatch/result messages for Web UI cards
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.

fix(cli): CLI-launched workflows missing progress card, result card, and log access in Web UI chat

1 participant