dsh-trajectory-traceview-plus 0.11.5 → 0.11.6

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.
package/src/40-view.js CHANGED
@@ -296,6 +296,10 @@
296
296
  // applied to a completely different transcript. `sessionKey` arrives from the
297
297
  // slot's `inject`; when the host does not provide one, behaviour is unchanged.
298
298
  const sessionRef = (0, react.useRef)(sessionKey);
299
+ // The session key that the CURRENT `revealed`/`query` values belong to. They lag one
300
+ // render behind a key change (the clear is scheduled, not applied), and writing that
301
+ // pair under the new key leaked one session's position into another.
302
+ const stateKeyRef = (0, react.useRef)(sessionKey);
299
303
  // ── view state that survives a tab switch ─────────────────────────────
300
304
  // The host UNMOUNTS this panel when the reader looks at the conversation and
301
305
  // remounts it on return (measured: root count 0 → 1). Without this, every
@@ -314,7 +318,11 @@
314
318
  // moment the reader typed a query — while the timeline had not moved at all —
315
319
  // and then the FIRST "next" went to match 2, so match 1 was only reachable by
316
320
  // wrapping all the way round.
317
- const [matchPtr, setMatchPtr] = (0, react.useState)(-1);
321
+ // The CURRENT match is tracked by STATION ID, not by array index. An index into
322
+ // `matches` silently changes meaning when the station list grows: after a page
323
+ // load the counter read "2/3" while the selection still sat on the record that
324
+ // used to be match 2 of 2 and had become match 3 of 3.
325
+ const [matchId, setMatchId] = (0, react.useState)(null);
318
326
  const [follow, setFollow] = (0, react.useState)(true);
319
327
  const [panelFull, setPanelFull] = (0, react.useState)(false);
320
328
  const [anchorNote, setAnchorNote] = (0, react.useState)(null);
@@ -381,9 +389,13 @@
381
389
  requests: snap.requests,
382
390
  callSchemas: snap.callSchemas,
383
391
  runningCalls: snap.runningCalls,
392
+ // Passed through for the "system prompt sits outside the loaded window"
393
+ // case: the contract leaves `request.prompt.system` EMPTY there, and the
394
+ // real text only exists on the snapshot.
395
+ systemPrompts: snap.systemPrompts,
384
396
  partial: partialRef.current
385
397
  }, t),
386
- [snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, partialSig, streamTick, t]
398
+ [snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, snap.systemPrompts, partialSig, streamTick, t]
387
399
  );
388
400
  const stations = tree.stations;
389
401
  const stationsRef = (0, react.useRef)(stations);
@@ -421,14 +433,36 @@
421
433
  setFollow(true);
422
434
  setRevealed(null); // overview: show the whole new transcript
423
435
  setQueryRaw("");
424
- setMatchPtr(0);
436
+ setMatchId(null);
425
437
  setOlderNote(null);
426
438
  setPanelFull(false);
427
439
  setTab("detail");
440
+ // The anchor box kept the previous conversation's text: harmless (it is not
441
+ // stored, and the note is fixed wording) but it reads as if it still referred to
442
+ // the session on screen. Everything else in this reset block is per-session, so
443
+ // this belongs here too.
444
+ setAnchorInput("");
445
+ setAnchorNote(null);
428
446
  }, [sessionKey]);
429
447
 
430
448
  // Remember where the reader was, so a host-initiated remount resumes there.
449
+ //
450
+ // The key and the VALUES can belong to different sessions for one render: when
451
+ // `sessionKey` changes, the reset effect above only SCHEDULES the clear, so this
452
+ // effect still sees the previous session's `revealed`/`query` next to the NEW key.
453
+ // Writing that pair files session A's position under session B, and the next mount
454
+ // of B then restores a selection it never had.
455
+ //
456
+ // HONEST LIMIT: probe group 8b catches the SYMPTOM ("view state leaked into
457
+ // another session") but does not isolate this guard — removing it leaves the probe
458
+ // green in 2/2 runs (§13.78 hit the same wall with the cache-scope clear). The guard
459
+ // stays because the mis-write is wrong on its face, not because a red would prove it.
431
460
  (0, react.useEffect)(() => {
461
+ if (stateKeyRef.current !== sessionKey) {
462
+ // Values in this render still belong to the previous session; drop them.
463
+ stateKeyRef.current = sessionKey;
464
+ return;
465
+ }
432
466
  writeViewState(sessionKey, revealed, queryRaw);
433
467
  }, [sessionKey, revealed, queryRaw]);
434
468
 
