Skip to content

Commit

Permalink
For the clear command, use lastFocusedWidget over openView (#232574)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken authored Oct 30, 2024
1 parent 3dff365 commit 342d1fd
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function registerNewChatActions() {
title: localize2('chat.newChat.label', "New Chat"),
category: CHAT_CATEGORY,
icon: Codicon.plus,
precondition: CONTEXT_CHAT_ENABLED,
precondition: ContextKeyExpr.and(CONTEXT_CHAT_ENABLED, CONTEXT_CHAT_LOCATION.notEqualsTo(ChatAgentLocation.EditingSession)),
f1: true,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
Expand All @@ -85,21 +85,15 @@ export function registerNewChatActions() {
const context = args[0];
const accessibilitySignalService = accessor.get(IAccessibilitySignalService);
const widgetService = accessor.get(IChatWidgetService);

let widget = widgetService.lastFocusedWidget;

if (isChatViewTitleActionContext(context)) {
const widget = widgetService.getWidgetBySessionId(context.sessionId);
// Is running in the Chat view title
announceChatCleared(accessibilitySignalService);
if (widget) {
widget.clear();
widget.focusInput();
}
} else {
// Is running from f1 or keybinding
const viewsService = accessor.get(IViewsService);

const chatView = await viewsService.openView(CHAT_VIEW_ID) as ChatViewPane;
const widget = chatView.widget;
widget = widgetService.getWidgetBySessionId(context.sessionId);
}

if (widget) {
announceChatCleared(accessibilitySignalService);
widget.clear();
widget.focusInput();
Expand Down

0 comments on commit 342d1fd

Please sign in to comment.