Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat(docs): Add dark theme support for demo GIFs (#190)
Maximilian Roos17bc77d1e522
diff --git a/docs/CLAUDE.md b/docs/CLAUDE.mdindex 1005d9d68..a7fd7dba3 100644--- a/docs/CLAUDE.md+++ b/docs/CLAUDE.md@@ -272,3 +272,23 @@ Demo GIFs (~2MB each) are stored in a separate `worktrunk-assets` repo to avoid```Deploy runs `fetch-assets` before building.++### Light/dark theme variants++Each demo build generates both light and dark GIF variants:+- `wt-demo.gif` / `wt-demo-dark.gif`+- `wt-select.gif` / `wt-select-dark.gif`++Theme definitions are in `docs/demos/themes.py`, matching the CSS variables in `_variables.html`.++In markdown, use `<picture>` with media queries:+```html+<figure class="demo">+<picture>+ <source srcset="/assets/wt-select-dark.gif" media="(prefers-color-scheme: dark)">+ <img src="/assets/wt-select.gif" alt="wt select demo" width="1600" height="800">+</picture>+</figure>+```++The browser automatically shows the appropriate variant based on system preference.diff --git a/docs/content/select.md b/docs/content/select.mdindex 24bc998e9..7fa7bf7ae 100644--- a/docs/content/select.md+++ b/docs/content/select.md@@ -11,7 +11,10 @@ group = "Commands"Interactive worktree picker with live preview. Navigate worktrees with keyboard shortcuts and press Enter to switch.<figure class="demo">-<img src="/assets/wt-select.gif" alt="wt select demo" width="1600" height="800">+<picture>+ <source srcset="/assets/wt-select-dark.gif" media="(prefers-color-scheme: dark)">+ <img src="/assets/wt-select.gif" alt="wt select demo" width="1600" height="800">+</picture></figure>## Examplesdiff --git a/docs/content/worktrunk.md b/docs/content/worktrunk.mdindex 41a6f0dcd..4e2917330 100644--- a/docs/content/worktrunk.md+++ b/docs/content/worktrunk.md@@ -11,7 +11,10 @@ becomes as simple as scaling git branches.Here's a quick demo:<figure class="demo">-<img src="/assets/wt-demo.gif" alt="Worktrunk demo showing wt list, wt switch, and wt merge" width="1600" height="900">+<picture>+ <source srcset="/assets/wt-demo-dark.gif" media="(prefers-color-scheme: dark)">+ <img src="/assets/wt-demo.gif" alt="Worktrunk demo showing wt list, wt switch, and wt merge" width="1600" height="900">+</picture><figcaption>Listing worktrees, creating a worktree, working, merging back</figcaption></figure>diff --git a/docs/demos/lib.py b/docs/demos/lib.pyindex 4a5b7a72f..b9567ae4b 100644--- a/docs/demos/lib.py+++ b/docs/demos/lib.py@@ -5,6 +5,8 @@ import subprocessfrom dataclasses import dataclassfrom pathlib import Path+from themes import THEMES, format_theme_for_vhs+REAL_HOME = Path.home()diff --git a/docs/demos/themes.py b/docs/demos/themes.pynew file mode 100644index 000000000..d7b002534--- /dev/null+++ b/docs/demos/themes.py@@ -0,0 +1,73 @@+"""VHS theme definitions matching the doc site color palette.++These themes are designed to match the CSS variables in docs/templates/_variables.html+so demos integrate seamlessly with light/dark mode switching.+"""++import json++# Light theme - matches the "Warm Workbench" light mode+# Based on the original "Warm Gold Light" theme with doc site alignment+LIGHT_THEME = {+ "name": "Warm Gold Light",+ "black": "#8c959f",+ "red": "#d73a49",+ "green": "#22863a",+ "yellow": "#d29922",+ "blue": "#0969da",+ "magenta": "#8250df",+ "cyan": "#1b7c83",+ "white": "#8c959f",+ "brightBlack": "#8c959f",+ "brightRed": "#cb2431",+ "brightGreen": "#2ea043",+ "brightYellow": "#f2cc60",+ "brightBlue": "#218bff",+ "brightMagenta": "#a475f9",+ "brightCyan": "#39c5cf",+ "brightWhite": "#8c959f",+ "background": "#FFFDF8",+ "foreground": "#1f2328",+ "cursor": "#d97706",+ "selection": "#FFF0C8",+}++# Dark theme - matches the "Warm Workbench" dark mode from _variables.html+# Colors derived from the CSS custom properties in dark mode:+# --wt-color-bg: #1c1b1a+# --wt-color-text: #e8e6e3+# --wt-color-accent: #f59e0b+# Terminal colors: --cyan: #67d4d4, --green: #4ade80, --red: #f87171, etc.+DARK_THEME = {+ "name": "Warm Workbench Dark",+ "black": "#6b7280", # --bright-black from CSS+ "red": "#f87171", # --red dark mode+ "green": "#4ade80", # --green dark mode+ "yellow": "#fbbf24", # --yellow dark mode+ "blue": "#60a5fa", # --blue dark mode+ "magenta": "#c084fc", # --magenta dark mode+ "cyan": "#67d4d4", # --cyan dark mode+ "white": "#a8a29e", # --wt-color-text-muted+ "brightBlack": "#6b7280", # same as black+ "brightRed": "#fca5a5", # lighter red+ "brightGreen": "#86efac", # lighter green+ "brightYellow": "#fde047", # lighter yellow+ "brightBlue": "#93c5fd", # lighter blue+ "brightMagenta": "#d8b4fe", # lighter magenta+ "brightCyan": "#a5f3fc", # lighter cyan+ "brightWhite": "#e8e6e3", # --wt-color-text+ "background": "#1c1b1a", # --wt-color-bg dark mode+ "foreground": "#e8e6e3", # --wt-color-text dark mode+ "cursor": "#f59e0b", # --wt-color-accent dark mode+ "selection": "#422006", # --wt-color-accent-soft dark mode+}++THEMES = {+ "light": LIGHT_THEME,+ "dark": DARK_THEME,+}+++def format_theme_for_vhs(theme: dict) -> str:+ """Format a theme dict as a VHS Set Theme command value."""+ return json.dumps(theme)diff --git a/docs/demos/wt-select/CLAUDE.md b/docs/demos/wt-select/CLAUDE.mdindex f119551e5..bc8328062 100644--- a/docs/demos/wt-select/CLAUDE.md+++ b/docs/demos/wt-select/CLAUDE.md@@ -7,9 +7,12 @@```Creates:-- `docs/demos/wt-select/out/wt-select.gif` - Animated demo+- `docs/demos/wt-select/out/wt-select.gif` - Light theme demo+- `docs/demos/wt-select/out/wt-select-dark.gif` - Dark theme demo- Demo repo at `docs/demos/wt-select/out/.demo-select/` (gitignored)+Theme colors are defined in `docs/demos/themes.py` to match the doc site's CSS variables.+## Demo GoalsThe demo showcases `wt select` with **realistic variety in all columns**:diff --git a/docs/demos/wt-select/build b/docs/demos/wt-select/buildindex 689d47dbe..aa4ef8e0a 100755--- a/docs/demos/wt-select/build+++ b/docs/demos/wt-select/build@@ -63,6 +63,7 @@ DEMOS_DIR = SCRIPT_DIR.parentsys.path.insert(0, str(DEMOS_DIR))from lib import DemoEnv, run, git, render_tape, record_vhs, build_wt, REAL_HOME+from themes import THEMES, format_theme_for_vhsREPO_ROOT = DEMOS_DIR.parent.parentFIXTURES_DIR = SCRIPT_DIR / "fixtures"@@ -70,7 +71,12 @@ OUT_DIR = SCRIPT_DIR / "out"TAPE_TEMPLATE = SCRIPT_DIR / "demo.tape"TAPE_RENDERED = OUT_DIR / ".rendered.tape"STARSHIP_CONFIG = OUT_DIR / "starship.toml"-OUTPUT_GIF = OUT_DIR / "wt-select.gif"++# Output GIF paths for light and dark variants+OUTPUT_GIFS = {+ "light": OUT_DIR / "wt-select.gif",+ "dark": OUT_DIR / "wt-select-dark.gif",+}# Custom VHS binary with keystroke overlay# Clone and build from: https://github.com/max-sixty/vhs/tree/keypress-overlay@@ -427,19 +433,31 @@ def main():# Record if VHS is available and tape existsvhs_available = Path(VHS_BINARY).exists() if "/" in VHS_BINARY else shutil.which(VHS_BINARY)if vhs_available:- replacements = {- "DEMO_REPO": demo_env.repo,- "DEMO_HOME": demo_env.home,- "REAL_HOME": REAL_HOME,- "STARSHIP_CONFIG": STARSHIP_CONFIG,- "OUTPUT_GIF": OUTPUT_GIF,- "TARGET_DEBUG": REPO_ROOT / "target" / "debug",- }- if render_tape(TAPE_TEMPLATE, TAPE_RENDERED, replacements):- print(f"\nRecording GIF with {VHS_BINARY}...")- record_vhs(TAPE_RENDERED, VHS_BINARY)- TAPE_RENDERED.unlink(missing_ok=True)- print(f"GIF saved to {OUTPUT_GIF}")+ # Record both light and dark variants+ docs_assets = REPO_ROOT / "docs" / "static" / "assets"+ docs_assets.mkdir(parents=True, exist_ok=True)++ for theme_name, output_gif in OUTPUT_GIFS.items():+ theme = THEMES[theme_name]+ replacements = {+ "DEMO_REPO": demo_env.repo,+ "DEMO_HOME": demo_env.home,+ "REAL_HOME": REAL_HOME,+ "STARSHIP_CONFIG": STARSHIP_CONFIG,+ "OUTPUT_GIF": output_gif,+ "TARGET_DEBUG": REPO_ROOT / "target" / "debug",+ "THEME": format_theme_for_vhs(theme),+ }+ if render_tape(TAPE_TEMPLATE, TAPE_RENDERED, replacements):+ print(f"\nRecording {theme_name} GIF with {VHS_BINARY}...")+ record_vhs(TAPE_RENDERED, VHS_BINARY)+ TAPE_RENDERED.unlink(missing_ok=True)+ print(f"GIF saved to {output_gif}")++ # Copy to docs for local preview+ asset_name = output_gif.name+ shutil.copy(output_gif, docs_assets / asset_name)+ print(f"Copied to {docs_assets / asset_name}")else:print(f"\nSkipping GIF recording ({VHS_BINARY} not available)")print("\nTo test manually:")diff --git a/docs/demos/wt-select/demo.tape b/docs/demos/wt-select/demo.tapeindex b1f7f33be..227e4bf9f 100644--- a/docs/demos/wt-select/demo.tape+++ b/docs/demos/wt-select/demo.tape@@ -8,7 +8,7 @@ Set FontSize 19Set FontFamily "Geist Mono, Berkeley Mono, Fira Code, JetBrains Mono, Menlo, Apple Color Emoji"Set Width 1600Set Height 800-Set Theme { "name": "Warm Gold Light", "black": "#8c959f", "red": "#d73a49", "green": "#22863a", "yellow": "#d29922", "blue": "#0969da", "magenta": "#8250df", "cyan": "#1b7c83", "white": "#8c959f", "brightBlack": "#8c959f", "brightRed": "#cb2431", "brightGreen": "#2ea043", "brightYellow": "#f2cc60", "brightBlue": "#218bff", "brightMagenta": "#a475f9", "brightCyan": "#39c5cf", "brightWhite": "#8c959f", "background": "#FFFDF8", "foreground": "#1f2328", "cursor": "#d97706", "selection": "#FFF0C8" }+Set Theme {{THEME}}Set Padding 18Set LineHeight 1.12Set TypingSpeed 28msdiff --git a/docs/demos/wt/build b/docs/demos/wt/buildindex b538b54e4..0f5e94080 100755--- a/docs/demos/wt/build+++ b/docs/demos/wt/build@@ -15,6 +15,7 @@ DEMOS_DIR = SCRIPT_DIR.parentsys.path.insert(0, str(DEMOS_DIR))from lib import DemoEnv, run, git, render_tape, record_vhs, build_wt, REAL_HOME+from themes import THEMES, format_theme_for_vhsREPO_ROOT = DEMOS_DIR.parent.parentFIXTURES_DIR = SCRIPT_DIR / "fixtures"@@ -22,7 +23,12 @@ OUT_DIR = SCRIPT_DIR / "out"TAPE_TEMPLATE = SCRIPT_DIR / "demo.tape"TAPE_RENDERED = OUT_DIR / ".rendered.tape"STARSHIP_CONFIG = OUT_DIR / "starship.toml"-OUTPUT_GIF = OUT_DIR / "wt-demo.gif"++# Output GIF paths for light and dark variants+OUTPUT_GIFS = {+ "light": OUT_DIR / "wt-demo.gif",+ "dark": OUT_DIR / "wt-demo-dark.gif",+}def commit_dated(repo, message, offset):@@ -302,28 +308,34 @@ def main():record_text(text_env)prepare_repo(vhs_env)- replacements = {- "DEMO_REPO": vhs_env.repo,- "DEMO_HOME": vhs_env.home,- "REAL_HOME": REAL_HOME,- "STARSHIP_CONFIG": STARSHIP_CONFIG,- "OUTPUT_GIF": OUTPUT_GIF,- "TARGET_DEBUG": REPO_ROOT / "target" / "debug",- }- render_tape(TAPE_TEMPLATE, TAPE_RENDERED, replacements)- record_vhs(TAPE_RENDERED)-- # Cleanup- TAPE_RENDERED.unlink(missing_ok=True)-- # Copy to docs for local preview++ # Record both light and dark variantsdocs_assets = REPO_ROOT / "docs" / "static" / "assets"docs_assets.mkdir(parents=True, exist_ok=True)- shutil.copy(OUTPUT_GIF, docs_assets / "wt-demo.gif")- print(f"GIF saved to {OUTPUT_GIF}")- print(f"Copied to {docs_assets / 'wt-demo.gif'}")- print(f"Text log saved to {OUT_DIR / 'run.txt'}")+ for theme_name, output_gif in OUTPUT_GIFS.items():+ theme = THEMES[theme_name]+ replacements = {+ "DEMO_REPO": vhs_env.repo,+ "DEMO_HOME": vhs_env.home,+ "REAL_HOME": REAL_HOME,+ "STARSHIP_CONFIG": STARSHIP_CONFIG,+ "OUTPUT_GIF": output_gif,+ "TARGET_DEBUG": REPO_ROOT / "target" / "debug",+ "THEME": format_theme_for_vhs(theme),+ }+ render_tape(TAPE_TEMPLATE, TAPE_RENDERED, replacements)+ print(f"\nRecording {theme_name} GIF...")+ record_vhs(TAPE_RENDERED)+ TAPE_RENDERED.unlink(missing_ok=True)+ print(f"GIF saved to {output_gif}")++ # Copy to docs for local preview+ asset_name = output_gif.name+ shutil.copy(output_gif, docs_assets / asset_name)+ print(f"Copied to {docs_assets / asset_name}")++ print(f"\nText log saved to {OUT_DIR / 'run.txt'}")if __name__ == "__main__":diff --git a/docs/demos/wt/demo.tape b/docs/demos/wt/demo.tapeindex a12129bdd..4d05b16be 100644--- a/docs/demos/wt/demo.tape+++ b/docs/demos/wt/demo.tape@@ -8,7 +8,7 @@ Set FontSize 24Set FontFamily "Geist Mono, Berkeley Mono, Fira Code, JetBrains Mono, Menlo, Apple Color Emoji"Set Width 1600Set Height 900-Set Theme { "name": "Warm Gold Light", "black": "#8c959f", "red": "#d73a49", "green": "#22863a", "yellow": "#d29922", "blue": "#0969da", "magenta": "#8250df", "cyan": "#1b7c83", "white": "#8c959f", "brightBlack": "#8c959f", "brightRed": "#cb2431", "brightGreen": "#2ea043", "brightYellow": "#f2cc60", "brightBlue": "#218bff", "brightMagenta": "#a475f9", "brightCyan": "#39c5cf", "brightWhite": "#8c959f", "background": "#FFFDF8", "foreground": "#1f2328", "cursor": "#d97706", "selection": "#FFF0C8" }+Set Theme {{THEME}}Set Padding 18Set LineHeight 1.12Set TypingSpeed 28msdiff --git a/scripts/publish-assets b/scripts/publish-assetsindex 28bdf67cc..677b91c61 100755--- a/scripts/publish-assets+++ b/scripts/publish-assets@@ -7,9 +7,12 @@ REPO_ROOT="$(dirname "$SCRIPT_DIR")"ASSETS_REPO="$REPO_ROOT/../worktrunk-assets"# Demo sources: name|source_path+# Both light and dark variants for theme switchingDEMOS=("wt-demo.gif|$REPO_ROOT/docs/demos/wt/out/wt-demo.gif"+ "wt-demo-dark.gif|$REPO_ROOT/docs/demos/wt/out/wt-demo-dark.gif""wt-select.gif|$REPO_ROOT/docs/demos/wt-select/out/wt-select.gif"+ "wt-select-dark.gif|$REPO_ROOT/docs/demos/wt-select/out/wt-select-dark.gif")# Clone assets repo if neededdiff --git a/src/main.rs b/src/main.rsindex a934b86ee..cdc6ec3c0 100644--- a/src/main.rs+++ b/src/main.rs@@ -526,8 +526,10 @@ fn expand_demo_placeholders(text: &str) -> String {.unwrap_or_default();// Use figure.demo class for proper mobile styling (no shrink, horizontal scroll)+ // Generate <picture> element for light/dark theme switching+ let dark_filename = filename.trim_end_matches(".gif").to_string() + "-dark.gif";let replacement = format!(- "<figure class=\"demo\">\n<img src=\"/assets/{filename}\" alt=\"{alt_text} demo\"{dim_attrs}>\n</figure>"+ "<figure class=\"demo\">\n<picture>\n <source srcset=\"/assets/{dark_filename}\" media=\"(prefers-color-scheme: dark)\">\n <img src=\"/assets/{filename}\" alt=\"{alt_text} demo\"{dim_attrs}>\n</picture>\n</figure>");let end = after_prefix + end_offset + SUFFIX.len();result.replace_range(start..end, &replacement);