dsh-trajectory-traceview-plus 0.11.3 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,9 +35,18 @@ const pkg = JSON.parse(read('package.json'));
35
35
  const version = String(pkg.version);
36
36
  const localSteps = pkg.scripts.check.split('&&').map((s) => s.trim()).filter(Boolean).length;
37
37
 
38
- const probe = read('test/browser/probe.js');
39
- const observedGroups = new Set([...probe.matchAll(/info\.([a-zA-Z]\w*)\s*=/g)].map((m) => m[1]));
40
- const assertions = [...probe.matchAll(/\bfail\(/g)].length;
38
+ // Two probe files, one count. `probe-en.js` was split out because `agent-browser eval`
39
+ // aborts at 30 s and the language switch pushed the single file over it (§13.69) — and
40
+ // leaving it out of this count is exactly the one-source-vs-two-sources blindness this
41
+ // very block has already been fixed for once (§13.44).
42
+ const PROBE_FILES = ['test/browser/probe.js', 'test/browser/probe-detail.js', 'test/browser/probe-en.js'];
43
+ const probes = PROBE_FILES.map((f) => read(f));
44
+ const observedGroups = new Set();
45
+ let assertions = 0;
46
+ for (const src of probes) {
47
+ for (const m of src.matchAll(/info\.([a-zA-Z]\w*)\s*=/g)) observedGroups.add(m[1]);
48
+ assertions += [...src.matchAll(/\bfail\(/g)].length;
49
+ }
41
50
 
42
51
  // ── checks added OUTSIDE probe.js ────────────────────────────────────────────
43
52
  //
@@ -55,7 +64,11 @@ const extraGroupNames = new Set(
55
64
  .map((m) => m[1])
56
65
  .filter((n) => !observedGroups.has(n)),
57
66
  );
58
- const extraAssertions = [...browserCheck.matchAll(/(?:parsed\.)?failures\.push\(/g)].length;
67
+ // Only `push("…")` is an assertion. `push(...other)` forwards failures produced
68
+ // ELSEWHERE (the English pass collects its own) — counting it as an assertion inflated the
69
+ // total by one for every forwarded bundle, and the gate would then demand README numbers
70
+ // that describe nothing a reader could point at.
71
+ const extraAssertions = [...browserCheck.matchAll(/(?:parsed\.)?failures\.push\(\s*["'`]/g)].length;
59
72
 
60
73
  const truth = {
61
74
  ciGates, localSteps, groups: observedGroups.size, assertions,
package/src/00-locale.js CHANGED
@@ -62,6 +62,17 @@
62
62
  "kpi.tokensIn": "请求 tokens",
63
63
  "kpi.tokensOut": "生成 tokens",
64
64
  "kpi.errors": "错误",
65
+ // The Token-usage chips were hardcoded English ("in" / "out" / "cache-read" …)
66
+ // inside a Chinese panel, while README §2 describes this section as
67
+ // "入站(含缓存读 / 写)与出站(含思考)". Same words as the README, compact
68
+ // enough for a chip. `fresh` = input tokens that came from the prompt rather
69
+ // than from cache (the API's `inputTokens` minus cache read/write).
70
+ "usage.in": "入站",
71
+ "usage.fresh": "未缓存",
72
+ "usage.cacheRead": "缓存读",
73
+ "usage.cacheWrite": "缓存写",
74
+ "usage.out": "出站",
75
+ "usage.think": "思考",
65
76
  "status.done": "已完成",
66
77
  "status.retry": "重试",
67
78
  "detail.args": "调用参数",
@@ -237,6 +248,12 @@
237
248
  "kpi.tokensIn": "Prompt tokens",
238
249
  "kpi.tokensOut": "Output tokens",
239
250
  "kpi.errors": "Errors",
251
+ "usage.in": "in",
252
+ "usage.fresh": "fresh",
253
+ "usage.cacheRead": "cache-read",
254
+ "usage.cacheWrite": "cache-write",
255
+ "usage.out": "out",
256
+ "usage.think": "think",
240
257
  "status.done": "Done",
241
258
  "status.retry": "Retry",
242
259
  "detail.args": "Call arguments",
package/src/10-styles.js CHANGED
@@ -281,9 +281,15 @@
281
281
  ".dstv_btn[data-on=true]{color:var(--dstv-info-ink);background:color-mix(in srgb,var(--dstv-info) 12%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dstv-info) 40%,transparent)}",
282
282
  ".dstv_tbtn[data-on=true]{color:var(--dstv-info-ink);background:color-mix(in srgb,var(--dstv-info) 14%,transparent);font-weight:700}",
283
283
  ".dstv_station[data-match=true] .dstv_hcard{border-color:transparent;background:linear-gradient(var(--dsw-alias-bg-layer-1),var(--dsw-alias-bg-layer-1)) padding-box,linear-gradient(135deg,var(--dstv-warn),var(--dstv-warn)) border-box;box-shadow:0 0 12px color-mix(in srgb,var(--dstv-warn) 35%,transparent)}",
284
- ".dstv_station[data-seek-dim=true] .dstv_hcard{opacity:.5;filter:saturate(.3)}",
285
- ".dstv_station[data-seek-dim=true] .dstv_hDot{opacity:.35}",
284
+ // Searching dims the non-matches. Driven from the listbox so a keystroke does not
285
+ // rewrite every station element (§13.72): reached = not [data-dim], matched =
286
+ // [data-match]. Same visual result, one attribute instead of N.
287
+ ".dstv_listbox[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hcard{opacity:.5;filter:saturate(.3)}",
288
+ ".dstv_listbox[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hDot{opacity:.35}",
286
289
  ".dstv_miniTick[data-match=true]{box-shadow:0 0 0 1.5px var(--dstv-warn);height:14px}",
290
+ // While searching, fade the ticks that did not match. Reached-only ticks fade via
291
+ // [data-dim]; the search fade lives here so it costs no per-tick attribute (§13.72).
292
+ ".dstv_minimap[data-searching=true] .dstv_miniTick:not([data-dim=true]):not([data-match=true]){opacity:.25}",
287
293
  ".dstv_detail.full{max-height:82vh}",
288
294
  ".dstv_panelToggle{margin-left:4px}",
289
295
  ".dstv_subCard{border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:5px 8px;background:var(--dsw-alias-bg-layer-2);display:flex;flex-direction:column;gap:3px;margin-top:3px}",
package/src/30-helpers.js CHANGED
@@ -1277,7 +1277,7 @@
1277
1277
  // `image`/`other` arrived). These used to fall through the chain and
1278
1278
  // vanish, so a future block type would render as "the model said
1279
1279
  // nothing". Name it instead of guessing at its content.
1280
- st.cells.push({ id: `u${n.seq}${st.cells.length}`, kind: "assistant", text: `${t("block.unknown")} · ${String(b.kind)}`, thinking: "" });
1280
+ st.cells.push({ id: `u${n.seq}${st.cells.length}`, kind: "assistant", text: unknownBlockLabel(b, t), thinking: "" });
1281
1281
  } else if (b.kind === "tool-call") {
1282
1282
  // every durable block is a real call, even with a repeated id
1283
1283
  claimCall(turn, b.callId);
@@ -1465,7 +1465,7 @@
1465
1465
  // know must be NAMED, not dropped. The streaming branch was missed when the
1466
1466
  // durable one got the placeholder, so a live `file`/future block showed an
1467
1467
  // empty step (measured: cells [] for {kind:"future"} and {kind:"file"}).
1468
- st.cells.push({ id: `pu${st.cells.length}`, kind: "assistant", text: `${t("block.unknown")} · ${String(b.kind)}`, thinking: "" });
1468
+ st.cells.push({ id: `pu${st.cells.length}`, kind: "assistant", text: unknownBlockLabel(b, t), thinking: "" });
1469
1469
  } else if (b.kind === "tool-call") {
1470
1470
  if (claimedCall(turn, b.callId)) continue;
1471
1471
  claimCall(turn, b.callId);
@@ -2010,6 +2010,26 @@
2010
2010
  const flat = String(raw ?? "").replace(/\s+/g, " ").trim();
2011
2011
  return flat.length > 80 ? `${flat.slice(0, 80)}…` : flat;
2012
2012
  }
2013
+ /**
2014
+ * The label for a block kind this build does not know.
2015
+ *
2016
+ * It used to be `${t("block.unknown")} · ${String(b.kind)}`, which is fine for a
2017
+ * FUTURE kind ("未知内容 · image") but renders the literal string "undefined" when
2018
+ * the kind is missing entirely — and that label reaches both the card text and the
2019
+ * station's aria-label, so a screen-reader user heard "unknown content · undefined".
2020
+ * A record with no kind at all is a malformed record, not a future one, and naming
2021
+ * it "undefined" is worse than saying nothing.
2022
+ * @param b - the block whose kind is unknown.
2023
+ * @param t - the bound language function.
2024
+ * @returns the label to show.
2025
+ */
2026
+ function unknownBlockLabel(b, t) {
2027
+ const base = t("block.unknown");
2028
+ const kind = b !== null && b !== void 0 ? b.kind : void 0;
2029
+ if (typeof kind !== "string" || kind === "") return base;
2030
+ return `${base} · ${kind}`;
2031
+ }
2032
+
2013
2033
  function stationAriaLabel(station, position, total, t) {
2014
2034
  // Per-turn number: `stepNo` is a window-wide counter, so this label used to
2015
2035
  // read "步骤 1" and then "步骤 5" for the same station once older history was
package/src/40-view.js CHANGED
@@ -262,6 +262,32 @@
262
262
  function TraceMapView({ useSession, useTrajectory, t, viewRequest, completeViewRequest, loadOlder, sessionKey }) {
263
263
  const scrollerRef = (0, react.useRef)(null);
264
264
  const minimapRef = (0, react.useRef)(null);
265
+ // Per-station rendered elements, so an unchanged card keeps its element identity and
266
+ // React skips the subtree entirely. Cleared when the session changes (ids are only
267
+ // unique within a session) — see `stationSig`'s comment.
268
+
269
+ const cardElCache = (0, react.useRef)(new Map());
270
+ const tickElCache = (0, react.useRef)(new Map());
271
+ // The caches live as long as the view, but their contents are only valid for one
272
+ // language and one session: station ids are per-session, and a cached element holds
273
+ // already-translated text. Clearing on change keeps `t` and `sessionKey` out of the
274
+ // per-element signature (they would invalidate every card anyway).
275
+ const sigCacheRef = (0, react.useRef)({ arr: null, sigs: [] });
276
+ const cacheScopeRef = (0, react.useRef)({ t: null, sessionKey: null });
277
+ // A cached element keeps the closures it was built with. Those closures would go
278
+ // stale the moment the view re-renders (arrow keys read the current selection, seek
279
+ // reads the current window) — so the cards call THROUGH this ref, which is refreshed
280
+ // on every render. Element identity stays cacheable, behaviour stays current.
281
+ const handlersRef = (0, react.useRef)({ seek: null, keyDown: null });
282
+
283
+
284
+ if (cacheScopeRef.current.t !== t || cacheScopeRef.current.sessionKey !== sessionKey) {
285
+ cacheScopeRef.current = { t, sessionKey };
286
+ cardElCache.current.clear();
287
+ tickElCache.current.clear();
288
+ sigCacheRef.current.arr = null;
289
+ sigCacheRef.current.sigs = [];
290
+ }
265
291
  const searchRef = (0, react.useRef)(null);
266
292
  const initDone = (0, react.useRef)(false);
267
293
  // Which session this panel is showing. The host reuses one component instance
@@ -983,6 +1009,17 @@
983
1009
  seek(i); ev.preventDefault(); ev.stopPropagation();
984
1010
  }
985
1011
  };
1012
+ // Refreshed after commit; a cached element reads it at click/key time. A layout
1013
+ // effect rather than a render-time assignment, because a render React throws away
1014
+ // would otherwise leave the abandoned pass's handler behind.
1015
+ //
1016
+ // DECLARED HERE, above `if (N === 0)` and its early return: a hook below that
1017
+ // branch is skipped on the empty/loading render, and React aborts the whole panel
1018
+ // with "Rendered fewer hooks than expected".
1019
+ (0, react.useLayoutEffect)(() => {
1020
+ handlersRef.current.seek = seek;
1021
+ handlersRef.current.keyDown = stationOnKeyDown;
1022
+ });
986
1023
  const onKeyDown = (ev) => {
987
1024
  const k = ev.key;
988
1025
  // Browser and OS shortcuts must win. The panel root is focusable
@@ -1295,6 +1332,77 @@
1295
1332
  });
1296
1333
  }
1297
1334
 
1335
+ /**
1336
+ * Element cache for the station list and the minimap.
1337
+ *
1338
+ * Why: the list renders EVERY station on every state change. Measured on a
1339
+ * 900-station window, one keystroke in the search box cost 1.3–2.2 s of main
1340
+ * thread — typing a query was unusable. The tree fold is NOT the cost (that is
1341
+ * memoised and does not re-run on a keystroke); the cost is rebuilding ~900 card
1342
+ * subtrees and ~900 minimap buttons to flip `data-seek-dim` on the handful of
1343
+ * stations that actually matched.
1344
+ *
1345
+ * Rebuilding an element and re-rendering it are different costs, and React bails
1346
+ * out of the second when the ELEMENT IS THE SAME OBJECT (referential equality).
1347
+ * So: cache the element per station and return the previous one when nothing the
1348
+ * card reads has changed. Compared by VALUE — each fold allocates fresh station
1349
+ * objects, so nothing else here can be compared by identity (§13.72).
1350
+ *
1351
+ * The signature covers exactly what the card body reads: the station fields
1352
+ * `renderStationCard` + the axis zone touch, its position, its neighbour's edge
1353
+ * (the idle band), and the four per-station booleans the parent computes.
1354
+ */
1355
+ // FNV-1a over the fields the card reads, accumulated WITHOUT building a
1356
+ // concatenated string. The first version joined every field into one string —
1357
+ // harmlessly fast on the fixture, but a real 1000-node window carries ~1.1 MB of
1358
+ // tool output, and joining that per station per render made a keystroke cost
1359
+ // 1.17 s again. A rolling hash over each field is linear either way, but it
1360
+ // allocates nothing (§13.73).
1361
+
1362
+ const stationSig = (s) => {
1363
+ if (s == null) return "";
1364
+ let h = 2166136261;
1365
+ const mix = (v) => {
1366
+ if (v === null || v === void 0) { h = (h ^ 31) * 16777619 >>> 0; return; }
1367
+ if (typeof v === "number") {
1368
+ h = (h ^ (v | 0)) * 16777619 >>> 0;
1369
+ h = (h ^ (Math.floor(v * 1000) | 0)) * 16777619 >>> 0;
1370
+ return;
1371
+ }
1372
+ if (typeof v === "boolean") { h = (h ^ (v ? 1 : 2)) * 16777619 >>> 0; return; }
1373
+ const str = String(v);
1374
+ h = (h ^ str.length) * 16777619 >>> 0;
1375
+ for (let i = 0; i < str.length; i += 1) h = ((h ^ str.charCodeAt(i)) * 16777619) >>> 0;
1376
+ };
1377
+ mix(s.kind); mix(s.id); mix(s.label); mix(s.who); mix(s.text);
1378
+ mix(s.displayText); mix(s.summary); mix(s.message); mix(s.name);
1379
+ mix(s.args); mix(s.payload); mix(s.eventType); mix(s.replace); mix(s.retry);
1380
+ mix(s.isError); mix(s.hasError); mix(s.live); mix(s.synthetic); mix(s.tag);
1381
+ mix(s.time); mix(s.startMs); mix(s.endMs); mix(s.seq); mix(s.toolMs); mix(s.maxToolMs);
1382
+ // The duration bar divides by a GLOBAL denominator (`stats.maxToolMs ||
1383
+ // stats.toolMs`), not by this station's own maximum. Mixing only the station
1384
+ // fields meant every cached bar kept its old width when a DIFFERENT station
1385
+ // became the slowest one — a stale proportion bar, caught by review.
1386
+ mix(stats.maxToolMs); mix(stats.toolMs);
1387
+ mix(s.outcomeText); mix(s.outcomeKind);
1388
+ if (Array.isArray(s.meta)) { mix(s.meta.length); for (const m of s.meta) mix(m); }
1389
+ else mix(s.meta);
1390
+ // EVERY cell field the card renders, not just the shape. The first version
1391
+ // hashed only kind/isError/running — so a settled step whose assistant cell text
1392
+ // changed kept the OLD text on the card (verified: ALPHA-ONE stayed on screen
1393
+ // while the detail panel showed ALPHA-TWO). `resultText` is deliberately absent:
1394
+ // the card does not render it and it is by far the largest field (§13.75).
1395
+ if (Array.isArray(s.cells)) {
1396
+ mix(s.cells.length);
1397
+ for (const c of s.cells) {
1398
+ mix(c.kind); mix(c.id);
1399
+ mix(c.text); mix(c.thinking);
1400
+ mix(c.name); mix(c.args); mix(c.errorName);
1401
+ mix(c.durationMs); mix(c.isError === true); mix(c.running === true);
1402
+ }
1403
+ } else mix(-1);
1404
+ return h.toString(36);
1405
+ };
1298
1406
  const renderStationCard = (s, cardKey) => {
1299
1407
  if (s.kind === "user") {
1300
1408
  return jsxs("div", {
@@ -1459,6 +1567,9 @@
1459
1567
  const minimapTicks = jsx("div", {
1460
1568
  className: "dstv_minimap",
1461
1569
  ref: minimapRef,
1570
+ // Same reason as the listbox: search dimming is one attribute on the strip,
1571
+ // not one per tick, so a keystroke does not rebuild every tick element.
1572
+ "data-searching": searching ? "true" : undefined,
1462
1573
  children: stations.map((s, i) => {
1463
1574
  const reached = i < R;
1464
1575
  let k = s.kind;
@@ -1466,13 +1577,34 @@
1466
1577
  if (s.kind === "maxTokens") k = "error";
1467
1578
  const done = reached && (s.kind !== "step" || !s.live);
1468
1579
  const matched = searching && matchSet.has(i);
1469
- return jsx("button", {
1580
+ // Same element-identity trick as the station cards: an unchanged tick keeps
1581
+ // its element and React skips it (§13.72).
1582
+ const tickSig = s.kind + "\u0002" + String(i) + "\u0002" + (reached ? "1" : "0")
1583
+ + (done ? "1" : "0") + (matched ? "1" : "0") + (s.live === true ? "1" : "0")
1584
+ + (k === "tool" || k === "step" ? String(s.cells.length) : "")
1585
+ // The highlight and the "N / total" part of the aria-label change with the
1586
+ // selection and with the window length. Missing either leaves the old
1587
+ // highlight cached — caught by the minimap assertion, not by reasoning.
1588
+ //
1589
+ // The tab stop is the SAME expression as `tabIndex` below, including its
1590
+ // overview half (`revealed === null && i === 0`). Hashing only the active
1591
+ // half left tick 0 with `tabIndex: 0` after any selection, so the strip had
1592
+ // TWO tab stops (measured: [0, 5] after selecting station 5).
1593
+ + "\u0002" + ((revealed !== null && i === R - 1) || (revealed === null && i === 0) ? "1" : "0")
1594
+ // `data-k` reads the DERIVED kind, which is "tool" for a step that contains
1595
+ // one — hash the value actually used rather than re-deriving it here.
1596
+ + "\u0002" + k
1597
+ + "\u0002" + minimapTickLabel(s) + "\u0002" + fmtClock(s.time)
1598
+ + "\u0002" + String(stations.length);
1599
+ const tickHit = tickElCache.current.get(i);
1600
+ if (tickHit !== undefined && tickHit.sig === tickSig && tickHit.t === t) return tickHit.el;
1601
+ const tickEl = jsx("button", {
1470
1602
  type: "button",
1471
1603
  className: "dstv_miniTick",
1472
1604
  "data-tick-idx": String(i),
1473
1605
  "data-k": k,
1474
1606
  "data-done": done ? "true" : undefined,
1475
- "data-dim": reached ? (searching && !matched ? "true" : undefined) : "true",
1607
+ "data-dim": reached ? undefined : "true",
1476
1608
  "data-active": revealed !== null && i === R - 1 ? "true" : undefined,
1477
1609
  "data-live": s.kind === "step" && s.live === true ? "true" : undefined,
1478
1610
  "data-match": matched ? "true" : undefined,
@@ -1490,11 +1622,40 @@
1490
1622
  // all. Fall back to the kind and always expose aria-label.
1491
1623
  title: `${minimapTickLabel(s)}${fmtClock(s.time) !== "" ? ` · ${fmtClock(s.time)}` : ""}`,
1492
1624
  "aria-label": `${t("detail.position")} ${String(i + 1)} / ${String(stations.length)} · ${minimapTickLabel(s)}${fmtClock(s.time) !== "" ? ` · ${fmtClock(s.time)}` : ""}`,
1493
- onClick: (ev) => { ev.stopPropagation(); seek(i); }
1625
+ onClick: (ev) => { ev.stopPropagation(); handlersRef.current.seek(i); }
1494
1626
  }, `mini${i}`);
1627
+ tickElCache.current.set(i, { sig: tickSig, t, el: tickEl });
1628
+ return tickEl;
1495
1629
  })
1496
1630
  }, "rootMini");
1497
1631
 
1632
+ // One signature per station, computed once per TREE rather than once per render.
1633
+ // The per-render version re-hashed every cell body on every keystroke and replay
1634
+ // tick: a real 1.11 MB window cost 105 ms per rebuild instead of 30 ms. `stations`
1635
+ // identity only changes when the fold produces a new tree, so keying on it is
1636
+ // exactly "recompute when the content could have changed".
1637
+ //
1638
+ // A ref rather than useMemo on purpose: this sits BELOW the `if (N === 0)` early
1639
+ // return, and a hook here would be skipped on the empty/loading render (§13.75).
1640
+ const sigPack = sigCacheRef.current;
1641
+ if (sigPack.arr !== stations) {
1642
+ sigPack.arr = stations;
1643
+ sigPack.sigs = stations.map(stationSig);
1644
+ // Drop what the new window no longer contains. A live station is replaced by its
1645
+ // durable twin (new id) on every fold, and paging in older history shifts every
1646
+ // index, so without this the element maps only ever grow — each entry pinning a
1647
+ // whole card subtree and its station closure (§13.75).
1648
+ if (cardElCache.current.size > stations.length || tickElCache.current.size > stations.length) {
1649
+ const live = new Set(stations.map((st) => st.id));
1650
+ for (const key of [...cardElCache.current.keys()]) {
1651
+ if (!live.has(key)) cardElCache.current.delete(key);
1652
+ }
1653
+ for (const key of [...tickElCache.current.keys()]) {
1654
+ if (!(key >= 0 && key < stations.length)) tickElCache.current.delete(key);
1655
+ }
1656
+ }
1657
+ }
1658
+ const sigOf = (i) => (i < 0 || i >= sigPack.sigs.length ? "" : sigPack.sigs[i]);
1498
1659
  const body = jsxs("div", {
1499
1660
  children: [
1500
1661
  jsx("div", {
@@ -1505,10 +1666,17 @@
1505
1666
  role: "listbox",
1506
1667
  "aria-label": t("view.label"),
1507
1668
  "aria-orientation": "horizontal",
1669
+ // Dimming non-matches while searching is a CSS job, not a per-card one.
1670
+ // Setting it per station meant the FIRST keystroke invalidated all 900
1671
+ // cards (2.4 s at 900 stations); one attribute on the list lets the
1672
+ // stylesheet do it and leaves every card's element identity intact.
1673
+ "data-searching": searching ? "true" : undefined,
1508
1674
  children: [
1509
1675
  revealed !== null && playheadLeft !== null ? jsx("span", { className: "dstv_playhead", "aria-hidden": "true", style: { left: `${playheadLeft}px` }, children: jsx("i", {}) }, "ph") : null,
1510
1676
  stations.map((s, i) => {
1511
1677
  const reached = i < R;
1678
+ const isActive = revealed !== null && i === R - 1;
1679
+ const matched = searching && matchSet.has(i);
1512
1680
  // G4-T3: idle gap vs the previous station's end (falls back to its
1513
1681
  // start / time). Rendered as an inline band so a long pause between
1514
1682
  // two steps is visible without opening either one.
@@ -1551,14 +1719,27 @@
1551
1719
  else if (s.kind === "unknown") dotCls += " unknown";
1552
1720
  else if (s.kind === "step" && s.cells.some((c) => c.kind === "tool")) dotCls += " tool";
1553
1721
  if (s.kind === "step" && s.live === true) dotCls += " live";
1554
- const matched = searching && matchSet.has(i);
1555
1722
  const clock = fmtClock(s.time);
1556
- const isActive = revealed !== null && i === R - 1;
1557
- return jsxs("div", {
1723
+ // Everything below is a pure function of (station, neighbour, position,
1724
+ // N, found-in-search). If none of those moved, hand React the element
1725
+ // it already rendered and it skips the whole subtree.
1726
+ const sig = [
1727
+ sigOf(i), sigOf(i - 1), String(i), String(N),
1728
+ reached ? "1" : "0", isActive ? "1" : "0",
1729
+ matched ? "1" : "0", clockAxis ? "1" : "0",
1730
+ // The overview state is its own dependency: station 0 is the roving
1731
+ // tab stop in the overview and is not once a selection exists, even
1732
+ // though neither `reached` nor `isActive` changes for it. Caught by
1733
+ // the roving-tab-stop assertion, not by reasoning (§13.72).
1734
+ revealed === null ? "1" : "0"
1735
+ ].join("\u0002");
1736
+ const hit = cardElCache.current.get(s.id);
1737
+ if (hit !== undefined && hit.sig === sig) return hit.el;
1738
+ const el = jsxs("div", {
1558
1739
  className: "dstv_station",
1559
1740
  "data-station-idx": String(i),
1560
1741
  "data-dim": reached ? undefined : "true",
1561
- "data-seek-dim": searching && !matched && reached ? "true" : undefined,
1742
+
1562
1743
  "data-match": matched ? "true" : undefined,
1563
1744
  "data-active": isActive ? "true" : undefined,
1564
1745
  role: "option",
@@ -1571,8 +1752,8 @@
1571
1752
  "aria-selected": revealed === null ? "false" : (isActive ? "true" : "false"),
1572
1753
  "aria-label": stationAriaLabel(s, i + 1, N, t),
1573
1754
  tabIndex: isActive || (revealed === null && i === 0) ? 0 : -1,
1574
- onKeyDown: (ev) => stationOnKeyDown(ev, i),
1575
- onClick: () => seek(i),
1755
+ onKeyDown: (ev) => handlersRef.current.keyDown(ev, i),
1756
+ onClick: () => handlersRef.current.seek(i),
1576
1757
  children: [
1577
1758
  ...gapPrefix,
1578
1759
  jsxs("div", {
@@ -1602,6 +1783,8 @@
1602
1783
  }, `card${s.id}`)
1603
1784
  ]
1604
1785
  }, s.id);
1786
+ cardElCache.current.set(s.id, { sig, el });
1787
+ return el;
1605
1788
  })
1606
1789
  ]
1607
1790
  })
@@ -1831,9 +2014,9 @@
1831
2014
  usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
1832
2015
  jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
1833
2016
  jsx("div", { className: "dstv_cfgChips", children: [
1834
- usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in ", jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1835
- usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-read ", jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1836
- usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out ", jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null
2017
+ usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
2018
+ usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
2019
+ usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null
1837
2020
  ] }, "uChips")
1838
2021
  ] }, "crUsage") : null,
1839
2022
  cr.outputText !== "" ? jsxs("div", { className: "dstv_dSection", children: [
@@ -1967,12 +2150,12 @@
1967
2150
  usage !== null && usage.input + usage.output > 0 ? jsxs("div", { className: "dstv_dSection", children: [
1968
2151
  jsx("span", { className: "dstv_dLabel", children: `📊 ${t("detail.usage")}` }, "uLbl"),
1969
2152
  jsx("div", { className: "dstv_cfgChips", children: [
1970
- usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["in ", jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
1971
- usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["fresh ", jsx("b", { children: fmtInt(usage.raw) }, "v")] }, "uFresh") : null,
1972
- usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-read ", jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
1973
- usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["cache-write ", jsx("b", { children: fmtInt(usage.cacheWrite) }, "v")] }, "uCW") : null,
1974
- usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["out ", jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null,
1975
- usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: ["think ", jsx("b", { children: fmtInt(usage.think) }, "v")] }, "uThink") : null
2153
+ usage.input > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.in")} `, jsx("b", { children: fmtInt(usage.input) }, "v")] }, "uIn") : null,
2154
+ usage.raw > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.fresh")} `, jsx("b", { children: fmtInt(usage.raw) }, "v")] }, "uFresh") : null,
2155
+ usage.cacheRead > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheRead")} `, jsx("b", { children: fmtInt(usage.cacheRead) }, "v")] }, "uCR") : null,
2156
+ usage.cacheWrite > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.cacheWrite")} `, jsx("b", { children: fmtInt(usage.cacheWrite) }, "v")] }, "uCW") : null,
2157
+ usage.output > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.out")} `, jsx("b", { children: fmtInt(usage.output) }, "v")] }, "uOut") : null,
2158
+ usage.think > 0 ? jsx("span", { className: "dstv_cfgChip", children: [`${t("usage.think")} `, jsx("b", { children: fmtInt(usage.think) }, "v")] }, "uThink") : null
1976
2159
  ] }, "uChips")
1977
2160
  ] }, "uSec") : null,
1978
2161
  // messages