Skip to content

fix: rebind orphaned tabs to the run connection - #961

Merged
EVWorth merged 1 commit into
devfrom
claude/relaxed-edison-8gs7dq
Nov 11, 2026
Merged

EVWorth merged 1 commit into
devfrom
claude/relaxed-edison-8gs7dq

Conversation

@EVWorth

@EVWorth EVWorth commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Problem

A tab bound to a connection that is gone (a closed SQLite file, a disconnected server) runs on the selected connection but stayed bound to the dead one. A BEGIN on a SQLite file from such a tab showed no TX badge on that tab, the last-tab rollback watcher (#941) did not cover it, and the close and switch prompts missed it. The tab also kept the old server's profileId, so it was reconnected to that server at the next start.

Change

  • bindUnboundTab in src/stores/resultStore.ts becomes bindTabToRun. It now also rebinds a tab whose connectionId is not live, for both Run and Explain. A tab on another connection that is still live is left alone.
  • The rebind is silent, as fix: MySQL failure path ignores QueryError.transaction #942 is for a tab with no connection: the connection the tab leaves is already gone, so there is nothing to roll back and nothing to ask.
  • setTabConnection accepts profileId: null to clear the profile. Omitting it still keeps the current one, so existing callers behave as before. The rebind passes the new connection's profile, or null for a SQLite file.
  • liveConnectionIds() moves from useConnectionSwitching.ts to src/lib/run-connection.ts, so where a run goes and whether a tab counts as orphaned share one definition.
  • Two stale comments fixed (noteTransaction in resultStore.ts, the header of src/lib/transaction-tracking.ts): the backend probes MySQL and MariaDB sessions too, so the statement-reading fallback applies only when the probe got no answer.

No per-tab transaction flag needed clearing on rebind: disconnecting a server or closing a file already forgets the flags of its tabs, and moving the tab makes the session watcher drop anything left.

Not changed

Tests

  • resultStore.test.ts: 8 new tests for the orphaned tab (rebound on Run and on Explain, to a server and to a SQLite file; profile replaced or cleared; badge shown; rollback on last tab; close prompt; two guards for a tab on another live connection). One fix: MySQL failure path ignores QueryError.transaction #942 test now makes its second connection live, since it would otherwise be an orphan.
  • editorStore.test.ts: omitted profileId keeps the profile, null clears it.
  • Seven of these fail with the fix reverse-applied.

Gates run locally: npm run lint (0 errors), npm run type-check, npm run test:unit (204 files, 3814 tests), npx dprint check --list-different, and AppLayout.browser.test.tsx (50 tests), which covers useConnectionSwitching. The rest of the browser suite was not run.

Closes #944


Generated by Claude Code

A tab whose SQLite file was closed or whose server was disconnected ran
on the selected connection but stayed bound to the dead one, so a
transaction it opened had no TX badge and was missed by the rollback
watcher and the close prompts. Bind it to where it ran, and replace or
clear its stale profile so it is not reconnected to the old server at
the next start.

Closes #944

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_014tzYxya6Umczq4EBPTYkX4
@EVWorth
EVWorth merged commit e4dff4b into dev Nov 11, 2026
15 checks passed
@EVWorth
EVWorth deleted the claude/relaxed-edison-8gs7dq branch November 11, 2026 00:30
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
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.

fix: SQLite tx untracked from orphaned tabs

2 participants