MoonshotAI / MoonshotAI/kimi-code
[Feature Request] 提交后收到回复前按 Esc 应还原输入框,而非留下 "Interrupted by user"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
问题
在 TUI 里提交一条消息后,如果 LLM 服务端还没开始往界面吐内容(即"等待回复"阶段)时按下 Esc,当前行为是:中断这次请求 + 留下一行红色的 Interrupted by user,而且我刚才提交的文字就没了。
期望行为:在这个"界面还没有显示任何新内容"的窗口期内按 Esc,应当 停止请求,并把刚才提交的那段话还原回输入框,方便改一改重新发送;而不是把消息吞掉、留下一个中断标记。
复现步骤
- 启动
kimi。 - 输入一段 prompt,回车提交。
- 在界面出现任何 assistant 输出之前(waiting 阶段)按 Esc。
实际行为
- 当前 turn 被中断。
- 显示红色
Interrupted by user。 - 刚才提交的 prompt 丢失,没有还原到输入框。
期望行为
- 当前 turn 被中断。
- 由于还没有任何 assistant 内容渲染出来,把原始 prompt 还原回输入框(可编辑、可直接重发)。
- 不再显示
Interrupted by user(或改为更轻量、不抢眼的提示)。
相关代码
- Esc 处理:
apps/kimi-code/src/tui/controllers/editor-keyboard.ts的editor.onEscape,在appState.streamingPhase !== 'idle'时调用cancelCurrentStream()。 - 红色提示来源:
apps/kimi-code/src/tui/controllers/session-event-handler.ts的handleStepInterrupted,对reason === 'aborted'且无 message 的情况执行showStatus('Interrupted by user', 'error')。 streamingPhase取值为'idle' | 'waiting' | 'thinking' | 'composing' | 'shell'(apps/kimi-code/src/tui/types.ts);"还没显示新内容"的窗口大致对应waiting(是否包含thinking取决于是否把思考指示也算作"已显示内容")。- 还原输入的 API 已存在:
host.restoreInputText(text),slash-command 流程已在用(见apps/kimi-code/src/tui/commands/swarm.ts)。
关键区分点是 "是否已有 assistant 内容渲染" —— 可通过 streamingPhase 处于 waiting/thinking 且尚未收到首个 assistant 文本/thinking delta 来判定。
备注
- 这与"流式输出到一半再中断"不同:那种情况下 assistant 已经产出内容,保留
Interrupted by user且不还原输入是合理的。 - 实现上可能需要:提交后保留最近一次 prompt,直到收到首个 delta 后才丢弃,以便在 pre-response 窗口中断时能还原。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/kimi-code/src/tui/controllers/editor-keyboard.ts at editor.onEscape and trace cancelCurrentStream into session-event-handler.ts and handleStepInterrupted. Check streamingPhase in apps/kimi-code/src/tui/types.ts and the existing host.restoreInputText usage in apps/kimi-code/src/tui/commands/swarm.ts. Done means an interrupted waiting-phase request restores the submitted prompt without the error status, while interruptions after assistant output retain the existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100