Skip to content

Commit 4a2e675

Browse files
committed
fix(webview): post condenseTaskContextResponse on condense failure
What: the condenseTaskContextRequest catch now also posts {type: 'condenseTaskContextResponse', text: taskId} after logging and showing the error. Why: ClineProvider.condenseTaskContext throws before its success-only response post when taskRegistry.getById finds no task (request racing task removal), and task.condenseContext failures reject the same way. ChatView only clears isCondensing/sendingDisabled from the response message, so the stuck state persisted (CodeRabbit 4172972739). Impact: failure responses carry the same shape as the success path, so the webview state always settles. Pin: rejection now asserts the response post alongside the log and the visible error.
1 parent ebd2c53 commit 4a2e675

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/core/webview/__tests__/webviewMessageHandler.spec.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,8 +2337,8 @@ describe("webviewMessageHandler - chat message queue", () => {
23372337
expect(updateSpy).toHaveBeenCalledWith(added.id, "edited", ["data:image/png;base64,from-mention"])
23382338
})
23392339

2340-
it("logs and shows a visible error when condenseTaskContext rejects", async () => {
2341-
const condenseError = new Error("queued submission failed")
2340+
it("logs, shows an error, and still posts the response when condenseTaskContext rejects", async () => {
2341+
const condenseError = new Error("Task with id task-1 not found in stack")
23422342
const providerWithCondense = mockClineProvider as unknown as {
23432343
condenseTaskContext: ReturnType<typeof vi.fn>
23442344
}
@@ -2349,8 +2349,14 @@ describe("webviewMessageHandler - chat message queue", () => {
23492349
).resolves.toBeUndefined()
23502350

23512351
expect(mockClineProvider.log).toHaveBeenCalledWith(
2352-
"[condenseTaskContextRequest] Failed: queued submission failed",
2352+
"[condenseTaskContextRequest] Failed: Task with id task-1 not found in stack",
23532353
)
23542354
expect(vscode.window.showErrorMessage).toHaveBeenCalledWith("common:errors.condense_failed")
2355+
// The response must still reach the webview so ChatView clears
2356+
// isCondensing/sendingDisabled when the task vanished mid-request.
2357+
expect(mockClineProvider.postMessageToWebview).toHaveBeenCalledWith({
2358+
type: "condenseTaskContextResponse",
2359+
text: "task-1",
2360+
})
23552361
})
23562362
})

‎src/core/webview/webviewMessageHandler.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,11 @@ export const webviewMessageHandler = async (
927927
`[condenseTaskContextRequest] Failed: ${error instanceof Error ? error.message : String(error)}`,
928928
)
929929
await vscode.window.showErrorMessage(t("common:errors.condense_failed"))
930+
// Post the response even on failure: a request racing task removal
931+
// (or a failed condense) must still clear ChatView's
932+
// isCondensing/sendingDisabled, which only the response message
933+
// releases. The shape matches the success path.
934+
await provider.postMessageToWebview({ type: "condenseTaskContextResponse", text: message.text! })
930935
}
931936
break
932937
case "deleteTaskWithId":

0 commit comments

Comments
 (0)