Skip to content

demos: live tmux hotkey recording (keycast overlay) + per-keystroke typing; fix explain live-mode resolution#13

Merged
Tombar merged 6 commits into
mainfrom
demo-hotkeys
Jul 18, 2026
Merged

demos: live tmux hotkey recording (keycast overlay) + per-keystroke typing; fix explain live-mode resolution#13
Tombar merged 6 commits into
mainfrom
demo-hotkeys

Conversation

@Tombar

@Tombar Tombar commented Jul 18, 2026

Copy link
Copy Markdown
Member

What

  • fix(explain): failsafe explain hardcoded Mode: "enabled" instead of resolving the live mode chain (env, pane files) — its verdict could disagree with what the hook would actually do. Now resolves the same chain as the hook, with a regression test. Fail-safe: an unresolvable mode falls back to enabled.
  • Recorder v2 (scripts/record-docs.sh): per-keystroke typing baked into every cast (TYPE_DELAY, default 50ms/key), --render/--claude flags, and a new tmux-hotkey scenario.
  • New demo tmux-hotkey: the documented Ctrl+Alt+T binding pressed live through tmux's root key table (virtui writes to the client PTY — the path a real keyboard takes, which even the bats harness can't exercise). A keycast overlay (⌨ Ctrl+Alt+T) shows the keypress like a video demo. Story: explain BLOCKs → hotkey → status bar flips to 🔓 sudo → same command ALLOWs → hotkey re-arms 🔒 on. The demo's tmux config is materialized from docs/toggle/tmux.md's own fenced blocks via the harness extractor, so the recording provably shows the documented setup.
  • Docs: embed in toggle/tmux.md, cross-link from reference/modes.md, document TYPE_DELAY + the honest split (tmux hotkey now recordable; WezTerm/iTerm stay manual).

Deliberately not in this PR

The inside-Claude demo (--claude): the scenario skeleton exists but no recording ships. It runs the recorded Claude with the operator's own unmodified config and never instructs the inner agent to skip its own review steps — if another guard fires first, that layered result is what gets recorded. It ships once reliable (see docs/demos/README.md "Planned").

Verification

  • go test ./cmd/failsafe/ green (includes new TestRun_ExplainResolvesLiveMode)
  • cast content grep-verified: keycast toast ⌨, Decision: BLOCK, Decision: ALLOW, sudo, no macOS zsh banner
  • per-keystroke events confirmed in cast JSON (one glyph per event, ~65ms apart)
  • doc-validation harness fence ordinals untouched (image/prose-only edits in harness-covered docs)

🤖 Generated with Claude Code

https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc

Tombar and others added 6 commits July 17, 2026 21:24
explain now resolves the live mode the same way the hook does (env,
pane-mode files, config), so its verdict matches what the hook would
actually decide. Previously it hardcoded "enabled", so a disabled pane
or FAILSAFE_MODE=disabled was invisible to explain — contradicting the
docs' claim that explain shows what the hook would do.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc
…ping

Rewrite scripts/record-docs.sh (v2):
- Human-visible typing: every command is typed one glyph at a time via a
  new type_line helper (TYPE_DELAY, default 0.05s; 0 = instant), replacing
  the atomic `virtui exec` in the step loop with type_line + `virtui wait`.
  Casts now read like someone at a keyboard, not text teleporting in.
- --render and --claude parse in any order.
- New tmux-hotkey scenario: the Ctrl+Alt+T per-pane toggle flipping the
  guard enabled<->disabled live — the same command BLOCKs, then (after the
  chord, sent as `press Escape Ctrl+T` through the tmux root key table)
  ALLOWs when re-run from shell history, then BLOCKs again, with the status
  bar following. The tmux config is materialised from docs/toggle/tmux.md's
  own fenced blocks (via test/docs/lib/extract.sh) so it can't drift.
- New opt-in --claude scenario (record_claude_hook): failsafe blocking a
  kubectl delete inside Claude Code, then the hotkey flipping the guard
  without leaving the Claude TUI. Runs with the REAL home (Claude auth is
  Keychain/~/.claude), isolates writes via FAILSAFE_LOG -> throwaway file,
  and removes only the pane-mode file its toggle creates. Degrades
  gracefully (skips if claude/tmux absent; a flaky turn warns and the other
  casts are unaffected).

Recorded + rendered: explain-block, mode-toggle, audit, tmux-hotkey
(.cast + .svg). Per-char typing verified (one output event per glyph);
tmux-hotkey verified to contain Decision: BLOCK, Decision: ALLOW, and the
`sudo` status flip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc
…) and clean pane banner

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc
The banner is printed by the outer bash that virtui spawns, before tmux's
default-command runs, so BASH_SILENCE_DEPRECATION_WARNING must be injected
at spawn time via virtui run -e (verified live during the re-record).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc
…--claude scenario

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TiYGMkQeeiUQ6vWVqJaaQc
@Tombar
Tombar merged commit 3aa33c3 into main Jul 18, 2026
3 checks passed
@Tombar
Tombar deleted the demo-hotkeys branch July 18, 2026 01:56
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