Skip to content

Commit 792b19b

Browse files
committed
Overlay branch overlay/web-subagent-detail on top of origin/main via Merge
# Conflicts: # apps/web/src/components/chat/V2LifecycleRow.logic.ts * apps/web/src/components/chat/TimelineV2EventRow.tsx * apps/web/src/components/chat/V2LifecycleRow.logic.ts * apps/web/src/components/chat/V2LifecycleRow.tsx • 3d8207ba7c Overlay branch overlay/web-subagent-detail on top of origin/main via Merge |\ | • 0acb18c feat(web): subagent rows without a thread expand to show prompt and report • | becf853 fix(web): PDF search finds phrases that wrap across lines (pingdotgg#25702) • | 68339a0 refactor(mobile): pull request list, filters and viewed files without synchronizing effects (pingdotgg#25614) • | a2398c2 refactor(mobile): thread inspector mode is derived, not synced (pingdotgg#25682) • | 9bc0c33 refactor(mobile): settings use web's pages and groups (pingdotgg#25686) • | 5432d8e refactor(web): drafts promote from the draft store, not from route effects (pingdotgg#25615) • | bd3287b feat(web): thread state lives at the end of the timeline, not stacked on the composer (pingdotgg#25401)
2 parents becf853 + 0acb18c commit 792b19b

4 files changed

