Skip to content

Don't depend on sessionResource in a few places#299110

Merged
TylerLeonhardt merged 2 commits intomainfrom
tyler/civil-skunk
Mar 4, 2026
Merged

Don't depend on sessionResource in a few places#299110
TylerLeonhardt merged 2 commits intomainfrom
tyler/civil-skunk

Conversation

@TylerLeonhardt
Copy link
Member

Removes some antipaterns and unused variables.

Removes some antipaterns and unused variables.
Copilot AI review requested due to automatic review settings March 4, 2026 04:15
@TylerLeonhardt TylerLeonhardt enabled auto-merge (squash) March 4, 2026 04:15
@TylerLeonhardt TylerLeonhardt self-assigned this Mar 4, 2026
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 removes an anti-pattern where widget state (dynamic variables and tool selections) was fetched via sessionResource-based service lookups (IChatVariablesService.getDynamicVariables(sessionResource)) in places that already had a direct IChatWidget reference. It introduces helper functions getDynamicVariablesForWidget and getSelectedToolAndToolSetsForWidget that work directly with a widget, and adds parseChatRequestWithReferences to ChatRequestParser to accept pre-fetched data instead of going through the service.

Changes:

  • Extracts getDynamicVariablesForWidget and getSelectedToolAndToolSetsForWidget as standalone exported helper functions in chatVariables.ts, and refactors existing call sites to use them directly
  • Adds parseChatRequestWithReferences to ChatRequestParser accepting pre-computed variable/tool data, with parseChatRequest now delegating to it; removes unused sessionResource parameter from ChatInputPart.getAttachedContext and getAttachedAndImplicitContext
  • Adds unit tests for the new helper functions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
chatVariables.ts (browser) Extracts getDynamicVariablesForWidget and getSelectedToolAndToolSetsForWidget as public functions; service methods now delegate to them
chatRequestParser.ts Adds parseChatRequestWithReferences accepting direct data; original parseChatRequest delegates to it
chatInputPart.ts Removes unused sessionResource parameter from getAttachedContext and getAttachedAndImplicitContext
chatWidget.ts Updates two parseChatRequest calls and getAttachedContext/getAttachedAndImplicitContext calls
chatInputEditorContrib.ts Uses parseChatRequestWithReferences with direct widget data
chatPasteProviders.ts Removes IChatVariablesService dependency; uses getDynamicVariablesForWidget
chatContinueInAction.ts Updates to use parseChatRequestWithReferences and parameterless context methods
mainThreadChatAgents2.ts Updates to use parseChatRequestWithReferences
chatVariables.test.ts New test file for getDynamicVariablesForWidget and getSelectedToolAndToolSetsForWidget
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/test/browser/attachments/chatVariables.test.ts:163

  • The test sets isDirectory for directory attachments uses multiple assert.strictEqual calls to verify different properties of the result. Per the project's coding guidelines, prefer a single assert.deepStrictEqual over multiple precise assertions when checking properties of the same object.
		assert.strictEqual(result.length, 1);
		assert.strictEqual(result[0].isFile, false);
		assert.strictEqual(result[0].isDirectory, true);

You can also share your feedback on Copilot code review. Take the survey.

@vs-code-engineering vs-code-engineering bot added this to the 1.111.0 milestone Mar 4, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TylerLeonhardt TylerLeonhardt merged commit 605a07d into main Mar 4, 2026
20 checks passed
@TylerLeonhardt TylerLeonhardt deleted the tyler/civil-skunk branch March 4, 2026 04:48
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