@@ -570,15 +604,23 @@
570
604
  const stepPrev = () => {
571
605
  setPlaying(false);
572
606
  setFollow(false);
573
- if (revealed === null) { if (N > 0) setRevealed(N); return; }
574
- if (R > 1) setRevealed(R - 1);
607
+ // Functional update: held-down arrow keys arrive faster than React can re-render,
608
+ // and reading `revealed` from the closure merged those repeats into a single step.
609
+ // Measured: 20 synthetic presses in one tick advanced ONE station; with a 200 ms gap
610
+ // they advanced 20. Real key auto-repeat sits in between, so the updater form is the
611
+ // honest one.
612
+ setRevealed((r) => {
613
+ if (r === null) return N > 0 ? Math.min(N, Math.max(1, N)) : null;
614
+ return r > 1 ? r - 1 : r;
615
+ });
575
616
  };
576
617
  const stepNext = () => {
577
618
  setPlaying(false);
578
619
  setFollow(false);
579
- if (revealed === null) { if (N > 0) setRevealed(1); return; }
580
- if (R < N) setRevealed(R + 1);
581
- else setRevealed(null);
620
+ setRevealed((r) => {
621
+ if (r === null) return N > 0 ? 1 : null;
622
+ return r < N ? r + 1 : null;
623
+ });
582
624
  };
