Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs(demos): record demos with the site's current palette (#4069)
Worktrunk Botee52834701c6
diff --git a/docs/demos/CLAUDE.md b/docs/demos/CLAUDE.mdindex 7bb6f636b..6d604e333 100644--- a/docs/demos/CLAUDE.md+++ b/docs/demos/CLAUDE.md@@ -77,7 +77,7 @@ TUI demos (Zellij, Claude UI) can't use text snapshots because VHS only captures4. Validation runs automatically when building TUI demos with defined checkpointsCheckpoints are defined in `docs/demos/shared/validation.py`. To add validation to a TUI demo:-1. Identify key frame numbers by examining the GIF (30fps, so frame 90 = 3 seconds)+1. Identify key frame numbers by examining the GIF (25fps, so frame 75 = 3 seconds; a negative frame counts back from the last, for the state a recording ends in)2. Define checkpoint patterns in `validation.py` with frame numbers, expected patterns, and forbidden patterns`wt-switch`, `wt-statusline`, and `wt-zellij-omnibus` have checkpoints. Other TUI demos are skipped until checkpoints are added.@@ -208,7 +208,7 @@ Each theme starts from a freshly prepared demo environment because recording a tSocial build generates light only (social media doesn't support theme-switching media queries).-Theme definitions are in `docs/demos/shared/themes.py`, matching the `--wt-*` custom properties in `docs/src/styles/custom.css`.+Each recording's environment carries its theme. The VHS terminal, Zellij, and the starship prompt take their colors from `docs/demos/shared/themes.py`, which reads the `--wt-*` custom properties in `docs/src/styles/custom.css` when the build runs, so a site palette change reaches the GIFs on the next recording. Claude Code and delta switch to their own light or dark theme.## Debugging a demo environmentdiff --git a/docs/demos/build b/docs/demos/buildindex d20b74267..f229b009f 100755--- a/docs/demos/build+++ b/docs/demos/build@@ -15,7 +15,6 @@ from __future__ import annotationsimport argparseimport os-import shutilimport subprocessimport sysimport tempfile@@ -30,7 +29,6 @@ SCRIPT_DIR = Path(__file__).parentsys.path.insert(0, str(SCRIPT_DIR))from shared import ( # noqa: E402- FIXTURES_DIR,VALIDATION_RS,DemoEnv,DemoSize,@@ -43,7 +41,9 @@ from shared import ( # noqa: E402check_dependencies,check_ffmpeg_libass,setup_demo_output,+ write_starship_config,record_theme,+ recorder_env,SIZE_DOCS,SIZE_DOCS_MOBILE,SIZE_SOCIAL,@@ -73,18 +73,20 @@ CLAUDE_DEMOS = {"wt-switch", "wt-statusline", "wt-zellij-omnibus"}@contextmanager-def prepared_demo_env(output_name: str, setup_func):+def prepared_demo_env(output_name: str, theme: str, setup_func):"""Create a prepared demo environment and remove it after use."""with tempfile.TemporaryDirectory(prefix="wt-demo-", ignore_cleanup_errors=True) as demo_env_dir:- yield _prepare_demo_env(Path(demo_env_dir), output_name, setup_func)+ yield _prepare_demo_env(Path(demo_env_dir), output_name, theme, setup_func)-def _prepare_demo_env(out_dir: Path, output_name: str, setup_func) -> DemoEnv:+def _prepare_demo_env(+ out_dir: Path, output_name: str, theme: str, setup_func+) -> DemoEnv:"""Prepare a demo environment at an existing directory."""- setup_demo_output(out_dir)- env = DemoEnv(name=output_name, out_dir=out_dir, repo_name="acme")+ env = DemoEnv(name=output_name, out_dir=out_dir, theme=theme, repo_name="acme")+ setup_demo_output(env)setup_func(env)return env@@ -379,8 +381,9 @@ def record_demo(if not tape_path.exists():raise FileNotFoundError(f"{tape_file} not found")+ # Snapshot and text output carry no colors, so they use the first theme.if snapshot_mode:- with prepared_demo_env(output_name, setup_func) as env:+ with prepared_demo_env(output_name, themes[0], setup_func) as env:output_snap = SNAPSHOTS_DIR / f"{output_name}.snap"record_snapshot(env, tape_path, output_snap, REPO_ROOT)elapsed = time.monotonic() - t0@@ -388,7 +391,7 @@ def record_demo(return elapsedif text_mode:- with prepared_demo_env(output_name, setup_func) as env:+ with prepared_demo_env(output_name, themes[0], setup_func) as env:replacements = build_tape_replacements(env, REPO_ROOT)output_txt = mode_out_dir / f"{output_name}.txt"record_text(env, tape_path, output_txt, replacements, REPO_ROOT)@@ -405,11 +408,10 @@ def record_demo(for theme, output_gif in output_gifs.items():# Every tape mutates its repository. A fresh environment keeps one# theme's commands from changing the starting state of the next theme.- with prepared_demo_env(output_name, setup_func) as env:+ with prepared_demo_env(output_name, theme, setup_func) as env:record_theme(env,tape_path,- theme,output_gif,REPO_ROOT,vhs_binary=vhs_binary,@@ -449,15 +451,14 @@ def record_demo(# =============================================================================-def spawn_debug_shell(env: DemoEnv, starship_config: Path):+def spawn_debug_shell(env: DemoEnv):"""Spawn an interactive fish shell with the demo environment set up."""- shell_env = os.environ.copy()- shell_env.pop("CLAUDE_CONFIG_DIR", None)+ shell_env = recorder_env()shell_env.update({"HOME": str(env.home),"XDG_CONFIG_HOME": str(env.home / ".config"),- "STARSHIP_CONFIG": str(starship_config),+ "STARSHIP_CONFIG": str(env.starship_config),"PATH": f"{REPO_ROOT / 'target' / 'debug'}:{env.home / '.local' / 'bin'}:{os.environ.get('PATH', '')}",# Keep real rustup/cargo for any rust tools"RUSTUP_HOME": str(Path.home() / ".rustup"),@@ -610,7 +611,7 @@ def build_target(target: str, args, vhs_binary: str) -> list[str]:mode_out_dir.mkdir(parents=True, exist_ok=True)if target == "docs":- shutil.copy(FIXTURES_DIR / "starship.toml", mode_out_dir / "starship.toml")+ write_starship_config(mode_out_dir / "starship.toml", "light")target_config = TARGETS[target]demos = target_config["demos"]@@ -642,9 +643,9 @@ def build_target(target: str, args, vhs_binary: str) -> list[str]:if args.shell:tape_file, output_name, setup_func = demos[0]debug_dir = Path(tempfile.mkdtemp(prefix="wt-demo-"))- env = _prepare_demo_env(debug_dir, output_name, setup_func)+ env = _prepare_demo_env(debug_dir, output_name, themes[0], setup_func)print(f"Demo repo: {env.repo}")- spawn_debug_shell(env, FIXTURES_DIR / "starship.toml")+ spawn_debug_shell(env)return []# TUI demos run sequentially (they use Zellij which conflicts when parallel)diff --git a/docs/demos/shared/__init__.py b/docs/demos/shared/__init__.pyindex ac662b729..6b423b63f 100644--- a/docs/demos/shared/__init__.py+++ b/docs/demos/shared/__init__.py@@ -26,7 +26,9 @@ from .lib import (check_dependencies,check_ffmpeg_libass,setup_demo_output,+ write_starship_config,record_theme,+ recorder_env,# Text output recordingrecord_text,build_tape_replacements,@@ -66,7 +68,9 @@ __all__ = ["check_dependencies","check_ffmpeg_libass","setup_demo_output",+ "write_starship_config","record_theme",+ "recorder_env",# Text output recording"record_text","build_tape_replacements",diff --git a/docs/demos/shared/fixtures/starship.toml b/docs/demos/shared/fixtures/starship.tomlindex eecc0df50..8b76b73af 100644--- a/docs/demos/shared/fixtures/starship.toml+++ b/docs/demos/shared/fixtures/starship.toml@@ -1,19 +1,10 @@format = "$directory$character"-palette = "gh_light"--[palettes.gh_light]-fg = "#1f2328"-bg = "#ffffff"-blue = "#0969da"-yellow = "#d29922"-green = "#2ea043"-red = "#d73a49"-muted = "#57606a"-soft = "#8b7355"-gold = "#d97706"+# setup_demo_output appends [palettes.site] with the site's colors for the+# recording's theme.+palette = "site"[directory]-style = "bold fg:soft"+style = "bold fg:craft"truncation_length = 3truncate_to_repo = truehome_symbol = "~"@@ -40,9 +31,9 @@ format = " [$duration]($style)"style = "fg:muted"[character]-success_symbol = "[❯](fg:soft)"+success_symbol = "[❯](fg:craft)"error_symbol = "[❯](fg:red)"-vicmd_symbol = "[❮](fg:soft)"+vicmd_symbol = "[❮](fg:craft)"[time]disabled = truediff --git a/docs/demos/shared/lib.py b/docs/demos/shared/lib.pyindex 500651f99..263bc879c 100644--- a/docs/demos/shared/lib.py+++ b/docs/demos/shared/lib.py@@ -13,7 +13,7 @@ from dataclasses import dataclassfrom datetime import datetime, timedeltafrom pathlib import Path-from .themes import THEMES, format_theme_for_vhs+from .themes import PALETTES, THEMES, format_theme_for_vhsREAL_HOME = Path.home()FIXTURES_DIR = Path(__file__).parent / "fixtures"@@ -176,10 +176,25 @@ def _forward_macos_keychains(home: Path) -> None:)+def recorder_env() -> dict[str, str]:+ """The recorder's environment without the calling Claude Code session's state.++ A build started from inside Claude Code inherits that session's ``CLAUDE*``+ variables, and a demo's Claude Code reads them as its own: the inherited+ child-session marker, for one, makes it warn that transcript saving is off.+ Only ``CLAUDE_CODE_OAUTH_TOKEN``, the documented way to authenticate demos,+ passes through.+ """+ return {+ name: value+ for name, value in os.environ.items()+ if not name.startswith("CLAUDE") or name == "CLAUDE_CODE_OAUTH_TOKEN"+ }++def _isolated_claude_env(home: Path) -> dict[str, str]:"""Build an environment whose Claude state stays under an isolated HOME."""- env = os.environ.copy()- env.pop("CLAUDE_CONFIG_DIR", None)+ env = recorder_env()env["HOME"] = str(home)env["XDG_CONFIG_HOME"] = str(home / ".config")return env@@ -284,6 +299,7 @@ class DemoEnv:name: strout_dir: Path+ theme: strrepo_name: str = "worktrunk"@property@@ -306,6 +322,10 @@ class DemoEnv:def bare_remote(self) -> Path:return self.root / "remote.git"+ @property+ def starship_config(self) -> Path:+ return self.out_dir / "starship.toml"+def run(cmd, cwd=None, env=None, check=True, capture=False):"""Run a command."""@@ -354,8 +374,7 @@ def record_vhs(tape_path: Path, vhs_binary: str = "vhs", expected_output: Path = None):"""Record a demo GIF using VHS."""- env = os.environ.copy()- env.pop("CLAUDE_CONFIG_DIR", None)+ env = recorder_env()# GIF assets include ANSI styling independent of the recorder's shell.env.pop("NO_COLOR", None)env["CLICOLOR_FORCE"] = "1"@@ -564,7 +583,7 @@ def setup_claude_code_config({"numStartups": 100,"installMethod": "global",- "theme": "light",+ "theme": env.theme,"firstStartTime": "2025-01-01T00:00:00.000Z","hasCompletedOnboarding": True,"hasCompletedClaudeInChromeOnboarding": True,@@ -638,6 +657,9 @@ def setup_claude_code_config(settings = {"permissions": {"allow": allowed_tools or [], "deny": [], "ask": []},"model": "claude-opus-4-6",+ # Accounts in the Remote Control rollout otherwise start it, which+ # prints a live claude.ai session URL into the GIF.+ "remoteControlAtStartup": False,"statusLine": {"type": "command","command": "wt list statusline --format=claude-code",@@ -650,13 +672,15 @@ def setup_claude_code_config(def setup_zellij_config(env: DemoEnv, default_cwd: str = None) -> None:"""Set up Zellij configuration for demo recording.- Creates config with warm-gold theme, minimal keybinds, and tab-rename plugin.- Plugin is downloaded automatically if missing.+ Creates config with the site palette for the recording's theme, minimal+ keybinds, and tab-rename plugin. Plugin is downloaded automatically if+ missing.Args:env: Demo environmentdefault_cwd: Optional default working directory for new panes"""+ palette = PALETTES[env.theme]zellij_config_dir = env.home / ".config" / "zellij"zellij_config_dir.mkdir(parents=True, exist_ok=True)zellij_plugins_dir = zellij_config_dir / "plugins"@@ -691,27 +715,26 @@ default_shell "fish"pane_frames falseshow_startup_tips falseshow_release_notes false-theme "warm-gold"+theme "worktrunk"// Load the tab-name pluginload_plugins {{"file:{zellij_plugins_dir}/zellij-tab-name.wasm"}}-// Warm gold theme to match the demo aestheticthemes {{- warm-gold {{- fg "#1f2328"- bg "#FFFDF8"- black "#f5f0e8"- red "#d73a49"- green "#22863a"- yellow "#d29922"- blue "#0969da"- magenta "#8250df"- cyan "#1b7c83"- white "#57534e"- orange "#d97706"+ worktrunk {{+ fg "{palette['--wt-ink']}"+ bg "{palette['--wt-paper']}"+ black "{palette['--wt-paper-soft']}"+ red "{palette['--wt-terminal-red']}"+ green "{palette['--wt-terminal-green']}"+ yellow "{palette['--wt-terminal-yellow']}"+ blue "{palette['--wt-terminal-blue']}"+ magenta "{palette['--wt-terminal-magenta']}"+ cyan "{palette['--wt-terminal-cyan']}"+ white "{palette['--wt-ink-muted']}"+ orange "{palette['--wt-copper']}"}}}}@@ -1105,15 +1128,21 @@ def check_ffmpeg_libass():)-def setup_demo_output(out_dir: Path) -> Path:- """Set up demo output directory and copy starship config.+def write_starship_config(path: Path, theme: str) -> None:+ """Write the starship fixture plus its ``site`` palette for ``theme``."""+ palette = PALETTES[theme]+ path.write_text(f"""{(FIXTURES_DIR / "starship.toml").read_text()}+[palettes.site]+craft = "{palette['--wt-craft']}"+muted = "{palette['--wt-ink-muted']}"+red = "{palette['--wt-terminal-red']}"+""")- Returns the path to the starship config file.- """- out_dir.mkdir(parents=True, exist_ok=True)- starship_config = out_dir / "starship.toml"- shutil.copy(FIXTURES_DIR / "starship.toml", starship_config)- return starship_config++def setup_demo_output(env: DemoEnv) -> None:+ """Set up demo output directory and write the starship config."""+ env.out_dir.mkdir(parents=True, exist_ok=True)+ write_starship_config(env.starship_config, env.theme)def record_text(@@ -1362,13 +1391,11 @@ def build_tape_replacements(demo_env: DemoEnv, repo_root: Path) -> dict:- Source shared-setup.tape: VHS Set directives (at top, before Output)- Source shared-commands.tape: Env vars and shell setup (after Require)"""- starship_config = (demo_env.out_dir / "starship.toml").resolve()-return {"DEMO_REPO": demo_env.repo.resolve(),"DEMO_HOME": demo_env.home.resolve(),"REAL_HOME": REAL_HOME,- "STARSHIP_CONFIG": starship_config,+ "STARSHIP_CONFIG": demo_env.starship_config.resolve(),"TARGET_DEBUG": (repo_root / "target" / "debug").resolve(),"ANTHROPIC_API_KEY": os.environ.get("ANTHROPIC_API_KEY", ""),"CLAUDE_CODE_OAUTH_TOKEN": os.environ.get("CLAUDE_CODE_OAUTH_TOKEN", ""),@@ -1379,18 +1406,16 @@ def build_tape_replacements(demo_env: DemoEnv, repo_root: Path) -> dict:def record_theme(demo_env: "DemoEnv",tape_template: Path,- theme_name: str,output_gif: Path,repo_root: Path,vhs_binary: str = "vhs",size: DemoSize = None,):- """Record one demo GIF in a prepared environment.+ """Record one demo GIF in a prepared environment, in the environment's theme.Args:demo_env: Prepared demo environment for this themetape_template: Path to the .tape template file- theme_name: Name of the VHS theme to useoutput_gif: Output GIF pathrepo_root: Path to worktrunk repo root (for target/debug)vhs_binary: VHS binary to use (default "vhs", can be path to custom build)@@ -1400,14 +1425,13 @@ def record_theme(size = SIZE_DOCStape_rendered = demo_env.out_dir / ".rendered.tape"- theme = THEMES[theme_name]delta_flags = "delta --paging=never"- if theme_name == "light":+ if demo_env.theme == "light":delta_flags += " --light"replacements = {**build_tape_replacements(demo_env, repo_root),"OUTPUT_GIF": output_gif,- "THEME": format_theme_for_vhs(theme),+ "THEME": format_theme_for_vhs(THEMES[demo_env.theme]),"WIDTH": size.width,"HEIGHT": size.height,"FONTSIZE": size.fontsize,@@ -1419,7 +1443,7 @@ def record_theme(returntape_rendered.write_text(rendered)- print(f"\nRecording {theme_name} GIF...")+ print(f"\nRecording {demo_env.theme} GIF...")record_vhs(tape_rendered, vhs_binary, expected_output=output_gif)tape_rendered.unlink(missing_ok=True)print(f"GIF saved to {output_gif}")diff --git a/docs/demos/shared/themes.py b/docs/demos/shared/themes.pyindex 9cf3ed9b1..6319970a5 100644--- a/docs/demos/shared/themes.py+++ b/docs/demos/shared/themes.py@@ -1,65 +1,72 @@-"""VHS themes coordinated with the documentation site's color palette.+"""Demo recording palettes, read from the documentation site's stylesheet.-The base surfaces and accents follow ``docs/src/styles/custom.css``. ANSI hues-are tuned separately for legible terminal captures in each theme.+The VHS terminal, Zellij, and starship colors come from hex ``--wt-*`` custom+properties in ``docs/src/styles/custom.css``: the light theme from its+``:root`` block, the dark theme from ``:root[data-theme='dark']``. A recording+uses whatever palette the site has when the build runs. Each property a+recording uses must be declared as a lowercase six-digit hex color in both+blocks; any other form is a ``KeyError`` rather than a silently wrong color.++The VHS terminal theme maps ANSI colors to properties the way the site renders+snapshot output (``terminal_color_class`` and ``terminal_background_class`` in+``tests/integration_tests/readme_sync.rs``). A bright hue uses its normal hue's+property. Bright black and white text use ``--wt-ink-muted``, the site's gray;+black, which the site never renders, matches them. Bright white uses+``--wt-terminal-gutter``, because Worktrunk draws its gutter with a bright-white+background."""import json+import re+from pathlib import Path++CUSTOM_CSS = Path(__file__).parents[2] / "src" / "styles" / "custom.css"+++def _hex_properties(css: str, selector: str) -> dict[str, str]:+ """Hex ``--wt-*`` properties declared in the top-level ``selector`` block."""+ start = css.index(f"\n{selector} {{\n")+ end = css.index("\n}\n", start)+ declarations = re.findall(+ r"^\s+(--wt-[\w-]+): (#[0-9a-f]{6});$", css[start:end], re.MULTILINE+ )+ return dict(declarations)+++def _site_palettes() -> dict[str, dict[str, str]]:+ css = CUSTOM_CSS.read_text()+ return {+ "light": _hex_properties(css, ":root"),+ "dark": _hex_properties(css, ":root[data-theme='dark']"),+ }+++PALETTES = _site_palettes()+++def _vhs_theme(theme: str) -> dict[str, str]:+ palette = PALETTES[theme]+ hues = {+ hue: palette[f"--wt-terminal-{hue}"]+ for hue in ("red", "green", "yellow", "blue", "magenta", "cyan")+ }+ gray = palette["--wt-ink-muted"]+ return {+ "name": f"worktrunk-{theme}",+ "black": gray,+ **hues,+ "white": gray,+ "brightBlack": gray,+ **{f"bright{hue.title()}": color for hue, color in hues.items()},+ "brightWhite": palette["--wt-terminal-gutter"],+ "background": palette["--wt-paper"],+ "foreground": palette["--wt-terminal-ink"],+ "cursor": palette["--wt-copper"],+ "selection": palette["--wt-gold-wash"],+ }+-# Light theme — based on the default ``--wt-*`` palette in custom.css.-LIGHT_THEME = {- "name": "Warm Gold Light",- "black": "#6b7280", # --bright-black- "red": "#dc2626", # --red- "green": "#357a59", # --green (desaturated from website's #1b7f4b)- "yellow": "#ca8a04", # --yellow- "blue": "#2563eb", # --blue- "magenta": "#9333ea", # --magenta- "cyan": "#3d7f7f", # --cyan (muted from website's #0a8080)- "white": "#8c959f",- "brightBlack": "#6b7280", # --bright-black- "brightRed": "#ef4444",- "brightGreen": "#4a9b76",- "brightYellow": "#eab308",- "brightBlue": "#3b82f6",- "brightMagenta": "#a855f7",- "brightCyan": "#5a9e9e",- "brightWhite": "#8c959f",- "background": "#f7f3eb", # --wt-paper- "foreground": "#27231f", # --wt-ink- "cursor": "#d85d22", # --wt-orange- "selection": "#f7d6c1", # --sl-color-accent-low-}--# Dark theme — based on the ``data-theme='dark'`` palette in custom.css.-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",- "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": "#eee8de", # --wt-ink- "background": "#1d1a18", # --wt-paper- "foreground": "#eee8de", # --wt-ink- "cursor": "#ef8a50", # --wt-orange- "selection": "#49200f", # --sl-color-accent-low-}--THEMES = {- "light": LIGHT_THEME,- "dark": DARK_THEME,-}+THEMES = {theme: _vhs_theme(theme) for theme in PALETTES}def format_theme_for_vhs(theme: dict) -> str:diff --git a/docs/demos/shared/validation.py b/docs/demos/shared/validation.pyindex 27a634f13..3d02bcc16 100644--- a/docs/demos/shared/validation.py+++ b/docs/demos/shared/validation.py@@ -30,7 +30,13 @@ from pathlib import Path@dataclassclass Checkpoint:- """A validation checkpoint that scans a range of frames."""+ """A validation checkpoint that scans a range of frames.++ A negative ``start`` or ``end`` counts back from the GIF's last frame (-1),+ for checkpoints on the state a recording ends in. How many frames a tape+ produces varies between runs with the recording machine's speed, so a+ fixed frame number near the end can fall past a faster recording's end.+ """start: intend: int@@ -40,7 +46,7 @@ class Checkpoint:# Checkpoint definitions per TUI demo.-# Ranges are calibrated from actual GIF content at 30fps.+# Ranges are calibrated from actual GIF content, which plays at 25fps.# Expected patterns must ALL be present (case-insensitive) in at least one# frame within the range. Every forbidden pattern must be absent from every# sampled frame.@@ -48,27 +54,33 @@ class Checkpoint:TUI_CHECKPOINTS: dict[str, list[Checkpoint]] = {"wt-switch": [Checkpoint(- start=360,- end=455,+ start=-100,+ end=-1,expected=["Claude Code", "Opus", "acme.dashboard"],forbidden=["Not logged in","Unknown command","Fable 5 is now","Tackle your toughest",+ # The recorder's own Claude Code session leaking in.+ "claude.ai/code",+ "Transcript saving",],),],"wt-statusline": [Checkpoint(- start=280,- end=410,+ start=-130,+ end=-1,expected=["Claude Code", "Opus", "acme.alpha"],forbidden=["Not logged in","Unknown command","Fable 5 is now","Tackle your toughest",+ # The recorder's own Claude Code session leaking in.+ "claude.ai/code",+ "Transcript saving",],),],@@ -87,6 +99,9 @@ TUI_CHECKPOINTS: dict[str, list[Checkpoint]] = {"Not logged in","Fable 5 is now","Tackle your toughest",+ # The recorder's own Claude Code session leaking in.+ "claude.ai/code",+ "Transcript saving",],),# Claude UI visible on TAB 2 (billing), without referral or model ads.@@ -99,6 +114,9 @@ TUI_CHECKPOINTS: dict[str, list[Checkpoint]] = {"Share Claude Code","Fable 5 is now","Tackle your toughest",+ # The recorder's own Claude Code session leaking in.+ "claude.ai/code",+ "Transcript saving",],),# The API agent adds a test. Commit generation should describe that@@ -117,12 +135,12 @@ TUI_CHECKPOINTS: dict[str, list[Checkpoint]] = {expected=["Removing feature"],forbidden=["/var/folders/", "wt-demo-"],),- # Near end — wt list --full showing all worktrees.+ # The recording ends on wt list --full showing all worktrees.# "billing" omitted: depends on timing of when the branch appears# in the list relative to the frame window.Checkpoint(- start=1650,- end=1850,+ start=-100,+ end=-1,expected=["Branch", "main"],forbidden=["CONFLICT",@@ -185,6 +203,25 @@ def extract_frames(}+def frame_count(gif_path: Path) -> int:+ """Number of frames in a GIF."""+ result = subprocess.run(+ [+ "ffprobe",+ "-v", "error",+ "-count_frames",+ "-select_streams", "v:0",+ "-show_entries", "stream=nb_read_frames",+ "-of", "csv=p=0",+ str(gif_path),+ ],+ capture_output=True,+ text=True,+ check=True,+ )+ return int(result.stdout)++def ocr_image(image_path: Path) -> str:"""Run OCR on an image and return the extracted text."""with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as f:@@ -298,11 +335,15 @@ def validate_checkpoint(Returns (passed, detail_message)."""- frame_numbers = list(range(checkpoint.start, checkpoint.end + 1, checkpoint.step))+ start, end = checkpoint.start, checkpoint.end+ if start < 0 or end < 0:+ total = frame_count(gif_path)+ start, end = (total + n if n < 0 else n for n in (start, end))+ label = f"frames {start}-{end}"+ frame_numbers = list(range(start, end + 1, checkpoint.step))frame_paths = extract_frames(gif_path, frame_numbers, work_dir)if not frame_paths:- label = f"frames {checkpoint.start}-{checkpoint.end}"return False, f"failed to extract {label}"best_errors: list[str] = []@@ -338,7 +379,6 @@ def validate_checkpoint(if not best_errors or len(errors) < len(best_errors):best_errors = errors- label = f"frames {checkpoint.start}-{checkpoint.end}"if not frames_checked:return False, f"no readable frames in {label}"if matched_frame is not None:diff --git a/docs/demos/tests/test_recording.py b/docs/demos/tests/test_recording.pyindex 8d8005052..3b25f8008 100644--- a/docs/demos/tests/test_recording.py+++ b/docs/demos/tests/test_recording.py@@ -45,9 +45,11 @@ Env HOME "{{DEMO_HOME}}"theme: tmp_path / theme / "recording.gif" for theme in ("light", "dark")}environments: list[Path] = []+ environment_themes: list[str] = []def setup_environment(environment) -> None:environments.append(environment.home.resolve())+ environment_themes.append(environment.theme)build["record_demo"].__globals__["TAPES_DIR"] = tmp_pathbuild["record_demo"](@@ -61,6 +63,7 @@ Env HOME "{{DEMO_HOME}}")assert len(environments) == 2+ assert environment_themes == ["light", "dark"]light_tape = Path(f"{output_gifs['light']}.tape").read_text()dark_tape = Path(f"{output_gifs['dark']}.tape").read_text()assert str(environments[0]) in light_tape