Remember previously selected session type and isolation mode#314609
Merged
Conversation
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>
Contributor
Screenshot ChangesBase: Changed (12) |
Contributor
There was a problem hiding this comment.
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
IStorageServicethrough 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); |
roblourens
approved these changes
May 6, 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 #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:
IStorageServicetoSessionTypePickerandMobileSessionTypePickersessions.lastSelectedSessionType(profile/machine scope)Isolation mode:
CopilotCLISessionreads stored isolation mode from storage as its initial value instead of hardcoding'worktree'CopilotCLISession.setIsolationMode()persists to storage whenever the mode changessessions.isolationPicker.selectedMode(profile/machine scope)