diff --git a/apps/web/src/components/chat/TimelineWorkEntryRow.tsx b/apps/web/src/components/chat/TimelineWorkEntryRow.tsx index 7d9cbbb491dd2..85bd88614be8d 100644 --- a/apps/web/src/components/chat/TimelineWorkEntryRow.tsx +++ b/apps/web/src/components/chat/TimelineWorkEntryRow.tsx @@ -27,7 +27,7 @@ import { } from "@t3tools/client-runtime/work-log/item-detail"; import { claudeSkillInvocation } from "@t3tools/shared/toolActivity"; import { msg, T, useGT, useMessages, Var } from "gt-react"; -import { memo, use, useState, type KeyboardEvent } from "react"; +import { memo, use, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react"; import { workEntryDisplayIndicatesToolFailure, workEntrySignalsSevereFailure, @@ -42,6 +42,7 @@ import * as DateTime from "effect/DateTime"; import { ChevronRightIcon, CircleAlertIcon, XIcon, RotateCcwIcon } from "lucide-react"; import { Button, InlineButton } from "../ui/button"; import { useAssetUrls } from "../../assets/assetUrls"; +import { observeResize } from "../../lib/observeResize"; import { useThreadShell } from "../../state/entities"; import { threadReadTargetId, @@ -300,6 +301,20 @@ function WorkEntryLogRow(props: WorkEntryRowProps) { const [expanded, setExpanded] = useState( () => groupView?.state.expandedEntries.has(workEntry.id) ?? false, ); + const noticeMessage = + workEntry.structuredPayload?.type === "system_notice" + ? workEntry.structuredPayload.message + : null; + const labelRef = useRef(null); + const [noticeCutOff, setNoticeCutOff] = useState(false); + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- only layout knows whether a notice fits its row + useLayoutEffect(() => { + const label = labelRef.current; + if (!label || noticeMessage === null) return; + const measure = () => setNoticeCutOff(label.scrollWidth > label.clientWidth); + measure(); + return observeResize(label, measure); + }, [noticeMessage]); const onInitialOutputReady = () => { if (groupView) groupView.onContentReady?.(workEntry.id); else props.onContentReady?.(); @@ -417,6 +432,18 @@ function WorkEntryLogRow(props: WorkEntryRowProps) { : null; const viewedImagePath = workEntryViewedImagePath(workEntry); const payload = workEntry.structuredPayload; + const mcpSignIn = + payload?.type === "system_notice" && + payload.mcpSignIn !== undefined && + payload.providerThreadId !== null ? ( + + ) : null; const skill = payload?.type === "dynamic_tool" ? claudeSkillInvocation(payload.toolName, payload.input) @@ -467,8 +494,10 @@ function WorkEntryLogRow(props: WorkEntryRowProps) { plainOutput !== undefined && workEntry.projectedItem !== undefined && turnItemNeedsDetailFetch(workEntry.projectedItem.item); + // A notice's details repeat its row, so it expands only to show text the row cuts off. const canExpandProjectedItem = - plainOutput !== undefined + (noticeMessage === null || noticeCutOff) && + (plainOutput !== undefined ? Boolean(plainOutput || viewedImage || workEntry.questionAnswer || plainOutputFetches) : workEntry.projectedItem === undefined ? canExpand @@ -478,7 +507,7 @@ function WorkEntryLogRow(props: WorkEntryRowProps) { viewedImage || workEntry.questionAnswer || turnItemHasDetail(workEntry.projectedItem.item), - ); + )); const iconWrapperClass = cn( "flex size-4 items-center justify-center", showWarningIndicator @@ -545,7 +574,12 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {

{isReasoning && !expanded ? ( ) : null} + {mcpSignIn}

} trailing={ <> + {/* 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} - {payload?.type === "system_notice" && - payload.mcpSignIn !== undefined && - payload.providerThreadId !== null ? ( - - ) : null} {notifiedSubagentThreadId ? ( ) : null} - } >