Repository navigation
feat(tui): add follow_up_behavior to choose whether Enter queues or steers - #4890
Conversation
…terminal reports it
🦋 Changeset detectedLatest commit: 7c96859 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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
🟡 Changes recommended
The steer-draft submission path bypasses queued compaction and model-switch barriers, allowing messages to enter pre-compaction context or use the old model.
What changed in this PR
此 PR 为 TUI 新增 follow_up_behavior 偏好,让用户选择忙时按 Enter 排队或仅注入当前草稿;默认保持排队行为,并接入现有配置、设置和消息投递流程。
Changes:
- 支持偏好解析、保存、重载及
/settings切换。 - 新增提交键映射和单草稿注入路径,处理不可注入与失败回退。
- 更新终端能力相关帮助、中英文文档及配置、键盘和消息流测试。
| File | Description |
|---|---|
| docs/zh/reference/keyboard.md | 补充排队快捷键与 Enter 偏好说明。 |
| docs/zh/guides/interaction.md | 说明忙时 Enter 的可选行为。 |
| docs/zh/configuration/config-files.md | 记录新配置项及示例。 |
| docs/en/reference/keyboard.md | 同步英文快捷键说明。 |
| docs/en/guides/interaction.md | 同步英文交互说明。 |
| docs/en/configuration/config-files.md | 同步英文配置参考。 |
| apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts | 覆盖草稿注入、失败恢复、回退及按键行为。 |
| apps/kimi-code/test/tui/fullscreen-layout.test.ts | 调整设置列表分页断言。 |
| apps/kimi-code/test/tui/controllers/editor-keyboard.test.ts | 验证偏好与提交键映射。 |
| apps/kimi-code/test/tui/config.test.ts | 验证解析、告警及配置往返保存。 |
| apps/kimi-code/test/tui/components/panels/help-panel.test.ts | 验证不同偏好与终端能力下的帮助内容。 |
| apps/kimi-code/test/tui/components/editor/custom-editor.test.ts | 覆盖新增提交键及编辑器特殊输入。 |
| apps/kimi-code/test/tui/commands/reload.test.ts | 验证重载和移除偏好。 |
| apps/kimi-code/test/tui/commands/follow-up-preferences.test.ts | 覆盖设置选择、持久化及保存失败。 |
| apps/kimi-code/src/tui/types.ts | 增加偏好状态及注入结果类型。 |
| apps/kimi-code/src/tui/kimi-tui.ts | 实现单草稿注入、恢复及动态帮助接入。 |
| apps/kimi-code/src/tui/controllers/editor-keyboard.ts | 根据偏好和按键选择投递方式。 |
| apps/kimi-code/src/tui/config.ts | 定义偏好、键位映射及配置读写。 |
| apps/kimi-code/src/tui/components/editor/custom-editor.ts | 识别并记录新增提交键。 |
| apps/kimi-code/src/tui/components/dialogs/settings-selector.ts | 新增 Follow-up behavior 入口。 |
| apps/kimi-code/src/tui/components/dialogs/help-panel.ts | 按偏好和终端能力生成快捷键说明。 |
| apps/kimi-code/src/tui/components/dialogs/follow-up-behavior-selector.ts | 提供 Queue / Steer 选择器。 |
| apps/kimi-code/src/tui/commands/reload.ts | 将重载后的偏好应用到运行状态。 |
| apps/kimi-code/src/tui/commands/dispatch.ts | 透传消息投递方式。 |
| apps/kimi-code/src/tui/commands/config.ts | 接入设置选择器并保存偏好。 |
| .changeset/follow-up-behavior.md | 添加用户可见功能的发布说明。 |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 956e17fb82
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed5fd9f359
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c9685910e
ℹ️ 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".

