Files
saphid--frame-control/ui/local-bin/ssh
T
saphidandClaude Opus 5.5 a910f83ac1 Fix the iPhone review's findings
- Cancelling (Change headset, Forget) invalidates the attempt in flight; a
  connection only becomes the app's once every step finished for it.
- A server that stops while the tunnel opens is noticed (exit callbacks are
  synchronised and replayed), and the app isn't left showing a dead page.
- The port is read only once the digits are complete, and range-checked.
- Other versions in ~/.cache/frame-control stay unless untouched for 14 days,
  so a second phone or iPad isn't cut off.
- The key is appended on its own line even if authorized_keys lacks a final
  newline.
- The app checks every 20 s, and on returning to the foreground, that the SSH
  session still answers, and reconnects if not.
- The ssh stand-in runs the command as its own process group and passes a
  TERM on to all of it, so a live-video ffmpeg stops with its stream.
- Touch screens show the library's Play buttons (the rule now follows the
  base one); the failure screen only says it's retrying when it is; the page
  says the app reconnects rather than naming a desktop menu.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 11:30:40 +10:00

30 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Stand-in for ssh when Frame Control's server runs on the Frame itself
# (FRAME_LOCAL=1, started by the iPhone app). The server and its helpers call
# `ssh [options] frame COMMAND`, and rsync calls it as its transport; here that
# means: run COMMAND in the home directory, as ssh would, with the same stdin.
while [ $# -gt 0 ]; do
case "$1" in
-[bcDEeFIiJLlmOoPpQRSWwB]) shift 2 ;; # options that take a value
-?*) shift ;;
*) break ;;
esac
done
[ $# -gt 0 ] && shift # the host alias
cd "$HOME" || exit 255
[ $# -eq 0 ] && exit 0 # -N: nothing to run
# Stopping ssh ends everything the command started (sshd hangs up the session).
# To do the same, run COMMAND as its own process group and pass on a TERM, HUP
# or INT to all of it, so e.g. a live-video ffmpeg can't outlive its stream.
set -m # job control: the background job gets its own process group, and keeps stdin
"${SHELL:-/bin/sh}" -c "$*" &
child=$!
trap 'kill -TERM -- "-$child" 2>/dev/null' TERM HUP INT
wait "$child"
status=$?
while kill -0 "$child" 2>/dev/null; do # a trapped signal ends `wait` early
wait "$child"
status=$?
done
exit "$status"