Skip to content
TypeScript

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

TinBane6670dc734e9b
diff --git a/apps/web/src/components/chat/V2LifecycleRow.logic.test.ts b/apps/web/src/components/chat/V2LifecycleRow.logic.test.ts
new file mode 100644
index 00000000000..ea25e827782
--- /dev/null
+++ b/apps/web/src/components/chat/V2LifecycleRow.logic.test.ts
@@ -0,0 +1,41 @@
+import * as DateTime from "effect/DateTime";
+import { describe, expect, it } from "vite-plus/test";
+
+import { subagentResumedSince } from "./V2LifecycleRow.logic";
+
+const failedAt = "2026-10-09T12:21:00.000Z";
+const beforeFailure = DateTime.makeUnsafe("2026-10-09T12:05:00.000Z");
+const afterFailure = DateTime.makeUnsafe("2026-10-09T12:48:00.000Z");
+
+describe("subagentResumedSince", () => {
+ it("is true while a resumed subagent runs", () => {
+ expect(subagentResumedSince({ status: "running", startedAt: afterFailure }, failedAt)).toBe(
+ true,
+ );
+ });
+
+ it("is true while it runs even when the notification was delivered after the resume", () => {
+ expect(
+ subagentResumedSince(
+ { status: "running", startedAt: afterFailure },
+ "2026-10-09T12:50:00.000Z",
+ ),
+ ).toBe(true);
+ });
+
+ it("is true once a run started after the notification has settled", () => {
+ expect(subagentResumedSince({ status: "completed", startedAt: afterFailure }, failedAt)).toBe(
+ true,
+ );
+ });
+
+ it("is false for the run the notification reported on", () => {
+ expect(subagentResumedSince({ status: "failed", startedAt: beforeFailure }, failedAt)).toBe(
+ false,
+ );
+ });
+
+ it("is false for a settled subagent with no start time", () => {
+ expect(subagentResumedSince({ status: "failed", startedAt: null }, failedAt)).toBe(false);
+ });
+});
diff --git a/apps/web/src/components/chat/V2LifecycleRow.logic.ts b/apps/web/src/components/chat/V2LifecycleRow.logic.ts
new file mode 100644
index 00000000000..583d86f2a00
--- /dev/null
+++ b/apps/web/src/components/chat/V2LifecycleRow.logic.ts
@@ -0,0 +1,27 @@
+import type { OrchestrationV2Subagent } from "@t3tools/contracts";
+import * as DateTime from "effect/DateTime";
+
+const ACTIVE_SUBAGENT_STATUSES = new Set<OrchestrationV2Subagent["status"]>([
+ "pending",
+ "running",
+ "waiting",
+]);
+
+/**
+ * Whether a subagent started another run after a notification reported its
+ * final outcome, so that outcome no longer describes it. Claude resumes a
+ * finished subagent under the same id. An active subagent is always on a later
+ * run, even when the notification was delivered late from the queue; a settled
+ * one is on a later run when it started after the notification arrived.
+ */
+export function subagentResumedSince(
+ agent: Pick<OrchestrationV2Subagent, "status" | "startedAt">,
+ notifiedAt: string,
+): boolean {
+ if (ACTIVE_SUBAGENT_STATUSES.has(agent.status)) return true;
+ if (agent.startedAt === null) return false;
+ const notifiedAtMillis = Date.parse(notifiedAt);
+ return (
+ !Number.isNaN(notifiedAtMillis) && DateTime.toEpochMillis(agent.startedAt) > notifiedAtMillis
+ );
+}
diff --git a/apps/web/src/components/chat/V2LifecycleRow.tsx b/apps/web/src/components/chat/V2LifecycleRow.tsx
index 194c288d6fc..3a59284ff4c 100644
--- a/apps/web/src/components/chat/V2LifecycleRow.tsx
+++ b/apps/web/src/components/chat/V2LifecycleRow.tsx
@@ -48,6 +48,7 @@ import { getTriggerDisplayModelName } from "./providerIconUtils";
import { ProviderInstanceIcon, providerTextColor } from "./ProviderInstanceIcon";
import { cn } from "~/lib/utils";
import { TimelineSystemDivider } from "./TimelineSystemDivider";
+import { subagentResumedSince } from "./V2LifecycleRow.logic";
import { Button, InlineButton } from "../ui/button";
import { T3Wordmark } from "../T3Wordmark";
@@ -357,6 +358,10 @@ export function SubagentNotificationLink(props: {
null,
);
if (agent === null) return props.fallback;
+ // A subagent resumed since this notification shows its live status, not the outcome reported then.
+ const resumed =
+ NOTIFICATION_OUTCOME_STATUS[props.outcome] !== null &&
+ subagentResumedSince(agent, props.createdAt);
return (
<SubagentTimelineLink
parentRef={props.parentRef}
@@ -372,11 +377,15 @@ export function SubagentNotificationLink(props: {
completedAt={agent.completedAt}
threadId={props.childThreadId}
onOpenThread={props.onOpenThread}
- event={{
- status: NOTIFICATION_OUTCOME_STATUS[props.outcome],
- label: NOTIFICATION_OUTCOME_LABEL[props.outcome],
- timestamp: formatShortTimestamp(props.createdAt, props.timestampFormat),
- }}
+ {...(resumed
+ ? {}
+ : {
+ event: {
+ status: NOTIFICATION_OUTCOME_STATUS[props.outcome],
+ label: NOTIFICATION_OUTCOME_LABEL[props.outcome],
+ timestamp: formatShortTimestamp(props.createdAt, props.timestampFormat),
+ },
+ })}
/>
);
}