Skip to content

feat(native-chat): model Codex MCP and web-search items instead of leaking opcodes - #18763

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/codex-item-coverage
Sep 5, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/codex-item-coverage

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​275
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​288 $\color{#cf222e}{\Huge{\mathbf{−}}}$​178 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110

What

Codex's app-server sends 19 thread-item types. The structured translator handled 6. The rest degraded in one of two ways, neither good:

  • items without streaming text fell through to a generic gray codex · item:<type> row (confirmed live for subAgentActivity)
  • items with streaming text emitted a bare status row carrying the streamed text, with no indication a tool had run at all

(Two earlier revisions of this description put mcpToolCall in that second group, via the catch-all in codexStreamingJournalItem. Both were wrong. CODEX_ITEM_STREAM_TYPES is a closed six-method map — agentMessage, plan, commandExecution, fileChange, and the two reasoning deltas — so neither mcpToolCall nor webSearch can reach that catch-all at all. Both landed in the first group: a generic gray row. The second group is real, but it is other item types.)

Either way the disposition table's own comment says it exists precisely so a new item type cannot leak. It had one entry.

This models the two that carry real tool activity and chromes the one that carries nothing:

  • mcpToolCall → a typed tool-call body (server, tool, arguments, result/error, state)
  • webSearch → a typed tool-call body (query, action, and the hits as output)
  • sleep → status-chrome

MCP tool names reach the row verbatim, always — no casing transform — qualified as server/tool. Downstream dispatch (the diff renderer, the question parsers, the tool-input previews) matches raw identifiers, so any transform would silently miss them; server/ also keeps two servers exposing the same tool distinguishable and stops an MCP tool coincidentally named apply_patch from hijacking the diff renderer.

(A first revision title-cased bare names — get_forecast became Get Forecast — and passed through only names containing :, ., / or __. That escape hatch almost never fired, because the wire field carries the bare server-advertised tool name rather than the mcp__server__tool callable namespace. It has been removed.)

Deliberately NOT hidden: the subagent items

subAgentActivity and collabAgentToolCall keep their generic rows in this PR, and there are tests pinning that.

A live probe against codex app-server 0.152.1 confirmed these arrive in real sessions today. Their gray rows are currently the only visible evidence that a subagent is running. Chroming them now — before the subagent UI exists — would make a spawned subagent's minutes of work render as a completely idle turn. A follow-up PR gives them a real display; until then, an ugly row beats no row.

Three candidates rejected after checking the schema

I originally proposed chroming four types. Checking each against Codex's generated schema and Rust source rejected three:

Type Why it stays visible
exitedReviewMode {id, review} looks opaque, but that field carries the review's overall explanation plus its full formatted findings block. Chroming it would silently swallow an entire code review's output.
enteredReviewMode Its review field carries a hint written to be shown to the user.
imageView {id, path}. Codex renders image: <path>; Orca's NativeChatBlock already has an image-ref variant keyed by path, so this is displayable content, not chrome.

Also left alone for the same reason: imageGeneration (carries result + savedPath), hookPrompt (fragments[].text), functionCallOutput and dynamicToolCall.

Only sleep survived the check — SleepItem = {id, durationMs} and nothing else, and Codex's own TUI returns None for it, so it renders as nothing there too.

The right fix for the other four is typed bodies in a follow-up, not classification. Hiding content is not the same as modelling it.

Scope guards

  • The shared ?? 'timeline-substantive' default in classifyProviderFrame is untouched — it is also the fallback for unknown Claude frames and unknown Codex notification methods, so changing it would silently affect the Claude lane.
  • hasProviderError ordering is preserved; error payloads still reach error-surface and stay exempt from the per-turn row cap.
  • Exact-name matching throughout. Item types are camelCase, where naive substring matching misfires badly ("webSearch".toLowerCase() is websearch, which does not contain "web search"; "agentMessage".includes("agent") is true).

Tests

44 passing across the two changed test files. Covers each new typed body, tool names surviving verbatim with no casing transform, argument-less and non-object MCP arguments, the five web-search shapes and their rendered labels, sleep chroming, an error payload still routing to error-surface, an unknown type still reaching the generic row — and the two subagent types still classifying timeline-substantive at both the translation and disposition layers.

The five dependent Codex journal test files were re-run green after the file split below. The changed-code quality gate reports 0 new findings across all 5 files (native, type-aware, React Doctor), and the max-lines ratchet passes.

A broad src/main/codex + src/main/native-chat sweep showed intermittent failures, but an identical rerun produced a disjoint failure set and every one of them passes in isolation. Disjoint failure sets across identical runs cannot come from a deterministic code change, and none of those files import anything this PR touches — observed, dismissed as machine load, not a regression here.

Review-loop follow-ups

Two review loops landed fixes on top of the original commit.

Validated against real captured Codex history, not hand-written fixtures. This is the strongest evidence on the PR, because both of the loop-2 defects were invisible to unit tests and to the original visual proof — the one MCP call captured there happened to have arguments. Measured over a real thread-history sample:

  • 78 of 223 webSearch items carry an empty query on a completed item (mostly action.type of other, some openPage). Those rows rendered as raw JSON, because label derivation reads top-level input keys only. The action's url, pattern and type are now hoisted beside the query — type lands on description, the lowest-ranked label key, so it names only an action carrying nothing better — while the full action object stays in the input so the expanded detail loses nothing.
  • 10 of 31 mcpToolCall items are argument-less tools sending arguments: {}, which rendered the row a literal {}. A zero-key object is now treated as absent. The previous comment claimed a null branch covered this, but arguments is required by the schema, so that branch was effectively unreachable while the case that actually occurs got the bad outcome.

Also fixed in loop 1: the {server, tool, arguments} wrapper defeated the row label the same way (every MCP row degraded to a truncated JSON blob — the arguments are now the input, unwrapped, matching the Claude lane), and webSearch dropped its results entirely, which made the typed body a net content loss against the generic row it replaced.

File split — audited as a pure move. The fixes pushed codex-structured-item-translation.ts past the 300-line cap, and a max-lines disable is not permitted, so the durable-identity concern moved to src/main/codex/codex-thread-item-identity.ts (37 effective lines; the translator is now 277). Every moved symbol — CODEX_MESSAGE_ITEM_TYPES, CodexThreadItem, isCodexMessageItemType, readCodexThreadItem, codexItemIdentity — was byte-compared against the pre-split file: no rewrite, no import cycle, and the original module re-exports them so all 7 existing importers are untouched. A reviewer should not need to redo that check.

Visual proof. The comment thread carries a re-capture on the current head. The earlier visual-proof comment is deliberately left in place: it shows the pre-fix rendering (Js {"server":"node_repl","tool":"js","arguments":{"code":"7*191"}}) and is now the receipt for two of the fixes above. A live webSearch item could not be produced — the provider reported the tool unavailable in that session — so that path is unit-tested only, and the proof comment says so rather than claiming coverage it does not have.

🤖 Generated with Claude Code

…aking opcodes

Codex's app-server sends 19 thread-item types; the structured translator handled
six. The rest fell through to a generic gray `codex · item:<type>` row, even
though the disposition table's own comment says it exists so a new item type
cannot leak like that — the table had one entry.

Give `mcpToolCall` and `webSearch` real tool-call bodies, and chrome `sleep`,
which carries only a duration and renders as nothing in Codex's own TUI.

`subAgentActivity` and `collabAgentToolCall` deliberately keep their generic
rows. They arrive in real sessions today and are currently the only visible
sign a subagent is running; hiding them before the subagent UI lands would
render minutes of work as an idle turn. Tests pin that they stay visible.

MCP tool names pass through verbatim when they contain `:`, `.`, `/` or `__`,
so `mcp__server__tool` survives instead of being title-cased into nonsense.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change moves Codex item identity helpers into a dedicated module and re-exports them. MCP translation preserves raw names and normalizes argument shapes. Web-search translation hoists action fields and serializes non-empty results. Journal dispatch handles MCP and web-search items. The provider-frame catalog classifies sleep as status chrome while preserving error precedence. Tests cover identities, translation, result handling, and frame classification.

Merge Risk: 🟡 Moderate · up to bc120

Completed MCP calls can appear without their structured results, hiding useful tool output from users. Non-text results should be preserved before release.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives detailed scope, rationale, testing evidence, visual-proof status, and AI disclosure. However, it does not provide the required Linked Issue entry or the required checklist confir… Add a linked issue using the required Fixes #<issue-number> format. Complete the checklist, including the agent skill boundary item and validation status for lint, typecheck, test, and build. Add the required ELI5, Why, Notes, and Review …
Docstring Coverage ⚠️ Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: modeling Codex MCP and web-search items instead of exposing raw opcodes.
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.
Full details: Description check

Explanation

The description gives detailed scope, rationale, testing evidence, visual-proof status, and AI disclosure. However, it does not provide the required Linked Issue entry or the required checklist confirmations.

Resolution

Add a linked issue using the required Fixes #&lt;issue-number&gt; format. Complete the checklist, including the agent skill boundary item and validation status for lint, typecheck, test, and build. Add the required ELI5, Why, Notes, and Review sections if their information is not already represented clearly.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

  • mcpToolCall typed body — models server/tool/arguments/state/result-or-error as a tool-call row, with mcpToolDisplayName keeping namespaced tool names byte-identical and title-casing only bare words.
  • webSearch typed body — models query/action and derives running/completed from the null-ness of action, matching Codex's own begin/end lifecycle.
  • sleep chromed — added to CODEX_ITEM_CLASSIFICATIONS as status-chrome, with the payload-error check still outranking it.
  • Subagent + content-bearing types left visible — subAgentActivity/collabAgentToolCall and the review/image/hook types keep their generic fallback rows, pinned by tests.

I verified the load-bearing schema claim independently against the open-source openai/codex (codex-rs) source rather than trusting the live-probe claim: McpToolCallItem (server, tool, arguments, camelCase status with a third failed value, error.message, result.content), WebSearchItem (query, Option<action>, Option<results>), and SleepItem ({id, durationMs}) all match the field names and shapes this PR reads. The one subtlety worth recording — that McpToolCallStatus also has a failed value the tests don't exercise — is already handled by commandState mapping any non-inProgress/completed status to failed. A stranded running web search (interrupted before WebSearchEnd) is also already settled to failed by interruptedBody at turn/session end, so it cannot hang permanently.

ℹ️ webSearch.results is dropped from the completed row

results carries the actual search findings (Option<Vec<JsonValue>>), but the typed body models only query/action, so a completed search shows what was asked and not what was found. This is a reasonable scope cut and not blocking — flagging only because the PR elsewhere goes out of its way to keep content-bearing fields visible, and results is a natural candidate for the same typed-body follow-up planned for the review/image types.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof

Captured on a fresh isolated dev profile (Playwright/CDP), structured Codex route enabled (experimentalNativeChat + experimentalStructuredNativeChat + openAgentTabsInChatByDefault). Structured app-server session against the local Codex CLI.

mcpToolCall — now a typed tool-call body

Codex called the node_repl MCP tool. On this branch the item renders as real typed tool-call rows — Js {"server":"node_repl","tool":"js","arguments":{"code":"7*191"}} with a Result 1337 row — instead of a gray codex · item:mcpToolCall opcode row.

after

Before (base 86cd327749d, identical journal)

The same persisted transcript rendered by the base build: the MCP turn shows only the assistant's 1337 text — the typed tool-call rows are gone. (Same translation code path that runs live, just rendered by the reverted build.)

before

Regression guard — subAgentActivity stays gray

A subagent turn still shows the gray codex · item:subAgentActivity (and collabAgentToolCall) rows on this branch — deliberately kept visible until the subagent UI lands. Visible in both screenshots above.

guard

Not captured: webSearch

Could not produce a live webSearch item. With [tools] web_search = true set in the session's managed Codex home, Codex against the configured provider did not invoke its native web-search tool — it reported "the in-app search surface isn't available in this session" and fell back to a browser/shell approach, so no webSearch thread item was emitted to render. The turn produced only response:unmatched / notification:hook/completed rows. This is a provider/backend limitation, not a rendering issue; the webSearch translation is covered by the unit tests in this PR. mcpToolCall was reachable and is shown above.

… on the row

Four fixes to the Codex MCP / web-search item bodies:

- Drop the title-casing display name. `get_forecast` became `Get Forecast`,
  which no longer matches the raw snake_case identifiers that the diff
  renderer, question parsers, and tool-input previews dispatch on, and does not
  match how the Claude lane or the sibling `shell`/`apply_patch`/`web_search`
  bodies name a tool. The row name is now `server/tool` verbatim, the bare
  `tool` when no server is given, and `mcp` when the item names no tool at all.
  Server-qualifying also stops an MCP tool that happens to be called
  `apply_patch` from hijacking the diff renderer.

- Pass the MCP call's own `arguments` as the tool input instead of wrapping it
  in `{server, tool, arguments}`. Row-label derivation only reads top-level
  keys, so the wrapper degraded every MCP row to a truncated raw JSON blob.
  A non-object `arguments` stays addressable under a key rather than being
  dropped; an absent one becomes null, which labels as empty rather than `{}`.

- Carry a web search's `results` as the call output, bounded like every other
  inline payload and omitted when there are none. They were being dropped
  entirely, which showed less than the generic fallback row it replaced.

- No streaming branches were added for these two item types: the Codex delta
  stream is a closed set of six methods that neither can reach, so such
  branches would be unreachable.

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

  • mcpToolCall name now verbatim — the raw tool identifier is emitted (server/-qualified when a server is present, mcp when the tool is missing) instead of title-casing bare words, so downstream exact-match dispatch (the diff renderer's EDIT_TOOL_NAMES) can actually match identifiers like str_replace/apply_patch rather than the Str Replace the old transform produced.
  • mcpToolCall input is the call's own arguments — arguments are the input directly so the row label can read query/command/file_path out of them; scalar/array args wrap under {arguments: …} and an absent arg is null (labels empty, not {}).
  • webSearch results now surface as output — results is JSON-stringified and bounded into the completed row's output, resolving the prior review's note that search hits were dropped.

I traced the verbatim-name change through its consumers to confirm no regression: diffFromToolCall (EDIT_TOOL_NAMES) is exact-match so the raw name only fires for genuinely edit-shaped tools; COMMAND_TOOL_NAMES lowercases (normalizedToolName) so the icon/verb gating is unaffected; and createToolInputDisplay(null) handles the now-possible null input cleanly (empty label, no detail). The two changed test files pass (42 tests), with exact toEqual/toMatchObject/not.toHaveProperty assertions rather than loose ones.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

A row label is derived from top-level `input` keys only, so a webSearch
whose detail lives inside `action` — an opened page, an in-page find, or
a bare `other` — fell through to the raw JSON of the whole input, as did
the empty `query` Codex leaves on a completed search. Hoist the action's
`url`, `pattern` and `type` beside the query, keep the full `action`
object so the expanded detail loses nothing, and emit no input at all for
the start frame.

An MCP tool that takes no arguments sends `arguments: {}`, which passed
straight through and labelled the row a literal `{}`; treat it as absent
so the row reads as a bare `server/tool`.

Split the durable-identity half of the item translator into
`codex-thread-item-identity.ts`, re-exported so every existing import is
unchanged, to keep both files under the max-lines cap.

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

  • Argument-less MCP calls render as a bare server/tool row — mcpToolArguments now maps {} (the arguments: {} shape an argument-less MCP tool actually sends on the wire) to null, so the row labels itself with the tool name instead of a literal {}.
  • Web-search actions hoist labelable fields to the top level — the new webSearchInput lifts url, pattern, and the action type (landing on description, the lowest-ranked label key) beside query, so every WebSearchAction shape (search / openPage / findInPage / other) resolves to a real row label instead of the input's raw JSON, while the whole action stays for the expanded detail.

I verified the newly load-bearing WebSearchAction wire contract against the real codex-rs source rather than trusting the live-probe claim: it is #[serde(tag = "type", rename_all = "camelCase")] with Search { query, queries }, OpenPage { url }, FindInPage { url, pattern }, and #[serde(other)] Other, so the discriminator and every field name the helper reads are correct, and readString correctly rejects the Option fields that serialize as null. Both changed test files pass (44 tests), with exact toEqual/toBe assertions over every web-search shape.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof (post-review-loop) — supersedes the earlier visual-proof comment

Captured on head c4a782c7a4d with a fresh isolated dev profile (Playwright/CDP). Settings: experimentalNativeChat, experimentalStructuredNativeChat, openAgentTabsInChatByDefault. Structured Codex app-server session against the local Codex CLI. Folder workspace, not a git worktree.

This capture is after the two review-loop fix commits (6136dce identity/input, c4a782c web-search labels + argument-less MCP). It supersedes the earlier visual-proof comment, which still showed the pre-fix row Js {"server":"node_repl","tool":"js","arguments":{"code":"7*191"}}. That comment was left in place; this one is the current-head proof.

1. mcpToolCall with arguments — MATCHED

Same node_repl / js call as the stale proof (7*191 → 1337). On current head:

  • Row name is the raw identifier node_repl/js (not title-cased Js).
  • Row label is the tool's own arguments {"code":"7*191"}, not the {"server":...,"tool":...,"arguments":...} wrapper JSON.

Collapsed row:

mcp js collapsed

Expanded detail still has the full input and result (nothing dropped to make the label):

mcp js expanded

2. Argument-less MCP call — MATCHED

node_repl/ping takes no arguments. The row reads as a bare node_repl/ping with no literal {} label. Expanded result still shows the full pong output.

Collapsed row:

mcp ping collapsed

Expanded result:

mcp ping expanded

3. webSearch — NOT REPRODUCED

Could not produce a live webSearch thread item. Codex replied that the native web_search tool is unavailable in this session and did not emit a tool-call row (turn details expand to the assistant sentence only). Same provider/backend limitation as the earlier proof; not a rendering issue. The webSearch translation remains unit-tested on this branch.

web search unavailable

Checklist

Claim Result
MCP row name is raw server/tool, no title-casing Matched (node_repl/js, node_repl/ping)
MCP row label comes from the tool's own arguments, not the wrapper JSON Matched ({"code":"7*191"})
Argument-less MCP call shows no literal {} Matched (bare node_repl/ping)
Web search row shows a human-readable label, not raw JSON Not reproduced — no webSearch item fired
Expanding a row still shows full detail Matched for both MCP cases

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop status — merge-ready at c4a782c7a4d

Two review loops ran against this PR. Both found real defects; both are fixed and pushed. A third pass came back clean, and the rendering is now visually proven on the real UI.

Loop 1 — 6136dce860b

Three defects, all inside the surface this PR introduced.

MCP tool names were title-cased. mcpToolDisplayName turned get_forecast into Get Forecast, passing through only names containing :, ., / or __. That was wrong on every axis: the Claude lane passes tool.name verbatim, the sibling Codex bodies in the same file emit raw shell / apply_patch / web_search, and downstream dispatch is exact-match on raw snake_case identifiers (TOOL_INPUT_KEYS, EDIT_TOOL_NAMES, QUESTION_TOOL_PARSERS), so a title-cased name silently missed all of it. The verbatim escape hatch also almost never fired, because the wire field carries the bare server-advertised tool name rather than the mcp__server__tool callable namespace. The function is deleted; the row name is now server/tool, which additionally stops a coincidentally-named MCP tool from hijacking the diff renderer.

The {server, tool, arguments} input wrapper defeated the row label. Label derivation reads only top-level keys of input, so every MCP row degraded to a truncated JSON blob. The call's own arguments are now the input, unwrapped — the same shape the Claude lane uses.

webSearch dropped its results. The old generic fallback row serialized the whole item, so as written the PR was a net content loss for a real web search. Results now ride as the bounded call output.

Also checked and deliberately not changed: the PR description says MCP items hit the catch-all in codexStreamingJournalItem. They cannot — CODEX_ITEM_STREAM_TYPES is a closed six-method map that neither new type appears in. Branches there would be unreachable dead code, so none were added. Worth correcting in the description.

Loop 2 — c4a782c7a4d

Two more instances of the same class — a row label is derived from top-level keys only — left in the sibling paths. Both were measured against a real Codex thread-history sample rather than argued from theory.

webSearch rendered raw JSON on about a third of real rows. 78 of 223 sampled webSearch items carry an empty query on a completed item (mostly action.type of other, some openPage), so the row read {"query":null,"action":{"type":"other"}}. This also refutes the original code comment's claim that Codex completes the item with both fields. The action's url, pattern and type are now hoisted beside the query — type lands on description, the lowest-ranked label key, so it names only an action carrying nothing better — while the full action object stays in the input so the expanded detail loses nothing.

arguments: {} labelled the row a literal {}. 10 of 31 sampled MCP items are argument-less tools. The previous comment claimed the null branch covered this, but arguments is schema-required, so that branch was effectively unreachable while the case that actually occurs got the bad outcome. A zero-key object is now treated as absent.

One structural change worth calling out

These fixes pushed codex-structured-item-translation.ts past the 300-line cap, and a max-lines disable is not permitted. The durable-identity half was therefore split into src/main/codex/codex-thread-item-identity.ts (37 effective lines; the translator is now 277). This was audited as a pure move: every moved symbol was byte-compared against the pre-split file, there is no rewrite and no import cycle, and the original module re-exports them so all seven existing importers are untouched.

Deliberately unchanged

sleep classified as status-chrome, and subAgentActivity / collabAgentToolCall keeping their generic visible rows until the sibling PR gives them a real display. MCP failure derivation, the action-as-completion-signal rule, the shared timeline-substantive default and the hasProviderError ordering were all reviewed and confirmed correct as written.

Verification

  • 44 tests green across the two changed test files; the five dependent Codex journal test files re-run green after the split.
  • Changed-code quality gate: 0 new findings across all 5 files (native, type-aware, React Doctor). max-lines ratchet OK.
  • Visual proof on the real UI is in the comment above, on a fresh isolated dev profile: node_repl/js renders with the raw server/tool name and its own arguments as the label, and the argument-less node_repl/ping renders bare with no {}. A live webSearch item could not be produced — the provider reported the tool unavailable in that session — so that path remains unit-tested only, and the proof comment says so rather than claiming otherwise.
  • A broad src/main/codex + src/main/native-chat sweep showed intermittent failures, but an identical rerun produced a disjoint failure set and every one of them passes in isolation. None of those files import anything this PR touches; this is machine-load flakiness, not a regression.

Merge-ready.

…em-coverage

The one conflict was the tool-summary import in
codex-structured-item-translation.test.ts; both arms are kept, since the
merged file calls briefToolArg, createToolInputDisplay and describeToolInput.

Combining both sides' additions pushed
codex-structured-item-translation.ts to 325 effective lines against a
300-line cap, so this merge also splits it. Two pure moves, no behaviour
change:

- codex-item-field-readers.ts: readRecord, readString, readFirstString and
  readTextContent, the readers the whole translation module uses.
- codex-command-action-class.ts: CommandActionClass, COMMAND_ACTION_CLASSES
  and commandActionFacts, Codex's own shell-call classification.

The readers move rather than stay and re-export because the classification
module needs them; leaving them behind would make the two modules a cycle.
Both new modules are leaves; no existing importer changes.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 84fb7b35-3096-42e7-a635-fd5dac8764e5

📥 Commits

Reviewing files that changed from the base of the PR and between ddc5b75 and bc12030.

📒 Files selected for processing (7)
  • src/main/codex/codex-command-action-class.ts
  • src/main/codex/codex-item-field-readers.ts
  • src/main/codex/codex-structured-item-translation.test.ts
  • src/main/codex/codex-structured-item-translation.ts
  • src/main/codex/codex-thread-item-identity.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/main/codex/codex-thread-item-identity.ts
  • src/main/codex/codex-structured-item-translation.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


function mcpToolCallItem(item: CodexThreadItem): CodexJournalItem {
const failure = readString(readRecord(item.error), 'message')
const text = failure ?? readTextContent(readRecord(item.result), 'content')

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve non-text MCP results.

mcpToolCallItem reads only result.content as text. A successful result that contains only structuredContent, metadata, or non-text content creates a completed row with no output. Serialize the complete result, or use it as a fallback when no text content exists, before applying boundInlineText. Codex MCP results include content, structuredContent, and metadata. (github.com)

Proposed fix
-  const text = failure ?? readTextContent(readRecord(item.result), 'content')
+  const result = readRecord(item.result)
+  const text =
+    failure ??
+    readTextContent(result, 'content') ??
+    (Object.keys(result).length > 0 ? JSON.stringify(result) : null)
📝 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
const text = failure ?? readTextContent(readRecord(item.result), 'content')
const result = readRecord(item.result)
const text =
failure ??
readTextContent(result, 'content') ??
(Object.keys(result).length > 0 ? JSON.stringify(result) : null)

@brennanb2025
brennanb2025 merged commit 471a5f4 into main Sep 5, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…aking opcodes (stablyai#18763)

* feat(native-chat): model Codex MCP and web-search items instead of leaking opcodes

Codex's app-server sends 19 thread-item types; the structured translator handled
six. The rest fell through to a generic gray `codex · item:<type>` row, even
though the disposition table's own comment says it exists so a new item type
cannot leak like that — the table had one entry.

Give `mcpToolCall` and `webSearch` real tool-call bodies, and chrome `sleep`,
which carries only a duration and renders as nothing in Codex's own TUI.

`subAgentActivity` and `collabAgentToolCall` deliberately keep their generic
rows. They arrive in real sessions today and are currently the only visible
sign a subagent is running; hiding them before the subagent UI lands would
render minutes of work as an idle turn. Tests pin that they stay visible.

MCP tool names pass through verbatim when they contain `:`, `.`, `/` or `__`,
so `mcp__server__tool` survives instead of being title-cased into nonsense.

* fix(native-chat): keep Codex MCP tool identity and web-search results on the row

Four fixes to the Codex MCP / web-search item bodies:

- Drop the title-casing display name. `get_forecast` became `Get Forecast`,
  which no longer matches the raw snake_case identifiers that the diff
  renderer, question parsers, and tool-input previews dispatch on, and does not
  match how the Claude lane or the sibling `shell`/`apply_patch`/`web_search`
  bodies name a tool. The row name is now `server/tool` verbatim, the bare
  `tool` when no server is given, and `mcp` when the item names no tool at all.
  Server-qualifying also stops an MCP tool that happens to be called
  `apply_patch` from hijacking the diff renderer.

- Pass the MCP call's own `arguments` as the tool input instead of wrapping it
  in `{server, tool, arguments}`. Row-label derivation only reads top-level
  keys, so the wrapper degraded every MCP row to a truncated raw JSON blob.
  A non-object `arguments` stays addressable under a key rather than being
  dropped; an absent one becomes null, which labels as empty rather than `{}`.

- Carry a web search's `results` as the call output, bounded like every other
  inline payload and omitted when there are none. They were being dropped
  entirely, which showed less than the generic fallback row it replaced.

- No streaming branches were added for these two item types: the Codex delta
  stream is a closed set of six methods that neither can reach, so such
  branches would be unreachable.

* fix(native-chat): label Codex web searches and argument-less MCP calls

A row label is derived from top-level `input` keys only, so a webSearch
whose detail lives inside `action` — an opened page, an in-page find, or
a bare `other` — fell through to the raw JSON of the whole input, as did
the empty `query` Codex leaves on a completed search. Hoist the action's
`url`, `pattern` and `type` beside the query, keep the full `action`
object so the expanded detail loses nothing, and emit no input at all for
the start frame.

An MCP tool that takes no arguments sends `arguments: {}`, which passed
straight through and labelled the row a literal `{}`; treat it as absent
so the row reads as a bare `server/tool`.

Split the durable-identity half of the item translator into
`codex-thread-item-identity.ts`, re-exported so every existing import is
unchanged, to keep both files under the max-lines cap.

---------

Co-authored-by: Merge Sim <sim@local>
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