583
625
  const toEnd = () => {
584
626
  setPlaying(false);
@@ -827,7 +869,7 @@
827
869
 
828
870
  // ── follow mode: keep the newest station in view while live ──────────
829
871
  (0, react.useEffect)(() => {
830
- if (!follow || revealed !== null) return;
872
+ if (!follow || !followTipRef.current) return;
831
873
  const sc = scrollerRef.current;
832
874
  if (sc === null) return;
833
875
  try { sc.scrollLeft = sc.scrollWidth; } catch { /* noop */ }
@@ -839,7 +881,9 @@
839
881
  const matchSet = (0, react.useMemo)(() => new Set(matches), [matches]);
840
882
  const searching = query !== "";
841
883
  const scopeNote = searchScopeNote(hasMore, loadingOlder, t);
842
- (0, react.useEffect)(() => { setMatchPtr(-1); }, [query]);
884
+ const matchPtr = (0, react.useMemo)(() => (matchId === null ? -1
885
+ : matches.findIndex((i) => stations[i]?.id === matchId)), [matchId, matches, stations]);
886
+ (0, react.useEffect)(() => { setMatchId(null); }, [query]);
843
887
  const gotoMatch = (dir) => {
844
888
  if (matches.length === 0) return;
845
889
  // A fresh query has no current match yet, so the FIRST step has to land on an
@@ -847,7 +891,7 @@
847
891
  // where the match set shrank between keystrokes.
848
892
  const base = matchPtr < 0 || matchPtr >= matches.length ? (dir > 0 ? -1 : 0) : matchPtr;
849
893
  const next = ((base + dir) % matches.length + matches.length) % matches.length;
850
- setMatchPtr(next);
894
+ setMatchId(stations[matches[next]]?.id ?? null);
851
895
  seek(matches[next]);
852
896
  };
853
897
  const onSearchKey = (ev) => {
@@ -880,7 +924,12 @@
880
924
  * (a selected `e30` became `e20`). Station ids are stable across rebuilds, so
881
925
  * remember the selected id and re-derive the position from it.
882
926
  */
883
- const selectedIdRef = (0, react.useRef)(null);
927
+ // `undefined` = "not recorded yet", `null` = "recorded, the overview is selected".
928
+ // The distinction matters: a remount restores `revealed` BEFORE the station list
929
+ // arrives, and writing `null` at that moment froze the pin as "nothing selected"
930
+ // for good — the next page load then kept the INDEX and showed a different record
931
+ // (measured: T6 → T3 after a remount onto an empty first frame).
932
+ const selectedIdRef = (0, react.useRef)(void 0);
884
933
  const stationsSignature = (0, react.useMemo)(() => stations.map((st) => st.id).join("\u0000"), [stations]);
885
934
  // Read the station from the list directly: `activeStation` is declared further
886
935
  // down, and touching a `const` before its declaration throws ReferenceError on
@@ -890,20 +939,45 @@
890
939
  // backwards page (same position, different station) and OVERWROTE the pinned
891
940
  // id with whatever now sat at that index, so the repair effect then "confirmed"
892
941
  // the wrong station. Verified live: e29532 became e28913 after loading history.
893
- const prevRevealedRef = (0, react.useRef)(revealed);
942
+ // Seeded with a SENTINEL, not with `revealed`. On a remount the view restores a
943
+ // selection from storage, so initialising with the restored number made the first
944
+ // effect run look like "nothing changed" and `selectedIdRef` was never written. The
945
+ // pin-by-id repair then had nothing to work with, and the first page load after a
946
+ // remount kept the INDEX instead of the station: measured "6 / 10 用户 T6" became
947
+ // "6 / 13 用户 T3" once three older stations were prepended.
948
+ const prevRevealedRef = (0, react.useRef)(void 0);
949
+ // "The reader is at the LIVE TIP" — recorded when the SELECTION changes, using the
950
+ // station count at that moment. Follow mode used to scroll only in the overview
951
+ // (`revealed === null`), so with a station selected a newly streamed record stayed
952
+ // off-screen even though 跟随 was on: measured 13 stations, station 13 selected,
953
+ // a 14th arrives, `scrollLeft` unchanged and the new card 268 px past the right
954
+ // edge. Appending a station must not clear this flag; only a deliberate jump to an
955
+ // older record does.
956
+ const followTipRef = (0, react.useRef)(true);
894
957
  (0, react.useEffect)(() => {
895
958
  const selectionChanged = prevRevealedRef.current !== revealed;
896
959
  prevRevealedRef.current = revealed;
897
- if (!selectionChanged) return;
960
+ // Re-run when the COUNT changes too: a restored selection can arrive before the
961
+ // station list does, and without this the pin stayed unrecorded for ever.
962
+ // Paging is still safe — once an id is recorded, `!changed` bails out below.
963
+ if (!selectionChanged && selectedIdRef.current !== void 0) return;
964
+ followTipRef.current = revealed === null
965
+ || revealed >= stationsRef.current.length;
966
+ if (revealed === null) { selectedIdRef.current = null; return; }
967
+ // No stations yet: leave the pin UNRECORDED rather than recording "nothing",
968
+ // so the arrival of the list can still fill it in.
969
+ if (stationsRef.current.length === 0) return;
898
970
  selectedIdRef.current = revealed === null ? null
899
971
  : (stationsRef.current[Math.min(stationsRef.current.length - 1, Math.max(0, revealed - 1))]?.id ?? null);
900
972
  // stationsRef is intentionally read through the ref: depending on `stations`
901
973
  // here would re-fire on paging, which is the bug being fixed.
902
974
  // eslint-disable-next-line react-hooks/exhaustive-deps
903
- }, [revealed]);
975
+ }, [revealed, N]);
904
976
  (0, react.useEffect)(() => {
905
977
  const id = selectedIdRef.current;
906
- if (id === null) return;
978
+ // `void 0` means the pin has not been recorded yet (data was not ready); do not
979
+ // treat that as "the overview is selected".
980
+ if (id === null || id === void 0) return;
907
981
  const at = stations.findIndex((st) => st.id === id);
908
982
  // Gone from the window (should not happen for a prepend) or already correct.
909
983
  if (at < 0 || at + 1 === revealed) return;
@@ -1030,6 +1104,12 @@
1030
1104
  // scrolling to the top. Bail out on any modifier combination.
1031
1105
  if (ev.ctrlKey === true || ev.metaKey === true || ev.altKey === true) return;
1032
1106
  const tag = ev.target && ev.target.tagName ? String(ev.target.tagName).toLowerCase() : "";
1107
+ // Bail out when the key belongs to a text field. HONEST STATUS: with today's markup
1108
+ // this branch is UNREACHABLE — every input inside the panel (search, anchor) has its
1109
+ // own onKeyDown that calls stopPropagation for every key, so nothing arrives here from
1110
+ // a field. It is kept as a guard for the next field someone adds, and the probe
1111
+ // assertion ("End inside the anchor box does not clear the selection") therefore
1112
+ // cannot be made to fail by deleting this line; do not mistake it for coverage.
1033
1113
  if (tag === "input" || tag === "textarea" || tag === "select" || (ev.target && ev.target.isContentEditable === true)) return;
1034
1114
  if (k === "/" || k === "f") {
1035
1115
  if (searchRef.current !== null && typeof searchRef.current.focus === "function") { searchRef.current.focus(); ev.preventDefault(); }
@@ -1207,7 +1287,12 @@
1207
1287
  type: "search",
1208
1288
  autoComplete: "off",
1209
1289
  "aria-label": t("search.label"),
1210
- value: query,
1290
+ // Bind the RAW text, not the trimmed match string. Rendering the
1291
+ // trimmed value made a controlled input swallow the space the user
1292
+ // had just typed: "alpha␣" was re-rendered as "alpha", so the next
1293
+ // word ran into it ("alphabeta") and a phrase search could never be
1294
+ // typed one key at a time. Matching still uses `query` (trimmed).
1295
+ value: queryRaw,
1211
1296
  placeholder: t("action.search"),
1212
1297
  onChange: (ev) => setQueryRaw(ev.target != null ? ev.target.value : ""),
1213
1298
  onKeyDown: onSearchKey
@@ -1383,7 +1468,12 @@
1383
1468
  // stats.toolMs`), not by this station's own maximum. Mixing only the station
1384
1469
  // fields meant every cached bar kept its old width when a DIFFERENT station
1385
1470
  // became the slowest one — a stale proportion bar, caught by review.
1386
- mix(stats.maxToolMs); mix(stats.toolMs);
1471
+ // Hash the EFFECTIVE denominator, not both inputs. `stats.toolMs` is only a
1472
+ // fallback for a zero max, but hashing it made every card depend on the SUM of
1473
+ // all tool durations: one slow tool changed the total, so a 900-station window
1474
+ // rebuilt all 900 cards to widen a single bar. Measured by the perf review:
1475
+ // 900 rebuilds -> 1 with the effective denominator.
1476
+ mix(Math.max(1, stats.maxToolMs || stats.toolMs));
1387
1477
  mix(s.outcomeText); mix(s.outcomeKind);
1388
1478
  if (Array.isArray(s.meta)) { mix(s.meta.length); for (const m of s.meta) mix(m); }
1389
1479
  else mix(s.meta);
@@ -1401,8 +1491,63 @@
1401
1491
  mix(c.durationMs); mix(c.isError === true); mix(c.running === true);
1402
1492
  }
1403
1493
  } else mix(-1);
1404
- return h.toString(36);
1494
+ // The hash alone is not enough: FNV-1a is 32-bit and `mix` folds a number into
1495
+ // 64 bits of state, so two REAL inputs can land on the same value. Measured by
1496
+ // review: seq-identical user stations at time 1700000000000 and 1704294967296
1497
+ // produced the same signature, and the cached card kept 06:13:20 while the
1498
+ // minimap tick (whose signature carries `fmtClock`) had already moved to 23:16:07.
1499
+ // Appending the RENDERED text of the two derived values the card shows gives a
1500
+ // second, non-hash channel — a collision now has to happen in both.
1501
+ //
1502
+ // `s.turn` was missing entirely: a station re-projected from turn 1 to turn 2
1503
+ // kept an aria-label reading "轮次 1" while the projection said 2.
1504
+ return h.toString(36)
1505
+ + "\u0002" + fmtClock(s.time)
1506
+ + "\u0002" + (s.turn === null || s.turn === void 0 ? "" : String(s.turn));
1405
1507
  };
1508
+ /**
1509
+ * Sub-calls can nest (a tool that itself calls tools). The detail panel rendered
1510
+ * ONE level: everything from `sub.subCalls` down was invisible, while both the
1511
+ * single-step copy and the whole-trace export printed the whole chain — so the
1512
+ * screen showed strictly less than the file you could copy from it.
1513
+ *
1514
+ * Recursive now. `depth` only feeds the React key and a data attribute; there is
1515
+ * no visual indentation budget to blow.
1516
+ */
1517
+ const renderSubCalls = (subs, depth) => subs.map((sub, i) => {
1518
+ const subPretty = prettyArgs(sub.argsRaw);
1519
+ const nested = Array.isArray(sub.subCalls) ? sub.subCalls : [];
1520
+ return jsxs("div", {
1521
+ className: "dstv_subCard",
1522
+ "data-depth": depth > 0 ? String(depth) : undefined,
1523
+ children: [
1524
+ jsxs("span", {
1525
+ className: "dstv_subHead",
1526
+ children: [
1527
+ sub.running ? jsx("i", { className: "dstv_dot", "data-live": true }, "sIcon") : sub.isError ? jsx("span", { className: "dstv_bad", children: "✗" }, "sIcon") : jsx("span", { className: "dstv_ok", children: "✓" }, "sIcon"),
1528
+ jsx("span", { className: "tname", children: `${depth > 0 ? "↳↳" : "↳"} ${sub.name}` }, "sName"),
1529
+ jsx("span", { className: "dstv_chips", children: [
1530
+ sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
1531
+ sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
1532
+ sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
1533
+ ] }, "sChips")
1534
+ ]
1535
+ }, "sHead"),
1536
+ sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
1537
+ jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sASum"),
1538
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sACode") }, "sAInner")
1539
+ ] }, "sArgs") : null,
1540
+ sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
1541
+ jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sRSum"),
1542
+ jsx("div", { className: "inner", children: jsxs("div", { children: [
1543
+ jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
1544
+ jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
1545
+ ] }) }, "sRInner")
1546
+ ] }, "sRes") : null,
1547
+ nested.length > 0 ? jsx("div", { className: "dstv_subKids", children: renderSubCalls(nested, depth + 1) }, "sKids") : null
1548
+ ]
1549
+ }, `ts${depth}-${i}`);
1550
+ });
1406
1551
  const renderStationCard = (s, cardKey) => {
1407
1552
  if (s.kind === "user") {
1408
1553
  return jsxs("div", {
@@ -1410,7 +1555,7 @@
1410
1555
  children: [
1411
1556
  jsx("span", { className: "dstv_name", children: s.who }, "uName"),
1412
1557
  s.time != null ? jsx("span", { className: "dstv_spanRow", children: jsx("span", { className: "dstv_spanEdge", children: fmtClock(s.time) }, "uClk") }, "uSpan") : null,
1413
- jsx("div", { className: "dstv_text dstv_clamp3", title: s.text, children: s.text || "…" }, "uText")
1558
+ jsx("div", { className: "dstv_text dstv_clamp3", title: cardTitle(s.text), children: cardText(s.text) || "…" }, "uText")
1414
1559
  ]
1415
1560
  }, cardKey);
1416
1561
  }
@@ -1448,8 +1593,8 @@
1448
1593
  className: "dstv_cellRow",
1449
1594
  children: [
1450
1595
  jsx("span", { className: "dstv_cellName", children: t("node.assistant") }, "aName"),
1451
- cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cell.thinking, children: `💭 ${markdownToPlain(cell.thinking)}` }, "aThink") : null,
1452
- cell.text !== "" ? jsx("div", { className: "dstv_text dstv_clamp2", title: cell.text, children: markdownToPlain(cell.text) }, "aText") : null
1596
+ cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(cell.thinking), children: `💭 ${cardText(markdownToPlain(cardText(cell.thinking)))}` }, "aThink") : null,
1597
+ cell.text !== "" ? jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(cell.text), children: cardText(markdownToPlain(cardText(cell.text))) }, "aText") : null
1453
1598
  ]
