Skip to content

fix(desktop): scope restored navigation by profile (#67709) - #79142

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/desktop-scope-restored-navigation-by-profile
Aug 5, 2026
Merged

fix(desktop): scope restored navigation by profile (#67709)#79142
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/desktop-scope-restored-navigation-by-profile

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

What changed

Salvage of #67823 (cc @Tranquil-Flow), rebased onto current upstream/main to resolve the modify/delete conflicts in use-desktop-integrations.ts and wiring.tsx and the content conflicts in session.ts and session.test.ts.

The original PR's intent is preserved in full:

  • Scope remembered desktop route and session keys by the encoded active profile
  • Discard ambiguous legacy global navigation keys instead of assigning them to an arbitrary profile
  • Delay cold-start restoration until the primary profile and session list have reached renderer.ready
  • Preserve explicit deep-link and hidden-window destinations
  • Restore and persist session routes only when a direct ID or lineage root is explicitly owned by the active profile
  • Clear both profile-scoped route and session state after resume exhaustion

Conflict resolution

upstream/main landed two changes in the same files since the original PR was authored:

  1. fix(desktop): scope the remembered route per profile #74277 (merged) added per-profile route key scoping with LAST_ROUTE_KEY declared separately further down in session.ts. This salvage consolidates LAST_ROUTE_KEY next to LAST_SESSION_KEY at the top, removes the duplicate declaration, and keeps the module-level legacyDiscardNeeded flag with _resetLegacyDiscardForTests() export for test isolation.

  2. Commit 143942d restructured wiring.tsx to call useDesktopIntegrations with $activeGatewayProfile.get() and $desktopBoot.get() (non-reactive .get() calls). This salvage converts both to reactive useStore() subscriptions (activeGatewayProfile and boot) so the profileReady gate and activeProfile prop update correctly when the boot phase or active profile changes.

The use-desktop-integrations.ts hook itself was applied cleanly from the original PR — no modifications to its logic were needed.

Why

The partial fix in #74277 scopes route keys but does NOT gate restoration on profile readiness or validate session ownership, so the race window is still open on current main. Users on v2026.8.3 with multiple profiles still see:

  • Chats appearing under the correct profile but opening another profile's transcript when duplicate session IDs exist
  • New empty Default-profile copies being created on every cold start
  • Session IDs existing in multiple profile databases with different histories

This salvage closes all three layers: profile-scoped keys, renderer.ready gate, and explicit session-ownership validation.

Verification

  • TypeScript renderer + Electron typecheck: passed (tsc --noEmit)
  • ESLint on all five changed files: passed (0 errors, 0 warnings)
  • Focused regression suite: 71/71 passed (session.test.ts + use-desktop-integrations.test.tsx)
  • Production desktop build including assert-dist-built: passed
  • git diff --check: passed
  • Branch shape: exactly 1 commit ahead of current upstream/main

Related

Scope remembered desktop route and session keys by the encoded active
profile. Discard ambiguous legacy global navigation keys instead of
assigning them to an arbitrary profile. Delay cold-start restoration
until the primary profile and session list have reached renderer.ready.
Preserve explicit deep-link and hidden-window destinations. Restore
and persist session routes only when a direct ID or lineage root is
explicitly owned by the active profile. Clear both profile-scoped route
and session state after resume exhaustion.

Closes NousResearch#67709
Co-authored-by: Tranquil-Flow <tranquilflow@users.noreply.github.com>
@kshitijk4poor
kshitijk4poor force-pushed the fix/desktop-scope-restored-navigation-by-profile branch from 6ceddab to 8770754 Compare August 5, 2026 06:50
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) August 5, 2026 06:52
@kshitijk4poor
kshitijk4poor merged commit 530d814 into NousResearch:main Aug 5, 2026
31 checks passed
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.

Desktop cold-start restore can resume a session into the wrong profile and create duplicate session IDs

1 participant