Skip to content

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

Closed
teamleaderleo wants to merge 34 commits into
feat-cmux-nextfrom
fix/next-adopted-tool-calls
Closed

teamleaderleo wants to merge 34 commits into
feat-cmux-nextfrom
fix/next-adopted-tool-calls

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

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 (6931c71), 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 2c2b9a6 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 190f2a4 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 924fc9f (cmux-review subagent; correctness first)
Runtime test: cargo test -p acpmux --test hub_integration adopt on Huge Blue at 924fc9f (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.

Written for commit 8181f41. Summary will update on new commits.

View guided diff Turn on auto-fix

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 19, 2026 21:13 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review 8181f41: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr22155 -f ref=fix/next-adopted-tool-calls -f platform=macos -f backend_mode=local

Pending: CI is running on 8181f41947 (run); the result below was for ea0ba51b73 and no longer applies.

Last result: Yours to fix: agent-pane-adopted-tool-calls.test.ts (a file this PR changes), agent-pane-adopted-tool-calls.test.ts (a file this PR changes). Seen on other PRs too (likely flaky): agent-pane-background-tasks.test.ts, composer-history.test.ts, composer-turn-cycle.test.ts and 13 more.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); it is rewritten when this head's CI completes.

red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on 67eea14 to compare; do not merge until green; see lane-rules
red: web / Web status; NEW: green on the base 67eea14; do not merge until green; see lane-rules
red: web / react-apps-check; no finished base run on 67eea14 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (1); no finished base run on 67eea14 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (2); no finished base run on 67eea14 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (3); no finished base run on 67eea14 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (4); no finished base run on 67eea14 to compare; do not merge until green; see lane-rules

CI fast guards failed on ea0ba51b73 (https://github.com/manaflow-ai/cmux/actions/runs/39532343717). It does not block the merge; a red guard merged into main breaks it for every open PR.
The log named no failed step; see the run.

Agents: python3 scripts/ci/guard_attribution.py fix applies the mechanical fixes locally.

@blacksmith-sh

This comment has been minimized.

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect adopted agent-chat history and its pane display.

Add support for Codex’s saved function_call records before merging so those reopened chats show their commands.

Findings

  1. P1 Saved Codex commands stay hidden ▶

Summary

Restores tool calls when reopening Codex and Claude chats.

  • Reopened Codex and Claude chats show the tools each turn used.
  • The pane counts edited files by path instead of counting edit calls.
  • Partial Codex diffs no longer look like full-file changes to Undo.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Saved transcript] --> B[Read turns and tools]
  B --> C[Append tool_call]
  C --> D[Append tool_call_update]
  D --> E[Append answer and turn end]
  E --> F[Worked for disclosure]
Loading

Reviews (4) · Last reviewed commit: "Merge feat-cmux-next into fix/next-adopt..." · Reviewed by Greptile

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-oth1f created for this PR by the cmux coordinator.

@teamleaderleo

teamleaderleo commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Visual preview of ea0ba51: in the maintainers' private review feed.

@cursor

cursor Bot commented Oct 19, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