1454
1599
  }, `a${cell.id}`);
1455
1600
  }
@@ -1488,12 +1633,20 @@
1488
1633
  className: "dstv_name",
1489
1634
  children: [
1490
1635
  jsx("span", { className: s.isError ? "dstv_bad" : "dstv_ok", children: s.isError ? "✗" : "⤷" }, "oIcon"),
1491
- `${t("node.orphanTool")} · ${s.name}`,
1492
- jsx("span", { className: "dstv_chips", children: [jsx("span", { className: "dstv_chip info", children: t("orphan.badge") }, "oBadge")] }, "oChips")
1636
+ // A compaction REPLAY is a different thing from "the call is outside
1637
+ // the window": the call is right there and was already answered.
1638
+ // Saying the call is missing sends the reader looking for a bug.
1639
+ `${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}`,
1640
+ jsx("span", {
1641
+ className: "dstv_chips",
1642
+ children: [jsx("span", { className: "dstv_chip info", children: s.replayOf !== null && s.replayOf !== void 0
1643
+ ? t("orphan.replayBadge").replace("{seq}", String(s.replayOf))
1644
+ : t("orphan.badge") }, "oBadge")]
1645
+ }, "oChips")
1493
1646
  ]
1494
1647
  }, "oName"),
1495
- s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: s.args, children: s.args }, "oArgs") : null,
1496
- jsx("div", { className: "dstv_text dstv_clamp4", title: body, children: body }, "oText")
1648
+ s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(s.args), children: cardText(s.args) }, "oArgs") : null,
1649
+ jsx("div", { className: "dstv_text dstv_clamp4", title: cardTitle(body), children: cardText(body) }, "oText")
1497
1650
  ]
