Skip to content

Remember previously selected session type and isolation mode#314609

Merged
sandy081 merged 1 commit into
mainfrom
sandy081/remember-session-type-isolation
May 6, 2026
Merged

Remember previously selected session type and isolation mode#314609
sandy081 merged 1 commit into
mainfrom
sandy081/remember-session-type-isolation

Conversation

@sandy081
Copy link
Copy Markdown
Member

@sandy081 sandy081 commented May 6, 2026

Fixes #313556

Persist the user's last-selected session type and isolation mode so they are restored when opening a new session, matching how the workspace picker retains its previously selected folder.

Session type picker:

  • Add IStorageService to SessionTypePicker and MobileSessionTypePicker
  • Store selected type on pick, restore from storage when no active session exists
  • Uses storage key sessions.lastSelectedSessionType (profile/machine scope)

Isolation mode:

  • CopilotCLISession reads stored isolation mode from storage as its initial value instead of hardcoding 'worktree'
  • CopilotCLISession.setIsolationMode() persists to storage whenever the mode changes
  • The isolation picker remains a pure UI widget with no storage dependency
  • Uses storage key sessions.isolationPicker.selectedMode (profile/machine scope)

Persist the user's last-selected session type and isolation mode so
they are restored when opening a new session, matching how the workspace
picker retains its previously selected folder.

Session type picker:
- Add IStorageService to SessionTypePicker and MobileSessionTypePicker
- Store selected type on pick, restore from storage when no session exists

Isolation picker:
- CopilotCLISession reads stored isolation mode as initial value
- CopilotCLISession.setIsolationMode() persists to storage on change
- Picker remains a pure UI widget with no storage dependency

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 6, 2026 01:21
@sandy081 sandy081 enabled auto-merge (squash) May 6, 2026 01:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Screenshot Changes

Base: 5d6fc554 Current: 8c430518

Changed (12)

chat/input/chatInput/Default/Dark
Before After
before after
chat/input/chatInput/Default/Light
Before After
before after
chat/input/chatInput/WithArtifacts/Dark
Before After
before after
chat/input/chatInput/WithFileChanges/Light
Before After
before after
chat/input/chatInput/WithTodos/Dark
Before After
before after
chat/input/chatInput/WithTodos/Light
Before After
before after
chat/input/chatInput/WithTodosAndFileChanges/Dark
Before After
before after
chat/input/chatInput/WithArtifactsAndFileChanges/Light
Before After
before after
chat/input/chatInput/Full/Dark
Before After
before after
chat/widget/chatWidget/SimpleQA/Light
Before After
before after
chat/widget/chatWidget/PendingToolApproval/Light
Before After
before after
chat/widget/chatWidget/MultiTurn/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 adds persistence for new-session defaults in the Agents window so the last chosen session type and isolation mode are reused when creating future sessions, aligning these pickers with the existing remembered-workspace behavior.

Changes:

  • Persist and restore the last selected session type in the shared session type picker.
  • Persist and restore the default isolation mode for Copilot CLI-backed sessions.
  • Thread IStorageService through the desktop and mobile picker flows without adding storage logic to the isolation picker UI itself.
Show a summary per file
File Description
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts Initializes Copilot CLI sessions from stored isolation mode and writes mode changes back to storage.
src/vs/sessions/contrib/chat/browser/sessionTypePicker.ts Restores the remembered session type when no active session exists and persists desktop picker selections.
src/vs/sessions/contrib/chat/browser/mobileSessionTypePicker.ts Wires the mobile session type picker to the same persisted session-type preference.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/sessions/contrib/chat/browser/sessionTypePicker.ts:145

  • This only updates storage when the chosen type differs from the active session's type. If storage is stale and the user explicitly re-picks the already-active type, the event is skipped and the old stored value survives, so the next new session restores the wrong default.
				if (type.id !== this._sessionType) {
					this.storageService.store(STORAGE_KEY_LAST_SESSION_TYPE, type.id, StorageScope.PROFILE, StorageTarget.MACHINE);
					this._onDidSelectSessionType.fire(type.id);
  • Files reviewed: 3/3 changed files
  • Comments generated: 4

Comment on lines 360 to +363
this._isolationMode = mode;
this._isolationModeObservable.set(mode, undefined);
this.setOption(ISOLATION_OPTION_ID, mode);
this.storageService.store(STORAGE_KEY_ISOLATION_MODE, mode, StorageScope.PROFILE, StorageTarget.MACHINE);
Comment on lines 80 to +81
if (id !== undefined && id !== this._sessionType) {
this.storageService.store(STORAGE_KEY_LAST_SESSION_TYPE, id, StorageScope.PROFILE, StorageTarget.MACHINE);
Comment on lines +43 to +45
// Restore the previously selected session type from storage
this._sessionType = this.storageService.get(STORAGE_KEY_LAST_SESSION_TYPE, StorageScope.PROFILE);

Comment on lines +261 to +265
const storedMode = storageService.get(STORAGE_KEY_ISOLATION_MODE, StorageScope.PROFILE);
const initialMode: IsolationMode = storedMode === 'workspace' ? 'workspace' : 'worktree';
this._isolationMode = initialMode;
this._isolationModeObservable.set(initialMode, undefined);
this.setOption(ISOLATION_OPTION_ID, initialMode);
@sandy081 sandy081 merged commit 154bccc into main May 6, 2026
30 checks passed
@sandy081 sandy081 deleted the sandy081/remember-session-type-isolation branch May 6, 2026 01:42
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 6, 2026
@sandy081 sandy081 restored the sandy081/remember-session-type-isolation branch May 6, 2026 07:22
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.

Agents: "New Session" should remember last harness and isolation mode selection

3 participants