diff options
Diffstat (limited to 'tests/pi-live.sh')
| -rwxr-xr-x | tests/pi-live.sh | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/pi-live.sh b/tests/pi-live.sh index 3c8604d..c2d2db7 100755 --- a/tests/pi-live.sh +++ b/tests/pi-live.sh @@ -317,6 +317,46 @@ expect "a title written over keeps the name" name "Find the sidecar" expect "the menu shows it" "\"$MENU\" --print | grep -c 'Find the sidecar'" 1 t kill-window -t main:named +# Session names: from the model after the first run, refreshed every 8 of +# your messages; a name you give is kept. (The fake model names a session +# "About <your latest message>".) +t new-window -d -t main: -n auto -c "$D/work3" +t send-keys -t main:auto "pi $NO_MCP" Enter +expect "naming: an agent of its own" "st auto" idle 150 +an() { t show -pv -t main:auto @agent_name 2>/dev/null; } +said() { grep -c "\"role\":\"$1\"" "$(t show -pv -t main:auto @agent_session)" 2>/dev/null; } +say() { # message count: send it, wait for its reply + type_line auto "$1" + expect "reply $2" "said assistant" "$2" 80 +} +expect "before any message: no name" an "" +say m1 1 +expect "named after its first run" an "About m1" 80 +for i in 2 3 4 5 6 7 8; do say "m$i" $i; done +expect "not renamed within 8 of your messages" an "About m1" 30 +say m9 9 +expect "renamed at the 8th since" an "About m9" 80 +say m10 10 +type_line auto "/autoname" +expect "/autoname: renamed now" an "About m10" 80 +type_line auto "/autoname Mine now" +expect "/autoname <name>: yours" an "Mine now" 50 +for i in 11 12 13 14 15 16 17 18; do say "m$i" $i; done +sleep 2 +expect "and kept past 8 more" an "Mine now" +t kill-window -t main:auto +# A print run names its session too, before pi exits. +(cd "$D/work3" && pi -p "print me" $NO_MCP >"$D/print.out" 2>&1) +expect "a print run is named" "grep -l '\"name\":\"About print me\"' \$(ls -t \"$D\"/agent/sessions/*work3*/*.jsonl | head -1) | wc -l | tr -d ' '" 1 +# An old session never named is named when resumed. +(cd "$D/work3" && pi --no-extensions -p "an old one" $NO_MCP >"$D/old.out" 2>&1) +OLD=$(ls -t "$D"/agent/sessions/*work3*/*.jsonl | head -1) +[ "$(grep -c '"type":"session_info"' "$OLD")" = 0 ] && pass "without the extension: unnamed" || fail "the old session has a name" +t new-window -d -t main: -n old -c "$D/work3" +t send-keys -t main:old "pi --session '$OLD' $NO_MCP" Enter +expect "resumed: named from its history" "t show -pv -t main:old @agent_name 2>/dev/null" "About an old one" 150 +t kill-window -t main:old + echo "2. screen detection (pi without the extension)" t send-keys -t main:plain "PI_CODING_AGENT_DIR=$D/agent-plain pi $NO_MCP" Enter expect "identified as pi" "t show -pv -t main:plain @agent 2>/dev/null" pi 150 @@ -341,7 +381,7 @@ expect "restore resumes it by its session file" "grep -c -- \"resume .*pi --sess expect "resumed 1 of 1 agents" "grep -c '^resumed 1 of 1 agents' $D/restore.out" 1 expect "it runs again, reporting the same session" "t show -pv -t main:agent @agent_session 2>/dev/null" "$SESSION" 150 # Its last message: the first may have scrolled off a long conversation. -expect "with its conversation" "t capture-pane -p -t main:agent -S - | grep -c 'slow 1 after\$'" 1 50 +expect "with its conversation" "t capture-pane -p -t main:agent -S - | grep -cE '^ *slow 1 after\$'" 1 50 expect "and its importance" "t show -pv -t main:agent @dingger_importance 2>/dev/null" high 50 expect "and its draft, back in the input box" "t capture-pane -p -t main:agent | grep -c '^an unsent idea;'" 1 50 expect "reported again" "t show -pv -t main:agent @dingger_draft 2>/dev/null" "an unsent idea;" 30 |
