Skip to content

Theme system v2: custom palettes, colorblind presets, and monochrome - #72

Merged
ApiliumDevTeam merged 2 commits into
devfrom
chore/tui-themes-polish
Jul 14, 2026
Merged

ApiliumDevTeam merged 2 commits into
devfrom
chore/tui-themes-polish

Conversation

@ApiliumDevTeam

Copy link
Copy Markdown
Collaborator

Summary

Generalizes the TUI theme system so users can define custom palettes, adds colorblind-optimized presets, and cleans up duplicated configuration.

Custom themes

  • Users can now place *.json files in ~/.mayros/themes/ to define custom palettes. Each file must contain the 22 palette color tokens as #RRGGBB hex strings. The loader (theme-loader.ts) validates, caches by mtime, and registers them at startup so /theme <name> and config.ui.theme accept custom names alongside built-ins.
  • ThemePreset generalized from a closed union to string (with BuiltinPreset for the 13 built-ins). resolvePalette consults a custom registry after the builtin switch.

New built-in palettes

  • colorblind-dark and colorblind-light: Okabe-Ito hues that avoid the red/green pairing for error/success (error = vermilion #D55E00, success = sky blue #56B4E9), so deuteranopic and protanopic users get distinguishable semantic colors.
  • monochrome: all tokens use the same foreground, for NO_COLOR environments or minimal terminals.

Polish

  • Deduplicated the THEME_PRESETS array — commands.ts had a local copy that had already drifted (missing the three new palettes). Now imports the canonical list from palettes.ts.
  • Migrated 3 process.stderr.write call sites (fast-mode, compact-handler) to the shared subsystem logger (createSubsystemLogger("tui")).

Test plan

  • pnpm tsgo — 0 errors
  • pnpm lint — 0 errors, 352 warnings
  • pnpm exec vitest run src/tui/ — 512 passed, 1 skipped, 0 failed
  • New tests: theme-loader validation (7), updated palette count assertion (13 presets)

Generalize the theme system so users can define custom palettes in
~/.mayros/themes/*.json. Each file must contain the 22 palette color
tokens as #RRGGBB hex strings; the loader validates, caches by mtime,
and registers them so /theme <name> and config.ui.theme accept custom
names alongside the built-ins.

Add three new built-in palettes:
- colorblind-dark and colorblind-light: Okabe-Ito hues that avoid the
  red/green pairing for error/success (error = vermilion, success = sky
  blue), so deuteranopic and protanopic users get distinguishable
  semantic colors.
- monochrome: all tokens use the same foreground, for NO_COLOR
  environments or users who prefer a minimal terminal.

Generalize ThemePreset from a closed union to string (with BuiltinPreset
for the 13 built-ins), add a custom palette registry, and relax the
/theme handler and config guards to accept custom names. The loader
runs at TUI startup before the config theme is resolved.
Remove the duplicated THEME_PRESETS array from commands.ts (it was a
local copy that had already drifted — missing the three new palettes
added in the theme system update). Import the canonical list from
palettes.ts instead so there is a single source of truth.

Migrate the three process.stderr.write call sites in
tui-command-handlers.ts (fast-mode) and compact-handler.ts to the
shared subsystem logger (createSubsystemLogger("tui")), so TUI
diagnostics route through the same logging infrastructure as the rest
of the codebase instead of writing raw stderr.
@ApiliumDevTeam
ApiliumDevTeam merged commit 1a2b8fa into dev Jul 14, 2026
6 of 7 checks passed
@ApiliumDevTeam
ApiliumDevTeam deleted the chore/tui-themes-polish branch July 14, 2026 11:19
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