Skip to content

fix(mecatui): settle concurrent tool cards promptly - #1977

Merged
jbeda merged 2 commits into
mainfrom
fix/mecatui-concurrent-tool-completion
Sep 27, 2026
Merged

jbeda merged 2 commits into
mainfrom
fix/mecatui-concurrent-tool-completion

Conversation

@jbeda

@jbeda jbeda commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Settle Subagent, Team, and Parallel conversation-card chrome from their terminal lifecycle projections instead of leaving completed cards on the running ellipsis while a sibling remains active.
  • Keep the later outer tool.result authoritative, and retain the newest genuinely pending tool in the running footer.
  • Cover concurrent success/error completion, late authoritative results, and typed scrollback reconciliation.

Regression details

The card-header state split predates typed scrollback: from the first inline Subagent UI, subagent.end drove the terminal body while only the outer tool.result changed the header from … to ✓/✗. Historically those events were adjacent because each read-batch goroutine finalized and emitted its own result before the batch-level wait, so the mismatch was rarely visible.

Commit 409ea74e8 (feat: integrate contextual guardrails into execution and approvals) changed successful read-only execution to produce private records, wait for every sibling with wg.Wait(), and only then finalize results in call order. A fast foreground Subagent still emits subagent.end from inside its tool execution, but its outer result can now remain withheld behind a slow sibling for an arbitrarily long interval. That timing regression exposed the pre-existing Mecatui state bug.

The typed-scrollback extraction in e7e51c90b preserved the state split; it did not introduce the regression. This PR uses existing Subagent/Team/Parallel terminal projections to settle presentation during the newly long interval while retaining the later canonical result as authoritative. Generic read-only tools have no equivalent early lifecycle event and remain tracked by #1976.

Development stage

  • Plan / Interface — Bounded/Architectural behavioral and exact-interface contract; no implementation
  • Implementation — based on an approved, merged Plan / Interface PR
  • Combined — compact one-task Bounded/Architectural exception; no separate plan PR
  • Spike / Routine / Cleanup — acceptance-plan spine exempt; Spike evidence does not ship as-is

Contract linkage

  • Work classification: Routine
  • Classification rationale: Corrects Mecatui presentation using terminal lifecycle facts already present in the event stream; no engine, protocol, authority, persistence, or public interface changes.
  • Decision record: None — no durable design decision changes.
  • Human waiver of spine: No
  • Acceptance plan: N/A — Routine bug fix
  • Human decisions resolved and recorded: N/A — no new material interface decision
  • Plan / Interface PR: N/A
  • Approved commit baseline: N/A
  • Combined/exemption rationale: Routine presentation regression fix

Interface conformance

  • No public interface change. Typed scrollback now distinguishes an early terminal projection from the later authoritative tool result for presentation purposes only.

Issue relationship

Relates to #1976

Type of change

  • Behavioral/interface plan
  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation/process
  • Other (describe):

Test plan

Baseline checks

  • Acceptance-plan checker
  • Linting (task lint)
  • Fast offline test suite (task test) — all relevant suites passed; the aggregate remains red on the unrelated existing ownership assertion at environment/microvm/repository_attachment_test.go:510, reproduced independently
  • Pre-review race suite (task test:race)
  • Offline demo (go run ./cmd/mecademo)
  • Markdown changed: docs generation/link checks (task docs)
  • User docs/user-facing behavior changed: site build (task site:build)
  • Guarded engine API affected: compatibility check (task api:check)
  • Intentional engine API change: task api:update + engine/CHANGELOG.md
  • Landed plan: strict acceptance trace (task ac-trace-strict)
  • Final implementation review: /panel-review

Additional focused verification:

  • go test ./cmd/mecatui/ui ./cmd/mecatui/ui/internal/scrollback -count=1
  • task test:golden

Changes

File Change
cmd/mecatui/ui/tool_block.go Render terminal delegation/parallel glyphs before the outer result arrives
cmd/mecatui/ui/internal/scrollback/tool.go Track terminal projections separately from authoritative results
cmd/mecatui/ui/update.go Apply Parallel terminal state and preserve remaining active siblings
cmd/mecatui/ui/conversation.go Find the newest pending tool while avoiding snapshot hydration for non-tool cards
cmd/mecatui/ui/concurrent_tool_completion_test.go Exercise concurrent lifecycle and late-result permutations

User-facing change

A completed fast Subagent or Parallel card now immediately shows ✓ or ✗ while a slower concurrent sibling continues running. The footer continues naming the remaining active sibling.

Special notes for reviewers

This deliberately does not change engine result timing. Generic read-only results are still retained behind the concurrent batch barrier; #1976 tracks the Bounded follow-up and acceptance plan.

jbeda and others added 2 commits September 27, 2026 12:10
Co-authored-by: Mecatl <noreply@mecatl.dev>
Co-authored-by: Mecatl <noreply@mecatl.dev>
@jbeda
jbeda merged commit 2f769e8 into main Sep 27, 2026
41 checks passed
@jbeda
jbeda deleted the fix/mecatui-concurrent-tool-completion branch September 27, 2026 19:43
This was referenced Sep 29, 2026
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