fix(claude): emit plan events for TodoWrite during input streaming #1541
MergedTimCrooker(GitHub profile, opens in a new tab)merged 19 commits into
main fromrefs/pull/1541/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/web/src/session-logic.test.ts line 639Resolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -591,4 +615,20 @@591615 const entries = deriveWorkLogEntries(activities, undefined);592- expect(entries.map((entry) => entry.id)).toEqual(["task-progress"]);616+ expect(entries.map((entry) => entry.id)).toEqual(["task-progress", "task-complete"]);617+ });618+619+ it("uses payload summary as label for task entries when available", () => {620+ const activities: OrchestrationThreadActivity[] = [621+ makeActivity({622+ id: "task-progress-with-summary",623+ createdAt: "2026-02-23T00:00:02.000Z",624+ kind: "task.progress",625+ summary: "Reasoning update",626+ tone: "info",627+ payload: { summary: "Searching for API endpoints" },628+ }),629+ ];630+631+ const entries = deriveWorkLogEntries(activities, undefined);632+ expect(entries[0]?.label).toBe("Searching for API endpoints");593633 });594634apps/web/src/session-logic.ts line 503OutdatedResolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -492,8 +491,13 @@492491 const command = extractToolCommand(payload);493492 const changedFiles = extractChangedFiles(payload);494493 const title = extractToolTitle(payload);494+ const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";495+ const taskSummary =496+ isTaskActivity && typeof payload?.summary === "string" && payload.summary.length > 0497+ ? payload.summary498+ : null;495499 const entry: DerivedWorkLogEntry = {496500 id: activity.id,497501 createdAt: activity.createdAt,498- label: activity.summary,499- tone: activity.tone === "approval" ? "info" : activity.tone,502+ label: taskSummary ?? activity.summary,503+ tone: isTaskActivity ? "thinking" : activity.tone === "approval" ? "info" : activity.tone,apps/web/src/session-logic.ts lines 494 to 503OutdatedResolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -492,8 +491,13 @@492491 const command = extractToolCommand(payload);493492 const changedFiles = extractChangedFiles(payload);494493 const title = extractToolTitle(payload);494+ const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";495+ const taskSummary =496+ isTaskActivity && typeof payload?.summary === "string" && payload.summary.length > 0497+ ? payload.summary498+ : null;495499 const entry: DerivedWorkLogEntry = {496500 id: activity.id,497501 createdAt: activity.createdAt,498- label: activity.summary,499- tone: activity.tone === "approval" ? "info" : activity.tone,502+ label: taskSummary ?? activity.summary,503+ tone: isTaskActivity ? "thinking" : activity.tone === "approval" ? "info" : activity.tone,
- apps/web/src/session-logic.ts line 503OutdatedResolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -492,8 +491,13 @@492491 const command = extractToolCommand(payload);493492 const changedFiles = extractChangedFiles(payload);494493 const title = extractToolTitle(payload);494+ const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";495+ const taskSummary =496+ isTaskActivity && typeof payload?.summary === "string" && payload.summary.length > 0497+ ? payload.summary498+ : null;495499 const entry: DerivedWorkLogEntry = {496500 id: activity.id,497501 createdAt: activity.createdAt,498- label: activity.summary,499- tone: activity.tone === "approval" ? "info" : activity.tone,502+ label: taskSummary ?? activity.summary,503+ tone: isTaskActivity ? "thinking" : activity.tone === "approval" ? "info" : activity.tone,
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/ChatView.tsx line 1956OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1946,3 +1946,11 @@19461946 planSidebarDismissedForTurnRef.current = null;19471947 }, [activeThread?.id]);194819481949+ // Auto-open the plan sidebar when plan/todo steps arrive (unless user dismissed it for this turn).1950+ useEffect(() => {1951+ if (!activePlan) return;1952+ if (planSidebarOpen) return;1953+ const turnKey = activePlan.turnId;1954+ if (turnKey && planSidebarDismissedForTurnRef.current === turnKey) return;1955+ setPlanSidebarOpen(true);1956+ }, [activePlan, planSidebarOpen]);
- apps/web/src/components/ChatView.tsx line 1951OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1946,3 +1944,8 @@19461944 planSidebarDismissedForTurnRef.current = null;19471945 }, [activeThread?.id]);194819461947+ // Auto-open the plan sidebar when plan/todo steps arrive (unless user dismissed it for this turn).1948+ useEffect(() => {1949+ if (!activePlan) return;1950+ if (planSidebarOpen) return;1951+ const turnKey = activePlan.turnId ?? "__dismissed__";
- apps/web/src/components/ChatView.tsx line 1954OutdatedResolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -1946,3 +1944,11 @@19461944 planSidebarDismissedForTurnRef.current = null;19471945 }, [activeThread?.id]);194819461947+ // Auto-open the plan sidebar when plan/todo steps arrive (unless user dismissed it for this turn).1948+ useEffect(() => {1949+ if (!activePlan) return;1950+ if (planSidebarOpen) return;1951+ const turnKey = activePlan.turnId ?? sidebarProposedPlan?.turnId ?? "__dismissed__";1952+ if (planSidebarDismissedForTurnRef.current === turnKey) return;1953+ setPlanSidebarOpen(true);1954+ }, [activePlan, planSidebarOpen, sidebarProposedPlan?.turnId]);
TimCrooker(GitHub profile, opens in a new tab) closed this
TimCrooker(GitHub profile, opens in a new tab) reopened this
- apps/web/src/components/ChatView.tsx line 1110OutdatedResolvedby TimCrooker(GitHub profile, opens in a new tab)@@ -746,3 +746,4 @@746746 () => deriveActivePlanState(threadActivities, activeLatestTurn?.turnId ?? undefined),747747 [activeLatestTurn?.turnId, threadActivities],748748 );749+ const planSidebarLabel = sidebarProposedPlan || interactionMode === "plan" ? "Plan" : "Tasks";@@ -492,8 +491,18 @@492491 const command = extractToolCommand(payload);493492 const changedFiles = extractChangedFiles(payload);494493 const title = extractToolTitle(payload);494+ const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";495+ const taskLabel =496+ isTaskActivity &&497+ ((typeof payload?.summary === "string" && payload.summary.length > 0 && payload.summary) ||498+ (typeof payload?.detail === "string" && payload.detail.length > 0 && payload.detail));495499 const entry: DerivedWorkLogEntry = {496500 id: activity.id,497501 createdAt: activity.createdAt,498- label: activity.summary,499- tone: activity.tone === "approval" ? "info" : activity.tone,502+ label: taskLabel || activity.summary,503+ tone:504+ activity.kind === "task.progress"505+ ? "thinking"506+ : activity.tone === "approval"507+ ? "info"508+ : activity.tone,
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 480OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -462,3 +462,19 @@462462 : "dynamic_tool_call";463463 }464464465+function isTodoTool(toolName: string): boolean {466+ return toolName.toLowerCase().includes("todowrite");467+}468+469+type PlanStep = { step: string; status: "pending" | "inProgress" | "completed" };470+471+function extractPlanStepsFromTodoInput(input: Record<string, unknown>): PlanStep[] | null {472+ // TodoWrite format: { todos: [{ content, status, activeForm? }] }473+ const todos = input.todos;474+ if (!Array.isArray(todos) || todos.length === 0) {475+ return null;476+ }477+ return todos478+ .filter((t): t is Record<string, unknown> => t !== null && typeof t === "object")479+ .map((todo) => ({480+ step: typeof todo.content === "string" ? todo.content : "Task",
juliusmarminge merged this0d28026
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
76bcff43-f45a-4fa6-94f6-75948292b898You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share