Skip to content

Commit bc08c18

Browse files
arhxamclaude
andcommitted
fix(server): fall back to a Cursor todo's title when its content is blank
`extractTodosAsPlan` derives each plan step with `todo.content?.trim() ?? todo.title?.trim() ?? ""`. Because `??` only falls back on null/undefined, a todo whose `content` is present but empty or whitespace (`""` / `" "`) keeps the empty string and never falls back to the `title`, so a real step is dropped by the `if (step === "") return []` guard below. Both `content` and `title` are optional in `CursorTodo`, so a blank-content-with-title todo is a valid payload. Use `||` so a blank content falls back to the title, matching the evident intent (and the trailing `|| ""` default). A missing/blank content with no title still yields "" and is dropped as before. Added a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent e259dd2 commit bc08c18

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎apps/server/src/provider/acp/CursorAcpExtension.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ describe("CursorAcpExtension", () => {
107107
});
108108
});
109109

110+
it("falls back to the title when content is present but blank", () => {
111+
expect(
112+
extractTodosAsPlan({
113+
toolCallId: "todos-2",
114+
todos: [
115+
{ id: "1", content: "", title: "Titled step", status: "pending" },
116+
{ id: "2", content: " ", title: "Whitespace content", status: "in_progress" },
117+
{ id: "3", content: "", title: "", status: "pending" },
118+
],
119+
merge: true,
120+
}),
121+
).toEqual({
122+
plan: [
123+
{ step: "Titled step", status: "pending" },
124+
{ step: "Whitespace content", status: "inProgress" },
125+
],
126+
});
127+
});
128+
110129
it("decodes Cursor list_available_models responses with per-model config options", () => {
111130
const decoded = CursorListAvailableModelsResponse.make({
112131
models: [

‎apps/server/src/provider/acp/CursorAcpExtension.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ export function extractTodosAsPlan(params: typeof CursorUpdateTodosRequest.Type)
9494
}>;
9595
} {
9696
const plan = params.todos.flatMap((todo) => {
97-
const step = todo.content?.trim() ?? todo.title?.trim() ?? "";
97+
// Fall back to the title when content is missing OR blank. `??` only
98+
// covers a missing content, so a present-but-empty content ("" or
99+
// whitespace) would shadow a real title and drop the step below.
100+
const step = todo.content?.trim() || todo.title?.trim() || "";
98101
if (step === "") {
99102
return [];
100103
}

0 commit comments

Comments
 (0)