Skip to content

Commit 0f2c282

Browse files
committed
test(dte-5): cover the remaining partial branches to reach 100% patch coverage
- NewTaskTool: add the disable-only capability case so the empty support-list error hint (...none) is exercised. - ClineProvider: add a non-Error say rejection case so the String(error) fallback in the non-fatal catch is exercised. - ChatView: drop the unreachable ?? fallback on the effort select value; the prefill invariant guarantees the value is defined whenever the selector renders, so the rendered and posted values agree by construction.
1 parent fea97fd commit 0f2c282

3 files changed

Lines changed: 71 additions & 2 deletions

File tree

‎src/__tests__/provider-delegation.spec.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,56 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
583583
expect(childRun).toHaveBeenCalledTimes(1)
584584
})
585585

586+
it("stringifies a non-Error say rejection in the non-fatal log (DTE series 5/5)", async () => {
587+
const parentTask = makeParentTask()
588+
const setRuntimeThinkingEffort = vi.fn()
589+
// A non-Error rejection (e.g. a raw string from the webview messaging
590+
// layer): the catch must not assume an Error shape, where error.message
591+
// would be undefined and the log line would read 'undefined'.
592+
const say = vi.fn().mockRejectedValue("webview gone")
593+
const childRun = vi.fn().mockResolvedValue(undefined)
594+
const createTask = vi.fn().mockResolvedValue({
595+
taskId: "child-1",
596+
start: vi.fn(),
597+
run: childRun,
598+
setRuntimeThinkingEffort,
599+
say,
600+
api: { getModel: () => ({ id: "child-model", info: { supportsReasoningEffort: ["low", "high"] } }) },
601+
})
602+
const taskHistoryStore = makeStoreStub()
603+
const providerLog = vi.fn()
604+
605+
const provider = {
606+
taskScheduler: new TaskScheduler(),
607+
emit: vi.fn(),
608+
getCurrentTask: vi.fn(() => parentTask),
609+
removeClineFromStack: vi.fn().mockResolvedValue(undefined),
610+
createTask,
611+
handleModeSwitch: vi.fn().mockResolvedValue(undefined),
612+
log: providerLog,
613+
isViewLaunched: false,
614+
recentTasksCache: undefined,
615+
taskHistoryStore,
616+
} as unknown as ClineProvider
617+
618+
// Must NOT reject: the failing notification is non-fatal.
619+
await ClineProvider.prototype.delegateParentAndOpenChild.call(provider, {
620+
parentTaskId: "parent-1",
621+
message: "Do something",
622+
initialTodos: [],
623+
mode: "code",
624+
thinkingEffort: "xhigh",
625+
})
626+
await Promise.resolve()
627+
628+
// The non-Error rejection is stringified into the log (the Error-instance
629+
// arm is covered by the disposed-parent test above).
630+
expect(providerLog).toHaveBeenCalledWith(expect.stringContaining("non-fatal"))
631+
expect(providerLog).toHaveBeenCalledWith(expect.stringContaining("webview gone"))
632+
// Delegation still proceeds: the child runs.
633+
expect(childRun).toHaveBeenCalledTimes(1)
634+
})
635+
586636
it("applies the effort when the child model (post mode switch) has a boolean-true capability (DTE series 5/5)", async () => {
587637
const parentTask = makeParentTask()
588638
const setRuntimeThinkingEffort = vi.fn()

‎src/core/tools/__tests__/newTaskThinkingEffort.spec.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,23 @@ describe("new_task thinking_effort validation (DTE series 5/5)", () => {
220220
expect(delegateParentAndOpenChild).not.toHaveBeenCalled()
221221
})
222222

223+
it("reports 'none' when the target model's only capability is 'disable' (DTE series 5/5)", async () => {
224+
const { task, delegateParentAndOpenChild } = makeTask({
225+
supportsReasoningEffort: ["disable"],
226+
})
227+
const callbacks = makeCallbacks()
228+
229+
await runNewTask(task, { thinking_effort: "low" }, callbacks)
230+
231+
// 'disable' is a settings off-switch, never a start level: it is filtered
232+
// from the error hint, leaving an empty list — the message falls back to
233+
// 'none' instead of trailing a dangling colon.
234+
expect(callbacks.pushToolResult).toHaveBeenCalledWith(
235+
expect.stringContaining("the target model only supports: none"),
236+
)
237+
expect(delegateParentAndOpenChild).not.toHaveBeenCalled()
238+
})
239+
223240
it("rejects an effort when the target model exposes no capability array", async () => {
224241
const { task, delegateParentAndOpenChild } = makeTask({
225242
supportsReasoningEffort: undefined,

‎webview-ui/src/components/chat/ChatView.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,8 +1833,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18331833
aria-label={t("settings:providers.reasoningEffort.label")}
18341834
data-testid="new-task-effort-select"
18351835
// The prefill normalizes newTaskAskEffort to a supported level (see the
1836-
// newTask branch of the ask handler), so rendered and posted values agree.
1837-
value={newTaskAskEffort ?? newTaskAskSupportedEfforts[0]}
1836+
// newTask branch of the ask handler) and every other ask clears it together
1837+
// with the supported list, so the value is defined whenever the selector
1838+
// renders — rendered and posted values agree by construction.
1839+
value={newTaskAskEffort}
18381840
onChange={(event) =>
18391841
// The select only offers model-supported levels (rendered below), so the
18401842
// raw value is a ReasoningEffortExtended.

0 commit comments

Comments
 (0)