mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-11-06 08:15:35 +00:00
An agent hook reported by writing an OSC 777 sequence to the tty the agent draws on. A tty write is not atomic: on macOS the kernel parks a writer whenever the output queue is over its high-water mark, which is exactly when the agent is busy redrawing, and lets the other writer in. The agent's output then lands inside our sequence, the OSC breaks, and the rest of the JSON is printed on screen. A pty test with a busy writer next to a small one splits even 100-byte writes, at arbitrary offsets, so no size keeps the sequence whole. The hook now sends the same JSON to the daemon that owns its pane (`$TTY7_PANE`, over the pane socket `$TTY7_CONFIG_DIR` leads to), which applies it exactly as if its reader had found it in the output. The pane id comes from the environment, which a detached tmux server or the like carries out of the pane, so the daemon applies a report only from a process that runs under the pane's shell. Anything else — no daemon, one that predates the message, a refusal — falls back to the tty as before, which is still how a hook with no daemon beside it reports.