MoonshotAI / MoonshotAI/kimi-code

[Feature Request] 提交后收到回复前按 Esc 应还原输入框,而非留下 "Interrupted by user"

Open
#2,781 0 comments 0 reactions 0 assignees View on GitHub

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,应当 停止请求,并把刚才提交的那段话还原回输入框,方便改一改重新发送;而不是把消息吞掉、留下一个中断标记。

复现步骤

  1. 启动 kimi
  2. 输入一段 prompt,回车提交。
  3. 在界面出现任何 assistant 输出之前(waiting 阶段)按 Esc。

实际行为

  • 当前 turn 被中断。
  • 显示红色 Interrupted by user
  • 刚才提交的 prompt 丢失,没有还原到输入框。

期望行为

  • 当前 turn 被中断。
  • 由于还没有任何 assistant 内容渲染出来,把原始 prompt 还原回输入框(可编辑、可直接重发)。
  • 不再显示 Interrupted by user(或改为更轻量、不抢眼的提示)。

相关代码

  • Esc 处理:apps/kimi-code/src/tui/controllers/editor-keyboard.tseditor.onEscape,在 appState.streamingPhase !== 'idle' 时调用 cancelCurrentStream()
  • 红色提示来源:apps/kimi-code/src/tui/controllers/session-event-handler.tshandleStepInterrupted,对 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.