Record created threads and subagent progress

- Add parent-thread records for spawned child threads
- Persist Claude subagent progress as reasoning items
- Tighten projection verification around readable thread projections
This commit is contained in:
Julius Marminge authored and maria-rcks committed 2026-08-03 11:45:05 -04:00
1 parent 82ffe9862c
commit efdf72ec8c
26 files changed
+1081 -266

No files matched your search

+26 -5
View File
@@ -217,6 +217,7 @@ import {
useProject,
useProjects,
useThread,
useThreadShell,
useThreadProposedPlans,
useThreadRefs,
useThreadVisibleTurnItems,
@@ -1432,11 +1433,30 @@ function ChatViewContent(props: ChatViewProps) {
: undefined,
[draftThread, fallbackDraftProject?.defaultModelSelection, threadId],
);
// Promotion is data-driven: the draft route keeps rendering while the
// server thread (same pre-allocated ref) starts, so live state must not
// depend on which route is mounted.
const isServerThread = activeServerThread !== null;
const activeThread = activeServerThread ?? localDraftThread;
const isServerThread = routeKind === "server" && serverThread !== null;
const activeThread = isServerThread ? serverThread : localDraftThread;
const parentSubagentThreadId =
activeThread?.lineage.relationshipToParent === "subagent"
? activeThread.lineage.parentThreadId
: null;
const parentSubagentEnvironmentId = activeThread?.environmentId ?? null;
const parentSubagentThreadRef = useMemo(() => {
if (parentSubagentEnvironmentId === null || parentSubagentThreadId === null) {
return null;
}
return scopeThreadRef(parentSubagentEnvironmentId, parentSubagentThreadId);
}, [parentSubagentEnvironmentId, parentSubagentThreadId]);
const parentSubagentThread = useThreadShell(parentSubagentThreadRef);
const parentThreadLink = useMemo(
() =>
parentSubagentThreadRef === null
? null
: {
threadId: parentSubagentThreadRef.threadId,
title: parentSubagentThread?.title ?? "Parent thread",
},
[parentSubagentThread?.title, parentSubagentThreadRef],
);
const threadError = isServerThread
? (localServerError ?? serverThread?.runtime?.lastError ?? null)
: localDraftError;
@@ -5921,6 +5941,7 @@ function ChatViewContent(props: ChatViewProps) {
routeThreadKey={routeThreadKey}
onOpenTurnDiff={onOpenTurnDiff}
onOpenThread={onOpenRelatedThread}
parentThreadLink={parentThreadLink}
onForkFromRun={onForkFromRun}
onRollbackCheckpoint={(input) => void onRollbackCheckpoint(input)}
revertTurnCountByUserMessageId={revertTurnCountByUserMessageId}
@@ -482,6 +482,16 @@ describe("deriveMessagesTimelineRows", () => {
tone: "tool" as const,
},
},
{
id: "thread-created-entry",
kind: "event" as const,
createdAt: "2026-01-01T00:00:10Z",
projectedItem: {
item: {
type: "thread_created",
},
} as never,
},
{
id: "assistant-final-entry",
kind: "message" as const,
@@ -517,6 +527,7 @@ describe("deriveMessagesTimelineRows", () => {
expect(collapsedRows.map((row) => row.id)).toEqual([
"user-entry",
"turn-fold:turn-1",
"thread-created-entry",
"assistant-final-entry",
]);
@@ -534,6 +545,7 @@ describe("deriveMessagesTimelineRows", () => {
"turn-fold:turn-1",
"assistant-thought-entry",
"work-entry-1",
"thread-created-entry",
"assistant-final-entry",
]);
expect(
@@ -604,6 +616,17 @@ describe("deriveMessagesTimelineRows", () => {
tone: "tool" as const,
},
},
{
id: "superseded-thread-created-entry",
kind: "event" as const,
createdAt: "2026-01-01T00:00:04.500Z",
attempt: supersededAttempt,
projectedItem: {
item: {
type: "thread_created",
},
} as never,
},
{
id: "steer-user-entry",
kind: "message" as const,
@@ -654,6 +677,7 @@ describe("deriveMessagesTimelineRows", () => {
expect(collapsedRows.map((row) => row.id)).toEqual([
"initial-user-entry",
`attempt-fold:${supersededAttemptId}`,
"superseded-thread-created-entry",
"steer-user-entry",
"active-assistant-entry",
]);
@@ -673,6 +697,7 @@ describe("deriveMessagesTimelineRows", () => {
`attempt-fold:${supersededAttemptId}`,
"superseded-assistant-entry",
"superseded-work-entry",
"superseded-thread-created-entry",
"steer-user-entry",
"active-assistant-entry",
]);
@@ -1,8 +1,7 @@
import * as Equal from "effect/Equal";
import {
formatDuration,
workEntryIndicatesToolNeutralStatus,
workLogEntryIsToolLike,
timelineEntryIsPersistentResourceCard,
type TimelineEntry,
type WorkLogEntry,
} from "../../session-logic";
@@ -297,7 +296,8 @@ function deriveSupersededAttemptFolds(
for (const entry of timelineEntries) {
if (
entry.attempt?.status !== "superseded" ||
(entry.kind === "message" && entry.message.role === "user")
(entry.kind === "message" && entry.message.role === "user") ||
timelineEntryIsPersistentResourceCard(entry)
) {
continue;
}
@@ -1,4 +1,4 @@
import { EnvironmentId, MessageId, RunId } from "@t3tools/contracts";
import { EnvironmentId, MessageId, RunId, ThreadId } from "@t3tools/contracts";
import { createRef, type ReactNode, type Ref } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { beforeAll, describe, expect, it, vi } from "vite-plus/test";
@@ -439,6 +439,48 @@ describe("MessagesTimeline", () => {
expect(markup).toContain("rounded-2xl bg-accent p-3");
});
it("identifies user-role messages sent by another agent", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const entry = buildUserTimelineEntry("Review this area");
const agentMarkup = renderToStaticMarkup(
<MessagesTimeline
{...buildProps()}
timelineEntries={[
{
...entry,
message: { ...entry.message, createdBy: "agent", creationSource: "provider" },
},
]}
/>,
);
const userMarkup = renderToStaticMarkup(
<MessagesTimeline {...buildProps()} timelineEntries={[entry]} />,
);
expect(agentMarkup).toContain('data-user-message-attribution="agent"');
expect(agentMarkup).toContain("Sent by another agent");
expect(userMarkup).not.toContain("Sent by another agent");
});
it("keeps a subagent parent-thread link at the top of an empty timeline", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const markup = renderToStaticMarkup(
<MessagesTimeline
{...buildProps()}
timelineEntries={[]}
parentThreadLink={{
threadId: ThreadId.make("thread-parent"),
title: "Architecture audit",
}}
/>,
);
expect(markup).toContain('aria-label="Open parent thread"');
expect(markup).toContain("Subagent of");
expect(markup).toContain("Architecture audit");
expect(markup).not.toContain("Send a message to start the conversation");
});
it("keeps steer intent visible on committed user messages", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const entry = buildUserTimelineEntry("Adjust the current turn");
@@ -714,6 +756,108 @@ describe("MessagesTimeline", () => {
expect(markup).not.toContain("Structured details");
});
it("renders created threads as linked cards outside the work log", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const markup = renderToStaticMarkup(
<MessagesTimeline
{...buildProps()}
timelineEntries={[
{
id: "thread-created",
kind: "event",
createdAt: MESSAGE_CREATED_AT,
projectedItem: {
position: 0,
visibility: "local",
sourceThreadId: "thread-1",
sourceItemId: "thread-created",
item: {
id: "thread-created",
threadId: "thread-1",
runId: "run-1",
nodeId: "node-1",
providerThreadId: null,
providerTurnId: null,
nativeItemRef: null,
parentItemId: null,
ordinal: 1,
status: "completed",
title: "Claude research thread",
startedAt: null,
completedAt: null,
updatedAt: {},
type: "thread_created",
targetThreadId: "thread-2",
targetRunId: "run-2",
targetProviderInstanceId: "claude-default",
targetModel: "claude-sonnet-4-6",
},
} as never,
},
]}
/>,
);
expect(markup).toContain('data-v2-item-type="thread_created"');
expect(markup).toContain('aria-label="Open Claude research thread"');
expect(markup).toContain("Claude research thread");
expect(markup).toContain("claude-default · claude-sonnet-4-6");
expect(markup).not.toContain("Work Log");
});
it("renders live subagent progress on the persistent linked card", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const markup = renderToStaticMarkup(
<MessagesTimeline
{...buildProps()}
timelineEntries={[
{
id: "subagent-progress",
kind: "event",
createdAt: MESSAGE_CREATED_AT,
projectedItem: {
position: 0,
visibility: "local",
sourceThreadId: "thread-1",
sourceItemId: "subagent-progress",
item: {
id: "subagent-progress",
threadId: "thread-1",
runId: "run-1",
nodeId: "node-subagent-1",
providerThreadId: "provider-thread-1",
providerTurnId: "provider-turn-1",
nativeItemRef: null,
parentItemId: null,
ordinal: 1,
status: "running",
title: "Package audit",
startedAt: null,
completedAt: null,
updatedAt: {},
type: "subagent",
subagentId: "node-subagent-1",
origin: "provider_native",
driver: "claudeAgent",
providerInstanceId: "claudeAgent",
childThreadId: "thread-subagent-1",
prompt: "Inspect the package",
progress: "Reading src/index.ts",
result: null,
},
} as never,
},
]}
/>,
);
expect(markup).toContain('data-v2-item-type="subagent"');
expect(markup).toContain('aria-label="Open Package audit"');
expect(markup).toContain("Reading src/index.ts");
expect(markup).not.toContain("Inspect the package");
expect(markup).not.toContain("Work Log");
});
it("renders V2 provider failures as standalone error rows", async () => {
const { MessagesTimeline } = await import("./MessagesTimeline");
const markup = renderToStaticMarkup(
@@ -105,6 +105,7 @@ import { formatChatTimestampTooltip, formatShortTimestamp } from "../../timestam
import { V2ItemInspector } from "./V2ItemInspector";
import { useV2ItemSupport } from "../../state/v2ItemSupport";
import { isV2LifecycleItem, V2LifecycleRow } from "./V2LifecycleRow";
import { TimelineSystemDivider } from "./TimelineSystemDivider";
import {
buildInlineTerminalContextText,
@@ -181,6 +182,10 @@ interface MessagesTimelineProps {
routeThreadKey: string;
onOpenTurnDiff: (runId: RunId, filePath?: string) => void;
onOpenThread: (threadId: OrchestrationV2TurnItem["threadId"]) => void;
parentThreadLink?: {
readonly threadId: ThreadId;
readonly title: string;
} | null;
onForkFromRun: (input: {
readonly sourceThreadId: ThreadId;
readonly runId: RunId;
@@ -224,6 +229,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
routeThreadKey,
onOpenTurnDiff,
onOpenThread,
parentThreadLink = null,
onForkFromRun,
onRollbackCheckpoint,
revertTurnCountByUserMessageId,
@@ -499,6 +505,23 @@ export const MessagesTimeline = memo(function MessagesTimeline({
}),
[activeTurnInProgress, isRevertingCheckpoint, isWorking, latestTurn?.turnId],
);
const listHeader = useMemo(
() =>
parentThreadLink === null ? (
TIMELINE_LIST_HEADER
) : (
<div className="mx-auto w-full min-w-0 max-w-3xl pt-1 sm:pt-2">
<TimelineSystemDivider
label="Subagent of"
detail={parentThreadLink.title}
icon={GitForkIcon}
actionLabel="Open parent thread"
onAction={() => onOpenThread(parentThreadLink.threadId)}
/>
</div>
),
[onOpenThread, parentThreadLink],
);
// Stable renderItem — no closure deps. Row components read shared state
// from TimelineRowCtx, which propagates through LegendList's memo.
@@ -511,10 +534,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
[],
);
if (rows.length === 0 && !isWorking) {
if (hideEmptyPlaceholder) {
return null;
}
if (rows.length === 0 && !isWorking && parentThreadLink === null) {
return (
<div className="flex h-full items-center justify-center">
<p className="text-sm text-muted-foreground/30">
@@ -527,57 +547,24 @@ export const MessagesTimeline = memo(function MessagesTimeline({
return (
<TimelineRowCtx value={sharedState}>
<TimelineRowActivityCtx value={activityState}>
<div ref={setTimelineViewportElement} className="relative h-full min-h-0">
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
keyExtractor={keyExtractor}
getItemType={getItemType}
renderItem={renderItem}
estimatedItemSize={90}
initialScrollAtEnd
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
contentInsetEndAdjustment={contentInsetEndAdjustment}
maintainScrollAtEnd={
anchoredEndSpace
? false
: {
animated: false,
on: {
dataChange: true,
itemLayout: true,
layout: true,
},
}
}
maintainVisibleContentPosition={{
data: true,
size: false,
}}
onScroll={handleScroll}
className={cn(
"scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain px-3 [overflow-anchor:none] sm:px-5",
topFadeEnabled && "chat-timeline-scroll-fade",
)}
ListHeaderComponent={topFadeEnabled ? TIMELINE_LIST_FADE_HEADER : TIMELINE_LIST_HEADER}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
<TimelineMinimap
items={minimapItems}
bottomInset={contentInsetEndAdjustment}
hasPersistentGutter={minimapHasPersistentGutter}
hitStripWidth={minimapHitStripWidth}
stripMap={minimapStripMap}
onSelect={(item) => {
onManualNavigation();
void listRef.current?.scrollToIndex({
index: item.rowIndex,
animated: true,
viewOffset: 24,
});
}}
/>
</div>
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
keyExtractor={keyExtractor}
getItemType={getItemType}
renderItem={renderItem}
estimatedItemSize={90}
initialScrollAtEnd
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
contentInsetEndAdjustment={contentInsetEndAdjustment}
maintainScrollAtEnd={!foldToggleSettling}
maintainScrollAtEndThreshold={0.1}
maintainVisibleContentPosition
onScroll={handleScroll}
className="scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain px-3 sm:px-5"
ListHeaderComponent={listHeader}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
</TimelineRowActivityCtx>
</TimelineRowCtx>
);
@@ -937,7 +924,15 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
return (
<div className="group flex flex-col items-end gap-1">
<div className="relative max-w-[80%] rounded-2xl bg-accent p-3">
{row.message.createdBy === "agent" ? (
<p
className="me-1 text-[11px] text-muted-foreground/70"
data-user-message-attribution="agent"
>
Sent by another agent
</p>
) : null}
<div className="relative max-w-[80%] rounded-2xl border border-border bg-secondary p-3">
{regularImages.length > 0 && (
<div className="mb-2 grid max-w-[420px] grid-cols-2 gap-2">
{regularImages.map((image: NonNullable<TimelineMessage["attachments"]>[number]) => (
@@ -1332,7 +1327,7 @@ function v2EventPresentation(item: OrchestrationV2TurnItem): {
case "subagent":
return {
label: item.title ?? "Subagent",
detail: item.result ?? item.prompt,
detail: item.result ?? item.progress ?? item.prompt,
tone:
item.status === "failed" ? "danger" : item.status === "completed" ? "success" : "muted",
icon: HammerIcon,
@@ -0,0 +1,46 @@
import type { LucideIcon } from "lucide-react";
import { cn } from "~/lib/utils";
export function TimelineSystemDivider(props: {
readonly label: string;
readonly detail?: string | null;
readonly tone?: "neutral" | "danger";
readonly icon?: LucideIcon;
readonly actionLabel?: string;
readonly onAction?: () => void;
}) {
const Icon = props.icon;
const content = (
<>
{Icon ? <Icon className="size-3 shrink-0" /> : null}
<span className="font-medium">{props.label}</span>
{props.detail ? <span className="max-w-80 truncate opacity-70">· {props.detail}</span> : null}
</>
);
return (
<div
className={cn(
"flex min-w-0 items-center gap-2 py-2 text-[11px] text-muted-foreground",
props.tone === "danger" && "text-destructive",
)}
>
<span aria-hidden="true" className="h-px flex-1 bg-border/70" />
{props.onAction ? (
<button
type="button"
aria-label={props.actionLabel}
onClick={props.onAction}
className="flex min-w-0 items-center gap-1.5 rounded-full border border-border/70 bg-background px-2.5 py-1 transition-colors hover:bg-muted"
title={props.actionLabel}
>
{content}
</button>
) : (
<span className="flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1">{content}</span>
)}
<span aria-hidden="true" className="h-px flex-1 bg-border/70" />
</div>
);
}
+76 -61
View File
@@ -1,9 +1,17 @@
import type { OrchestrationV2TurnItem, ThreadId } from "@t3tools/contracts";
import type { TimestampFormat } from "@t3tools/contracts/settings";
import { GitForkIcon, HammerIcon, MinusIcon, XIcon, ZapIcon } from "lucide-react";
import {
ExternalLinkIcon,
GitForkIcon,
HammerIcon,
MessageSquareIcon,
MinusIcon,
XIcon,
ZapIcon,
} from "lucide-react";
import { cn } from "~/lib/utils";
import { formatShortTimestamp } from "../../timestampFormat";
import { TimelineSystemDivider } from "./TimelineSystemDivider";
const LIFECYCLE_TYPES = new Set<OrchestrationV2TurnItem["type"]>([
"run_interrupt_request",
@@ -12,6 +20,7 @@ const LIFECYCLE_TYPES = new Set<OrchestrationV2TurnItem["type"]>([
"handoff",
"fork",
"subagent",
"thread_created",
]);
export function isV2LifecycleItem(item: OrchestrationV2TurnItem): boolean {
@@ -46,7 +55,12 @@ export function V2LifecycleRow(props: {
}
if (item.type === "run_interrupt_result") {
return (
<SystemDivider label="Run interrupted" detail={item.message} tone="danger" icon={XIcon} />
<TimelineSystemDivider
label="Run interrupted"
detail={item.message}
tone="danger"
icon={XIcon}
/>
);
}
if (item.type === "compaction") {
@@ -55,7 +69,7 @@ export function V2LifecycleRow(props: {
? null
: `${item.beforeTokenCount ?? "?"} → ${item.afterTokenCount ?? "?"} tokens`;
return (
<SystemDivider
<TimelineSystemDivider
label="Context compacted"
detail={item.summary ?? tokenDetail}
icon={MinusIcon}
@@ -64,7 +78,7 @@ export function V2LifecycleRow(props: {
}
if (item.type === "handoff") {
return (
<SystemDivider
<TimelineSystemDivider
label="Context handoff"
icon={ZapIcon}
tone={item.status === "failed" ? "danger" : "neutral"}
@@ -78,7 +92,7 @@ export function V2LifecycleRow(props: {
if (item.type === "fork") {
const relatedThreadId = item.source.type === "run" ? item.source.threadId : item.targetThreadId;
return (
<SystemDivider
<TimelineSystemDivider
label={item.source.type === "run" ? "Forked from conversation" : "Conversation fork"}
icon={GitForkIcon}
actionLabel={item.source.type === "run" ? "Open source conversation" : "Open fork"}
@@ -86,75 +100,76 @@ export function V2LifecycleRow(props: {
/>
);
}
if (item.type === "subagent") {
const content = (
<>
<HammerIcon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 flex-1 truncate text-xs font-medium">
{item.title ?? "Subagent"}
</span>
<span className="max-w-[50%] truncate text-xs text-muted-foreground">
{item.result ?? item.prompt}
</span>
<span className="rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground">
{item.status}
</span>
</>
if (item.type === "thread_created") {
return (
<RelatedThreadCard
itemType={item.type}
icon={MessageSquareIcon}
title={item.title ?? "Created thread"}
detail={`${item.targetProviderInstanceId} · ${item.targetModel}`}
badge="created"
threadId={item.targetThreadId}
onOpenThread={props.onOpenThread}
/>
);
return item.childThreadId === null ? (
<div className="flex min-w-0 items-center gap-2 rounded-lg border border-border/60 bg-card/30 px-3 py-2">
{content}
</div>
) : (
<button
type="button"
onClick={() => item.childThreadId && props.onOpenThread(item.childThreadId)}
className="flex w-full min-w-0 items-center gap-2 rounded-lg border border-border/60 bg-card/30 px-3 py-2 text-left transition-colors hover:bg-muted/50"
>
{content}
</button>
}
if (item.type === "subagent") {
return (
<RelatedThreadCard
itemType={item.type}
icon={HammerIcon}
title={item.title ?? "Subagent"}
detail={item.result ?? item.progress ?? item.prompt}
badge={item.status}
threadId={item.childThreadId}
onOpenThread={props.onOpenThread}
/>
);
}
return null;
}
function SystemDivider(props: {
readonly label: string;
readonly detail?: string | null;
readonly tone?: "neutral" | "danger";
readonly icon?: typeof GitForkIcon;
readonly actionLabel?: string;
readonly onAction?: () => void;
function RelatedThreadCard(props: {
readonly itemType: "subagent" | "thread_created";
readonly icon: typeof HammerIcon;
readonly title: string;
readonly detail: string;
readonly badge: string;
readonly threadId: ThreadId | null;
readonly onOpenThread: (threadId: ThreadId) => void;
}) {
const Icon = props.icon;
const threadId = props.threadId;
const content = (
<>
{Icon ? <Icon className="size-3 shrink-0" /> : null}
<span className="font-medium">{props.label}</span>
{props.detail ? <span className="max-w-80 truncate opacity-70">· {props.detail}</span> : null}
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
<span className="min-w-0 flex-1 truncate text-xs font-medium">{props.title}</span>
<span className="max-w-[50%] truncate text-xs text-muted-foreground">{props.detail}</span>
<span className="rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground">
{props.badge}
</span>
{threadId === null ? null : (
<ExternalLinkIcon className="size-3 shrink-0 text-muted-foreground" aria-hidden="true" />
)}
</>
);
return (
return threadId === null ? (
<div
className={cn(
"flex min-w-0 items-center gap-2 py-2 text-[11px] text-muted-foreground",
props.tone === "danger" && "text-destructive",
)}
data-v2-item-type={props.itemType}
className="flex min-w-0 items-center gap-2 rounded-lg border border-border/60 bg-card/30 px-3 py-2"
>
<span aria-hidden="true" className="h-px flex-1 bg-border/70" />
{props.onAction ? (
<button
type="button"
onClick={props.onAction}
className="flex min-w-0 items-center gap-1.5 rounded-full border border-border/70 bg-background px-2.5 py-1 transition-colors hover:bg-muted"
title={props.actionLabel}
>
{content}
</button>
) : (
<span className="flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1">{content}</span>
)}
<span aria-hidden="true" className="h-px flex-1 bg-border/70" />
{content}
</div>
) : (
<button
type="button"
data-v2-item-type={props.itemType}
aria-label={`Open ${props.title}`}
onClick={() => props.onOpenThread(threadId)}
className="flex w-full min-w-0 items-center gap-2 rounded-lg border border-border/60 bg-card/30 px-3 py-2 text-left transition-colors hover:bg-muted/50"
>
{content}
</button>
);
}
@@ -3183,11 +3183,18 @@ function workLogRowContent(item: OrchestrationV2TurnItem): WorkLogRowContent {
preview: `→ ${compactId(item.targetThreadId) ?? item.targetThreadId}`,
tone: "muted",
};
case "thread_created":
return {
glyph: "↗",
label: item.title ?? "Thread created",
preview: `${item.targetProviderInstanceId} · ${item.targetModel}`,
tone: "emerald",
};
case "subagent":
return {
glyph: "↳",
label: item.title ?? "Subagent",
preview: clipOneLine(item.result ?? item.prompt, 120),
preview: clipOneLine(item.result ?? item.progress ?? item.prompt, 120),
tone: item.status === "completed" ? "emerald" : "sky",
};
case "user_message":
@@ -3647,7 +3654,7 @@ function ChatSubagentItem(props: {
readonly onOpenThread: (threadId: ThreadId) => void;
}) {
const label = props.item.title ?? "Subagent";
const detail = props.item.result ?? props.item.prompt;
const detail = props.item.result ?? props.item.progress ?? props.item.prompt;
const content = (
<>
<ToolKindPill kind="AGENT" />
+19 -1
View File
@@ -145,7 +145,7 @@ describe("V2 session presentation", () => {
expect(targets.has(steerMessageId)).toBe(false);
});
it("uses visible turn item order and keeps interruption lifecycle entries standalone", () => {
it("uses visible turn item order and keeps lifecycle resource entries standalone", () => {
const now = DateTime.makeUnsafe("2026-06-20T00:00:00.000Z");
const threadId = ThreadId.make("thread-visible");
const runId = RunId.make("run-visible");
@@ -213,6 +213,15 @@ describe("V2 session presentation", () => {
retryable: false,
},
} satisfies OrchestrationV2TurnItem;
const threadCreatedItem = {
...base("item-thread-created", 6),
type: "thread_created" as const,
title: "Follow-up thread",
targetThreadId: ThreadId.make("thread-follow-up"),
targetRunId: RunId.make("run-follow-up"),
targetProviderInstanceId: ProviderInstanceId.make("claude-default"),
targetModel: "claude-sonnet-4-6",
} satisfies OrchestrationV2TurnItem;
const visibleTurnItems: ReadonlyArray<OrchestrationV2ProjectedTurnItem> = [
userItem,
requestItem,
@@ -220,6 +229,7 @@ describe("V2 session presentation", () => {
resultItem,
todoItem,
errorItem,
threadCreatedItem,
].map((item, position) => ({
position,
visibility: "local" as const,
@@ -240,6 +250,7 @@ describe("V2 session presentation", () => {
["event", resultItem.id],
["work", todoItem.id],
["event", errorItem.id],
["event", threadCreatedItem.id],
]);
const commandEntry = entries[2];
const userEntry = entries[0];
@@ -247,6 +258,8 @@ describe("V2 session presentation", () => {
if (userEntry?.kind === "message") {
expect(userEntry.projectedItem).toBe(visibleTurnItems[0]);
expect(userEntry.message.inputIntent).toBe("turn_start");
expect(userEntry.message.createdBy).toBe("user");
expect(userEntry.message.creationSource).toBe("web");
}
expect(commandEntry?.kind).toBe("work");
if (commandEntry?.kind === "work") {
@@ -268,6 +281,11 @@ describe("V2 session presentation", () => {
expect(errorEntry.projectedItem.item.failure.message).toBe("Invalid reasoning effort.");
}
}
const threadCreatedEntry = entries[6];
expect(threadCreatedEntry?.kind).toBe("event");
if (threadCreatedEntry?.kind === "event") {
expect(threadCreatedEntry.projectedItem.item.type).toBe("thread_created");
}
});
it("resolves attempt identity through V2 execution nodes", () => {
+16
View File
@@ -338,9 +338,22 @@ const STANDALONE_V2_ITEM_TYPES = new Set<OrchestrationV2ProjectedTurnItem["item"
"run_interrupt_request",
"run_interrupt_result",
"subagent",
"thread_created",
"user_input_request",
]);
const PERSISTENT_RESOURCE_V2_ITEM_TYPES = new Set<OrchestrationV2TurnItem["type"]>([
"fork",
"subagent",
"thread_created",
]);
export function timelineEntryIsPersistentResourceCard(entry: TimelineEntry): boolean {
return (
entry.kind === "event" && PERSISTENT_RESOURCE_V2_ITEM_TYPES.has(entry.projectedItem.item.type)
);
}
function projectedItemCreatedAt(row: OrchestrationV2ProjectedTurnItem): string {
return DateTime.formatIso(row.item.startedAt ?? row.item.updatedAt);
}
@@ -530,6 +543,9 @@ export function deriveTimelineEntriesFromVisibleTurnItems(input: {
: {}),
runId: item.runId,
streaming: item.type === "assistant_message" && item.streaming,
...(item.type === "user_message"
? { createdBy: item.createdBy, creationSource: item.creationSource }
: {}),
createdAt,
updatedAt: DateTime.formatIso(item.updatedAt),
...(item.type === "user_message" ? { inputIntent: item.inputIntent } : {}),