Skip to content

v1.4 - Hooks Status Channel

Choose a tag to compare

@theyashgupta theyashgupta released this 11 Jul 20:53
· 1078 commits to main since this release
v1.4
f4fa4c6

Dispatch v1.4 changes how the board knows what an agent is doing. Until now, status came from reading the terminal: every two seconds the server captured each session's visible tmux pane and regex-matched status lines out of the rendered text. It worked, but everything difficult about it existed because the channel was pixels. Markers could scroll off screen between polls, long lines wrapped at pane width and corrupted the payload, and every TUI repaint was a chance to mistake chrome for state. This release replaces that with the direct route: Claude Code tells Dispatch what happened, the moment it happens. That was roadmap issue #46.

Native hooks as the status channel

When Dispatch starts a session it now injects a hooks configuration scoped to that session alone, using the CLI's per-session settings layer plus a few environment variables delivered through tmux. Nothing is written to your own Claude settings, and a claude you launch yourself in some other terminal behaves exactly as before; the hook script checks for Dispatch's environment variables and exits instantly when they are absent. Resumed sessions get the same injection, so a card that comes back after a restart reports status the same way a fresh one does.

When the agent finishes a turn, a Stop hook fires carrying the full text of the final reply. Dispatch runs the same status-marker parse over that text that it used to run over captured pixels, except the text is now complete: a status reason can be as long as it wants, wrap however the terminal likes, or scroll off screen entirely, and it still arrives intact. When you type a reply, a UserPromptSubmit hook flips the waiting card back to In Progress. In our test runs the flip took around 0.3 seconds; the pane watcher needed about four.

The transport is deliberately boring. A small POSIX script under ~/.dispatch/ posts the hook payload to a loopback-only endpoint with a per-session token and a one-second timeout, then exits 0 no matter what happened, so a slow or dead server can never stall your Claude session. On the server side the endpoint rejects anything without a valid token and applies events through the same single-writer store path everything else uses. A manual drag still beats whatever the hooks say, same as it always beat the markers.

The statusChannel setting

A new config key selects the status source: hooks, pane, or auto, with auto as the default. Auto routes each session by observation. The first authenticated hook event marks a session hook-driven and pane scanning steps aside for it; a session that never produces hook traffic (an older CLI, some future non-Claude agent) keeps full pane-based routing with no configuration needed. Setting pane restores the old behavior exactly and skips hook injection at launch entirely. Setting hooks turns pane marker scanning off.

Demoting the watcher did not delete it. On every channel it still detects dead tmux sessions within a few seconds and reaps orphaned ttyd processes, because hooks can tell you a turn ended but not that the terminal vanished. The unseen-activity dot moved to the new channel too: tool-use events stamp it now, throttled to one update per two seconds per card, with the turn-ending event exempt from the throttle so the final output of a turn always registers.

The parts you'd only notice if they were wrong

Session tokens are minted per session, survive backend restarts through a boot-time rebuild, are unregistered the moment a session dies or a card is cleaned up, and never leave the server: the board snapshot that goes out over SSE and REST is stripped of them at a single chokepoint while the on-disk copy keeps them. A relaunch that skips hook injection also clears the session's hook-routing state, so a card cannot get stuck believing in a channel that no longer exists. Hook payload fields are treated as untrusted input, so a malformed body is a quiet no-op rather than a crash. The config key is validated at boot: a typo'd statusChannel refuses to start with an error naming the field instead of limping along in a mode you did not choose.

The old path is still verified byte for byte. With hooks absent or disabled, the pane watcher behaves exactly as it did in v1.3, and the replay suite that pins its behavior passed unchanged throughout.

Full changelog: v1.3...v1.4

Requires Node ≥ 22.22, tmux, ttyd, git, and the Claude Code CLI. Setup is in the README.