Repository navigation
fix: rebind orphaned tabs to the run connection - #961
Merged
Merged
Conversation
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
This was referenced Nov 11, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
BEGINon 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'sprofileId, so it was reconnected to that server at the next start.Change
bindUnboundTabinsrc/stores/resultStore.tsbecomesbindTabToRun. It now also rebinds a tab whoseconnectionIdis not live, for both Run and Explain. A tab on another connection that is still live is left alone.setTabConnectionacceptsprofileId: nullto clear the profile. Omitting it still keeps the current one, so existing callers behave as before. The rebind passes the new connection's profile, ornullfor a SQLite file.liveConnectionIds()moves fromuseConnectionSwitching.tstosrc/lib/run-connection.ts, so where a run goes and whether a tab counts as orphaned share one definition.noteTransactioninresultStore.ts, the header ofsrc/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
tab.database, as fix: MySQL failure path ignores QueryError.transaction #942 does.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: omittedprofileIdkeeps the profile,nullclears it.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, andAppLayout.browser.test.tsx(50 tests), which coversuseConnectionSwitching. The rest of the browser suite was not run.Closes #944
Generated by Claude Code