Skip to content

feat: include cursor position in wait change detection#4

Open
onesuper wants to merge 1 commit intomainfrom
feature/cursor-stability-wait
Open

feat: include cursor position in wait change detection#4
onesuper wants to merge 1 commit intomainfrom
feature/cursor-stability-wait

Conversation

@onesuper
Copy link
Copy Markdown
Owner

@onesuper onesuper commented Apr 9, 2026

Problem

wait tracked changes in screen text, title, and fullscreen state — but not cursor position. When a program moved the cursor without changing visible text (e.g. vim navigating between lines, pdb repositioning the prompt, or any TUI app
that redraws the cursor after processing input), wait would not resolve. Agents had to fall back to blind sleep calls to compensate.

This is particularly relevant now that wait is being positioned as a semantic readiness signal rather than a polling mechanism — cursor stability is a key indicator that a program has finished responding to input.

Solution

Extended hasChanged to also compare cursor x/y position. wait now captures the cursor position before waiting and compares it on each change event. If only the cursor moves (screen text unchanged), wait still resolves correctly.

Changes

  • hasChanged accepts an optional cursor: { x, y } field in both before and current snapshots
  • wait captures beforeCursor from terminal.buffer.active before the wait loop begins
  • On each check, current cursor position is passed to hasChanged
  • Fully backward compatible — cursor comparison is only performed when both sides provide a cursor value

Tests

Four new unit tests on hasChanged:

  • returns true when cursor position changes even if screen text is the same
  • returns true when cursor row changes
  • returns false when cursor position is the same
  • ignores cursor when cursor is not provided (backward compatible)

hasChanged now compares cursor x/y in addition to screen text, title,
and fullscreen state. This allows `wait` to resolve when only the cursor
moves (e.g. vim navigating without changing text), giving agents more
accurate readiness signals without polling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant