Skip to content

chat: fix duplicate command registration for agent-host-copilotcli#318273

Merged
roblourens merged 1 commit into
mainfrom
agents/please-fix-this-error-that-i-m-seeing-9144b8b9
May 26, 2026
Merged

chat: fix duplicate command registration for agent-host-copilotcli#318273
roblourens merged 1 commit into
mainfrom
agents/please-fix-this-error-that-i-m-seeing-9144b8b9

Conversation

@roblourens
Copy link
Copy Markdown
Member

Fixes an error thrown on startup:

Error: Cannot register two commands with the same id: workbench.action.chat.openNewChatSessionInPlace.agent-host-copilotcli

The command was being registered twice:

  1. Statically in src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts (added in #314187).
  2. Dynamically in src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts via the autorun that registers an in-place openNewChatSessionInPlace.<type> action for every contributed session type. The agent host calls registerChatSessionContribution for agent-host-copilotcli at startup, which triggers that registration — that path was added in #312628 specifically to ensure types like agent-host-copilotcli get the in-place command.

CommandsRegistry.registerCommand asserts on duplicate ids, so the second registration threw.

Fix

Remove the static duplicate from electron-browser/chat.contribution.ts. The dynamic registration already covers it, runs as soon as the agent host registers its contribution, and is the systematic mechanism for all session types.

The neighbouring openNewSessionSidebar / openNewSessionEditor static commands stay — they have distinct ids and serve their documented purpose of providing stable command ids for automation that may run before the agent host has registered.

(Written by Copilot)

The command `workbench.action.chat.openNewChatSessionInPlace.agent-host-copilotcli`
was registered twice:

1. Statically in `electron-browser/chat.contribution.ts` (added in #314187)
2. Dynamically in `chatSessions.contribution.ts` via the autorun that
   registers an in-place action for every contributed session type. The
   agent host calls `registerChatSessionContribution` for the
   `agent-host-copilotcli` type at startup, which triggers that
   registration.

The static duplicate hit `CommandsRegistry.registerCommand`'s 'Cannot
register two commands with the same id' assertion. Remove the static
 the dynamic one already covers it and is explicitlyregistration
designed to handle programmatically-registered contributions like
`agent-host-copilotcli`.

The neighbouring `openNewSessionSidebar` / `openNewSessionEditor`
static commands stay; they have distinct ids and serve their documented
purpose of providing stable command ids for automation that may run
before the agent host has registered.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 26, 2026 01:42
@roblourens roblourens enabled auto-merge (squash) May 26, 2026 01:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes a redundant static command registration that was colliding with the dynamic per-session-type command registration, fixing a startup-time duplicate-command-id assertion for the agent-host Copilot CLI session type.

Changes:

  • Remove the static workbench.action.chat.openNewChatSessionInPlace.agent-host-copilotcli command registration from the Electron chat contribution, relying on the existing dynamic registration path instead.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts Removes the duplicate static in-place “new session” command registration so startup no longer throws on duplicate command ids.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts:342

  • The comment mentions dynamic per-agent commands as agent-host-copilot, but the actual local agent-host scheme/session type in this area is agent-host-copilotcli (see SessionType.AgentHostCopilot) and, more generally, agent-host-${agent.provider}. Updating the example would avoid confusion when tracing which command ids/schemes are expected to exist at runtime.
// Static sidebar/editor open commands for the Agent Host umbrella scheme.
// The dynamic per-agent commands (e.g. `agent-host-copilot`) are only
// registered after the agent host starts and surfaces an AgentInfo, which
// is asynchronous. Provide stable command ids that automation (evals) can
  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@roblourens roblourens merged commit f0f00ff into main May 26, 2026
26 checks passed
@roblourens roblourens deleted the agents/please-fix-this-error-that-i-m-seeing-9144b8b9 branch May 26, 2026 02:03
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 26, 2026
anthonykim1 added a commit that referenced this pull request May 26, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
dileepyavan pushed a commit that referenced this pull request May 27, 2026
Squashed cherry-pick of 10 commits from main that are included in the
Insiders build (183159e) people are verifying:

- agentHost: show fetched URL for web_fetch (#318240)
- Fix SSH remote agent host passphrase auth (#318244)
- agentHost: add setting to disable worktreeCreated task auto-dispatch (#318243)
- Agent host: clearer worktree git timeout errors and 60s budget (#318242)
- Normalize LF to CRLF in agent host terminal tool output (#318257)
- sessions: restore X-button removal of SSH remote agent host entries (#318262)
- chat: fix duplicate command registration for agent-host-copilotcli (#318273)
- launch: build copilot in compile; wait for CDP in launch.sh (#318272)
- Preserve unread state across remote host disconnect (#318267)
- Add more codenotify for terminal (#318285)
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.

3 participants