Skip to content

fix(tui): preserve session location during handoff - #39886

Merged
kitlangton merged 2 commits into
v2from
session-location-handoff
Jul 31, 2026
Merged

fix(tui): preserve session location during handoff#39886
kitlangton merged 2 commits into
v2from
session-location-handoff

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What

Keep a session's project location available while navigation hydrates its SessionInfo, so immediately creating a new session starts in the selected project.

This follows up on #39753. The inherited-directory behavior worked for hydrated sessions, but the Open menu could navigate with a session fetched privately by the dialog before the shared data context knew about it.

Before / After

Before

  1. Open the Open menu and select a recent session from another project.
  2. The dialog navigates with only the session ID.
  3. Before session synchronization finishes, run New Session.
  4. The TUI cannot find SessionInfo.location and falls back to the launch/default directory.

After

  1. Selecting the session immediately sets LocationProvider.ref from the dialog's SessionInfo.
  2. The session page preserves that provisional location until synchronized data arrives.
  3. New Session prefers hydrated session data and otherwise inherits LocationProvider.ref.

How

  • packages/tui/src/component/dialog-open.tsx sets the selected session's location without changing stable option identity.
  • packages/tui/src/routes/session/index.tsx keeps the existing provisional location while SessionInfo is unavailable.
  • packages/tui/src/app.tsx falls back to the provisional location when creating a new session.
  • packages/tui/test/cli/tui/dialog-open.test.tsx selects a session available only in the dialog's private request and verifies its location is preserved while the shared store remains unhydrated.

Scope

This does not add route-level location state, preload fetched Open-menu sessions into the shared data store, or change server synchronization behavior.

Testing

  • cd packages/tui && bun run test (576 passed, 5 skipped)
  • cd packages/tui && bun typecheck
  • Pre-push hook: bun turbo typecheck --concurrency=3 (33 tasks passed)

Flow

sequenceDiagram
  participant Open as Open dialog
  participant Location as LocationProvider
  participant Data as Session data
  participant New as New Session

  Open->>Location: set selected SessionInfo.location
  Open->>Data: navigate before shared hydration
  alt New Session before hydration
    New->>Location: inherit provisional ref
  else SessionInfo hydrated
    Data-->>New: inherit hydrated location
  end
Loading

@kitlangton
kitlangton merged commit 1311d90 into v2 Jul 31, 2026
12 of 13 checks passed
@kitlangton
kitlangton deleted the session-location-handoff branch July 31, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant