From 9d0b59671c019c8260b650bbb959d018deafd795 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 6 Oct 2026 12:39:25 +0200 Subject: [PATCH] o: use filtered event stream instead of statewait loop Subscribe to agent-specific state events via streaming rdwr pattern. No more polling loop - single filtered subscription. --- data/scripts/o | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/data/scripts/o b/data/scripts/o index a7ea4cf..d33e14a 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -320,20 +320,19 @@ cmd_tui() { tmux set-option -t "=${tmux_session}" status-right "starting... | %H:%M" tmux set-option -t "=${tmux_session}" status-right-length 64 - while true; do - ollie-9p read "${PREFIX}/statewait" 2>/dev/null | while read -r state; do - bg="" - case "$state" in - idle) bg="colour70" ;; - calling*) bg="colour214" ;; - thinking) bg="colour33" ;; - paused) bg="colour245" ;; - *) bg="default" ;; - esac - tmux set-option -t "=${tmux_session}" status-right-style "fg=default,bg=$bg" 2>/dev/null - status=$(ollie-9p read "${PREFIX}/status" 2>/dev/null | head -n1) - tmux set-option -t "=${tmux_session}" status-right "${status:-$state} | %H:%M" 2>/dev/null - done + # Subscribe to state events for this agent only + echo "session.${s}.agent.${a}.state" | ollie-9p rdwrs event 2>/dev/null | while read -r topic state; do + bg="" + case "$state" in + idle) bg="colour70" ;; + calling*) bg="colour214" ;; + thinking) bg="colour33" ;; + paused) bg="colour245" ;; + *) bg="default" ;; + esac + tmux set-option -t "=${tmux_session}" status-right-style "fg=default,bg=$bg" 2>/dev/null + status=$(ollie-9p read "${PREFIX}/status" 2>/dev/null | head -n1) + tmux set-option -t "=${tmux_session}" status-right "${status:-$state} | %H:%M" 2>/dev/null done & local bg_pid=$! trap "kill $bg_pid 2>/dev/null" EXIT