diff --git a/.changeset/vscode-busy-error-message.md b/.changeset/vscode-busy-error-message.md new file mode 100644 index 0000000000..b361b449cb --- /dev/null +++ b/.changeset/vscode-busy-error-message.md @@ -0,0 +1,5 @@ +--- +"kimi-code": patch +--- + +Stop reporting a busy chat session as "Internal error occurred." A prompt sent while a response is still being generated now surfaces as "A message is being sent. Please wait." (code `turn.agent_busy`) with the original detail attached, instead of the generic internal-error message that the plain `Error` was mapped to. diff --git a/apps/vscode/src/runtime/session-runtime.ts b/apps/vscode/src/runtime/session-runtime.ts index a3bd2b4615..4b1db8ff36 100644 --- a/apps/vscode/src/runtime/session-runtime.ts +++ b/apps/vscode/src/runtime/session-runtime.ts @@ -1,5 +1,6 @@ import { isKimiError, + KimiError, type ContentPart as SdkContentPart, type Event, type PromptInput, @@ -188,7 +189,7 @@ export class SessionRuntime { // such terminal event, so reject terminally: the caller's composer must // unlock rather than hang until the handshake timeout. this.emitError( - new Error(ALREADY_GENERATING_MESSAGE), + new KimiError("turn.agent_busy", ALREADY_GENERATING_MESSAGE), "runtime", { terminal: this.hasActiveWork ? false : undefined }, ); @@ -225,7 +226,7 @@ export class SessionRuntime { beginHostAction(input: string | LegacyContentPart[], forkable = false): number { this.ensureOpen(); if (this.isBusy) { - throw new Error(ALREADY_GENERATING_MESSAGE); + throw new KimiError("turn.agent_busy", ALREADY_GENERATING_MESSAGE); } const actionId = ++this.hostActionSequence; this.hostActionActive = true; diff --git a/apps/vscode/test/kimi-runtime.test.ts b/apps/vscode/test/kimi-runtime.test.ts index 6a86f7f2d1..a5cfdc856e 100644 --- a/apps/vscode/test/kimi-runtime.test.ts +++ b/apps/vscode/test/kimi-runtime.test.ts @@ -599,6 +599,8 @@ describe("Kimi runtime (owns shared SDK sessions for Webviews)", () => { const busyWarning = broadcasts.find(({ data }) => (data as { type?: string }).type === "error"); expect(busyWarning?.data).toMatchObject({ type: "error", + code: "turn.agent_busy", + message: "A message is being sent. Please wait.", phase: "runtime", detail: "A response is already being generated for this session.", terminal: false, diff --git a/apps/vscode/test/settings-store.test.ts b/apps/vscode/test/settings-store.test.ts index 93d0decad8..b26590a29e 100644 --- a/apps/vscode/test/settings-store.test.ts +++ b/apps/vscode/test/settings-store.test.ts @@ -426,15 +426,15 @@ describe("Webview mid-turn warnings", () => { useChatStore.getState().processEvent({ type: "error", - code: "internal", - message: "Internal error occurred.", + code: "turn.agent_busy", + message: "A message is being sent. Please wait.", detail: "A response is already being generated for this session.", phase: "runtime", terminal: false, }); // The turn is still running: nothing unlocks, nothing flushes, nothing is retried. - expect(boundary.toastWarning).toHaveBeenCalledWith("Internal error occurred."); + expect(boundary.toastWarning).toHaveBeenCalledWith("A message is being sent. Please wait."); const state = useChatStore.getState(); expect(state.isStreaming).toBe(true); expect(state.queue).toHaveLength(1);