TUI: rejected /new and /clear lose input after lazy session assembly
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 60/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Bắt đầu tại apps/kimi-code/src/tui/commands/dispatch.ts quanh các dòng 383-399, nơi nhánh bận sau khi lắp ráp cho /new và /clear hiển thị lỗi rồi trả về mà không khôi phục đầu vào, và so sánh với guard canRestoreSubmittedInput hiện có. Chạy trường hợp blocks /new trong apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts (engine v2) qua đường dẫn editor. Hoàn thành khi lệnh bị từ chối chỉ quay lại editor nếu editor vẫn trống và không có panel nào được mở, đồng thời các kiểm tra cho bản nháp mới hơn và panel đã mở vẫn đạt. Chờ maintainer /approve trước khi mở PR.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Start the TUI without an active session and submit a first prompt.
- While lazy session creation is pending, submit /new (or /clear).
- Let that session finish assembly and the first prompt start streaming.
- 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.
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)
- Ngôn ngữ chính
- TypeScript
- Star
- 7.8k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 117
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MoonshotAI/kimi-code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
MoonshotAI/kimi-code#4177 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
MoonshotAI/kimi-code#4170 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
MoonshotAI/kimi-code#4147 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
MoonshotAI/kimi-code#4146 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
MoonshotAI/kimi-code#4141 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MoonshotAI/kimi-code
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
anomalyco/opencode#56380 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
BUG | `MCP 服务器` | 全局层行的停用/启用与删除报 404 server row not found,编辑保存会在 profile 层复制出重复行Có thể đã có người làm @w6242652 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Chocobozzz/PeerTube#7832 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Pay to use?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
darkreader/darkreader#16108 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày