The best way to control Claude Code, Codex and more from any computer or phone
fix(web): Claude task lists stay in the composer between turns (#18392)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Antony committed
Oct 20, 2026 at 07:43 UTC
1ba3c781d04a0694ec1277ddf386b658b93d765f
10 files changed
+561
-35
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+27
-5
@@ -6380,6 +6380,20 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6380
harness.sdkMessages,
6381
toolResults("00000000-0000-4000-8000-000000000505", ["tool-todo-2", "tool-exit-plan-1"]),
6382
);
6383
+ yield* Queue.offer(
6384
+ harness.sdkMessages,
6385
+ assistantTools("00000000-0000-4000-8000-000000000509", [
6386
+ {
6387
+ id: "tool-todo-3",
6388
+ name: "TodoWrite",
6389
+ input: { todos: [{ content: "Implement", status: "pending" }] },
6390
+ },
6391
+ ]),
6392
+ );
6393
+ yield* Queue.offer(
6394
+ harness.sdkMessages,
6395
+ toolResults("00000000-0000-4000-8000-000000000510", ["tool-todo-3"]),
6396
+ );
6397
yield* Queue.offer(
6398
harness.sdkMessages,
6399
makeResultFrame({
@@ -6401,7 +6415,15 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6415
);
6416
const todoItems = [...items.values()].filter((item) => item.type === "todo_list");
6417
const proposedItems = [...items.values()].filter((item) => item.type === "proposed_plan");
6404
- assert.lengthOf(todoItems, 2);
6418
+ assert.lengthOf(todoItems, 3);
6419
+ assert.equal(todoItems[1]?.status, "completed");
6420
+ assert.deepEqual(todoItems[1]?.steps, [
6421
+ { id: "todo-0", text: "Inspect", status: "completed" },
6422
+ ]);
6423
+ assert.deepEqual(todoItems[2]?.steps, [
6424
+ { id: "todo-0", text: "Implement", status: "pending" },
6425
+ ]);
6426
+ assert.equal(todoItems[1]?.runId, todoItems[2]?.runId);
6427
assert.lengthOf(proposedItems, 1);
6428
assert.equal(
6429
proposedItems[0]?.type === "proposed_plan" && proposedItems[0].markdown,
@@ -6419,15 +6441,15 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6441
item.type === "dynamic_tool" && item.nativeItemRef?.nativeId === "tool-exit-plan-1",
6442
),
6443
);
6444
+ const proposedPlan = [...plans.values()].find((plan) => plan.kind === "proposed_plan");
6445
+ assert.equal(proposedPlan?.status, "active");
6446
+ assert.deepEqual(harness.permissionModeChanges, ["bypassPermissions"]);
6447
assert.deepEqual(
6448
[...plans.values()]
6449
.filter((plan) => plan.kind === "todo_list")
6450
.map((plan) => plan.status),
6426
- ["superseded", "completed"],
6451
+ ["superseded", "superseded", "active"],
6452
);
6428
- const proposedPlan = [...plans.values()].find((plan) => plan.kind === "proposed_plan");
6429
- assert.equal(proposedPlan?.status, "active");
6430
- assert.deepEqual(harness.permissionModeChanges, ["bypassPermissions"]);
6453
}).pipe(
6454
Effect.provide(
6455
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+1
-1
@@ -5953,7 +5953,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
5953
[
5954
...(previousPlan === undefined ||
5955
previousPlan.id === plan.id ||
5956
- previousPlan.status === "completed"
5956
+ (previousPlan.kind !== "todo_list" && previousPlan.status === "completed")
5957
? []
5958
: [
5959
emitProviderEvent({
apps/server/src/orchestration-v2/ProjectionStore.test.ts
+180
-2
@@ -1609,6 +1609,8 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
1609
const now = yield* DateTime.now;
1610
const nowIso = DateTime.formatIso(now);
1611
const threadId = ThreadId.make("thread:notification-turn-pages");
1612
+ const providerInstanceId = ProviderInstanceId.make("claudeAgent");
1613
+ const modelSelection = { instanceId: providerInstanceId, model: "claude-sonnet-4-6" };
1614
yield* projectionStore.apply({
1615
id: EventId.make("event:notification-turn-pages:thread"),
1616
type: "thread.created",
@@ -1639,6 +1641,53 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
1641
},
1642
});
1643
1644
+ const providerThreadId = ProviderThreadId.make("provider-thread:notification-turn-pages");
1645
+ yield* projectionStore.apply({
1646
+ id: EventId.make("event:notification-turn-pages:provider-thread"),
1647
+ type: "provider-thread.updated",
1648
+ threadId,
1649
+ occurredAt: now,
1650
+ payload: {
1651
+ id: providerThreadId,
1652
+ driver: ProviderDriverKind.make("claudeAgent"),
1653
+ providerInstanceId,
1654
+ providerSessionId: null,
1655
+ appThreadId: threadId,
1656
+ ownerNodeId: null,
1657
+ nativeThreadRef: null,
1658
+ nativeConversationHeadRef: null,
1659
+ status: "idle",
1660
+ firstRunOrdinal: 1,
1661
+ lastRunOrdinal: 412,
1662
+ handoffIds: [],
1663
+ forkedFrom: null,
1664
+ createdAt: now,
1665
+ updatedAt: now,
1666
+ },
1667
+ });
1668
+ const planId = PlanId.make("plan:notification-turn-pages");
1669
+ const olderPlanId = PlanId.make("plan:notification-turn-pages:older");
1670
+ for (const [id, run] of [
1671
+ [olderPlanId, 1],
1672
+ [planId, 2],
1673
+ ] as const) {
1674
+ yield* projectionStore.apply({
1675
+ id: EventId.make(`event:notification-turn-pages:plan:${run}`),
1676
+ type: "plan.updated",
1677
+ threadId,
1678
+ occurredAt: now,
1679
+ payload: {
1680
+ id,
1681
+ threadId,
1682
+ runId: RunId.make(`run:notification-turn-pages:${run}`),
1683
+ nodeId: NodeId.make(`node:notification-turn-pages:${run}`),
1684
+ kind: "todo_list",
1685
+ status: "active",
1686
+ steps: [{ id: "unfinished", text: "Finish the task", status: "pending" }],
1687
+ },
1688
+ });
1689
+ }
1690
+
1691
const startedRuns = 412;
1692
const allIds: string[] = [];
1693
const startIds: string[] = [];
@@ -1693,14 +1742,14 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
1742
run_id, thread_id, ordinal, provider, provider_thread_id, status,
1743
requested_at, completed_at, payload_json
1744
) VALUES (
1696
- ${runId}, ${threadId}, ${run}, 'codex', NULL, ${status}, ${nowIso}, ${nowIso},
1745
+ ${runId}, ${threadId}, ${run}, 'claudeAgent', ${providerThreadId}, ${status}, ${nowIso}, ${nowIso},
1746
${encodeUnknownJsonString({
1747
id: runId,
1748
threadId,
1749
ordinal: run,
1750
providerInstanceId,
1751
modelSelection,
1703
- providerThreadId: null,
1752
+ providerThreadId,
1753
userMessageId: `message:notification-turn-pages:${run}`,
1754
rootNodeId: `node:notification-turn-pages:${run}`,
1755
activeAttemptId: null,
@@ -1763,6 +1812,22 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
1812
snapshotSequence: 0,
1813
});
1814
assert.strictEqual(bounded.projection.visibleTurnItems[0]?.sourceItemId, startIds[262]);
1815
+ assert.deepEqual(
1816
+ bounded.projection.plans.map((plan) => plan.id),
1817
+ [planId, olderPlanId],
1818
+ );
1819
+ assert.deepEqual(
1820
+ {
1821
+ oldRunIds: bounded.projection.runs
1822
+ .filter((run) => run.ordinal < 261)
1823
+ .map((run) => run.id),
1824
+ providerThreadIds: bounded.projection.providerThreads.map((thread) => thread.id),
1825
+ },
1826
+ {
1827
+ oldRunIds: [RunId.make("run:notification-turn-pages:2")],
1828
+ providerThreadIds: [providerThreadId],
1829
+ },
1830
+ );
1831
const loaded = bounded.projection.visibleTurnItems.map((row) => String(row.sourceItemId));
1832
let cursor = bounded.historyCursor;
1833
for (let pages = 0; cursor !== null; pages += 1) {
@@ -1784,6 +1849,119 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
1849
cursor = page.nextCursor;
1850
}
1851
assert.deepEqual(loaded, allIds);
1852
+
1853
+ const completedPlan = {
1854
+ id: planId,
1855
+ threadId,
1856
+ runId: RunId.make("run:notification-turn-pages:2"),
1857
+ nodeId: NodeId.make("node:notification-turn-pages:2"),
1858
+ kind: "todo_list" as const,
1859
+ status: "completed" as const,
1860
+ explanation: "All tasks complete",
1861
+ steps: [{ id: "unfinished", text: "Finish the task", status: "completed" as const }],
1862
+ };
1863
+ yield* projectionStore.apply({
1864
+ id: EventId.make("event:notification-turn-pages:plan:completed"),
1865
+ type: "plan.updated",
1866
+ threadId,
1867
+ occurredAt: now,
1868
+ payload: completedPlan,
1869
+ });
1870
+ const afterCompletion = yield* projectionStore.getThreadSnapshotWindow(threadId, {
1871
+ rowLimit: 77,
1872
+ userTurnLimit: 10,
1873
+ });
1874
+ const completedBounded = buildBoundedThreadProjection({
1875
+ projection: afterCompletion.projection,
1876
+ snapshotSequence: 0,
1877
+ });
1878
+ assert.deepEqual(
1879
+ {
1880
+ plans: completedBounded.projection.plans,
1881
+ oldRunIds: completedBounded.projection.runs
1882
+ .filter((run) => run.ordinal < 261)
1883
+ .map((run) => run.id),
1884
+ providerThreadIds: completedBounded.projection.providerThreads.map((thread) => thread.id),
1885
+ },
1886
+ {
1887
+ plans: [completedPlan, bounded.projection.plans.find((plan) => plan.id === olderPlanId)],
1888
+ oldRunIds: [completedPlan.runId],
1889
+ providerThreadIds: [providerThreadId],
1890
+ },
1891
+ );
1892
+
1893
+ // Older versions left completed predecessors unsuperseded; IDs do not order replacements.
1894
+ const newerPlan = {
1895
+ ...completedPlan,
1896
+ id: PlanId.make("plan:legacy-newer"),
1897
+ status: "active" as const,
1898
+ explanation: "More work remains",
1899
+ steps: [{ id: "new", text: "Finish the new task", status: "pending" as const }],
1900
+ };
1901
+ yield* projectionStore.apply({
1902
+ id: EventId.make("event:notification-turn-pages:plan:legacy-newer"),
1903
+ type: "plan.updated",
1904
+ threadId,
1905
+ occurredAt: now,
1906
+ payload: newerPlan,
1907
+ });
1908
+ for (const [plan, itemOrdinal] of [
1909
+ [completedPlan, 7],
1910
+ [newerPlan, 8],
1911
+ ] as const) {
1912
+ yield* projectionStore.apply({
1913
+ id: EventId.make(`event:notification-turn-pages:legacy-item:${itemOrdinal}`),
1914
+ type: "turn-item.updated",
1915
+ threadId,
1916
+ runId: plan.runId,
1917
+ nodeId: plan.nodeId,
1918
+ occurredAt: now,
1919
+ payload: {
1920
+ id: TurnItemId.make(`turn-item:notification-turn-pages:${itemOrdinal}`),
1921
+ threadId,
1922
+ runId: plan.runId,
1923
+ nodeId: plan.nodeId,
1924
+ providerThreadId,
1925
+ providerTurnId: null,
1926
+ nativeItemRef: null,
1927
+ parentItemId: null,
1928
+ ordinal: itemOrdinal,
1929
+ status: "completed",
1930
+ title: null,
1931
+ startedAt: now,
1932
+ completedAt: now,
1933
+ updatedAt: now,
1934
+ type: "todo_list",
1935
+ planId: plan.id,
1936
+ steps: plan.steps,
1937
+ explanation: plan.explanation,
1938
+ },
1939
+ });
1940
+ }
1941
+ const legacySnapshot = yield* projectionStore.getThreadSnapshotWindow(threadId, {
1942
+ rowLimit: 77,
1943
+ userTurnLimit: 10,
1944
+ });
1945
+ assert.isTrue(legacySnapshot.projection.turnItems.every((item) => item.ordinal > 8));
1946
+ assert.deepEqual(
1947
+ legacySnapshot.projection.plans.findLast((plan) => plan.runId === newerPlan.runId),
1948
+ newerPlan,
1949
+ );
1950
+ const legacyBounded = buildBoundedThreadProjection({
1951
+ projection: legacySnapshot.projection,
1952
+ snapshotSequence: 0,
1953
+ });
1954
+ assert.deepEqual(
1955
+ {
1956
+ ownerPlans: legacyBounded.projection.plans.filter(
1957
+ (plan) => plan.runId === newerPlan.runId,
1958
+ ),
1959
+ oldRunIds: legacyBounded.projection.runs
1960
+ .filter((run) => run.ordinal < 261)
1961
+ .map((run) => run.id),
1962
+ },
1963
+ { ownerPlans: [newerPlan], oldRunIds: [newerPlan.runId] },
1964
+ );
1965
}),
1966
);
1967
apps/server/src/orchestration-v2/ProjectionStore.ts
+67
-2
@@ -3091,6 +3091,54 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
3091
const cohortPlanIds = cohortJson("planId");
3092
const cohortCheckpointIds = cohortJson("checkpointId");
3093
const cohortHandoffIds = cohortJson("contextHandoffId");
3094
+ // A newer completion must keep an older active list from resurfacing after paging.
3095
+ const [latestTodoList] =
3096
+ window === undefined ||
3097
+ (fields !== undefined &&
3098
+ !fields.some(
3099
+ (field) => field === "plans" || field === "runs" || field === "providerThreads",
3100
+ ))
3101
+ ? []
3102
+ : yield* sql<{
3103
+ readonly plan_id: string;
3104
+ readonly run_id: string;
3105
+ readonly provider_thread_id: string | null;
3106
+ readonly last_plan_id: string;
3107
+ }>`
3108
+ WITH latest_owner AS MATERIALIZED (
3109
+ SELECT plan.plan_id, owner.run_id, owner.provider_thread_id
3110
+ FROM orchestration_v2_projection_plans AS plan
3111
+ INNER JOIN orchestration_v2_projection_runs AS owner
3112
+ ON owner.thread_id = plan.thread_id AND owner.run_id = plan.run_id
3113
+ WHERE plan.thread_id = ${threadId}
3114
+ AND plan.kind = 'todo_list' AND plan.status <> 'superseded'
3115
+ ORDER BY owner.ordinal DESC, plan.plan_id DESC
3116
+ LIMIT 1
3117
+ )
3118
+ SELECT COALESCE(CASE WHEN EXISTS (
3119
+ SELECT 1 FROM orchestration_v2_projection_plans
3120
+ WHERE thread_id = ${threadId} AND run_id = owner.run_id
3121
+ AND kind = 'todo_list' AND status <> 'superseded'
3122
+ AND plan_id <> owner.plan_id
3123
+ ) THEN (
3124
+ -- Plan UUIDs cannot order replacements within a run.
3125
+ SELECT plan.plan_id
3126
+ FROM orchestration_v2_projection_turn_items AS item
3127
+ CROSS JOIN orchestration_v2_projection_plans AS plan
3128
+ ON plan.plan_id = json_extract(item.payload_json, '$.planId')
3129
+ WHERE item.run_id = owner.run_id AND item.thread_id = ${threadId}
3130
+ AND item.type = 'todo_list'
3131
+ AND plan.run_id = owner.run_id AND plan.thread_id = ${threadId}
3132
+ AND plan.kind = 'todo_list' AND plan.status <> 'superseded'
3133
+ ORDER BY item.ordinal DESC
3134
+ LIMIT 1
3135
+ ) END, owner.plan_id) AS plan_id, owner.run_id, owner.provider_thread_id,
3136
+ (
3137
+ SELECT MAX(plan_id) FROM orchestration_v2_projection_plans
3138
+ WHERE thread_id = ${threadId} AND run_id = owner.run_id
3139
+ ) AS last_plan_id
3140
+ FROM latest_owner AS owner
3141
+ `;
3142
3143
const [
3144
thread,
@@ -3126,7 +3174,18 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
3174
WHERE thread_id = ${threadId}
3175
AND (status IN ('queued','preparing','starting','running','waiting')
3176
OR run_id IN (SELECT value FROM json_each(${cohortRunIds}))
3129
- OR run_id = ${window.requiredRunId ?? null})
3177
+ OR run_id = ${window.requiredRunId ?? null}
3178
+ -- Queued or cancelled turns must not hide the latest actual session.
3179
+ OR run_id = ${latestTodoList?.run_id ?? null}
3180
+ OR run_id = (
3181
+ SELECT run_id FROM orchestration_v2_projection_runs
3182
+ WHERE thread_id = ${threadId}
3183
+ AND provider_thread_id IS NOT NULL
3184
+ AND json_extract(payload_json, '$.startedAt') IS NOT NULL
3185
+ AND ${latestTodoList?.plan_id ?? null} IS NOT NULL
3186
+ ORDER BY ordinal DESC
3187
+ LIMIT 1
3188
+ ))
3189
ORDER BY ordinal ASC
3190
`,
3191
fields !== undefined && !fields.includes("attempts")
@@ -3246,6 +3305,8 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
3305
WHERE (thread_id = ${threadId} AND status = 'active')
3306
OR provider_thread_id IN (SELECT value FROM json_each(${cohortProviderThreadIds}))
3307
OR owner_node_id IN (SELECT value FROM json_each(${cohortNodeIds}))
3308
+ OR (thread_id = ${threadId}
3309
+ AND provider_thread_id = ${latestTodoList?.provider_thread_id ?? null})
3310
ORDER BY COALESCE(first_run_ordinal, 0), provider_thread_id ASC
3311
`,
3312
fields !== undefined && !fields.includes("providerTurns")
@@ -3322,11 +3383,15 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
3383
WHERE plan.thread_id = ${threadId}
3384
AND (
3385
plan.status = 'active'
3386
+ OR plan.plan_id = ${latestTodoList?.plan_id ?? null}
3387
OR plan.plan_id IN (
3388
SELECT value FROM json_each(${cohortPlanIds})
3389
)
3390
)
3329
- ORDER BY plan_id ASC
3391
+ -- Keep the selected artifact last within its run for equal-run consumers.
3392
+ ORDER BY CASE WHEN plan_id = ${latestTodoList?.plan_id ?? null}
3393
+ THEN ${latestTodoList?.last_plan_id ?? null} ELSE plan_id END ASC,
3394
+ plan_id = ${latestTodoList?.plan_id ?? null} ASC
3395
`,
3396
fields !== undefined && !fields.includes("checkpointScopes")
3397
? Effect.succeed([])
apps/server/src/orchestration-v2/threadHistoryPaging.ts
+26
-4
@@ -482,9 +482,26 @@ export function buildBoundedThreadProjection(input: {
482
}): BoundedProjectionResult {
483
const policy = input.policy ?? THREAD_HISTORY_PAGE_POLICY;
484
const threadId = input.projection.thread.id;
485
+ const runOrdinals = new Map(input.projection.runs.map((run) => [run.id, run.ordinal]));
486
+ let latestTodoList: (typeof input.projection.plans)[number] | undefined;
487
+ let latestTodoListOrdinal = -1;
488
+ for (const plan of input.projection.plans) {
489
+ const ordinal = plan.runId === null ? undefined : runOrdinals.get(plan.runId);
490
+ if (
491
+ plan.kind === "todo_list" &&
492
+ plan.status !== "superseded" &&
493
+ ordinal !== undefined &&
494
+ ordinal >= latestTodoListOrdinal
495
+ ) {
496
+ latestTodoList = plan;
497
+ latestTodoListOrdinal = ordinal;
498
+ }
499
+ }
500
const controlProjection = {
501
...input.projection,
487
- plans: input.projection.plans.filter((plan) => plan.status === "active"),
502
+ plans: input.projection.plans.filter(
503
+ (plan) => plan.status === "active" || plan.id === latestTodoList?.id,
504
+ ),
505
contextHandoffs: input.projection.contextHandoffs.filter(
506
(handoff) => handoff.status === "pending" || handoff.status === "ready",
507
),
@@ -506,7 +523,7 @@ export function buildBoundedThreadProjection(input: {
523
turnItems: [],
524
visibleTurnItems: [],
525
});
509
- // Control state (checkpoint file lists, an active plan) cannot be paged, so it may claim at most
526
+ // Control state (checkpoint file lists, the latest task list) cannot be paged, so it may claim at most
527
// half the budget; past that the window would shrink to the one row every page admits.
528
const windowBudget = Math.max(
529
policy.maxEncodedBytes / 2,
@@ -548,9 +565,14 @@ export function buildBoundedThreadProjection(input: {
565
turnItems.flatMap((item) => (item.type === "handoff" ? [String(item.contextHandoffId)] : [])),
566
);
567
const plans = input.projection.plans
551
- .filter((plan) => plan.status === "active" || visiblePlanIds.has(String(plan.id)))
568
+ .filter(
569
+ (plan) =>
570
+ plan.status === "active" ||
571
+ plan.id === latestTodoList?.id ||
572
+ visiblePlanIds.has(String(plan.id)),
573
+ )
574
.map((plan) =>
553
- plan.status === "active"
575
+ plan.status === "active" || plan.id === latestTodoList?.id
576
? plan
577
: plan.kind === "proposed_plan"
578
? { ...plan, markdown: "", detailInTurnItem: true as const }
apps/web/src/components/ChatView.tsx
+19
-16
@@ -187,6 +187,7 @@ import {
187
derivePhase,
188
selectHandoffImageResources,
189
deriveActivePlanState,
190
+ selectComposerTasksPlan,
191
deriveActiveWorkStartedAt,
192
deriveCanInterruptRunningThread,
193
findLatestProposedPlan,
@@ -1827,27 +1828,29 @@ export default function ChatView(props: ChatViewProps) {
1828
}
1829
const latestRunSettled = isLatestRunSettled(activeLatestRun, activeRuntime);
1830
const activePlan = deriveActivePlanState(serverProjection, activeActivityRun?.runId);
1830
- // Tasks progress for the running turn's own plan only — deriveActivePlanState
1831
- // falls back to older runs' plans, which must not label fresh work.
1831
+ const activeActivityRunSettled = isLatestRunSettled(activeActivityRun, activeRuntime);
1832
+ const composerTasksPlan = selectComposerTasksPlan(
1833
+ serverProjection,
1834
+ activePlan,
1835
+ activeActivityRun?.runId ?? null,
1836
+ activeActivityRunSettled,
1837
+ );
1838
const activeComposerTasksProgress = (() => {
1833
- if (
1834
- isLatestRunSettled(activeActivityRun, activeRuntime) ||
1835
- !activePlan ||
1836
- activePlan.runId !== (activeActivityRun?.runId ?? null)
1837
- ) {
1838
- return null;
1839
- }
1840
- const totalSteps = activePlan.steps.length;
1839
+ if (!composerTasksPlan) return null;
1840
+ const live = !activeActivityRunSettled && composerTasksPlan.runId === activeActivityRun?.runId;
1841
+ const totalSteps = composerTasksPlan.steps.length;
1842
if (totalSteps === 0) return null;
1842
- const completedSteps = activePlan.steps.filter((step) => step.status === "completed").length;
1843
+ const completedSteps = composerTasksPlan.steps.filter(
1844
+ (step) => step.status === "completed",
1845
+ ).length;
1846
const step =
1844
- activePlan.steps.find((candidate) => candidate.status === "inProgress")?.step ??
1845
- activePlan.steps.find((candidate) => candidate.status === "pending")?.step ??
1846
- activePlan.steps.at(-1)!.step;
1847
- return { step, completedSteps, totalSteps };
1847
+ composerTasksPlan.steps.find((candidate) => candidate.status === "inProgress")?.step ??
1848
+ composerTasksPlan.steps.find((candidate) => candidate.status === "pending")?.step ??
1849
+ composerTasksPlan.steps.at(-1)!.step;
1850
+ return { step, completedSteps, totalSteps, live };
1851
})();
1852
const activeComposerTaskSteps =
1850
- activeComposerTasksProgress && activePlan ? activePlan.steps : null;
1853
+ activeComposerTasksProgress && composerTasksPlan ? composerTasksPlan.steps : null;
1854
const activeThreadEnvironmentId = activeThread?.environmentId;
1855
const activeThreadProjectId = activeThread?.projectId;
1856
const activeProjectRef =
apps/web/src/components/chat/ComposerTasksBadge.tsx
+2
-1
@@ -9,6 +9,7 @@ export interface ComposerTasksProgress {
9
readonly step: string;
10
readonly completedSteps: number;
11
readonly totalSteps: number;
12
+ readonly live: boolean;
13
}
14
15
export interface ComposerTaskStep {
@@ -205,7 +206,7 @@ export const ComposerTasksContent = memo(function ComposerTasksContent({
206
>
207
{step.durationMs !== undefined
208
? formatDuration(step.durationMs)
208
- : step.status === "inProgress"
209
+ : step.status === "inProgress" && progress.live
210
? "now"
211
: null}
212
</span>
apps/web/src/session-logic.test.ts
+186
@@ -5,6 +5,7 @@ import {
5
CheckpointScopeId,
6
NodeId,
7
PlanId,
8
+ ProviderDriverKind,
9
ProviderInstanceId,
10
ProviderThreadId,
11
RunAttemptId,
@@ -31,6 +32,7 @@ import {
32
derivePhase,
33
findLatestProposedPlan,
34
isLatestRunSettled,
35
+ selectComposerTasksPlan,
36
selectHandoffImageResources,
37
selectMessageImageResources,
38
createMessageAttachmentPreviewProjector,
@@ -1130,6 +1132,190 @@ describe("V2 session presentation", () => {
1132
});
1133
});
1134
1135
+describe("composer tasks drawer", () => {
1136
+ const projection = makeThreadProjectionFixture();
1137
+ const now = projection.updatedAt;
1138
+
1139
+ function providerThread(id: string, driver: string) {
1140
+ return {
1141
+ id: ProviderThreadId.make(id),
1142
+ driver: ProviderDriverKind.make(driver),
1143
+ providerInstanceId: ProviderInstanceId.make(driver),
1144
+ providerSessionId: null,
1145
+ appThreadId: projection.thread.id,
1146
+ ownerNodeId: null,
1147
+ nativeThreadRef: null,
1148
+ nativeConversationHeadRef: null,
1149
+ status: "idle" as const,
1150
+ firstRunOrdinal: null,
1151
+ lastRunOrdinal: null,
1152
+ handoffIds: [],
1153
+ forkedFrom: null,
1154
+ createdAt: now,
1155
+ updatedAt: now,
1156
+ };
1157
+ }
1158
+
1159
+ function run(id: string, ordinal: number, providerThreadId: string | null) {
1160
+ return {
1161
+ id: RunId.make(id),
1162
+ threadId: projection.thread.id,
1163
+ ordinal,
1164
+ providerInstanceId: projection.thread.providerInstanceId,
1165
+ modelSelection: projection.thread.modelSelection,
1166
+ providerThreadId: providerThreadId === null ? null : ProviderThreadId.make(providerThreadId),
1167
+ userMessageId: MessageId.make(`message-${id}`),
1168
+ rootNodeId: null,
1169
+ activeAttemptId: null,
1170
+ status: "completed" as const,
1171
+ requestedAt: now,
1172
+ startedAt: now,
1173
+ completedAt: now,
1174
+ checkpointId: null,
1175
+ contextHandoffId: null,
1176
+ };
1177
+ }
1178
+
1179
+ const openList = {
1180
+ createdAt: "2026-06-20T00:00:00.000Z",
1181
+ runId: RunId.make("run-1"),
1182
+ steps: [
1183
+ { step: "Inspect", status: "completed" as const },
1184
+ { step: "Implement", status: "inProgress" as const },
1185
+ { step: "Verify", status: "pending" as const },
1186
+ ],
1187
+ };
1188
+ const completedList = {
1189
+ ...openList,
1190
+ steps: openList.steps.map((step) => ({ ...step, status: "completed" as const })),
1191
+ };
1192
+
1193
+ it.each(["claudeAgent", "codex"])(
1194
+ "shows %s tasks through the run lifecycle, retaining unfinished tasks only for Claude",
1195
+ (driver) => {
1196
+ const firstRun = run("run-1", 1, driver);
1197
+ const settled = {
1198
+ ...projection,
1199
+ providerThreads: [providerThread(driver, driver)],
1200
+ runs: [firstRun],
1201
+ };
1202
+ const running = {
1203
+ ...settled,
1204
+ runs: [{ ...firstRun, status: "running" as const, completedAt: null }],
1205
+ };
1206
+ expect(selectComposerTasksPlan(running, openList, firstRun.id, false)).toBe(openList);
1207
+ expect(selectComposerTasksPlan(running, completedList, firstRun.id, false)).toBe(
1208
+ completedList,
1209
+ );
1210
+
1211
+ const retainedList = driver === "claudeAgent" ? openList : null;
1212
+ expect(selectComposerTasksPlan(settled, openList, firstRun.id, true)).toBe(retainedList);
1213
+ expect(selectComposerTasksPlan(settled, completedList, firstRun.id, true)).toBeNull();
1214
+
1215
+ const nextRun = {
1216
+ ...run("run-2", 2, driver),
1217
+ status: "running" as const,
1218
+ completedAt: null,
1219
+ };
1220
+ const later = { ...settled, runs: [...settled.runs, nextRun] };
1221
+ expect(selectComposerTasksPlan(later, openList, nextRun.id, false)).toBe(retainedList);
1222
+ },
1223
+ );
1224
+
1225
+ it("retains the newest unfinished Claude list after loading plans in snapshot order", () => {
1226
+ const olderRun = run("run:ordinal:8", 8, "claudeAgent");
1227
+ const planRun = run("run:ordinal:12", 12, "claudeAgent");
1228
+ const laterRun = {
1229
+ ...run("run:ordinal:13", 13, "claudeAgent"),
1230
+ status: "running" as const,
1231
+ completedAt: null,
1232
+ };
1233
+ const newestPlan = {
1234
+ id: PlanId.make("plan:run:ordinal:12"),
1235
+ threadId: projection.thread.id,
1236
+ runId: planRun.id,
1237
+ nodeId: NodeId.make("node:ordinal:12"),
1238
+ kind: "todo_list" as const,
1239
+ status: "active" as const,
1240
+ steps: [{ id: "new", text: "Finish the current task", status: "pending" as const }],
1241
+ };
1242
+ for (const status of ["superseded", "active"] as const) {
1243
+ const snapshot = {
1244
+ ...projection,
1245
+ providerThreads: [providerThread("claudeAgent", "claudeAgent")],
1246
+ runs: [olderRun, planRun, laterRun],
1247
+ plans: [
1248
+ newestPlan,
1249
+ {
1250
+ ...newestPlan,
1251
+ id: PlanId.make("plan:run:ordinal:8"),
1252
+ runId: olderRun.id,
1253
+ nodeId: NodeId.make("node:ordinal:8"),
1254
+ status,
1255
+ steps: [{ id: "old", text: "Stale task", status: "pending" as const }],
1256
+ },
1257
+ ],
1258
+ };
1259
+ const plan = deriveActivePlanState(snapshot, laterRun.id);
1260
+ expect
1261
+ .soft(selectComposerTasksPlan(snapshot, plan, laterRun.id, false), status)
1262
+ .toMatchObject({
1263
+ runId: planRun.id,
1264
+ steps: [{ step: "Finish the current task", status: "pending" }],
1265
+ });
1266
+ }
1267
+ });
1268
+
1269
+ it.each(["codex", "claudeAgent"])(
1270
+ "drops retained Claude tasks only after a new %s session actually starts",
1271
+ (driver) => {
1272
+ const settled = {
1273
+ ...projection,
1274
+ providerThreads: [
1275
+ providerThread("claude-original", "claudeAgent"),
1276
+ providerThread("next-session", driver),
1277
+ ],
1278
+ runs: [run("run-1", 1, "claude-original")],
1279
+ };
1280
+ const nextRun = run("run-2", 2, "next-session");
1281
+ for (const status of ["queued", "cancelled"] as const) {
1282
+ const unstarted = {
1283
+ ...settled,
1284
+ runs: [
1285
+ ...settled.runs,
1286
+ {
1287
+ ...nextRun,
1288
+ status,
1289
+ startedAt: null,
1290
+ completedAt: status === "cancelled" ? now : null,
1291
+ },
1292
+ ],
1293
+ };
1294
+ expect
1295
+ .soft(
1296
+ selectComposerTasksPlan(unstarted, openList, nextRun.id, status === "cancelled"),
1297
+ `A ${status} run with an assigned provider thread has not switched sessions`,
1298
+ )
1299
+ .toBe(openList);
1300
+ }
1301
+
1302
+ const started = {
1303
+ ...settled,
1304
+ runs: [...settled.runs, { ...nextRun, status: "running" as const, completedAt: null }],
1305
+ };
1306
+ expect(selectComposerTasksPlan(started, openList, nextRun.id, false)).toBeNull();
1307
+ expect(
1308
+ selectComposerTasksPlan(
1309
+ { ...settled, runs: [...settled.runs, nextRun] },
1310
+ openList,
1311
+ nextRun.id,
1312
+ true,
1313
+ ),
1314
+ ).toBeNull();
1315
+ },
1316
+ );
1317
+});
1318
+
1319
describe("native provider presentation in the v2 timeline", () => {
1320
const timestamp = DateTime.makeUnsafe("2026-09-04T12:00:00.000Z");
1321
const base = {
apps/web/src/session-logic.ts
+46
-4
@@ -255,11 +255,22 @@ export function deriveActivePlanState(
255
latestRunId: RunId | undefined,
256
): ActivePlanState | null {
257
if (projection === null) return null;
258
- const plans = projection.plans.filter((plan) => plan.kind === "todo_list");
258
+ const plans = projection.plans
259
+ .filter((plan) => plan.kind === "todo_list")
260
+ .filter((plan) => plan.status !== "superseded");
261
+ const runOrdinals = new Map<RunId | null, number>(
262
+ projection.runs.map((run) => [run.id, run.ordinal]),
263
+ );
264
const plan =
260
- [...plans].toReversed().find((candidate) => candidate.runId === latestRunId) ??
261
- plans.at(-1) ??
262
- null;
265
+ plans.findLast((candidate) => candidate.runId === latestRunId) ??
266
+ plans.reduce<(typeof plans)[number] | null>(
267
+ (latest, candidate) =>
268
+ latest === null ||
269
+ (runOrdinals.get(candidate.runId) ?? -1) >= (runOrdinals.get(latest.runId) ?? -1)
270
+ ? candidate
271
+ : latest,
272
+ null,
273
+ );
274
if (plan === null || plan.steps.length === 0) return null;
275
return {
276
createdAt: planItemTime(projection, plan.id),
@@ -273,6 +284,37 @@ export function deriveActivePlanState(
284
};
285
}
286
287
+// Claude's unfinished tasks belong to the provider session, not just the turn.
288
+export function selectComposerTasksPlan(
289
+ projection: OrchestrationV2ThreadProjection | null,
290
+ plan: ActivePlanState | null,
291
+ activeRunId: RunId | null,
292
+ activeRunSettled: boolean,
293
+): ActivePlanState | null {
294
+ if (projection === null || plan === null) return null;
295
+ if (activeRunId !== null && !activeRunSettled && plan.runId === activeRunId) return plan;
296
+ if (plan.steps.every((step) => step.status === "completed")) return null;
297
+ const planProviderThreadId = projection.runs.find(
298
+ (run) => run.id === plan.runId,
299
+ )?.providerThreadId;
300
+ if (planProviderThreadId === undefined || planProviderThreadId === null) return null;
301
+ const planDriver = projection.providerThreads.find(
302
+ (providerThread) => providerThread.id === planProviderThreadId,
303
+ )?.driver;
304
+ if (planDriver !== "claudeAgent") return null;
305
+ let latestStartedRun: OrchestrationV2ThreadProjection["runs"][number] | null = null;
306
+ for (const run of projection.runs) {
307
+ if (
308
+ run.startedAt !== null &&
309
+ run.providerThreadId !== null &&
310
+ (latestStartedRun === null || run.ordinal > latestStartedRun.ordinal)
311
+ ) {
312
+ latestStartedRun = run;
313
+ }
314
+ }
315
+ return latestStartedRun?.providerThreadId === planProviderThreadId ? plan : null;
316
+}
317
+
318
function planItemTime(projection: OrchestrationV2ThreadProjection, planId: PlanId): string {
319
const item = projection.turnItems.findLast(
320
(candidate) =>
docs/user/providers-claude.md
+7
@@ -77,6 +77,13 @@ can still be started by you. Invoke those one per message: Claude directly runs
77
only the last named skill and may try to start earlier ones through its Skill
78
tool, which refuses skills reserved for manual invocation.
79
80
+## Task lists
81
+
82
+To show Claude task lists in the web and desktop apps, add
83
+`CLAUDE_CODE_ENABLE_TODO_TOOLS=1` under **Variables** in the Claude instance's
84
+**Environment** section in **Settings > Providers**. Unfinished tasks stay visible
85
+between turns in the same Claude session.
86
+
87
## OpenRouter
88
89
Create a Claude instance with its own config directory, such as