1498
1651
  }, cardKey);
1499
1652
  }
@@ -1502,7 +1655,7 @@
1502
1655
  className: "dstv_hcard compactionCard",
1503
1656
  children: [
1504
1657
  jsx("span", { className: "dstv_name", children: `♺ ${t("node.compaction")}` }, "cName"),
1505
- jsx("div", { className: "dstv_text dstv_clamp2", title: s.summary, children: s.summary || "…" }, "cText")
1658
+ jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.summary), children: cardText(s.summary) || "…" }, "cText")
1506
1659
  ]
1507
1660
  }, cardKey);
1508
1661
  }
@@ -1511,7 +1664,7 @@
1511
1664
  className: "dstv_hcard errorCard",
1512
1665
  children: [
1513
1666
  jsx("span", { className: "dstv_name", children: `✗ ${t("node.error")}` }, "eName"),
1514
- jsx("div", { className: "dstv_text dstv_clamp2", title: s.message, children: s.message || "…" }, "eText")
1667
+ jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "eText")
1515
1668
  ]
1516
1669
  }, cardKey);
1517
1670
  }
@@ -1520,7 +1673,7 @@
1520
1673
  className: "dstv_hcard retryCard",
1521
1674
  children: [
1522
1675
  jsx("span", { className: "dstv_name", children: `↻ ${t("node.retry")}${Number.isFinite(s.retry) ? ` #${s.retry}` : ""}` }, "rName"),
1523
- jsx("div", { className: "dstv_text sec dstv_clamp2", title: s.message, children: s.message || "…" }, "rText")
1676
+ jsx("div", { className: "dstv_text sec dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "rText")
1524
1677
  ]
1525
1678
  }, cardKey);
1526
1679
  }
@@ -1539,7 +1692,7 @@
1539
1692
  `${t("node.unknown")}${s.eventType !== "" ? ` · ${s.eventType}` : ""}`,
1540
1693
  jsx("span", { className: "dstv_chips", children: jsx("span", { className: "dstv_chip", children: `seq ${s.seq}` }, "ukSeq") }, "ukChips")
1541
1694
  ] }, "ukName"),
