Skip to content

fix(tui): keep closed tabs closed - #40181

Closed
kitlangton wants to merge 1 commit into
v2from
fix-tab-close
Closed

fix(tui): keep closed tabs closed#40181
kitlangton wants to merge 1 commit into
v2from
fix-tab-close

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Keep a session tab closed when another TUI process is still viewing the same session.

Before / After

Before: session tabs use shared persisted state. Closing the active tab in one TUI removed it and navigated that TUI away, but another TUI whose route still pointed at the same session observed the removal. Its route-sync effect treated the missing tab as new and appended it again, so the closed tab reappeared at the end of the strip.

After: a missing tab is opened only when that TUI actually enters the session route, enables tabs, or changes tab scope. Reactive title, unread, root-hydration, and shared-storage updates can update an existing tab but cannot resurrect a removed one. Explicitly navigating away and back still opens the session again.

How

  • packages/tui/src/context/session-tabs.tsx separates route admission from metadata reconciliation with Solid's on helper.
  • Route admission tracks the raw route plus tab scope, so later root hydration does not masquerade as navigation while scope changes still populate the selected store.
  • Metadata reconciliation checks tab presence both before scheduling persistence and again inside the locked mutation, closing the stale-write race.
  • packages/tui/test/context/session-tabs.test.tsx runs two TUI providers against the same persisted state and verifies close, non-resurrection, and explicit reopen behavior.

Scope

  • This preserves shared global/cwd tab persistence across TUI processes.
  • This does not change tab keybindings, close animations, or session deletion.

Testing

  • bun run test test/context/session-tabs.test.tsx test/context/session-tabs-model.test.ts from packages/tui (34 passed)
  • bun typecheck from packages/tui
  • bun run test from packages/tui (592 passed, 5 skipped)
  • Push-hook workspace typecheck (33 tasks passed)
  • git diff --check

The full suite emits the existing asynchronous session-tab lock teardown warning and completes with zero failures.

Flow

sequenceDiagram
  participant A as TUI A
  participant S as Shared tab state
  participant B as TUI B
  A->>S: Close session tab
  S-->>B: Persisted tab removed
  Note over B: Route is unchanged
  B->>B: Metadata sync sees no existing tab
  Note over S: Tab remains closed
  B->>B: Navigate away and back
  B->>S: Open session tab
Loading

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