chat: implement and migrate to IChatWidgetService.reveal/revealWidget#277971
chat: implement and migrate to IChatWidgetService.reveal/revealWidget#277971connor4312 merged 1 commit intomainfrom
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jriekenMatched files:
@bpaseroMatched files:
@lszomoruMatched files:
|
cea4959 to
4e0ba52
Compare
4e0ba52 to
26053d3
Compare
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.
26053d3 to
aca5435
Compare
There was a problem hiding this comment.
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 |
| await widgetService.reveal(widget); | ||
| widget.input.openModelPicker(); |
There was a problem hiding this comment.
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.
| await widgetService.reveal(widget); | |
| widget.input.openModelPicker(); | |
| const revealed = await widgetService.reveal(widget); | |
| if (revealed) { | |
| widget.input.openModelPicker(); | |
| } |
|
|
||
| // 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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
showChatViewwhich only supported sidebar chat.
Refs #277318
cc @roblourens