Skip to content

fix(terminal): suppress false busy state after terminal resize#2365

Merged
gregpriday merged 2 commits intomainfrom
feature/issue-2364-terminal-resize-incorrectly
Feb 26, 2026
Merged

fix(terminal): suppress false busy state after terminal resize#2365
gregpriday merged 2 commits intomainfrom
feature/issue-2364-terminal-resize-incorrectly

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

Prevents false idle→busy transitions when terminal resize sends SIGWINCH to the PTY, causing xterm to reflow its content and emit ANSI escape sequences that the ActivityMonitor misinterprets as real agent activity.

Closes #2364

Changes Made

  • ActivityMonitor.ts — Added notifyResize(suppressionMs = 1000) public method that sets a resizeSuppressUntil timestamp and resets the high-output tracking window. Guards in onData() and runPollingCycle() skip all idle→busy transitions during the suppression window:

    • High-output byte rate recovery
    • Non-polling pattern detection (becomeBusyFromPattern)
    • Line-rewrite / spinner detection (becomeBusy via updateLineRewriteDetection)
    • Polling cycle working-signal branch and high-output recovery
  • TerminalProcess.ts — Calls this.activityMonitor.notifyResize() inside resize() after both the PTY process and headless terminal have been resized. Guarded by this.activityMonitor null check; exited terminals are unaffected by the existing early return.

  • ActivityMonitor.test.ts — 5 new unit tests in "Resize suppression (Issue #2364)" describe block:

    1. High-output bytes during suppression window do not trigger busy
    2. High-output bytes after suppression window expires do trigger busy
    3. Polling-cycle pattern recovery is suppressed during resize
    4. Rapid successive resizes reset (extend) the suppression window
    5. Already-busy terminals remain busy through resize

- Derive project name from worktree directory basename (kebab-cased, lowercase)
- Replace fixed 'context-' prefix with the project name for easier identification
- Cap project name at 50 chars; filename pattern is now {project}-{branch}-{timestamp}.{ext}
Adds a resize suppression window to ActivityMonitor that prevents reflow
bytes emitted by SIGWINCH from triggering false idle→busy transitions.

- Add `notifyResize(suppressionMs=1000)` to ActivityMonitor that sets a
  `resizeSuppressUntil` timestamp and resets the high-output window
- Guard all idle→busy transitions during suppression: high-output
  recovery, non-polling pattern detection, line-rewrite detection, and
  the polling cycle working-signal branch
- Call `activityMonitor.notifyResize()` from TerminalProcess.resize()
  after PTY and headless terminal are resized
- Add 5 unit tests covering suppression window, expiry, polling cycle
  suppression, rapid successive resizes, and busy-terminal preservation
@gregpriday gregpriday merged commit 4682966 into main Feb 26, 2026
2 of 3 checks passed
@gregpriday gregpriday deleted the feature/issue-2364-terminal-resize-incorrectly branch March 3, 2026 00:29
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.

Terminal resize incorrectly triggers agent working state

1 participant