MoonshotAI / MoonshotAI/kimi-code
[VSCode] 侧边栏的 New Conversation 会清空所有 Kimi 的对话,包括编辑器标签页里正在进行的对话
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What version of Kimi Code is running?
VS Code 扩展 0.7.0(VS Code 1.133.0)
Which open platform/subscription were you using?
managed:kimi-code(OAuth 托管)
Which model were you using?
kimi-code/k3
What platform is your computer?
Darwin 25.5.0 arm64 arm
What issue are you seeing?
点击侧边栏标题栏的 +(New Conversation)时,不只是侧边栏被重置 —— 所有打开着的 Kimi 对话窗口都会被清空,包括在编辑器标签页里的那些;如果某个窗口正在流式输出内容的话,那一轮也会被停掉。
每个 Kimi 视图持有各自独立的 session 和工作目录(BridgeHandler 按 webviewId 分别管理),所以"一次点击重置全部"没有语义依据。
(动图里是 1 个侧边栏 + 2 个标签页,各自有独立的对话;点一次侧边栏标题栏的 +,三个全部被清空。)
根因:这个命令自己前后两行是矛盾的(apps/vscode/src/extension.ts:116-119):
"kimi.newConversation": async () => {
await vscode.commands.executeCommand("kimi.webview.focus"); // ① 只作用于侧边栏视图
provider?.broadcast(Events.NewConversation, {}); // ② 广播给所有 webview
},
第 ① 行无条件 reveal 并聚焦 kimi.webview —— 那是侧边栏视图专属的、由 VS Code 自动生成的命令,等于代码自己声明"我是侧边栏的动作"。第 ② 行却把事件发给每一个已注册的 webview。一个命令不可能既是侧边栏专属又是全局的。
三条佐证:
- 定向能力是有现成的,而且旁边就在用。
broadcastInternal(KimiWebviewProvider.ts:112)第三个参数就是用来定向的,insertEditorMention(KimiWebviewProvider.ts:84-95)正在逐webviewId使用它。公开的broadcast(:80)不传这个参数,所以就出现"发给所有人"的行为。 - 同一功能的另一个入口行为不同。 webview 内部的 Cmd/Ctrl+N(
webview-ui/src/App.tsx:53-65)以及 Header 里的+按钮都只影响自己所在的那个视图。同一个"新建对话",两条路径行为不一致。 - 群发的几个命令里只有它是破坏性的。
kimi.focusInput(extension.ts:101-104)与它逐行同构、也是群发,但群发只是让每个视图的输入框都聚焦一下,无害;配置变更广播同理。只有NewConversation会使窗口丢状态。
What steps can reproduce the bug?
- 打开 Kimi 侧边栏,发一条消息(让对话区有可见内容)
- 在侧边栏标题栏点 ↗(
Kimi Code: Open in New Tab),在新开的标签页里也发一条消息 - 回到侧边栏,点标题栏的
+(New Conversation)
—— 注意点的是 VS Code 侧边栏标题栏上那个+(view/title贡献的),不是 kimi对话窗口内部 History 旁边那个 - 标签页里的对话也被清空了;如果它正在输出,那一轮对话就会被中断
从命令面板执行 Kimi Code: New Conversation 是同一条路径,效果相同。
What is the expected behavior?
只有侧边栏视图被重置,编辑器标签页保留自己的对话和正在进行的回合。
kimi对话窗口内部那个 + 和 Cmd/Ctrl+N 已经是这个行为,命令这条路径应该和它一致。
Additional information
- 不是回归。 这段代码随 #1769(扩展迁移到 Node SDK)一次性进入仓库,此后每个发布版本都有;
git blame显示它没有任何注释,而这个仓库对刻意的、反直觉的决策一贯是写注释解释的。 - 只有在同时打开 2 个及以上 Kimi 对话窗口时会出现——只用左侧边栏时,"发给所有人"和"发给侧边栏"结果相同,所以日常开发不容易撞见。
- 修复已备好(改
KimiWebviewProvider记录侧边栏的webviewId并定向投递,加了 4 个单元测试和 changeset),PR 随后提交。
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 with the kimi.newConversation command in apps/vscode/src/extension.ts:116-119 and the webview registration and broadcast logic in apps/vscode/src/KimiWebviewProvider.ts. Compare this path with insertEditorMention and the New Conversation handling in webview-ui/src/App.tsx, then run the mentioned unit tests. Done means the sidebar resets while editor-tab conversations and active output remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100