Skip to content

feat(settings): pick a dark and a light theme from herdr's themes - #1255

Merged
devswha merged 30 commits into
mainfrom
theme-table/3-settings
Oct 17, 2026
Merged

devswha merged 30 commits into
mainfrom
theme-table/3-settings

Conversation

@devswha

@devswha devswha commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Part 3 of 4 for #1121 (stacked: based on part 2; review in order).

Change

Settings → Appearance now has the mode (Dark / Light / System) and two pickers, Dark theme and Light theme. Each lists every theme, so any theme can sit on either side; a theme's own row decides whether it draws dark or light. Choosing one half of a known pair pre-fills the other side only while that side is still the default or the previous pick's sibling.

  • Telemetry first: shared/telemetry.ts accepts every theme id and the darkTheme/lightTheme keys (older apps' snapshots still validate). The Worker is already deployed with this schema; telemetry/deployed.json records it, so the deploy gate passes.
  • Settings model: darkTheme/lightTheme are shared settings; the legacy palette/paletteDark/paletteLight stay as compatibility mirrors. Every saved look loads unchanged.
  • Mixed versions: normalizeThemeChange in PreferenceStore.set is the single place that reconciles old and new clients, decided by the incoming change's key set. Clients never send corrective writes, so an old tab or old server cannot start a write loop.
  • UI strings in ko/ja/zh; theme names stay untranslated.

Validation

  • bun run check fast green (including scripts/telemetry-deployed.test.ts).
  • Migration and sync fixtures through the real usePreferencesSync hook with an on-disk PreferenceStore, counting revisions (no extra PUTs; old server drops keys and recovers).
  • scripts/preferences-sync-regression.ts, settings-pages-demo-regression.ts, composer-fit-demo-regression.ts, telemetry-regression.ts pass on the built demo.
  • Live Worker: bunx wrangler deploy done; an invalid body to /v1/events returns 400.

Settings -> Appearance replaces the palette selects with a Dark theme and a
Light theme picker, always shown, each listing every supported theme in two
groups by kind with the side's own kind first. Picking one of the seven known
pairs fills the other side with its sibling while that side is still the
default or the previous pick's sibling (pickTheme); a side chosen by hand is
kept. Any theme fits either side, so a dark theme chosen for light mode draws
dark, as in herdr.

The theme names are a label map the i18n test reads; the brand names stay as
their projects write them, the color words Amber and Charcoal stay translated.
The stale Colors, Light colors, Dark colors and System-mode strings leave the
three dictionaries, and the Appearance search aliases drop "palette". Settings
selects grow to a finger-sized target on touch screens.

The settings-pages demo regression drives the new pickers for the six legacy
combos, then Tokyo Night with its pre-filled Tokyo Night Day across the mode
toggle, a dark theme on the light side under Light mode, and a hand-chosen
side that is not refilled; the composer-fit regression iterates the real theme
rows of each mode; the telemetry regression picks on the dark side.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4357a3a6-cf5e-4135-83c7-6c0dc814c1f9
📥 Commits

Reviewing files that changed from the base of the PR and between 05f7b51 and b9904b1.

⛔ Files ignored due to path filters: 1
  • bun.lock is excluded by !**/*.lock, !bun.lock
📒 Files selected for processing: 38
  • changelog.d/herdr-themes.md
  • package.json
  • scripts/composer-fit-demo-regression.ts
  • scripts/fixed-sleeps.json
  • scripts/herdr-themes.test.ts
  • scripts/preferences-sync-regression.ts
  • scripts/settings-pages-demo-regression.ts
  • scripts/telemetry-deployed.test.ts
  • scripts/telemetry-regression.ts
  • server/preferences.test.ts
  • server/preferences.ts
  • shared/preferences.ts
  • shared/telemetry.ts
  • src/App.tsx
  • src/components/RepoDiffViewer.tsx
  • src/components/SettingsControls.css
  • src/components/SettingsDialog.tsx
  • src/components/TextFileView.tsx
  • src/lib/api.test.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.test.ts
  • src/lib/i18n.zh.ts
  • src/lib/paletteFor.test.ts
  • src/lib/paletteFor.ts
  • src/lib/paletteSettings.ts
  • src/lib/preferencesSync.hook.test.ts
  • src/lib/preferencesSync.test.ts
  • src/lib/preferencesSync.ts
  • src/lib/settings.legacy-fixture.ts
  • src/lib/settings.test.ts
  • src/lib/settings.ts
  • src/lib/themeFor.test.ts
  • src/lib/themeFor.ts
  • src/lib/themes.test.ts
  • src/lib/themes.ts
  • telemetry/deployed.json
  • telemetry/worker.test.ts
💤 Files with no reviewable changes: 3
  • scripts/fixed-sleeps.json
  • src/lib/paletteFor.test.ts
  • src/lib/paletteFor.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Appearance settings now provide separate selectors for dark and light themes, including the full set of supported themes.
    • Choosing a theme can automatically select its paired theme for the other mode until that mode is customized. Dark themes remain dark when selected for light mode.
    • Theme choices are preserved across settings sync and compatible with older saved preferences.
  • Improvements
    • Theme colors now apply consistently across the terminal, file views, and document styling.
    • Theme selectors have larger touch targets on coarse-pointer devices.

The Appearance settings now store separate dark and light themes, with sibling selection and legacy palette compatibility. Theme resolution, preference synchronization, telemetry validation, and regression checks now support the per-mode theme fields.

Changes: Per-mode theme selection

Layer / File(s) Summary
Theme selection and settings model
src/lib/themes.ts, src/lib/themeFor.ts, src/lib/settings.ts, src/lib/settings.legacy-fixture.ts, src/lib/paletteFor.ts
Settings now store dark and light theme IDs, mirror legacy palette fields, and resolve the active choice to a theme entry. Theme selection can fill an eligible sibling on the other side.
Appearance controls and theme consumers
src/components/SettingsDialog.tsx, src/App.tsx, src/components/RepoDiffViewer.tsx, src/components/TextFileView.tsx, src/components/SettingsControls.css, src/lib/i18n.*.ts, scripts/settings-pages-demo-regression.ts, scripts/composer-fit-demo-regression.ts, scripts/herdr-themes.test.ts, changelog.d/herdr-themes.md
The Appearance page has separate dark and light theme selectors. Theme consumers use the resolved entry, and translations and browser checks cover theme names, selection, and rendering.
Preference synchronization and legacy normalization
shared/preferences.ts, server/preferences.ts, server/preferences.test.ts, src/lib/preferencesSync.ts, src/lib/preferencesSync.test.ts, src/lib/preferencesSync.hook.test.ts, scripts/preferences-sync-regression.ts, scripts/fixed-sleeps.json, package.json
Shared and server preference updates normalize palette changes against per-mode settings. Sync handling and tests cover legacy records, old-server responses, concurrent edits, and updates between clients.
Telemetry theme snapshots
shared/telemetry.ts, src/lib/settings.ts, src/lib/settings.test.ts, src/lib/api.test.ts, telemetry/worker.test.ts, scripts/telemetry-regression.ts, scripts/telemetry-deployed.test.ts, telemetry/deployed.json
Telemetry validation accepts supported theme IDs and snapshots with both per-mode fields. Tests cover serialization, validation, storage, and the recorded Worker fingerprint.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Suggested reviewers: sergiorademacher

Merge Risk: ⚪ Minimal · up to b9904

The change adds separate dark and light theme pickers with compatibility for older clients and servers. No actionable merge-blocking issue remains from this review.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 51.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 31 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: adding separate dark and light theme selection from Herdr's themes.
Description check Passed The description includes the required Change and Validation sections, links the feature to issue #1121, explains compatibility behavior, and lists validation results.
Full details: Docstring Coverage

Explanation

Docstring coverage is 51.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 31 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ne side

A shared document an older server wrote holds only "palette". When a new
client picked a theme for one side, the writer filled the other side with
amber and mirrored amber into "palette", so fresh and older clients lost the
user's synced look. Move the stored palette to the side it was drawn on
before merging the change.
@devswha

devswha commented Oct 17, 2026

Copy link
Copy Markdown
Owner Author

Merge-pass review found a blocker in this PR, fixed in ef4b4bc (and merged up into #1256 as 3465ed9): a shared preferences document an older server wrote holds only palette (no sides). When a new client then picked a theme for one side, normalizeThemeChange filled the other side with amber and mirrored amber into palette, so fresh and older clients lost the user's synced look (e.g. stored {theme: "dark", palette: "charcoal"} + {lightTheme: "one-light"} became {palette: "amber", lightTheme: "one-light"}). The writer now moves the stored palette to the side it was drawn on first. New cases in server/preferences.test.ts seed an older-server file; all three fail before the fix and pass after.

Base automatically changed from theme-table/2-herdr-pairs to main October 17, 2026 12:47
@devswha

devswha commented Oct 17, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@devswha
devswha merged commit e50d923 into main Oct 17, 2026
18 checks passed
@devswha
devswha deleted the theme-table/3-settings branch October 17, 2026 13:06
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