mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
Milestone 1's last functional piece. "asciiscapes claude" is the whole product from the user's side, and it has to work on a machine with nothing set up: it bootstraps tmux when there is no session, joins the current window when there is, and falls back to a second Terminal window via osascript when tmux is missing. The agent keeps the pane the user typed into and its own TTY -- the launcher execs it rather than wrapping it, so nothing sits between the keyboard and the agent. --print shows the exact commands and changes nothing. Three defects found by actually running it rather than reading it: The scape bound to a session once, at startup, so launching both halves together left it in demo mode forever -- the agent cannot announce itself until it is up. New -await keeps looking. And -await must IGNORE the session pointer it finds at startup: Listen happily opens a socket for a session that ended yesterday, so binding to the stale pointer succeeds and the scape then runs beside a live agent showing a dead session. It takes the first session that differs instead. The stale pointer that exposed this was written BY THE TEST SUITE. adapter_test.go feeds real hook payloads through translate(), and a SessionStart payload records its session as current -- with no override that is the user's own ~/.config/asciiscapes/run/current. Running the tests left the next "asciiscapes -live" chasing a session called "s". ASCIISCAPES_HOME already existed and internal/event's tests already used it; the main package never did. TestMain now points the package at a temp dir. A suite that writes outside its temp dir cannot notice that it did, which is why this surfaced from reading the file by hand. Verified in a real tmux: two panes, agent left and scape right at 38%, the scape painting; then a session announced AFTER it started, an event emitted into that session, and the dotted done balloon with its message appearing in the pane. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PsdMUTHxbXJ8hud6jedByL
27 lines
842 B
Go
27 lines
842 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// TestMain keeps the suite out of the user's real state.
|
|
//
|
|
// The adapter tests feed genuine hook payloads through translate(), and a
|
|
// SessionStart payload records its session as the current one -- which, with
|
|
// no override, means writing "s" into ~/.config/asciiscapes/run/current. That
|
|
// file is what a scape started by hand follows, so running the tests left the
|
|
// next `asciiscapes -live` chasing a session that never existed. Found on
|
|
// 2026-09-01 by reading the file while testing the launcher, not by any test:
|
|
// a suite that writes outside its temp dir cannot notice that it did.
|
|
func TestMain(m *testing.M) {
|
|
dir, err := os.MkdirTemp("", "asciiscapes-test")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
os.Setenv("ASCIISCAPES_HOME", dir)
|
|
code := m.Run()
|
|
os.RemoveAll(dir)
|
|
os.Exit(code)
|
|
}
|