Skip to content

sessions: keep the draft's editors when submit replaces it with a new session - #343333

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sandy081/agents/empty-editor-sidepane-issue
Oct 21, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sandy081/agents/empty-editor-sidepane-issue

Conversation

@sandy081

Copy link
Copy Markdown
Member

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 Agents - add support for session working sets #310225 / sessions: persist layout state per session and across reloads #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 eslint and hygiene on the changed files: passed

… session

A provider can commit a draft by replacing it with a session under a different resource. The visible-sessions model switches to the committed session before the layout controller handles the replacement, so the owner-change apply found no saved working set (drafts never save one) and applied an empty one, closing the draft's Changes and Files tabs. The committed session now adopts the editors on screen instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 20:34
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.144.0 milestone Oct 21, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/sessions/contrib/layout/browser/baseSessionLayoutController.ts
  • src/vs/sessions/contrib/layout/test/browser/desktopLayoutController.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for more details.

Copilot review overview

2 open issues
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

Comment on lines 1250 to +1256
if (isStaleChatOwner() || !this._editorWorkingSetService.beginApply(owner)) {
return;
}
if (workingSet === 'empty' && sessionResource && isEqual(sessionResource, this._workingSetAdoptingReplacement)) {
this._workingSetAdoptingReplacement = undefined;
return;
}
Comment on lines +2157 to +2158
});
harness.visibleSessionsObs.set([committed], undefined);
@sandy081
Sandeep Somavarapu (sandy081) merged commit dee4420 into main Oct 21, 2026
59 of 60 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/agents/empty-editor-sidepane-issue branch October 21, 2026 20:57
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