Skip to content

Agents - preserve reply draft when feedback widget rebuilds#319608

Merged
benibenj merged 1 commit into
mainfrom
benibenj/agents/fix-feedback-editor-input-close-issue
Jun 2, 2026
Merged

Agents - preserve reply draft when feedback widget rebuilds#319608
benibenj merged 1 commit into
mainfrom
benibenj/agents/fix-feedback-editor-input-close-issue

Conversation

@benibenj
Copy link
Copy Markdown
Contributor

@benibenj benibenj commented Jun 2, 2026

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 _clearWidgets and 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:

  • IReplyDraftState is owned by AgentFeedbackEditorWidgetContribution and passed to every AgentFeedbackEditorWidget.
  • _startAddingReply writes the textarea value to the shared drafts map on every input event, and clears it on submit / cancel.
  • Before disposing widgets, _clearWidgets snapshots whether one of the reply textareas was the active element so the rebuilt widget can refocus it.
  • _buildFeedbackItems re-opens the reply input for any comment that has a saved draft, restoring the text and focus.
  • Orphaned drafts (whose comment no longer exists) are pruned after each rebuild.
  • The teardown blur is ignored (this._disposed) so it doesn't wipe the draft as part of widget disposal.

Behaviour

  • Reply input stays open when focus moves elsewhere if it contains text (existing behaviour, now actually upheld across rebuilds).
  • Empty reply input still auto-cancels on blur (unchanged).
  • Escape and Enter on empty text still cancel (unchanged).
  • Caret is placed at the end of restored text so typing continues naturally.

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>
Copilot AI review requested due to automatic review settings June 2, 2026 16:05
@benibenj benibenj enabled auto-merge (squash) June 2, 2026 16:07
Copy link
Copy Markdown
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 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) on AgentFeedbackEditorWidgetContribution and 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

@benibenj benibenj merged commit f5d16d0 into main Jun 2, 2026
26 checks passed
@benibenj benibenj deleted the benibenj/agents/fix-feedback-editor-input-close-issue branch June 2, 2026 16:46
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 2, 2026
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