fix(orchestration): defer push-on-idle injection while user is typing
Open
innocarpe
opened this issue 4 months ago
โข
3 comments
Description
Orchestration push-on-idle still wrote banners into a pane where a human was typing (clobbering the draft) and could auto-submit with synthetic Enter when no active coordinator run was registered (#7391 only guarded the coordinator_handle match).
Focused fix
Defer delivery (no PTY write) when the leaf is user-focused โ messages stay undelivered for later idle
Skip synthetic Enter when there is no active coordinator run, or leaf is user-focused / Cursor / active coordinator
Pure helpers + runtime wiring in deliverPendingMessages
Out of scope: per-terminal --no-submit flag (#3034)
Preserves
Worker auto-submit under an active coordinator run when the pane is not user-focused
This PR fixes orchestration push-on-idle injection clobbering user input by deferring banner delivery and auto-submit when the user is actively typing. The implementation introduces a 5-second quiet window after keystrokes, checked before pointer writes and Enter submission.
Key changes:
Adds typing-quiet detection logic that defers delivery when window is focused and PTY has input in last 5s
Implements retry mechanism with per-mailbox timers to redeliver after quiet window expires
Wires timing state through PTY controller and runtime dependencies
Skips synthetic Enter when no active coordinator or user is typing
Diagram
sequenceDiagram
participant User
participant PTY
participant Delivery
participant TypingQuiet
participant Timer
participant Submit
User->>PTY: keystroke
PTY->>PTY: update lastInputAtByPty
Note over Delivery: Orchestration message arrives
Delivery->>TypingQuiet: defer(lastInputAt, now, focused)
TypingQuiet->>TypingQuiet: "remaining = 5000 - (now - lastInputAt)"
alt "remaining > 0"
TypingQuiet->>Timer: setTimeout(redrive, remaining)
TypingQuiet-->>Delivery: true (deferred)
Note over Delivery: No PTY write
else "remaining <= 0"
TypingQuiet-->>Delivery: false (can deliver)
Delivery->>PTY: write pointer banner
Delivery->>Submit: schedule Enter after 500ms
Submit->>TypingQuiet: shouldDefer?
alt still typing
TypingQuiet-->>Submit: true
Submit->>Timer: scheduleTypingQuietRetry
Note over Submit: Skip Enter, keep unread
else quiet
TypingQuiet-->>Submit: false
Submit->>PTY: write Enter
end
end
Timer->>Delivery: redrive after quiet window
Delivery->>PTY: write pointer banner
We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
[ ] Trigger review
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Last reviewed commit: 08a8085986b5ad28b1a1697c5e361f9d36b9a690
Latest commit, not reviewed: 69b6302f846d9ca2cba1bb7b8286fdd16aae1aa8
Use the following commands to manage reviews:
@coderabbitai resume to resume automatic reviews.
@coderabbitai review to trigger a single review.
Use the checkboxes below for quick actions:
[ ] โถ๏ธ Resume reviews
[ ] ๐ Trigger review
Walkthrough
Orchestration mailbox delivery now tracks the latest renderer-accepted PTY input timestamp. Focused PTYs defer pointer writes during a five-second typing-quiet interval. A retry coordinator redrives deferred mailboxes after the interval. Pointer staging now handles PTY writes, delivery-flight finalization, mailbox watermark updates, Cursor redrives, and delayed Enter submission. Runtime wiring supplies PTY input, focus, clock, and write callbacks. Tests cover quiet-period decisions, deferred delivery, unfocused windows, missing input, and immediate delivery.
๐ฅ Pre-merge checks | โ 3 | โ 2
โ Failed checks (2 warnings)
Check name
Status
Explanation
Resolution
Description check
โ ๏ธ Warning
The description explains the bug, fix, trade-offs, issue, and test evidence but omits most required template sections and visual-proof details.
Use the repository template and add the missing ELI5, What Changed, Why, Visual Proof, Testing, checklist, and review sections.
Docstring Coverage
โ ๏ธ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
โ Passed checks (3 passed)
Check name
Status
Explanation
Title check
โ Passed
The title clearly describes the primary change: deferring push-on-idle injection while the user is typing.
Linked Issues check
โ Passed
The changes address issue #11242 by deferring delivery during typing, delaying synthetic Enter, and preserving coordinator and Cursor protections.
Out of Scope Changes check
โ Passed
The implementation and tests remain focused on orchestration typing-quiet delivery and synthetic submission behavior described in issue #11242.
[ ] Autofix ยท Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Rebase onto latest upstream/main: keep message-delivery flights; defer push-on-idle injection while user-focused; synthesize Enter only for unattended workers under active run.
[!NOTE]
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
#14832 is the pointer-era follow-up for the same submit-while-typing failure.
The proposed gate there is this PTY had user input in the last 5s and the Orca window is focused (then retry), rather than deferring only while the focused leaf matches. lastInputAtByPty is already per-terminal, so splits / clicking the editor still keep the draft attached to the PTY that received keys.
[!NOTE]
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
Follow-up for the pointer-era report on #14832 / #11242.
Rebased onto current main (delivery now lives in OrchestrationMailboxPointerDelivery) and replaced the focused-leaf gate:
Defer the pointer write when this PTY had renderer input in the last 5s (lastInputAtByPty via RuntimePtyController.lastUserInputAt) and an Orca window is focused (BrowserWindow.getFocusedWindow()), then retry after the remaining quiet time.
Skip the delayed Enter under the same predicate so we do not submit the draft. Pointer writes still do not stamp lastInputAtByPty.
Do not use tab.activeLeafId or INTERACTIVE_OUTPUT_WINDOW_MS.
Preserves: idle push still delivers after the quiet window; Cursor still skips Enter; no remote wire change.
[!NOTE]
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
Rebased onto current main after the PTY controller split. lastUserInputAt is wired through RuntimePtyController from lastInputAtByPty (renderer keystrokes only). An active coordinator Run does not bypass the 5s typing-quiet gate; pointer write and delayed Enter still defer while this PTY is being typed.