teamleaderleo and others added 5 commits October 19, 2026 19:16
A reopened Codex turn that ran commands and edited two files replays only
its prompt and final answer (hq#2569 item 3). Boundary tests: a Codex
rollout fixture and a Claude Code transcript through adoption, and a pane
browser test over the daemon's own replayed records (generated from the
Rust test; this commit's copy is the base's output, without tool calls).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adopting a chat replayed each past turn as its prompt and final answer
only, so a turn that ran commands and edited files showed the answer and
a Worked for footer that opened nothing (hq#2569 item 3).

adopt_replay now also reads the turn's tool calls (adopt_tools.rs): Codex
item_completed commands, file changes, MCP calls and web searches (and the
older exec_command_end and patch events), and Claude Code tool_use with
its tool_result through the live path's own tool_call builder. replay_adopted
appends each as a tool_call and its settling tool_call_update before the
answer, so the pane folds them under Worked for as it does a live turn's.
A file change keeps each hunk as a diff and names each file with its +/-
counts, for the edited-files card. The settled run's summary counts edited
files rather than edit calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- cargo clippy --fix cmux-tui/crates/acpmux/tests/hub_integration/fork_through.rs

Autofix-Run: https://github.com/manaflow-ai/cmux/actions/runs/39325739748
…whole-file Undo, a multi-file patch counts each file

A reopened chat's failed or declined Codex file change keeps its files and
its error text but no diffs or +/- counts: they never applied. Each
replayed hunk is marked as part of its file (_meta.acpmux.fragment), and the
edited-files card's Undo refuses a fragment. The folded run summary counts a
diff-less edit by the files its input names (toolPaths editedPaths).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@teamleaderleo
teamleaderleo force-pushed the fix/next-adopted-tool-calls branch from 122b32e to 68edd1d Compare October 20, 2026 02:30
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 02:31 — with GitHub Actions Inactive
@blacksmith-sh

blacksmith-sh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmpa7enylrg/summary-fail.json (live):/summary-fail.json (live): View Logs
/tmp/tmph1wfjce2/summary-missing.json (live):/summary-missing.json (live): View Logs

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

teamleaderleo added a commit that referenced this pull request Oct 20, 2026
… Outputs (failing)

A reopened Codex turn that edited two files (hq#2569 item 4): the card
lists each file with its counts and View changes opens the hunks (both
already drawn now that #22155 replays the edits), the chat menu lists
Changes, and the summary's Outputs lists the edited files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adopt.rs: keep both the replayed tool-call tests and the base's finished-run reopen tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +409 to +410
if s(record, "type") != Some("event_msg") {
return None;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Saved Codex commands stay hidden

codex_tool rejects every response_item, but Codex records tool calls in that format too. The checked-in Codex 0.142.2 rollout records commands as function_call and function_call_output, with no matching tool events. Reopening those chats still shows no commands under “Worked for.” Read these call/result pairs by call_id and add coverage using that rollout format.

… saturate a Codex duration

feat-cmux-next dropped the backdate helper when finished CLI chats began reopening directly
(#22139), so the merged tests no longer compiled. A malformed duration no longer overflows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 11:14 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 18:07 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 18:37 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 19:04 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 19:23 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 19:39 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 19:55 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 20:13 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 20, 2026 20:27 — with GitHub Actions Inactive
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

owner: 01a15c03-03d0-7460-8bd4-cc70444781bd

…opted-tool-calls

# Conflicts:
#	cmux-tui/crates/acpmux/src/adopt_replay.rs
#	webviews/src/agent-session/acpmux/conversation/toolRunSummary.ts
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

owner: 01a15c03-03d0-7460-8bd4-cc70444781bd

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 21, 2026 02:53 — with GitHub Actions Inactive
teamleaderleo added a commit that referenced this pull request Oct 21, 2026
…Outputs (hq#2569 item 4) (#22166)

* acpmux: test that an adopted chat replays its tool calls (failing)

A reopened Codex turn that ran commands and edited two files replays only
its prompt and final answer (hq#2569 item 3). Boundary tests: a Codex
rollout fixture and a Claude Code transcript through adoption, and a pane
browser test over the daemon's own replayed records (generated from the
Rust test; this commit's copy is the base's output, without tool calls).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* acpmux: a reopened Codex or Claude chat shows each turn's tool calls

Adopting a chat replayed each past turn as its prompt and final answer
only, so a turn that ran commands and edited files showed the answer and
a Worked for footer that opened nothing (hq#2569 item 3).

adopt_replay now also reads the turn's tool calls (adopt_tools.rs): Codex
item_completed commands, file changes, MCP calls and web searches (and the
older exec_command_end and patch events), and Claude Code tool_use with
its tool_result through the live path's own tool_call builder. replay_adopted
appends each as a tool_call and its settling tool_call_update before the
answer, so the pane folds them under Worked for as it does a live turn's.
A file change keeps each hunk as a diff and names each file with its +/-
counts, for the edited-files card. The settled run's summary counts edited
files rather than edit calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* acpmux: cargo fmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(next): PR autofix at 2c2b9a6

- cargo clippy --fix cmux-tui/crates/acpmux/tests/hub_integration/fork_through.rs

Autofix-Run: https://github.com/manaflow-ai/cmux/actions/runs/39325739748

* acpmux: a failed Codex patch replays no edits, a replayed hunk is no whole-file Undo, a multi-file patch counts each file

A reopened chat's failed or declined Codex file change keeps its files and
its error text but no diffs or +/- counts: they never applied. Each
replayed hunk is marked as part of its file (_meta.acpmux.fragment), and the
edited-files card's Undo refuses a fragment. The folded run summary counts a
diff-less edit by the files its input names (toolPaths editedPaths).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmux-next: test the edited-files card, Changes menu entry and summary Outputs (failing)

A reopened Codex turn that edited two files (hq#2569 item 4): the card
lists each file with its counts and View changes opens the hunks (both
already drawn now that #22155 replays the edits), the chat menu lists
Changes, and the summary's Outputs lists the edited files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmux-next: list Changes in the chat menu and the edited files under Outputs

The chat actions menu now lists Changes while the chat has changes, beside
its header button, as the Codex and Claude apps' chat menus do. The
summary's Outputs lists every file the chat changed: it used to drop the
last turn's files (listing them only under Changes), so a chat whose one
editing turn was the last said "Outputs: None". Changes is now the one row
that opens the turn's diff with its totals (hq#2569 item 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmux-next: Outputs keeps the files only the turn's checkpoint knows, and a reopened Codex hunk offers no Undo

A file a shell command or formatter edited is in the last turn's checkpoint
but in no tool diff: it is listed under Outputs too and opens that turn's
diff at the file, as its Changes row did. Every Outputs file row is a
summary file row, so the fourteen-file stage reads its files there. The
adopted edited-files card offers no Undo for replayed Codex hunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmux-next: an unconfirmed Claude edit shows no diff; a file the last turn changed again opens that turn's diff

A Claude Code edit cut off before its result, or refused, changed nothing: its proposed diffs wait
in PastTool.proposed and settle only with a result that did not fail, so the edited-files card and
Outputs never count them. An output the last turn changed again (a shell command after an earlier
edit tool) now opens the last turn's diff with its counts, listed once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* acpmux: adopt replay tests need no backdated transcript after #22139; saturate a Codex duration

feat-cmux-next dropped the backdate helper when finished CLI chats began reopening directly
(#22139), so the merged tests no longer compiled. A malformed duration no longer overflows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* cmux-next: Outputs matches a last-turn file to an output by exact path first

Review on #22166: a turn file's bare name ('index.ts') or a checkpoint's root file ('package.json')
matched any output ending in it, so a same-named file in another folder lost its row and opened the
wrong turn's diff. A turn file now takes the output with its own path, and a checkpoint file the
shortest output path ending in its path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style: vp fmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: cmux-autofix[bot] <cmux-autofix[bot]@users.noreply.github.com>
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Closing: this change is already on feat-cmux-next. #22166 carried this branch, and it merged as b69093a. Merging base into this branch now leaves no diff. Closed by backlog-sweep, which adopted the PR.

Agent session: cosmic-gray

This branch was previously deployed

4 inactive (3 outdated) deployments
cmux-tui-merge-tree — 8181f419 Deployed Oct 21, 2026 by teamleaderleo
artifacts — ea0ba51b Deployed Oct 21, 2026 by teamleaderleo
sentry-dsyms — ea0ba51b Deployed Oct 21, 2026 by teamleaderleo
ci-routing-agent — 2a01c946 Deployed Oct 20, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-land Reviewed at this head; next-autoland merges it into feat-cmux-next when its only reds are base reds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant