Skip to content

fix(native-chat): one / picker for every agent, anywhere in the prompt - #19832

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-picker-parity
Sep 10, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-picker-parity

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​237 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​191
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​105 $\color{#cf222e}{\Huge{\mathbf{−}}}$​91 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14

ELI5

Typing / in native chat only did something if / was the very first character you typed. Say "validate it with /electron" and nothing came up. And the box behaved differently depending on the agent: Claude put skills under /, Codex hid them under $. Now / works everywhere, for every agent, and shows the same one list of commands and skills.

What Changed

  • / is the composer's only trigger. It opens one grouped commands + skills menu for every agent with a known grammar, at the start of the draft and mid-prompt after whitespace.
  • The $ trigger is removed. Nobody has to learn a different prompt box per agent.
  • Codex's / menu now lists skills, which it never did before.
  • Each row carries the token it will insert. Picking a skill writes /electron for Claude and $electron for Codex — the form that agent actually invokes.
  • Only a draft-leading command is dispatchable. Picking a command mid-sentence completes the token into your draft instead of firing the command on its own and throwing away what you wrote.
  • Name collisions are resolved only when both kinds invoke through the same sigil, so a Codex /review command and a $review skill stay as separate rows.
  • A mid-prompt token stops at the next /, so open /Users/me/notes stays prose.

Why

Two problems. The picker's trigger was anchored to draft position 0, so mid-sentence skill references — the way people actually write them — produced nothing. And the composer's grammar was per-agent, which means every new agent we support is another prompt-box behavior to design, explain, and maintain.

One typed grammar, per-agent invocation. The translation happens when a row is accepted, not at send time, and that placement is load-bearing: the PTY lane branches on the literal draft text to decide typed-vs-pasted delivery, send classification is shared with mobile and reads the same plain text, and the draft cache persists the composer document across pane switches. Translating later would desync all three. Because the accepted token is agent-native, invocation still works on both agents: a Codex skill lands as $electron and is pasted (the existing delivery test pins this), a Codex command still dispatches typed into the TUI, and Claude is unchanged.

Deliberate deviations worth a reviewer's attention:

  • Agent grammar stays renderer-side. The structured lane already reports its own catalog, but the grammar is still local policy in the agent profile, stamped per item at build time. An alternative is having the execution host announce its trigger characters and answer completions for a given cursor offset; that would be a larger change and is not what this does.
  • Behavior removed, not just added. The $ popup is gone. Typing $name by hand still sends and classifies exactly as before — only the autocomplete surface for it is removed.
  • A $ token can appear in a / menu row for Codex, because that row shows what will be inserted. The composer pill hides the sigil once accepted. Easy to change to a bare name if reviewers prefer.

Linked Issue

No issue — reported directly.

Visual Proof

Validated on f6f6095 in the real desktop Codex native-chat composer through Playwright CDP with a disposable local profile and hidden renderer. Keyboard input opened the slash picker at draft start and after whitespace, displayed Commands and Skills together, and accepted a Codex skill as its native $skill-creator pill. Enter completed mid-prompt /mod to /model, preserving the surrounding prose without sending; draft text/document caches and a chat/terminal round trip confirmed the skill token.

Before typing · Draft-start slash menu · Grouped commands and skills

Mid-sentence skill menu → Inserted skill pill

Mid-prompt command menu → Completed draft with surrounding prose

Scope: desktop Codex composer only; provider execution, other agents, mobile, and remote/platform-specific flows were not exercised.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Automated, all green:

  • pnpm test src/renderer/src/components/native-chat/ src/shared/native-chat-agent-profiles.test.ts — 126 files, 1271 tests
  • pnpm test src/shared/ — 688 files, 7633 tests
  • tsc -p config/tsconfig.tc.web.json, config/tsconfig.node.json, config/tsconfig.tc.cli.json — clean
  • pnpm run check:code-quality:changed — 0 findings; oxfmt --check clean
  • pnpm build not run locally; leaving that to CI

Tests deliberately rewritten because they encoded the old per-agent grammar, not because they broke:

  • keeps Codex commands under slash and skills under dollar → now asserts one / menu with both kinds and per-item tokens
  • keeps Codex dollar skills separate from slash commands (profiles) → now asserts skillPrefix only governs the written token
  • the $-trigger derivation block → now asserts $ is inert and Codex skills come from /

Left alone on purpose, because they pin delivery rather than menu policy: types Codex slash composer sends instead of pasting them and keeps Codex skill sends pasted.

Review

Worth challenging: whether accept-time translation is the right ownership model versus a host-announced grammar; whether showing $electron in a / menu is the right row text; and whether removing the $ popup needs a deprecation path.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Cross-platform: pure renderer string/derivation logic, no paths or shortcuts.
  • SSH / remote: SSH skill discovery remains unavailable in native chat; this PR does not change that boundary or any wire contract. Local Codex chats now request the existing runtime catalog on /, which they previously never did.
  • Mobile: mobile has no picker and imports only send classification, which is unchanged.
  • Backwards compatibility: removes the $ autocomplete surface. Hand-typed $name still works.
  • Performance: the derivation is two regexes on the text before the caret; discovery results are cached per host context.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Lint, typecheck, and tests pass locally (build left to CI)

The composer only opened its picker when `/` was the first character of the
draft, so a skill named mid-sentence ("validate it with /electron") offered
nothing. Codex was worse: its `/` menu listed commands only, and skills lived
on a separate `$` trigger, so the prompt box behaved differently per agent.

`/` is now the whole composer grammar. It opens one grouped commands+skills
menu for every agent with a known grammar, both at the start of the draft and
mid-prompt after whitespace. The `$` trigger is gone.

Per-agent invocation is preserved where it belongs — in what a pick writes.
Each row carries its own token, so choosing a skill in Codex inserts
`$electron` while Claude inserts `/electron`, and the text that reaches the
agent stays the text that agent actually invokes. Only a draft-leading command
is dispatchable; picking one mid-sentence completes the token instead of
sending the command on its own and discarding the draft.

Name collisions now key on whether both kinds share a sigil, so a Codex
`/review` command and a `$review` skill stay separate rows.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

Native chat autocomplete now uses slash mode for both commands and skills. Picker items provide exact insertion tokens. Leading slash entries can dispatch commands, while mid-prompt entries only complete text. Picker rendering, ARIA state, keyboard handling, and state tracking no longer use a separate skill mode. Agent profiles no longer expose groupedSlash. Tests cover unified slash behavior, token replacement, dispatchability, filtering, and catalog loading.

Merge Risk: 🔵 Low · up to f6f60

Selecting a mid-sentence picker suggestion can add an extra space before the remaining text. This is a minor draft-formatting defect that should be corrected before or shortly after merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, visual proof, compatibility, and checklist. However, it explicitly states "No issue — reported directly" even though the template… Add the required linked issue reference in the Linked Issue section, for example Fixes #19832`` or the correct tracking issue number. Keep the remaining description content unchanged if accurate.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: one slash picker for every agent, including mid-prompt usage.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, compatibility, and checklist. However, it explicitly states "No issue — reported directly" even though the template requires a linked issue.

  • 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.

ℹ️ Two minor suggestions — a mid-prompt path edge case and a test-coverage gap. Nothing blocking.

Reviewed changes

  • / becomes the composer's only trigger. deriveComposerAutocomplete now keys off two shared regexes (LEADING_SLASH_TRIGGER, MID_PROMPT_SLASH_TRIGGER) and returns a single slash mode for every profiled agent; the skill mode and $ trigger are removed.
  • Per-row token on NativeChatPickerItem. Skills render under / but insert the agent-native form ($electron for Codex, /electron for Claude), so accept-time translation replaces the old prefix plumbing.
  • dispatchable gating. Only a draft-leading /command dispatches on Enter; mid-prompt picks complete the token instead, preserving the surrounding prose.
  • Profile simplification. groupedSlash is dropped from NativeChatAgentProfile; grouped is now derived from skillsEnabled, and skillPrefix governs only the written token.

The accept-time-translation model and the removal of the $ popup are well reasoned and the test suite pins the interesting cases (per-item tokens, same-named command/skill staying separate for Codex, mid-prompt filtering, $ inertness). Two rough edges worth a look are inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

// the one that can dispatch; elsewhere the token starts after whitespace and its
// query stops at the next `/` so file paths stay prose.
export const LEADING_SLASH_TRIGGER = /^\/(\S*)$/
export const MID_PROMPT_SLASH_TRIGGER = /\s\/([^\s/]*)$/

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.

A mid-prompt token only stops at the next /, so a single-segment absolute path after whitespace — rm /tmp, open /Users, cat /etc — still opens the picker, and isSkillPickerTriggered will fetch the skill catalog for it too. Only multi-segment paths like open /Users/me/notes are suppressed. Worth confirming that's an acceptable rough edge rather than an annoyance.

Merge Sim added 2 commits September 9, 2026 20:12
The trigger-key swap cases still used `$:4` keys. editReplacesTriggerToken is
sigil-agnostic so they passed, but they modelled an input the composer can no
longer produce.

@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: Advanced

Run ID: fd171da0-0bbe-44d4-97a9-d27f3648e9ea

📥 Commits

Reviewing files that changed from the base of the PR and between bbefbce and f6f6095.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-skills.react.test.tsx

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

Comment on lines +115 to +116
draft: 'Explain /clear before continuing',
caret: 'Explain /clear '.length,

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not preserve two separator spaces after completion.

The suffix already starts with a space. applyPickerSuggestion adds another space after /clear, so this assertion accepts Explain /clear before continuing. Update the insertion logic to avoid adding a separator when the suffix already starts with whitespace. Expect one space and place the caret immediately after /clear.

Proposed test expectation
-        draft: 'Explain /clear  before continuing',
-        caret: 'Explain /clear '.length,
+        draft: 'Explain /clear before continuing',
+        caret: 'Explain /clear'.length,

@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.

ℹ️ This delta is test-only and clean — no new issues. The one open thread from the prior review (single-segment mid-prompt paths) is unchanged here and stays for your call.

Reviewed changes

  • Mid-prompt command dispatch is now under test. use-native-chat-composer-keydown.test.tsx gains an it.each over all four profiled agents asserting Enter on a mid-prompt /command completes the token via completePickerItem (never dispatchPickerCommand) and preserves the surrounding prose.
  • Skill-discovery reuse is pinned. use-native-chat-skills.react.test.tsx drives isSkillPickerTriggered across leading, mid-prompt, and dismissed states and asserts the catalog is fetched exactly once per host context.
  • Dismissal fixtures model the live grammar. The editReplacesTriggerToken dismissal inputs switched from the removed $:4 trigger to the live /:0 / /:4 keys.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready to merge

The review/fix loop is clean after two rounds, and the opening and closing release-readiness passes found no P0/P1/P2 issues. The change removes the underlying failure mechanism: the composer derives one cursor-aware slash completion range, each item owns the agent-native token it inserts, and only prompt-leading commands can dispatch. That fits the existing editor persistence and send-classification ownership without adding a parallel flow.

I pushed f6f6095 with focused regression and performance coverage:

  • Mid-prompt Enter completes commands without dispatching, sending, or losing surrounding prose for Claude, OpenClaude, Codex, and Grok.
  • Slash typing, closing, and reopening reuse one discovery request; no new polling, fanout, or unbounded state was introduced.
  • Review validation passed 127 files / 1,283 tests, a focused 17-test rerun, pnpm tc, changed-code quality/format checks, and a mutation check that fails when the dispatchability guard is removed.
  • The final independent readiness pass reran 126 files / 1,271 tests and git diff --check.
  • GitHub CI is fully green, including all eight test shards, typecheck, static analysis, verification, and macOS/Windows packaging.

Hidden-renderer Electron QA passed on the exact final head with ORCA_BACKGROUND_LAUNCH=1 and Playwright CDP:

Mobile, Windows/WSL runtime, and SSH runtime QA are inapplicable to this renderer grammar change; it changes no mobile behavior, platform execution path, or remote wire contract. The requested Grok QA worker could not enter the task because Grok Build reported exhausted credits, so a Codex Electron worker ran the same desktop validation and attached the evidence above.

Verdict: clean and ready to merge.

@brennanb2025
brennanb2025 merged commit dda103d into main Sep 10, 2026
28 checks passed
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