Files
faumarayandClaude Opus 5.5 1ffcf690cc spikes/gpui/windows: spike 3, a second window on the shared model
A main window and a Studio-like window (cx.open_window through
gpui_kit::open_window) both render views that observe one root entity: a
counter both change, the push-to-talk state, which window is active, and
the studio's preview. Closing the studio window docks it
(on_window_should_close), closing the main window ends the app, F11
toggles fullscreen, Ctrl+Tab activates the other window. The global
push-to-talk key is voelin-platform's X11 hotkey (XInput2 raw events),
read by a GPUI foreground task. The preview comes from voelin-media's
studio compositor and its preview tap, one BGRA RenderImage shown by both
windows, the replaced one dropped from every atlas. drive.sh runs the
scenario and its checks on the headless display.

From the interrupted attempt, changed here: the window's size after a
fullscreen toggle is logged once the window manager has set it (the
toggle's own bounds are the old ones) and checked (1000x900 back);
drive.sh says how long the app took to end; measure.sh (new) runs the
three cost cases into $OUT instead of the README's commands, which wrote
into the current directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:43:43 +03:00

119 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
# Spike 3's scenario on the headless display: opens the studio window from
# the main one, changes the shared counter from both, holds the global
# push-to-talk key while the studio window has focus, toggles fullscreen,
# moves focus with GPUI and with the window manager, closes the studio
# window (it docks) and then the main one (the app ends); then checks the
# events the spike printed. Screenshots and the event log go to $OUT.
#
# spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/windows/drive.sh
set -eu
root=$(cd "$(dirname "$0")/../../.." && pwd)
out=${OUT:-$root/.scratch/gpui-spikes-results}
mkdir -p "$out"
out=$(cd "$out" && pwd)
events=$out/windows-events.jsonl
"$root/target/release/spike-windows" --seconds 120 --warmup 3 >"$events" 2>"$out/windows.log" &
pid=$!
shot() { xwd -root -silent | magick xwd:- -resize 50% "png:$out/$1"; }
find_window() {
i=0
until w=$(xdotool search --name "$1" 2>/dev/null | head -1) && [ -n "$w" ]; do
i=$((i + 1))
[ $i -lt 150 ] || { echo "no window $1" >&2; return 1; }
sleep 0.1
done
echo "$w"
}
step() { echo "== $*" >&2; }
main=$(find_window 'Voelin \(spike\)')
sleep 2
step "Ctrl+O in the main window opens the studio window"
xdotool windowactivate --sync "$main"
sleep 0.3
xdotool key ctrl+o
studio=$(find_window 'Stream Studio \(spike\)')
sleep 2
step "Ctrl+K twice in the studio window: the shared counter"
xdotool windowactivate --sync "$studio"
sleep 0.3
xdotool key ctrl+k
sleep 0.2
xdotool key ctrl+k
sleep 0.5
step "the global push-to-talk key held while the studio window has focus"
xdotool keydown F8
sleep 0.6
shot windows-talking.png
xdotool keyup F8
sleep 0.5
step "F11: the studio window fullscreen, then windowed"
xdotool key F11
sleep 1.5
shot windows-studio-fullscreen.png
xdotool key F11
sleep 1.5
step "Ctrl+Tab in the studio: GPUI activates the main window"
xdotool key ctrl+Tab
sleep 1
step "Ctrl+K in the main window"
xdotool key ctrl+k
sleep 0.5
shot windows-both.png
step "the window manager activates the studio window, Alt+F4 closes it"
xdotool windowactivate --sync "$studio"
sleep 0.5
xdotool key alt+F4
sleep 1
step "push-to-talk with the main window and no studio window"
xdotool windowactivate --sync "$main"
sleep 0.3
xdotool keydown F8
sleep 0.3
xdotool keyup F8
sleep 0.5
shot windows-docked.png
step "Alt+F4 on the main window ends the app"
xdotool key alt+F4
ended=true
i=0
while kill -0 "$pid" 2>/dev/null; do
i=$((i + 1))
if [ $i -ge 100 ]; then
ended=false
kill "$pid"
break
fi
sleep 0.1
done
wait "$pid" || true
fail=0
check() {
if jq -e -s "$2" "$events" >/dev/null; then
echo "PASS $1"
else
echo "FAIL $1"
fail=1
fi
}
ev='[.[] | select(.event)]'
check "the studio window opens from the main one" "$ev | any(.event == \"studio window opened\")"
check "a key in the studio window reaches the shared model" "$ev | map(select(.event == \"studio: increment\")) | length == 2 and (last.counter == 2)"
check "the global hotkey reaches the shared model with the studio window active" "$ev | any(.event == \"hotkey Pressed with the studio window active\" and .talking)"
check "the hotkey's release too" "$ev | any(.event | startswith(\"hotkey Released\"))"
check "fullscreen and back" "$ev | (any(.event | startswith(\"studio window fullscreen\")) and any(.event | startswith(\"studio window windowed\")))"
check "the studio window gets its own size back (1000x900)" "$ev | any(.event == \"studio window now 1000x900\")"
check "GPUI moves focus to the other window (Ctrl+Tab)" "$ev | (map(select(.event | startswith(\"studio window windowed\"))) | last.t) as \$a | (map(select(.event == \"main: increment\")) | first.t) as \$b | any(.event == \"main window active\" and .t >= \$a and .t <= \$b)"
check "the main window changes the same counter" "$ev | any(.event == \"main: increment\" and .counter == 3)"
check "closing the studio window docks it, the app goes on" "$ev | any(.event == \"studio window closed, docked in the main window\")"
check "the hotkey with the main window active" "$ev | any(.event == \"hotkey Pressed with the main window active\")"
if $ended; then
echo "PASS closing the main window ends the app (after $((i / 10)).$((i % 10)) s)"
else
echo "FAIL closing the main window ends the app (killed after 10 s)"
fail=1
fi
exit $fail