feat(react): group, sort, and filter preference rows#75
Open
soufian3hm wants to merge 2 commits into
Open
Conversation
Frontend-only slice. <Preferences> and <Inbox> gain preferencesFilter, preferencesSort, and preferenceGroups: categories can be filtered, reordered, and rendered under labeled headings, with ungrouped rows following in sorted order. PreferenceGroup is exported. Default rendering is unchanged. Refs dodopayments#38
Greptile SummaryThis PR adds grouping controls for React preference rows. The main changes are:
Confidence Score: 4/5The changed flow looks mergeable after handling duplicate categories in groups.
packages/react/src/components/Preferences.tsx Important Files Changed
Reviews (1): Last reviewed commit: "feat(react): group, sort, filter prefere..." | Re-trigger Greptile |
| </label> | ||
| ))} | ||
| {groups.map((group) => { | ||
| const rows = group.categories.filter((category) => visibleSet.has(category)); |
There was a problem hiding this comment.
When the same category appears in two groups, this renders two checkboxes for the same preference. Both rows use the same key={category} and write the same { category, channel: 'in_app' } preference, so React can reuse the wrong row identity and the panel shows duplicate controls for one setting.
Context Used: CLAUDE.md (source)
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.
Frontend-only slice of #38 -- the grouping / sorting / filtering the issue calls out as shippable against current data. The other three items (critical categories, global per-channel toggle, categories endpoint) are the server half, so this intentionally does not close #38.
What
<Preferences>and<Inbox>gain three optional props:preferencesFilter?: (category: string) => boolean-- show only a subset of categories.preferencesSort?: (a: string, b: string) => number-- order the rows (default: alphabetical, unchanged).preferenceGroups?: PreferenceGroup[]-- render rows under labeled headings; categories in no group follow in sorted order, and an empty group renders no heading.PreferenceGroup({ label, categories }) is exported. It works against the panel's existing category source (loaded items + explicit preference rows), so there is no server change. Default rendering with no props is unchanged.Verification
biome,pnpm --filter "./packages/*" build, typecheck, and vitest are all green -- 110 react tests, including 5 new ones: filter, sort, groups + ungrouped tail, empty-group heading suppression, and the props threading through<Inbox>to the panel. A minor changeset covers@chimely/react.I kept this to the frontend-only slice deliberately. Happy to add a
Closes #38(or open follow-up issues for the server items) if you'd prefer -- your call on how to track the remainder.