Skip to content

Commit d85caff

Browse files
Fix streamed plan presentation
Generated-By: PostHog Code Task-Id: 40c57a59-b4e1-4760-8e56-ecd03e9c2f0f
1 parent fb10f81 commit d85caff

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/core/src/sessions/planApprovalPresentation.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ describe("extractPlanText", () => {
1818
expect(extractPlanText(toolCall)).toBe(expected);
1919
});
2020

21-
it("prefers the canonical raw plan over rendered content", () => {
21+
it("prefers updated streamed content over the initial raw plan", () => {
2222
expect(
2323
extractPlanText({
24-
rawInput: { plan: "Canonical" },
25-
content: [{ text: "Rendered" }],
24+
rawInput: { plan: "Initial" },
25+
content: [{ text: "Updated" }],
2626
}),
27-
).toBe("Canonical");
27+
).toBe("Updated");
2828
});
2929
});

packages/core/src/sessions/planApprovalPresentation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export function extractPlanText(toolCall: {
1212
rawInput?: { plan?: unknown } | null;
1313
content?: readonly unknown[] | null;
1414
}): string | null {
15-
const rawPlan = toolCall.rawInput?.plan;
16-
if (typeof rawPlan === "string" && rawPlan.trim()) return rawPlan;
17-
1815
for (const item of toolCall.content ?? []) {
1916
const text = extractTextContent(item);
2017
if (text?.trim()) return text;
2118
}
19+
20+
const rawPlan = toolCall.rawInput?.plan;
21+
if (typeof rawPlan === "string" && rawPlan.trim()) return rawPlan;
2222
return null;
2323
}

0 commit comments

Comments
 (0)