Files
chandra/handset/smoke.sh
nandiandClaude Opus 5.5 589d167f79
CI / test (pull_request) Successful in 1m22s
Remote: copy from the phone to this device's clipboard
- Web UI: Ctrl+C, Ctrl+X, Ctrl+Shift+C (Cmd+C on Mac) also put what they copied, text or PNG, on this device's clipboard; Copy, Copy Selection and Copy Clipboard buttons
- chandra-remote: GET /api/clipboard/data, with the same authorization as the upload
- Compositor: clipboard-get-fd has the clipboard's owner write into a pipe, refused while locked; input-copy presses Ctrl+Shift+C in terminals, Ctrl+C elsewhere
- Pending clipboard transfers keep the main loop awake

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 18:26:53 -08:00

35 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Start the payload's compositor headless and put an image on its clipboard through chandra-remote.
set -euo pipefail
p=/payload
R=$(mktemp -d /tmp/smXXXX)
mkdir "$R/cfg"
export XDG_RUNTIME_DIR=$R XDG_CONFIG_HOME=$R/cfg HOME=$R CHANDRA_TEST_CONFIG=1
touch "$R/log" "$R/rem"
trap 'rc=$?; [ $rc = 0 ] || cat "$R/log" "$R/rem"; exit $rc' EXIT
cd $p/session/usr/local/share/chandra
timeout 120 $p/session/usr/local/bin/chandra-host compositor.wasm --socket "$R/wt" \
--theme config/themes/moon-night.json > "$R/log" 2>&1 &
for _ in $(seq 200); do [ -S "$R/chandra/wt.sock" ] && break; sleep .2; done
ctl() { python3 $p/session/usr/local/bin/chandra-ctl --socket "$R/chandra/wt.sock" "$@"; }
ctl ping | grep -qx 'ok pong'
ctl list | tail -n 1
printf 'enabled=1\nbind=127.0.0.1\nauth=none\n' > "$R/r.conf"
$p/live/usr/local/bin/chandra-remote --config "$R/r.conf" --socket "$R/chandra/wt.sock" \
--shm "$R/fb" --web-dir $p/live/usr/local/share/chandra/remote --bind 127.0.0.1 > "$R/rem" 2>&1 &
remote=$!
for _ in $(seq 50); do curl -fsS -m 2 -o /dev/null http://127.0.0.1:6080/ 2>/dev/null && break; sleep .2; done
python3 -c "import os,sys;sys.stdout.buffer.write(b'\x89PNG\r\n\x1a\n'+os.urandom(1<<20))" > "$R/p.png"
out=$(curl -fsS -m 30 -H Expect: -H 'X-Chandra-Remote: 1' -H 'Content-Type: image/png' \
--data-binary "@$R/p.png" http://127.0.0.1:6080/api/clipboard)
echo "$out"
[ "$out" = '{"ok":true,"serial":1}' ]
# The same image comes back out.
curl -fsS -m 30 -H 'X-Chandra-Remote: 1' http://127.0.0.1:6080/api/clipboard/data | cmp - "$R/p.png"
# It restarts in place, and answers again.
kill -USR2 $remote
sleep 2
curl -fsS -m 5 http://127.0.0.1:6080/api/clipboard
echo
echo "smoke ok"