Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restructures chat request sending to improve perceived performance by creating the request model (and triggering UI update) before doing potentially slow async work like hook/instruction collection.
Changes:
- Refactors
ChatServiceImplto callmodel.addRequest(...)before awaiting hook/instruction collection, and collects hooks + instructions in parallel afterward. - Moves automatic-instruction collection (previously done in the widget) into the service behind a new
instructionContextoption. - Updates
ChatWidgetto passinstructionContextand removes its prior_autoAttachInstructionsflow.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts | Creates request model earlier; adds async hook/instruction collection helpers; integrates collected instructions into variableData before invoking the agent. |
| src/vs/workbench/contrib/chat/common/chatService/chatService.ts | Adds instructionContext to IChatSendRequestOptions (and imports ChatModeKind). |
| src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts | Removes widget-side auto instruction attachment and passes instructionContext into sendRequest. |
Copilot's findings
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/chat/common/chatService/chatService.ts:1432
instructionContextis required for instruction collection inChatServiceImpl, but pending/queued requests are persisted with a serializedsendOptionsthat currently does not include this field (seeserializeSendOptions/ISerializableSendOptionsinchatModel.ts). After reload/restore, queued requests may run without automatic instruction collection. Consider addinginstructionContext(or enough data to recompute it) to the serializable send-options schema so restored pending requests behave the same as live ones.
instructionContext?: {
modeKind: ChatModeKind;
enabledTools?: UserSelectedTools;
enabledSubAgents?: readonly string[];
};
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts:1165
collectInstructionslogs an error for any thrown exception, including request cancellation. Since this uses the request cancellation token, cancellations will likely produce noisy error logs. Consider checkingisCancellationError(err)(ortoken.isCancellationRequested) and skipping logging (or lowering to trace) for cancellations.
} catch (err) {
this.logService.error('[ChatService] Failed to collect instructions:', err);
return [];
- Files reviewed: 3/3 changed files
- Comments generated: 3
src/vs/workbench/contrib/chat/common/chatService/chatService.ts
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.