@devries-cameron20 / t3code Mirror · read-only / commits / 6670dc734e
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 23, 03:00 UTC

fix(web): a resumed subagent's notification row shows it running, not failed (#18099)

Co-authored-by: TinBane <363069+TinBane@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

TinBane committed Oct 19, 2026 at 06:33 UTC 6670dc734e9bb86e95fb6993e9de88f046a49f39
3 files changed +82 -5
apps/web/src/components/chat/V2LifecycleRow.logic.test.ts new
+41
@@ -0,0 +1,41 @@
1 +import * as DateTime from "effect/DateTime";
2 +import { describe, expect, it } from "vite-plus/test";
3 +
4 +import { subagentResumedSince } from "./V2LifecycleRow.logic";
5 +
6 +const failedAt = "2026-10-09T12:21:00.000Z";
7 +const beforeFailure = DateTime.makeUnsafe("2026-10-09T12:05:00.000Z");
8 +const afterFailure = DateTime.makeUnsafe("2026-10-09T12:48:00.000Z");
9 +
10 +describe("subagentResumedSince", () => {
11 + it("is true while a resumed subagent runs", () => {
12 + expect(subagentResumedSince({ status: "running", startedAt: afterFailure }, failedAt)).toBe(
13 + true,
14 + );
15 + });
16 +
17 + it("is true while it runs even when the notification was delivered after the resume", () => {
18 + expect(
19 + subagentResumedSince(
20 + { status: "running", startedAt: afterFailure },
21 + "2026-10-09T12:50:00.000Z",
22 + ),
23 + ).toBe(true);
24 + });
25 +
26 + it("is true once a run started after the notification has settled", () => {
27 + expect(subagentResumedSince({ status: "completed", startedAt: afterFailure }, failedAt)).toBe(
28 + true,
29 + );
30 + });
31 +
32 + it("is false for the run the notification reported on", () => {
33 + expect(subagentResumedSince({ status: "failed", startedAt: beforeFailure }, failedAt)).toBe(
34 + false,
35 + );
36 + });
37 +
38 + it("is false for a settled subagent with no start time", () => {
39 + expect(subagentResumedSince({ status: "failed", startedAt: null }, failedAt)).toBe(false);
40 + });
41 +});
apps/web/src/components/chat/V2LifecycleRow.logic.ts new
+27
@@ -0,0 +1,27 @@
1 +import type { OrchestrationV2Subagent } from "@t3tools/contracts";
2 +import * as DateTime from "effect/DateTime";
3 +
4 +const ACTIVE_SUBAGENT_STATUSES = new Set<OrchestrationV2Subagent["status"]>([
5 + "pending",
6 + "running",
7 + "waiting",
8 +]);
9 +
10 +/**
11 + * Whether a subagent started another run after a notification reported its
12 + * final outcome, so that outcome no longer describes it. Claude resumes a
13 + * finished subagent under the same id. An active subagent is always on a later
14 + * run, even when the notification was delivered late from the queue; a settled
15 + * one is on a later run when it started after the notification arrived.
16 + */
17 +export function subagentResumedSince(
18 + agent: Pick<OrchestrationV2Subagent, "status" | "startedAt">,
19 + notifiedAt: string,
20 +): boolean {
21 + if (ACTIVE_SUBAGENT_STATUSES.has(agent.status)) return true;
22 + if (agent.startedAt === null) return false;
23 + const notifiedAtMillis = Date.parse(notifiedAt);
24 + return (
25 + !Number.isNaN(notifiedAtMillis) && DateTime.toEpochMillis(agent.startedAt) > notifiedAtMillis
26 + );
27 +}
apps/web/src/components/chat/V2LifecycleRow.tsx
+14 -5
@@ -48,6 +48,7 @@ import { getTriggerDisplayModelName } from "./providerIconUtils";
48 import { ProviderInstanceIcon, providerTextColor } from "./ProviderInstanceIcon";
49 import { cn } from "~/lib/utils";
50 import { TimelineSystemDivider } from "./TimelineSystemDivider";
51 +import { subagentResumedSince } from "./V2LifecycleRow.logic";
52 import { Button, InlineButton } from "../ui/button";
53 import { T3Wordmark } from "../T3Wordmark";
54
@@ -357,6 +358,10 @@ export function SubagentNotificationLink(props: {
358 null,
359 );
360 if (agent === null) return props.fallback;
361 + // A subagent resumed since this notification shows its live status, not the outcome reported then.
362 + const resumed =
363 + NOTIFICATION_OUTCOME_STATUS[props.outcome] !== null &&
364 + subagentResumedSince(agent, props.createdAt);
365 return (
366 <SubagentTimelineLink
367 parentRef={props.parentRef}
@@ -372,11 +377,15 @@ export function SubagentNotificationLink(props: {
377 completedAt={agent.completedAt}
378 threadId={props.childThreadId}
379 onOpenThread={props.onOpenThread}
375 - event={{
376 - status: NOTIFICATION_OUTCOME_STATUS[props.outcome],
377 - label: NOTIFICATION_OUTCOME_LABEL[props.outcome],
378 - timestamp: formatShortTimestamp(props.createdAt, props.timestampFormat),
379 - }}
380 + {...(resumed
381 + ? {}
382 + : {
383 + event: {
384 + status: NOTIFICATION_OUTCOME_STATUS[props.outcome],
385 + label: NOTIFICATION_OUTCOME_LABEL[props.outcome],
386 + timestamp: formatShortTimestamp(props.createdAt, props.timestampFormat),
387 + },
388 + })}
389 />
390 );
391 }