1542
- s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: s.payload, children: s.payload }, "ukText") : null
1695
+ s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: cardTitle(s.payload), children: cardText(s.payload) }, "ukText") : null
1543
1696
  ]
1544
1697
  }, cardKey);
1545
1698
  }
@@ -1577,6 +1730,15 @@
1577
1730
  if (s.kind === "maxTokens") k = "error";
1578
1731
  const done = reached && (s.kind !== "step" || !s.live);
1579
1732
  const matched = searching && matchSet.has(i);
1733
+ // Two DIFFERENT derived values, and the signature must hash each one.
1734
+ // `data-active` is `revealed !== null && i === R - 1`; the tab stop is that
1735
+ // OR the overview's first tick. Hashing only the tab stop made the two states
1736
+ // collide at i == 0: overview gives tab=1/active=0, selecting the first
1737
+ // station gives tab=1/active=1, so the cached tick kept `data-active`
1738
+ // undefined and the strip highlighted nothing (measured: three stations,
1739
+ // overview, click tick 0 → cards show selection 0, minimap active set []).
1740
+ const tickActive = revealed !== null && i === R - 1;
1741
+ const tickTab = tickActive || (revealed === null && i === 0);
1580
1742
  // Same element-identity trick as the station cards: an unchanged tick keeps
1581
1743
  // its element and React skips it (§13.72).
1582
1744
  const tickSig = s.kind + "\u0002" + String(i) + "\u0002" + (reached ? "1" : "0")
@@ -1590,7 +1752,8 @@
1590
1752
  // overview half (`revealed === null && i === 0`). Hashing only the active
1591
1753
  // half left tick 0 with `tabIndex: 0` after any selection, so the strip had
1592
1754
  // TWO tab stops (measured: [0, 5] after selecting station 5).
1593
- + "\u0002" + ((revealed !== null && i === R - 1) || (revealed === null && i === 0) ? "1" : "0")
1755
+ + "\u0002" + (tickTab ? "1" : "0")
1756
+ + "\u0002" + (tickActive ? "1" : "0")
1594
1757
  // `data-k` reads the DERIVED kind, which is "tool" for a step that contains
1595
1758
  // one — hash the value actually used rather than re-deriving it here.
1596
1759
  + "\u0002" + k
@@ -1605,7 +1768,7 @@
1605
1768
  "data-k": k,
1606
1769
  "data-done": done ? "true" : undefined,
1607
1770
  "data-dim": reached ? undefined : "true",
1608
- "data-active": revealed !== null && i === R - 1 ? "true" : undefined,
1771
+ "data-active": tickActive ? "true" : undefined,
1609
1772
  "data-live": s.kind === "step" && s.live === true ? "true" : undefined,
1610
1773
  "data-match": matched ? "true" : undefined,
1611
1774
  // Roving tabindex, same as the station list. This strip is a SECOND
@@ -1616,7 +1779,7 @@
1616
1779
  // ...but exactly one tick must stay reachable, or the whole strip
1617
1780
  // disappears from the keyboard in the overview state. Same rule as
1618
1781
  // the station list: the active one, else the first.
1619
- tabIndex: (revealed !== null && i === R - 1) || (revealed === null && i === 0) ? 0 : -1,
1782
+ tabIndex: tickTab ? 0 : -1,
1620
1783
  // `s.label` is undefined for user stations, so the tooltip read
1621
1784
  // "undefined · 6:13:20 AM" and the button had no accessible name at
1622
1785
  // all. Fall back to the kind and always expose aria-label.
