Skip to content

fix: reported tx state on failure; bind new tabs - #943

Merged
EVWorth merged 2 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h
Oct 31, 2026
Merged

EVWorth merged 2 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h

Conversation

@EVWorth

@EVWorth EVWorth commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Done by the implementer-frontend lane. 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:

  • A failing DDL or a deadlock ends the transaction, but the inference kept the badge.
  • A CALL opens 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's profile_id.

Binding is skipped when:

  • the tab is already bound;
  • the run has no session;
  • a production run is still waiting for confirmation.

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:

  • Following the selection was a bug. On MySQL, a "+" tab with an open BEGIN kept 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.
  • The prompts now apply. The connection-switch prompts (Show an open transaction, and warn before closing a tab that has one #843, feat(sqlite): transaction state per connection #941) and the SQLite last-tab rollback only work for bound tabs, so binding brings these tabs under them.
  • The badge shows. A "+" tab that runs BEGIN on a SQLite file now shows the file's TX badge.
  • The tab looks like its connection. It now gets its connection's colour and production dot.

Other code that uses the tab's connection was checked:

  • Autocomplete reads the selected connection, which useConnectionSwitching keeps in step, so it is unaffected.
  • sessionsToClose keeps 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:
    • a "+" tab runs BEGIN on a file, and the badge shows on it and on the file's other tabs;
    • closing that tab when it is the last one on the file prompts and sends ROLLBACK.
  • The cases that test the new behaviour fail with the change reverse-applied.
  • Gates:
    • npm run test:unit: 3798 tests pass.
    • Browser tests for QueryToolbar, MainPanel, AppLayout and SQLEditor pass.
    • Lint shows 0 errors and no new warnings. type-check and dprint are clean.

Generated by Claude Code

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
@EVWorth
EVWorth merged commit 928a632 into main Oct 31, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/hopeful-bardeen-1k4d1h branch October 31, 2026 19:44
@github-actions github-actions Bot mentioned this pull request Nov 8, 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: MySQL failure path ignores QueryError.transaction

2 participants