refactor(desktop): extract AppearanceSettings into section components#1431
refactor(desktop): extract AppearanceSettings into section components#1431
Conversation
Add configurable font family and font size settings for both terminal panels and editor/diff views in the Appearance settings page. - Add terminal_font_family, terminal_font_size, editor_font_family, editor_font_size columns to local-db settings table - Add getFontSettings/setFontSettings tRPC procedures - Add Editor Font and Terminal Font sections to Appearance settings with text input for font family, number input for size (10-24), and reset to default button - Wire up Terminal to apply custom fonts via xterm options with live updates - Wire up Monaco editor/diff views via useMonacoEditorOptions hook - Add settings search entries for font customization
…ts and live preview
- Move Zod schema and transform logic to font-settings.utils.ts (single source of truth) and import in both the router and test file - Add .max(500) length limit on font family strings for safety - Add no-op guard to skip DB write when no fields are provided - Remove ineffective defaults test that only asserted its own literals Addresses remaining CodeRabbit review feedback on PR #1336. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add draft state for font size inputs (editor & terminal) so mutations only fire on blur instead of every keystroke, matching the existing font family draft pattern - Replace fake snapshot UUID in migration 0021 with a real UUID v4
…ings # Conflicts: # packages/local-db/drizzle/meta/0021_snapshot.json # packages/local-db/drizzle/meta/_journal.json
…ings # Conflicts: # packages/local-db/src/schema/schema.ts
Break the monolithic 432-line AppearanceSettings into focused section components following the established TerminalSettings pattern: - FontPreview: extracted inline preview component - FontSettingSection: reusable editor/terminal font section (deduplicates ~120 lines) - ThemeSection: owns theme store hooks and grid rendering - MarkdownStyleSection: owns markdown store hooks and select dropdown - CustomThemesSection: placeholder for upcoming feature Use SectionList for automatic border separators, replacing fragile conditional className logic.
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis pull request introduces a complete font settings feature enabling users to customize terminal and editor fonts independently. It adds backend validation and storage, database schema extensions, new UI components for font customization, and integrations with Monaco editor and terminal rendering to dynamically apply user-selected fonts. Changes
Sequence DiagramsequenceDiagram
actor User
participant UI as FontSettingSection<br/>(React Component)
participant TrpcApi as electronTrpc API<br/>(Settings Router)
participant Db as Database
participant Monaco as Monaco Editor<br/>(via Hook)
participant Terminal as Terminal<br/>(xterm)
User->>UI: Opens Font Settings
UI->>TrpcApi: getFontSettings.useQuery()
TrpcApi->>Db: Query current font settings
Db-->>TrpcApi: Returns fontFamily, fontSize
TrpcApi-->>UI: Populate preview with current fonts
User->>UI: Changes font family/size (draft)
UI->>UI: Update local draft state<br/>(optimistic UI)
User->>UI: Blur / Commit changes
UI->>TrpcApi: setFontSettings(input)
TrpcApi->>TrpcApi: Validate via schema<br/>Transform (trim, sanitize)
TrpcApi->>Db: Upsert settings record
Db-->>TrpcApi: Confirm update
TrpcApi-->>UI: Return success
TrpcApi->>Monaco: invalidateQueries (cache refresh)
TrpcApi->>Terminal: invalidateQueries (cache refresh)
Monaco->>TrpcApi: useMonacoEditorOptions hook fetches fonts
TrpcApi-->>Monaco: Return merged options<br/>(fontFamily, fontSize)
Monaco->>Monaco: Apply options to editor instances
Terminal->>TrpcApi: getFontSettings.useQuery()
TrpcApi-->>Terminal: Return terminal font settings
Terminal->>Terminal: Apply fontFamily/fontSize<br/>to xterm, call fit()
Monaco-->>User: ✓ Editor displays custom font
Terminal-->>User: ✓ Terminal displays custom font
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Summary
AppearanceSettingsinto focused section components following the establishedTerminalSettingspatternFontSettingSectioncomponent parameterized byvariantSectionListfor automatic border separators, replacing fragile conditional className logicBuilds on top of #1336 by @uinafdev
Test plan
Summary by CodeRabbit
Release Notes
New Features
• Customize font family and size independently for editor and terminal with live preview of changes
• Font settings searchable and accessible from the appearance settings panel
• Reset fonts to system defaults instantly when desired
• Supported font size range: 10-24pt for optimal readability and usability
• Support for Nerd Fonts in terminal configuration