The best way to control Claude Code, Codex and more from any computer or phone
perf(web): long threads stream with 70% less work-row derivation (#29971)
Entrpi committed
Nov 4, 2026 at 10:43 UTC
ebfca09e91e94536d16bcc958e07d1b68fa3a880
2 files changed
+42
-3
packages/client-runtime/src/work-log/presentation.ts
+25
-2
@@ -291,12 +291,31 @@ function workEntryIndicatesToolFailureFromOutput(
291
return output.length > 0 && toolOutputIndicatesFailure(output);
292
}
293
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
+
310
export function workEntryIndicatesToolFailure(entry: WorkLogPresentationEntry): boolean {
295
- return workEntryIndicatesToolFailureFromOutput(entry, true);
311
+ return (checksFor(entry).failure ??= workEntryIndicatesToolFailureFromOutput(entry, true));
312
}
313
314
export function workEntryDisplayIndicatesToolFailure(entry: WorkLogPresentationEntry): boolean {
299
- return workEntryIndicatesToolFailureFromOutput(entry, false);
315
+ return (checksFor(entry).displayFailure ??= workEntryIndicatesToolFailureFromOutput(
316
+ entry,
317
+ false,
318
+ ));
319
}
320
321
function workLogEntryIsLocalCodeSearch(entry: WorkLogPresentationEntry): boolean {
@@ -308,6 +327,10 @@ function workLogEntryIsLocalCodeSearch(entry: WorkLogPresentationEntry): boolean
327
}
328
329
export function toolGroupAction(entry: WorkLogPresentationEntry): ToolGroupAction {
330
+ return (checksFor(entry).action ??= computeToolGroupAction(entry));
331
+}
332
+
333
+function computeToolGroupAction(entry: WorkLogPresentationEntry): ToolGroupAction {
334
if (entry.itemType === "thread_created") return "thread-create";
335
const presentation = resolveWorkEntryToolPresentation(entry);
336
if (presentation?.action !== undefined) return presentation.action;
packages/shared/src/t3McpToolPresentation.ts
+17
-1
@@ -380,8 +380,24 @@ function normalizeT3McpToolLabel(value: string): string {
380
return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
381
}
382
383
-// ACP tool prefixes vary; match loosely but require a known display-name entry.
383
+// Timelines resolve every work row's tool name on each update; names repeat across updates.
384
+// ACP titles can carry whole commands, so long labels are parsed but not kept.
385
+const toolNameCache = new Map<string, string | null>();
386
+const TOOL_NAME_CACHE_LIMIT = 10_000;
387
+const TOOL_NAME_CACHE_MAX_KEY_LENGTH = 256;
388
+
389
function resolveT3McpToolName(value: string): string | null {
390
+ if (value.length > TOOL_NAME_CACHE_MAX_KEY_LENGTH) return parseT3McpToolName(value);
391
+ const cached = toolNameCache.get(value);
392
+ if (cached !== undefined) return cached;
393
+ const name = parseT3McpToolName(value);
394
+ if (toolNameCache.size >= TOOL_NAME_CACHE_LIMIT) toolNameCache.clear();
395
+ toolNameCache.set(value, name);
396
+ return name;
397
+}
398
+
399
+// ACP tool prefixes vary; match loosely but require a known display-name entry.
400
+function parseT3McpToolName(value: string): string | null {
401
const label = normalizeT3McpToolLabel(value);
402
const mcpMatch = /^mcp__(?<server>.+?)__(?<tool>.+)$/i.exec(label);
403
if (mcpMatch?.groups) {