Skip to content

feat(history): record every statement, tagged with where it came from - #603

Merged
EVWorth merged 1 commit into
mainfrom
feat/history-statement-origin
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/history-statement-origin

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Closes #586. Unblocked by #595 merging.

Only editor queries were recorded. Grid cell edits, admin actions, imports and restores all called api.executeQuery directly and left no trace — a user who changed three cells and later asked "what did I run against prod" got an incomplete answer with no sign anything was missing. Which statements appeared was an accident of which call sites had been refactored, not a decision.

Everything goes through lib/run-statement.ts now, tagged editor / grid / designer / routine / admin / import / restore / internal. Same shape as DBeaver's Query Manager, and the only way to make coverage a policy rather than an accident.

Defaults

The panel shows the user's own work and offers the rest behind a checkbox — a thousand-statement dump would otherwise bury a day's editing under statements nobody typed.

Reads the app makes on the user's behalf (SHOW GLOBAL STATUS, the backup generator's SHOW CREATE TABLE, the restore's USE) are tagged internal and hidden unless asked for. Recorded rather than dropped, because when something looks odd you want them.

The migration defaults existing rows to editor — the only thing that recorded history before the column existed.

runStatement deliberately does not gate

A caller running a hundred statements from a dump confirms once for the operation, not once per statement. That decision stays with the caller; confirmDestructive remains a separate call.

Two real bugs this surfaced

  • A throw while recording failed the statement. It surfaced as "Save failed" on a grid edit that had already been written — telling the caller to roll back something that succeeded. Caught by an existing test whose result fixture had no rows array, which also showed the row count needed reading defensively.
  • Two browser tests mocked lib/tauri-api without CommandError and failed to import at all. Only the chromium suite catches that; npx vitest run excludes *.browser.test.tsx. I'd missed this class of failure once already this session, which is why I now run both suites before pushing.

Verification

5 new Rust tests (54 in the module), 9 helper tests, 5 store tests, 3 panel tests. Unit 1964, browser 300, all Rust crates, clippy clean, 0 lint errors.

Only editor queries were recorded. Grid cell edits, admin actions, imports
and restores all called api.executeQuery directly and left no trace, so a
user who changed three cells and later asked "what did I run against prod"
got an incomplete answer with no sign anything was missing. Which
statements appeared was an accident of which call sites had been
refactored, not a decision (#586).

Everything goes through lib/run-statement.ts now, tagged editor, grid,
designer, routine, admin, import, restore or internal. That is the same
shape DBeaver's Query Manager uses, and it is the only way to make coverage
a policy rather than an accident.

The panel shows the user's own work by default and offers the rest behind a
checkbox. A thousand-statement dump would otherwise bury a day's editing
under statements nobody typed. Reads the app makes on the user's behalf —
SHOW GLOBAL STATUS, the backup generator's SHOW CREATE TABLE, the restore's
USE — are tagged internal and stay hidden unless asked for, which is
better than not recording them at all when something looks odd.

The migration defaults existing rows to editor, because that is the only
thing that recorded history before the column existed.

runStatement deliberately does not gate. A caller running a hundred
statements from a dump confirms once for the operation rather than once per
statement, so that decision stays with the caller and confirmDestructive
stays a separate call.

A throw while recording no longer fails the statement. It surfaced as
"Save failed" on a grid edit that had already been written — telling the
caller to roll back something that had succeeded. Found by an existing test
whose result fixture had no `rows` array, which also showed the row count
had to be read defensively.

Two browser tests mocked lib/tauri-api without CommandError, which
runStatement imports. They failed to import at all. Only the chromium
suite catches that — `npx vitest run` excludes *.browser.test.tsx.

Closes #586

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 0a04cd5 into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/history-statement-origin branch September 10, 2026 01:16
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.

[P1/arch] History records only editor queries; app-generated SQL is invisible

1 participant