Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes loss of in-progress ask_questions inputs when the chat UI is re-created (e.g., moving Chat into the editor area) by persisting draft question/answer state on the underlying ChatQuestionCarouselData model rather than only in the widget.
Changes:
- Add transient draft fields (
draftAnswers,draftCurrentIndex) toChatQuestionCarouselDataand ensure they are not serialized. - Persist draft state from
ChatQuestionCarouselPartinto the model during interaction, and clear draft state once the carousel is submitted/auto-finalized. - Add unit and browser tests to cover draft retention across widget recreation and serialization behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatQuestionCarouselData.ts | Adds transient draft fields for in-memory retention; toJSON remains serialization-safe. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts | Restores/persists draft state to the model during interaction; saves on dispose; clears on submit paths via renderer. |
| src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts | Clears draft state on submit/auto-finalize and ensures data/isUsed are set consistently. |
| src/vs/workbench/contrib/chat/test/common/model/chatQuestionCarouselData.test.ts | Extends serialization test to ensure draft fields are not included in toJSON. |
| src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatQuestionCarouselPart.test.ts | Adds coverage for draft retention across widget disposal/recreation. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatQuestionCarouselData.ts:18
- The class doc comment says
toJSONstrips only thecompletionpromise, but the class now also has transient draft state (draftAnswers/draftCurrentIndex) that is intentionally not serialized. Consider updating the comment to reflect thattoJSONexcludes all transient runtime fields (completion + draft state).
export class ChatQuestionCarouselData implements IChatQuestionCarousel {
public readonly kind = 'questionCarousel' as const;
public readonly completion = new DeferredPromise<{ answers: Record<string, unknown> | undefined }>();
public draftAnswers: Record<string, unknown> | undefined;
public draftCurrentIndex: number | undefined;
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts
Show resolved
Hide resolved
connor4312
approved these changes
Mar 2, 2026
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.
fixes #297406
retain-answers.mov