Agents - preserve reply draft when feedback widget rebuilds#319608
Merged
benibenj merged 1 commit intoJun 2, 2026
Conversation
The reply input on an agent feedback comment was disposed every time the widget was rebuilt (e.g. when `onDidChangeFeedback` fired for unrelated items), losing the user's in-progress text. Persist draft text and focus on the contribution so a rebuilt widget can restore the open reply input and re-focus it if it was focused. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a usability issue in the Agents feedback editor widget where an in-progress reply could be lost when the widget is torn down and rebuilt due to unrelated feedback / review state changes. It introduces shared draft state owned by the editor contribution so reply text (and optionally focus) can be restored across rebuilds.
Changes:
- Add a shared reply-draft store (
drafts+focusedCommentId) onAgentFeedbackEditorWidgetContributionand pass it into each widget instance. - Persist reply textarea content into the shared store on
input, restore drafts during_buildFeedbackItems, and capture focused reply before teardown so focus can be restored. - Update the widget fixture to match the new constructor parameter.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/contrib/agentFeedback/browser/agentFeedbackEditorWidgetContribution.ts | Adds shared reply-draft state and restoration logic across widget rebuilds, plus focus snapshotting and orphan draft pruning. |
| src/vs/sessions/contrib/agentFeedback/test/browser/agentFeedbackEditorWidget.fixture.ts | Updates fixture instantiation to include the new optional draft-state argument. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
benvillalobos
approved these changes
Jun 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.
Problem
When typing a reply on a feedback item in the agent feedback editor widget, the reply input could close even though it had text in it. This happened because any unrelated
onDidChangeFeedback(or code/PR review state change) tears down all widgets via_clearWidgetsand rebuilds them, throwing away the textarea the user was typing in.Fix
Persist in-progress reply state on the contribution (which survives rebuilds) and have each widget restore it:
IReplyDraftStateis owned byAgentFeedbackEditorWidgetContributionand passed to everyAgentFeedbackEditorWidget._startAddingReplywrites the textarea value to the shared drafts map on everyinputevent, and clears it on submit / cancel._clearWidgetssnapshots whether one of the reply textareas was the active element so the rebuilt widget can refocus it._buildFeedbackItemsre-opens the reply input for any comment that has a saved draft, restoring the text and focus.this._disposed) so it doesn't wipe the draft as part of widget disposal.Behaviour
EscapeandEnteron empty text still cancel (unchanged).