@@ -1835,7 +1998,7 @@
1835
1998
  if (s.kind === "orphan-tool") {
1836
1999
  const body = s.displayText !== "" ? s.displayText : t("orphan.noText");
1837
2000
  return jsxs("div", { className: "dstv_dBody", children: [
1838
- jsx("span", { className: "dstv_dLabel", children: `${t("node.orphanTool")} · ${s.name}` }, "oLbl"),
2001
+ jsx("span", { className: "dstv_dLabel", children: `${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}` }, "oLbl"),
1839
2002
  jsx("div", { className: "dstv_dSection", children: [
1840
2003
  jsx("span", { className: "dstv_chip info", children: t("orphan.badge") }, "oBadge"),
1841
2004
  jsx("span", { className: "dstv_chip", children: `callId ${s.callId}` }, "oCid")
@@ -1908,40 +2071,10 @@
1908
2071
  ] }, `dr${cell.id}`) : null,
1909
2072
  cell.resultText === "" && !cell.isError && !cell.running ? jsx("span", { className: "dstv_dLabel sec", children: t("detail.noResult") }, "tNoRes") : null,
1910
2073
  cell.subCalls.length > 0 ? jsxs("details", { className: "dstv_det", open: cell.subCalls.some((sub) => sub.isError), children: [
1911
- jsx("summary", { children: [`${t("detail.subCalls")} (${cell.subCalls.length})`, cell.subCalls.some((sub) => sub.isError) ? jsx("span", { className: "dstv_chip err", children: t("chip.error") }, "tSubErr") : null] }, "tSubSum"),
2074
+ jsx("summary", { children: [`${t("detail.subCalls")} (${cell.subCalls.length})${cell.subCallsTruncated === true && Number.isSafeInteger(cell.subCallsTotal) ? ` · ${t("detail.subCallsCut").replace("{shown}", String(cell.subCalls.length)).replace("{total}", String(cell.subCallsTotal))}` : ""}`, cell.subCalls.some((sub) => sub.isError) ? jsx("span", { className: "dstv_chip err", children: t("chip.error") }, "tSubErr") : null] }, "tSubSum"),
1912
2075
  jsx("div", {
1913
2076
  className: "inner",
1914
- children: cell.subCalls.map((sub, i) => {
1915
- const subPretty = prettyArgs(sub.argsRaw);
1916
- return jsxs("div", {
1917
- className: "dstv_subCard",
1918
- children: [
1919
- jsxs("span", {
1920
- className: "dstv_subHead",
1921
- children: [
1922
- sub.running ? jsx("i", { className: "dstv_dot", "data-live": true }, "sIcon") : sub.isError ? jsx("span", { className: "dstv_bad", children: "✗" }, "sIcon") : jsx("span", { className: "dstv_ok", children: "✓" }, "sIcon"),
1923
- jsx("span", { className: "tname", children: `↳ ${sub.name}` }, "sName"),
1924
- jsx("span", { className: "dstv_chips", children: [
1925
- sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
1926
- sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
1927
- sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
1928
- ] }, "sChips")
1929
- ]
1930
- }, "sHead"),
1931
- sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
1932
- jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sArgSum"),
1933
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sArgCode") }, "sArgInner")
1934
- ] }, "sArgs") : null,
1935
- sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
1936
- jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sResSum"),
1937
- jsx("div", { className: "inner", children: jsxs("div", { children: [
1938
- jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
1939
- jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
1940
- ] }) }, "sResInner")
1941
- ] }, "sRes") : null
1942
- ]
1943
- }, `ts${i}`);
1944
- })
2077
+ children: renderSubCalls(cell.subCalls, 0)
1945
2078
  }, "tSubInner")
1946
2079
  ] }, `ds${cell.id}`) : null
1947
2080
  ] }, `dt${cell.id}`);
@@ -2041,6 +2174,12 @@
2041
2174
  // fields can be drifted. Normalise ONCE here — every reader below
2042
2175
  // (`tools.map`, the JSON previews, the React keys) then sees a safe shape.
2043
2176
  const tools = safeToolList(req.prompt?.tools);
2177
+ // The contract says `prompt.system` is EMPTY when the system node sits outside the
2178
+ // loaded window; the snapshot still carries it (`systemFrom`, filled by the fold).
2179
+ // Showing "0 chars" there was a silent lie about what the model saw.
2180
+ const savedPrompt = req.systemFrom !== null && req.systemFrom !== void 0 ? req.systemFrom : null;
2181
+ const systemText = (req.prompt?.system ?? "") !== "" ? req.prompt.system
2182
+ : (savedPrompt !== null ? String(savedPrompt.text ?? "") : "");
2044
2183
  const diff = req.promptDiff ?? null;
2045
2184
  const evidenceChips = evidenceOf(req, activeMessages, hasMore);
2046
2185
 
@@ -2051,7 +2190,7 @@
2051
2190
  temperature: cfg.temperature,
2052
2191
  reasoningEffort: cfg.reasoningEffort,
2053
2192
  maxTokens: cfg.maxTokens,
2054
- system: req.prompt?.system ?? "",
2193
+ system: systemText,
2055
2194
  tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })),
2056
2195
  messages: messages.map((m) => m.role === "note"
2057
2196
  ? { role: "user", content: [{ type: "text", text: m.text }] }
@@ -2065,7 +2204,7 @@
2065
2204
  // else; the request tab was the only place that called JSON directly.
2066
2205
  const payloadJson = safeJsonPreview(payload, Number.MAX_SAFE_INTEGER, 2);
2067
2206
  const sysToolsJson = safeJsonPreview(tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })), Number.MAX_SAFE_INTEGER, 2);
