Skip to content

Commit 15d2d8c

Browse files
roblourensCopilot
andauthored
Fix agent host agents in vscode (#312628)
* chat: register in-place action for programmatic chat session contributions The autorun that registers `openNewChatSessionInPlace.<type>` actions filters `_contributions` by `_contributionDisposables.has(...)`. Only extension-contributed providers were getting added to that map (via `_evaluateAvailability`), so programmatically-registered contributions (local + remote agent hosts) had no in-place action and the session-type picker in VS Code threw "command not found" when switching to the local Copilot CLI agent host. Mark programmatic registrations as active in `registerChatSessionContribution` so they participate in the autorun. Also disambiguate the agent-host displayName in VS Code by suffixing "- Agent Host", since the extension-host Copilot CLI harness uses the same "Copilot CLI" label. The Agents window keeps the original displayName. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chat: refresh hasCanDelegateProviders context key on programmatic register/unregister Programmatic chat session contributions bypass _evaluateAvailability, which was the only path that called _updateHasCanDelegateProvidersContextKey. Update the context key directly in registerChatSessionContribution and its dispose so UI gated on ChatContextKeys.hasCanDelegateProviders stays in sync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1d8e3cb commit 15d2d8c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,22 @@ export class AgentHostContribution extends Disposable implements IWorkbenchContr
152152
const agentId = sessionType;
153153
const vendor = sessionType;
154154

155+
// In the Agents app, the agent-host displayName is unambiguous because
156+
// only agent-host sessions exist there. In VS Code, the same picker
157+
// also lists the extension-host harness with the same displayName
158+
// (e.g. "Copilot CLI"), so suffix with "- Agent Host" to disambiguate.
159+
const displayName = this._isSessionsWindow
160+
? agent.displayName
161+
: localize('agentHost.displayName', "{0} - Agent Host", agent.displayName);
162+
155163
// Chat session contribution.
156164
// In the Agents app, hide the delegation picker for local agent host
157165
// sessions (matches behavior of remote agent host sessions). In VS Code,
158166
// keep the picker available so users can hand off to other targets.
159167
store.add(this._chatSessionsService.registerChatSessionContribution({
160168
type: sessionType,
161169
name: agentId,
162-
displayName: agent.displayName,
170+
displayName,
163171
description: agent.description,
164172
canDelegate: true,
165173
requiresCustomModels: true,

src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,19 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
810810
}
811811

812812
this._contributions.set(contribution.type, { contribution, extension: undefined });
813+
// Programmatically-registered contributions are always considered
814+
// available; mark them as such so the autorun in the constructor
815+
// registers the in-place "New {0} Session" action for them. Without
816+
// this, types like `agent-host-copilotcli` (registered by the local
817+
// agent host) have no `openNewChatSessionInPlace.<type>` command.
818+
this._contributionDisposables.set(contribution.type, new DisposableStore());
819+
this._updateHasCanDelegateProvidersContextKey();
813820
this._onDidChangeAvailability.fire();
814821

815822
return toDisposable(() => {
816823
this._contributions.delete(contribution.type);
824+
this._contributionDisposables.deleteAndDispose(contribution.type);
825+
this._updateHasCanDelegateProvidersContextKey();
817826
this._onDidChangeAvailability.fire();
818827
});
819828
}

0 commit comments

Comments
 (0)