refactor(spotlight): registry-driven CMDK preferences#5817
Open
ajnart wants to merge 5 commits into
Open
Conversation
…at/cnmdk-preferences
Enrich userPreferenceDefinitions with mutationGroup field to express which tRPC mutation handles each preference key. Move visiblePreferenceDefinitions helper from spotlight registry to the shared settings package. This enables data-driven mutation dispatch in the CMDK hook and eliminates manual key-to-group mappings.
Replace 5 per-preference children files with a single preference-registry.tsx that auto-generates CMDK children via factory functions. Rewrite useUserPreferences from ~347 lines to ~160 lines by deriving mutation dispatch, pending state, and optimistic values from preference definitions. Simplify settings-children.tsx and groups.tsx to iterate over visiblePreferenceDefinitions instead of maintaining manual mappings. Deleted: board.tsx, color-scheme.tsx, first-day-of-week.tsx, search-engine.tsx, registry.ts Net reduction: ~261 lines across 9 files.
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.
Summary
Stacked on #4915 (
feat/rework-perferences).Replaces the per-preference CMDK children files with a unified, data-driven preference system:
mutationGroupfield linking it to the correct tRPC mutation, enabling data-driven dispatchpreference-registry.tsxauto-generates CMDK children viacreateStaticChildrenandcreateAsyncSelectableChildrenfactory functions, replacing 5 separate filesuseUserPreferencesreduced from ~347 to ~160 lines by deriving mutation dispatch, pending state, and optimistic values from definitionssettings-children.tsxandgroups.tsxnow iterate overvisiblePreferenceDefinitionsinstead of maintaining manual per-key mappingsAdding a new preference now only requires:
definitions.tswithmutationGrouppreference-registry.tsxNet reduction: ~261 lines across 9 files, with 5 files deleted.
Test plan