Repository navigation
fix(favorites): refuse duplicate names, and stop a stray click renaming - #583
Merged
Merged
Conversation
Two favorites could share a name inside a category. The sidebar shows the name and nothing else at a glance, so the user was left opening rows one at a time to work out which was which. Neither the dialog nor the store checked, so any path in could create the pair (#332). The refusal lives in the store, since every path reaches it and only some of them go through a dialog. addFavorite, renameFavorite, updateFavorite and moveToCategory now return a result instead of nothing, and refuse a name already held in the target category — matched case- and whitespace-insensitively, because "Users" beside "users " is a distinction the sidebar cannot draw. A favorite is never its own duplicate, so recasing a name still works. deleteCategory sweeps its favorites into Uncategorized and can land two of the same name there; those get a numeric suffix rather than being dropped or merged. The dialog stays open on a refusal and says which category holds the name, with an Overwrite button that updates the existing favorite. Closing it would have thrown away the SQL the user came to save along with the name they still had to change. A refused save no longer creates the category that was typed alongside it. Renaming in the sidebar: a press anywhere in the row being renamed now does nothing at all. Before, it blurred the input — committing the rename — and the click that followed loaded the query, so one press the user read as "open this" also wrote a half-typed name (#333). A refused rename keeps the editor open with the reason instead of closing as though it had taken. Escape sets an explicit cancelled flag; that is defensive rather than a fix, since a blur does not currently follow the unmount. Also fixes the mock path in SaveFavoriteDialog.test.tsx, which resolved to src/components/stores/favoritesStore and so never applied — every test in that file had been running against the real store. Closes #332 Closes #333 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 #332, closes #333.
Duplicate names (#332)
Two favorites could share a name inside a category, and the sidebar shows the name and nothing else at a glance. Neither the dialog nor the store checked, so any path in could create the pair.
The refusal is in the store — every path reaches it, only some go through a dialog.
addFavorite,renameFavorite,updateFavoriteandmoveToCategoryreturn aFavoriteWriteResultand refuse a name already held in the target category. Matching is case- and whitespace-insensitive; a favorite is never its own duplicate, so recasing still works.deleteCategorysweeps into Uncategorized and can create a collision there — those get a numeric suffix rather than being dropped or merged.The dialog stays open on a refusal, names the category that holds it, and offers Overwrite. Closing would have discarded the SQL the user came to save. A refused save no longer creates the new category typed alongside it.
Rename race (#333)
A press anywhere in the row being renamed now does nothing. Before, it blurred the input (committing the rename) and the click that followed loaded the query — one press the user read as "open this" also wrote a half-typed name. A refused rename keeps the editor open with the reason.
Escape sets an explicit cancelled flag. Being straight about this one: it is defensive, not a fix — the test for it passes against the unfixed component too, because no blur currently follows the unmount.
Verification
19 new tests. Checked against the unfixed code: 9/9 store tests fail, 3/5 dialog tests fail (2 are guards), 2/5 rename tests fail — the two that describe the actual defect. Full suite 1815 passing.
Incidental
SaveFavoriteDialog.test.tsxmocked../../stores/favoritesStore, which from__tests__/resolves tosrc/components/stores/favoritesStore. The mock never applied and every test in the file had been running against the real store. Path corrected.