Skip to content

inlineChat: bypass zone widget in hover mode, use direct sendRequest#308726

Merged
jrieken merged 2 commits intomainfrom
joh/inline-chat-hover-direct-sendrequest
Apr 9, 2026
Merged

inlineChat: bypass zone widget in hover mode, use direct sendRequest#308726
jrieken merged 2 commits intomainfrom
joh/inline-chat-hover-direct-sendrequest

Conversation

@jrieken
Copy link
Copy Markdown
Member

@jrieken jrieken commented Apr 9, 2026

Summary

In hover mode, the InlineChatZoneWidget was being lazily instantiated, fully configured (model, attachments, input text), used to submit requests via chatWidget.acceptInput(), then immediately hidden. This PR eliminates that intermediary by calling IChatService.sendRequest() directly on the session's ChatModel, so the zone widget is never instantiated in hover mode.

Session Context

Key decisions from the development session:

  • Direct sendRequest over addRequest: Uses the high-level IChatService.sendRequest() which handles parsing, instruction collection, and agent invocation - not the low-level ChatModel.addRequest().
  • Zone mode untouched: All changes are scoped to hover mode. The _runZone() codepath is the original run() logic, completely unchanged (except attachDiagnostics defaulting to true since it's always zone mode).
  • _resolveModelId() uses lookupLanguageModelByQualifiedName: Same 3-tier priority as _applyModelDefaults (user session choice > inlineChat.defaultModel setting > vendor default for location), but queries ILanguageModelsService directly instead of going through chatWidget.input.switchModelByQualifiedName().
  • _buildLocationData() replicates zone widget's resolveData: Produces identical IChatLocationData shape, handling both regular editors and notebook cells.
  • Constructor autoruns guarded: The HIDE/SHOW autorun no longer calls this._zone.value in hover mode (which would force instantiation). The diff-adjustment autorun uses rawValue?. so it only acts when the zone already exists.
  • InlineChatRunOptions API unchanged: External callers (extensions, actions) don't need changes.
  • as unknown as T used in test mocks: Partial<T> as T was insufficient for deeply-nested mock objects; unknown intermediary was chosen over any to satisfy lint rules.

Changes

  • run() split into _runHover() and _runZone() - dispatches based on _renderMode
  • New _resolveModelId(location) - resolves language model ID without zone widget
  • New _buildLocationData() - builds IChatLocationData from editor state without zone widget
  • Constructor autoruns guarded - _zone.value -> _zone.rawValue?. where appropriate for hover mode
  • New test file inlineChatController.test.ts - verifies sendRequest options (location, locationData, modelId, modeInfo) match expected values in hover mode

Copilot AI review requested due to automatic review settings April 9, 2026 09:27
@jrieken jrieken enabled auto-merge (squash) April 9, 2026 09:27
Copy link
Copy Markdown
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 optimizes inline chat hover mode by avoiding lazy instantiation/configuration of InlineChatZoneWidget and instead submitting requests directly via IChatService.sendRequest() against the session’s ChatModel, keeping the existing zone mode flow intact.

Changes:

  • Split run() into _runHover() (direct sendRequest) and _runZone() (existing widget-based flow).
  • Added hover-mode helpers _resolveModelId() and _buildLocationData() to replicate widget-derived request options.
  • Added a new browser test suite to validate hover-mode sendRequest option parity (location, locationData, modelId, modeInfo).
Show a summary per file
File Description
src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts Adds hover-mode direct request submission path and supporting model/location resolution helpers; guards autoruns to avoid forcing zone widget instantiation.
src/vs/workbench/contrib/inlineChat/test/browser/inlineChatController.test.ts New tests asserting hover-mode sendRequest parameters match expected parity behaviors.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 3

@jrieken jrieken merged commit e9e008a into main Apr 9, 2026
23 checks passed
@jrieken jrieken deleted the joh/inline-chat-hover-direct-sendrequest branch April 9, 2026 13:54
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 9, 2026
joshspicer pushed a commit that referenced this pull request Apr 9, 2026
…308726)

* inline chat: bypass zone widget in hover mode, use direct sendRequest

* address review: notebook config gate, faked timers in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants