Skip to content

chat: implement and migrate to IChatWidgetService.reveal/revealWidget#277971

Merged
connor4312 merged 1 commit intomainfrom
connor4312/chat-multi-focus
Nov 18, 2025
Merged

chat: implement and migrate to IChatWidgetService.reveal/revealWidget#277971
connor4312 merged 1 commit intomainfrom
connor4312/chat-multi-focus

Conversation

@connor4312
Copy link
Member

Previously we did a couple of different ad-hoc things when showing chat,
which often didn't support editor chat, aux window chat, and never
supported quick chat at all.

This implement a method on the IChatWidgetService to reveal the chat
widget regardless of location, and also to reveal+open the last widget
or create a new one if there wasn't one, replacing the popular showChatView
which only supported sidebar chat.

Refs #277318

cc @roblourens

Copilot AI review requested due to automatic review settings November 18, 2025 00:41
@connor4312 connor4312 enabled auto-merge (squash) November 18, 2025 00:41
@connor4312 connor4312 self-assigned this Nov 18, 2025
@vs-code-engineering
Copy link

vs-code-engineering bot commented Nov 18, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@jrieken

Matched files:

  • src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.ts
  • src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.ts
  • src/vs/workbench/contrib/inlineChat/test/browser/inlineChatController.test.ts
  • src/vs/workbench/contrib/inlineChat/test/browser/inlineChatSession.test.ts

@bpasero

Matched files:

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

@lszomoru

Matched files:

  • src/vs/workbench/contrib/scm/browser/scmHistoryChatContext.ts

@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 18, 2025
@connor4312 connor4312 force-pushed the connor4312/chat-multi-focus branch from cea4959 to 4e0ba52 Compare November 18, 2025 00:43
@connor4312 connor4312 mentioned this pull request Nov 18, 2025
21 tasks
@connor4312 connor4312 force-pushed the connor4312/chat-multi-focus branch from 4e0ba52 to 26053d3 Compare November 18, 2025 00:47
Previously we did a couple of different ad-hoc things when showing chat,
which often didn't support editor chat, aux window chat, and never
supported quick chat at all.

This implement a method on the IChatWidgetService to reveal the chat
widget regardless of location, and also to reveal+open the last widget
or create a new one if there wasn't one, replacing the popular `showChatView`
which only supported sidebar chat.
@connor4312 connor4312 force-pushed the connor4312/chat-multi-focus branch from 26053d3 to aca5435 Compare November 18, 2025 00:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors chat widget revelation logic by introducing two new methods on IChatWidgetService: reveal() and revealWidget(). These replace the previous ad-hoc showChatView() function and provide comprehensive support for revealing chat widgets across all locations including sidebar chat, editor chat, auxiliary window chat, and quick chat.

Key Changes

  • Introduced IChatWidgetService.reveal() to reveal any chat widget regardless of its location, with support for editor groups, quick chat, and view-based chat
  • Introduced IChatWidgetService.revealWidget() to reveal the last focused widget or create a new chat view if none exists
  • Migrated all 20+ call sites from showChatView() to the new service methods

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/chat.ts Added new reveal() and revealWidget() methods to IChatWidgetService interface; removed old showChatView() and showChatWidgetInViewOrEditor() helper functions; added sessionResource property to IQuickChatService
src/vs/workbench/contrib/chat/browser/chatWidget.ts Implemented reveal() and revealWidget() methods in ChatWidgetService; added dependencies for IEditorGroupsService, IViewsService, IQuickChatService, and ILayoutService
src/vs/workbench/contrib/chat/browser/chatQuick.ts Added sessionResource getter to QuickChatService and QuickChat classes; migrated openChatView() to use new chatWidgetService.revealWidget()
src/vs/workbench/contrib/chat/test/browser/mockChatWidget.ts Added mock implementations of reveal() and revealWidget() methods
src/vs/workbench/contrib/chat/browser/chatSetup.ts Replaced showChatView() calls with widgetService.revealWidget() across setup flows
src/vs/workbench/contrib/chat/browser/actions/chatActions.ts Migrated chat action handlers to use widgetService.revealWidget()
src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts Added reveal() call before opening model picker; replaced showChatWidgetInViewOrEditor() with widgetService.reveal()
src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts Removed withChatView() helper; migrated attachment actions to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.ts Migrated getting started flow to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/chat/browser/chatAccessibilityService.ts Replaced showChatWidgetInViewOrEditor() with widgetService.reveal()
src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationWidget.ts Replaced showChatWidgetInViewOrEditor() with chatWidgetService.reveal(); removed unused IInstantiationService dependency
src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.ts Migrated to use chatWidgetService.revealWidget() for element attachment
src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.ts Migrated prompt running actions to use widgetService.revealWidget()
src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.ts Migrated instruction attachment to use widgetService.revealWidget()
src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts Migrated lifecycle handler to use widgetService.revealWidget()
src/vs/workbench/contrib/chat/electron-browser/actions/voiceChatActions.ts Migrated voice chat actions to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.ts Migrated moveToPanelChat() and askInPanelChat() to use widgetService.revealWidget()
src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.ts Migrated notebook chat integration to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.ts Migrated cell error handling to use widgetService.revealWidget()
src/vs/workbench/contrib/scm/browser/scmHistoryChatContext.ts Migrated SCM history context actions to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts Migrated terminal decoration chat integration to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.ts Migrated terminal chat controller to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.ts Migrated viewInChat() to use chatWidgetService.revealWidget()
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts Replaced showChatView() with chatWidgetService.revealWidget() for terminal tool integration

Comment on lines +438 to 439
await widgetService.reveal(widget);
widget.input.openModelPicker();
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider handling the case where reveal returns false (indicating the widget could not be revealed). If the widget cannot be revealed, calling widget.input.openModelPicker() might not have the desired effect.

Suggested change
await widgetService.reveal(widget);
widget.input.openModelPicker();
const revealed = await widgetService.reveal(widget);
if (revealed) {
widget.input.openModelPicker();
}

Copilot uses AI. Check for mistakes.

// focus transfer to other documents is async. If we depend on the focus
// being synchronously transferred in consuming code, this can fail, so
// wait for it to propagate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little confusing, was there somewhere that we depend on this? And is this just async when switching to a new aux window, or always async?

Copy link
Member Author

@connor4312 connor4312 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only async when switching to an aux window. This was specially with the "open model picker" command where the context view service looks for the active document to determine where to open the picker. If I don't wait, there is actually no active document and so it falls back to the main window. There just seems to be some asyncness in chrome/electron around the focus transfer.

@connor4312 connor4312 merged commit e9cb9f3 into main Nov 18, 2025
28 checks passed
@connor4312 connor4312 deleted the connor4312/chat-multi-focus branch November 18, 2025 01:34
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants