Repository navigation
fix: reported tx state on failure; bind new tabs - #943
Merged
Merged
Conversation
A failed run on an editor session reports whether the session is still in a transaction (#917), and CommandError carries it since #941. The failure path still inferred the state from the statements that ran, which is wrong when the failing statement changed it itself (DDL's implicit commit, a deadlock's rollback) or when a transaction was opened where the SQL does not show it. Prefer the reported state and keep the inference only as the fallback. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
A tab opened with "+" has no connection and runs on the selected one. On a SQLite file a BEGIN there set the file's flag, but the tab showed no TX badge and the last-tab rollback watcher ignored it, since both read the tab's connection. On MySQL the tab followed the selection to another server while its transaction stayed open on the first, with no prompt. Bind such a tab to the connection its first run (or query plan) goes to, keeping its database and recording the profile for reconnects. From then on it behaves like every tab opened on a connection: the badge, the close prompt and the switch prompt all cover it. Closes #942 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
Merged
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.
Done by the
implementer-frontendlane. Frontend only.Closes #942
1. MySQL: use the transaction state reported after a failure
When a run on an editor session fails and the error carries
CommandError.transaction(reported by the backend since #917), that value now sets the tab's TX flag. Errors without the field fall back to the old inference, which reads the last completed result or the statements before the failing one.That inference could be wrong in two ways:
CALLopens a transaction, but the inference missed it.2. A tab with no connection is bound on its first run
Tabs opened from "+", Ctrl+T, history or favorites start with no
connectionId. They run on whichever connection is selected but were never bound to it. Now the first run or Explain binds the tab to that connection, keeping the tab's database and the connection'sprofile_id.Binding is skipped when:
Visible change: after its first run, such a tab no longer follows the selected connection. Clicking another connection switches to or opens that connection's tab, which is what every tab opened from a connection already does.
Why this behaviour is the right one:
BEGINkept its TX badge when it followed the selection to server B. Its COMMIT and ROLLBACK then went to B, and the real transaction stayed open on A with no prompt.BEGINon a SQLite file now shows the file's TX badge.Other code that uses the tab's connection was checked:
useConnectionSwitchingkeeps in step, so it is unaffected.sessionsToClosekeeps the tab's session on its own connection, so the session isn't closed by mistake.Tests
resultStore.test.ts, "after a failure that reports the session's state (fix: MySQL failure path ignores QueryError.transaction #942)": five cases.resultStore.test.ts, "a tab with no connection, on its first run (fix: MySQL failure path ignores QueryError.transaction #942)": seven cases, covering MySQL, SQLite, a failed run, Explain, an already-bound tab, a run with no session, and a pending production confirmation.EditorTabs.sqlite.test.tsx:BEGINon a file, and the badge shows on it and on the file's other tabs;ROLLBACK.npm run test:unit: 3798 tests pass.Generated by Claude Code