Skip to content

Commit 6670dc7

Browse files
TinBaneclaude
andauthored
fix(web): a resumed subagent's notification row shows it running, not failed (pingdotgg#18099)
Co-authored-by: TinBane <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent b2877c4 commit 6670dc7

3 files changed

Lines changed: 82 additions & 5 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { getTriggerDisplayModelName } from "./providerIconUtils";
4848
import { ProviderInstanceIcon, providerTextColor } from "./ProviderInstanceIcon";
4949
import { cn } from "~/lib/utils";
5050
import { TimelineSystemDivider } from "./TimelineSystemDivider";
51+
import { subagentResumedSince } from "./V2LifecycleRow.logic";
5152
import { Button, InlineButton } from "../ui/button";
5253
import { T3Wordmark } from "../T3Wordmark";
5354

@@ -357,6 +358,10 @@ export function SubagentNotificationLink(props: {
357358
null,
358359
);
359360
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);
360365
return (
361366
<SubagentTimelineLink
362367
parentRef={props.parentRef}
@@ -372,11 +377,15 @@ export function SubagentNotificationLink(props: {
372377
completedAt={agent.completedAt}
373378
threadId={props.childThreadId}
374379
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+
})}
380389
/>
381390
);
382391
}

0 commit comments

Comments
 (0)