Skip to content

Commit ee4edc1

Browse files
Copilotcwebster-99
andauthored
Show sign-in dialog when delegating to session targets while unauthenticated
When a user tries to delegate to Copilot CLI, Cloud, or other session targets while not signed in, trigger the sign-in/setup dialog instead of letting the request fail with a non-actionable error. The sign-in check is added to three entry points: - SubmitAction.handleDelegation() for the session target picker - CreateRemoteAgentJobAction.run() for the "Continue in..." dropdown - CreateRemoteAgentJobFromEditorAction.run() for the editor context menu This matches the existing Local session behavior where the setup dialog is shown when the user's entitlement is Unknown and anonymous access is not enabled. Fixes #296117 Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/12f524df-1f4f-414c-b3bc-5ce531b1b112 Co-authored-by: cwebster-99 <60238438+cwebster-99@users.noreply.github.com>
1 parent 7db09d1 commit ee4edc1

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/vs/workbench/contrib/chat/browser/actions/chatContinueInAction.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { IWorkspaceContextService } from '../../../../../platform/workspace/comm
4545
import { IAgentSessionsService } from '../agentSessions/agentSessionsService.js';
4646
import { IChatWidget, IChatWidgetService, isIChatViewViewContext } from '../chat.js';
4747
import { ctxHasEditorModification } from '../chatEditing/chatEditingEditorContextKeys.js';
48+
import { ChatEntitlement, IChatEntitlementService } from '../../../../services/chat/common/chatEntitlementService.js';
4849
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
4950
import { PromptFileVariableKind, toPromptFileVariableEntry } from '../../common/attachments/chatVariableEntries.js';
5051

@@ -391,6 +392,15 @@ export class CreateRemoteAgentJobAction {
391392
const agentSessionsService = accessor.get(IAgentSessionsService);
392393
const chatSessionsService = accessor.get(IChatSessionsService);
393394
const fileService = accessor.get(IFileService);
395+
const chatEntitlementService = accessor.get(IChatEntitlementService);
396+
397+
// If the user is not signed in, trigger the sign-in/setup flow before continuing
398+
if (chatEntitlementService.entitlement === ChatEntitlement.Unknown && !chatEntitlementService.anonymous) {
399+
const setupSucceeded = await commandService.executeCommand<boolean | undefined>(CHAT_SETUP_ACTION_ID);
400+
if (!setupSucceeded) {
401+
return;
402+
}
403+
}
394404

395405
const remoteJobCreatingKey = ChatContextKeys.remoteJobCreating.bindTo(contextKeyService);
396406

@@ -532,6 +542,15 @@ class CreateRemoteAgentJobFromEditorAction {
532542
const editorService = accessor.get(IEditorService);
533543
const activeEditor = editorService.activeTextEditorControl;
534544
const commandService = accessor.get(ICommandService);
545+
const chatEntitlementService = accessor.get(IChatEntitlementService);
546+
547+
// If the user is not signed in, trigger the sign-in/setup flow before continuing
548+
if (chatEntitlementService.entitlement === ChatEntitlement.Unknown && !chatEntitlementService.anonymous) {
549+
const setupSucceeded = await commandService.executeCommand<boolean | undefined>(CHAT_SETUP_ACTION_ID);
550+
if (!setupSucceeded) {
551+
return;
552+
}
553+
}
535554

536555
if (!activeEditor) {
537556
return;

src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ import { IChatWidget, IChatWidgetService } from '../chat.js';
3636
import { getAgentSessionProvider, AgentSessionProviders } from '../agentSessions/agentSessions.js';
3737
import { getEditingSessionContext } from '../chatEditing/chatEditingActions.js';
3838
import { ctxHasEditorModification, ctxHasRequestInProgress, ctxIsGlobalEditingSession } from '../chatEditing/chatEditingEditorContextKeys.js';
39-
import { ACTION_ID_NEW_CHAT, CHAT_CATEGORY, clearChatSessionPreservingType, handleCurrentEditingSession, handleModeSwitch } from './chatActions.js';
39+
import { ChatEntitlement, IChatEntitlementService } from '../../../../services/chat/common/chatEntitlementService.js';
40+
import { ACTION_ID_NEW_CHAT, CHAT_CATEGORY, CHAT_SETUP_ACTION_ID, clearChatSessionPreservingType, handleCurrentEditingSession, handleModeSwitch } from './chatActions.js';
4041
import { CreateRemoteAgentJobAction } from './chatContinueInAction.js';
4142
import { CTX_HOVER_MODE } from '../../../inlineChat/common/inlineChat.js';
4243

@@ -161,6 +162,16 @@ abstract class SubmitAction extends Action2 {
161162

162163
private async handleDelegation(accessor: ServicesAccessor, widget: IChatWidget, delegationTarget: Exclude<AgentSessionProviders, AgentSessionProviders.Local>): Promise<void> {
163164
const chatSessionsService = accessor.get(IChatSessionsService);
165+
const chatEntitlementService = accessor.get(IChatEntitlementService);
166+
const commandService = accessor.get(ICommandService);
167+
168+
// If the user is not signed in, trigger the sign-in/setup flow before delegating
169+
if (chatEntitlementService.entitlement === ChatEntitlement.Unknown && !chatEntitlementService.anonymous) {
170+
const setupSucceeded = await commandService.executeCommand<boolean | undefined>(CHAT_SETUP_ACTION_ID);
171+
if (!setupSucceeded) {
172+
return;
173+
}
174+
}
164175

165176
// Find the contribution for the delegation target
166177
const contributions = chatSessionsService.getAllChatSessionContributions();

0 commit comments

Comments
 (0)