2068
- const sysJson = safeJsonPreview({ system: req.prompt?.system ?? "", tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })) }, Number.MAX_SAFE_INTEGER, 2);
2207
+ const sysJson = safeJsonPreview({ system: systemText, tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })) }, Number.MAX_SAFE_INTEGER, 2);
2069
2208
 
2070
2209
  return jsxs("div", { className: "dstv_dBody", children: [
2071
2210
  // config + lifecycle chips
@@ -2118,13 +2257,14 @@
2118
2257
  req.prompt !== null ? jsxs("div", { className: "dstv_dSection", children: [
2119
2258
  jsxs("div", { className: "dstv_dSecHead", children: [
2120
2259
  jsx("span", { children: `🧠 ${t("detail.systemPrompt")}` }, "spHead"),
2121
- jsx("span", { className: "sub", children: `${fmtInt(req.prompt.systemChars)} ${t("detail.chars")}` }, "spLen"),
2260
+ jsx("span", { className: "sub", children: `${fmtInt(systemText.length)} ${t("detail.chars")}` }, "spLen"),
2261
+ savedPrompt !== null ? jsx("span", { className: "sub", children: t("detail.systemOutside").replace("{seq}", String(savedPrompt.seq)) }, "spOut") : null,
2122
2262
  jsx("span", { className: "grow" }, "spGrow"),
2123
2263
  jsx(CopyBtn, { text: sysJson, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "spCopy")
2124
2264
  ] }, "spSecHead"),
2125
2265
  jsxs("details", { className: "dstv_det", open: false, children: [
2126
2266
  jsx("summary", { children: [t("detail.systemPrompt")] }, "spSum"),
2127
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children: req.prompt.system || "…" }, "spCode") }, "spInner")
2267
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children: systemText !== "" ? systemText : t("detail.systemNone") }, "spCode") }, "spInner")
2128
2268
  ] }, "spDet")
2129
2269
  ] }, "spSec") : null,
2130
2270
  // tool catalog
@@ -2263,7 +2403,18 @@
2263
2403
  okLabel: t("anchor.copied"),
2264
2404
  failLabel: t("anchor.copyFailed")
2265
2405
  }, "dExportStep"),
2266
- jsx("button", { type: "button", className: "dstv_btn dstv_panelToggle", title: panelFull ? t("action.collapsePanel") : t("action.expandPanel"), onClick: () => setPanelFull((v) => !v), children: panelFull ? "⤡" : "⤢" }, "dToggle")
2406
+ jsx("button", {
2407
+ type: "button",
2408
+ className: "dstv_btn dstv_panelToggle",
2409
+ title: panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
2410
+ // A glyph is not a name. Chromium's AX tree announced this control as
2411
+ // "button, ⤢" — the arrow is a picture, and a screen reader user had
2412
+ // to guess what it does. The title alone is a tooltip, not a name.
2413
+ "aria-label": panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
2414
+ "aria-expanded": panelFull ? "true" : "false",
2415
+ onClick: () => setPanelFull((v) => !v),
2416
+ children: panelFull ? "⤡" : "⤢"
2417
+ }, "dToggle")
2267
2418
  ]
2268
2419
  }, "dHead"),
2269
2420
  // The key must include WHAT is being rendered, not just where. An error
@@ -2291,7 +2442,7 @@
2291
2442
  jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.turns) }, "kvNum"), jsx("span", { children: t("node.turn") }, "kvLbl")] }, "kTurns"),
2292
2443
  jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.steps) }, "kvNum"), jsx("span", { children: t("node.step") }, "kvLbl")] }, "kSteps"),
2293
2444
  jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.tools) }, "kvNum"), jsx("span", { children: t("node.tool") }, "kvLbl")] }, "kTools"),
2294
- jsxs("span", { className: `dstv_kpi${stats.errors > 0 ? " err" : ""}`, children: [jsx("b", { children: String(stats.errors) }, "kvNum"), jsx("span", { children: t("kpi.errors") }, "kvLbl")] }, "kErr"),
2445
+ jsxs("span", { className: `dstv_kpi${stats.errors > 0 ? " err" : ""}`, children: [jsx("b", { children: String(stats.errors) }, "kvNum"), jsx("span", { children: t("kpi.errorSteps") }, "kvLbl")] }, "kErr"),
2295
2446
  jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtDur(stats.toolMs) }, "kvNum"), jsx("span", { children: t("kpi.toolTime") }, "kvLbl")] }, "kDur"),
2296
2447
  stats.tokensIn > 0 ? jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtTokens(stats.tokensIn) }, "kvNum"), jsx("span", { children: t("kpi.tokensIn") }, "kvLbl")] }, "kTokIn") : null,
2297
2448
  stats.tokensOut > 0 ? jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtTokens(stats.tokensOut) }, "kvNum"), jsx("span", { children: t("kpi.tokensOut") }, "kvLbl")] }, "kTokOut") : null,