Skip to content

feat: simplify theme usage with bundled theme names#231

Merged
subsy merged 4 commits intomainfrom
feature/theme-improvements
Jan 27, 2026
Merged

feat: simplify theme usage with bundled theme names#231
subsy merged 4 commits intomainfrom
feature/theme-improvements

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Jan 26, 2026

Summary

  • Allow users to specify themes by simple name instead of full path
  • Add three new popular bundled themes: catppuccin, dracula, solarized-light
  • Rename existing themes to shorter names (remove -theme suffix)
  • Bump version to 0.6.0

Usage

# Before
ralph-tui run --theme ./assets/themes/high-contrast-theme.json

# After - just use the theme name
ralph-tui run --theme dracula
ralph-tui run --theme catppuccin
ralph-tui run --theme solarized-light
ralph-tui run --theme high-contrast
ralph-tui run --theme bright

# Custom theme files still work
ralph-tui run --theme ./my-custom-theme.json

Bundled Themes

Theme Description
bright Vibrant colors with purple backgrounds
catppuccin Soothing pastel colors (Mocha variant)
dracula Classic dark theme with vibrant accents
high-contrast High contrast with near-black backgrounds
solarized-light Light theme based on Solarized palette

Test plan

  • Run ralph-tui run --theme dracula and verify theme loads
  • Run ralph-tui run --theme catppuccin and verify theme loads
  • Run ralph-tui run --theme solarized-light and verify light theme renders correctly
  • Run ralph-tui run --theme ./assets/themes/bright.json to verify full paths still work
  • Verify --help shows updated theme documentation

Summary by CodeRabbit

  • New Features

    • Added bundled themes (bright, catppuccin, dracula, high-contrast, solarized-light) and allow selecting a theme by name or by providing a custom JSON file path.
  • Documentation

    • Updated configuration docs and examples to use bundled theme names, show custom theme usage, and clarify the default theme and theme file structure.
  • Tests

    • Added tests for bundled-theme discovery, path resolution and theme loading.
  • Version

    • Bumped package version to 0.6.0.

✏️ Tip: You can customize this high-level summary in your review settings.

Allow users to specify themes by name instead of full path:
  ralph-tui run --theme dracula

Changes:
- Add resolveThemePath() to detect theme names vs file paths
- Rename themes: bright-theme.json -> bright.json, high-contrast-theme.json -> high-contrast.json
- Add new bundled themes: catppuccin, dracula, solarized-light
- Update CLI help text and documentation
- Bump version to 0.6.0
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Preview Jan 27, 2026 0:25am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Adds bundled theme support and three new theme JSON assets; theme loading now accepts either a bundled theme name or a filesystem path via resolveThemePath/loadThemeFile. CLI help, docs, tests and package version updated to reflect named bundled themes.

Changes

Cohort / File(s) Summary
Bundled theme assets
assets/themes/catppuccin.json, assets/themes/dracula.json, assets/themes/solarized-light.json
Added three new JSON theme files defining colour palettes for bg, fg, status, task, accent and border tokens.
Theme resolution & runtime
src/tui/theme.ts
Added BUNDLED_THEMES, exported BundledThemeName, resolveThemePath(themeInput) and updated loadThemeFile(themeInput) to accept bundled names or file paths; added getThemesDir() and adjusted initialization/validation logic.
Tests
tests/tui/theme.test.ts
New/extended tests validating BUNDLED_THEMES, resolveThemePath behaviour (relative/absolute/path formats), loading bundled themes and related error cases.
CLI help
src/commands/run.tsx
Updated --theme help text to indicate it accepts either a bundled theme name or a path to a custom JSON theme.
Docs & README
README.md, website/content/docs/configuration/themes.mdx
Updated examples and prose to show bundled-theme usage by name, expanded bundled theme list to include bright, catppuccin, dracula, high-contrast, solarized-light, and adjusted theme file examples.
Version bump
package.json
Bumped package version from 0.5.0 to 0.6.0.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant ThemeResolver
  participant FS as FileSystem
  participant App as TUI

  User->>CLI: run command with --theme "dracula" or "/path/to/theme.json"
  CLI->>ThemeResolver: loadThemeFile(themeInput)
  ThemeResolver->>ThemeResolver: resolveThemePath(themeInput)
  alt Bundled name
    ThemeResolver->>FS: read <themes_dir>/dracula.json
    FS-->>ThemeResolver: theme JSON
  else File path
    ThemeResolver->>FS: read "/path/to/theme.json"
    FS-->>ThemeResolver: theme JSON
  end
  ThemeResolver->>ThemeResolver: validate & merge with defaults
  ThemeResolver-->>CLI: ThemeColors
  CLI->>App: initializeTheme(ThemeColors)
  App-->>User: start TUI with selected theme
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hop through colours, bright and new,
Dracula coats the midnight hue,
Catppuccin warms a cosy day,
Solarized light leads the way,
I nibble themes and dance — hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling users to specify themes by short bundled names rather than file paths, which is the core objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 68.42105% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.10%. Comparing base (98007ec) to head (dba61d2).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/tui/theme.ts 68.42% 12 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #231      +/-   ##
==========================================
+ Coverage   45.07%   45.10%   +0.02%     
==========================================
  Files          84       84              
  Lines       24402    24437      +35     
