fix: suppress turn-complete terminal notification while goal is active#1183
fix: suppress turn-complete terminal notification while goal is active#1183ForgottenR wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 1819964 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b81e62b083
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const hasActiveGoal = state.appState.goal?.status === 'active'; | ||
| if (!hasActiveGoal) { |
There was a problem hiding this comment.
Preserve notifications for post-turn goal stops
When an active goal stops because the driver pauses or blocks it after runOneTurn returns (for example Esc/cancel, provider failure/filtering, a UserPromptSubmit hook block, or a budget reached after the turn), the turn.ended event is emitted before those goal updates in packages/agent-core/src/agent/turn/index.ts. At this point state.appState.goal.status is still active, so this branch suppresses the only turn-complete notification; the later goal.updated handler only updates UI state and does not call finalizeTurn or notify. Users who leave the terminal therefore won't be alerted when an autonomous goal actually stops in these blocking/failure paths.
Useful? React with 👍 / 👎.
b81e62b to
1819964
Compare
Related Issue
N/A
Problem
In goal mode,
TurnFlow.driveGoal()runs multiple autonomous continuation turns. Each turn end callsStreamingUIController.finalizeTurn(), which unconditionally emits a "Kimi Code task complete" terminal bell/desktop notification. This causes the notification to fire before the goal has actually finished.A second issue (pointed out by review): for runtime-driven stops — interruption, provider failure/filtering, UserPromptSubmit hook block, or budget reached after the turn —
turn.endedis emitted before the goal is paused/blocked. If the notification decision only looks at the currentgoal.status, it suppresses the only turn-complete notification and users who left the terminal are never alerted that the autonomous goal actually stopped.What changed
StreamingUIController.finalizeTurn()and intoSessionEventHandler.SessionEventHandlernow tracks when the active goal leaves theactivestate. If the turn has already ended, it notifies immediately; otherwise it waits forturn.endedand then notifies.StreamingUIController.finalizeTurn()now returns whether it scheduled a queued message, so the caller knows whether to skip the notification.session-event-handler-notification.test.tscovering normal turns, active-goal continuation, model-driven completion, and runtime-driven pause/block.session-event-handler-goal-queue.test.tsandstreaming-ui.test.tsmocks for the newfinalizeTurnreturn type.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.