Conversation
Reviewed the full diff. This is careful work: sequence-numbered intents with identity guards, an explicit committed-refresh barrier before validating the remembered session, synchronous anchor capture ahead of the gateway swap, and the serialization rewrite in profile.ts genuinely fixes a latent bug (the old code had concurrent callers both await the same gatewaySwitch promise and then both fall through to dial — the chained previousSwitch version closes that double-dial race). Test quality is well above bar (deferred-gate serialization ordering, re-click-latest-intent, cross-backend scoping). Remaining points:
The i18n sweep (5 locales + types) and settings-search wiring are complete, and the refreshSessionsCommitted boolean contract is cleanly layered under the existing refreshSessions wrapper. |
57e4e97 to
a863932
Compare
a863932 to
748a43c
Compare
What does this PR do?
Desktop profile switches currently start a fresh draft and discard the foreground session. This adds an explicit client-local choice while preserving the existing behavior as the default:
fresh_draftremains the default.restore_last_sessionreturns to the last remembered session for the selected profile after the target source, profile, and session list are authoritative.The restore path reuses current Desktop primitives: gateway activation epochs, exact session-owner resolution, guarded sidebar refresh, native pane focus/open behavior, and existing profile-scoped session-tile placement buckets. It does not persist or reconstruct pane trees.
Restore intent is tied to one exact profile/source activation and native navigation identity. Newer profile selections, explicit New Chat, route/session/pane navigation, ambiguous ownership, refresh failure, and backend failure cancel stale work rather than navigating later.
The PR also scopes Ctrl+Tab session candidates to the active profile. Cycling wraps within a concrete profile. In the aggregate All Profiles view, bare-ID Ctrl+Tab and numeric session switching fail closed because rows can legitimately share IDs across owners; the native sidebar remains available there.
Related work: #77957 and #60202 explore automatic restoration. This PR keeps fresh drafts as the default and makes restoration opt-in.
Related Issue
No new issue. Related: #77957, #60202.
Type of Change
Changes Made
apps/desktop/src/store/profile-switch-behavior.ts: persist the Desktop-local behavior preference and own generation/cancellation state for one profile-switch intent.apps/desktop/src/store/profile.ts: cross the existing fresh-draft barrier, serialize reversal through current gateway activation, and bind restoration to the exact requested/live/descriptor identities.apps/desktop/src/app/contrib/hooks/use-profile-switch-continuity.ts: capture native pane/session navigation, refresh the authoritative target list, resolve exact ownership, and focus or open the remembered session through existing paths.apps/desktop/src/app/session/hooks/use-session-list-actions.ts: separate guarded data publication from loading-barrier ownership using the existing request counter and gateway-switch barrier.apps/desktop/src/store/session-switcher.ts: derive immediate, held, reverse, and numeric Ctrl+Tab candidates from the canonical concrete-profile scope, close stale switcher state when scope changes, and fail closed in All Profiles where bare IDs are not authoritative.How to Test
apps/desktop, run the focused Vitest files for profile switch behavior, continuity, guarded session-list refresh, profile source selection, and session switching.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — N/A: this PR changes only Desktop TypeScriptDocumentation & Housekeeping
docs/, docstrings) — N/A; the preference is described in the Appearance UIcli-config.yaml.exampleif I added/changed config keys — N/A; this is client-local persisted UI stateCONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A; no repository architecture/workflow contract changedScreenshots / Logs
No screenshots: the change is behavioral session/profile continuity rather than a new visual surface.
AI assistance disclosure
Prepared with AI-assisted implementation and independent read-only reviews. The final two-commit branch was replayed onto current
main, audited against intervening changes, and checked for scope/privacy. Vitest, typecheck, build, packaging, and full test suites were intentionally not rerun; their status remains unknown.