Skip to content

sessions: track preferred session type when no explicit user pick - #321141

Merged
Sandeep Somavarapu (sandy081) merged 4 commits into
mainfrom
sandy081/session-type-default-pref
Jun 12, 2026
Merged

Sandeep Somavarapu (sandy081) merged 4 commits into
mainfrom
sandy081/session-type-default-pref

Conversation

@sandy081

Copy link
Copy Markdown
Member

What

Reworks how the Agents window decides which session type a new chat uses, so that the picker distinguishes an explicit user pick from the preferred (first) session type for the folder.

Picker (sessionTypePicker.ts)

  • The stored preference is now written only when the user explicitly picks a type — observing the active session's type no longer overwrites it.
  • getUserPickedSessionType() returns the explicit pick (or undefined if the user never picked / re-selected the default).
  • getPreferredSessionType(folderUri) returns the first entry in the folder's live session-type list, recomputed so it follows provider changes.
  • Re-selecting the default (first) type clears the stored pick (treated as "no explicit preference").

New chat widget (newChatWidget.ts)

  • New session creation resolves the type from the picker: the user pick when its provider can serve the folder, otherwise the preferred (first) type.
  • When there is no explicit pick, the draft tracks the preferred type and is recreated when the folder's session-type list changes (e.g. a late-registering agent host prepends a new type).

Why

Previously the stored "last session type" could be silently overwritten just by observing an active session, and a new chat would not follow the preferred default as providers register lazily.

Notes for reviewers

  • Persisted preference survives reload and is honored for new sessions.
  • Added unit tests in sessionTypePicker.test.ts covering: preferred follows session-type changes, user pick persists across reload, observing a session doesn't overwrite the pick, and re-selecting the default clears the stored pick.

Co-authored-by: Copilot [email protected]

The session type picker now distinguishes an explicit user pick from the
active session's type. The stored preference is written only when the user
explicitly picks a non-default type, and is cleared when the user re-selects
the default (first) type. New chat creation reads the user pick when present,
otherwise falls back to the preferred (first) session type for the folder and
keeps tracking it as the folder's session-type list changes.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 12, 2026 13:18

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.

Pull request overview

This PR refines how the Agents window selects a session type for new chats by separating an explicit user pick from the folder’s preferred default (first) session type, and updating draft-session recreation behavior to track late provider/session-type changes.

Changes:

  • Update SessionTypePicker to persist a session-type preference only on explicit user selection, expose getUserPickedSessionType(), and compute a live getPreferredSessionType(folderUri) as the folder’s first available type.
  • Update NewChatWidget draft creation to prefer the user’s explicit pick when servable; otherwise fall back to the preferred (first) type, and recreate drafts when preferred changes (when there is no explicit pick).
  • Add unit tests covering preferred-type tracking, persistence across reload, and default re-selection semantics.
Show a summary per file
File Description
src/vs/sessions/contrib/chat/browser/sessionTypePicker.ts Separates stored explicit pick from displayed active-session type; adds preferred-type computation and default re-selection storage behavior.
src/vs/sessions/contrib/chat/browser/newChatWidget.ts Resolves draft session type via explicit pick vs preferred default; adjusts provider-change recreation rules accordingly.
src/vs/sessions/contrib/chat/test/browser/sessionTypePicker.test.ts Adds coverage for preferred-type tracking and explicit-pick persistence/clearing behaviors.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

- Keep the original storage key (sessions.lastSelectedSessionType) to avoid
  resetting existing users' persisted preference.
- Persist the explicit selection regardless of whether the visible pick
  changed (it may reflect the active session): picking the default clears the
  stored preference, any other pick stores it; only fire onDidSelectSessionType
  when the visible pick actually changes.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) merged commit e6455d8 into main Jun 12, 2026
25 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/session-type-default-pref branch June 12, 2026 15:08
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants