chat: fix duplicate command registration for agent-host-copilotcli#318273
Merged
roblourens merged 1 commit intoMay 26, 2026
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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-copilotclicommand 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 isagent-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
DonJayamanne
approved these changes
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an error thrown on startup:
The command was being registered twice:
src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts(added in #314187).src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.tsvia the autorun that registers an in-placeopenNewChatSessionInPlace.<type>action for every contributed session type. The agent host callsregisterChatSessionContributionforagent-host-copilotcliat startup, which triggers that registration — that path was added in #312628 specifically to ensure types likeagent-host-copilotcliget the in-place command.CommandsRegistry.registerCommandasserts 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/openNewSessionEditorstatic 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)