@@ -291,12 +291,31 @@ function workEntryIndicatesToolFailureFromOutput(
291291 return output . length > 0 && toolOutputIndicatesFailure ( output ) ;
292292}
293293
294+ // Rows are re-derived on every timeline update but entries are reused while
295+ // their item is unchanged, so these per-entry checks are computed once.
296+ const entryChecks = new WeakMap <
297+ WorkLogPresentationEntry ,
298+ { failure ?: boolean ; displayFailure ?: boolean ; action ?: ToolGroupAction }
299+ > ( ) ;
300+
301+ function checksFor ( entry : WorkLogPresentationEntry ) {
302+ let checks = entryChecks . get ( entry ) ;
303+ if ( ! checks ) {
304+ checks = { } ;
305+ entryChecks . set ( entry , checks ) ;
306+ }
307+ return checks ;
308+ }
309+
294310export function workEntryIndicatesToolFailure ( entry : WorkLogPresentationEntry ) : boolean {
295- return workEntryIndicatesToolFailureFromOutput ( entry , true ) ;
311+ return ( checksFor ( entry ) . failure ??= workEntryIndicatesToolFailureFromOutput ( entry , true ) ) ;
296312}
297313
298314export function workEntryDisplayIndicatesToolFailure ( entry : WorkLogPresentationEntry ) : boolean {
299- return workEntryIndicatesToolFailureFromOutput ( entry , false ) ;
315+ return ( checksFor ( entry ) . displayFailure ??= workEntryIndicatesToolFailureFromOutput (
316+ entry ,
317+ false ,
318+ ) ) ;
300319}
301320
302321function workLogEntryIsLocalCodeSearch ( entry : WorkLogPresentationEntry ) : boolean {
@@ -308,6 +327,10 @@ function workLogEntryIsLocalCodeSearch(entry: WorkLogPresentationEntry): boolean
308327}
309328
310329export function toolGroupAction ( entry : WorkLogPresentationEntry ) : ToolGroupAction {
330+ return ( checksFor ( entry ) . action ??= computeToolGroupAction ( entry ) ) ;
331+ }
332+
333+ function computeToolGroupAction ( entry : WorkLogPresentationEntry ) : ToolGroupAction {
311334 if ( entry . itemType === "thread_created" ) return "thread-create" ;
312335 const presentation = resolveWorkEntryToolPresentation ( entry ) ;
313336 if ( presentation ?. action !== undefined ) return presentation . action ;
0 commit comments