Repository navigation
fix(native-chat): pass agent-implemented slash commands through to the agent - #19929
Conversation
…e agent Claim what the host implements; pass through what the agent implements. Claude's harness expands a slash command out of the message text, so the host claimed catalog commands it had no way to run and answered "/init is not available in chat sessions" for commands Claude does run. Codex's app-server has no slash parser at all, so its catalog stays claimed — except /goal, which the model carries out through its own goal tools.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds agent profile metadata for text-driven and harness-expanded slash commands. It adds helpers for text-driven and host-claimed commands. The structured composer uses the active agent to build menus and route host commands. The mobile send bridge applies agent-specific reconciliation. Tests cover command ownership, structured routing, unsupported commands, and attachment handling. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Per-agent host-claim policy —
native-chat-agent-profiles.tsaddsexpandsSlashCommandsFromText(Claude-family) andtextDrivenCommands(Codexgoal) and a newgetHostClaimedNativeChatCommandsthat applies them. - Dispatcher consults the host-claimed set —
structuredRecognizedCommandsnow unions the four host commands withgetHostClaimedNativeChatCommandsinstead of the raw catalog, so/init/review/help(Claude) and/goal(Codex) reach the agent as text. - Attachment-guard contract made explicit —
isStructuredAgentSessionComposerCommandnow means "the host owns this command", with a doc comment stating it for the next caller. - Tests — new coverage for the profile policy, the dispatcher pass-through/refusal split, and the renderer attachment guard end-to-end.
The change is precisely scoped: for Codex the only behavioral delta is /goal (everything else in its catalog stays claimed and refused), and for Claude the only delta is the three catalog commands its harness genuinely implements. I verified the two load-bearing domain claims against the code — claudeDispatchInvokesSlashCommand already mirrors the SDK's "trailing / text runs a command" rule (comment says "verified against the real CLI over stream-json"), and the Codex structured turn is sent as raw turn/start input with no slash parse, with goal tool + thread/goal/* notifications supporting the model-owned-goal claim. The new tests assert exact values (not loose truthiness) and passed locally (34/34).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Codex reports no command catalog, so its structured `/` menu is the host fallback -- which listed only the host's own commands and hid `/goal`, the one command the model itself acts on. The picker now appends the profile's text-driven commands, described from the curated catalog, so a command that passes through is discoverable and not merely typable. The menu invariant holds either way: a pick is answered by the host or run by the agent, never refused with "not available in chat sessions".
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Text-driven command mirror —
getTextDrivenNativeChatCommandsinnative-chat-agent-profiles.tsreturns the catalog entries whose names are in the profile'stextDrivenCommands, mirroring the claimed set. - Pick the offer for agent-run commands —
structuredSlashCommandsnow takes anagentand appends the text-driven commands, so Codex's/goalis discoverable in the fallback/menu (Codex reports no catalog) and not merely typable. - Callers pass
agent— bothuseNativeChatComposerCatalogandMobileNativeChatComposerthread the agent through so the menu matches the dispatcher's pass-through policy. - Tests — exact-value coverage for menu/dispatcher sync (every offered row is either host-answered or passes through), Claude non-regression, and Codex
/goaldiscovery.
The change stays symmetric with the first commit's host-claim policy: getTextDrivenNativeChatCommands returns exactly the complement that getHostClaimedNativeChatCommands unclaims, so the offered-but-unclaimed set for Codex is precisely ['goal'] and the "menu pick is never refused" invariant holds. All four changed test files plus the desktop composer test pass locally (42/42 and 25/25).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Per-agent host-command reconciliation on mobile —
useMobileStructuredNativeChatSendBridgenow takes anagentand computesisStructuredAgentSessionComposerCommand(text, agent)once, replacing the hardcoded union over'codex'and'claude'. - Agent threaded through the controller —
useMobileNativeChatControllerpassesactiveChatResolution?.agent === 'claude' ? 'claude' : 'codex', mirroring the existing normalization inuse-mobile-structured-agent-session.ts. - Tests — a new
use-mobile-structured-native-chat-send-bridge.test.tscovers the optimistic echo for a passed-through/init, the unconfirmed-hold for/reviewon Claude, and the restored-draft path for a Codex host command.
The prior bridge checked whether either agent claimed a command, so a command Codex claims but Claude passes through (e.g. /init, /review, both present in both catalogs) was reconciled as a host command in a Claude session — no optimistic bubble on accepted, and a wrongly restored draft on unknown. Routing the check through the actual agent fixes that. The mapping is closed because structured sessions only resolve to claude or codex (isAgentSessionHandleProvider), and it matches the dispatch path's own agent === 'claude' ? 'claude' : 'codex' normalization. The new tests assert exact calls, and the first two fail against the old union logic, so they pin the fix rather than just observing it.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status: readyFinal reviewed head: 7b590f8. The PR is mergeable, the branch is synchronized, and all current GitHub checks are green. Meaningful fix made during reviewThe review found that mobile structured-send reconciliation classified slash commands against a union of provider catalogs instead of the active provider. That could suppress the optimistic echo for accepted Claude commands and mishandle uncertain sends. The branch now uses the same active-agent ownership policy as desktop and shared dispatch. The focused fix was pushed without expanding product scope. Review and readiness verdict
Validation
Rendered Electron evidenceCaptured over hidden CDP with ORCA_BACKGROUND_LAUNCH=1. The capture preceded the final main sync; that sync preserved these command paths unchanged.
Host-owned control: Codex /model remains host-handled and does not start a new agent response. QA limitations
|






