Skip to content

feat(ui): add Catppuccin themes#305

Open
mfkd wants to merge 1 commit into
modem-dev:mainfrom
mfkd:feat/catppuccin-themes
Open

feat(ui): add Catppuccin themes#305
mfkd wants to merge 1 commit into
modem-dev:mainfrom
mfkd:feat/catppuccin-themes

Conversation

@mfkd
Copy link
Copy Markdown

@mfkd mfkd commented May 13, 2026

Summary

  • Add built-in Catppuccin Latte and Mocha themes.
  • Wire the new theme ids through app and OpenTUI theme resolution.
  • Update docs, changelog, and theme coverage tests.

Closes #304.

Testing

  • bun run typecheck
  • bun test

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR adds Catppuccin Latte (light) and Catppuccin Mocha (dark) as two new built-in themes, wiring them through the AppTheme array, the HUNK_DIFF_THEME_NAMES public constant, the OpenTUI component type, and the UI menu — with docs and tests updated throughout.

  • src/ui/themes.ts: Adds the full official Catppuccin palette as CATPPUCCIN_PALETTES, a createCatppuccinTheme factory that maps palette tokens to Hunk's semantic slots via blendHex, and registers both themes in the THEMES array.
  • src/opentui/themes.ts: Extends HUNK_DIFF_THEME_NAMES so external consumers see the new identifiers in the public type.
  • src/ui/themes.test.ts (new): Dedicated suite verifying sentinel palette values, derived diff background math, semantic color distinctness, and syntax-role mapping.

Confidence Score: 4/5

Safe to merge — the theme additions are self-contained, all changed files have tests, and the palette values match the official Catppuccin spec.

The two style concerns are non-blocking: catppuccinBlend is a harmless passthrough, and createCatppuccinTheme's free appearance parameter could produce a mismatched theme if a future caller pairs the wrong flavor with the wrong appearance, but the two existing call sites are correct. No logic errors, missing cases, or broken contracts were found.

src/ui/themes.ts — the createCatppuccinTheme signature accepts appearance independently of flavor, which is worth tightening before more Catppuccin flavors (Frappe, Macchiato) are added.

Important Files Changed

Filename Overview
src/ui/themes.ts Adds CATPPUCCIN_PALETTES, createCatppuccinTheme, and two new theme entries; palette values match the official spec and the blending logic is correct, though the catppuccinBlend wrapper and the freely-passable appearance parameter are minor design rough spots.
src/opentui/themes.ts Extends HUNK_DIFF_THEME_NAMES constant and HunkDiffThemeName union to include the two new Catppuccin variants; straightforward and consistent with existing pattern.
src/ui/themes.test.ts New dedicated test file verifying palette sentinel values, derived diff background correctness, semantic distinctness, and syntax-role mapping; thorough coverage of the new themes.
src/ui/diff/pierre.test.ts Correctly adds Catppuccin Latte and Mocha to the markdown-remap test and only Mocha to the dark-theme isolation test; omission of Latte is intentional and matches the pre-existing pattern for Paper.
src/opentui/HunkDiffView.test.tsx Updates snapshot assertion for HUNK_DIFF_THEME_NAMES to include the two new identifiers; correct and complete.
src/ui/lib/ui-lib.test.ts Extends theme-menu label assertion and adds syntaxStyle existence checks for both Catppuccin variants; no issues.
docs/opentui-component.md Updates the theme prop type column to include the two new identifiers; accurate and complete.
README.md Adds catppuccin-latte and catppuccin-mocha to the inline comment listing valid theme values; accurate.
CHANGELOG.md Single entry documenting the two new themes under Added; correct placement.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["CATPPUCCIN_PALETTES\n(latte | mocha)"] --> B["createCatppuccinTheme(flavor, appearance)"]
    B --> C["catppuccinBlend / blendHex\n(diff backgrounds, accents, notes)"]
    B --> D["withLazySyntaxStyle\n(lazy SyntaxStyle init)"]
    D --> E["THEMES array\n[...existing, latte, mocha]"]
    E --> F["resolveTheme(id, themeMode)"]
    F --> G["AppTheme\n(id, label, appearance, colors…)"]

    H["HUNK_DIFF_THEME_NAMES\n(opentui/themes.ts)"] --> I["HunkDiffThemeName union type"]
    I --> J["HunkDiffView theme prop"]

    G --> K["UI rendering\n(diff rows, syntax, badges)"]
    J --> K
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/ui/themes.ts:189-192
The `appearance` value for each Catppuccin flavor is fixed by definition — Latte is always `"light"` and Mocha is always `"dark"`. Accepting it as a free parameter means a caller could pass `createCatppuccinTheme("latte", "dark")`, producing a visually light theme whose `appearance` field says `"dark"`. The `resolveTheme` function and any rendering pipeline that branches on `appearance` would then apply dark-mode transforms to a light palette. Deriving `appearance` from `flavor` inside the function removes this class of misuse entirely.

```suggestion
/** Map official Catppuccin palette tokens into Hunk's semantic theme slots. */
function createCatppuccinTheme(flavor: CatppuccinFlavor) {
  const palette = CATPPUCCIN_PALETTES[flavor];
  const label = flavor === "latte" ? "Catppuccin Latte" : "Catppuccin Mocha";
  const appearance: AppTheme["appearance"] = flavor === "latte" ? "light" : "dark";
```

### Issue 2 of 2
src/ui/themes.ts:184-188
`catppuccinBlend` is a one-line passthrough that delegates directly to the already-imported `blendHex` without adding any logic or guards. The call sites already read clearly with `blendHex`, so this wrapper adds indirection without benefit.

```suggestion
/** Map official Catppuccin palette tokens into Hunk's semantic theme slots. */
```

Reviews (1): Last reviewed commit: "feat(ui): add Catppuccin themes" | Re-trigger Greptile

Comment thread src/ui/themes.ts
Comment thread src/ui/themes.ts Outdated
@mfkd mfkd mentioned this pull request May 13, 2026
@mfkd mfkd force-pushed the feat/catppuccin-themes branch from 0b0476b to 716e632 Compare May 13, 2026 08:02
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.

Add Catppuccin themes

1 participant