feat(tmux-claude-attention): auto-jump to the Claude window that needs you #64

Merged
jmz merged 5 commits from feat/claude-autojump into master 2026-11-25 15:00:14 +00:00
Member

Auto-jump to the Claude window that needs you, plus pings that respect the upcoming sup supervisor's verdict. This is Plan A of the Claude supervisor (design and plans: jmz/nixos-hosts#1174).

What changes

  • tmux-claude-attention autojump WINDOW STATE, called from the status hook. It switches the most recently active client to a window that needs you:

    • permission prompts jump at once;
    • idle/waiting jump after a 30 s grace while sup isn't running, or on sup's needs-you verdict once it is.
  • Guards against misplaced keystrokes and ping-pong. No jump while you:

    • typed in the last 5 s;
    • are in copy mode, have the prefix pending, or are in a non-root key table;
    • are on a window that needs you yourself, or on the window you were just jumped to.

    Jumps are 20 s apart, best-ranked first. A last-moment re-check runs right before the switch.

  • With sup alive (@sup_heartbeat), notify and away-check skip idle/waiting windows sup marked handled or fine. Prompts always ping. New pseudo-state needs-you.

  • Off switch: tmux set -g @claude_autojump off. Tunables: @claude_autojump_idle (5), _retry (2), _tries (30), _cooldown (20), _idle_grace (30).

Tests: bash test/test-tmux-claude-attention.sh. 119 pass, 10 consecutive runs green, shellcheck clean. Private tmux server only.

Known follow-ups, needed before sup ships:

  • A needs-you chain is dropped by a later idle/waiting hook event while sup is alive.
  • The last-moment check could become atomic with an if-shell -F guard.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq

Auto-jump to the Claude window that needs you, plus pings that respect the upcoming `sup` supervisor's verdict. This is Plan A of the Claude supervisor (design and plans: jmz/nixos-hosts#1174). **What changes** - `tmux-claude-attention autojump WINDOW STATE`, called from the status hook. It switches the most recently active client to a window that needs you: - permission prompts jump at once; - idle/waiting jump after a 30 s grace while `sup` isn't running, or on `sup`'s `needs-you` verdict once it is. - Guards against misplaced keystrokes and ping-pong. No jump while you: - typed in the last 5 s; - are in copy mode, have the prefix pending, or are in a non-root key table; - are on a window that needs you yourself, or on the window you were just jumped to. Jumps are 20 s apart, best-ranked first. A last-moment re-check runs right before the switch. - With `sup` alive (`@sup_heartbeat`), `notify` and `away-check` skip idle/waiting windows `sup` marked handled or fine. Prompts always ping. New pseudo-state `needs-you`. - Off switch: `tmux set -g @claude_autojump off`. Tunables: `@claude_autojump_idle` (5), `_retry` (2), `_tries` (30), `_cooldown` (20), `_idle_grace` (30). **Tests:** `bash test/test-tmux-claude-attention.sh`. 119 pass, 10 consecutive runs green, shellcheck clean. Private tmux server only. **Known follow-ups, needed before `sup` ships:** - A `needs-you` chain is dropped by a later idle/waiting hook event while `sup` is alive. - The last-moment check could become atomic with an `if-shell -F` guard. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq <!-- claude-session name=claude-supervisor-design id=087b0dee-d649-45c3-bd8b-9a876c116b13 host=spl-vm05 -->
While the supervisor heartbeat is fresh, idle/waiting desktop notifies skip
windows judged handled/fine and wait for unjudged ones; the away ping skips
only judged windows. Add the needs-you pseudo-state and clear the verdict and
pending jump when a window goes busy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq
New `autojump WINDOW STATE` (called by the hook after notify for every
non-busy state) switches the most recently active client to a window that
needs you: never while you type (@claude_autojump_idle), never away from a
window that itself needs you, one jump per @claude_autojump_cooldown,
best-ranked pending window first. idle/waiting are left to sup while its
heartbeat is alive and otherwise wait @claude_autojump_idle_grace. A busy
window cancels its pending jump. sup_alive no longer counts a heartbeat
from the future.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq
- Check chains honour the off switch and sup's verdict mid-chain (sup up
  during the grace, verdict changed); idle/waiting with sup alive drops
  an older prompt chain at once.
- Prefix pressed, a non-root key table, or a pane mode (copy mode) on the
  client's pane hold the jump like typing; unreadable client_activity
  counts as typing.
- No jump to a window already on some screen; idle -> waiting keeps the
  seq and starts no second chain; the jump target is marked
  (@claude_jumped, cleared on busy) and holds the next queued jump while
  you read it.
- One last-moment re-check right before switch-client (activity of that
  client, pending, busy, off).
- Jump message shows for 3 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq
fix(tmux-claude-attention): make auto-jump tests deterministic
All checks were successful
Test Bootstrap Script / End-to-End Bootstrap Test (Alpine) (pull_request) Successful in 24s
ci / gate (pull_request) Successful in 2m5s
ae8eee1a3a
Two flakes, two root causes:

- Script: after switch-client the check wrote @claude_autojump_last,
  @claude_jumped and dropped pending in separate later tmux calls; a late
  tail could clear a newer request's pending (seen as "waiting ranks above
  idle" jumping to the idle window). The writes now go in the same command
  list as the switch, and every other pending drop is seq-guarded
  server-side (if-shell -F on @claude_jump_seq). cmd_autojump resolves its
  WINDOW to the window id first; the check rejects non-id/non-numeric args.
- Test: the nohup stub logs asynchronously (backgrounded by the script),
  so a line from the idle->waiting test could land after its truncation and
  be counted by "no check scheduled at arm time". Zero assertions now use
  @claude_jump_pending (set synchronously before scheduling); the log is
  only waited on for positive lines.

Also: wait for @claude_autojump_last / @claude_jumped values instead of
reading them right after the client lands, wait_for the race file and for
no running check instead of sleep 1.5, and aj_reset waits until no
autojump check of the run is left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq
fix(tmux-claude-attention): keep needs-you jumps and guard the switch atomically
All checks were successful
Test Bootstrap Script / End-to-End Bootstrap Test (Alpine) (pull_request) Successful in 23s
ci / gate (pull_request) Successful in 2m7s
e13b0110ed
- cmd_autojump: an idle/waiting event while sup is alive no longer kills a
  window's needs-you jump (Claude's idle_prompt ~60 s after Stop, while you
  type elsewhere): with @claude_verdict needs-you it keeps the seq and the
  running chain, mirroring the check's own rule.
- The switch runs inside if-shell -F with a server-side guard on what the
  last-moment re-check read: same seq, still pending, not busy, not off,
  and the chosen client's client_activity unchanged (#{L:} client loop).
  The jump's writes and its message are in the same guarded list; a failed
  switch drops (seq-guarded), a false guard with the request still ours
  looks again. The display name is computed before the re-check, and the
  client name and message are sanitised for the command string.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EJQB7AmgdaVhFXmDLq
jmz scheduled this pull request to auto merge when all checks succeed 2026-11-25 14:59:04 +00:00
jmz merged commit e13b0110ed into master 2026-11-25 15:00:14 +00:00
jmz deleted branch feat/claude-autojump 2026-11-25 15:00:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/dotfiles-public!64
No description provided.