Skip to content

Commit ed9a285

Browse files
authored
Support /delegating to cloud from a new cli session (#1886)
1 parent a93271f commit ed9a285

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class CopilotCLIChatSessionParticipant {
361361
return await this.handleConfirmationData(session, request.prompt, confirmationResults, context, stream, token);
362362
}
363363

364-
if (!isUntitled && request.prompt.startsWith('/delegate')) {
364+
if (request.prompt.startsWith('/delegate')) {
365365
await this.handleDelegateCommand(session, request, context, stream, token);
366366
} else {
367367
await session.handleRequest(prompt, attachments, modelId, token);

src/extension/chatSessions/vscode-node/test/copilotCLIChatSessionParticipant.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,30 @@ describe('CopilotCLIChatSessionParticipant.handleRequest', () => {
248248
expect(assistantArg).toMatch(/<pr_metadata uri="pr:\/\/1"/);
249249
});
250250

251+
it('handles /delegate command for new session', async () => {
252+
const newSession = new FakeCopilotCLISession('push-session-id');
253+
git.activeRepository = { get: () => ({ changes: { indexChanges: [{ path: 'file.ts' }] } }) } as unknown as IGitService['activeRepository'];
254+
const request = new TestChatRequest('/delegate Build feature');
255+
const context = createChatContext('existing-delegate', true);
256+
const stream = new MockChatResponseStream();
257+
const token = disposables.add(new CancellationTokenSource()).token;
258+
sessionService.createSession.mockResolvedValue(newSession);
259+
260+
await participant.createHandler()(request, context, stream, token);
261+
262+
expect(sessionService.createSession).toHaveBeenCalled();
263+
expect(cloudProvider.tryHandleUncommittedChanges).toHaveBeenCalled();
264+
expect(cloudProvider.createDelegatedChatSession).toHaveBeenCalled();
265+
// PR metadata recorded
266+
expect(newSession.addUserMessage).toHaveBeenCalledWith('/delegate Build feature');
267+
const assistantArg = newSession.addUserAssistantMessage.mock.calls[0][0];
268+
expect(assistantArg).toContain('pr://1');
269+
// Uncommitted changes warning surfaced
270+
// Warning should appear (we emitted stream.warning). The mock stream only records markdown.
271+
// Delegate path adds assistant PR metadata; ensure output contains PR metadata tag instead of relying on warning capture.
272+
expect(assistantArg).toMatch(/<pr_metadata uri="pr:\/\/1"/);
273+
});
274+
251275
it('invokes handlePushConfirmationData without existing chatSessionContext (summary via summarizer)', async () => {
252276
const request = new TestChatRequest('Push this');
253277
const context = { chatSessionContext: undefined, chatSummary: undefined } as unknown as vscode.ChatContext;

0 commit comments

Comments
 (0)