Skip to content

fix(native-chat): infer interrupt after acknowledged Escape on chat Stop - #41285

Merged
nwparker merged 1 commit into
mainfrom
bugbash/ag3-pr-31795
Nov 11, 2026
Merged

nwparker merged 1 commit into
mainfrom
bugbash/ag3-pr-31795

Conversation

@nwparker

@nwparker nwparker commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Send single-Escape chat Stop cancellations through sendRawVerified(ESC) (requireWriteSettlement: true) and trigger createAgentInterruptInference(...).observeInputIntent('plain-escape', statusBeforeEscape) once the write is acknowledged.
  • Capture statusBeforeEscape before dispatching the Escape so slow remote write settlements cannot clear a turn that began mid-send, and refused writes never trigger interrupt inference.
  • Add unit tests in use-native-chat-interactive-send.test.tsx.

Fixes #31786

Co-authored-by: Zetao Qi [email protected]

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​125 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​125
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

A chat Stop wrote Escape directly to the runtime PTY, bypassing xterm onData so agents that emit no interrupt hook stayed Working in the sidebar. Send Stop's Escape via sendRawVerified and observe plain-escape against the pre-Escape status baseline only after write settlement.

Fixes #31786
Co-authored-by: Zetao Qi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The Stop action now uses sendRawVerified to send Escape. After acknowledged delivery, it runs interrupt inference with the captured and current pane statuses. Inference errors are warned and return false. Tests cover accepted and rejected delivery, delayed acceptance after a status change, and the inference settle interval.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 2f010

Chat Stop should now clear the Working status when the agent emits no interrupt hook. Refused writes do not trigger inference. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description covers the core of the change. It states the mechanism (sendRawVerified with requireWriteSettlement, observeInputIntent after acknowledgment), the reason for capturing statusBeforeEsca… Add the missing template sections: an ELI5 summary; a What Changed section that describes the before and after user experience (Stop on a non-hook agent does not clear the Working status, and the fix clears it); a Visual Proof section with …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: after an acknowledged Escape on chat Stop, the interrupt inference runs. It matches the raw summary and the PR objectives. It uses a conventional fix(scope) prefix and…
Linked Issues check Passed Issue #31786 requires that chat Stop in a terminal-backed chat clears the "Working" status when the agent fires no interrupt hook, matching what a typed Escape already does through xterm onData. At th…
Out of Scope Changes check Passed The whole-PR diff for the source file adds only the createAgentInterruptInference import, the statusBeforeEscape capture, the verified Escape dispatch with acknowledgement gating, and the dependen…
Full details: Title check

Explanation

The title names the main change: after an acknowledged Escape on chat Stop, the interrupt inference runs. It matches the raw summary and the PR objectives. It uses a conventional fix(scope) prefix and is 72 characters, within a normal length.

Full details: Linked Issues check

Explanation

Issue #31786 requires that chat Stop in a terminal-backed chat clears the "Working" status when the agent fires no interrupt hook, matching what a typed Escape already does through xterm onData. At the reviewed head, cancel in use-native-chat-interactive-send.ts sends the single Escape through sendRawVerified(ESC), which calls sendRuntimePtyInputVerified with requireWriteSettlement: true. Before dispatch, it captures statusBeforeEscape from agentStatusByPaneKey[paneKey]. Only when the write resolves as accepted does it call createAgentInterruptInference(...).observeInputIntent('plain-escape', statusBeforeEscape). This restores the inference path the issue says is missing. The change is confined to the non-second-Escape branch of cancel, so agents that use the second-Escape path are unchanged. The issue's phone Stop note is described as likely, not established, so it is not a requirement here. Unverified: the internals of createAgentInterruptInference and the new unit tests were not inspected. The test file summary reports coverage of accepted, rejected, and superseded-status cases.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff for the source file adds only the createAgentInterruptInference import, the statusBeforeEscape capture, the verified Escape dispatch with acknowledgement gating, and the dependency update on paneKey and sendRawVerified. All of these serve the Stop path in issue #31786. The test file (+125 lines, per the summary) tests this same hook behavior. No unrelated code paths were changed in the inspected source. The sendRaw callback remains in the returned API and is used by other callers, so its retention is not a scope change.

Full details: Description check

Explanation

The description covers the core of the change. It states the mechanism (sendRawVerified with requireWriteSettlement, observeInputIntent after acknowledgment), the reason for capturing statusBeforeEscape first, and the test file. It links the issue with 'Fixes #31786'. It omits several template sections: ELI5, a before/after description of user-visible behavior, Visual Proof, the Testing checklist, the Risk level and rollback plan, and the AI Disclosure and Review sections. The Linked Issue section is present. The Notes and Checklist sections are absent. The description is partly complete, so it is not a fail, but it needs these additions.

Resolution

Add the missing template sections: an ELI5 summary; a What Changed section that describes the before and after user experience (Stop on a non-hook agent does not clear the Working status, and the fix clears it); a Visual Proof section with a before and after video or an N/A reason (this is a behavior change, so a before and after is required); a Testing section with the platforms tested and the checklist items; a Risk section with the level (Low, Medium, or High), what could break, and how to revert; and the AI Disclosure section if applicable. Also confirm the Agent skill upstream boundary checkbox and the Checklist items.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1

src/renderer/src/components/native-chat/session/terminal/send/use-native-chat-interactive-send.test.tsx: 1

69-74: Trivial · Maintainability & Code Quality · Quick win

Test acceptance gating with an unresolved write.

The immediately resolved mock does not test whether inference can start before acknowledgment. The delayed test also changes the status, which lets the helper reject premature inference independently of acknowledgment.

Add a deferred-write case that keeps the status unchanged. Advance beyond AGENT_INTERRUPT_SETTLE_MS before resolving the write and assert no inference. Then accept the write, advance the settle interval, and assert one inference.

Based on learnings, use a deferred promise for asynchronous ordering assertions.

Source: Learnings

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b199868a-0d93-4d26-afba-060494f9559e
Commits

Reviewing files that changed from the base of the PR and between f9d5456 and 2f010c2.

Files selected for processing: 2

  • src/renderer/src/components/native-chat/session/terminal/send/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/session/terminal/send/use-native-chat-interactive-send.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@nwparker
nwparker merged commit 891995f into main Nov 11, 2026
41 checks passed
@nwparker
nwparker deleted the bugbash/ag3-pr-31795 branch November 11, 2026 23:22
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.

[Bug]: Sidebar keeps "Working" after Stop in Chat UI when the agent fires no interrupt hook

1 participant