Skip to content

fix: suppress turn-complete terminal notification while goal is active#1183

Open
ForgottenR wants to merge 1 commit into
MoonshotAI:mainfrom
ForgottenR:fix/suppress-turn-notification-during-goal
Open

fix: suppress turn-complete terminal notification while goal is active#1183
ForgottenR wants to merge 1 commit into
MoonshotAI:mainfrom
ForgottenR:fix/suppress-turn-notification-during-goal

Conversation

@ForgottenR

@ForgottenR ForgottenR commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Related Issue

N/A

Problem

In goal mode, TurnFlow.driveGoal() runs multiple autonomous continuation turns. Each turn end calls StreamingUIController.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.ended is emitted before the goal is paused/blocked. If the notification decision only looks at the current goal.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

  • Moved the turn-complete terminal notification out of StreamingUIController.finalizeTurn() and into SessionEventHandler.
  • SessionEventHandler now tracks when the active goal leaves the active state. If the turn has already ended, it notifies immediately; otherwise it waits for turn.ended and then notifies.
  • This preserves the original behavior for normal turns and for paused/blocked/complete goals, while suppressing the bell only during genuine active-goal continuation turns.
  • StreamingUIController.finalizeTurn() now returns whether it scheduled a queued message, so the caller knows whether to skip the notification.
  • Added session-event-handler-notification.test.ts covering normal turns, active-goal continuation, model-driven completion, and runtime-driven pause/block.
  • Updated existing session-event-handler-goal-queue.test.ts and streaming-ui.test.ts mocks for the new finalizeTurn return type.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1819964

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@1819964
npx https://pkg.pr.new/@moonshot-ai/kimi-code@1819964

commit: 1819964

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +579 to +580
const hasActiveGoal = state.appState.goal?.status === 'active';
if (!hasActiveGoal) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@ForgottenR ForgottenR force-pushed the fix/suppress-turn-notification-during-goal branch from b81e62b to 1819964 Compare June 28, 2026 21:26
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.

1 participant