Skip to content

fix(tui): steer user messages into the running turn while a goal is active - #2153

Merged
chengluyu merged 3 commits into
mainfrom
fix/goal-queue-drain-steer
Jul 24, 2026
Merged

fix(tui): steer user messages into the running turn while a goal is active#2153
chengluyu merged 3 commits into
mainfrom
fix/goal-queue-drain-steer

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Related Issue

None — this is a clear, reproducible bug fix; the problem is explained below.

Problem

While a goal is being pursued, the engine holds its single active turn across the whole goal continuation loop. The TUI, however, goes idle at every turn.ended — including each goal continuation boundary — and then sends queued input (drained from its message queue, or typed in the brief idle window) as a fresh prompt. That prompt races the goal driver and is rejected with turn.agent_busy ("Cannot launch a new turn while another turn (ID N) is active"), so the user's message is silently dropped: it appears in the local transcript but never reaches the session history.

What changed

  • In the TUI's message-send path, when a goal is active the message is now sent via session.steer instead of session.prompt. The engine buffers steered input into the running goal turn (flushed at the next step / turn boundary, where the model can react to it), or launches a turn of its own if the goal loop just ended — both correct outcomes, with no rejection. When no goal is active, messages still go through prompt exactly as before.
  • This follows the engine's designed contract (turn.agent_busy: "Wait for the current turn to finish or steer it") rather than changing engine semantics, so other hosts are unaffected.
  • Added message-flow tests covering: fresh input steered while a goal is active even in the idle window, a queued message steered at a goal continuation boundary, and the unchanged prompt path when no goal is active.
  • Includes a changeset (@moonshot-ai/kimi-code, patch).

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 Jul 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9071abc

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 Jul 24, 2026

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

commit: 9071abc

@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: ba67dbb33e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: e1485d0fb0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/kimi-tui.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 9071abcf06

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chengluyu
chengluyu merged commit c497af6 into main Jul 24, 2026
14 checks passed
@chengluyu
chengluyu deleted the fix/goal-queue-drain-steer branch July 24, 2026 18:12
@github-actions github-actions Bot mentioned this pull request Jul 24, 2026
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