Repository navigation
fix(history): show why a query failed, and make retention configurable - #584
Merged
Merged
Conversation
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]>
This was referenced Sep 9, 2026
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.
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:
QueryExecutorflattened every statement failure toCoreError::Query(e.to_string()), dropping the sqlx error before anything could read it.Stringat 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_queryandsqlite_executereturnQueryError { 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.unwrapturns that into aCommandErrorthat still extendsError, so every existingString(e)/e.messagecaller is untouched; itsnamedeliberately 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.