Reliable loop messaging: msg-loop.sh + hardened ping_session (retry submit)
tmux `send-keys -l <long msg>` often leaves the text UNSENT in the input box (the immediate Enter is swallowed while the TUI ingests the paste). Both now type the message then retry Enter/C-m until the leading text is no longer in the input box (= submitted) or a bounded loop gives up. - msg-loop.sh: standalone reliable messenger for orchestrator use. - launch.sh ping_session: same retry-submit (loads on next watchdog restart). Live-tested: delivered first try. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+13
-3
@@ -142,11 +142,21 @@ stop_loops() {
|
||||
done
|
||||
}
|
||||
|
||||
# Wake a loop by typing a one-line message into its tmux session (queues if mid-turn).
|
||||
# Wake a loop by typing a message into its tmux session and SUBMITTING it. A single Enter after a
|
||||
# long `send-keys -l` is often swallowed while the TUI ingests the paste (text left unsent in the
|
||||
# input box), so retry Enter/C-m until the message's leading text is no longer in the input box.
|
||||
ping_session() {
|
||||
local s="$1" msg="$2"
|
||||
local s="$1" msg="$2" prefix i
|
||||
session_alive "$s" || return 0
|
||||
tmux send-keys -t "$s" -l -- "$msg" 2>/dev/null && { sleep 0.3; tmux send-keys -t "$s" Enter 2>/dev/null; }
|
||||
prefix="${msg:0:28}"
|
||||
tmux send-keys -t "$s" -l -- "$msg" 2>/dev/null || return 0
|
||||
sleep 0.5
|
||||
for i in 1 2 3 4 5; do
|
||||
tmux send-keys -t "$s" Enter 2>/dev/null
|
||||
sleep 1
|
||||
tmux capture-pane -pt "$s" 2>/dev/null | tail -4 | grep -qF -- "$prefix" || return 0 # submitted
|
||||
tmux send-keys -t "$s" C-m 2>/dev/null; sleep 0.5
|
||||
done
|
||||
}
|
||||
|
||||
# A loop can stall ALIVE on a usage/spend-limit notice: the claude process stays up (so the
|
||||
|
||||
Reference in New Issue
Block a user