Skip to content

Show an open transaction, and warn before closing a tab that has one #843

Closed

Description

@EVWorth

Severity: P1 (data safety: uncommitted work is rolled back without warning).

What happens

On http://localhost:1420/?mock=connected:

  1. Run BEGIN, then UPDATE customers SET city = 'X' WHERE id = 1. The pane says "Query executed. 1 row(s) affected." Nothing in the toolbar, the tab or the status bar says a transaction is open.
  2. Open a second tab, then close the first one with its X (or middle-click, or "Close Others" from the second tab). It closes at once with no prompt, and its server session is closed, which rolls back the open transaction.
  3. The same happens to a tab holding unsaved SQL: it closes without a prompt, and closing the last query tab replaces its content with a blank tab.

Cause

  • src/stores/editorStore.ts:99-123 (closeTab), closeOtherTabs and closeTabsToRight never confirm anything.
  • src/lib/server-sessions.ts:64-78 (closeStale) closes the tab's session as soon as the tab disappears, or when the tab is pointed at another connection, with no check for an open transaction.
  • The only place the frontend learns that a transaction is open is the grid save (src/hooks/useGridSave.ts:155, outcome.transaction === "open"). No UI shows it.

Fix

  • Track transaction state per tab session. The backend already reports transaction: "open" from apply_grid_edits; return it from execute_query too.
  • Show a "Transaction open — Commit / Rollback" indicator on the tab and in the toolbar.
  • Before closing a tab, or re-pointing it at another connection, confirm when it has an open transaction or unsaved content.

Part of #783.

Activity

  1. added
    bug
    on Oct 21, 2026
  2. EVWorth commented on Oct 23, 2026

    @EVWorth
    OwnerAuthor

    The close-confirmation half of this issue is fixed in the next fix batch: closing a tab with unsaved SQL now asks first. That applies to Close, Close Others, Close to the Right and Ctrl+W.

    The transaction half is still open, because it needs a backend change first. execute_query doesn't report whether a transaction is open; only apply_grid_edits does. Working it out in the frontend by parsing BEGIN/COMMIT wouldn't be reliable, because of autocommit=0, DDL that commits implicitly, and stored procedures. The plan:

    1. Return the session's transaction state with each execute_query result. On MySQL that can come from @@in_transaction; on MariaDB the server status flags carry it.
    2. Show a "Transaction open: Commit / Rollback" indicator on the tab.
    3. Warn before closing a tab, or pointing it at another server, while its transaction is open.

    Generated by Claude Code

  3. EVWorth commented on Oct 30, 2026

    @EVWorth
    OwnerAuthor

    Done across #908 (TX badge, Commit/Rollback, the prompt on close), #916 and #926 (the backend reports the state after success and after failure), and #922 (the prompt before pointing a tab at another connection).


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions