Repository navigation
Fix #345692: Preserve draft open editors when replacing new draft session - #345807
Merged
Kyle Cutler (kycutler) merged 2 commits intoNov 4, 2026
Merged
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the draft-session state-preservation change, although tests were not run during review.
No open issues 🎉
What changed in this PR
Fixes #345692 by preserving open editors and layout state when a draft session is replaced in the Agents window, preventing workspace-folder changes from closing its browser tab.
Changes:
- Routes draft replacement through the existing session-replacement handler to transfer working-set and layout state.
- Adds regression tests for remembered panel views and avoiding an empty working-set restore.
No actionable findings remain. Tests were not run during this review.
| File | Description |
|---|---|
src/vs/sessions/contrib/layout/test/browser/baseSessionLayoutController.test.ts |
Adds panel-state and working-set preservation tests for draft replacement. |
src/vs/sessions/contrib/layout/browser/baseSessionLayoutController.ts |
Reuses session-replacement handling for new drafts and updates its explanatory comment. |
Review effort: Balanced
Kyle Cutler (kycutler)
approved these changes
Nov 3, 2026
Kyle Cutler (kycutler)
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, thank you Saurabh Sungh (@genius-0963)!
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 3, 2026
Kyle Cutler (kycutler)
enabled auto-merge (squash)
November 3, 2026 22:36
Aaron Munger (amunger)
approved these changes
Nov 4, 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 #345692
Description
When changing the workspace folder of a draft session in the Agents window composer (or when a draft is replaced pre-send),
onDidReplaceNewDraftSessionis emitted with{ from, to }.Previously,
BaseLayoutControllerlistened toonDidReplaceNewDraftSessionby calling_forgetPeerChatState(this._chatLayoutOwnerKeys.forgetSession(from.resource)). This forgot the outgoing draft's session state without transferring layout or working set state to the incoming replacement draftto. Consequently, whentowas activated as the active session,BaseLayoutController's working set restore treatedtoas having an empty working set ('empty') and ranapplyWorkingSet('empty'). This wiped all open editors in the editor group, destroying any browser tab opened from the composer beforeSessionBrowserNetworkContributioncould reconcile and preserve it with the new folder's storage affinity.This PR updates
BaseLayoutControllerto routeonDidReplaceNewDraftSessionthrough_onSessionReplaced(from, to), mirroring howonDidReplaceSessionhandles draft graduation. This:_workingSetAdoptingReplacementonto.resourceso the new draft adopts the active draft's open editors and layout instead of resetting with an empty working set.fromtoto.Verification Steps