1 #!/usr/bin/env bash
2 # Drive the interactive ratatui TUI under tmux: launch it, type /help, dump the
3 # rendered screen to a file ("screenshot" for a terminal app), then quit cleanly.
4 #
5 # The TUI only starts when stdin is a real TTY, so it must run inside a terminal
6 # multiplexer — tmux gives us one plus `capture-pane` to read what it drew.
7 # Requires tmux (`brew install tmux`). Unix only (the TUI is #[cfg(unix)]).
8 #
9 # Usage: .claude/skills/run-sigit/tui-smoke.sh [path-to-binary]
10 set -euo pipefail
11
12 BIN="${1:-${SIGIT_BIN:-target/debug/sigit}}"
13 SESSION="sigit-smoke-$$"
14 OUT="${TMPDIR:-/tmp}/sigit-tui.txt"
15
16 if [[ ! -x "$BIN" ]]; then
17 echo "binary not found/executable: $BIN — run \`cargo build\` first" >&2
18 exit 2
19 fi
20 command -v tmux >/dev/null || { echo "tmux not installed (brew install tmux)" >&2; exit 2; }
21
22 cleanup() { tmux kill-session -t "$SESSION" 2>/dev/null || true; }
23 trap cleanup EXIT
24
25 tmux new-session -d -s "$SESSION" -x 120 -y 35
26 tmux send-keys -t "$SESSION" "$BIN" Enter
27 sleep 6 # banner + (lazy) model selection
28 tmux send-keys -t "$SESSION" '/help' Enter
29 sleep 2
30 tmux capture-pane -t "$SESSION" -p > "$OUT"
31 tmux send-keys -t "$SESSION" C-c # Ctrl+C quits
32 sleep 1
33
34 echo "Captured TUI screen -> $OUT"
35 if grep -q '/whoami' "$OUT"; then
36 echo "OK — TUI launched and /help rendered."
37 else
38 echo "FAILED — /help output not found in capture:" >&2
39 sed '/^$/d' "$OUT" | head -40 >&2
40 exit 1
41 fi