cmux-next: a reopened Codex or Claude chat shows each turn's tool calls

Closed
TE
16d ago
+1544-58

Summary

Reopening a Codex chat in the cmux NEXT agent pane showed each past turn as its final message and a "Worked for 1m 32s" footer that opened nothing, even when the turn ran commands and edited files (manaflow-ai/cmuxterm-hq#2569, item 3). Codex desktop shows that work under a collapsible "Worked for".

The calls were lost in acpmux's adoption replay. adopt_replay::read turned the harness transcript into prompt and answer pairs only, so Hub::replay_adopted never appended a tool_call. The webview was fine: with no tool rows, a settled turn has nothing to fold.

Now the replay reads each turn's tool calls too (adopt_tools.rs) and appends a tool_call plus its settling tool_call_update before the answer, the same records a live turn leaves:

  • Codex: reads item_completed commands, file changes, MCP calls and web searches from current rollouts, and exec_command_end and patch events from older ones. A file change keeps each hunk as a diff and lists every file with its +/- counts in rawInput.changes. That's the data the edited-files card (item 4) needs.
  • Claude Code: each tool_use and its tool_result go through the live path's own builder. claude_stdio::tool_call_fields is now shared by inbound.rs and the replay.

In the pane, "Worked for" now opens through the existing settled-run line ("Edited files, ran commands") to "Ran 3 commands" and "Edited 2 files +4 -1", and each command opens to its line. No new chrome. The one webview change: the run summary counts edited files rather than edit calls, so one Codex change over two files reads "edited files".

Testing

Failing tests first (6931c710820), fix after:

  • cargo test -p acpmux --test hub_integration adopt_replays (Huge Blue): on the base, both new tests fail. Codex replays turn_started, user_message, agent_message_chunk, turn_end, turn_result and no tool calls. At 2c2b9a6e90e all 9 adopt tests pass. adopt_replays_a_codex_turns_commands_and_file_edits adopts a Codex Desktop-shaped rollout fixture (tests/fixtures/codex-rollout-tool-calls.jsonl). adopt_replays_a_claude_turns_tool_calls adopts a Claude Code transcript through the fake Claude harness, including a failed call.
  • The Codex test also writes and checks webviews/test/fixtures/adopted-codex-turn.events.json, the daemon's own replayed records (ACPMUX_UPDATE_FIXTURES=1 rewrites it). agent-pane-adopted-tool-calls.test.ts loads those records into the pane.
  • CMUX_BROWSER_TESTS=1 bun test test/agent-pane-adopted-tool-calls.test.ts (big-red, Chromium): on the red commit there is no "Worked for" disclosure. At 190f2a4ac8a it passes, together with agent-pane-turn-footer and agent-pane-step-rows (6 pass).
  • Also on Huge Blue: cargo test -p acpmux --lib claude_stdio (24 pass), --test chats_transcript --test chats_open (pass), cargo clippy -p acpmux --all-targets with no warnings, and cargo fmt. On big-red: tsc --noEmit, vp lint/vp fmt on the changed TS, and check:browser-lanes.

Observed / Not run

Observed: the red and green results above, at the named commits.
Not run: a cmux NEXT app build or live dogfood of adopting a real Codex chat (no Swift builds here). The full acpmux suite was not run; CI covers it.

Risk evidence (high tier)

Review: SHIP at 924fc9fe6a9cc98f29f2059de3a2af917f0d5a4e (cmux-review subagent; correctness first)
Runtime test: cargo test -p acpmux --test hub_integration adopt on Huge Blue at 924fc9fe6a9cc98f29f2059de3a2af917f0d5a4e (11 pass; cargo clippy -p acpmux --all-targets clean)

Changelog

Fixed: Reopening a Codex or Claude Code chat in cmux NEXT shows each turn's commands and file edits under "Worked for", not only the final message.

Proof

The browser test drives the pane over the daemon's replayed records: "Worked for 1m 32s" expands to "Edited files, ran commands", then to "Ran 3 commands" and "Edited 2 files +4 -1", and each command line shows. No screenshot.

Checklist

  • Behavior changes have added or updated tests
  • Localization: no new or changed strings

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Reopening a Codex or Claude chat in the cmux NEXT agent pane now shows each turn's tool calls under the "Worked for" fold, where before the adoption replay kept only prompt and answer pairs.

Bug Fixes

  • adopt_replay reads tool calls from the harness transcript, and Hub::replay_adopted replays them as tool_call and tool_call_update records before the answer, matching a live turn.
  • Codex turns read item_completed events (and older exec_command_end/patch events); Claude Code turns read tool_use/tool_result via the shared claude_stdio::tool_call_fields.
  • Each file change keeps its hunks as diffs with +/- counts for the edited-files card; a failed patch shows its error without the edits, and a hunk marked as a fragment disables whole-file Undo.
  • The run summary counts edited files, not edit calls, so a diff-less edit counts the files its input names.
  • A malformed Codex duration saturates instead of overflowing, and the adopted-rollout tests no longer need a backdated transcript.