Lines changed: 168 additions & 43 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function V2EventTimelineRow({ row }: { row: Extract<TimelineRow, { kind:
4141
return (
4242
<V2LifecycleRow
4343
environmentId={ctx.activeThreadEnvironmentId}
44+
rowId={row.id}
4445
item={item}
4546
resourceSummary={row.resourceSummary}
4647
createdAt={row.createdAt}
@@ -308,6 +309,7 @@ const V2SubagentGroup = memo(function V2SubagentGroup({
308309
<V2LifecycleRow
309310
environmentId={ctx.activeThreadEnvironmentId}
310311
key={item.id}
312+
rowId={row.id}
311313
item={item}
312314
createdAt={row.createdAt}
313315
timestampFormat={ctx.timestampFormat}

‎apps/web/src/components/chat/V2LifecycleRow.logic.test.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as DateTime from "effect/DateTime";
22
import { describe, expect, it } from "vite-plus/test";
33

4-
import { subagentResumedSince } from "./V2LifecycleRow.logic";
4+
import { subagentInlineDetail, subagentResumedSince } from "./V2LifecycleRow.logic";
55

66
const failedAt = "2026-10-09T12:21:00.000Z";
77
const beforeFailure = DateTime.makeUnsafe("2026-10-09T12:05:00.000Z");
@@ -30,3 +30,32 @@ describe("subagentResumedSince", () => {
3030
);
3131
});
3232
});
33+
34+
describe("subagentInlineDetail", () => {
35+
it("shows the prompt and report of a subagent that has no thread to open", () => {
36+
expect(
37+
subagentInlineDetail({
38+
hasThread: false,
39+
prompt: " Find where models are labelled. ",
40+
report: "\nShort answer: no.\n",
41+
}),
42+
).toEqual({ prompt: "Find where models are labelled.", report: "Short answer: no." });
43+
});
44+
45+
it("leaves a subagent with its own thread to that thread", () => {
46+
expect(subagentInlineDetail({ hasThread: true, prompt: "Prompt", report: "Report" })).toBe(
47+
null,
48+
);
49+
});
50+
51+
it("drops the generic end-of-task line, and has nothing to show without text", () => {
52+
expect(
53+
subagentInlineDetail({
54+
hasThread: false,
55+
prompt: "Prompt",
56+
report: "Child task ended with status completed",
57+
}),
58+
).toEqual({ prompt: "Prompt", report: null });
59+
expect(subagentInlineDetail({ hasThread: false, prompt: " ", report: null })).toBe(null);
60+
});
61+
});

‎apps/web/src/components/chat/V2LifecycleRow.logic.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ const ACTIVE_SUBAGENT_STATUSES = new Set<OrchestrationV2Subagent["status"]>([
77
"waiting",
88
]);
99

10+
/** Some providers report this when a child ends without a report of its own. */
11+
export const GENERIC_CHILD_END = /^Child task ended with status\b/i;
12+
13+
/**
14+
* What a subagent row expands to. Providers that run subagents without a thread of their own
15+
* leave the prompt and report on the row, and touch screens cannot hover for its preview.
16+
*/
17+
export function subagentInlineDetail(input: {
18+
readonly hasThread: boolean;
19+
readonly prompt: string | null | undefined;
20+
readonly report: string | null | undefined;
21+
}): { readonly prompt: string | null; readonly report: string | null } | null {
22+
if (input.hasThread) return null;
23+
const prompt = input.prompt?.trim() || null;
24+
const trimmedReport = input.report?.trim();
25+
const report = trimmedReport && !GENERIC_CHILD_END.test(trimmedReport) ? trimmedReport : null;
26+
return prompt === null && report === null ? null : { prompt, report };
27+
}
28+
1029
/** Claude can reuse resumed agent ids. Active agents supersede outcomes; settled agents must start after notification. */
1130
export function subagentResumedSince(
1231
agent: Pick<OrchestrationV2Subagent, "status" | "startedAt">,

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

Lines changed: 117 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ThreadHoverCardPopup } from "../ThreadHoverCard";
2+
import ChatMarkdown from "../ChatMarkdown";
23
import { AgentElapsed } from "./AgentElapsed";
34
import { projectedSubagentsToRuntime } from "@t3tools/client-runtime/state/subagentRuntime";
4-
import type { ReactNode } from "react";
5+
import { type ReactNode, use, useState } from "react";
56
import { useThreadShell, useProject } from "../../state/entities";
67
import { SubagentTooltipContent } from "./SubagentTooltipContent";
78
import { useAtomValue } from "@effect/atom-react";
@@ -53,7 +54,12 @@ import { getTriggerDisplayModelName } from "./providerIconUtils";
5354
import { ProviderInstanceIcon, providerTextColor } from "./ProviderInstanceIcon";
5455
import { cn } from "~/lib/utils";
5556
import { TimelineSystemDivider } from "./TimelineSystemDivider";
56-
import { subagentResumedSince } from "./V2LifecycleRow.logic";
57+
import { TimelineRowCtx } from "./timelineRowContext";
58+
import {
59+
GENERIC_CHILD_END,
60+
subagentInlineDetail,
61+
subagentResumedSince,
62+
} from "./V2LifecycleRow.logic";
5763
import { Button, InlineButton } from "../ui/button";
5864
import { T3Wordmark } from "../T3Wordmark";
5965

@@ -75,6 +81,8 @@ export type { HandoffTimelineRun } from "@t3tools/client-runtime/handoff";
7581

7682
export function V2LifecycleRow(props: {
7783
readonly item: OrchestrationV2TurnItem;
84+
/** The timeline row this item renders in, which keeps its place when the row expands. */
85+
readonly rowId: string;
7886
readonly environmentId: EnvironmentId;
7987
readonly resourceSummary?: boolean | undefined;
8088
readonly createdAt: string;
@@ -199,11 +207,13 @@ export function V2LifecycleRow(props: {
199207
status={item.status}
200208
driver={item.driver}
201209
title={formatSubagentDisplayTitle(item.title ?? "Subagent")}
210+
prompt={item.prompt}
202211
result={item.result}
203212
progress={item.progress}
204213
startedAt={item.startedAt}
205214
completedAt={item.completedAt}
206215
threadId={item.childThreadId}
216+
anchorRowId={props.rowId}
207217
onOpenThread={props.onOpenThread}
208218
/>
209219
);
@@ -236,8 +246,6 @@ const SETTLED_SUBAGENT_STATUSES = new Set<OrchestrationV2TurnItem["status"]>([
236246
"interrupted",
237247
]);
238248

239-
const GENERIC_CHILD_END = /^Child task ended with status\b/i;
240-
241249
function plainDetail(text: string): string {
242250
return text
243251
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
@@ -371,6 +379,7 @@ export function SubagentNotificationLink(props: {
371379
status={agent.status}
372380
driver={agent.driver}
373381
title={formatSubagentDisplayTitle(agent.title ?? "Subagent")}
382+
prompt={agent.prompt}
374383
result={agent.result}
375384
progress={agent.progress}
376385
startedAt={agent.startedAt}
@@ -397,23 +406,30 @@ function SubagentTimelineLink(props: {
397406
readonly origin: OrchestrationV2Subagent["origin"];
398407
readonly driver: ProviderDriverKind;
399408
readonly title: string;
409+
readonly prompt: string;
400410
readonly result: string | null;
401411
readonly progress: string | undefined;
402412
readonly status: OrchestrationV2TurnItem["status"];
403413
readonly startedAt: DateTime.Utc | null;
404414
readonly completedAt: DateTime.Utc | null;
405415
readonly threadId: ThreadId | null;
416+
readonly anchorRowId?: string;
406417
readonly onOpenThread: (threadId: ThreadId) => void;
407418
readonly event?: {
408419
readonly status: OrchestrationV2TurnItem["status"] | null;
409420
readonly label: string;
410421
readonly timestamp: string;
411422
};
412423
}) {
424+
const ctx = use(TimelineRowCtx);
413425
const agent = useAtomValue(
414426
environmentThreadDetails.threadAtom(props.parentRef),
415427
(thread) => thread?.projection.subagents.find((agent) => agent.id === props.subagentId) ?? null,
416428
);
429+
const detailKey = `subagent-detail:${props.subagentId}`;
430+
const [expanded, setExpanded] = useState(() =>
431+
ctx.workGroupViewState.expandedEntries.has(detailKey),
432+
);
417433
const threadId = props.threadId;
418434
const liveStatus = agent?.status ?? props.status;
419435
const status = props.event ? props.event.status : liveStatus;
@@ -424,6 +440,18 @@ function SubagentTimelineLink(props: {
424440
const rawDetail = settled ? result || progress : progress || result;
425441
const detail =
426442
rawDetail && !GENERIC_CHILD_END.test(rawDetail) ? plainDetail(rawDetail) || null : null;
443+
const inlineDetail = subagentInlineDetail({
444+
hasThread: threadId !== null,
445+
prompt: agent?.prompt ?? props.prompt,
446+
report: rawDetail,
447+
});
448+
const toggleDetail = () => {
449+
const next = !expanded;
450+
ctx.onToggleWorkEntry(props.anchorRowId ?? detailKey, !next);
451+
if (next) ctx.workGroupViewState.expandedEntries.add(detailKey);
452+
else ctx.workGroupViewState.expandedEntries.delete(detailKey);
453+
setExpanded(next);
454+
};
427455
const failed = status === "failed";
428456
const timing = {
429457
status: liveStatus,
@@ -465,54 +493,101 @@ function SubagentTimelineLink(props: {
465493
<span className="shrink-0 text-xs text-muted-foreground tabular-nums">
466494
{props.event ? props.event.timestamp : <SubagentElapsed agent={timing} />}
467495
</span>
468-
{threadId !== null ? (
496+
{threadId !== null || inlineDetail !== null ? (
469497
<ChevronRightIcon
470498
aria-hidden
471-
className="size-3.5 shrink-0 text-muted-foreground/60 transition-colors group-hover/subagent:text-foreground"
499+
className={cn(
500+
"size-3.5 shrink-0 text-muted-foreground/60 transition-[color,transform] group-hover/subagent:text-foreground",
501+
threadId === null && expanded && "rotate-90",
502+
)}
472503
/>
473504
) : null}
474505
</>
475506
);
476507
const className =
477508
"group/subagent flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left";
509+
const interactiveClassName = cn(
510+
className,
511+
"cursor-pointer transition-colors hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
512+
);
478513
return (
479-
<Tooltip>
480-
<TooltipTrigger
481-
delay={200}
482-
render={
483-
threadId === null ? (
484-
<div data-v2-item-type="subagent" aria-description={statusLabel} className={className}>
485-
{content}
486-
</div>
487-
) : (
488-
<button
489-
type="button"
490-
data-v2-item-type="subagent"
491-
aria-label={`Open ${props.title}`}
492-
aria-description={statusLabel}
493-
onClick={() => props.onOpenThread(threadId)}
494-
className={cn(
495-
className,
496-
"cursor-pointer transition-colors hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
497-
)}
498-
>
499-
{content}
500-
</button>
501-
)
502-
}
503-
/>
504-
<ThreadHoverCardPopup>
505-
<SubagentTimelineTooltip
506-
{...props}
507-
elapsed={agent ? <AgentElapsed agent={projectedSubagentsToRuntime([agent])[0]!} /> : null}
508-
model={agent?.model ?? null}
509-
modelSelection={agent?.modelSelection}
510-
status={liveStatus}
511-
result={agent?.result ?? props.result}
512-
progress={agent?.progress ?? props.progress}
514+
<div>
515+
<Tooltip>
516+
<TooltipTrigger
517+
delay={200}
518+
render={
519+
threadId !== null ? (
520+
<button
521+
type="button"
522+
data-v2-item-type="subagent"
523+
aria-label={`Open ${props.title}`}
524+
aria-description={statusLabel}
525+
onClick={() => props.onOpenThread(threadId)}
526+
className={interactiveClassName}
527+
>
528+
{content}
529+
</button>
530+
) : inlineDetail !== null ? (
531+
<button
532+
type="button"
533+
data-v2-item-type="subagent"
534+
aria-expanded={expanded}
535+
aria-description={statusLabel}
536+
onClick={toggleDetail}
537+
className={interactiveClassName}
538+
>
539+
{content}
540+
</button>
541+
) : (
542+
<div
543+
data-v2-item-type="subagent"
544+
aria-description={statusLabel}
545+
className={className}
546+
>
547+
{content}
548+
</div>
549+
)
550+
}
513551
/>
514-
</ThreadHoverCardPopup>
515-
</Tooltip>
552+
<ThreadHoverCardPopup>
553+
<SubagentTimelineTooltip
554+
{...props}
555+
elapsed={
556+
agent ? <AgentElapsed agent={projectedSubagentsToRuntime([agent])[0]!} /> : null
557+
}
558+
model={agent?.model ?? null}
559+
modelSelection={agent?.modelSelection}
560+
status={liveStatus}
561+
result={agent?.result ?? props.result}
562+
progress={agent?.progress ?? props.progress}
563+
/>
564+
</ThreadHoverCardPopup>
565+
</Tooltip>
566+
{expanded && inlineDetail !== null ? (
567+
<div className="ms-10 me-2 mt-1 mb-2 space-y-2 text-xs">
568+
{inlineDetail.prompt !== null ? (
569+
<div>
570+
<p className="mb-1 text-3xs font-medium text-muted-foreground">Prompt</p>
571+
<p className="max-h-40 overflow-auto rounded-md border border-border/45 bg-muted/15 p-2 whitespace-pre-wrap break-words text-muted-foreground select-text">
572+
{inlineDetail.prompt}
573+
</p>
574+
</div>
575+
) : null}
576+
{inlineDetail.report !== null ? (
577+
<div>
578+
<p className="mb-1 text-3xs font-medium text-muted-foreground">Report</p>
579+
<ChatMarkdown
580+
text={inlineDetail.report}
581+
cwd={ctx.markdownCwd}
582+
threadRef={ctx.threadRef ?? undefined}
583+
skills={ctx.skills}
584+
lineBreaks
585+
/>
586+
</div>
587+
) : null}
588+
</div>
589+
) : null}
590+
</div>
516591
);
517592
}
518593

0 commit comments

Comments
 (0)