Skip to content

fix(history): show why a query failed, and make retention configurable - #584

Merged
EVWorth merged 2 commits into
mainfrom
fix/history-structured-errors
Sep 9, 2026
Merged

EVWorth merged 2 commits into
mainfrom
fix/history-structured-errors

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #324, closes #323.

The error was recorded but invisible, and gutted on the way (#324)

A failed query showed a red X next to the SQL and nothing else — a user debugging a recurring failure had to rerun the query to find out which table was missing.

The structure was thrown away twice. Worth flagging, because the issue only named the second one:

  1. QueryExecutor flattened every statement failure to CoreError::Query(e.to_string()), dropping the sqlx error before anything could read it.
  2. The command layer then flattened whatever survived to String at the IPC boundary.

MySQL had told us error 1146, SQLSTATE 42S02, on table app.user. None of it reached the frontend. Fixing only the boundary would have changed nothing.

Now: the executor keeps the sqlx error; execute_query and sqlite_execute return QueryError { message, code, sqlState } built from whatever the driver attached — MySQL's number and SQLSTATE, SQLite's extended result code, or nothing at all for a failure that never reached a server. unwrap turns that into a CommandError that still extends Error, so every existing String(e) / e.message caller is untouched; its name deliberately stays "Error" for the same reason.

The panel shows the message inline, truncated with the full text in a tooltip, expanding on click. Code and SQLSTATE sit in the metadata row.

Verified against live MySQL 8 and MariaDB 11 through the real executor: both report 1146/42S02 for a missing table, 1064/42000 for a syntax error.

Three numbers for one cap (#323)

Spec said 10,000, architecture note said 200, code hardcoded 500, user could change none of them. The cap is now a store field defaulting to 500, changed from a control in the history panel. Lowering it trims immediately. It persists, and a pre-existing history loads with the default.

500 is a localStorage figure, not a retention policy — the few megabytes are shared, and one pasted migration script is worth hundreds of ordinary entries. Options go to 10,000 for those who want them.

FR-9.1.3 is now marked partial: the age-based retention it describes is not implemented, and saying so beats leaving it reading as met.

Verification

3 Rust unit tests, 2 live integration tests, 14 frontend tests. Checked against unfixed code: 5/5 panel, 1/2 resultStore (the other is a guard), 7/7 retention fail. Full suites green, clippy clean.

EVWorth and others added 2 commits September 9, 2026 17:21
A failed query recorded `String(e)` and the history panel rendered a red X
next to the SQL and nothing else. A user debugging a recurring failure
could see that something went wrong but not what, and had to rerun the
query to find out which table was missing (#324).

The structure was being thrown away twice. The executor flattened every
statement failure to `CoreError::Query(e.to_string())`, dropping the sqlx
error before anything could read it, and the command layer then flattened
whatever survived to a String at the IPC boundary. MySQL had told us the
error was 1146, SQLSTATE 42S02, on table `app.user`; none of that reached
the frontend.

The executor now keeps the sqlx error. `execute_query` and `sqlite_execute`
return a `QueryError { message, code, sqlState }` instead of a String,
built from whatever the driver attached — MySQL's error number and
SQLSTATE, SQLite's extended result code, or nothing for a failure that
never reached a server. `unwrap` in tauri-api turns that into a
`CommandError` that still extends Error, so every existing `String(e)` and
`e.message` caller is unaffected; its `name` stays "Error" for the same
reason.

The history panel shows the message inline under the SQL, truncated with
the full text in a tooltip, and expands it on click. The code and SQLSTATE
sit in the metadata row, so 1146 and 1064 are distinguishable at a glance.

Verified against live MySQL 8 and MariaDB 11 through the real executor
path: both report 1146/42S02 for a missing table and 1064/42000 for a
syntax error.

Closes #324

Co-Authored-By: Claude Opus 5 <[email protected]>
The spec asked for 10,000 entries, the architecture note said 200, and the
code kept 500 in a constant nobody could change. Three numbers, none
agreeing, and no way for a user to pick any of them (#323).

The cap is now a store field, default 500, changed from a control in the
history panel — next to the count it governs, rather than in a settings
dialog that has nothing else to do with history. Lowering it trims straight
away instead of waiting for the next query, so the panel does not keep
showing rows the setting has just excluded. The choice persists, and a
history stored before this existed loads with the default.

500 stays the default for a reason worth writing down: history lives in
localStorage, whose few megabytes are shared with everything else the app
stores, and a single entry is unbounded — one pasted migration script is
worth hundreds of ordinary queries. Larger settings go up to the spec's
10,000 for people who want them, on the understanding that the ceiling is
bytes and not entries.

The spec and architecture now say the same thing as the code. FR-9.1.3 is
marked partial: the age-based retention it describes is not implemented,
and saying so is better than leaving the requirement reading as met.

Closes #323

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant