Skip to content

Commit 4bcc205

Browse files
committed
docs: anchor standalone cursor-line waits with --after-seq
1 parent de2720d commit 4bcc205

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

docs/USAGE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Useful flags:
102102
- `--regex <pattern>`: wait for a regex match in rendered output.
103103
- `--scope <scope>`: where `--text`/`--regex` match — `screen` (default, whole visible screen) or `cursor-line` (only the row the cursor is on). See [Echo-Match](#echo-match).
104104
- `--screen-stable-ms <ms>`: wait for the rendered screen to be stable.
105+
- `--after-seq <n>`: only match renderer snapshots produced after this Event Log sequence — thread an input command's returned `seq` here so the wait cannot match pre-input screen state.
105106
- `--idle-ms <ms>`: wait for output idleness.
106107
- `--exit`: wait for the process to exit.
107108
- `--timeout <ms>`: maximum wait time in milliseconds, with `0` meaning infinite.
@@ -118,6 +119,13 @@ agent-tty wait <session-id> --regex 'READY>$' --scope cursor-line --json
118119

119120
Rendered lines are right-trimmed of trailing ASCII spaces, so anchor prompt regexes without the trailing space: a prompt displayed as `READY> ` matches `READY>$`, not `READY> $`.
120121

122+
A standalone cursor-line wait issued right after an input command (`type`, `send-keys`, `run --no-wait`) can still match the **pre-input screen**: input commands return once the input is logged, before the application's response is necessarily rendered. If the cursor row already matched before the input — for example a repeated prompt in an echo-disabled application — the wait returns without the application having responded. Thread the input command's returned `seq` into `--after-seq` so the wait only observes screen state produced after the input; inside `batch`, wait steps get this anchoring automatically from the Wait Baseline:
123+
124+
```bash
125+
SEQ=$(agent-tty send-keys <session-id> Enter --json | jq -r '.result.seq')
126+
agent-tty wait <session-id> --regex 'READY>$' --scope cursor-line --after-seq "$SEQ" --json
127+
```
128+
121129
For waiting on output text that scrolls past the cursor, prefer a distinctive output token or combine `--text` with `--screen-stable-ms`.
122130

123131
### Screen Hash

skill-data/agent-tty/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ agent-tty --home "$AGENT_HOME" batch "$SESSION_ID" '[
8989
agent-tty --home "$AGENT_HOME" screenshot "$SESSION_ID" --json
9090
```
9191

92-
A `wait` can still match the _echo_ of a just-typed command. Add `"scope": "cursor-line"` to a wait step (or `--scope cursor-line` on a standalone `wait`) to restrict `text`/`regex` matching to the row the cursor is on — once Enter is pressed the cursor moves past the echoed line, so the echo cannot match. This is ideal for prompts, which render at the cursor; rendered lines are right-trimmed of trailing spaces, so anchor a prompt displayed as `READY> ` with `READY>$`. For output that scrolls past the cursor, use a distinctive output token or `screenStableMs`.
92+
A `wait` can still match the _echo_ of a just-typed command. Add `"scope": "cursor-line"` to a wait step (or `--scope cursor-line` on a standalone `wait`) to restrict `text`/`regex` matching to the row the cursor is on — once Enter is pressed the cursor moves past the echoed line, so the echo cannot match. This is ideal for prompts, which render at the cursor; rendered lines are right-trimmed of trailing spaces, so anchor a prompt displayed as `READY> ` with `READY>$`. A standalone cursor-line wait issued right after an input command can still observe the pre-input screen (for example a repeated prompt in an echo-disabled application), so pass the input command's returned `seq` as `--after-seq`; `batch` wait steps are anchored automatically. For output that scrolls past the cursor, use a distinctive output token or `screenStableMs`.
9393

9494
### Export reviewer-facing artifacts
9595

0 commit comments

Comments
 (0)