Files
worktrunk/docs/demos/shared/__init__.py
Maximilian RoosandClaude Opus 5 75baa2cd37 demos: record the interactive picker, and fix the bugs it exposed (#4178)
The interactive picker had no demo, and the two things that sell it
don't survive a still image: rows painting from local git before any
network call, and a preview pane you page through without leaving the
list. Making that recordable meant giving the demo environment a forge
that answers on a schedule, which is what most of this diff is.

## The mocked forge

`docs/demos/shared/fixtures/gh-mock.sh` answers every `gh` call from a
file that `write_gh_mock_data` writes once the branches exist — first
line a delay, the rest a JSON body. The per-branch delays are the point:
wt runs one `gh pr list` per branch concurrently, so staggered replies
land the CI cells one at a time behind a frame that already painted.
`fixtures/llm-mock.sh` does the same for the Summary column, picking a
sentence from the paths in each branch's diff.

Three things have to hold or the CI column silently empties rather than
failing, and `docs/demos/CLAUDE.md` now records all three: a parseable
origin (set via `url.<bare>.pushInsteadOf`, so `git remote get-url`
still hands wt the URL while pushes go to the local bare repo), `gh
--version` and `gh auth status` both exiting 0, and `DEMO_PROJECT_ID`
matching the URL.

## The recordings

`wt-switch-picker` is the full tour, and it is the one demo that records
at its own size — `SIZE_DOCS_PICKER`, the same 1600x900 canvas in
smaller text, giving 139x34 instead of 102x25. At the usual size the CI
and Summary columns fall off the right edge and the preview is too short
to page a diff. It runs against sixteen worktrees with varied CI, a
ten-comment PR thread, and a working tree dirty in several different
ways.

`wt-zellij-omnibus` opens on the picker rather than passing through it:
`alt-p` widens the rows, the CI cells land behind them, `ctrl-d` pages a
diff, then Enter selects. That beat is the picker's showing on the
homepage, which stays at two demos.

## Bugs this turned up

**`wt merge` on a dirty worktree described the wrong changes.**
`build_squash_prompt` diffed `merge_base..HEAD`, but the squash commits
the index — `handle_squash` stages the working tree before generating
the message and soft-resets afterwards. So the generated message covered
the branch's older commits and said nothing about the work just staged
into the same commit, which on a dirty `wt merge` is the whole reason it
ran. It now diffs `merge_base` against the index, matching the stats
`handle_squash` prints for that same commit. With nothing staged the two
spans are identical, so there is no second path.

**`wt step squash --dry-run` previewed a different prompt than it would
send.** `wt step commit --dry-run` stages into a temp index so its
preview spans what a real run would commit, while `--show-prompt`
deliberately shows only what is already staged. Making the squash prompt
read the index broke that parity for squash — its `--dry-run` showed
neither. It now mirrors `--stage` the same way, with the flag plumbed
through from the CLI. The task line in the default squash template moved
with it: "the combined effect of these commits" pointed at the one block
that doesn't carry the staged work, and now names `<diff>` as what the
squash records and `<commits>` as what it folds in.

**The picker preview dropped a character.** The pane rendered one column
wider than skim paints, so a wrapped line breaking flush against the
right edge lost its last character — "when" as "whe", mid-sentence, with
nothing that reads as clipping. Reproduced outside VHS in a pyte PTY at
139 columns before the fix and again after; `PREVIEW_RESERVED_COLS`
documents where the column goes.

## VHS fork

Three commits on `max-sixty/vhs` `keypress-overlay`, all pushed: pass
`macOptionIsMeta` so `Alt+<key>` reaches the program at all rather than
typing a bare letter into the query; time the keystroke overlay by
recorded frames instead of the wall clock, which removed a 640ms lag and
the fixed fudge that was hiding it; and record a modified key as one
keystroke, so `Alt+"8"` draws a highlighted `⌥8` rather than a greyed
`⌥` and an unrelated `8`. `_VHS_FORK_MARKER` names the newest of them,
because a clone that predates one records a wrong GIF and reports
nothing.

## Checks

All five affected recordings re-recorded and OCR-validated, and
published to `worktrunk-assets`. New tests:
`test_squash_prompt_covers_what_its_run_would_commit` covers both
preview paths — `--show-prompt` on the real index, `--dry-run` on the
mirrored one.
`test_preview_width_stops_short_of_the_column_skim_leaves_unpainted`
covers 80/120/139/200.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 16:55:22 -07:00

89 lines
1.9 KiB
Python

"""Shared infrastructure for demo recording scripts."""
from .lib import (
REAL_HOME,
FIXTURES_DIR,
VALIDATION_RS,
DemoEnv,
DemoSize,
SIZE_SOCIAL,
SIZE_DOCS,
SIZE_DOCS_MOBILE,
SIZE_DOCS_PICKER,
run,
git,
render_tape,
record_vhs,
build_wt,
commit_dated,
prepare_base_repo,
claude_auth_available,
setup_claude_code_config,
setup_zellij_config,
setup_fish_config,
setup_mock_clis,
prepare_demo_repo,
write_gh_mock_data,
DEMO_PROJECT_ID,
# Demo recording infrastructure
check_dependencies,
check_ffmpeg_libass,
setup_demo_output,
write_starship_config,
record_theme,
recorder_env,
# Text output recording
record_text,
build_tape_replacements,
# Snapshot recording
extract_commands_from_tape,
record_snapshot,
# External dependencies
ensure_vhs_binary,
)
from .themes import THEMES, format_theme_for_vhs
__all__ = [
"REAL_HOME",
"FIXTURES_DIR",
"VALIDATION_RS",
"DemoEnv",
"DemoSize",
"SIZE_SOCIAL",
"SIZE_DOCS",
"SIZE_DOCS_MOBILE",
"SIZE_DOCS_PICKER",
"run",
"git",
"render_tape",
"record_vhs",
"build_wt",
"commit_dated",
"prepare_base_repo",
"claude_auth_available",
"setup_claude_code_config",
"setup_zellij_config",
"setup_fish_config",
"setup_mock_clis",
"prepare_demo_repo",
"write_gh_mock_data",
"DEMO_PROJECT_ID",
"THEMES",
"format_theme_for_vhs",
# Demo recording infrastructure
"check_dependencies",
"check_ffmpeg_libass",
"setup_demo_output",
"write_starship_config",
"record_theme",
"recorder_env",
# Text output recording
"record_text",
"build_tape_replacements",
# Snapshot recording
"extract_commands_from_tape",
"record_snapshot",
# External dependencies
"ensure_vhs_binary",
]