Skip to content

Pane(fix[wait_for_text]): anchor on baseline so stale scrollback no longer matches#47

Open
tony wants to merge 1 commit into
mainfrom
stale-wait-for-text
Open

Pane(fix[wait_for_text]): anchor on baseline so stale scrollback no longer matches#47
tony wants to merge 1 commit into
mainfrom
stale-wait-for-text

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented May 12, 2026

Closes #45.

Summary

  • Snapshot (history_size, cursor_y) at entry and translate it to a stable absolute grid index; capture from baseline_abs - hs_now + 1 each poll so wait_for_text only matches lines written after the call begins.
  • Drop content_start / content_end parameters — the baseline anchor supersedes them. Recorded as a ### Breaking changes entry with before/after migration.
  • Cross-reference {tooliconl}search-panes in the docstring for the synchronous "is the pattern there right now?" case, document the sentinel-marker adversarial-safety pattern, and call out scrollback-truncation / reverse-index / clear/reset edge cases per the issue.
  • Restructure WAIT_FOR_TEXT_FIXTURES into pre_command (sent before the wait, settled into baseline) and during_command (sent before the wait but output appears during it). Add stale_scrollback_does_not_match regression case.

Test plan

  • uv run ruff check . --fix --show-fixes — clean
  • uv run ruff format . — no changes
  • uv run mypy — Success: no issues found in 51 source files
  • uv run py.test --reruns 0 -vvv — 447 passed
  • just build-docs — build succeeded
  • New text_appears_during_wait test: positive path still works (text written during the wait matches)
  • New stale_scrollback_does_not_match test: pre-existing scrollback no longer matches (regression for wait_for_text matches stale scrollback immediately — needs baseline anchor #45)
  • Existing timeout_not_found test: empty-pane timeout path still works

@tony tony force-pushed the stale-wait-for-text branch from aa8de89 to 317fbee Compare May 12, 2026 22:58
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.98%. Comparing base (c02f4ae) to head (f706ded).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
+ Coverage   84.91%   84.98%   +0.07%     
==========================================
  Files          40       40              
  Lines        2294     2305      +11     
  Branches      294      294              
==========================================
+ Hits         1948     1959      +11     
  Misses        261      261              
  Partials       85       85              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
Copy link
Copy Markdown
Member Author

tony commented May 13, 2026

Code review

No issues found. Checked for bugs and AGENTS.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

…onger matches (#45)

why: wait_for_text returned found=True on the first poll whenever the
     pattern was already present in the pane when the call began, so
     agents using the tool to synchronise on command output saw the
     wrong result. The sibling wait_for_content_change already snapshots
     a baseline; wait_for_text now mirrors that pattern.

what:
- Snapshot (history_size, cursor_y) at entry; compute baseline_abs as
  the absolute grid index. Each poll re-reads history_size and
  captures from baseline_abs - hs_now + 1 onward, so the matched
  region tracks the pane's grid even as content scrolls into history.
- Add _read_grid_position and _read_history_size helpers that expand
  the corresponding tmux format strings via display-message.
- Drop content_start / content_end parameters; the baseline anchor
  supersedes them. Pre-alpha API contract makes this a clean drop.
- Rewrite docstring: new "wait for new appearance" semantics, cross-
  reference search_panes for synchronous matches, sentinel-marker
  pattern as adversarial-safety guidance, and edge-case notes for
  scrollback truncation, reverse-index sequences, and clear/reset.
- Restructure WAIT_FOR_TEXT_FIXTURES with separate pre_command and
  during_command fields; add stale_scrollback_does_not_match
  regression test.
- CHANGES: ### Breaking changes entry for the parameter drop (with
  before/after migration block) and ### Fixes entry for the
  stale-scrollback behaviour.
@tony tony force-pushed the stale-wait-for-text branch from 317fbee to f706ded Compare May 13, 2026 00:54
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.

wait_for_text matches stale scrollback immediately — needs baseline anchor

2 participants