Skip to content

feat(palette): choose the agent when starting a session from Cmd+K - #685

Merged
Ark0N merged 1 commit into
Ark0N:masterfrom
aakhter:pr/palette-agent-picker
Oct 24, 2026
Merged

Ark0N merged 1 commit into
Ark0N:masterfrom
aakhter:pr/palette-agent-picker

Conversation

@aakhter

@aakhter aakhter commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Problem

The Cmd+K palette's "New session" row always starts whatever the Run button is set to. Starting a session with a different agent means leaving the palette, opening the Run menu, changing the Run button's mode, and then running, which also leaves the Run button changed for every later launch.

Approach

The "New session" row now shows the agent it will start, with arrows on either side of the agent's logo and name.

  • The agents come from the CLI catalog the server already injects (window.__codemanCliCatalog), filtered to enabled entries that are installed here (isCliAvailable()), in catalog order. That is the same list the welcome screen's Run buttons offer. No CLI id list lives in the palette code, and a CLI added through clis.json shows up with no frontend change.
  • Each time the palette opens, the row starts on the Run button's mode, or on the first offered agent if that mode is not offered.
  • Left/Right change the agent while the row is highlighted, but only when the key would not move the caret anyway (Left at the start of the query, Right at its end, no selection), so editing a typed case name still works. The arrows can also be clicked; clicking them keeps focus in the search box and does not launch.
  • Enter launches the picked agent once through run(), with the same temporary _runMode swap the custom-model entries and worktree launches use. The Run button's mode and the saved runMode setting are not changed, and the swap is undone even if the launch throws.
  • With only one agent offered, or on a page rendered without the catalog, the row looks and behaves as before.

No new setting. Which agents appear is already controlled by the CLI registry's own enable toggles, and a second palette-only list would be another place to curate the same thing.

panels-ui.js is added to the files test/frontend-cli-no-id-branching.test.ts scans. It has no CLI id branches today, so this costs nothing and keeps the palette from growing one.

Tests

  • test/command-palette-ui.test.ts: 10 new cases covering the catalog-derived list (disabled and uninstalled CLIs left out), the starting agent and its fallback, Left/Right cycling with wrap-around, Left/Right left to the caret mid-query, no cycling on a session row, arrow clicks that cycle without launching, the one-shot launch that leaves the Run button mode alone (also when run() throws), and no picker with a single agent. The existing palette tests pass unchanged.
  • test/frontend-cli-no-id-branching.test.ts now also scans panels-ui.js.
  • npm run typecheck, npm run lint, npm run format:check, npm run check:frontend-syntax, npm run check:public-assets, npm run test:ci.
  • Checked in Chromium against a local instance: opened Cmd+K, moved the new-session row from Claude Code to Shell with the arrow keys and the arrow buttons, pressed Enter, and the created session had mode: "shell" while the Run button stayed on Claude Code.

The palette's "New session" row now shows the agent it will start and
lets Left/Right (or the row's arrows) switch it. The agents come from the
injected CLI catalog, filtered to enabled and installed entries, so no CLI
id list lives in the palette. The pick is a one-shot launch through run()
with a temporary _runMode swap: the Run button's mode is left unchanged.
@Ark0N

Ark0N commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thanks @aakhter, this is a nice addition: the Cmd+K New session row now shows which agent it will start, Left/Right or the arrows switch it, and Enter launches it once through run() without touching the Run button's mode.

I ran it in Chromium against a dev server. Left/Right cycle and wrap, the caret is respected mid-query, clicking an arrow keeps focus in the search box and does not launch, Enter posts the picked mode, and the Run button and the saved runMode stay where they were. Typecheck, lint, format, frontend syntax, public assets and the 23 test files that load panels-ui.js are all green.

I will apply these small things at merge time (tell me if you would rather push them yourself):

  1. Arrows inside the row's button (src/web/public/panels-ui.js:705-709): the arrow spans have role="button" and sit inside the row's <button>, so Chromium exposes two nested buttons and reads the row as "New session Run Shell in testcase Previous agent Shell Next agent". The subtitle already names the agent, so I will put aria-hidden="true" on the .command-palette-agent span and drop the arrows' role and aria-label. Clicks keep working, since they key off data-palette-agent-cycle.
  2. zh-CN (src/web/public/panels-ui.js:705): i18n.js translates title attributes, so the "Agent for the new session (Left/Right to change)" tooltip gets a ZH_CN entry.
  3. Docs (docs/wiki/Keyboard-Shortcuts.md:11): one sentence on the Ctrl+K row saying Left/Right change the agent on the New session row.

One thing for a follow-up, not this PR: _commandPaletteAgentChoices() (src/web/public/panels-ui.js:580) gates on the host's isCliAvailable(), while for a Docker case the Run menu offers what the container has (_refreshRunModeAvailability, src/web/public/session-ui.js:784). With the Run button on a CLI that only the container ships, the row now starts on the first offered agent instead of the Run button's mode. The welcome screen has the same host-only gate, so a shared helper could fix both. You are welcome to take that on; otherwise I will open an issue for it.

I will merge it with the three fixes above on top. Thanks again!

@Ark0N
Ark0N merged commit c6a5995 into Ark0N:master Oct 24, 2026
2 checks passed
Ark0N pushed a commit that referenced this pull request Oct 24, 2026
palette agent switch: aria-hidden on .command-palette-agent, arrows lose role="button" and aria-label (no nested buttons in the row)
i18n: zh-CN entry for the "Agent for the new session (Left/Right to change)" tooltip
docs: Keyboard-Shortcuts Ctrl+K row says Left/Right change the agent on the New session row
test: pin the aria-hidden switch and the zh-CN tooltip entry in command-palette-ui.test.ts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Oct 24, 2026
Keep the Run button's mode when fewer than two agents are offered (_commandPaletteAgent), so a Docker case whose host offers only Shell still starts the container agent the Run button shows; pinned by a new palette test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Oct 24, 2026
@Ark0N

Ark0N commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Merged, thank you! This ships in 1.45.0.

Testing the merged branch turned up one regression: the palette gated agents on what the host has installed, so a Docker case couldn't start a CLI that only its container has. Cmd+K now uses the same per-case rule as the Run menu (_runModeAvailableForCase() in session-ui.js), and with a single choice the row keeps the Run button's mode. At merge I also made the agent switch aria-hidden (no nested buttons inside the row), added the zh-CN tooltip, and mentioned Left/Right on the Keyboard Shortcuts page.

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.

2 participants