fix(agent-completion): stop PermissionRequest hooks from firing false completion notifications#6316
Conversation
… task-complete notifications (stablyai#5698)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe coordinator now treats only 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Summary
agent-task-completedesktop notification becauseisCompletionHookStatein the agent-completion coordinator treated'waiting'(PermissionRequest) and'blocked'(Copilot elicitation dialog) as completion states.isAttentionHookStatethat callsclearPendingHookDone()to cancel any quiet-window timer that started on a priordoneevent — preventing a delayed false notification if a permission prompt arrives within the 1.5-second quiet window.'done'now triggers the completion path. The sidebar attention indicator already surfaces permission-prompt state inline without a notification.Closes #5698.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation run in this session:
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts— 46 tests passed (0 failed). Covers: updated regression test asserting 0 dispatches onwaiting(was 2); newblockedno-dispatch test; new debounce-cancellation edge case (working → done → waitingbefore quiet window, 0 dispatches after timer advance).pnpm run typecheck:web— passed (0 errors).AI Review Report
Reviewed
agent-completion-coordinator.tschange and the surroundingobserveHookStatuslogic on macOS, Linux, and Windows. The change is a pure coordinator logic fix — no Electron, IPC, SSH, terminal, or browser surface touched. The helperisAttentionHookStatemirrors the existingisCompletionHookStatepattern. TheclearPendingHookDone()call matches every other early-return site inobserveHookStatusthat clears pending timers. The existing 1.5-second quiet-window path for realdoneevents is unchanged. Provider neutrality: all four provider normalization functions (Claude, Devin, Kimi, Copilot) map PermissionRequest/blocked to'waiting'/'blocked'— those mappings are correct and unaffected. Mobile/desktop notification routing unchanged (DesktopNotificationSourcetype is not modified). No cross-platform risk; pure logic change in renderer TypeScript.Security Audit
No IPC paths, filesystem access, subprocesses, auth, or secrets touched. The change affects only which coordinator state transitions dispatch a notification — no security surface.
Notes
Routing
'waiting'/'blocked'to a newagent-attention-needednotification source was considered. That would be a product feature (separate notification category with its own settings, throttling, and mobile semantics) and is out of scope for this correctness fix. The sidebar attention indicator already covers the attention state inline.