Skip to content

refactor(spotlight): registry-driven CMDK preferences#5817

Open
ajnart wants to merge 5 commits into
feat/rework-perferencesfrom
feat/cnmdk-preferences
Open

refactor(spotlight): registry-driven CMDK preferences#5817
ajnart wants to merge 5 commits into
feat/rework-perferencesfrom
feat/cnmdk-preferences

Conversation

@ajnart
Copy link
Copy Markdown
Member

@ajnart ajnart commented May 29, 2026

Summary

Stacked on #4915 (feat/rework-perferences).

Replaces the per-preference CMDK children files with a unified, data-driven preference system:

  • Enriched preference definitions — each definition now carries a mutationGroup field linking it to the correct tRPC mutation, enabling data-driven dispatch
  • Unified preference registrypreference-registry.tsx auto-generates CMDK children via createStaticChildren and createAsyncSelectableChildren factory functions, replacing 5 separate files
  • Rewritten hookuseUserPreferences reduced from ~347 to ~160 lines by deriving mutation dispatch, pending state, and optimistic values from definitions
  • Simplified consumerssettings-children.tsx and groups.tsx now iterate over visiblePreferenceDefinitions instead of maintaining manual per-key mappings

Adding a new preference now only requires:

  1. Add entry to definitions.ts with mutationGroup
  2. Add icon + children factory to preference-registry.tsx
  3. Add translations

Net reduction: ~261 lines across 9 files, with 5 files deleted.

Test plan

  • Open CMDK → verify all preferences appear and filter correctly
  • Toggle boolean preferences (openSearchInNewTab, ddgBangs, pingIcons) → verify optimistic UI and persistence
  • Change select preferences (colorScheme, locale, firstDayOfWeek) → verify children drill-down and value update
  • Change board-based preferences (homeBoardId, mobileHomeBoardId) → verify async loading and selection
  • Change search engine → verify async loading and selection
  • "Full preferences page" link → navigates to manage page
  • Test as guest → only colorScheme and locale visible
  • Verify manage page preferences still work independently

@ajnart ajnart requested a review from a team as a code owner May 29, 2026 14:24
@ajnart ajnart marked this pull request as draft May 29, 2026 14:25
ajnart added 3 commits May 29, 2026 17:05
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.
@ajnart ajnart changed the title wip: user preferences in command palette refactor(spotlight): registry-driven CMDK preferences May 29, 2026
@ajnart ajnart changed the base branch from dev to feat/rework-perferences May 29, 2026 15:27
@ajnart ajnart marked this pull request as ready for review May 29, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant