Skip to content

Commit 8edd798

Browse files
committed
feat(web): the agent's todo list shows as a line at the end of the thread
Since the composer tasks badge went away (pingdotgg#25401), todo progress only appears as Tasks rows folded into each turn's work log, so following an agent's plan means opening the turn. A Tasks line now sits above the goal line with the count and the current step. It shows while the list's run works, and after the turn ends while the same agent session still has steps left. The shared presentation lives in client-runtime next to the goal and background-work presentations. Droid (Claude Opus) in T3 Code
1 parent 7873f53 commit 8edd798

5 files changed

Lines changed: 140 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import {
7979
deriveThreadActivityRun,
8080
deriveLatestThreadRun,
8181
deriveThreadStructureRuntime,
82+
presentThreadTodoList,
8283
} from "@t3tools/client-runtime/state/thread-execution";
8384
import {
8485
resolveWorkflowOpening,
@@ -350,7 +351,7 @@ import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark";
350351
import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
351352
import { ChatRightPanel } from "./chat/ChatRightPanel";
352353
import { useDraftEnvironmentRouting } from "./chat/useDraftEnvironmentRouting";
353-
import { branchMismatchBannerItem } from "./chat/ThreadActivityBanners";
354+
import { branchMismatchBannerItem, tasksNowItem } from "./chat/ThreadActivityBanners";
354355
import { ThreadNow } from "./chat/ThreadNow";
355356
import { useDelayedStatus } from "../hooks/useDelayedStatus";
356357
import { useTimelineFollow } from "./chat/useTimelineFollow";
@@ -2921,9 +2922,13 @@ export default function ChatView(props: ChatViewProps) {
29212922
};
29222923
const onExpandTimelineImageStable = useStableCallback(onExpandTimelineImage);
29232924
const shownThreadSyncPhase = activeEnvironmentUnavailable ? null : delayedThreadSyncPhase;
2925+
const todoList = serverProjection ? presentThreadTodoList(serverProjection) : null;
2926+
const tasksNow =
2927+
todoList && activeThread ? tasksNowItem({ threadId: activeThread.id, todoList }) : null;
29242928
const hasThreadNow =
29252929
childInputNow !== null ||
29262930
backgroundWorkNow !== null ||
2931+
tasksNow !== null ||
29272932
goalNow !== null ||
29282933
shownThreadSyncPhase !== null;
29292934
const queuedRunCount = serverProjection ? getUserQueuedThreadRuns(serverProjection).length : 0;
@@ -2967,6 +2972,7 @@ export default function ChatView(props: ChatViewProps) {
29672972
attention={childInputNow}
29682973
work={backgroundWorkNow}
29692974
syncPhase={shownThreadSyncPhase}
2975+
tasks={tasksNow}
29702976
goal={goalNow}
29712977
/>
29722978
{threadStatusLine}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
77
import {
88
presentPendingBackgroundWork,
99
presentProviderGoal,
10+
type ThreadTodoListPresentation,
1011
} from "@t3tools/client-runtime/state/thread-execution";
1112
import { childThreadInputsTitle } from "@t3tools/client-runtime/state/threads";
12-
import { GitBranchIcon, MessageCircleIcon, ShieldQuestionIcon, TargetIcon } from "lucide-react";
13+
import {
14+
GitBranchIcon,
15+
ListTodoIcon,
16+
MessageCircleIcon,
17+
ShieldQuestionIcon,
18+
TargetIcon,
19+
} from "lucide-react";
1320
import { Fragment } from "react";
1421
import { cn } from "~/lib/utils";
1522
import { Button, InlineButton } from "../ui/button";
@@ -95,6 +102,19 @@ export function goalNowItem(input: {
95102
};
96103
}
97104

105+
/** The agent's todo list progress, for the end of the timeline. */
106+
export function tasksNowItem(input: {
107+
readonly threadId: ThreadId;
108+
readonly todoList: ThreadTodoListPresentation;
109+
}): ThreadNowItem {
110+
return {
111+
id: `tasks:${input.threadId}`,
112+
icon: <ListTodoIcon />,
113+
title: input.todoList.title,
114+
description: input.todoList.current ?? undefined,
115+
};
116+
}
117+
98118
/** Background commands and subagents, for the end of the timeline. */
99119
export function backgroundWorkNowItem(input: {
100120
readonly threadId: ThreadId;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,28 @@ function ThreadSyncLine({ phase }: { readonly phase: ThreadSyncPhase }) {
7979

8080
/**
8181
* What the thread is doing now, at the end of the timeline: what needs you, background work,
82-
* the sync status while messages load, then the goal.
82+
* the sync status while messages load, then the agent's tasks and goal.
8383
*/
8484
export function ThreadNow({
8585
attention,
8686
work,
8787
syncPhase,
88+
tasks,
8889
goal,
8990
}: {
9091
/** Something that needs you elsewhere, such as a subagent's question. */
9192
readonly attention: ThreadNowItem | null;
9293
readonly work: ThreadNowItem | null;
9394
readonly syncPhase: ThreadSyncPhase | null;
95+
readonly tasks: ThreadNowItem | null;
9496
readonly goal: ThreadNowItem | null;
9597
}): ReactNode {
9698
return (
9799
<>
98100
{attention ? <ThreadNowLine item={attention} announce /> : null}
99101
{work ? <ThreadNowLine item={work} /> : null}
100102
{syncPhase ? <ThreadSyncLine phase={syncPhase} /> : null}
103+
{tasks ? <ThreadNowLine item={tasks} /> : null}
101104
{goal ? <ThreadNowLine item={goal} /> : null}
102105
</>
103106
);

‎packages/client-runtime/src/state/threadExecution.test.ts‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
TurnItemId,
33
NodeId,
44
MessageId,
5+
PlanId,
56
ProviderInstanceId,
67
ProviderThreadId,
78
ProviderSessionId,
@@ -11,6 +12,7 @@ import {
1112
RunId,
1213
ThreadId,
1314
type OrchestrationV2ExecutionNode,
15+
type OrchestrationV2PlanStep,
1416
type OrchestrationV2RunStatus,
1517
} from "@t3tools/contracts";
1618
import * as DateTime from "effect/DateTime";
@@ -25,6 +27,7 @@ import {
2527
deriveRunlessWorkStartedAt,
2628
deriveThreadActivityRun,
2729
deriveThreadRuntime,
30+
presentThreadTodoList,
2831
threadRuntimeHasInterruptibleRun,
2932
} from "./threadExecution.ts";
3033

@@ -393,3 +396,67 @@ describe("provider-reported model selection", () => {
393396
).toBeNull();
394397
});
395398
});
399+
400+
describe("presentThreadTodoList", () => {
401+
const session = ProviderThreadId.make("session-thread");
402+
const sessionRun = (id: string, ordinal: number, status: OrchestrationV2RunStatus) => ({
403+
...run(id, ordinal, status),
404+
providerThreadId: session,
405+
});
406+
const todoList = (runId: string, statuses: ReadonlyArray<OrchestrationV2PlanStep["status"]>) => ({
407+
id: PlanId.make(`plan-${runId}`),
408+
threadId: v2Projection.thread.id,
409+
runId: RunId.make(runId),
410+
nodeId: NodeId.make(`node-${runId}`),
411+
kind: "todo_list" as const,
412+
status: "active" as const,
413+
steps: statuses.map((status, index) => ({ id: `${index}`, text: `Step ${index}`, status })),
414+
});
415+
const projection = (
416+
runs: ReadonlyArray<ReturnType<typeof sessionRun>>,
417+
plans: ReadonlyArray<ReturnType<typeof todoList>>,
418+
) => ({
419+
...v2Projection,
420+
thread: { ...v2Projection.thread, activeProviderThreadId: session },
421+
runs,
422+
plans,
423+
});
424+
425+
it("shows the latest list's progress and current step while its run works", () => {
426+
const earlier = sessionRun("earlier", 1, "completed");
427+
expect(
428+
presentThreadTodoList(
429+
projection(
430+
[earlier, sessionRun("current", 2, "running")],
431+
[
432+
todoList("current", ["completed", "running", "pending"]),
433+
todoList("earlier", ["pending"]),
434+
],
435+
),
436+
),
437+
).toEqual({ title: "Tasks 1/3", current: "Step 1" });
438+
expect(
439+
presentThreadTodoList(
440+
projection(
441+
[earlier, sessionRun("current", 2, "running")],
442+
[todoList("current", ["completed", "completed"])],
443+
),
444+
),
445+
).toEqual({ title: "Tasks 2/2", current: null });
446+
});
447+
448+
it("keeps unfinished tasks after the turn until they finish or another session takes over", () => {
449+
const ended = sessionRun("ended", 1, "completed");
450+
const unfinished = projection([ended], [todoList("ended", ["completed", "pending"])]);
451+
expect(presentThreadTodoList(unfinished)).toEqual({ title: "Tasks 1/2", current: "Step 1" });
452+
expect(
453+
presentThreadTodoList(projection([ended], [todoList("ended", ["completed", "completed"])])),
454+
).toBeNull();
455+
expect(
456+
presentThreadTodoList({
457+
...unfinished,
458+
thread: { ...unfinished.thread, activeProviderThreadId: ProviderThreadId.make("other") },
459+
}),
460+
).toBeNull();
461+
});
462+
});

‎packages/client-runtime/src/state/threadExecution.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,47 @@ export function presentProviderGoal(
408408
};
409409
}
410410

411+
export interface ThreadTodoListPresentation {
412+
readonly title: string;
413+
readonly current: string | null;
414+
}
415+
416+
type ThreadTodoList = Extract<ThreadStructure["plans"][number], { readonly kind: "todo_list" }>;
417+
418+
/** The latest todo list while its run works, or after it while the same session has steps left. */
419+
export function presentThreadTodoList(
420+
projection: ThreadStructure,
421+
): ThreadTodoListPresentation | null {
422+
const runs = new Map(projection.runs.map((run) => [run.id, run]));
423+
let latest: {
424+
readonly plan: ThreadTodoList;
425+
readonly run: OrchestrationV2ThreadProjection["runs"][number];
426+
} | null = null;
427+
for (const plan of projection.plans) {
428+
if (plan.kind !== "todo_list" || plan.status === "superseded" || plan.runId === null) continue;
429+
const run = runs.get(plan.runId);
430+
if (run !== undefined && (latest === null || run.ordinal >= latest.run.ordinal)) {
431+
latest = { plan, run };
432+
}
433+
}
434+
if (latest === null || latest.plan.steps.length === 0) return null;
435+
const { plan, run } = latest;
436+
const done = plan.steps.filter((step) => step.status === "completed").length;
437+
if (
438+
!ACTIVITY_RUN_STATUSES.has(run.status) &&
439+
(done === plan.steps.length ||
440+
plan.status === "completed" ||
441+
run.providerThreadId === null ||
442+
run.providerThreadId !== projection.thread.activeProviderThreadId)
443+
) {
444+
return null;
445+
}
446+
const current =
447+
plan.steps.find((step) => step.status === "running") ??
448+
plan.steps.find((step) => step.status === "pending");
449+
return { title: `Tasks ${done}/${plan.steps.length}`, current: current?.text ?? null };
450+
}
451+
411452
export function notificationChildThreadId(
412453
source: OrchestrationV2NotificationSource,
413454
): ThreadId | undefined {

0 commit comments

Comments
 (0)