Skip to content

Commit 0492714

Browse files
fix: ensure active session is recreated after deletion (#16702)
Contributed on behalf of Lonti.com Pty Ltd Signed-off-by: Rannie Peralta <[email protected]>
1 parent 7787953 commit 0492714

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/ai-chat-ui/src/browser/ai-chat-ui-contribution.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget>
398398
}
399399
});
400400
} else if (context.button === AIChatContribution.REMOVE_CHAT_BUTTON) {
401+
const activeSession = this.chatService.getActiveSession();
402+
401403
// Wait for deletion to complete before refreshing the list
402404
this.chatService.deleteSession(context.item.id!).then(() => getItems()).then(items => {
403405
quickPick.items = items;
@@ -406,6 +408,13 @@ export class AIChatContribution extends AbstractViewContribution<ChatViewWidget>
406408
}
407409
// Update persisted sessions flag after deletion
408410
this.checkPersistedSessions();
411+
412+
if (activeSession && activeSession.id === context.item.id) {
413+
this.chatService.createSession(ChatAgentLocation.Panel, {
414+
// Auto-focus only when the quick pick is no longer visible
415+
focus: items.length === 0
416+
});
417+
}
409418
}).catch(error => {
410419
this.logger.error('Failed to delete chat session', error);
411420
this.messageService.error(nls.localize('theia/ai/chat-ui/failedToDeleteSession', 'Failed to delete chat session'));

0 commit comments

Comments
 (0)