orchestrator: SMOKE_VISIBLE=1 shows smoke runs on the user's screen (D-009)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-11 22:13:30 -06:00
commit 97205d2fb1

View file

@ -16,6 +16,9 @@
# SMOKE_SIZE=WxH screen size (default 1280x800)
# SMOKE_BIN=path browser binary (default target/release/nacre)
# NACRE_NO_BRIDGE=1 passed through: no network bridge
# SMOKE_VISIBLE=1 show the window on the user's screen (their Wayland display, niri monitor
# SMOKE_MONITOR, default DP-1) with the real GPU instead of hidden Xvfb + software GL;
# only the Wayland socket is shared, profile/runtime dir/bus stay throwaway
#
# Script commands (src/selftest.rs has the full list): wait <s>, waitload [s], open <url>, newtab <url>,
# page <nacre://...>, shot <name>, status <name>, set <json pointer> <json>, flyout <name>, do <action>,
@ -31,7 +34,13 @@ script=${1:?usage: tools/smoke.sh <script.txt> [outdir]}
out=${2:-$root/target/smoke/$(basename "$script" .txt)-$(date +%Y%m%d-%H%M%S)}
bin=${SMOKE_BIN:-$root/target/release/nacre}
[ -x "$bin" ] || { echo "smoke: no binary at $bin (build first)" >&2; exit 2; }
command -v Xvfb >/dev/null || { echo "smoke: Xvfb is missing (pacman -S xorg-server-xvfb)" >&2; exit 2; }
visible=${SMOKE_VISIBLE:-}
if [ -n "$visible" ]; then
[ -n "${WAYLAND_DISPLAY:-}" ] && [ -S "${XDG_RUNTIME_DIR:-}/$WAYLAND_DISPLAY" ] \
|| { echo "smoke: SMOKE_VISIBLE needs the user's Wayland session" >&2; exit 2; }
else
command -v Xvfb >/dev/null || { echo "smoke: Xvfb is missing (pacman -S xorg-server-xvfb)" >&2; exit 2; }
fi
mkdir -p "$out"
out=$(cd "$out" && pwd)
@ -50,23 +59,31 @@ cleanup() {
}
trap cleanup EXIT
# Xvfb picks a free display number and writes it to fd 3.
exec 3<>"$runtime/display"
Xvfb -displayfd 3 -screen 0 "${SMOKE_SIZE:-1280x800}x24" -nolisten tcp -noreset >"$out/xvfb.log" 2>&1 &
xvfb_pid=$!
for _ in $(seq 50); do
display=$(head -n1 "$runtime/display" 2>/dev/null)
[ -n "$display" ] && break
sleep 0.1
done
[ -n "${display:-}" ] || { echo "smoke: Xvfb did not start (see $out/xvfb.log)" >&2; exit 1; }
if [ -n "$visible" ]; then
# Share only the compositor socket; open the window on the chosen monitor.
ln -s "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" "$runtime/wayland-0"
command -v niri >/dev/null && niri msg action focus-monitor "${SMOKE_MONITOR:-DP-1}" >/dev/null 2>&1
dispvars=(WAYLAND_DISPLAY=wayland-0 XDG_SESSION_TYPE=wayland)
else
# Xvfb picks a free display number and writes it to fd 3.
exec 3<>"$runtime/display"
Xvfb -displayfd 3 -screen 0 "${SMOKE_SIZE:-1280x800}x24" -nolisten tcp -noreset >"$out/xvfb.log" 2>&1 &
xvfb_pid=$!
for _ in $(seq 50); do
display=$(head -n1 "$runtime/display" 2>/dev/null)
[ -n "$display" ] && break
sleep 0.1
done
[ -n "${display:-}" ] || { echo "smoke: Xvfb did not start (see $out/xvfb.log)" >&2; exit 1; }
dispvars=(DISPLAY=":$display" XDG_SESSION_TYPE=x11 LIBGL_ALWAYS_SOFTWARE=1)
fi
env -u WAYLAND_DISPLAY -u DBUS_SESSION_BUS_ADDRESS -u NACRE_HOME \
env -u WAYLAND_DISPLAY -u DISPLAY -u DBUS_SESSION_BUS_ADDRESS -u NACRE_HOME \
-u http_proxy -u https_proxy -u all_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
DISPLAY=":$display" XDG_SESSION_TYPE=x11 \
"${dispvars[@]}" \
HOME="$home" XDG_CONFIG_HOME="$home/.config" XDG_DATA_HOME="$home/.local/share" \
XDG_CACHE_HOME="$home/.cache" XDG_RUNTIME_DIR="$runtime" \
LIBGL_ALWAYS_SOFTWARE=1 RUST_BACKTRACE=1 NACRE_SCRIPT="$out/script.txt" \
RUST_BACKTRACE=1 NACRE_SCRIPT="$out/script.txt" \
timeout -k 10 "${SMOKE_TIMEOUT:-180}" "$bin" >"$out/nacre.log" 2>&1
code=$?