Attach the terminal to tmux runs so Unix matches the Windows experience - #17
Merged
Conversation
`sleeperagent run` from a real terminal now drops the user straight into the live tmux session (a supervised `tmux attach` child) while the watchdog keeps polling in the parent, logging to the instance log file. The supervisor's own attach client is hidden from the auto-detach check (attachSuppressingPane); detaching the view (prefix+d) restores console logging with the watchdog still running, and a subsequent manual attach still auto-detaches as a real takeover. New --detached flag restores the console-watch mode; non-TTY runs are unchanged. Verified with a new real-tmux integration test (integration_interactive_attach) plus the existing 8, all green in WSL. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Takeover detection during the self-view: ClientAttached now counts clients while our view is up (via tmux list-clients) instead of masking them all, so a second human attaching still auto-detaches. - Attach failure / view detach falls back to the classic console mode: hotkeys d/q/k engage late via a fallback channel, restoring the kill and detach affordances; runs from inside tmux ($TMUX set) skip the auto-attach entirely since tmux refuses nested attaches. - Supervisor-initiated detach no longer yanks the user out of the view: it flashes a tmux status-line message and waits for them to detach (mirrors the pty backend), and the killed/ended paths wait (bounded) for the view teardown so final messages land on the console. - Extracted setupInteractiveAttach and gave attach-existing (the crash-recovery path) the same interactive attach + --detached flag; deduped the detach message; replaced the 50ms waitCondition poll with a viewDone channel; refreshed the stale pty-only wording in logs.go. Verified: go vet + unit tests green; all 10 integration tests pass in WSL tmux, including a new second-client takeover test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On Windows (ConPTY backend)
sleeperagent runputs you directly in the agent session: you prompt it normally while the watchdog monitors and auto-resumes after a limit reset. On Linux/macOS (tmux backend) the session started detached and invisible — and attaching to prompt the agent kicked the watchdog off via auto-detach. This makes the tmux backend match the Windows experience.What
runfrom a real terminal now starts attached: aftertmux new-session -d, a supervisedtmux attachchild wires the user terminal into the session while the supervisor keeps polling in the parent. Supervisor logs go to the instance log file (sleeperagent logs --name N) so they never corrupt the agent TUI.attachSuppressingPanehides our own client from theClientAttachedcheck. A manualtmux attachafter the self-view exits is still treated as a takeover and auto-detaches as before.--detachedflag restores the old console-watch mode (hotkeys d/q/k). Non-TTY runs (scripts, CI) are unchanged, so existing integration tests needed no edits.Testing
go vet+go test ./...green on Windows (includes a new unit test for the suppression wrapper).test/integration_interactive_attach.sh(auto-attach on start, no self-auto-detach, view detach keeps RUNNING, takeover still auto-detaches), wired intorun_all.sh.🤖 Generated with Claude Code