#!/bin/sh # Spike 2's scenario on the headless display: a screenshot of the sample # chat lines, then typing, an emoji from the picker inserted at the caret, # Ctrl+Enter, a picture and a file path pasted from the clipboard, a click # on a masked link; 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/composer/drive.sh set -eu root=$(cd "$(dirname "$0")/../../.." && pwd) out=${OUT:-$root/.scratch/gpui-spikes-results} mkdir -p "$out" out=$(cd "$out" && pwd) # First the same window with a font configuration of only Noto Color Emoji # and Noto Sans CJK (no DejaVu Sans, whose monochrome U+1F600-U+1F640 win # over the fallback chain's Noto Color Emoji), picker open: its emoji probe # is the comparison for the system configuration's. # GPUI itself needs one of its default UI fonts (Cantarell is one). latin=$(nix build --no-link --print-out-paths nixpkgs#cantarell-fonts | head -1) cat >"$out/fonts-noto-only.conf" < $(dirname "$SPIKE_EMOJI_FONT") $(dirname "$SPIKE_EXTRA_FONTS") $latin/share/fonts CONF FONTCONFIG_FILE=$out/fonts-noto-only.conf "$root/target/release/spike-composer" --picker --seconds 6 >"$out/composer-noto-only.jsonl" 2>/dev/null & pid=$! sleep 4 win=$(xdotool search --name 'Composer \(spike\)' | head -1) xwd -id "$win" -silent | magick xwd:- "png:$out/composer-noto-only.png" wait "$pid" || true events=$out/composer-events.jsonl "$root/target/release/spike-composer" --seconds 90 >"$events" 2>"$out/composer.log" & pid=$! step() { echo "== $*" >&2; } i=0 until win=$(xdotool search --name 'Composer \(spike\)' 2>/dev/null | head -1) && [ -n "$win" ]; do i=$((i + 1)) [ $i -lt 150 ] || { echo "no window" >&2; exit 1; } sleep 0.1 done xdotool windowactivate --sync "$win" sleep 2.5 xwd -id "$win" -silent | magick xwd:- "png:$out/composer-messages.png" eval "$(xdotool getwindowgeometry --shell "$win")" step "typing, then the caret one character back" xdotool type --delay 80 'ab' xdotool key Left sleep 0.3 step "the emoji button, then the picker's first emoji" xdotool mousemove --window "$win" 30 $((HEIGHT - 30)) click 1 sleep 0.8 xwd -id "$win" -silent | magick xwd:- "png:$out/composer-picker.png" xdotool mousemove --window "$win" 37 $((HEIGHT - 12 - 36 - 8 - 180 + 8 + 17)) click 1 sleep 0.5 step "Ctrl+Enter sends" xdotool key ctrl+Return sleep 0.5 step "a picture on the clipboard, Ctrl+V" magick -size 64x48 xc:'#3b6cf6' "$out/paste.png" xclip -selection clipboard -t image/png -i "$out/paste.png" sleep 0.3 xdotool key ctrl+v sleep 0.8 step "a file's path on the clipboard, Ctrl+V" printf '%s' "$out/paste.png" | xclip -selection clipboard sleep 0.3 xdotool key ctrl+v sleep 0.8 xdotool type --delay 80 'files' xwd -id "$win" -silent | magick xwd:- "png:$out/composer-attachments.png" xdotool key ctrl+Return sleep 0.5 step "a click on the first message's masked link" # Held 120 ms: InteractiveText installs its mouse-up listener on the frame # after the mouse-down, so a click shorter than a frame is lost. xdotool mousemove --window "$win" 50 59 mousedown 1 sleep 0.12 xdotool mouseup 1 sleep 0.5 xwd -id "$win" -silent | magick xwd:- "png:$out/composer-after.png" kill "$pid" 2>/dev/null || true wait "$pid" 2>/dev/null || 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)]' probe='[.[] | select(.event == "emoji probe")]' check "the emoji font is loaded" "$ev | any(.event == \"fonts\" and .emoji != null)" check "voelin-ui-vm marks every emoji of the probe as an emoji run" "$probe | length == 3 and all(.emoji_runs > 0)" # Findings, not checks (docs/design/gpui-spikes.md, spike 2, "Colour # emoji"): of each probe text's emoji, how many GPUI draws in colour, with # the emoji runs in the emoji font and with the UI font's fallback chain # alone, under the system's font configuration and under the Noto-only one. for f in "$events" "$out/composer-noto-only.jsonl"; do jq -c -s --arg f "$(basename "$f")" '[.[] | select(.event == "emoji probe") | {text, emoji_font: .emoji_font.colour_glyphs, fallback_chain: .fallback_chain.colour_glyphs}] | {file: $f, colour_glyphs: .}' "$f" | sed 's/^/FINDING /' done check "an emoji from the picker goes in at the caret" "$ev | any(.event == \"emoji inserted\" and (.value | startswith(\"a\") and endswith(\"b\") and length > 2))" check "Ctrl+Enter sends the text with the emoji (no newline)" "$ev | any(.event == \"sent\" and (.text | startswith(\"a\") and endswith(\"b\")) and (.text | contains(\"\n\") | not))" check "a pasted picture is attached" "$ev | any(.event == \"attached\" and (.what[0] | startswith(\"picture Png\")))" check "a pasted file path is attached" "$ev | any(.event == \"attached\" and (.what[0] | startswith(\"file \")))" check "the message goes with both attachments" "$ev | any(.event == \"sent\" and .text == \"files\" and (.attachments | length) == 2)" check "a click on a masked link reaches the app, which asks first" "$ev | any(.event == \"link clicked\" and .masked and .url == \"https://example.com/raid\")" exit $fail