Repository navigation
fix(agent-completion): stop PermissionRequest hooks from firing false completion notifications - #6316
Conversation
📝 WalkthroughWalkthroughThe coordinator now treats only 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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. Comment |
Co-authored-by: Orca <[email protected]>
a7cbe5b to
e6eaf82
Compare
…aiting Wire dispatchAttention into the done-after-waiting regression test so it verifies both halves of the stablyai#5698 fix: the mid-turn permission pause surfaces as attention exactly once, and the later genuine 'done' still completes exactly once. Matches sibling tests that assert on both paths. Co-authored-by: Orca <[email protected]>
|
Takeover + validation summary I took over this PR, screened it, verified it against current Verdict: VALIDATED (reduced scope: test-only).
Checks: Trade-off: test-only, no runtime behavior change, no regressions. |
|
Thanks again, @rodboev. Even with the underlying fix already on main, keeping your regression test to lock in "a permission pause still yields exactly one completion" is well worth it — that's exactly the kind of guard that saves a future headache. Merged! |
|
Thanks Rod 🙏 By the time we reviewed, the runtime fix had already landed — but your regression test earns its keep by proving a permission pause still ends in exactly one real completion. Good tests outlive the bug that inspired them. Grateful for it. 🐋 |
… completion notifications (stablyai#6316) * test(agent-completion): cover done after waiting pause Co-authored-by: Orca <[email protected]> * test(agent-completion): assert attention fires alongside done-after-waiting Wire dispatchAttention into the done-after-waiting regression test so it verifies both halves of the stablyai#5698 fix: the mid-turn permission pause surfaces as attention exactly once, and the later genuine 'done' still completes exactly once. Matches sibling tests that assert on both paths. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: brennanb2025 <[email protected]> Co-authored-by: Orca <[email protected]> Co-authored-by: Neil <[email protected]>
Description
Closes #5698 (P1): Claude/Devin/Kimi/Copilot
PermissionRequesthooks were firing falseagent-task-completenotifications, because the completion coordinator treated thewaiting(PermissionRequest) andblocked(Copilot elicitation) states as completion signals.The source fix for this bug has already landed on
main.isCompletionHookStatenow returns'done'only, and a dedicatedisAttentionHookStaterouteswaiting/blockedthroughdispatchAttention(which cancels any pending quiet-windowdonetimer) instead of the completion path.mainadditionally gained ashouldSuppressHookCompletionlayer that hardens the same seam. Issue #5698 is closed.What remained missing was positive-path regression coverage. The existing suite proves
waiting/blockeddo not complete (the negative direction), but nothing proved that a genuinedonestill completes after an intervening permission pause in the same turn. That is the exact real-world flow from the bug report (agent pauses for a permission prompt, user approves, agent finishes) and the scenario most at risk of being broken by an over-correction of the fix.This PR (now scoped to test-only) adds that guard:
working → waiting → working → donedispatches attention exactly once (for the pause) and completion exactly once (for the genuine finish).Takeover note: the original ~33-line diff already reduced to a single test because the source change merged separately. This branch merges current
main, keeps the author's test, and polishes it to also assert the attention dispatch — matching the sibling tests in the file that assert on both the completion and attention paths.Evidence
Failing under the pre-fix bug (temporarily reverting
isCompletionHookStateto includewaiting/blockedand disablingisAttentionHookState, simulating June behavior):The mid-turn
waitingfires a false completion (call #1) on top of the realdonecompletion (call #2) — exactly the #5698 symptom.Passing on
main+ this test (fix restored):pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts— 57 passedpnpm run typecheck— clean (node + cli + web)oxlint+oxfmt --checkon the touched file — cleanELI5
When Claude stops to ask "can I run this command?", that's the middle of a job, not the end. The app used to ding you with "task complete!" every time it asked. That bug is already fixed. This change adds a safety net that makes sure the fix didn't go too far: after Claude asks permission, you approve, and it actually finishes — you should still get exactly one "done" ding. The test proves you do.
Trade-offs
waiting/blockedshould raise their own distinct "needs attention" notification instead of only the inline sidebar indicator) remains out of scope — that would be a new notification category with its own settings and throttling.