dsh-trajectory-traceview-plus 0.11.4 → 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/CHANGELOG.md +199 -0
- package/README.en.md +26 -13
- package/README.md +36 -17
- package/docs/DESIGN.md +1128 -8
- package/docs/PROVENANCE.md +11 -2
- package/lib/client.js +745 -121
- package/package.json +2 -2
- package/scripts/browser-check.mjs +25 -3
- package/scripts/browser-harness.mjs +13 -0
- package/scripts/build-client.mjs +9 -0
- package/scripts/harness-stamp.mjs +56 -0
- package/scripts/path-leak-check.mjs +71 -0
- package/scripts/readme-numbers.mjs +13 -2
- package/scripts/shortcut-check.mjs +33 -8
- package/src/00-locale.js +17 -0
- package/src/10-styles.js +19 -2
- package/src/30-helpers.js +297 -41
- package/src/40-view.js +412 -78
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
|
|
@@ -270,6 +296,10 @@
|
|
|
270
296
|
// applied to a completely different transcript. `sessionKey` arrives from the
|
|
271
297
|
// slot's `inject`; when the host does not provide one, behaviour is unchanged.
|
|
272
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);
|
|
273
303
|
// ── view state that survives a tab switch ─────────────────────────────
|
|
274
304
|
// The host UNMOUNTS this panel when the reader looks at the conversation and
|
|
275
305
|
// remounts it on return (measured: root count 0 → 1). Without this, every
|
|
@@ -288,7 +318,11 @@
|
|
|
288
318
|
// moment the reader typed a query — while the timeline had not moved at all —
|
|
289
319
|
// and then the FIRST "next" went to match 2, so match 1 was only reachable by
|
|
290
320
|
// wrapping all the way round.
|
|
291
|
-
|
|
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);
|
|
292
326
|
const [follow, setFollow] = (0, react.useState)(true);
|
|
293
327
|
const [panelFull, setPanelFull] = (0, react.useState)(false);
|
|
294
328
|
const [anchorNote, setAnchorNote] = (0, react.useState)(null);
|
|
@@ -355,9 +389,13 @@
|
|
|
355
389
|
requests: snap.requests,
|
|
356
390
|
callSchemas: snap.callSchemas,
|
|
357
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,
|
|
358
396
|
partial: partialRef.current
|
|
359
397
|
}, t),
|
|
360
|
-
[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]
|
|
361
399
|
);
|
|
362
400
|
const stations = tree.stations;
|
|
363
401
|
const stationsRef = (0, react.useRef)(stations);
|
|
@@ -395,14 +433,36 @@
|
|
|
395
433
|
setFollow(true);
|
|
396
434
|
setRevealed(null); // overview: show the whole new transcript
|
|
397
435
|
setQueryRaw("");
|
|
398
|
-
|
|
436
|
+
setMatchId(null);
|
|
399
437
|
setOlderNote(null);
|
|
400
438
|
setPanelFull(false);
|
|
401
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);
|
|
402
446
|
}, [sessionKey]);
|
|
403
447
|
|
|
404
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.
|
|
405
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
|
+
}
|
|
406
466
|
writeViewState(sessionKey, revealed, queryRaw);
|
|
407
467
|
}, [sessionKey, revealed, queryRaw]);
|
|
408
468
|
|
|
@@ -544,15 +604,23 @@
|
|
|
544
604
|
const stepPrev = () => {
|
|
545
605
|
setPlaying(false);
|
|
546
606
|
setFollow(false);
|
|
547
|
-
|
|
548
|
-
|
|
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
|
+
});
|
|
549
616
|
};
|
|
550
617
|
const stepNext = () => {
|
|
551
618
|
setPlaying(false);
|
|
552
619
|
setFollow(false);
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
620
|
+
setRevealed((r) => {
|
|
621
|
+
if (r === null) return N > 0 ? 1 : null;
|
|
622
|
+
return r < N ? r + 1 : null;
|
|
623
|
+
});
|
|
556
624
|
};
|
|
557
625
|
const toEnd = () => {
|
|
558
626
|
setPlaying(false);
|
|
@@ -801,7 +869,7 @@
|
|
|
801
869
|
|
|
802
870
|
// ── follow mode: keep the newest station in view while live ──────────
|
|
803
871
|
(0, react.useEffect)(() => {
|
|
804
|
-
if (!follow ||
|
|
872
|
+
if (!follow || !followTipRef.current) return;
|
|
805
873
|
const sc = scrollerRef.current;
|
|
806
874
|
if (sc === null) return;
|
|
807
875
|
try { sc.scrollLeft = sc.scrollWidth; } catch { /* noop */ }
|
|
@@ -813,7 +881,9 @@
|
|
|
813
881
|
const matchSet = (0, react.useMemo)(() => new Set(matches), [matches]);
|
|
814
882
|
const searching = query !== "";
|
|
815
883
|
const scopeNote = searchScopeNote(hasMore, loadingOlder, t);
|
|
816
|
-
(0, react.
|
|
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]);
|
|
817
887
|
const gotoMatch = (dir) => {
|
|
818
888
|
if (matches.length === 0) return;
|
|
819
889
|
// A fresh query has no current match yet, so the FIRST step has to land on an
|
|
@@ -821,7 +891,7 @@
|
|
|
821
891
|
// where the match set shrank between keystrokes.
|
|
822
892
|
const base = matchPtr < 0 || matchPtr >= matches.length ? (dir > 0 ? -1 : 0) : matchPtr;
|
|
823
893
|
const next = ((base + dir) % matches.length + matches.length) % matches.length;
|
|
824
|
-
|
|
894
|
+
setMatchId(stations[matches[next]]?.id ?? null);
|
|
825
895
|
seek(matches[next]);
|
|
826
896
|
};
|
|
827
897
|
const onSearchKey = (ev) => {
|
|
@@ -854,7 +924,12 @@
|
|
|
854
924
|
* (a selected `e30` became `e20`). Station ids are stable across rebuilds, so
|
|
855
925
|
* remember the selected id and re-derive the position from it.
|
|
856
926
|
*/
|
|
857
|
-
|
|
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);
|
|
858
933
|
const stationsSignature = (0, react.useMemo)(() => stations.map((st) => st.id).join("\u0000"), [stations]);
|
|
859
934
|
// Read the station from the list directly: `activeStation` is declared further
|
|
860
935
|
// down, and touching a `const` before its declaration throws ReferenceError on
|
|
@@ -864,20 +939,45 @@
|
|
|
864
939
|
// backwards page (same position, different station) and OVERWROTE the pinned
|
|
865
940
|
// id with whatever now sat at that index, so the repair effect then "confirmed"
|
|
866
941
|
// the wrong station. Verified live: e29532 became e28913 after loading history.
|
|
867
|
-
|
|
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);
|
|
868
957
|
(0, react.useEffect)(() => {
|
|
869
958
|
const selectionChanged = prevRevealedRef.current !== revealed;
|
|
870
959
|
prevRevealedRef.current = revealed;
|
|
871
|
-
|
|
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;
|
|
872
970
|
selectedIdRef.current = revealed === null ? null
|
|
873
971
|
: (stationsRef.current[Math.min(stationsRef.current.length - 1, Math.max(0, revealed - 1))]?.id ?? null);
|
|
874
972
|
// stationsRef is intentionally read through the ref: depending on `stations`
|
|
875
973
|
// here would re-fire on paging, which is the bug being fixed.
|
|
876
974
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
877
|
-
}, [revealed]);
|
|
975
|
+
}, [revealed, N]);
|
|
878
976
|
(0, react.useEffect)(() => {
|
|
879
977
|
const id = selectedIdRef.current;
|
|
880
|
-
|
|
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;
|
|
881
981
|
const at = stations.findIndex((st) => st.id === id);
|
|
882
982
|
// Gone from the window (should not happen for a prepend) or already correct.
|
|
883
983
|
if (at < 0 || at + 1 === revealed) return;
|
|
@@ -983,6 +1083,17 @@
|
|
|
983
1083
|
seek(i); ev.preventDefault(); ev.stopPropagation();
|
|
984
1084
|
}
|
|
985
1085
|
};
|
|
1086
|
+
// Refreshed after commit; a cached element reads it at click/key time. A layout
|
|
1087
|
+
// effect rather than a render-time assignment, because a render React throws away
|
|
1088
|
+
// would otherwise leave the abandoned pass's handler behind.
|
|
1089
|
+
//
|
|
1090
|
+
// DECLARED HERE, above `if (N === 0)` and its early return: a hook below that
|
|
1091
|
+
// branch is skipped on the empty/loading render, and React aborts the whole panel
|
|
1092
|
+
// with "Rendered fewer hooks than expected".
|
|
1093
|
+
(0, react.useLayoutEffect)(() => {
|
|
1094
|
+
handlersRef.current.seek = seek;
|
|
1095
|
+
handlersRef.current.keyDown = stationOnKeyDown;
|
|
1096
|
+
});
|
|
986
1097
|
const onKeyDown = (ev) => {
|
|
987
1098
|
const k = ev.key;
|
|
988
1099
|
// Browser and OS shortcuts must win. The panel root is focusable
|
|
@@ -993,6 +1104,12 @@
|
|
|
993
1104
|
// scrolling to the top. Bail out on any modifier combination.
|
|
994
1105
|
if (ev.ctrlKey === true || ev.metaKey === true || ev.altKey === true) return;
|
|
995
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.
|
|
996
1113
|
if (tag === "input" || tag === "textarea" || tag === "select" || (ev.target && ev.target.isContentEditable === true)) return;
|
|
997
1114
|
if (k === "/" || k === "f") {
|
|
998
1115
|
if (searchRef.current !== null && typeof searchRef.current.focus === "function") { searchRef.current.focus(); ev.preventDefault(); }
|
|
@@ -1170,7 +1287,12 @@
|
|
|
1170
1287
|
type: "search",
|
|
1171
1288
|
autoComplete: "off",
|
|
1172
1289
|
"aria-label": t("search.label"),
|
|
1173
|
-
|
|
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,
|
|
1174
1296
|
placeholder: t("action.search"),
|
|
1175
1297
|
onChange: (ev) => setQueryRaw(ev.target != null ? ev.target.value : ""),
|
|
1176
1298
|
onKeyDown: onSearchKey
|
|
@@ -1295,6 +1417,137 @@
|
|
|
1295
1417
|
});
|
|
1296
1418
|
}
|
|
1297
1419
|
|
|
1420
|
+
/**
|
|
1421
|
+
* Element cache for the station list and the minimap.
|
|
1422
|
+
*
|
|
1423
|
+
* Why: the list renders EVERY station on every state change. Measured on a
|
|
1424
|
+
* 900-station window, one keystroke in the search box cost 1.3–2.2 s of main
|
|
1425
|
+
* thread — typing a query was unusable. The tree fold is NOT the cost (that is
|
|
1426
|
+
* memoised and does not re-run on a keystroke); the cost is rebuilding ~900 card
|
|
1427
|
+
* subtrees and ~900 minimap buttons to flip `data-seek-dim` on the handful of
|
|
1428
|
+
* stations that actually matched.
|
|
1429
|
+
*
|
|
1430
|
+
* Rebuilding an element and re-rendering it are different costs, and React bails
|
|
1431
|
+
* out of the second when the ELEMENT IS THE SAME OBJECT (referential equality).
|
|
1432
|
+
* So: cache the element per station and return the previous one when nothing the
|
|
1433
|
+
* card reads has changed. Compared by VALUE — each fold allocates fresh station
|
|
1434
|
+
* objects, so nothing else here can be compared by identity (§13.72).
|
|
1435
|
+
*
|
|
1436
|
+
* The signature covers exactly what the card body reads: the station fields
|
|
1437
|
+
* `renderStationCard` + the axis zone touch, its position, its neighbour's edge
|
|
1438
|
+
* (the idle band), and the four per-station booleans the parent computes.
|
|
1439
|
+
*/
|
|
1440
|
+
// FNV-1a over the fields the card reads, accumulated WITHOUT building a
|
|
1441
|
+
// concatenated string. The first version joined every field into one string —
|
|
1442
|
+
// harmlessly fast on the fixture, but a real 1000-node window carries ~1.1 MB of
|
|
1443
|
+
// tool output, and joining that per station per render made a keystroke cost
|
|
1444
|
+
// 1.17 s again. A rolling hash over each field is linear either way, but it
|
|
1445
|
+
// allocates nothing (§13.73).
|
|
1446
|
+
|
|
1447
|
+
const stationSig = (s) => {
|
|
1448
|
+
if (s == null) return "";
|
|
1449
|
+
let h = 2166136261;
|
|
1450
|
+
const mix = (v) => {
|
|
1451
|
+
if (v === null || v === void 0) { h = (h ^ 31) * 16777619 >>> 0; return; }
|
|
1452
|
+
if (typeof v === "number") {
|
|
1453
|
+
h = (h ^ (v | 0)) * 16777619 >>> 0;
|
|
1454
|
+
h = (h ^ (Math.floor(v * 1000) | 0)) * 16777619 >>> 0;
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
if (typeof v === "boolean") { h = (h ^ (v ? 1 : 2)) * 16777619 >>> 0; return; }
|
|
1458
|
+
const str = String(v);
|
|
1459
|
+
h = (h ^ str.length) * 16777619 >>> 0;
|
|
1460
|
+
for (let i = 0; i < str.length; i += 1) h = ((h ^ str.charCodeAt(i)) * 16777619) >>> 0;
|
|
1461
|
+
};
|
|
1462
|
+
mix(s.kind); mix(s.id); mix(s.label); mix(s.who); mix(s.text);
|
|
1463
|
+
mix(s.displayText); mix(s.summary); mix(s.message); mix(s.name);
|
|
1464
|
+
mix(s.args); mix(s.payload); mix(s.eventType); mix(s.replace); mix(s.retry);
|
|
1465
|
+
mix(s.isError); mix(s.hasError); mix(s.live); mix(s.synthetic); mix(s.tag);
|
|
1466
|
+
mix(s.time); mix(s.startMs); mix(s.endMs); mix(s.seq); mix(s.toolMs); mix(s.maxToolMs);
|
|
1467
|
+
// The duration bar divides by a GLOBAL denominator (`stats.maxToolMs ||
|
|
1468
|
+
// stats.toolMs`), not by this station's own maximum. Mixing only the station
|
|
1469
|
+
// fields meant every cached bar kept its old width when a DIFFERENT station
|
|
1470
|
+
// became the slowest one — a stale proportion bar, caught by review.
|
|
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));
|
|
1477
|
+
mix(s.outcomeText); mix(s.outcomeKind);
|
|
1478
|
+
if (Array.isArray(s.meta)) { mix(s.meta.length); for (const m of s.meta) mix(m); }
|
|
1479
|
+
else mix(s.meta);
|
|
1480
|
+
// EVERY cell field the card renders, not just the shape. The first version
|
|
1481
|
+
// hashed only kind/isError/running — so a settled step whose assistant cell text
|
|
1482
|
+
// changed kept the OLD text on the card (verified: ALPHA-ONE stayed on screen
|
|
1483
|
+
// while the detail panel showed ALPHA-TWO). `resultText` is deliberately absent:
|
|
1484
|
+
// the card does not render it and it is by far the largest field (§13.75).
|
|
1485
|
+
if (Array.isArray(s.cells)) {
|
|
1486
|
+
mix(s.cells.length);
|
|
1487
|
+
for (const c of s.cells) {
|
|
1488
|
+
mix(c.kind); mix(c.id);
|
|
1489
|
+
mix(c.text); mix(c.thinking);
|
|
1490
|
+
mix(c.name); mix(c.args); mix(c.errorName);
|
|
1491
|
+
mix(c.durationMs); mix(c.isError === true); mix(c.running === true);
|
|
1492
|
+
}
|
|
1493
|
+
} else mix(-1);
|
|
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));
|
|
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
|
+
});
|
|
1298
1551
|
const renderStationCard = (s, cardKey) => {
|
|
1299
1552
|
if (s.kind === "user") {
|
|
1300
1553
|
return jsxs("div", {
|
|
@@ -1302,7 +1555,7 @@
|
|
|
1302
1555
|
children: [
|
|
1303
1556
|
jsx("span", { className: "dstv_name", children: s.who }, "uName"),
|
|
1304
1557
|
s.time != null ? jsx("span", { className: "dstv_spanRow", children: jsx("span", { className: "dstv_spanEdge", children: fmtClock(s.time) }, "uClk") }, "uSpan") : null,
|
|
1305
|
-
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")
|
|
1306
1559
|
]
|
|
1307
1560
|
}, cardKey);
|
|
1308
1561
|
}
|
|
@@ -1340,8 +1593,8 @@
|
|
|
1340
1593
|
className: "dstv_cellRow",
|
|
1341
1594
|
children: [
|
|
1342
1595
|
jsx("span", { className: "dstv_cellName", children: t("node.assistant") }, "aName"),
|
|
1343
|
-
cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cell.thinking, children: `💭 ${markdownToPlain(cell.thinking)}` }, "aThink") : null,
|
|
1344
|
-
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
|
|
1345
1598
|
]
|
|
1346
1599
|
}, `a${cell.id}`);
|
|
1347
1600
|
}
|
|
@@ -1380,12 +1633,20 @@
|
|
|
1380
1633
|
className: "dstv_name",
|
|
1381
1634
|
children: [
|
|
1382
1635
|
jsx("span", { className: s.isError ? "dstv_bad" : "dstv_ok", children: s.isError ? "✗" : "⤷" }, "oIcon"),
|
|
1383
|
-
|
|
1384
|
-
|
|
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")
|
|
1385
1646
|
]
|
|
1386
1647
|
}, "oName"),
|
|
1387
|
-
s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: s.args, children: s.args }, "oArgs") : null,
|
|
1388
|
-
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")
|
|
1389
1650
|
]
|
|
1390
1651
|
}, cardKey);
|
|
1391
1652
|
}
|
|
@@ -1394,7 +1655,7 @@
|
|
|
1394
1655
|
className: "dstv_hcard compactionCard",
|
|
1395
1656
|
children: [
|
|
1396
1657
|
jsx("span", { className: "dstv_name", children: `♺ ${t("node.compaction")}` }, "cName"),
|
|
1397
|
-
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")
|
|
1398
1659
|
]
|
|
1399
1660
|
}, cardKey);
|
|
1400
1661
|
}
|
|
@@ -1403,7 +1664,7 @@
|
|
|
1403
1664
|
className: "dstv_hcard errorCard",
|
|
1404
1665
|
children: [
|
|
1405
1666
|
jsx("span", { className: "dstv_name", children: `✗ ${t("node.error")}` }, "eName"),
|
|
1406
|
-
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")
|
|
1407
1668
|
]
|
|
1408
1669
|
}, cardKey);
|
|
1409
1670
|
}
|
|
@@ -1412,7 +1673,7 @@
|
|
|
1412
1673
|
className: "dstv_hcard retryCard",
|
|
1413
1674
|
children: [
|
|
1414
1675
|
jsx("span", { className: "dstv_name", children: `↻ ${t("node.retry")}${Number.isFinite(s.retry) ? ` #${s.retry}` : ""}` }, "rName"),
|
|
1415
|
-
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")
|
|
1416
1677
|
]
|
|
1417
1678
|
}, cardKey);
|
|
1418
1679
|
}
|
|
@@ -1431,7 +1692,7 @@
|
|
|
1431
1692
|
`${t("node.unknown")}${s.eventType !== "" ? ` · ${s.eventType}` : ""}`,
|
|
1432
1693
|
jsx("span", { className: "dstv_chips", children: jsx("span", { className: "dstv_chip", children: `seq ${s.seq}` }, "ukSeq") }, "ukChips")
|
|
1433
1694
|
] }, "ukName"),
|
|
1434
|
-
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
|
|
1435
1696
|
]
|
|
1436
1697
|
}, cardKey);
|
|
1437
1698
|
}
|
|
@@ -1459,6 +1720,9 @@
|
|
|
1459
1720
|
const minimapTicks = jsx("div", {
|
|
1460
1721
|
className: "dstv_minimap",
|
|
1461
1722
|
ref: minimapRef,
|
|
1723
|
+
// Same reason as the listbox: search dimming is one attribute on the strip,
|
|
1724
|
+
// not one per tick, so a keystroke does not rebuild every tick element.
|
|
1725
|
+
"data-searching": searching ? "true" : undefined,
|
|
1462
1726
|
children: stations.map((s, i) => {
|
|
1463
1727
|
const reached = i < R;
|
|
1464
1728
|
let k = s.kind;
|
|
@@ -1466,14 +1730,45 @@
|
|
|
1466
1730
|
if (s.kind === "maxTokens") k = "error";
|
|
1467
1731
|
const done = reached && (s.kind !== "step" || !s.live);
|
|
1468
1732
|
const matched = searching && matchSet.has(i);
|
|
1469
|
-
|
|
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);
|
|
1742
|
+
// Same element-identity trick as the station cards: an unchanged tick keeps
|
|
1743
|
+
// its element and React skips it (§13.72).
|
|
1744
|
+
const tickSig = s.kind + "\u0002" + String(i) + "\u0002" + (reached ? "1" : "0")
|
|
1745
|
+
+ (done ? "1" : "0") + (matched ? "1" : "0") + (s.live === true ? "1" : "0")
|
|
1746
|
+
+ (k === "tool" || k === "step" ? String(s.cells.length) : "")
|
|
1747
|
+
// The highlight and the "N / total" part of the aria-label change with the
|
|
1748
|
+
// selection and with the window length. Missing either leaves the old
|
|
1749
|
+
// highlight cached — caught by the minimap assertion, not by reasoning.
|
|
1750
|
+
//
|
|
1751
|
+
// The tab stop is the SAME expression as `tabIndex` below, including its
|
|
1752
|
+
// overview half (`revealed === null && i === 0`). Hashing only the active
|
|
1753
|
+
// half left tick 0 with `tabIndex: 0` after any selection, so the strip had
|
|
1754
|
+
// TWO tab stops (measured: [0, 5] after selecting station 5).
|
|
1755
|
+
+ "\u0002" + (tickTab ? "1" : "0")
|
|
1756
|
+
+ "\u0002" + (tickActive ? "1" : "0")
|
|
1757
|
+
// `data-k` reads the DERIVED kind, which is "tool" for a step that contains
|
|
1758
|
+
// one — hash the value actually used rather than re-deriving it here.
|
|
1759
|
+
+ "\u0002" + k
|
|
1760
|
+
+ "\u0002" + minimapTickLabel(s) + "\u0002" + fmtClock(s.time)
|
|
1761
|
+
+ "\u0002" + String(stations.length);
|
|
1762
|
+
const tickHit = tickElCache.current.get(i);
|
|
1763
|
+
if (tickHit !== undefined && tickHit.sig === tickSig && tickHit.t === t) return tickHit.el;
|
|
1764
|
+
const tickEl = jsx("button", {
|
|
1470
1765
|
type: "button",
|
|
1471
1766
|
className: "dstv_miniTick",
|
|
1472
1767
|
"data-tick-idx": String(i),
|
|
1473
1768
|
"data-k": k,
|
|
1474
1769
|
"data-done": done ? "true" : undefined,
|
|
1475
|
-
"data-dim": reached ?
|
|
1476
|
-
"data-active":
|
|
1770
|
+
"data-dim": reached ? undefined : "true",
|
|
1771
|
+
"data-active": tickActive ? "true" : undefined,
|
|
1477
1772
|
"data-live": s.kind === "step" && s.live === true ? "true" : undefined,
|
|
1478
1773
|
"data-match": matched ? "true" : undefined,
|
|
1479
1774
|
// Roving tabindex, same as the station list. This strip is a SECOND
|
|
@@ -1484,17 +1779,46 @@
|
|
|
1484
1779
|
// ...but exactly one tick must stay reachable, or the whole strip
|
|
1485
1780
|
// disappears from the keyboard in the overview state. Same rule as
|
|
1486
1781
|
// the station list: the active one, else the first.
|
|
1487
|
-
tabIndex:
|
|
1782
|
+
tabIndex: tickTab ? 0 : -1,
|
|
1488
1783
|
// `s.label` is undefined for user stations, so the tooltip read
|
|
1489
1784
|
// "undefined · 6:13:20 AM" and the button had no accessible name at
|
|
1490
1785
|
// all. Fall back to the kind and always expose aria-label.
|
|
1491
1786
|
title: `${minimapTickLabel(s)}${fmtClock(s.time) !== "" ? ` · ${fmtClock(s.time)}` : ""}`,
|
|
1492
1787
|
"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); }
|
|
1788
|
+
onClick: (ev) => { ev.stopPropagation(); handlersRef.current.seek(i); }
|
|
1494
1789
|
}, `mini${i}`);
|
|
1790
|
+
tickElCache.current.set(i, { sig: tickSig, t, el: tickEl });
|
|
1791
|
+
return tickEl;
|
|
1495
1792
|
})
|
|
1496
1793
|
}, "rootMini");
|
|
1497
1794
|
|
|
1795
|
+
// One signature per station, computed once per TREE rather than once per render.
|
|
1796
|
+
// The per-render version re-hashed every cell body on every keystroke and replay
|
|
1797
|
+
// tick: a real 1.11 MB window cost 105 ms per rebuild instead of 30 ms. `stations`
|
|
1798
|
+
// identity only changes when the fold produces a new tree, so keying on it is
|
|
1799
|
+
// exactly "recompute when the content could have changed".
|
|
1800
|
+
//
|
|
1801
|
+
// A ref rather than useMemo on purpose: this sits BELOW the `if (N === 0)` early
|
|
1802
|
+
// return, and a hook here would be skipped on the empty/loading render (§13.75).
|
|
1803
|
+
const sigPack = sigCacheRef.current;
|
|
1804
|
+
if (sigPack.arr !== stations) {
|
|
1805
|
+
sigPack.arr = stations;
|
|
1806
|
+
sigPack.sigs = stations.map(stationSig);
|
|
1807
|
+
// Drop what the new window no longer contains. A live station is replaced by its
|
|
1808
|
+
// durable twin (new id) on every fold, and paging in older history shifts every
|
|
1809
|
+
// index, so without this the element maps only ever grow — each entry pinning a
|
|
1810
|
+
// whole card subtree and its station closure (§13.75).
|
|
1811
|
+
if (cardElCache.current.size > stations.length || tickElCache.current.size > stations.length) {
|
|
1812
|
+
const live = new Set(stations.map((st) => st.id));
|
|
1813
|
+
for (const key of [...cardElCache.current.keys()]) {
|
|
1814
|
+
if (!live.has(key)) cardElCache.current.delete(key);
|
|
1815
|
+
}
|
|
1816
|
+
for (const key of [...tickElCache.current.keys()]) {
|
|
1817
|
+
if (!(key >= 0 && key < stations.length)) tickElCache.current.delete(key);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
const sigOf = (i) => (i < 0 || i >= sigPack.sigs.length ? "" : sigPack.sigs[i]);
|
|
1498
1822
|
const body = jsxs("div", {
|
|
1499
1823
|
children: [
|
|
1500
1824
|
jsx("div", {
|
|
@@ -1505,10 +1829,17 @@
|
|
|
1505
1829
|
role: "listbox",
|
|
1506
1830
|
"aria-label": t("view.label"),
|
|
1507
1831
|
"aria-orientation": "horizontal",
|
|
1832
|
+
// Dimming non-matches while searching is a CSS job, not a per-card one.
|
|
1833
|
+
// Setting it per station meant the FIRST keystroke invalidated all 900
|
|
1834
|
+
// cards (2.4 s at 900 stations); one attribute on the list lets the
|
|
1835
|
+
// stylesheet do it and leaves every card's element identity intact.
|
|
1836
|
+
"data-searching": searching ? "true" : undefined,
|
|
1508
1837
|
children: [
|
|
1509
1838
|
revealed !== null && playheadLeft !== null ? jsx("span", { className: "dstv_playhead", "aria-hidden": "true", style: { left: `${playheadLeft}px` }, children: jsx("i", {}) }, "ph") : null,
|
|
1510
1839
|
stations.map((s, i) => {
|
|
1511
1840
|
const reached = i < R;
|
|
1841
|
+
const isActive = revealed !== null && i === R - 1;
|
|
1842
|
+
const matched = searching && matchSet.has(i);
|
|
1512
1843
|
// G4-T3: idle gap vs the previous station's end (falls back to its
|
|
1513
1844
|
// start / time). Rendered as an inline band so a long pause between
|
|
1514
1845
|
// two steps is visible without opening either one.
|
|
@@ -1551,14 +1882,27 @@
|
|
|
1551
1882
|
else if (s.kind === "unknown") dotCls += " unknown";
|
|
1552
1883
|
else if (s.kind === "step" && s.cells.some((c) => c.kind === "tool")) dotCls += " tool";
|
|
1553
1884
|
if (s.kind === "step" && s.live === true) dotCls += " live";
|
|
1554
|
-
const matched = searching && matchSet.has(i);
|
|
1555
1885
|
const clock = fmtClock(s.time);
|
|
1556
|
-
|
|
1557
|
-
|
|
1886
|
+
// Everything below is a pure function of (station, neighbour, position,
|
|
1887
|
+
// N, found-in-search). If none of those moved, hand React the element
|
|
1888
|
+
// it already rendered and it skips the whole subtree.
|
|
1889
|
+
const sig = [
|
|
1890
|
+
sigOf(i), sigOf(i - 1), String(i), String(N),
|
|
1891
|
+
reached ? "1" : "0", isActive ? "1" : "0",
|
|
1892
|
+
matched ? "1" : "0", clockAxis ? "1" : "0",
|
|
1893
|
+
// The overview state is its own dependency: station 0 is the roving
|
|
1894
|
+
// tab stop in the overview and is not once a selection exists, even
|
|
1895
|
+
// though neither `reached` nor `isActive` changes for it. Caught by
|
|
1896
|
+
// the roving-tab-stop assertion, not by reasoning (§13.72).
|
|
1897
|
+
revealed === null ? "1" : "0"
|
|
1898
|
+
].join("\u0002");
|
|
1899
|
+
const hit = cardElCache.current.get(s.id);
|
|
1900
|
+
if (hit !== undefined && hit.sig === sig) return hit.el;
|
|
1901
|
+
const el = jsxs("div", {
|
|
1558
1902
|
className: "dstv_station",
|
|
1559
1903
|
"data-station-idx": String(i),
|
|
1560
1904
|
"data-dim": reached ? undefined : "true",
|
|
1561
|
-
|
|
1905
|
+
|
|
1562
1906
|
"data-match": matched ? "true" : undefined,
|
|
1563
1907
|
"data-active": isActive ? "true" : undefined,
|
|
1564
1908
|
role: "option",
|
|
@@ -1571,8 +1915,8 @@
|
|
|
1571
1915
|
"aria-selected": revealed === null ? "false" : (isActive ? "true" : "false"),
|
|
1572
1916
|
"aria-label": stationAriaLabel(s, i + 1, N, t),
|
|
1573
1917
|
tabIndex: isActive || (revealed === null && i === 0) ? 0 : -1,
|
|
1574
|
-
onKeyDown: (ev) =>
|
|
1575
|
-
onClick: () => seek(i),
|
|
1918
|
+
onKeyDown: (ev) => handlersRef.current.keyDown(ev, i),
|
|
1919
|
+
onClick: () => handlersRef.current.seek(i),
|
|
1576
1920
|
children: [
|
|
1577
1921
|
...gapPrefix,
|
|
1578
1922
|
jsxs("div", {
|
|
@@ -1602,6 +1946,8 @@
|
|
|
1602
1946
|
}, `card${s.id}`)
|
|
1603
1947
|
]
|
|
1604
1948
|
}, s.id);
|
|
1949
|
+
cardElCache.current.set(s.id, { sig, el });
|
|
1950
|
+
return el;
|
|
1605
1951
|
})
|
|
1606
1952
|
]
|
|
1607
1953
|
})
|
|
@@ -1652,7 +1998,7 @@
|
|
|
1652
1998
|
if (s.kind === "orphan-tool") {
|
|
1653
1999
|
const body = s.displayText !== "" ? s.displayText : t("orphan.noText");
|
|
1654
2000
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
1655
|
-
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"),
|
|
1656
2002
|
jsx("div", { className: "dstv_dSection", children: [
|
|
1657
2003
|
jsx("span", { className: "dstv_chip info", children: t("orphan.badge") }, "oBadge"),
|
|
1658
2004
|
jsx("span", { className: "dstv_chip", children: `callId ${s.callId}` }, "oCid")
|
|
@@ -1725,40 +2071,10 @@
|
|
|
1725
2071
|
] }, `dr${cell.id}`) : null,
|
|
1726
2072
|
cell.resultText === "" && !cell.isError && !cell.running ? jsx("span", { className: "dstv_dLabel sec", children: t("detail.noResult") }, "tNoRes") : null,
|
|
1727
2073
|
cell.subCalls.length > 0 ? jsxs("details", { className: "dstv_det", open: cell.subCalls.some((sub) => sub.isError), children: [
|
|
1728
|
-
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"),
|
|
1729
2075
|
jsx("div", {
|
|
1730
2076
|
className: "inner",
|
|
1731
|
-
children: cell.subCalls
|
|
1732
|
-
const subPretty = prettyArgs(sub.argsRaw);
|
|
1733
|
-
return jsxs("div", {
|
|
1734
|
-
className: "dstv_subCard",
|
|
1735
|
-
children: [
|
|
1736
|
-
jsxs("span", {
|
|
1737
|
-
className: "dstv_subHead",
|
|
1738
|
-
children: [
|
|
1739
|
-
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"),
|
|
1740
|
-
jsx("span", { className: "tname", children: `↳ ${sub.name}` }, "sName"),
|
|
1741
|
-
jsx("span", { className: "dstv_chips", children: [
|
|
1742
|
-
sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
|
|
1743
|
-
sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
|
|
1744
|
-
sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
|
|
1745
|
-
] }, "sChips")
|
|
1746
|
-
]
|
|
1747
|
-
}, "sHead"),
|
|
1748
|
-
sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
|
|
1749
|
-
jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sArgSum"),
|
|
1750
|
-
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sArgCode") }, "sArgInner")
|
|
1751
|
-
] }, "sArgs") : null,
|
|
1752
|
-
sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
|
|
1753
|
-
jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sResSum"),
|
|
1754
|
-
jsx("div", { className: "inner", children: jsxs("div", { children: [
|
|
1755
|
-
jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
|
|
1756
|
-
jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
|
|
1757
|
-
] }) }, "sResInner")
|
|
1758
|
-
] }, "sRes") : null
|
|
1759
|
-
]
|
|
1760
|
-
}, `ts${i}`);
|
|
1761
|
-
})
|
|
2077
|
+
children: renderSubCalls(cell.subCalls, 0)
|
|
1762
2078
|
}, "tSubInner")
|
|
1763
2079
|
] }, `ds${cell.id}`) : null
|
|
1764
2080
|
] }, `dt${cell.id}`);
|
|
@@ -1858,6 +2174,12 @@
|
|
|
1858
2174
|
// fields can be drifted. Normalise ONCE here — every reader below
|
|
1859
2175
|
// (`tools.map`, the JSON previews, the React keys) then sees a safe shape.
|
|
1860
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 ?? "") : "");
|
|
1861
2183
|
const diff = req.promptDiff ?? null;
|
|
1862
2184
|
const evidenceChips = evidenceOf(req, activeMessages, hasMore);
|
|
1863
2185
|
|
|
@@ -1868,7 +2190,7 @@
|
|
|
1868
2190
|
temperature: cfg.temperature,
|
|
1869
2191
|
reasoningEffort: cfg.reasoningEffort,
|
|
1870
2192
|
maxTokens: cfg.maxTokens,
|
|
1871
|
-
system:
|
|
2193
|
+
system: systemText,
|
|
1872
2194
|
tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })),
|
|
1873
2195
|
messages: messages.map((m) => m.role === "note"
|
|
1874
2196
|
? { role: "user", content: [{ type: "text", text: m.text }] }
|
|
@@ -1882,7 +2204,7 @@
|
|
|
1882
2204
|
// else; the request tab was the only place that called JSON directly.
|
|
1883
2205
|
const payloadJson = safeJsonPreview(payload, Number.MAX_SAFE_INTEGER, 2);
|
|
1884
2206
|
const sysToolsJson = safeJsonPreview(tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })), Number.MAX_SAFE_INTEGER, 2);
|
|
1885
|
-
const sysJson = safeJsonPreview({ system:
|
|
2207
|
+
const sysJson = safeJsonPreview({ system: systemText, tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })) }, Number.MAX_SAFE_INTEGER, 2);
|
|
1886
2208
|
|
|
1887
2209
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
1888
2210
|
// config + lifecycle chips
|
|
@@ -1935,13 +2257,14 @@
|
|
|
1935
2257
|
req.prompt !== null ? jsxs("div", { className: "dstv_dSection", children: [
|
|
1936
2258
|
jsxs("div", { className: "dstv_dSecHead", children: [
|
|
1937
2259
|
jsx("span", { children: `🧠 ${t("detail.systemPrompt")}` }, "spHead"),
|
|
1938
|
-
jsx("span", { className: "sub", children: `${fmtInt(
|
|
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,
|
|
1939
2262
|
jsx("span", { className: "grow" }, "spGrow"),
|
|
1940
2263
|
jsx(CopyBtn, { text: sysJson, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "spCopy")
|
|
1941
2264
|
] }, "spSecHead"),
|
|
1942
2265
|
jsxs("details", { className: "dstv_det", open: false, children: [
|
|
1943
2266
|
jsx("summary", { children: [t("detail.systemPrompt")] }, "spSum"),
|
|
1944
|
-
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children:
|
|
2267
|
+
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children: systemText !== "" ? systemText : t("detail.systemNone") }, "spCode") }, "spInner")
|
|
1945
2268
|
] }, "spDet")
|
|
1946
2269
|
] }, "spSec") : null,
|
|
1947
2270
|
// tool catalog
|
|
@@ -2080,7 +2403,18 @@
|
|
|
2080
2403
|
okLabel: t("anchor.copied"),
|
|
2081
2404
|
failLabel: t("anchor.copyFailed")
|
|
2082
2405
|
}, "dExportStep"),
|
|
2083
|
-
jsx("button", {
|
|
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")
|
|
2084
2418
|
]
|
|
2085
2419
|
}, "dHead"),
|
|
2086
2420
|
// The key must include WHAT is being rendered, not just where. An error
|
|
@@ -2108,7 +2442,7 @@
|
|
|
2108
2442
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.turns) }, "kvNum"), jsx("span", { children: t("node.turn") }, "kvLbl")] }, "kTurns"),
|
|
2109
2443
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.steps) }, "kvNum"), jsx("span", { children: t("node.step") }, "kvLbl")] }, "kSteps"),
|
|
2110
2444
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.tools) }, "kvNum"), jsx("span", { children: t("node.tool") }, "kvLbl")] }, "kTools"),
|
|
2111
|
-
jsxs("span", { className: `dstv_kpi${stats.errors > 0 ? " err" : ""}`, children: [jsx("b", { children: String(stats.errors) }, "kvNum"), jsx("span", { children: t("kpi.
|
|
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"),
|
|
2112
2446
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtDur(stats.toolMs) }, "kvNum"), jsx("span", { children: t("kpi.toolTime") }, "kvLbl")] }, "kDur"),
|
|
2113
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,
|
|
2114
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,
|