Walking skeleton test suite passes end-to-end: - AS-1: Permission block enqueue/dequeue - AS-2: FIFO ordering - AS-3: Answered-in-pane reconcile - AS-4: Dropped-event recovery - AS-5: Skip + cooldown - AS-6: No forced focus-steal - AS-7: Pane reuse regression Phase 6 exit criterion met (AS-1 through AS-6 pass). Phase 6 complete (AS-7 also passes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
2.3 KiB
Bash
Executable file
73 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Trail Boss CLI — navigation commands for tmux integration
|
|
set -e
|
|
|
|
TB_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)"
|
|
DAEMON_URL="${TRAILBOSS_URL:-http://127.0.0.1:4000}"
|
|
|
|
case "$1" in
|
|
jump-next)
|
|
# Query daemon for head-of-queue pane id, then navigate to it
|
|
PANE_INFO=$(curl -s "$DAEMON_URL/next")
|
|
PANE_ID=$(echo "$PANE_INFO" | grep -o '"paneId":"[^"]*"' | cut -d'"' -f4)
|
|
|
|
if [ -z "$PANE_ID" ] || [ "$PANE_ID" = "null" ]; then
|
|
REASON=$(echo "$PANE_INFO" | grep -o '"reason":"[^"]*"' | cut -d'"' -f4)
|
|
echo "Trail Boss: $REASON" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Navigate to the pane: switch-client, select-window, select-pane
|
|
# Pane ids are tmux-server-global, so we can address them directly
|
|
SESSION_NAME=$(tmux display -p -t "$PANE_ID" '#{session_name}')
|
|
if [ -z "$SESSION_NAME" ]; then
|
|
echo "Trail Boss: pane $PANE_ID not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Record origin so `trailboss return` can come back
|
|
tmux display -p '#{session_name}' > /tmp/trailboss-origin
|
|
tmux switch-client -t "$SESSION_NAME" \; select-window -t "$PANE_ID" \; select-pane -t "$PANE_ID"
|
|
;;
|
|
|
|
skip)
|
|
# Skip current head and move to tail, then jump to new head
|
|
PANE_INFO=$(curl -s -X POST "$DAEMON_URL/skip")
|
|
PANE_ID=$(echo "$PANE_INFO" | grep -o '"paneId":"[^"]*"' | cut -d'"' -f4)
|
|
|
|
if [ -z "$PANE_ID" ] || [ "$PANE_ID" = "null" ]; then
|
|
REASON=$(echo "$PANE_INFO" | grep -o '"reason":"[^"]*"' | cut -d'"' -f4)
|
|
echo "Trail Boss: $REASON" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SESSION_NAME=$(tmux display -p -t "$PANE_ID" '#{session_name}')
|
|
if [ -z "$SESSION_NAME" ]; then
|
|
echo "Trail Boss: pane $PANE_ID not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
tmux display -p '#{session_name}' > /tmp/trailboss-origin
|
|
tmux switch-client -t "$SESSION_NAME" \; select-window -t "$PANE_ID" \; select-pane -t "$PANE_ID"
|
|
;;
|
|
|
|
popup)
|
|
# Show the queue picker overlay
|
|
exec "$TB_DIR/bin/trailboss-popup"
|
|
;;
|
|
|
|
return)
|
|
# Switch back to the operator session recorded before the last jump
|
|
ORIGIN=$(cat /tmp/trailboss-origin 2>/dev/null)
|
|
if [ -z "$ORIGIN" ]; then
|
|
echo "Trail Boss: no origin session recorded" >&2
|
|
exit 1
|
|
fi
|
|
tmux switch-client -t "$ORIGIN"
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: trailboss {jump-next|skip|popup|return}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|