Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

TUI: rejected /new and /clear lose input after lazy session assembly

未关闭 适合新手
#4,225 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
60/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
cli

调研方向

从 apps/kimi-code/src/tui/commands/dispatch.ts 约第 383-399 行开始,该处 /new 和 /clear 在组装后的忙碌分支会显示错误并返回,而不恢复输入,将其与现有的 canRestoreSubmittedInput 守卫进行比较。通过编辑器路径(v2 引擎)运行 apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts 中的 blocks /new 用例。完成标准是:被拒绝的命令仅在编辑器仍为空且未打开任何面板时才返回编辑器,并且较新草稿和已打开面板的检查仍然通过。在维护者 /approve 之前,不要开启 PR。

由索引模型根据 Issue 内容生成。

描述

bug
What version of Kimi Code is running?

Source checkout f28c51c01f025bba9f0d0f58f6309e7517a8cd02; affected dispatch and test unchanged at main d4b9dc4a2d6ff72413964feda2563f0adf8e04d2

Which open platform/subscription were you using?

Not applicable: registered local TUI component tests, no provider request or login needed

Which model were you using?

No real model call; deferred test session

What platform is your computer?

Linux x86_64, Node.js 24.19.0, pnpm 10.33.0

What issue are you seeing?

If /new or /clear is submitted while first-use session creation is pending, the first prompt can start streaming before the command resumes. The command correctly reports "Cannot /new while streaming", but the editor stays empty instead of restoring the rejected input.

The synchronous busy gate and the delayed session-requiring-command branch already restore rejected input. The post-assembly busy branch for /new only shows the error and returns.

What steps can reproduce the bug?
  1. Start the TUI without an active session and submit a first prompt.
  2. While lazy session creation is pending, submit /new (or /clear).
  3. Let that session finish assembly and the first prompt start streaming.
  4. Observe the busy error and the empty editor.

Deterministic component reproduction: in the existing blocks /new while the waited-out first prompt starts a turn (v2 engine) case in apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts, keep its deferred harness.createSession setup but submit through the actual editor instead of calling driver.handleUserInput('/new') directly:

driver.state.editor.setText('/new');
driver.state.editor.handleInput('\r');
expect(driver.state.editor.getText()).toBe('');

resolveCreate(lazySession);
await vi.waitFor(() => {
  expect(lazySession.prompt).toHaveBeenCalledWith('hello', { promptId: undefined });
  expect(stripSgr(renderTranscript(driver))).toContain('Cannot /new while streaming');
  expect(driver.state.editor.getText()).toBe('/new'); // receives ''
});

The analogous /clear assertion also receives ''. These assertions exercise the submitted-input path that clears the editor; the existing direct-dispatch case does not check restoration.

What is the expected behavior?

Restore the rejected submitted command only if the editor is still empty and no replacement panel has opened. Preserve a newer user draft or an opened panel. The existing canRestoreSubmittedInput guard appears suitable.

Additional information

Executed the registered KimiTUI message-flow Vitest tests after building the workspace at f28c51c: /new and /clear restoration assertions failed; three controls passed (successful session replacement, newer editor draft, opened replacement panel). Five selected cases only; 359 others were filtered/unexecuted, not a full-suite pass. No production changes or real LLM calls.

Fresh source check: dispatch.ts, the existing message-flow test and CONTRIBUTING.md are unchanged at d4b9dc4. This is source continuity, not a new full-workspace test run.

Source: https://github.com/MoonshotAI/kimi-code/blob/f28c51c01f025bba9f0d0f58f6309e7517a8cd02/apps/kimi-code/src/tui/commands/dispatch.ts#L383-L399

Would you approve a small guarded input-restoration fix? I will wait for a maintainer /approve before opening a PR, as requested by CONTRIBUTING.

Contribution
  • I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
主要语言
TypeScript
星标
7.8k
派生
1.3k
平均合并
1 天 7 小时
30 天内合并 PR
117

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MoonshotAI/kimi-code 的其他 Issue

查看 MoonshotAI/kimi-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。