@devries-cameron20 / t3code Mirror · read-only / commits / f47700849e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 12:00 UTC

fix(web): show the result of the notified delegated task (#22141)

Co-authored-by: GPT-6.1 Sol at high effort <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Alb11747 committed Oct 30, 2026 at 16:37 UTC f47700849e6f8c146cd022d3bdc6f3a045c9e98e
3 files changed +132 -6
apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
+124 -4
@@ -1,25 +1,30 @@
1 import { AudioPreview } from "../files/AudioPreview";
2 -import { onTestFinished } from "vite-plus/test";
2 import { page } from "vite-plus/test/browser";
4 -import { stubGlobal } from "../../../test/render";
3 import {
4 ComposerContextId,
5 EnvironmentId,
6 MessageId,
7 + NodeId,
8 + ProviderDriverKind,
9 + ProviderInstanceId,
10 RunAttemptId,
11 RunId,
12 RuntimeRequestId,
13 TurnItemId,
14 ScheduledTaskId,
15 ThreadId,
16 + type OrchestrationV2Subagent,
17 } from "@t3tools/contracts";
18 import type { LegendListRef } from "@legendapp/list/react";
19 import { createRef, Profiler, StrictMode, type ComponentProps, type ReactElement } from "react";
18 -import { describe, expect, it, vi } from "vite-plus/test";
20 +import * as DateTime from "effect/DateTime";
21 +import { Atom } from "effect/reactivity";
22 +import { describe, expect, it, onTestFinished, vi } from "vite-plus/test";
23
24 import "~/index.css";
25
22 -import { act, fakeTimers, render } from "../../../test/render";
26 +import { environmentThreadDetails } from "../../state/threads";
27 +import { act, fakeTimers, render, stubGlobal } from "../../../test/render";
28 import { MessagesTimeline } from "./MessagesTimeline";
29 import { makeStreamingTimelineFixture } from "../../test-fixtures";
30 import {
@@ -128,6 +133,43 @@ function message(
133 };
134 }
135
136 +function work(id: string, entry: Record<string, unknown>): Entry {
137 + return {
138 + id,
139 + kind: "work",
140 + createdAt: CREATED_AT,
141 + entry: { id, createdAt: CREATED_AT, ...entry },
142 + } as Entry;
143 +}
144 +
145 +function v2Item(type: string, fields: Record<string, unknown>) {
146 + const id = (fields.id as string | undefined) ?? type;
147 + return {
148 + position: 0,
149 + visibility: "local",
150 + sourceThreadId: "thread-1",
151 + sourceItemId: id,
152 + item: {
153 + id,
154 + threadId: "thread-1",
155 + runId: "run-1",
156 + nodeId: null,
157 + providerThreadId: null,
158 + providerTurnId: null,
159 + nativeItemRef: null,
160 + parentItemId: null,
161 + ordinal: 0,
162 + status: "completed",
163 + title: null,
164 + startedAt: null,
165 + completedAt: null,
166 + updatedAt: {},
167 + type,
168 + ...fields,
169 + },
170 + } as never;
171 +}
172 +
173 async function renderElement(element: ReactElement, options: { router?: false } = {}) {
174 const container = document.createElement("div");
175 container.style.cssText = "height: 1200px; width: 900px; display: flex; flex-direction: column;";
@@ -165,6 +207,84 @@ function setup({ scheduledTasks = [] as ReadonlyArray<{ id: string; title: strin
207 const TASK_ID = ScheduledTaskId.make("task-1");
208 const AUTOMATION_PROMPT = "Triage the inbox\n\nLabel every new issue and close duplicates.";
209
210 +describe("MessagesTimeline work rows", () => {
211 + it.each(["delegated", "legacy", "missing"] as const)(
212 + "uses the reported task for %s completion notifications",
213 + async (source) => {
214 + setup();
215 + const now = DateTime.makeUnsafe(CREATED_AT);
216 + const childThreadId = ThreadId.make("shared-child");
217 + const task = (
218 + id: string,
219 + status: OrchestrationV2Subagent["status"],
220 + result: string,
221 + ): OrchestrationV2Subagent => ({
222 + id: NodeId.make(id),
223 + threadId: ThreadId.make("thread-1"),
224 + runId: null,
225 + parentNodeId: NodeId.make("parent-root"),
226 + origin: "app_owned",
227 + createdBy: "agent",
228 + driver: ProviderDriverKind.make("claudeAgent"),
229 + providerInstanceId: ProviderInstanceId.make("claudeAgent"),
230 + providerThreadId: null,
231 + childThreadId,
232 + nativeTaskRef: null,
233 + prompt: "Simplify delivery",
234 + title: "Simplify delivery",
235 + model: null,
236 + status,
237 + result,
238 + startedAt: now,
239 + completedAt: now,
240 + updatedAt: now,
241 + });
242 + const tasks = [
243 + task("original", "interrupted", "Old interrupted progress"),
244 + task("continued", "completed", "Final implementation report"),
245 + task("follow-up", "completed", "Follow-up explanation"),
246 + ];
247 + using _threadAtom = vi.spyOn(environmentThreadDetails, "threadAtom").mockReturnValue(
248 + Atom.make({
249 + projection: { subagents: tasks, turnItems: [], visibleTurnItems: [] },
250 + }) as never,
251 + );
252 + const onOpenThread = vi.fn();
253 + await using screen = await renderTimeline(
254 + (source === "delegated" ? ["continued", "follow-up"] : [source]).map((id) =>
255 + work(`notification-${id}`, {
256 + label: "Notification fallback",
257 + tone: "info",
258 + itemType: "notification",
259 + projectedItem: v2Item("notification", {
260 + id: `notification-${id}`,
261 + source:
262 + source === "legacy"
263 + ? { kind: "subagent", childThreadId }
264 + : { kind: "delegated_task", childThreadId, taskIds: [NodeId.make(id)] },
265 + outcome: "completed",
266 + summary: "Notification fallback",
267 + }),
268 + }),
269 + ),
270 + { onOpenThread },
271 + );
272 + if (source === "delegated") {
273 + expect(screen.text()).toContain("Final implementation report");
274 + expect(screen.text()).toContain("Follow-up explanation");
275 + expect(screen.text()).not.toContain("Old interrupted progress");
276 + await click(screen.buttons("Open Simplify delivery")[0]!);
277 + expect(onOpenThread).toHaveBeenCalledWith(childThreadId);
278 + } else if (source === "legacy") {
279 + expect(screen.text()).toContain("Old interrupted progress");
280 + } else {
281 + expect(screen.text()).toContain("Notification fallback");
282 + expect(screen.text()).not.toContain("Old interrupted progress");
283 + }
284 + },
285 + );
286 +});
287 +
288 describe("MessagesTimeline messages", () => {
289 it("settles when equally long messages have very different rendered heights", async () => {
290 const props = baseProps();
apps/web/src/components/chat/TimelineWorkEntryRow.tsx
+1
@@ -160,6 +160,7 @@ export const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: WorkEn
160 <SubagentNotificationLink
161 parentRef={scopeThreadRef(ctx.activeThreadEnvironmentId, item.threadId)}
162 childThreadId={childThreadId}
163 + taskIds={item.source.kind === "delegated_task" ? item.source.taskIds : undefined}
164 outcome={item.outcome}
165 createdAt={props.workEntry.createdAt}
166 timestampFormat={ctx.timestampFormat}
apps/web/src/components/chat/V2LifecycleRow.tsx
+7 -2
@@ -311,17 +311,22 @@ const NOTIFICATION_OUTCOME_LABEL: Record<OrchestrationV2Notification["outcome"],
311 export function SubagentNotificationLink(props: {
312 readonly parentRef: ScopedThreadRef;
313 readonly childThreadId: ThreadId;
314 + readonly taskIds?: ReadonlyArray<NodeId> | undefined;
315 readonly outcome: OrchestrationV2Notification["outcome"];
316 readonly createdAt: string;
317 readonly timestampFormat: TimestampFormat;
318 readonly onOpenThread: (threadId: ThreadId) => void;
319 readonly fallback: ReactNode;
320 }) {
321 + // Follow-up tasks share a child conversation; this notice reports a particular task result.
322 const agent = useAtomValue(
323 environmentThreadDetails.threadAtom(props.parentRef),
324 (thread) =>
323 - thread?.projection.subagents.find((agent) => agent.childThreadId === props.childThreadId) ??
324 - null,
325 + thread?.projection.subagents.find((agent) =>
326 + props.taskIds === undefined
327 + ? agent.childThreadId === props.childThreadId
328 + : props.taskIds.includes(agent.id),
329 + ) ?? null,
330 );
331 if (agent === null) return props.fallback;
332 const resumed =