==========================================
+ Hits        11000    11023      +23     
- Misses      13402    13414      +12     
Files with missing lines Coverage Δ
src/commands/run.tsx 8.23% <ø> (ø)
src/tui/theme.ts 88.97% <68.42%> (-3.44%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/tui/theme.ts`:
- Around line 389-405: The bundled-theme detection in getThemesDir uses a
POSIX-only '/dist/' substring check on currentDir; update it to a
path-segment-aware check so it works on Windows (backslashes) too: use
path.sep-aware comparisons or path methods to detect a 'dist' segment (e.g.,
split currentDir by path.sep and check if any segment === 'dist', or use
path.basename(currentDir) === 'dist' or currentDir.endsWith(`${path.sep}dist`)).
Modify the if that references currentDir.includes('/dist/') ||
currentDir.endsWith('/dist') to use one of these path-segment checks while
keeping the rest of getThemesDir and its return paths unchanged; refer to the
getThemesDir function and currentDir variable when making the change.
🧹 Nitpick comments (2)
src/tui/theme.ts (1)

407-430: Provide a clearer error for unknown bundled names.
Fail fast with a message listing valid options when a simple name is not in BUNDLED_THEMES, rather than a file‑not‑found path error.

♻️ Optional refactor
   if (isSimpleName) {
+    if (!BUNDLED_THEMES.includes(themeInput as BundledThemeName)) {
+      throw new Error(
+        `Unknown bundled theme '${themeInput}'. Available themes: ${BUNDLED_THEMES.join(', ')}`
+      );
+    }
     // Resolve as bundled theme
     const themesDir = getThemesDir();
     return join(themesDir, `${themeInput}.json`);
   }
src/commands/run.tsx (1)

358-358: Avoid duplicating bundled theme names in help text.
Optional: derive the list from BUNDLED_THEMES to prevent drift when themes change.

♻️ Optional refactor
-import { initializeTheme } from '../tui/theme.js';
+import { initializeTheme, BUNDLED_THEMES } from '../tui/theme.js';
 export function printRunHelp(): void {
-  console.log(`
+  const bundledThemes = BUNDLED_THEMES.join(', ');
+  console.log(`
@@
-  --theme <name|path> Theme name (bright, catppuccin, dracula, high-contrast, solarized-light) or path to custom JSON theme file
+  --theme <name|path> Theme name (${bundledThemes}) or path to custom JSON theme file

AI Agent added 2 commits January 27, 2026 00:05
Use path.sep to split the directory path into segments and check
if 'dist' is among them, instead of POSIX-only substring matching.
Add tests for:
- BUNDLED_THEMES constant (contains all 5 theme names)
- resolveThemePath() function (theme name vs file path detection)
- Loading bundled themes by name (dracula, catppuccin, etc.)
- initializeTheme with bundled theme names

Achieves 98.37% line coverage on theme.ts (up from ~58%).
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/tui/theme.test.ts`:
- Around line 827-833: The test's suffix assertion is OS-dependent; update the
'resolves relative path from cwd' test to build an OS-agnostic expected suffix
(e.g., use Node's path.join('themes', 'custom.json') or path.sep to construct
expectedSuffix) and assert against that instead of the hardcoded
'themes/custom.json'; import or reference the path module and use
resolveThemePath and expectedSuffix (or normalize both strings) so the assertion
works on Windows and POSIX systems.

@subsy subsy merged commit 901b027 into main Jan 27, 2026
9 checks passed
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
feat: simplify theme usage with bundled theme names
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