@@ -412,13 +412,14 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
const showDestructiveRowStyle =
!showWarningIndicator &&
showFailedIndicator &&
- (workEntrySignalsSevereFailure(workEntry) || !workLogEntryIsToolLike(workEntry));
- const entryIconName =
- showWarningIndicator || showDestructiveRowStyle ? "circle-alert" : workEntryIconName(workEntry);
- const entryToolIcon =
- showWarningIndicator || showDestructiveRowStyle
- ? undefined
- : (workEntry.toolIcon ?? workEntry.toolSource?.icon);
+ (severeFailure ||
+ workEntrySignalsSevereFailure(workEntry) ||
+ !workLogEntryIsToolLike(workEntry));
+ const replacesIcon = showWarningIndicator || (showDestructiveRowStyle && !severeFailure);
+ const entryIconName = replacesIcon ? "circle-alert" : workEntryIconName(workEntry);
+ const entryToolIcon = replacesIcon
+ ? undefined
+ : (workEntry.toolIcon ?? workEntry.toolSource?.icon);
const isReasoning = workEntry.itemType === "reasoning";
const questionHeading = workEntry.questionAnswer
? getQuestionTextPreview(workEntry.questionAnswer)
@@ -429,14 +430,12 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
? gt("Thinking")
: gt("Thought")
: questionHeading || (displayLabel ?? workEntryDisplayLabel(workEntry, workspaceRoot, m));
- // Re-tier only an existing action prefix; command-only labels keep their exact text.
- const actionParts =
- workLogEntryIsToolLike(workEntry) && !isReasoning
- ? /^(Read|Reading|Ran|Running|Edited|Editing|Created|Creating|Deleted|Deleting|Searched|Searching|Listed|Listing|Opened|Opening|Updated|Updating|Fetched|Fetching|Called|Calling)(\s+)(.+)$/s.exec(
- previewText,
- )
+ const editItem = workEntry.projectedItem?.item ?? workEntry.structuredPayload;
+ const editCounts =
+ editItem?.type === "file_change" &&
+ (editItem.additions !== undefined || editItem.deletions !== undefined)
+ ? { additions: editItem.additions ?? 0, deletions: editItem.deletions ?? 0 }
: null;
- const targetIsCode = Boolean(workEntry.command || workEntry.changedFiles?.length);
const answerPreview =
workEntry.questionAnswer && hasQuestionAnswer(workEntry.questionAnswer)
? getQuestionAnswerPreview(workEntry.questionAnswer)
@@ -479,18 +478,15 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
? (preview: ExpandedImagePreview) =>
onImageExpand(workGroupImageGallery(groupViewedImages, viewedImagePath, preview))
: onImageExpand;
- const canExpand =
- previewText.trim().length > 0 ||
- (workEntry.itemType === "dynamic_tool" && workEntry.toolData !== undefined) ||
- Boolean(
- workEntryRawCommand(workEntry) ||
- workEntry.command?.trim() ||
- workEntry.detail?.trim() ||
- workEntry.changedFiles?.length ||
- viewedImage,
- );
+ const inspectedItem =
+ plainOutput === undefined &&
+ workEntry.projectedItem &&
+ v2ItemInspectorHasContent(workEntry.projectedItem.item)
+ ? workEntry.projectedItem
+ : undefined;
+ // Check the body before offering a disclosure, including for non-projected entries.
const expandedBody =
- expanded && !isReasoning
+ (expanded || !inspectedItem) && !isReasoning
? plainOutput !== undefined
? plainOutput
: buildToolCallExpandedBody(
@@ -507,18 +503,16 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
turnItemNeedsDetailFetch(workEntry.projectedItem.item);
// A notice's details repeat its row, so it expands only to show text the row cuts off.
const canExpandProjectedItem =
+ expandable &&
(noticeMessage === null || noticeCutOff) &&
- (plainOutput !== undefined
- ? Boolean(plainOutput || viewedImage || workEntry.questionAnswer || plainOutputFetches)
- : workEntry.projectedItem === undefined
- ? canExpand
- : isReasoning
- ? Boolean(workEntry.detail?.trim())
- : Boolean(
- viewedImage ||
- workEntry.questionAnswer ||
- turnItemHasDetail(workEntry.projectedItem.item),
- ));
+ Boolean(
+ expandedBody ||
+ inspectedItem ||
+ viewedImage ||
+ workEntry.questionAnswer ||
+ plainOutputFetches ||
+ (isReasoning && workEntry.detail?.trim()),
+ );
const iconWrapperClass = cn(
"flex size-3.5 items-center justify-center",
showWarningIndicator
@@ -532,16 +526,24 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
: iconConfig.className,
);
const headingClass = showWarningIndicator
- ? "font-medium text-warning-foreground"
+ ? "font-medium text-warning"
: showDestructiveRowStyle
- ? "font-medium text-error-foreground"
- : targetIsCode && !actionParts && workLogEntryIsToolLike(workEntry)
- ? "font-sans font-normal text-dim-foreground"
- : "font-medium text-foreground";
+ ? "font-medium text-destructive"
+ : workLogEntryIsToolLike(workEntry)
+ ? "text-secondary-label"
+ : "text-foreground/80";
const threadLabel = isReasoning ? null : threadReadLabel(previewText, workEntry, threadTarget, m);
- const accessiblePreview = [threadLabel?.text ?? previewText, answerPreview]
+ const accessiblePreview = [
+ [threadLabel?.text ?? previewText, answerPreview].filter(Boolean).join(": "),
+ editCounts
+ ? gt(
+ "{additions, plural, one {{additions} addition} other {{additions} additions}}, {deletions, plural, one {{deletions} deletion} other {{deletions} deletions}}",
+ editCounts,
+ )
+ : null,
+ ]
.filter(Boolean)
- .join(": ");
+ .join(", ");
const accessibleDisplayText = showFailedIndicator
? gt("{label}, tool call failed", { label: accessiblePreview })
: accessiblePreview;
@@ -583,11 +585,11 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
}
label={
-
+
- ) : actionParts ? (
- <>
- {actionParts[1]}
- {actionParts[2]}
-
- {actionParts[3]}
-
- >
) : (
previewText
)}
+ {editCounts ? (
+
+ +{editCounts.additions} −{editCounts.deletions}
+
+ ) : null}
{answerPreview ? (
- {/* First, so revealing it takes label space instead of moving the controls. Notices
- skip it, so hovering never changes what fits or moves Sign in. */}
- {noticeMessage === null ? (
-
- ) : null}
{createdThread ? (
) : null}
{canExpandProjectedItem ? (
-
-
-
+
) : null}
>
}
@@ -722,14 +715,12 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
!isReasoning &&
!workEntry.questionAnswer &&
canExpandProjectedItem &&
- (expandedBody ||
- plainOutputFetches ||
- (workEntry.projectedItem && plainOutput === undefined)) ? (
+ (expandedBody || inspectedItem || plainOutputFetches) ? (
- {workEntry.projectedItem && plainOutput === undefined ? (
+ {inspectedItem ? (
formatWorkingTimerNow(createdAt, activeThreadEnvironmentId), true)}
+ ref={tickTextContent(
+ () => formatWorkingTimerNow(createdAt, activeThreadEnvironmentId, clock),
+ true,
+ )}
className="tabular-nums"
/>
);
@@ -358,14 +404,67 @@ function ExpandedWorkGroupEntries({
const workEntryKey = (entry: TimelineWorkEntry) => entry.id;
export function WorkingTimelineRow({ row }: { row: Extract }) {
- const { isCompacting, isPreparingWorktree, backgroundWorktreeSetup } =
- use(TimelineRowActivityCtx);
- const compacting = row.compacting === true || isCompacting;
- const shimmer = isPreparingWorktree || compacting;
+ const ctx = use(TimelineRowCtx);
+ const gt = useGT();
+ const {
+ isCompacting,
+ isPreparingWorktree,
+ backgroundWorktreeSetup,
+ pendingRequest,
+ providerStartingLabel,
+ providerStarting,
+ } = use(TimelineRowActivityCtx);
+ const window = row.window;
+ const [fit, onOverflowChange] = useReducer(
+ (current: { overflows: boolean; fade: boolean }, overflows: boolean) =>
+ current.overflows === overflows ? current : { overflows, fade: current.fade || !overflows },
+ { overflows: false, fade: false },
+ );
+ if (
+ window?.compactCommand &&
+ window.items.length === 0 &&
+ !window.stopping &&
+ !pendingRequest &&
+ !isPreparingWorktree &&
+ !backgroundWorktreeSetup
+ )
+ return null;
+ const compacting =
+ row.compacting !== undefined || isCompacting || workingWindowHasActiveCompaction(window);
const label = isPreparingWorktree ? (
Setting up worktree…
+ ) : window?.stopping ? (
+ Stopping…
+ ) : pendingRequest && row.createdAt ? (
+ // The clock stops while the turn waits on the user.
+ gt("Paused at {time}", {
+ time: formatWorkingTimer(row.createdAt, pendingRequest.createdAt) ?? "0s",
+ })
) : compacting ? (
-
+
+
+ {row.createdAt ? (
+
+ Compacting for
+
+ ) : (
+ Compacting…
+ )}
+
+ ) : providerStartingLabel ? (
+ // Until the provider opens a turn, the run is still launching it.
+ providerStarting ? (
+
+
+ {providerStartingLabel}
+
+ ) : (
+ providerStartingLabel
+ )
) : row.createdAt ? (
Working for
@@ -373,20 +472,45 @@ export function WorkingTimelineRow({ row }: { row: ExtractWorking...
);
+ const historyOpen = window?.historyOpen ?? false;
+ const foldable =
+ window !== undefined && (historyOpen || (fit.overflows && window.items.length > 0));
return (
-
-
-
+
+
{
+ if (window) ctx.onToggleWorkingHistory(window.key);
+ }}
>
- {label}
- {shimmer ? {label} : null}
-
+
+ {label}
+ {isPreparingWorktree ? {label} : null}
+
+
{backgroundWorktreeSetup ? (
) : null}
+
+ {window ? : null}
+
+ {window ? (
+
+ ) : null}
);
}
@@ -431,23 +555,6 @@ function BackgroundWorktreeSetupChip({ snapshot }: { snapshot: WorktreeSetupSnap
);
}
-function CompactingLabel({ createdAt }: { createdAt: string | null }) {
- return (
-
-
- {createdAt ? (
-
-
- Compacting for
-
-
- ) : (
- Compacting…
- )}
-
- );
-}
-
export function ThinkingTimelineRow({ row }: { row: Extract
}) {
const ctx = use(TimelineRowCtx);
const gt = useGT();
@@ -462,6 +569,7 @@ export function ThinkingTimelineRow({ row }: { row: Extract ;
// A failed group keeps this disclosure while an approval waits, but nothing is thinking then.
const live = ctx.pendingApprovals.size === 0;
+ const { groupId } = row;
const activity = (
);
- const { groupId } = row;
if (groupId === undefined) return activity;
return (
+
+
+
);
}
@@ -523,7 +631,6 @@ function LiveActivityRow({
toolIcon,
failed = false,
active = false,
- shimmer = false,
}: {
label: ReactNode;
iconName?: WorkEntryIconName;
@@ -532,14 +639,13 @@ function LiveActivityRow({
toolIcon?: ToolActivityIcon | undefined;
failed?: boolean;
active?: boolean;
- shimmer?: boolean;
}) {
- const animated = active && !failed;
- const showShimmer = animated && shimmer;
+ const { isWorking, pendingRequest, turnEnded } = use(TimelineRowActivityCtx);
+ const animated = isWorking && active && !failed && !pendingRequest && !turnEnded;
return (
- {showShimmer ? (
+ {animated ? (
- {label}
-
+ {label}
}
trailing={
showTrailingFailureMark ? (
@@ -752,8 +847,6 @@ export function WorkGroupToggleTimelineRow({
toolIcon={row.toolIcon}
failed={row.hasFailure}
expanded={row.expanded}
- createdAt={row.createdAt}
- timestampFormat={ctx.timestampFormat}
onToggle={() => ctx.onToggleWorkGroup(row.groupId, row.id)}
/>
);
@@ -765,8 +858,6 @@ function WorkGroupHeader(props: {
toolIcon?: ToolActivityIcon | undefined;
failed?: boolean | undefined;
expanded: boolean;
- createdAt: string;
- timestampFormat: TimestampFormat;
onToggle: () => void;
}) {
const gt = useGT();
@@ -785,9 +876,653 @@ function WorkGroupHeader(props: {
muted
/>
}
- label={{props.label} }
+ label={{props.label} }
+ />
+ );
+}
+
+export function BackgroundActivityTimelineRow({
+ row,
+}: {
+ row: Extract;
+}) {
+ const ctx = use(TimelineRowCtx);
+ const gt = useGT();
+ const label = row.active
+ ? gt("{count, plural, one {{count} wake-up…} other {{count} wake-ups…}}", {
+ count: row.updateCount,
+ })
+ : gt("{count, plural, one {{count} wake-up} other {{count} wake-ups}}", {
+ count: row.updateCount,
+ });
+ const summary = row.updates.map((update) => update.summary).join(", ");
+ const sources = new Map();
+ for (const update of row.updates) {
+ sources.set(update.source.kind, (sources.get(update.source.kind) ?? 0) + 1);
+ }
+ return (
+ ctx.onToggleWorkGroup(row.id, row.id)}
+ icon={ }
+ label={
+
+ {label}
+ {summary}
+
+ }
trailing={
-
+
+
+ {[...sources].map(([kind, count]) => {
+ const Icon =
+ kind === "monitor"
+ ? ActivityIcon
+ : kind === "command"
+ ? TerminalIcon
+ : kind === "subagent" || kind === "delegated_task"
+ ? UsersIcon
+ : BellIcon;
+ return (
+
+
+
+ );
+ })}
+
+
+
+ }
+ />
+ );
+}
+
+/** A request waiting on the user, in the tone of its slot: approvals warn, questions inform. */
+function WorkingRequestRow({ entry }: { entry: TimelineWorkEntry }) {
+ const ctx = use(TimelineRowCtx);
+ const gt = useGT();
+ const approval = entry.itemType === "approval_request";
+ const target = approval
+ ? (entry.command ?? entry.detail ?? null)
+ : gt("for your answer", { $context: "follows Waiting, a question awaits the user" });
+ return (
+
+ ) : (
+
+ )
+ }
+ label={
+
+
+ {approval
+ ? entry.command
+ ? gt("Wants to run", { $context: "a command name follows" })
+ : gt("Needs approval")
+ : gt("Waiting", { $context: "for your answer follows" })}
+
+ {target ? (
+
+ {approval && entry.command
+ ? formatWorkspaceRelativePath(entry.command, ctx.workspaceRoot)
+ : target}
+
+ ) : null}
+
+ }
+ />
+ );
+}
+
+function WorkingWindowText({
+ item,
+ itemKey,
+}: {
+ item: Extract;
+ itemKey: string;
+}) {
+ const ctx = use(TimelineRowCtx);
+ const liveText = useAssistantMessageText(
+ item.message.streaming ? ctx.threadRef : null,
+ item.projectedItemId,
+ );
+ const text = liveText ?? item.message.text;
+ const textRef = useCarriedTextFade(item.message.id);
+ if (text.trim().length === 0) return null;
+ return (
+
+ );
+}
+
+const WorkingWindowItemView = memo(function WorkingWindowItemView({
+ item,
+ itemKey,
+ current,
+}: {
+ item: WorkingWindowItem;
+ itemKey: string;
+ current: boolean;
+}) {
+ const ctx = use(TimelineRowCtx);
+ if (item.kind === "text") {
+ return ;
+ }
+ if (item.kind === "agents") {
+ return ;
+ }
+ const { entry } = item;
+ if (entry.toolLifecycleStatus === "inProgress") {
+ if (entry.itemType === "approval_request" || entry.itemType === "user_input_request") {
+ return ;
+ }
+ return (
+
+ );
+ }
+ const failedTestRun =
+ entry.itemType === "command_execution" &&
+ workEntryDisplayIndicatesToolFailure(entry) &&
+ commandRunsTests(entry.command ?? entry.label);
+ return (
+
+ );
+});
+
+function WorkingWindowView({
+ window,
+ itemKey,
+ onOverflowChange,
+}: {
+ window: WorkingWindow;
+ itemKey: string;
+ onOverflowChange: (overflows: boolean) => void;
+}) {
+ const ctx = use(TimelineRowCtx);
+ const gt = useGT();
+ const {
+ isCompacting,
+ isPreparingWorktree,
+ turnEnded,
+ pendingRequest,
+ liveAnswerPreview,
+ providerStartingLabel,
+ } = use(TimelineRowActivityCtx);
+ const open = window.historyOpen;
+ const [history, setHistory] = useState<{ head: number; tailStart: number } | null>(null);
+ if (open && history === null) {
+ setHistory({
+ head: WORKING_HISTORY_BATCH,
+ tailStart: Math.max(0, window.items.length - WORKING_WINDOW_TAIL),
+ });
+ }
+ const windowRef = useRef(null);
+ const spacerRef = useRef(null);
+ const [collapseClips, setCollapseClips] = useState(false);
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- reads the expanded height before the collapse transition paints its first frame
+ useLayoutEffect(() => {
+ if (open) return;
+ setCollapseClips((windowRef.current?.scrollHeight ?? 0) > WORKING_WINDOW_COLLAPSED_HEIGHT);
+ }, [open]);
+ const { onWorkingHistoryCollapsing } = ctx;
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- older items stay mounted, and the timeline stops following its end, until the collapse transition finishes
+ useEffect(() => {
+ if (open || history === null) return;
+ onWorkingHistoryCollapsing(true);
+ let cancelled = false;
+ void transitionsSettled(windowRef.current).then(() => {
+ if (!cancelled) setHistory(null);
+ });
+ return () => {
+ cancelled = true;
+ onWorkingHistoryCollapsing(false);
+ };
+ }, [open, history, onWorkingHistoryCollapsing]);
+ const head = history?.head;
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- mounts older items as the timeline scroll brings them near the viewport
+ useEffect(() => {
+ const spacer = spacerRef.current;
+ if (!open || head === undefined || !spacer) return;
+ let observer: IntersectionObserver | undefined;
+ let cancelled = false;
+ void transitionsSettled(windowRef.current).then(() => {
+ if (cancelled) return;
+ observer = new IntersectionObserver(
+ (entries) => {
+ if (!entries.some((entry) => entry.isIntersecting)) return;
+ setHistory(
+ (current) => current && { ...current, head: current.head + WORKING_HISTORY_BATCH },
+ );
+ },
+ { scrollMargin: "100% 0px" },
+ );
+ observer.observe(spacer);
+ });
+ return () => {
+ cancelled = true;
+ observer?.disconnect();
+ };
+ }, [open, head]);
+ const { workGroupViewState, onToggleWorkEntry, onWorkEntryContentReady } = ctx;
+ const viewedImages = useWorkGroupViewedImages(
+ window.items.flatMap((item) => (item.kind === "work" ? [item.entry] : [])),
+ );
+ // Entries opened in the history keep their state, and toggling one keeps the bar in place.
+ const groupView = (() => ({
+ state: workGroupViewState,
+ viewedImages,
+ onToggleEntry: (collapsed: boolean, entryId: string) =>
+ onToggleWorkEntry("working-indicator-row", collapsed, entryId),
+ onContentReady: (entryId: string) =>
+ onWorkEntryContentReady?.("working-indicator-row", entryId),
+ }))();
+ const headEnd = history ? Math.min(history.head, history.tailStart) : 0;
+ const unmounted = history ? history.tailStart - headEnd : 0;
+ const shown = history
+ ? window.items.slice(history.tailStart)
+ : window.items.slice(-WORKING_WINDOW_TAIL);
+ const renderItem = (item: WorkingWindowItem) => (
+
+
+
+ );
+ const showThinking =
+ !turnEnded &&
+ !pendingRequest &&
+ providerStartingLabel === null &&
+ !window.answering &&
+ !workingWindowItemIsLive(window.items.at(-1)) &&
+ !isCompacting &&
+ !isPreparingWorktree &&
+ !workingWindowHasActiveCompaction(window);
+ if (shown.length === 0 && !showThinking) return null;
+ return (
+
+
+ {history === null ? (
+
+ ) : (
+ <>
+ {history ? window.items.slice(0, headEnd).map(renderItem) : null}
+ {unmounted > 0 ? (
+
+ ) : null}
+ {shown.map(renderItem)}
+ {showThinking ? (
+
+ ) : null}
+ >
+ )}
+
+
+ );
+}
+
+function CollapsedWorkingWindow({
+ items,
+ itemKey,
+ showThinking,
+ onOverflowChange,
+}: {
+ items: WorkingWindow["items"];
+ itemKey: string;
+ showThinking: boolean;
+ onOverflowChange: (overflows: boolean) => void;
+}) {
+ const gt = useGT();
+ const rootRef = useRef(null);
+ const contentRef = useRef(null);
+ const spacerRef = useRef(null);
+ const followRef = useRef(true);
+ const prependRef = useRef<{ height: number; top: number; inSpacer: boolean } | null>(null);
+ const [following, setFollowing] = useState(true);
+ const [start, setStart] = useState(() => Math.max(0, items.length - WORKING_WINDOW_TAIL));
+ const getViewport = () =>
+ rootRef.current?.querySelector('[data-slot="scroll-area-viewport"]');
+ // Following runs in ResizeObserver after layout; only a prepend needs correction before paint.
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- preserves the visible offset when mounting an older batch
+ useLayoutEffect(() => {
+ const prepend = prependRef.current;
+ if (!prepend) return;
+ const viewport = getViewport();
+ if (!viewport) return;
+ viewport.scrollTop =
+ prepend.top + (prepend.inSpacer ? 0 : viewport.scrollHeight - prepend.height);
+ prependRef.current = null;
+ });
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- content can grow between renders while markdown and command output stream
+ useLayoutEffect(() => {
+ const viewport = rootRef.current?.querySelector(
+ '[data-slot="scroll-area-viewport"]',
+ );
+ const content = contentRef.current;
+ if (!viewport || !content) return;
+ viewport.scrollTop = viewport.scrollHeight;
+ const reportOverflow = () =>
+ onOverflowChange(viewport.scrollHeight - viewport.clientHeight > 1);
+ reportOverflow();
+ return observeResize([content, viewport], () => {
+ reportOverflow();
+ if (followRef.current) viewport.scrollTop = viewport.scrollHeight;
+ });
+ }, [onOverflowChange]);
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- mounts older items as scrolling brings the spacer near the viewport
+ useEffect(() => {
+ const viewport = rootRef.current?.querySelector(
+ '[data-slot="scroll-area-viewport"]',
+ );
+ const spacer = spacerRef.current;
+ if (start === 0 || !viewport || !spacer) return;
+ const observer = new IntersectionObserver(
+ (entries) => {
+ if (prependRef.current || !entries.some((entry) => entry.isIntersecting)) return;
+ prependRef.current = {
+ height: viewport.scrollHeight,
+ top: viewport.scrollTop,
+ inSpacer:
+ viewport.scrollTop === 0 ||
+ viewport.scrollTop + viewport.clientHeight <= spacer.offsetHeight,
+ };
+ setStart((current) => Math.max(0, current - WORKING_HISTORY_BATCH));
+ },
+ { root: viewport, rootMargin: "80px 0px" },
+ );
+ observer.observe(spacer);
+ return () => observer.disconnect();
+ }, [start]);
+
+ return (
+