Skip to content

fix(favorites): refuse duplicate names, and stop a stray click renaming - #583

Merged
EVWorth merged 1 commit into
mainfrom
fix/favorites-duplicate-names-rename-race
Sep 9, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/favorites-duplicate-names-rename-race

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

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, updateFavorite and moveToCategory return a FavoriteWriteResult and 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. deleteCategory sweeps 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.tsx mocked ../../stores/favoritesStore, which from __tests__/ resolves to src/components/stores/favoritesStore. The mock never applied and every test in the file had been running against the real store. Path corrected.

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]>
@EVWorth
EVWorth merged commit 8ccaf5a into main Sep 9, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/favorites-duplicate-names-rename-race branch September 9, 2026 23:55
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