Skip to content

Commit 94f0925

Browse files
fix(tests): write the specs against the surface main actually declares
Two adaptations, tests only, no production hunk moved: - presentAssistantMessage-missing-native-args.spec.ts: the fixture set presentAssistantMessageLocked / presentAssistantMessageHasPendingUpdates, which main renamed to dispatchState / pendingWork (src/core/task/dispatchState.ts:1-7 defines the enum, the PendingWork type and transitionDispatch); the double now sets dispatchState: DispatchState.IDLE and pendingWork: null like main's own presentAssistantMessage specs. - Task.spec.ts: two 'task.abort = true' assignments on a real new Task({...}) became 'void task.abortTask()'. Task.ts:3582 declares 'get abort(): boolean' over the run-state latch and src/ carries no 'set abort(' declaration; Task.ts:3633 declares 'public abortTask(isAbandoned = false): Promise<void>', whose first statement is the synchronous requestAbort(), so the latch is set at the same point in the stream and the promise is the shared one rather than a floating call. Main's own Task.spec.ts carries 18 abortTask()/requestAbort( rows and assigns .abort only on doubles.
1 parent c0fba32 commit 94f0925

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎src/core/assistant-message/__tests__/presentAssistantMessage-missing-native-args.spec.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { describe, it, expect, beforeEach, vi } from "vitest"
44
import { presentAssistantMessage } from "../presentAssistantMessage"
5+
import { DispatchState } from "../../task/dispatchState"
56
import { type RequestPolicySnapshot } from "../../prompts/tools/effective-tool-policy"
67
import { isValidToolName, validateToolUse } from "../../tools/validateToolUse"
78

@@ -50,8 +51,10 @@ describe("presentAssistantMessage - finalized block without nativeArgs", () => {
5051
taskId: "test-task-id",
5152
instanceId: "test-instance",
5253
abort: false,
53-
presentAssistantMessageLocked: false,
54-
presentAssistantMessageHasPendingUpdates: false,
54+
// main renamed the dispatcher fields (src/core/task/dispatchState.ts): the presenter reads
55+
// dispatchState and pendingWork, not the old lock/flag pair.
56+
dispatchState: DispatchState.IDLE,
57+
pendingWork: null,
5558
currentStreamingContentIndex: 0,
5659
assistantMessageContent: [
5760
{

‎src/core/task/__tests__/Task.spec.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8043,7 +8043,9 @@ describe("Cline", () => {
80438043
// The streaming loop checks this.abort right after the presenter hands off a chunk, so the
80448044
// cancel lands mid-stream and reaches abortStream(-"user_cancelled") with the view open.
80458045
vi.spyOn(getTaskTestAccess(task), "presentAssistantMessageSafe").mockImplementation(() => {
8046-
task.abort = true
8046+
// Task.abort is a getter over the run-state latch; the method the tree declares is
8047+
// abortTask(), which latches the abort synchronously and returns the shared promise.
8048+
void task.abortTask()
80478049
})
80488050
vi.spyOn(task, "attemptApiRequest").mockImplementation(() =>
80498051
asyncStreamFrom<ApiStreamChunk>([{ type: "text", text: "partial model output" }]),
@@ -8075,7 +8077,9 @@ describe("Cline", () => {
80758077
vi.spyOn(task.diffViewProvider, "reset").mockResolvedValue(undefined)
80768078
vi.spyOn(getTaskTestAccess(task), "safeEnsureModelFetched").mockResolvedValue(stubModelInfo)
80778079
vi.spyOn(getTaskTestAccess(task), "presentAssistantMessageSafe").mockImplementation(() => {
8078-
task.abort = true
8080+
// Task.abort is a getter over the run-state latch; the method the tree declares is
8081+
// abortTask(), which latches the abort synchronously and returns the shared promise.
8082+
void task.abortTask()
80798083
})
80808084
vi.spyOn(task, "attemptApiRequest").mockImplementation(() =>
80818085
asyncStreamFrom<ApiStreamChunk>([{ type: "text", text: "partial model output" }]),

0 commit comments

Comments
 (0)