Skip to content

retain input in question carousel #298795

Merged
meganrogge merged 4 commits intomainfrom
merogge/retain-input
Mar 2, 2026
Merged

retain input in question carousel #298795
meganrogge merged 4 commits intomainfrom
merogge/retain-input

Conversation

@meganrogge
Copy link
Collaborator

fixes #297406

retain-answers.mov

Copilot AI review requested due to automatic review settings March 2, 2026 20:18
@meganrogge meganrogge marked this pull request as draft March 2, 2026 20:18
@meganrogge meganrogge self-assigned this Mar 2, 2026
@meganrogge meganrogge added this to the March 2026 milestone Mar 2, 2026
@meganrogge meganrogge marked this pull request as ready for review March 2, 2026 20:19
@meganrogge meganrogge enabled auto-merge (squash) March 2, 2026 20:19
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 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) to ChatQuestionCarouselData and ensure they are not serialized.
  • Persist draft state from ChatQuestionCarouselPart into 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 toJSON strips only the completion promise, but the class now also has transient draft state (draftAnswers / draftCurrentIndex) that is intentionally not serialized. Consider updating the comment to reflect that toJSON excludes 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;

@meganrogge meganrogge merged commit 119cb00 into main Mar 2, 2026
20 checks passed
@meganrogge meganrogge deleted the merogge/retain-input branch March 2, 2026 22:07
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.

Input state is not retained if session is moved during ask_questions

3 participants