Skip to content

Commit 7322281

Browse files
TonybynMp4claude
andcommitted
fix(web): Claude task lists stay in the composer between turns
Claude's TaskCreate/TaskUpdate list lives for the whole Claude session, but the composer tasks drawer only showed the running turn's own plan. A Claude list with open steps vanished when the turn ended and stayed hidden until the agent touched it again. When the latest todo list was written by a Claude run, keep it in the drawer after the run settles and during later runs on the same Claude provider thread, until every step is completed. Other providers keep today's behavior. Closes #14327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 83fbbc1 commit 7322281

4 files changed

Lines changed: 205 additions & 18 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ import {
195195
selectHandoffImageResources,
196196
type TimelineEntriesProjection,
197197
deriveActivePlanState,
198+
selectComposerTasksPlan,
198199
deriveActiveWorkStartedAt,
199200
deriveCanInterruptRunningThread,
200201
findLatestProposedPlan,
@@ -2452,27 +2453,36 @@ export default function ChatView(props: ChatViewProps) {
24522453
() => deriveActivePlanState(serverProjection, activeActivityRun?.runId),
24532454
[activeActivityRun?.runId, serverProjection],
24542455
);
2455-
// Tasks progress for the running turn's own plan only — deriveActivePlanState
2456-
// falls back to older runs' plans, which must not label fresh work.
2456+
// deriveActivePlanState falls back to older runs' plans; only the running
2457+
// turn's own list, or a Claude session's open list, belongs in the drawer.
2458+
const activeActivityRunSettled = isLatestRunSettled(activeActivityRun, activeRuntime);
2459+
const composerTasksPlan = useMemo(
2460+
() =>
2461+
selectComposerTasksPlan(
2462+
serverProjection,
2463+
activePlan,
2464+
activeActivityRun?.runId ?? null,
2465+
activeActivityRunSettled,
2466+
),
2467+
[activeActivityRun?.runId, activeActivityRunSettled, activePlan, serverProjection],
2468+
);
24572469
const activeComposerTasksProgress = useMemo(() => {
2458-
if (
2459-
isLatestRunSettled(activeActivityRun, activeRuntime) ||
2460-
!activePlan ||
2461-
activePlan.runId !== (activeActivityRun?.runId ?? null)
2462-
) {
2463-
return null;
2464-
}
2465-
const totalSteps = activePlan.steps.length;
2470+
if (!composerTasksPlan) return null;
2471+
const live =
2472+
!activeActivityRunSettled && composerTasksPlan.runId === (activeActivityRun?.runId ?? null);
2473+
const totalSteps = composerTasksPlan.steps.length;
24662474
if (totalSteps === 0) return null;
2467-
const completedSteps = activePlan.steps.filter((step) => step.status === "completed").length;
2475+
const completedSteps = composerTasksPlan.steps.filter(
2476+
(step) => step.status === "completed",
2477+
).length;
24682478
const step =
2469-
activePlan.steps.find((candidate) => candidate.status === "inProgress")?.step ??
2470-
activePlan.steps.find((candidate) => candidate.status === "pending")?.step ??
2471-
activePlan.steps.at(-1)!.step;
2472-
return { step, completedSteps, totalSteps };
2473-
}, [activeActivityRun, activePlan, activeRuntime]);
2479+
composerTasksPlan.steps.find((candidate) => candidate.status === "inProgress")?.step ??
2480+
composerTasksPlan.steps.find((candidate) => candidate.status === "pending")?.step ??
2481+
composerTasksPlan.steps.at(-1)!.step;
2482+
return { step, completedSteps, totalSteps, live };
2483+
}, [activeActivityRun?.runId, activeActivityRunSettled, composerTasksPlan]);
24742484
const activeComposerTaskSteps =
2475-
activeComposerTasksProgress && activePlan ? activePlan.steps : null;
2485+
activeComposerTasksProgress && composerTasksPlan ? composerTasksPlan.steps : null;
24762486
const activeProjectRef = useMemo(
24772487
() =>
24782488
activeThread ? scopeProjectRef(activeThread.environmentId, activeThread.projectId) : null,

‎apps/web/src/components/chat/ComposerTasksBadge.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface ComposerTasksProgress {
99
readonly step: string;
1010
readonly completedSteps: number;
1111
readonly totalSteps: number;
12+
/** False when the list is shown from a turn that is no longer running. */
13+
readonly live: boolean;
1214
}
1315

1416
export interface ComposerTaskStep {
@@ -205,7 +207,7 @@ export const ComposerTasksContent = memo(function ComposerTasksContent({
205207
>
206208
{step.durationMs !== undefined
207209
? formatDuration(step.durationMs)
208-
: step.status === "inProgress"
210+
: step.status === "inProgress" && progress.live
209211
? "now"
210212
: null}
211213
</span>

‎apps/web/src/session-logic.test.ts‎

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CheckpointScopeId,
66
NodeId,
77
PlanId,
8+
ProviderDriverKind,
89
ProviderInstanceId,
910
ProviderThreadId,
1011
RunAttemptId,
@@ -31,6 +32,7 @@ import {
3132
derivePhase,
3233
findLatestProposedPlan,
3334
isLatestRunSettled,
35+
selectComposerTasksPlan,
3436
selectHandoffImageResources,
3537
selectMessageImageResources,
3638
createMessageAttachmentPreviewProjector,
@@ -972,6 +974,141 @@ describe("V2 session presentation", () => {
972974
});
973975
});
974976

977+
describe("composer tasks drawer", () => {
978+
const projection = makeThreadProjectionFixture();
979+
const now = projection.updatedAt;
980+
981+
function providerThread(id: string, driver: string) {
982+
return {
983+
id: ProviderThreadId.make(id),
984+
driver: ProviderDriverKind.make(driver),
985+
providerInstanceId: ProviderInstanceId.make(driver),
986+
providerSessionId: null,
987+
appThreadId: projection.thread.id,
988+
ownerNodeId: null,
989+
nativeThreadRef: null,
990+
nativeConversationHeadRef: null,
991+
status: "idle" as const,
992+
firstRunOrdinal: null,
993+
lastRunOrdinal: null,
994+
handoffIds: [],
995+
forkedFrom: null,
996+
createdAt: now,
997+
updatedAt: now,
998+
};
999+
}
1000+
1001+
function run(id: string, ordinal: number, providerThreadId: string | null) {
1002+
return {
1003+
id: RunId.make(id),
1004+
threadId: projection.thread.id,
1005+
ordinal,
1006+
providerInstanceId: projection.thread.providerInstanceId,
1007+
modelSelection: projection.thread.modelSelection,
1008+
providerThreadId: providerThreadId === null ? null : ProviderThreadId.make(providerThreadId),
1009+
userMessageId: MessageId.make(`message-${id}`),
1010+
rootNodeId: null,
1011+
activeAttemptId: null,
1012+
status: "completed" as const,
1013+
requestedAt: now,
1014+
startedAt: now,
1015+
completedAt: now,
1016+
checkpointId: null,
1017+
contextHandoffId: null,
1018+
};
1019+
}
1020+
1021+
function plan(runId: string, statuses: ReadonlyArray<"pending" | "inProgress" | "completed">) {
1022+
return {
1023+
createdAt: "2026-06-20T00:00:00.000Z",
1024+
runId: RunId.make(runId),
1025+
steps: statuses.map((status, index) => ({ step: `Step ${index}`, status })),
1026+
};
1027+
}
1028+
1029+
const threads = [providerThread("claude", "claudeAgent"), providerThread("codex", "codex")];
1030+
const openList = plan("claude-1", ["completed", "inProgress", "pending"]);
1031+
1032+
it("shows the running turn's own list for every provider", () => {
1033+
const codexPlan = plan("codex-1", ["completed", "completed"]);
1034+
const withRuns = {
1035+
...projection,
1036+
runs: [run("codex-1", 1, "codex")],
1037+
providerThreads: threads,
1038+
};
1039+
expect(selectComposerTasksPlan(withRuns, codexPlan, RunId.make("codex-1"), false)).toBe(
1040+
codexPlan,
1041+
);
1042+
});
1043+
1044+
it("keeps a Claude list with open steps after its run settles and during later Claude runs", () => {
1045+
const settled = {
1046+
...projection,
1047+
runs: [run("claude-1", 1, "claude")],
1048+
providerThreads: threads,
1049+
};
1050+
expect(selectComposerTasksPlan(settled, openList, RunId.make("claude-1"), true)).toBe(openList);
1051+
1052+
const laterRun = {
1053+
...settled,
1054+
runs: [...settled.runs, run("claude-2", 2, "claude")],
1055+
};
1056+
expect(selectComposerTasksPlan(laterRun, openList, RunId.make("claude-2"), false)).toBe(
1057+
openList,
1058+
);
1059+
});
1060+
1061+
it("hides a settled Claude list once every step is completed", () => {
1062+
const settled = {
1063+
...projection,
1064+
runs: [run("claude-1", 1, "claude")],
1065+
providerThreads: threads,
1066+
};
1067+
const done = plan("claude-1", ["completed", "completed"]);
1068+
expect(selectComposerTasksPlan(settled, done, RunId.make("claude-1"), true)).toBeNull();
1069+
});
1070+
1071+
it("keeps today's behavior for other providers once their run settles", () => {
1072+
const codexPlan = plan("codex-1", ["completed", "pending"]);
1073+
const withRuns = {
1074+
...projection,
1075+
runs: [run("codex-1", 1, "codex"), run("codex-2", 2, "codex")],
1076+
providerThreads: threads,
1077+
};
1078+
expect(selectComposerTasksPlan(withRuns, codexPlan, RunId.make("codex-1"), true)).toBeNull();
1079+
expect(selectComposerTasksPlan(withRuns, codexPlan, RunId.make("codex-2"), false)).toBeNull();
1080+
});
1081+
1082+
it("hides a Claude list once a later run moves to another provider thread", () => {
1083+
const switched = {
1084+
...projection,
1085+
runs: [run("claude-1", 1, "claude"), run("codex-2", 2, "codex")],
1086+
providerThreads: threads,
1087+
};
1088+
expect(selectComposerTasksPlan(switched, openList, RunId.make("codex-2"), false)).toBeNull();
1089+
1090+
const freshClaudeSession = {
1091+
...switched,
1092+
providerThreads: [...threads, providerThread("claude-fresh", "claudeAgent")],
1093+
runs: [run("claude-1", 1, "claude"), run("claude-3", 3, "claude-fresh")],
1094+
};
1095+
expect(
1096+
selectComposerTasksPlan(freshClaudeSession, openList, RunId.make("claude-3"), true),
1097+
).toBeNull();
1098+
});
1099+
1100+
it("keeps the Claude list while a newer run has not reached a provider thread yet", () => {
1101+
const queued = {
1102+
...projection,
1103+
runs: [run("claude-1", 1, "claude"), run("pending-2", 2, null)],
1104+
providerThreads: threads,
1105+
};
1106+
expect(selectComposerTasksPlan(queued, openList, RunId.make("pending-2"), false)).toBe(
1107+
openList,
1108+
);
1109+
});
1110+
});
1111+
9751112
describe("native provider presentation in the v2 timeline", () => {
9761113
const timestamp = DateTime.makeUnsafe("2026-09-04T12:00:00.000Z");
9771114
const base = {

‎apps/web/src/session-logic.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,44 @@ export function deriveActivePlanState(
281281
};
282282
}
283283

284+
/**
285+
* Picks the todo list the composer tasks drawer shows, given the plan from
286+
* deriveActivePlanState. Every provider shows the running turn's own list.
287+
* Claude keeps one task list (TaskCreate/TaskUpdate) for its whole session, so
288+
* a Claude list with open steps also stays visible after its run settles and
289+
* during later runs on that same Claude session.
290+
*/
291+
export function selectComposerTasksPlan(
292+
projection: OrchestrationV2ThreadProjection | null,
293+
plan: ActivePlanState | null,
294+
activeRunId: RunId | null,
295+
activeRunSettled: boolean,
296+
): ActivePlanState | null {
297+
if (projection === null || plan === null) return null;
298+
if (!activeRunSettled && plan.runId === activeRunId) return plan;
299+
if (plan.steps.every((step) => step.status === "completed")) return null;
300+
const planProviderThreadId = projection.runs.find(
301+
(run) => run.id === plan.runId,
302+
)?.providerThreadId;
303+
if (planProviderThreadId === undefined || planProviderThreadId === null) return null;
304+
const planDriver = projection.providerThreads.find(
305+
(providerThread) => providerThread.id === planProviderThreadId,
306+
)?.driver;
307+
if (planDriver !== "claudeAgent") return null;
308+
// A later run on another provider thread (provider switch, fresh session)
309+
// does not own this list.
310+
let latestStartedRun: OrchestrationV2ThreadProjection["runs"][number] | null = null;
311+
for (const run of projection.runs) {
312+
if (
313+
run.providerThreadId !== null &&
314+
(latestStartedRun === null || run.ordinal > latestStartedRun.ordinal)
315+
) {
316+
latestStartedRun = run;
317+
}
318+
}
319+
return latestStartedRun?.providerThreadId === planProviderThreadId ? plan : null;
320+
}
321+
284322
function planItemTime(projection: OrchestrationV2ThreadProjection, planId: PlanId): string {
285323
const item = projection.turnItems.findLast(
286324
(candidate) =>

0 commit comments

Comments
 (0)