Pull Request Overview
- Opened on October 21, 2026
- Status Merged
- Commit count 1 with first commit October 21, 2026
Total Delta
Open Days
Test Delta
How long has this pull request spent in each phase of its lifecycle?
| Fraction of total time | Business days | Phase |
|---|---|---|
|
|
0.0 days | Authoring 1 commit before pull request opened for review |
|
|
0.0 days | Awaiting first review |
|
|
9.0 days | Merge to deploy (still awaiting deployment) |
Total time for pull request
0.0 business days
from first commit authored to merge
Still awaiting deployment
sessions: keep the draft's editors when submit replaces it with a new session
When a provider commits a draft by replacing it with a session under a different resource, the draft's side-pane tabs (Changes, Files and any opened files) were closed on submit.
Cause
SessionsService handles onDidReplaceSession first and switches the active session synchronously. The layout controller then sees an owner change from the draft key to the committed key and queues a working-set apply. Drafts never save a working set, so the apply resolves to 'empty' and closes the draft's editors. _onSessionReplaced runs only afterwards, too late to carry anything over.
Fix
BaseLayoutController._onSessionReplaced marks the committed session when it replaced the active draft under a different resource and has no saved working set. The queued apply, which runs after both listeners, skips the 'empty' apply for that session, so it keeps the editors on screen and saves them normally when the user leaves. The mark is cleared if the active session moves elsewhere, so another session's tabs can't carry over.
Unchanged: switching from a draft to another existing session still applies that session's working set (possibly empty).
Notes for reviewers
- The extension-backed Copilot Chat Sessions provider commits to a new resource and hits this path. The local Agent Host provider commits to the same resource, so the owner key doesn't change there.
- This was investigated from a report of an empty editor group (Add Tab list) next to the Files details after submitting a new session with the Agent Host Copilot CLI provider. On a dev build (isolated smoke profile, mock LLM) I could not reproduce that report, with the side pane open or closed at submit and opened right after submit or once the session view had loaded. So this PR fixes the related, test-proven defect and does not claim to fix that report. Every mock turn failed with an unrelated allowed-model policy error, and the harness can't select worktree isolation, so a successful worktree-isolated turn was not replayed.
- Likely long-standing: the owner-change "saved working set or
'empty'" apply goes back to #310225 / #315696. Existing submit tests didn't configure workspace folders, so no working-set apply ran in them.
Testing
- New test
[managed tabs / submit] a resource-replace submit keeps the draft's tabs, 4 variants (Editor visible or Details only; replace event before or after the session switch). All 4 fail without the fix and pass with it:./scripts/test.sh --run src/vs/sessions/contrib/layout/test/browser/desktopLayoutController.test.ts --grep "resource-replace submit keeps" -
./scripts/test.sh --runGlob "vs/sessions/contrib/layout/test/**/*.test.js": 291 passing -
npm run typecheck-client: passed -
npm run eslintand hygiene on the changed files: passed
Comments Threads Pending Resolution
Resolved Comment Threads
No resolved comments have been left on this PR.
> [!WARNING]
> Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a `copilot-code-review.yml` file specifying one with the `runs-on` attribute. See the [docs](https://gh.io/AA11tgch) for more details.
## Copilot review overview
2 open issues
-
[beginApply(owner)` is called before the new early-return path. If `beginApply\` requires a…](https://github.com/microsoft/vscode/pull/343333#discussion_r4341835447) · New
[switchToCommitted` updates `draft.isCreated` and `activeSessionObs\` in a transaction, but updates…](https://github.com/microsoft/vscode/pull/343333#discussion_r4341835532) · New
-
What changed in this PR
Fixes a layout regression where submitting a draft that is replaced by a new session under a different resource would close the draft’s side-pane tabs/editors due to an `'empty'` working-set apply happening before `_onSessionReplaced` could carry state over.
**Changes:**
- Add a one-shot marker in `BaseLayoutController` to skip applying `'empty'` working sets for a committed session that replaces the active draft under a different resource.
- Clear the marker when the active session moves away.
- Add a new managed-tabs submit test covering both event orderings and editor visibility variants.
| File | Description |
| ---- | ----------- |
| src/vs/sessions/contrib/layout/test/browser/desktopLayoutController.test.ts | Adds regression coverage ensuring resource-replace submit keeps the draft’s tabs and does not apply `'empty'`. |
| src/vs/sessions/contrib/layout/browser/baseSessionLayoutController.ts | Introduces a marker to prevent an `'empty'` working-set apply from closing editors during draft→committed resource replacement. |
Review effort: Lite