New categories saved but rendered nowhere - #221
Merged
Conversation
Adding a category appeared to do nothing — it saved to the list and then rendered nowhere, because groupByCategory dropped every category with no items. Verified against prod: the list had "Food" and "test" stored in itemCategories while neither showed in the UI. That filter was correct while categories were implicit — a short grocery list should not be buried under 15 unused aisle headers — but wrong the moment users create categories by hand. It also left no drop target: an item cannot be dragged into a category that is not rendered. Visibility now keys off isPristineDefault: an empty category is hidden only when it is a built-in the user has never touched. Anything added, renamed or re-emoji'd stays visible with no items. An empty Other is still hidden — it is noise until something lands in it. The previous behaviour had a test asserting it, which is why this shipped. That test encoded the old assumption rather than the requirement; replaced with cases covering an added category, a renamed built-in, and a re-emoji'd built-in. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Adding a category looked like it silently failed. It didn't — it saved and then rendered nowhere.
Verified against prod before changing anything: the list already had both categories stored.
Cause
groupByCategorydropped every category with no items. That was right while categories were implicit — a five-item grocery list shouldn't be buried under 15 unused aisle headers — and wrong the moment users create categories by hand. It also left no drop target: you can't drag an item into a category that isn't rendered, so a new category could never receive its first item.Fix
Visibility keys off a new
isPristineDefault: an empty category is hidden only when it's a built-in the user has never touched.On how this shipped
The old behaviour had a passing test asserting it (
"groupByCategory omits empty categories, including Other"). It encoded the previous assumption rather than the requirement, so it locked in the bug instead of catching it. Replaced with cases for an added category, a renamed built-in, and a re-emoji'd built-in.151 pass / 0 fail. Both typechecks clean; lint unchanged.
After merge
Wait for Railway, then reload — "Food" and "test" are already in your list and will simply appear. Nothing to re-create.
🤖 Generated with Claude Code
Note
Show empty user-created and modified categories that were previously hidden
groupByCategoryin categories.ts previously hid all empty categories; it now hides only empty built-in categories that are untouched (same name and emoji as the default).isPristineDefaultpredicate in itemCategories.ts checks whether a category matches its original built-in definition by id, name, and emoji.itemsarray when they have no items.Macroscope summarized c62f59d.