Skip to content

Commit f345377

Browse files
authored
archive after chatWidget#handleDelegationExit (#281373)
1 parent ce28e19 commit f345377

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import { ChatInputPart, IChatInputPartOptions, IChatInputStyles } from './chatIn
8383
import { ChatListDelegate, ChatListItemRenderer, IChatListItemTemplate, IChatRendererDelegate } from './chatListRenderer.js';
8484
import { ChatEditorOptions } from './chatOptions.js';
8585
import { ChatViewWelcomePart, IChatSuggestedPrompts, IChatViewWelcomeContent } from './viewsWelcome/chatViewWelcomeController.js';
86+
import { IAgentSessionsService } from './agentSessions/agentSessionsService.js';
8687

8788
const $ = dom.$;
8889

@@ -374,6 +375,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
374375
@IChatLayoutService private readonly chatLayoutService: IChatLayoutService,
375376
@IChatEntitlementService private readonly chatEntitlementService: IChatEntitlementService,
376377
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
378+
@IAgentSessionsService private readonly agentSessionsService: IAgentSessionsService,
377379
@IChatTodoListService private readonly chatTodoListService: IChatTodoListService,
378380
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
379381
@ILifecycleService private readonly lifecycleService: ILifecycleService
@@ -1364,6 +1366,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
13641366
return;
13651367
}
13661368

1369+
const parentSessionResource = viewModel.sessionResource;
1370+
13671371
// Check if response is complete, not pending confirmation, and has no error
13681372
const checkIfShouldClear = (): boolean => {
13691373
const items = viewModel.getItems();
@@ -1377,6 +1381,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
13771381

13781382
if (checkIfShouldClear()) {
13791383
await this.clear();
1384+
this.archiveLocalParentSession(parentSessionResource);
13801385
return;
13811386
}
13821387

@@ -1400,7 +1405,16 @@ export class ChatWidget extends Disposable implements IChatWidget {
14001405

14011406
if (shouldClear) {
14021407
await this.clear();
1408+
this.archiveLocalParentSession(parentSessionResource);
1409+
}
1410+
}
1411+
1412+
private archiveLocalParentSession(sessionResource: URI): void {
1413+
if (sessionResource.scheme !== Schemas.vscodeLocalChatSession) {
1414+
return;
14031415
}
1416+
const session = this.agentSessionsService.model.sessions.find(candidate => isEqual(candidate.resource, sessionResource));
1417+
session?.setArchived(true);
14041418
}
14051419

14061420
setVisible(visible: boolean): void {

0 commit comments

Comments
 (0)