@@ -3,13 +3,7 @@ import { use, type ReactNode } from "react";
33import { formatDuration , type WorkLogEntry } from "../../session-logic" ;
44import { cn } from "~/lib/utils" ;
55import { WorkLogList } from "./WorkLog" ;
6- import { summarizeToolGroup } from "@t3tools/client-runtime/work-log/presentation" ;
7- import {
8- TimelineRowActivityCtx ,
9- TimelineRowCtx ,
10- type TimelineRow ,
11- type TimelineWorkEntry ,
12- } from "./timelineRowContext" ;
6+ import { TimelineRowCtx , type TimelineRow , type TimelineWorkEntry } from "./timelineRowContext" ;
137import { ToolActivityIconView } from "./TimelineToolActivityIcon" ;
148import { workEntryIconName } from "./TimelineWorkEntryRow.logic" ;
159import { SimpleWorkEntryRow } from "./TimelineWorkEntryRow" ;
@@ -121,14 +115,11 @@ function CardHeader(props: {
121115 ) ;
122116}
123117
124- /**
125- * The newest calls and thoughts, in a body that is always 4 rows tall, so a card never grows
126- * as calls arrive and never shrinks when it settles.
127- */
118+ /** The newest calls and thoughts. Rows only append, so the card grows to 4 rows and stops. */
128119function ToolCardTail ( { entries } : { entries : ReadonlyArray < TimelineWorkEntry > } ) {
129120 const { workspaceRoot } = use ( TimelineRowCtx ) ;
130121 return (
131- < div className = "min-h-30 border-t border-border px-1 py-1" >
122+ < div className = "border-t border-border px-1 py-1" >
132123 < WorkLogList density = "card" >
133124 { entries . map ( ( entry ) => (
134125 < SimpleWorkEntryRow key = { entry . id } workEntry = { entry } workspaceRoot = { workspaceRoot } />
@@ -138,16 +129,11 @@ function ToolCardTail({ entries }: { entries: ReadonlyArray<TimelineWorkEntry> }
138129 ) ;
139130}
140131
141- function useRunIsWorking ( runId : string | null | undefined ) {
142- const { isWorking, latestRunId } = use ( TimelineRowActivityCtx ) ;
143- return isWorking && runId != null && runId === latestRunId ;
144- }
145-
146132function toolNoun ( count : number ) {
147133 return count === 1 ? "tool" : "tools" ;
148134}
149135
150- /** Tools running now: a card with the newest calls , so progress is visible without a click. */
136+ /** The working run's calls in one card , so progress is visible without a click. */
151137export function LiveToolCard ( { row } : { row : Extract < TimelineRow , { kind : "work-live" } > } ) {
152138 const ctx = use ( TimelineRowCtx ) ;
153139 const stats = toolGroupStats ( row . groupedEntries ) ;
@@ -181,23 +167,17 @@ export function LiveToolCard({ row }: { row: Extract<TimelineRow, { kind: "work-
181167 ) ;
182168}
183169
184- /**
185- * Finished tools. While the run still works they keep the live card's size, so nothing below
186- * moves; once the run ends they settle to one quiet line that opens into the card.
187- */
170+ /** Finished tools: one quiet line that opens into the card. */
188171export function ToolGroupLine ( { row } : { row : Extract < TimelineRow , { kind : "work-toggle" } > } ) {
189172 const ctx = use ( TimelineRowCtx ) ;
190173 const stats = toolGroupStats ( row . groupedEntries ) ;
191174 const duration = stats . durationMs !== null ? formatDuration ( stats . durationMs ) : null ;
192- const holdCard = useRunIsWorking ( row . runId ) && ! row . expanded ;
193175 return (
194176 < div
195177 className = {
196- holdCard
197- ? toolCardClassName . whole
198- : row . expanded
199- ? toolCardClassName . top
200- : "mt-1.5 rounded-md border border-transparent hover:bg-foreground/[0.03]"
178+ row . expanded
179+ ? toolCardClassName . top
180+ : "mt-1.5 rounded-md border border-transparent hover:bg-foreground/[0.03]"
201181 }
202182 >
203183 < CardHeader
@@ -229,47 +209,13 @@ export function ToolGroupLine({ row }: { row: Extract<TimelineRow, { kind: "work
229209 </ >
230210 }
231211 expanded = { row . expanded }
232- className = { row . expanded || holdCard ? "rounded-t-xl" : "rounded-md" }
212+ className = { row . expanded ? "rounded-t-xl" : "rounded-md" }
233213 onToggle = { ( ) => ctx . onToggleWorkGroup ( row . groupId , row . id ) }
234214 />
235- { holdCard ? (
236- < ToolCardTail entries = { liveToolCardTail ( row . groupedEntries , LIVE_TAIL_ROWS ) } />
237- ) : null }
238215 </ div >
239216 ) ;
240217}
241218
242- /**
243- * A single finished call while its run still works. It keeps the live card's size; once the
244- * run ends the call shows as a plain row.
245- */
246- export function SettledToolCard ( { entries } : { entries : ReadonlyArray < TimelineWorkEntry > } ) {
247- const stats = toolGroupStats ( entries ) ;
248- const { summary } = summarizeToolGroup ( entries ) ;
249- const duration = stats . durationMs !== null ? formatDuration ( stats . durationMs ) : null ;
250- return (
251- < div className = { toolCardClassName . whole } >
252- < CardHeader
253- entries = { entries }
254- label = { summary }
255- accessibleLabel = { [ summary , stats . failedCount > 0 ? `${ stats . failedCount } failed` : null ]
256- . filter ( Boolean )
257- . join ( ", " ) }
258- failedCount = { stats . failedCount }
259- trailing = { duration }
260- expanded = { false }
261- className = "rounded-t-xl"
262- />
263- < ToolCardTail entries = { liveToolCardTail ( entries , LIVE_TAIL_ROWS ) } />
264- </ div >
265- ) ;
266- }
267-
268- /** True when the entries belong to the run that is working now. */
269- export function useEntriesInWorkingRun ( entries : ReadonlyArray < WorkLogEntry > ) {
270- return useRunIsWorking ( entries [ 0 ] ?. runId ) ;
271- }
272-
273219/** Bottom of an open card: the full list of calls. */
274220export function ToolCardBody ( { children } : { children : ReactNode } ) {
275221 return (
0 commit comments