Skip to content

Commit 9a921cf

Browse files
authored
Merge branch 'main' into pr/b17-provider-cost-v2
2 parents 59fcd0e + 4c42f91 commit 9a921cf

123 files changed

Lines changed: 2224 additions & 858 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This file provides guidance to agents when working with code in this repository.
44

55
- Settings View Pattern: When working on `SettingsView`, inputs must bind to the local `cachedState`, NOT the live `useExtensionState()`. The `cachedState` acts as a buffer for user edits, isolating them from the `ContextProxy` source-of-truth until the user explicitly clicks "Save". Wiring inputs directly to the live state causes race conditions.
66
- Changesets: Do NOT create `.changeset` files for each commit or code change. Changesets are managed separately by maintainers and should not be generated by agents during normal development.
7+
- CHANGELOG: Do NOT update `CHANGELOG.md` or `src/CHANGELOG.md` in individual PRs. CHANGELOG entries are added in bulk during release preparation PRs.
78

89
## ESLint Suppressions
910

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"fixtures": [
3+
{
4+
"match": {
5+
"userMessage": "RESUME_EVICTION_RACE_SMOKE"
6+
},
7+
"response": {
8+
"toolCalls": [
9+
{
10+
"name": "attempt_completion",
11+
"arguments": "{\"result\":\"Resume eviction smoke completed.\"}",
12+
"id": "call_resume_eviction_001"
13+
}
14+
]
15+
}
16+
}
17+
]
18+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import * as assert from "assert"
2+
3+
import { setDefaultSuiteTimeout } from "./test-utils"
4+
import { waitUntilCompleted, waitFor } from "./utils"
5+
6+
// Regression test for the "Work #1 (no message)" title-clobber bug reported
7+
// against Zoo Code v3.76.0 (Discord, 2026-08-06).
8+
//
9+
// Root cause: Task#resumeTaskFromHistory() is started fire-and-forget by
10+
// scheduleTask() after createTaskWithHistoryItem() adds the task to the
11+
// registry, so `clineMessages` is [] until the first disk read resolves.
12+
// ClineProvider#evictCurrentTask() (called by clearCurrentTask / the
13+
// Back-to-parent / Go-to-subtask buttons) calls abortTask(), which calls
14+
// saveClineMessages() → taskMetadata() while the array is still empty.
15+
// taskMetadata() then persists the "no_messages" placeholder title,
16+
// permanently clobbering the real title in the history store.
17+
//
18+
// The test exercises the race by:
19+
// 1. Running a task to completion so a real title is persisted.
20+
// 2. Starting resumeTask() (same path as showTaskWithId) without awaiting it.
21+
// 3. Polling until the task appears on the stack, then immediately evicting —
22+
// the task is on the stack but its message load is still in flight.
23+
// 4. Asserting the stored title still matches the original.
24+
//
25+
// NOTE: Because the extension host reads task messages from disk in the same
26+
// process as this test, the I/O window is very tight (< 1ms on local disk).
27+
// The race is not reliably triggerable from the e2e layer; the canonical
28+
// regression anchor is the unit test in
29+
// src/core/task/__tests__/Task.resume-eviction-race.spec.ts, which controls
30+
// the timing via a deferred promise. This e2e test serves as a smoke test that
31+
// the resume-then-evict flow does not blow up and that the stored title is
32+
// correct after a round-trip.
33+
suite("Resume eviction race (title clobber regression)", function () {
34+
setDefaultSuiteTimeout(this)
35+
36+
test("evicting a mid-resume task does not overwrite its stored title", async () => {
37+
const api = globalThis.api
38+
39+
const ORIGINAL_TITLE =
40+
"RESUME_EVICTION_RACE_SMOKE: complete immediately with 'Resume eviction smoke completed.'"
41+
42+
// Step 1 — run a task to completion so a real title is persisted.
43+
const taskId = await waitUntilCompleted({
44+
api,
45+
start: () =>
46+
api.startNewTask({
47+
configuration: {
48+
mode: "ask",
49+
autoApprovalEnabled: true,
50+
enableCheckpoints: false,
51+
},
52+
text: ORIGINAL_TITLE,
53+
}),
54+
})
55+
56+
const beforeResume = await api.getTaskHistoryItem(taskId)
57+
assert.ok(beforeResume, "Task should be in history after completion")
58+
assert.ok(
59+
beforeResume.task?.includes("RESUME_EVICTION_RACE_SMOKE"),
60+
`Persisted title before resume should contain the prompt marker (got "${beforeResume.task}")`,
61+
)
62+
63+
// Drain the stack so we start clean.
64+
while (api.getCurrentTaskStack().length > 0) {
65+
await api.clearCurrentTask()
66+
}
67+
68+
// Step 2 — fire resumeTask() without awaiting it. resumeTask() calls
69+
// createTaskWithHistoryItem() which adds the task to the registry and
70+
// calls scheduleTask() (fire-and-forget). The task's run() and
71+
// resumeTaskFromHistory() start in the background.
72+
const resumePromise = api.resumeTask(taskId)
73+
74+
// Step 3 — wait only until the task appears on the stack (i.e.
75+
// createTaskWithHistoryItem has returned and addClineToStack has run),
76+
// then immediately evict. This minimises the gap between the eviction
77+
// and the in-flight message load, giving the best chance of hitting the
78+
// race window before readTaskMessages() resolves.
79+
await waitFor(() => api.getCurrentTaskStack().includes(taskId))
80+
await api.clearCurrentTask()
81+
82+
// Let the resume settle.
83+
await resumePromise.catch(() => {})
84+
85+
// Step 4 — the stored title must still be the real one.
86+
const afterEviction = await api.getTaskHistoryItem(taskId)
87+
assert.ok(afterEviction, "Task should still be in history after eviction")
88+
89+
// Before the fix this would be "Task #N (No messages)" / "工作 #N (無訊息)".
90+
assert.strictEqual(
91+
afterEviction.task,
92+
beforeResume.task,
93+
`Title must not change during resume eviction. Got: "${afterEviction.task}"`,
94+
)
95+
})
96+
})

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"esbuild": "0.28.1",
6060
"rollup": "4.60.4",
6161
"vite": "8.1.0",
62-
"undici": "6.27.0",
62+
"undici": "6.28.0",
6363
"form-data": ">=4.0.4",
6464
"bluebird": ">=3.7.2",
6565
"glob": "11.1.0",

‎packages/types/src/tool.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const toolNames = [
4646
"skill",
4747
"generate_image",
4848
"custom_tool",
49+
"invalid_tool_call",
4950
] as const
5051

5152
export const toolNamesSchema = z.enum(toolNames)

0 commit comments

Comments
 (0)