Requirement or Bug
Agent 工作期间按 Enter,消息会排进队列,等当前轮次结束才发出;想立即插话只能按 Ctrl-S,而 Ctrl-S 会把输入框和整个队列一起注入。很多用户更希望忙时按 Enter 就直接插话。这个 PR 新增
tui.toml偏好follow_up_behavior(queue|steer,默认queue),也可以在/settings→ Follow-up behavior 中切换。选 Steer 后,Enter 只把输入框里这一条注入正在运行的轮次。默认值下行为不变。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路。 每次提交多带一个“投递方式”。编辑器记下是哪个键触发的提交,提交时按当前偏好查一张固定的表,得到
default(今天 Enter 走的路径)、steer-draft(只注入这一条,不碰队列)或queue(忙时一定排队)。default走的代码和今天完全相同。steer-draft在当前无法注入时退回default。queue(默认)steer“今天的 Enter”指:忙时排队(Tower 模式或 WaitFor 期间连同队列一起注入),空闲时直接发送。“排队”指:忙时一定排队,Tower 模式和 WaitFor 期间也一样,空闲时直接发送;这样排进去的消息不会被 Tower / WaitFor 自动注入,Ctrl-S 仍会把它一起注入。Ctrl-S 不变。
flowchart TD K[Enter / Ctrl-Enter / Cmd-Enter / Ctrl-Q] --> T{偏好 × 按键} T -- default --> D[今天的 Enter 路径] T -- queue --> H[忙时排队,等回合结束] T -- steer-draft --> C{现在能注入吗} C -- 能 --> S[只注入这一条,队列原样保留] C -- 不能 --> D S -- 注入失败 --> Q[放回队列原位置并报错]“不能注入”包括:空闲、
!shell 命令在跑、正在压缩、消息被暂缓、上一条注入还没完成、bash 模式输入、内置斜杠命令。这些情况下按键效果和今天的 Enter 一样,不会吞掉消息。\x1b\r,今天会插入换行,绑定它会破坏现有用法/settings和/help才提到 Ctrl-Enter;文档不写/compact或模型切换时按 steer 键tui.toml# follow_up_behavior = "queue" # "queue" | "steer"阅读指南
apps/kimi-code/src/tui/config.ts:偏好的解析、渲染,以及“偏好 × 按键 → 投递方式”的表。components/editor/custom-editor.ts:把 Ctrl-Enter、Cmd-Enter、Ctrl-Q 当作提交,并记下提交键。controllers/editor-keyboard.ts:提交时查表。kimi-tui.ts的trySteerDraft和sendMessage:注入一条草稿,失败时放回队列原位置;queue投递把消息标成holdUntilTurnEnds,Tower / WaitFor 的自动注入会跳过它。commands/config.ts、dialogs/follow-up-behavior-selector.ts、dialogs/help-panel.ts:/settings入口和帮助面板。steerMessage的回调从布尔值改成三态(steered/failed/restored),现有调用方的分支不变。可以略读:dispatch.ts和各发送方法的参数透传、文档、测试。Screenshots / Recordings
以下文本快照来自本分支在支持 kitty 键盘协议的终端里的真实运行。终端认不出 Ctrl-Enter 时,选择器的 Queue 只写前半句,Steer 写
Ctrl-Q queues one.,/help不显示 Ctrl-Enter 这一行。/settings第 2 页新增的一项:选中后打开的选择器:
切到 Steer 之后,
tui.toml写入:/help中相关的几行(Queue,默认):/help中相关的几行(Steer):Behavior Changes and Affected Users
queue时的 Enter;任何偏好下的 Ctrl-Stui.toml被 TUI 重写时/settings选过之后写真实值tui.toml的用户会看到新行tui.toml写了非法值queue处理/settings列表/help快捷键已知限制:引擎要等消息真正注入后才确认 steer(#4630 起如此)。所以在一次很长的工具调用期间,
steer下第一次 Enter 会注入,之后的 Enter 退回排队,直到第一条被 Agent 接收。同一窗口内 Ctrl-S 也不起作用,这是 main 上的现有行为。测试覆盖:
test/tui/config.test.ts:解析、注释行与真实值的渲染、非法值告警。test/tui/commands/follow-up-preferences.test.ts:/settings保存、未变化时不重写、保存失败、选择器文案随终端能力变化。test/tui/components/editor/custom-editor.test.ts、test/tui/controllers/editor-keyboard.test.ts:三个键都能提交,并保留 Enter 的特殊情况(补全、\续行、粘贴中的 Enter)。test/tui/kimi-tui-message-flow.test.ts:只注入草稿、各种退回、失败放回队列、Tower 下不带走已有队列、Tower 下 Ctrl-Q 一定排队、/help行随偏好和终端能力变化。test/tui/components/panels/help-panel.test.ts、test/tui/commands/reload.test.ts:帮助面板各组合、/reload读取新值。验证
pnpm exec vitest run test/tui:173 个文件、3785 个测试全部通过;每个 commit 各自单独通过 typecheck 和该 commit 改到的测试。新增的 Tower 排队测试做过反向验证:去掉修复后 5 条变红。queue下 Enter 排队、Ctrl-Enter 只注入草稿并在同一轮次被读到、Ctrl-Q 排队;/settings切到 Steer 后写入follow_up_behavior = "steer" # "queue" | "steer",Enter 只注入这一条,Ctrl-Enter / Ctrl-Q 排队,/help描述随之变化。这次运行早于 Tower / WaitFor 强制排队的 commit,强制排队只有单测覆盖。tui.toml后启动 TUI,重新生成的文件里是注释行# follow_up_behavior = "queue" # "queue" | "steer";默认设置下/help列出 Enter、Ctrl-Enter、Ctrl-Q 三行(见上方快照)。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.