Skip to content

Add commands, fix send-to-exited, improve docs#70

Merged
pcarrier merged 6 commits intomainfrom
indent-2026-03-31-blit-improvements
Mar 31, 2026
Merged

Add commands, fix send-to-exited, improve docs#70
pcarrier merged 6 commits intomainfrom
indent-2026-03-31-blit-improvements

Conversation

@pcarrier
Copy link
Copy Markdown
Contributor

@pcarrier pcarrier commented Mar 31, 2026

Summary

  • Add blit wait ID --timeout N command that blocks until a PTY exits, returning its exit code (124 on timeout, matching GNU timeout convention)
  • Add --pattern REGEX flag to wait that matches against new output produced after the wait begins (avoids stale matches from old scrollback)
  • Add --wait --timeout N flags to blit start for inline blocking (blit start --cols 200 --wait --timeout 60 make -j8)
  • Fix blit send silently dropping input to exited sessions — now returns an error
  • Fix wait --pattern hanging on already-exited PTY when pattern doesn't match
  • Document restart scrollback behavior (reuses session ID, does not clear terminal state)
  • Document --ssh tunneling mechanism (SSH stdin/stdout relay to remote Unix socket via nc/socat, with connection multiplexing)
  • Strengthen history size warning — emphasize always using --from-end 0 --limit N
  • Replace polling loop documentation in SKILLS.md with blit wait examples

Motivation

Every agent using blit reinvents the same polling loop to wait for command completion, and most get the sleep interval or retry count wrong. blit wait collapses 4-5 lines of bash into one. start --wait further reduces the most common pattern to a single command. The send-to-exited bug causes silent confusion. The doc gaps around restart, SSH, and history size were identified in external feedback.

Testing

10 new tests added to the existing MockServer-based test infrastructure:

Test What it verifies
test_send_to_exited_session send returns error for exited PTY
test_wait_already_exited Immediate return when PTY already exited at connect
test_wait_exits_later Recv loop picks up S2C_EXITED and returns exit code
test_wait_timeout Returns 124 when deadline fires
test_wait_not_found Error for nonexistent PTY
test_wait_signal_exit Signal exit maps to 128+N
test_wait_pattern_match Regex match in terminal output exits 0
test_wait_pattern_exits_before_match PTY exits before pattern matches, returns exit code
test_wait_pattern_already_exited_no_match Already-exited PTY returns exit status instead of hanging
test_wait_invalid_pattern Bad regex returns error

All 57 tests pass. cargo build clean.

Open in Indent
Tag @indent to continue the conversation here.

Adds `blit wait ID --timeout N` to block until a PTY exits, with optional
`--pattern REGEX` to match against new output. Fixes silent no-op when
sending to exited sessions. Documents restart scrollback behavior, SSH
tunneling mechanism, and history size warnings in SKILLS.md.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@indent
Copy link
Copy Markdown

indent bot commented Mar 31, 2026

PR Summary

Adds a blit wait ID --timeout N command that blocks until a PTY exits (returning its exit code) or until output matches a --pattern REGEX. Also adds --wait --timeout N flags to blit start for inline blocking in a single command. Fixes blit send to error when targeting exited sessions, and updates SKILLS.md documentation throughout.

  • New cmd_wait function with two modes: exit-wait (returns process exit code) and pattern-match (subscribes to output, returns 0 on match)
  • blit start --wait --timeout N starts a PTY and blocks until it exits, opening a second connection for the wait logic
  • cmd_start return type changed from Result<(), String> to Result<u16, String> to expose the created PTY ID
  • Timeout returns exit code 124 (matching GNU timeout convention); signal exits mapped to 128+signal
  • cmd_send now returns an error when the target session has already exited
  • Added regex crate dependency for pattern matching
  • Comprehensive test coverage for wait scenarios: already-exited, exits-later, timeout, not-found, signal exit, pattern match/no-match, invalid pattern, send-to-exited, and pattern on already-exited PTY
  • SKILLS.md updated with wait and start --wait usage, restart scrollback warning, SSH tunneling details, and output conventions

Issues

All clear! No issues remaining. 🎉

1 issue already resolved
  • cmd_wait with --pattern on an already-exited PTY will hang until timeout if the pattern doesn't match the frozen viewport. The non-pattern branch correctly checks conn.exited before looping, but the pattern branch skips this check. After subscribing, the server sends one initial update (the frozen terminal state), but if the pattern isn't found, no further updates or exit events arrive, so the loop blocks until the deadline. (fixed by commit 2cb5bb2)

CI Checks

All CI checks passed on commit 2cb5bb2.

@pcarrier pcarrier added the indent label Mar 31, 2026 — with indent
pcarrier and others added 3 commits March 31, 2026 20:03
When using --pattern on a PTY that already exited, the server sends one
initial S2C_UPDATE but no subsequent updates or S2C_EXITED. After
processing the update without a match, check conn.exited to return
immediately instead of blocking until timeout.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
Allows `blit start --cols 200 --wait --timeout 60 make -j8` to start a
PTY and block until it exits in one command. Opens a second connection
to run the wait logic after the PTY is created.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
The README agent subcommands section was missing the new wait command,
restart, and the start --wait shorthand.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@pcarrier pcarrier changed the title Add blit wait command, fix send-to-exited, improve docs Add commands, fix send-to-exited, improve docs Mar 31, 2026
pcarrier and others added 2 commits March 31, 2026 20:29
Added wait subcommand synopsis and description, start --wait --timeout
flags, send-to-exited error behavior, and restart scrollback note.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@pcarrier pcarrier merged commit c40a661 into main Mar 31, 2026
1 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants