- Add tui/main.go, tui/go.mod, tui/go.sum (Go + Bubble Tea TUI) - Add CLAUDE.md with project instructions - Add bin/trailboss-preview script - Update bin/trailboss, bin/trailboss-start, bin/trailboss-watch - Update PROGRESS.md and docs/plan/plan.md to reflect completion - Add .gitignore entries for build artifacts (tui/tui, bin/trailboss-tui) - Remove stray root main.go placeholder and ~ directory Bead-Id: tb-25j Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
2.2 KiB
Bash
Executable file
68 lines
2.2 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)
|
|
# Always return to the Trail Boss dashboard window (TUI pane is active)
|
|
tmux switch-client -t trail-boss:dashboard
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: trailboss {jump-next|skip|popup|return}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|