What changes for you
Before — a slash command the agent itself implements was refused by the chat host, and nothing was sent:
/init,/reviewand/helpanswered "/init is not available in chat sessions. Use the slash menu to see available commands." — even though Claude's own harness implements them and would have run them./initis even offered in Claude's slash menu, so picking it from the menu produced the refusal too./goal <objective>was refused the same way.After — the host claims only the commands it implements (
/clear,/compact,/model,/effort); a command the agent implements is sent on as the message text and actually runs:/initreaches Claude, which analyses the project and writesCLAUDE.md./goalis now listed in the/menu, and/goal <objective>reaches the model, which opens a real goal and works the objective.A hand-typed
/clearis still answered by the host and never sent to the model as literal text — claiming remains the default for every agent that has no pass-through policy.Before / after, on a real build
Both runs use the same throwaway folder workspace and the same typed command. "Before" is a dev build of
main(12f2c6b991); "after" is a dev build of this branch (9eab58a823). Captured over CDP against the rendered app.Claude —
/initmain): refused, nothing sentCLAUDE.mdcreatedIn the "after" shot the user bubble is the
/initthe user typed, the turn reads Worked for 44s, andCLAUDE.mdhas appeared in the file tree on the right.Codex —
/goal Add a unit test for countWidgetsmain): refused, nothing sentThe Codex session rollout for that run records the model calling
create_goal({objective: "Add and verify a focused unit test for countWidgets"})and, once the test passed,update_goal({status: "complete"})— so/goalas prose really does reach the model's goal tools.And
/goalis now discoverable, not just typableCodex reports no command catalog, so its structured
/menu is the host's fallback list — which offered only the host's own commands and hid/goaleven after it started working. The picker now also offers the commands the agent itself runs from message text, described from the curated catalog:/menu now lists/goalClaude's menu is unchanged: it reports its own catalog, so it takes the session-reported branch and never reaches this fallback.
The principle
Claim what the host implements; pass through what the agent implements.
dispatchStructuredAgentSessionComposerCommanddecides the fate of every/commandtyped into a structured native chat session. Anything in its recognized set is claimed by the host; anything else falls through and is sent to the agent as ordinary message text. Until now the recognized set was the host's own commands plus the whole per-agent curated catalog — which is wrong whenever the agent itself implements the command.The two providers differ fundamentally:
/goal: the model owns goal tools and callscreate_goalitself when/goal <objective>arrives as prose.So the policy is per-agent, and
src/shared/native-chat-agent-profiles.tsalready declares itself the single place that kind of policy lives. It now carries two fields:expandsSlashCommandsFromText— Claude and OpenClaude. The host claims nothing from the catalog; it keeps only its own four (clear,compact,model,effort).textDrivenCommands— Codex's['goal']. An explicit, narrow allowance, not a blanket unclaim.getHostClaimedNativeChatCommands(agent)applies that policy, and the composer'sstructuredRecognizedCommandsconsults it instead of the raw catalog. No agent checks were added to the dispatcher.Claiming stays the default. An agent with no policy (and the
custom-agentfallback) still has its whole catalog claimed, so a hand-typed/clearis answered by the host and never reaches the model as literal prompt text. That protective intent is what the recognized set is for, and it is untouched.getVerifiedNativeChatCommandsis deliberately unchanged — send classification, collision detection, transcript envelope surfacing, and the mobile composer all key off it, and none of those want the host-claim distinction.Bugs fixed
/initon Claude answered "/init is not available in chat sessions" —initis inCLAUDE_COMMANDS, so the host claimed and refused a command Claude implements and would have run. It now passes through./reviewon Claude — identical mechanism, identical fix.(
/helpon Claude was refused by the same mechanism and now passes through too.)/goalon Codexgoalis inCODEX_COMMANDS, so/goal <objective>was refused. It now passes through as text, where the model's own goal tools create a real goal. Every other Codex catalog command stays claimed and refused, because sending e.g./permissionsor/vimas text would just be garbage in the transcript.Attachment guard: decision
isStructuredAgentSessionComposerCommandis also the attachment guard inuse-native-chat-structured-composer-send.ts("Remove attachments before using a chat-session command."). No code change there — and that is the point.The predicate's meaning is now precisely "the host, not the agent, owns this command", which is exactly the condition the guard wants:
/clear,/compact,/model,/effortstill refuse.transport.send(text, attachments), so refusing would be a regression./init,/reviewand/goal <objective>now send normally with their attachments.The same predicate change makes the mobile bridge and the desktop draft-preservation path correct for free: a passed-through command is a real chat turn, so it gets its optimistic bubble and clears the composer like any other send.
The function's doc comment now states this contract so the next caller does not have to infer it.
Discoverability: the structured picker
structuredSlashCommands()builds the/menu for a structured session whose host reports no catalog of its own — which is every Codex session. It took no agent, so it could only ever offer host commands, and/goalwas invisible in the one place a user looks for it.It now takes the agent and appends
getTextDrivenNativeChatCommands(agent)— the exact mirror of the claimed set, resolved against the curated catalog so the row carries the description that already exists (goal→ "Set or view the goal"). Nothing was added toCODEX_COMMANDS: a name added there would be claimed-and-refused unless it were also intextDrivenCommands, which is the coupling this PR documents. A name already offered by the host is not duplicated.The menu invariant is preserved and now stated in the terms the change requires: a row the user picks is either answered by the host or run by the agent — never refused. The existing
NativeChatComposertest that pinned the Codex menu to an exact list now pins['model', 'effort', 'goal'], and the shared test walks every offered row through the real dispatcher asserting none of them produces the "not available in chat sessions" refusal.Callers updated:
use-native-chat-composer-catalog.ts(desktop) andMobileNativeChatComposer.tsx(mobile) both pass their agent.Validation (picker commit
fce181473d)Ablation — new/updated tests kept, all four prod files reverted to
9eab58a823:The three failures are one per surface: the shared picker, the desktop hook, and the rendered composer. A second arm reverting only the desktop caller failed exactly one test (the hook), so the caller wiring is pinned independently rather than riding on the shared change.
Gates (all gated on exit status):
pnpm run typecheck:tsc— exit 0, 0error TS(non-incremental, all three projects; the incrementalpnpm tccan pass on a stale tsbuildinfo)pnpm run check:code-quality:changed— exit 0: 0 new findings across 9 changed filespnpm run check:react-doctor:changed— exit 0pnpm run audit:code-quality:native— exit 0 (repo-wide,--deny-warnings)pnpm test src/shared src/renderer/src/components/native-chat— 8997 passed, 0 failed, 117 skipped (813 files). The first sweep caught one real regression —NativeChatComposer.test.tsxpinned the Codex menu to an exact['model', 'effort']— which is updated in this commit rather than worked around.Not verified locally:
mobile/node_modulesis empty in this worktree, so mobile's ownvitestandtsc --noEmitcannot run — reverting the mobile edit reproduces the identicalexpo/tsconfig.base.jsonresolution error, so the failure is environmental and pre-existing. The mobile change is one argument on an existing call; it is covered by CI.Validation (pass-through commit
9eab58a823)Ablation — new tests kept, both source files reverted to base
721a269289:Gates (all gated on exit status):
pnpm tc— exit 0pnpm run check:code-quality:changed— exit 0: 0 new findings across 5 changed files (code quality, type-aware, React Doctor)pnpm test src/shared src/renderer/src/components/native-chat— 8988–8992 passed of 9110. Five failures across two full runs, allTest timed out/ socket-timing under load, a different set each run, and all four files pass in isolation (41/41, exit 0):feature-interactions,export-let-function-initializer-ban,remote-runtime-shared-control-connection,NativeChatMessageList.tool-stream-cost. None touch command dispatch.Coverage added
src/shared/structured-agent-session-composer.test.ts—/init,/review,/helppass through on Claude;/clear,/compact,/model,/effortstill claimed on Claude;/goal ship the fixpasses through on Codex;/permissionsstill refused on Codex with its original message.src/shared/native-chat-agent-profiles.test.ts— the policy itself: Claude-family claims nothing, Codex claims everything butgoal(while the verified catalog still lists it), unpolicied agents claim their whole catalog.src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.test.tsx(new) — the attachment guard end-to-end through the real dispatcher: refuses on host-claimed commands, sends with attachments on passed-through ones.