Skip to content

Enhance draft input persistence for remote chat sessions#311312

Merged
DonJayamanne merged 2 commits intomainfrom
don/interior-swan
Apr 20, 2026
Merged

Enhance draft input persistence for remote chat sessions#311312
DonJayamanne merged 2 commits intomainfrom
don/interior-swan

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

Improve the handling of unsent draft inputs in remote chat sessions. Ensure that draft inputs are preserved when switching sessions, allowing users to retain their input state. Add tests to verify that draft inputs are correctly restored after disposing and reloading a session.

Fixes #311310

Copilot AI review requested due to automatic review settings April 20, 2026 05:46
@DonJayamanne DonJayamanne self-assigned this Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 341ef7db Current: fc39d444

Changed (5)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Dark
Before After
before after
editor/inlineCompletions/other/JumpToHint/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Light
Before After
before after
agentSessionsViewer/ApprovalRowLongLabel/Light
Before After
before after

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 improves draft (unsent) chat input persistence for remote/external chat sessions so that switching away from a session and back restores the user’s pending input state. It also adds a regression test validating draft restoration after disposing/reloading a remote session.

Changes:

  • Persist serialized draft inputState for external sessions in session metadata and restore it when loading remote sessions.
  • Persist external session metadata on dispose when there are requests or an unsent draft.
  • Add a unit test covering draft restoration for a remote session after disposal/reload.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts Adds a test to ensure a remote session’s draft input text is restored after dispose/reload.
src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts Extends session metadata to include serialized draft inputState for external sessions.
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Persists metadata for external sessions when there’s a draft; restores draft from stored metadata on remote session load.
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts Adds a public method to flush view input state into the bound input model.
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts Calls the flush helper before dropping the model reference (currently only in the setModel(undefined) path).

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts:210

  • The dispose-time condition model.getRequests().length > 0 || hasDraftInput(model) can leave stale metadata.inputState behind for empty external sessions. Example: type a draft (persisted), reopen, clear the draft back to empty, switch away -> hasDraftInput becomes false and metadata is no longer written, so the old draft will be restored again next open. Consider persisting metadata for external sessions when there is any existing stored inputState to clear, or basing the decision on whether inputModel.toJSON() has changed rather than only whether it’s currently non-empty.
				} else if (!localSessionId && (model.getRequests().length > 0 || hasDraftInput(model))) {
					// External sessions: persist metadata when there are requests, OR when the
					// user has typed/attached unsent input we need to restore on next open.
					await this._chatSessionStore.storeSessionsMetadataOnly([model]);
				}
  • Files reviewed: 5/5 changed files
  • Comments generated: 3

Comment thread src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts
Comment thread src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts
Comment thread src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts
@DonJayamanne DonJayamanne marked this pull request as ready for review April 20, 2026 21:50
@DonJayamanne DonJayamanne enabled auto-merge (squash) April 20, 2026 21:50
@DonJayamanne DonJayamanne merged commit d52c531 into main Apr 20, 2026
26 checks passed
@DonJayamanne DonJayamanne deleted the don/interior-swan branch April 20, 2026 22:11
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 20, 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.

Input State no persisted when using Copilot CLI

4 participants