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/CHANGELOG.md +165 -1
- package/README.en.md +23 -12
- package/README.md +33 -17
- package/docs/DESIGN.md +306 -8
- package/docs/PROVENANCE.md +8 -2
- package/lib/client.js +528 -113
- package/package.json +2 -2
- package/scripts/browser-check.mjs +7 -5
- 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 +13 -2
- package/src/30-helpers.js +275 -39
- package/src/40-view.js +223 -72
package/lib/client.js
CHANGED
|
@@ -73,6 +73,10 @@ window.__ModuleLoader__.load({
|
|
|
73
73
|
"kpi.tokensIn": "请求 tokens",
|
|
74
74
|
"kpi.tokensOut": "生成 tokens",
|
|
75
75
|
"kpi.errors": "错误",
|
|
76
|
+
// The KPI counts STEPS that contain an error, not error events: one step with 24
|
|
77
|
+
// tool calls and 4 failures shows 1. The bare label "错误 / Errors" made that read
|
|
78
|
+
// as a wrong number; the chip says what it counts now.
|
|
79
|
+
"kpi.errorSteps": "出错步骤",
|
|
76
80
|
// The Token-usage chips were hardcoded English ("in" / "out" / "cache-read" …)
|
|
77
81
|
// inside a Chinese panel, while README §2 describes this section as
|
|
78
82
|
// "入站(含缓存读 / 写)与出站(含思考)". Same words as the README, compact
|
|
@@ -89,6 +93,9 @@ window.__ModuleLoader__.load({
|
|
|
89
93
|
"detail.args": "调用参数",
|
|
90
94
|
"detail.noArgs": "(无参数)",
|
|
91
95
|
"detail.subCalls": "子调用",
|
|
96
|
+
// The budget silently dropped the tail: 20,000 children rendered 1,999 with no
|
|
97
|
+
// indication anywhere. Say how many exist when the list was cut.
|
|
98
|
+
"detail.subCallsCut": "只显示前 {shown} 个(共 {total} 个)",
|
|
92
99
|
"detail.position": "站点",
|
|
93
100
|
"detail.result": "工具结果",
|
|
94
101
|
"detail.noResult": "(无结果内容)",
|
|
@@ -103,6 +110,8 @@ window.__ModuleLoader__.load({
|
|
|
103
110
|
"detail.items": "项",
|
|
104
111
|
"detail.request": "请求配置",
|
|
105
112
|
"detail.systemPrompt": "系统提示",
|
|
113
|
+
"detail.systemOutside": "来自窗口外的系统事件 e{seq}",
|
|
114
|
+
"detail.systemNone": "(当前窗口内没有系统提示)",
|
|
106
115
|
"detail.toolsCatalog": "工具目录",
|
|
107
116
|
"detail.messages": "消息列表",
|
|
108
117
|
"detail.copy": "复制",
|
|
@@ -126,6 +135,8 @@ window.__ModuleLoader__.load({
|
|
|
126
135
|
"gap.idle": "空闲",
|
|
127
136
|
"node.orphanTool": "孤立工具结果",
|
|
128
137
|
"orphan.badge": "调用不在窗口内",
|
|
138
|
+
"node.replayedTool": "压缩重放的工具结果",
|
|
139
|
+
"orphan.replayBadge": "与 e{seq} 相同(上下文压缩后重放)",
|
|
129
140
|
"orphan.noText": "(无结果文本)",
|
|
130
141
|
"timing.notRecorded": "未记录耗时",
|
|
131
142
|
"timing.notRecordedHint": "该步骤没有 timing 记录,无法得到耗时",
|
|
@@ -259,6 +270,7 @@ window.__ModuleLoader__.load({
|
|
|
259
270
|
"kpi.tokensIn": "Prompt tokens",
|
|
260
271
|
"kpi.tokensOut": "Output tokens",
|
|
261
272
|
"kpi.errors": "Errors",
|
|
273
|
+
"kpi.errorSteps": "steps with errors",
|
|
262
274
|
"usage.in": "in",
|
|
263
275
|
"usage.fresh": "fresh",
|
|
264
276
|
"usage.cacheRead": "cache-read",
|
|
@@ -270,6 +282,7 @@ window.__ModuleLoader__.load({
|
|
|
270
282
|
"detail.args": "Call arguments",
|
|
271
283
|
"detail.noArgs": "(no arguments)",
|
|
272
284
|
"detail.subCalls": "Sub-calls",
|
|
285
|
+
"detail.subCallsCut": "showing the first {shown} of {total}",
|
|
273
286
|
"detail.position": "Station",
|
|
274
287
|
"detail.result": "Tool result",
|
|
275
288
|
"detail.noResult": "(no result content)",
|
|
@@ -284,6 +297,8 @@ window.__ModuleLoader__.load({
|
|
|
284
297
|
"detail.items": "items",
|
|
285
298
|
"detail.request": "Request config",
|
|
286
299
|
"detail.systemPrompt": "System prompt",
|
|
300
|
+
"detail.systemOutside": "from system event e{seq} outside the window",
|
|
301
|
+
"detail.systemNone": "(no system prompt in this window)",
|
|
287
302
|
"detail.toolsCatalog": "Tool catalog",
|
|
288
303
|
"detail.messages": "Messages",
|
|
289
304
|
"detail.copy": "Copy",
|
|
@@ -307,6 +322,8 @@ window.__ModuleLoader__.load({
|
|
|
307
322
|
"gap.idle": "Idle",
|
|
308
323
|
"node.orphanTool": "Orphan tool result",
|
|
309
324
|
"orphan.badge": "call outside window",
|
|
325
|
+
"node.replayedTool": "Replayed tool result",
|
|
326
|
+
"orphan.replayBadge": "same as e{seq} (re-sent after compaction)",
|
|
310
327
|
"orphan.noText": "(no result text)",
|
|
311
328
|
"timing.notRecorded": "no duration",
|
|
312
329
|
"timing.notRecordedHint": "This step has no timing record at all",
|
|
@@ -625,6 +642,11 @@ window.__ModuleLoader__.load({
|
|
|
625
642
|
// surface one consistent, high-contrast focus indicator (WCAG 2.4.7/2.4.11).
|
|
626
643
|
".dstv_root button:focus-visible,.dstv_root summary:focus-visible,.dstv_root a:focus-visible,.dstv_root input:focus-visible{outline:2px solid var(--dstv-info);outline-offset:2px;border-radius:6px}",
|
|
627
644
|
// Suppress the ring only for pointer users, never for keyboard users.
|
|
645
|
+
// The panel root is focusable (it owns the keyboard shortcuts), and it had NO focus
|
|
646
|
+
// ring: real Tab put focus on `.dstv_root` with `:focus-visible=true` and
|
|
647
|
+
// `outline-style:none`, so a keyboard user could not see where they were. Inset so
|
|
648
|
+
// the ring is not clipped by the panel's own overflow.
|
|
649
|
+
".dstv_root:focus-visible{outline:2px solid var(--dstv-info);outline-offset:-2px}",
|
|
628
650
|
".dstv_root:focus:not(:focus-visible){outline:none}",
|
|
629
651
|
".dstv_station:focus:not(:focus-visible){outline:none}",
|
|
630
652
|
".dstv_search:focus-within{border-color:var(--dstv-info);box-shadow:0 0 0 2px color-mix(in srgb,var(--dstv-info) 18%,transparent)}",
|
|
@@ -667,8 +689,14 @@ window.__ModuleLoader__.load({
|
|
|
667
689
|
// Searching dims the non-matches. Driven from the listbox so a keystroke does not
|
|
668
690
|
// rewrite every station element (§13.72): reached = not [data-dim], matched =
|
|
669
691
|
// [data-match]. Same visual result, one attribute instead of N.
|
|
670
|
-
|
|
671
|
-
|
|
692
|
+
// `.dstv_listbox` does not exist: the element carrying `data-searching` is the
|
|
693
|
+
// horizontally-scrolling flex row, whose class is `.dstv_hflow`. The rule matched
|
|
694
|
+
// nothing, so typing a query left every non-matching card at full opacity while
|
|
695
|
+
// the MINIMAP dimmed correctly (its selector uses `.dstv_minimap`, which is real).
|
|
696
|
+
// Measured after the move to a container attribute: card opacity 1 / filter none
|
|
697
|
+
// with `data-searching="true"` on the listbox, tick opacity .25.
|
|
698
|
+
".dstv_hflow[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hcard{opacity:.5;filter:saturate(.3)}",
|
|
699
|
+
".dstv_hflow[data-searching=true] .dstv_station:not([data-dim=true]):not([data-match=true]) .dstv_hDot{opacity:.35}",
|
|
672
700
|
".dstv_miniTick[data-match=true]{box-shadow:0 0 0 1.5px var(--dstv-warn);height:14px}",
|
|
673
701
|
// While searching, fade the ticks that did not match. Reached-only ticks fade via
|
|
674
702
|
// [data-dim]; the search fade lives here so it costs no per-tick attribute (§13.72).
|
|
@@ -982,6 +1010,17 @@ window.__ModuleLoader__.load({
|
|
|
982
1010
|
return max;
|
|
983
1011
|
}
|
|
984
1012
|
/** Fresh mutable per-step accumulator used while folding assistant nodes. */
|
|
1013
|
+
/**
|
|
1014
|
+
* Ordering key for a seq that may be missing or malformed.
|
|
1015
|
+
*
|
|
1016
|
+
* `null < 20` is TRUE (null coerces to 0), so an unparsed seq did not merely sort
|
|
1017
|
+
* badly — it pulled its whole turn to the FRONT of the timeline. Measured: a legal
|
|
1018
|
+
* fractional seq (22 - 0.9, the host's interrupted-reply marker) turned the order
|
|
1019
|
+
* into [prefix(t2), user20, error22, user10, step(t1)] instead of
|
|
1020
|
+
* [user10, step(t1), user20, prefix(t2), error22]. Everything that sorts or
|
|
1021
|
+
* compares seqs goes through this.
|
|
1022
|
+
*/
|
|
1023
|
+
const orderKey = (v) => (typeof v === "number" && Number.isFinite(v) ? v : Number.MAX_SAFE_INTEGER);
|
|
985
1024
|
function newStepState(seq) {
|
|
986
1025
|
return {
|
|
987
1026
|
seq, time: null, cells: [], live: false, request: null,
|
|
@@ -1004,14 +1043,17 @@ window.__ModuleLoader__.load({
|
|
|
1004
1043
|
* though the cap was 2,000. The cap is per tool cell, not per root.
|
|
1005
1044
|
*/
|
|
1006
1045
|
function mapSubCalls(list, tr) {
|
|
1007
|
-
if (!Array.isArray(list)) return [];
|
|
1046
|
+
if (!Array.isArray(list)) return { list: [], total: 0, truncated: false };
|
|
1008
1047
|
const budget = { used: 0 };
|
|
1009
1048
|
const out = [];
|
|
1010
1049
|
for (const sub of list) {
|
|
1011
1050
|
if (budget.used >= SUB_CALL_MAX_TOTAL) break;
|
|
1012
1051
|
out.push(subDetailOf(sub, 0, budget, tr));
|
|
1013
1052
|
}
|
|
1014
|
-
|
|
1053
|
+
// The budget silently dropped the tail: a parent with 20,000 children rendered
|
|
1054
|
+
// 1,999 and NOTHING anywhere said so — not the panel, not the export. Reporting
|
|
1055
|
+
// it is the difference between "this is all there was" and "this is all that fit".
|
|
1056
|
+
return { list: out, total: list.length, truncated: budget.used >= SUB_CALL_MAX_TOTAL };
|
|
1015
1057
|
}
|
|
1016
1058
|
/** Map one sub-call entry (settled ToolResultNode or running shape) to full detail. */
|
|
1017
1059
|
function subDetailOf(sub, depth, budget, tr) {
|
|
@@ -1429,7 +1471,16 @@ window.__ModuleLoader__.load({
|
|
|
1429
1471
|
// step. Prefer a step (the thing anchors are normally copied from); otherwise
|
|
1430
1472
|
// take the first match as before.
|
|
1431
1473
|
const hits = stations.filter((st) => st.anchorSeq === parsed.seq);
|
|
1432
|
-
if (hits.length === 0)
|
|
1474
|
+
if (hits.length === 0) {
|
|
1475
|
+
// An anchor copied from a tool RESULT (`e19`) outlives the result becoming a
|
|
1476
|
+
// station: load one more page and seq 19 is now a cell inside the step at 15.
|
|
1477
|
+
// Reporting "not loaded" for an output that is visibly on screen is wrong, so
|
|
1478
|
+
// fall back to the step that absorbed that result.
|
|
1479
|
+
const absorbed = stations.find((st) => st.kind === "step"
|
|
1480
|
+
&& (st.cells ?? []).some((c) => c.kind === "tool" && c.resultSeq === parsed.seq));
|
|
1481
|
+
if (absorbed !== void 0) return { ok: true, station: absorbed, absorbedFrom: parsed.seq };
|
|
1482
|
+
return { ok: false, reason: "not-loaded", seq: parsed.seq };
|
|
1483
|
+
}
|
|
1433
1484
|
const preferred = hits.find((st) => st.kind === "step") ?? hits[0];
|
|
1434
1485
|
return { ok: true, station: preferred };
|
|
1435
1486
|
}
|
|
@@ -1708,16 +1759,43 @@ window.__ModuleLoader__.load({
|
|
|
1708
1759
|
* but total for every input.
|
|
1709
1760
|
*/
|
|
1710
1761
|
function stepOf(v) {
|
|
1711
|
-
|
|
1762
|
+
// `Number(obj)` throws when the object has no primitive conversion at all — an
|
|
1763
|
+
// ordinary hostile field (`{toString: null}`) took the WHOLE view down, because
|
|
1764
|
+
// this runs while seating every assistant node and nothing caught it. One bad
|
|
1765
|
+
// number must degrade one station, never the panel (§13.84).
|
|
1766
|
+
let n = NaN;
|
|
1767
|
+
try { n = typeof v === "symbol" ? NaN : Number(v); } catch { n = NaN; }
|
|
1712
1768
|
return Math.max(1, Number.isFinite(n) ? Math.trunc(n) : 1);
|
|
1713
1769
|
}
|
|
1714
1770
|
function seqOf(v) {
|
|
1715
1771
|
if (Number.isSafeInteger(v)) return v;
|
|
1716
1772
|
// BigInt is comparable and printable, so keep it when it still fits a double.
|
|
1717
1773
|
if (typeof v === "bigint") { const n = Number(v); return Number.isSafeInteger(n) ? n : null; }
|
|
1774
|
+
// A FRACTIONAL seq is legal: the host marks an interrupted reply at `22 - 0.9`
|
|
1775
|
+
// so it sorts just before the turn error at 22. Dropping it to null destroyed the
|
|
1776
|
+
// only ordering key the node had — and because `null < 20` is true, the whole turn
|
|
1777
|
+
// jumped to the front of the timeline (measured order: prefix(t2), user20,
|
|
1778
|
+
// error22, user10, step(t1)). Anchors are unaffected: every anchor site checks
|
|
1779
|
+
// `Number.isSafeInteger` itself, so a fractional seq still gets no `e` anchor.
|
|
1780
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
1718
1781
|
return null;
|
|
1719
1782
|
}
|
|
1720
1783
|
function deriveTraceTree(snap, t) {
|
|
1784
|
+
// The official contract is explicit that `prompt.system` is empty when the
|
|
1785
|
+
// `system/message` node "lies outside the loaded history window" — the text itself is
|
|
1786
|
+
// still available on the snapshot as `systemPrompts`. Without this, a window that starts
|
|
1787
|
+
// mid-conversation claimed the request carried NO system prompt (0 chars, "…" on screen),
|
|
1788
|
+
// which is a silent lie about what the model actually saw.
|
|
1789
|
+
const systemPrompts = Array.isArray(snap?.systemPrompts)
|
|
1790
|
+
? snap.systemPrompts.filter((s) => s != null && typeof s === "object" && typeof s.text === "string" && s.text !== "")
|
|
1791
|
+
.slice().sort((a, b) => (Number(a.seq) || 0) - (Number(b.seq) || 0))
|
|
1792
|
+
: [];
|
|
1793
|
+
const systemPromptBefore = (seq) => {
|
|
1794
|
+
if (!Number.isFinite(seq)) return null;
|
|
1795
|
+
let pick = null;
|
|
1796
|
+
for (const s of systemPrompts) { if (Number(s.seq) <= seq) pick = s; else break; }
|
|
1797
|
+
return pick;
|
|
1798
|
+
};
|
|
1721
1799
|
const rawNodes = safeList(snap?.eventNodes);
|
|
1722
1800
|
// Only pay for the copy when a node actually needs repairing: a well-formed
|
|
1723
1801
|
// snapshot (the normal case) proceeds with the objects the host handed us.
|
|
@@ -1808,16 +1886,54 @@ window.__ModuleLoader__.load({
|
|
|
1808
1886
|
// React warned about duplicate keys (measured: `["tdup","tdup"]`). Suffix the
|
|
1809
1887
|
// ordinal unconditionally; it is what keeps same-id siblings apart.
|
|
1810
1888
|
const cellId = (prefix, callId, ordinal) => `${prefix}${typeof callId === "string" ? callId : `?${String(ordinal)}`}#${String(ordinal)}`;
|
|
1811
|
-
/**
|
|
1812
|
-
|
|
1889
|
+
/**
|
|
1890
|
+
* Next unclaimed result for this call, or undefined when none is left.
|
|
1891
|
+
*
|
|
1892
|
+
* `turn`/`afterSeq` are not decoration: when the log omits `callId`, EVERY id-less
|
|
1893
|
+
* result lands in the same `resultsById` bucket under `undefined`, and "first
|
|
1894
|
+
* unconsumed" handed turn 2's output to turn 1's call — silently, with no
|
|
1895
|
+
* diagnostic (measured: CALL_A displayed ONLY-RESULT-B while CALL_B, the real
|
|
1896
|
+
* caller, showed nothing). Prefer a result from the SAME turn that comes AFTER
|
|
1897
|
+
* the call; fall back to the same turn, then to the legacy first-unconsumed so a
|
|
1898
|
+
* normal log behaves exactly as before.
|
|
1899
|
+
*/
|
|
1900
|
+
// Which result seq was already consumed for each callId. Compaction replays tool
|
|
1901
|
+
// results (`tool/result` repeated under the SAME callId at a much later seq — measured
|
|
1902
|
+
// 13 such groups in one 17k-event session). Without this the duplicate looked like
|
|
1903
|
+
// "the call is outside the window", which is false: the call is right there and was
|
|
1904
|
+
// already answered.
|
|
1905
|
+
const consumedByCallId = new Map();
|
|
1906
|
+
const reclaimResult = (key, seq) => {
|
|
1907
|
+
if (key === void 0 || key === null) return;
|
|
1908
|
+
const list = consumedByCallId.get(key);
|
|
1909
|
+
if (list === void 0) consumedByCallId.set(key, [seq]);
|
|
1910
|
+
else list.push(seq);
|
|
1911
|
+
};
|
|
1912
|
+
const takeResult = (callId, turn, afterSeq) => {
|
|
1813
1913
|
const list = resultsById.get(callId);
|
|
1814
1914
|
if (list === void 0) return void 0;
|
|
1915
|
+
// Without an id, the bucket holds every id-less result in the window. A result
|
|
1916
|
+
// from ANOTHER turn is not this call's output — taking it is the silent
|
|
1917
|
+
// misattribution this rewrite exists to stop, so an id-less call refuses it
|
|
1918
|
+
// and shows "no result" instead of someone else's text.
|
|
1919
|
+
const idless = callId === void 0 || callId === null;
|
|
1920
|
+
let sameTurn = null;
|
|
1921
|
+
let legacy = null;
|
|
1815
1922
|
for (const r of list) {
|
|
1816
1923
|
if (consumedResults.has(r)) continue;
|
|
1817
|
-
|
|
1818
|
-
|
|
1924
|
+
const sameTurnMatch = r.turn === turn && turn !== void 0;
|
|
1925
|
+
if (idless && !sameTurnMatch) continue;
|
|
1926
|
+
if (sameTurnMatch && Number.isFinite(afterSeq) && Number.isFinite(r.seq) && r.seq > afterSeq) {
|
|
1927
|
+
consumedResults.add(r);
|
|
1928
|
+
reclaimResult(callId, r.seq);
|
|
1929
|
+
return r;
|
|
1930
|
+
}
|
|
1931
|
+
if (sameTurnMatch && sameTurn === null) sameTurn = r;
|
|
1932
|
+
if (legacy === null) legacy = r;
|
|
1819
1933
|
}
|
|
1820
|
-
|
|
1934
|
+
const pick = sameTurn ?? legacy;
|
|
1935
|
+
if (pick !== null) { consumedResults.add(pick); reclaimResult(callId, pick.seq); }
|
|
1936
|
+
return pick ?? void 0;
|
|
1821
1937
|
};
|
|
1822
1938
|
|
|
1823
1939
|
// Requests keyed by `${turn}:${step}`, with prompt inheritance across
|
|
@@ -1905,12 +2021,13 @@ window.__ModuleLoader__.load({
|
|
|
1905
2021
|
const ensureTurn = (turn, seq) => {
|
|
1906
2022
|
let e = turnMap.get(turn);
|
|
1907
2023
|
if (e === void 0) {
|
|
1908
|
-
e = { turn, user: [], stations: [], seq: seq
|
|
2024
|
+
e = { turn, user: [], stations: [], seq: orderKey(seq) };
|
|
1909
2025
|
turnMap.set(turn, e);
|
|
1910
2026
|
turns.push(e);
|
|
1911
2027
|
lastTurnEntry = e;
|
|
1912
2028
|
}
|
|
1913
|
-
|
|
2029
|
+
const ord = orderKey(seq);
|
|
2030
|
+
if (e.seq > ord) e.seq = ord;
|
|
1914
2031
|
return e;
|
|
1915
2032
|
};
|
|
1916
2033
|
const flushUser = (turn, seq) => {
|
|
@@ -2014,7 +2131,7 @@ window.__ModuleLoader__.load({
|
|
|
2014
2131
|
} else if (b.kind === "tool-call") {
|
|
2015
2132
|
// every durable block is a real call, even with a repeated id
|
|
2016
2133
|
claimCall(turn, b.callId);
|
|
2017
|
-
const res = takeResult(b.callId);
|
|
2134
|
+
const res = takeResult(b.callId, turn, n.seq);
|
|
2018
2135
|
const isRunning = res === undefined && runningById.has(b.callId);
|
|
2019
2136
|
if (isRunning) st.live = true;
|
|
2020
2137
|
const schema = schemasById.get(b.callId);
|
|
@@ -2030,6 +2147,7 @@ window.__ModuleLoader__.load({
|
|
|
2030
2147
|
st.toolMs += dur ?? 0;
|
|
2031
2148
|
st.toolCount += 1;
|
|
2032
2149
|
if (res?.isError === true) st.hasError = true;
|
|
2150
|
+
const subPack1 = mapSubCalls(res?.subCalls, t);
|
|
2033
2151
|
st.cells.push({
|
|
2034
2152
|
id: cellId("t", b.callId, st.cells.length),
|
|
2035
2153
|
kind: "tool",
|
|
@@ -2037,11 +2155,18 @@ window.__ModuleLoader__.load({
|
|
|
2037
2155
|
name: typeof b.name === "string" && b.name !== "" ? b.name : t("node.tool"),
|
|
2038
2156
|
args: argsText(b.argsRaw),
|
|
2039
2157
|
resultText: res !== undefined ? blocksText(res.content, t) : "",
|
|
2158
|
+
// The result's own seq. A copied `tvp1:e19` anchor used to die the moment a page
|
|
2159
|
+
// load brought in the call header: seq 19 stopped being a station of its own and became
|
|
2160
|
+
// a cell of the step at 15, so the anchor said "not loaded" while the output was on
|
|
2161
|
+
// screen. `resultSeq` lets the resolver walk that back to the owning step.
|
|
2162
|
+
resultSeq: res !== undefined && Number.isSafeInteger(res.seq) ? res.seq : null,
|
|
2040
2163
|
isError: res?.isError === true,
|
|
2041
2164
|
errorName: res?.error?.name,
|
|
2042
2165
|
durationMs: dur,
|
|
2043
2166
|
running: isRunning,
|
|
2044
|
-
subCalls:
|
|
2167
|
+
subCalls: subPack1.list,
|
|
2168
|
+
subCallsTotal: subPack1.total,
|
|
2169
|
+
subCallsTruncated: subPack1.truncated,
|
|
2045
2170
|
schema: schema != null ? { name: schema.name, description: schema.description, parameters: schema.parameters } : null
|
|
2046
2171
|
});
|
|
2047
2172
|
}
|
|
@@ -2116,13 +2241,16 @@ window.__ModuleLoader__.load({
|
|
|
2116
2241
|
st.live = true;
|
|
2117
2242
|
st.toolCount += 1;
|
|
2118
2243
|
const schema = schemasById.get(c.callId);
|
|
2244
|
+
const subPack2 = mapSubCalls(c.subCalls, t);
|
|
2119
2245
|
st.cells.push({
|
|
2120
2246
|
id: cellId("t", c.callId, st.cells.length), kind: "tool", callId: c.callId,
|
|
2121
2247
|
name: typeof c.name === "string" && c.name !== "" ? c.name : t("node.tool"),
|
|
2122
2248
|
args: argsText(c.argsRaw),
|
|
2123
2249
|
resultText: "", isError: false, errorName: void 0, durationMs: null,
|
|
2124
2250
|
running: true,
|
|
2125
|
-
subCalls:
|
|
2251
|
+
subCalls: subPack2.list,
|
|
2252
|
+
subCallsTotal: subPack2.total,
|
|
2253
|
+
subCallsTruncated: subPack2.truncated,
|
|
2126
2254
|
schema: schema != null ? { name: schema.name, description: schema.description, parameters: schema.parameters } : null
|
|
2127
2255
|
});
|
|
2128
2256
|
}
|
|
@@ -2202,19 +2330,27 @@ window.__ModuleLoader__.load({
|
|
|
2202
2330
|
} else if (b.kind === "tool-call") {
|
|
2203
2331
|
if (claimedCall(turn, b.callId)) continue;
|
|
2204
2332
|
claimCall(turn, b.callId);
|
|
2205
|
-
const res = takeResult(b.callId);
|
|
2333
|
+
const res = takeResult(b.callId, turn, seq);
|
|
2206
2334
|
st.toolCount += 1;
|
|
2207
2335
|
if (res?.isError === true) st.hasError = true;
|
|
2208
2336
|
const schema = schemasById.get(b.callId);
|
|
2337
|
+
const subPack3 = mapSubCalls(res?.subCalls, t);
|
|
2209
2338
|
st.cells.push({
|
|
2210
2339
|
id: cellId("t", b.callId, st.cells.length), kind: "tool", callId: b.callId,
|
|
2211
2340
|
name: typeof b.name === "string" && b.name !== "" ? b.name : t("node.tool"),
|
|
2212
2341
|
args: argsText(b.argsRaw),
|
|
2213
2342
|
resultText: res !== undefined ? blocksText(res.content, t) : "",
|
|
2343
|
+
// The result's own seq. A copied `tvp1:e19` anchor used to die the moment a page
|
|
2344
|
+
// load brought in the call header: seq 19 stopped being a station of its own and became
|
|
2345
|
+
// a cell of the step at 15, so the anchor said "not loaded" while the output was on
|
|
2346
|
+
// screen. `resultSeq` lets the resolver walk that back to the owning step.
|
|
2347
|
+
resultSeq: res !== undefined && Number.isSafeInteger(res.seq) ? res.seq : null,
|
|
2214
2348
|
isError: res?.isError === true,
|
|
2215
2349
|
errorName: res?.error?.name,
|
|
2216
2350
|
durationMs: null, running: res === undefined,
|
|
2217
|
-
subCalls:
|
|
2351
|
+
subCalls: subPack3.list,
|
|
2352
|
+
subCallsTotal: subPack3.total,
|
|
2353
|
+
subCallsTruncated: subPack3.truncated,
|
|
2218
2354
|
schema: schema != null ? { name: schema.name, description: schema.description, parameters: schema.parameters } : null
|
|
2219
2355
|
});
|
|
2220
2356
|
}
|
|
@@ -2228,7 +2364,7 @@ window.__ModuleLoader__.load({
|
|
|
2228
2364
|
// Binary search: `turnsBySeq` is already sorted. The previous linear scan ran
|
|
2229
2365
|
// once per compaction/special event, so a log with many of both cost
|
|
2230
2366
|
// O(events x turns) — measured 105 ms at 1000 turns, and it grows from there.
|
|
2231
|
-
const turnForSeq = (s) => {
|
|
2367
|
+
const turnForSeq = (s, turnHint) => {
|
|
2232
2368
|
let lo = 0;
|
|
2233
2369
|
let hi = turnsBySeq.length - 1;
|
|
2234
2370
|
let best = null;
|
|
@@ -2237,7 +2373,21 @@ window.__ModuleLoader__.load({
|
|
|
2237
2373
|
if (turnsBySeq[mid].seq <= s) { best = turnsBySeq[mid]; lo = mid + 1; }
|
|
2238
2374
|
else hi = mid - 1;
|
|
2239
2375
|
}
|
|
2240
|
-
|
|
2376
|
+
if (best !== null) return best;
|
|
2377
|
+
// The event sits BEFORE every turn boundary in this window. That is the normal
|
|
2378
|
+
// shape after paging: a page can start on a tool RESULT whose call sits above
|
|
2379
|
+
// it, and the result's own turn then has no boundary at or before its seq.
|
|
2380
|
+
//
|
|
2381
|
+
// The fallback used to be `lastTurnEntry` — the turn created LAST — so the
|
|
2382
|
+
// orphan was filed under the newest turn and `ensureTurn` lowered that turn's
|
|
2383
|
+
// seq to the orphan's. Sorting by seq then put the NEWEST turn first and split
|
|
2384
|
+
// the timeline: turn 68 → 65 → 66 → 67, with ~1h52m of apparent rewind in the
|
|
2385
|
+
// gap bars, and the export filed the result under the wrong turn (§13.83).
|
|
2386
|
+
//
|
|
2387
|
+
// Prefer the event's OWN turn when the log states one (the orphan's node
|
|
2388
|
+
// carries `turn`), else the earliest turn — never the last.
|
|
2389
|
+
const hinted = turnMap.get(typeof turnHint === "number" ? turnHint : NaN);
|
|
2390
|
+
return hinted ?? turnsBySeq[0] ?? ensureTurn(0, s);
|
|
2241
2391
|
};
|
|
2242
2392
|
const consumedCompactionReqs = new Set();
|
|
2243
2393
|
// Index the exact-replacementSeq match instead of scanning every request per
|
|
@@ -2254,7 +2404,7 @@ window.__ModuleLoader__.load({
|
|
|
2254
2404
|
}
|
|
2255
2405
|
for (const n of nodes) {
|
|
2256
2406
|
if (n.kind === "compaction") {
|
|
2257
|
-
const e = turnForSeq(n.seq);
|
|
2407
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2258
2408
|
// Pair with the compaction provider request: exact replacementSeq
|
|
2259
2409
|
// match first, else the nearest unconsumed compaction request that
|
|
2260
2410
|
// completed within a minute before this marker landed.
|
|
@@ -2269,6 +2419,13 @@ window.__ModuleLoader__.load({
|
|
|
2269
2419
|
let best = null;
|
|
2270
2420
|
for (const r of compactionReqs) {
|
|
2271
2421
|
if (consumedCompactionReqs.has(r)) continue;
|
|
2422
|
+
// A request that NAMES a different replacementSeq belongs to that
|
|
2423
|
+
// marker. Time-proximity used to override the declaration, so a
|
|
2424
|
+
// marker at seq 20 displayed the output of the request for seq 10 —
|
|
2425
|
+
// a marker outside the window — and `unplacedRequests` stayed 0, so
|
|
2426
|
+
// nothing said the text was someone else's. Leaving it unconsumed
|
|
2427
|
+
// makes the view report it instead of borrowing it.
|
|
2428
|
+
if (Number.isSafeInteger(r.replacementSeq) && r.replacementSeq !== n.seq) continue;
|
|
2272
2429
|
const doneAt = Number.isFinite(r.completedAt) ? r.completedAt : r.startedAt;
|
|
2273
2430
|
if (!Number.isFinite(doneAt)) continue;
|
|
2274
2431
|
const gap = n.time - doneAt;
|
|
@@ -2319,7 +2476,7 @@ window.__ModuleLoader__.load({
|
|
|
2319
2476
|
const e = ensureTurn(typeof n.turn === "number" ? n.turn : 0, n.seq);
|
|
2320
2477
|
e.stations.push({ id: `x${n.seq}`, kind: "maxTokens", time: n.time, seq: n.seq, label: t("node.maxTokens") });
|
|
2321
2478
|
} else if (n.kind === "command") {
|
|
2322
|
-
const e = turnForSeq(n.seq);
|
|
2479
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2323
2480
|
e.stations.push({
|
|
2324
2481
|
id: `c${n.seq}`, kind: "command", time: n.time, seq: n.seq,
|
|
2325
2482
|
name: asText(n.name) !== "" ? asText(n.name) : `/${asText(n.commandId) || "?"}`, args: asText(n.args),
|
|
@@ -2330,7 +2487,7 @@ window.__ModuleLoader__.load({
|
|
|
2330
2487
|
// The contract's own fallback surface. Rendering nothing would hide a
|
|
2331
2488
|
// real event that exists in the session log, and the review tool's whole
|
|
2332
2489
|
// promise is that what the log recorded is what the reader sees.
|
|
2333
|
-
const e = turnForSeq(n.seq);
|
|
2490
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2334
2491
|
e.stations.push({
|
|
2335
2492
|
id: `k${n.seq}`, kind: "unknown", time: n.time, seq: n.seq,
|
|
2336
2493
|
eventType: typeof n.type === "string" ? n.type : "",
|
|
@@ -2372,9 +2529,10 @@ window.__ModuleLoader__.load({
|
|
|
2372
2529
|
return `ot${base}${seen === 0 ? "" : `_${String(seen)}`}`;
|
|
2373
2530
|
};
|
|
2374
2531
|
for (const n of orphans) {
|
|
2375
|
-
const e = turnForSeq(n.seq);
|
|
2532
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2376
2533
|
const text = blocksText(n.content, t);
|
|
2377
|
-
const
|
|
2534
|
+
const subCallPack = mapSubCalls(n.subCalls, t);
|
|
2535
|
+
const subCalls = subCallPack.list;
|
|
2378
2536
|
// Anchor issuance is centralized in the "special stations" branch below
|
|
2379
2537
|
// (it re-checks `seq` for integer-ness and stamps anchorKey/synthetic).
|
|
2380
2538
|
e.stations.push({
|
|
@@ -2401,6 +2559,14 @@ window.__ModuleLoader__.load({
|
|
|
2401
2559
|
displayText: text !== "" ? text : (n.error?.code ?? n.error?.name ?? ""),
|
|
2402
2560
|
isError: n.isError === true,
|
|
2403
2561
|
subCalls,
|
|
2562
|
+
subCallsTotal: subCallPack.total,
|
|
2563
|
+
subCallsTruncated: subCallPack.truncated,
|
|
2564
|
+
// Set when this same callId ALREADY produced a result earlier in the window —
|
|
2565
|
+
// i.e. this is a compaction replay, not a missing call.
|
|
2566
|
+
replayOf: (() => {
|
|
2567
|
+
const used = consumedByCallId.get(n.callId);
|
|
2568
|
+
return used !== void 0 && used.length > 0 ? used[0] : null;
|
|
2569
|
+
})(),
|
|
2404
2570
|
hasError: n.isError === true
|
|
2405
2571
|
});
|
|
2406
2572
|
}
|
|
@@ -2410,9 +2576,9 @@ window.__ModuleLoader__.load({
|
|
|
2410
2576
|
// Sort turns by their earliest known seq first (turn 0 "system events" may
|
|
2411
2577
|
// be created late by a stray compaction/command and would otherwise land last).
|
|
2412
2578
|
for (const e of turns) {
|
|
2413
|
-
let mseq = e.seq;
|
|
2414
|
-
for (const st of e.stations)
|
|
2415
|
-
for (const st of e.steps?.values() ?? [])
|
|
2579
|
+
let mseq = orderKey(e.seq);
|
|
2580
|
+
for (const st of e.stations) mseq = Math.min(mseq, orderKey(st.seq));
|
|
2581
|
+
for (const st of e.steps?.values() ?? []) mseq = Math.min(mseq, orderKey(st.seq));
|
|
2416
2582
|
e.minSeq = mseq;
|
|
2417
2583
|
}
|
|
2418
2584
|
turns.sort((a, b) => a.minSeq - b.minSeq);
|
|
@@ -2426,7 +2592,7 @@ window.__ModuleLoader__.load({
|
|
|
2426
2592
|
const turnNodes = turns.map((e) => {
|
|
2427
2593
|
const pieceList = [];
|
|
2428
2594
|
for (const s of e.stations) {
|
|
2429
|
-
pieceList.push({ at: s.seq, kind: s.kind, data: s });
|
|
2595
|
+
pieceList.push({ at: orderKey(s.seq), kind: s.kind, data: s });
|
|
2430
2596
|
if (s.kind === "orphan-tool") {
|
|
2431
2597
|
stats.tools += 1;
|
|
2432
2598
|
if (s.isError === true) stats.errors += 1;
|
|
@@ -2435,7 +2601,7 @@ window.__ModuleLoader__.load({
|
|
|
2435
2601
|
const stepNums = e.steps === void 0 ? [] : [...e.steps.keys()].sort((a, b) => a - b);
|
|
2436
2602
|
for (const s of stepNums) {
|
|
2437
2603
|
const st = e.steps.get(s);
|
|
2438
|
-
pieceList.push({ at: st.seq, kind: "step", data: st, stepNum: s });
|
|
2604
|
+
pieceList.push({ at: orderKey(st.seq), kind: "step", data: st, stepNum: s });
|
|
2439
2605
|
}
|
|
2440
2606
|
pieceList.sort((a, b) => a.at - b.at);
|
|
2441
2607
|
|
|
@@ -2508,6 +2674,15 @@ window.__ModuleLoader__.load({
|
|
|
2508
2674
|
tools: Array.isArray(found.prompt.tools) ? found.prompt.tools : [],
|
|
2509
2675
|
systemChars: typeof found.prompt.system === "string" ? found.prompt.system.length : 0
|
|
2510
2676
|
} : null,
|
|
2677
|
+
// Present only when the request header's own prompt text is empty AND an older
|
|
2678
|
+
// system event exists: the reader then sees the real text, labelled as coming from
|
|
2679
|
+
// outside the window, instead of "0 chars".
|
|
2680
|
+
systemFrom: (() => {
|
|
2681
|
+
const own = found.prompt != null && typeof found.prompt.system === "string" ? found.prompt.system : "";
|
|
2682
|
+
if (own !== "") return null;
|
|
2683
|
+
const older = systemPromptBefore(Number(r.startSeq));
|
|
2684
|
+
return older !== null ? { seq: Number(older.seq), text: older.text, update: older.update === true } : null;
|
|
2685
|
+
})(),
|
|
2511
2686
|
promptChangeKind: r.promptChange?.kind ?? null,
|
|
2512
2687
|
promptDiff: promptDiffOf(r.promptChange, found.prompt),
|
|
2513
2688
|
startSeq: r.startSeq ?? null
|
|
@@ -2771,7 +2946,8 @@ window.__ModuleLoader__.load({
|
|
|
2771
2946
|
: station.kind === "user" ? t("node.user")
|
|
2772
2947
|
: station.kind === "error" ? t("node.error")
|
|
2773
2948
|
: station.kind === "compaction" ? t("node.compaction")
|
|
2774
|
-
:
|
|
2949
|
+
// Same distinction as the card: a compaction replay is not a missing call.
|
|
2950
|
+
: station.kind === "orphan-tool" ? t(station.replayOf !== null && station.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")
|
|
2775
2951
|
: station.kind === "unknown" ? t("node.unknown")
|
|
2776
2952
|
: String(station.kind);
|
|
2777
2953
|
const parts = [`${position} / ${total}`, kind];
|
|
@@ -2933,6 +3109,16 @@ window.__ModuleLoader__.load({
|
|
|
2933
3109
|
// again here duplicated every sub-call result in the export.
|
|
2934
3110
|
pushSubLines(L, sub, 1, t);
|
|
2935
3111
|
}
|
|
3112
|
+
// Say it when the list was cut. A file that silently stops at 1,999 of
|
|
3113
|
+
// 20,000 reads as "this was everything", which is the one outcome this
|
|
3114
|
+
// view promises never to produce.
|
|
3115
|
+
if (cell.subCallsTruncated === true && Number.isSafeInteger(cell.subCallsTotal)) {
|
|
3116
|
+
const shown = (cell.subCalls ?? []).length;
|
|
3117
|
+
L.push("");
|
|
3118
|
+
L.push(`> ${typeof t === "function"
|
|
3119
|
+
? t("detail.subCallsCut").replace("{shown}", fmtInt(shown)).replace("{total}", fmtInt(cell.subCallsTotal))
|
|
3120
|
+
: `showing the first ${String(shown)} of ${String(cell.subCallsTotal)}`}`);
|
|
3121
|
+
}
|
|
2936
3122
|
L.push("");
|
|
2937
3123
|
}
|
|
2938
3124
|
}
|
|
@@ -3012,7 +3198,27 @@ window.__ModuleLoader__.load({
|
|
|
3012
3198
|
// "[object Object]".
|
|
3013
3199
|
return asText(content)
|
|
3014
3200
|
.replace(/`{3,}/g, (run) => "\\`".repeat(run.length))
|
|
3015
|
-
|
|
3201
|
+
// GFM fences with TILDES too, and only backticks were escaped: prose ending in an
|
|
3202
|
+
// unclosed "~~~" turned every following station into code (verified with Pandoc
|
|
3203
|
+
// by the boundary review). Same treatment: leading tildes of a run this long
|
|
3204
|
+
// get escaped, so the run is no longer a fence opener.
|
|
3205
|
+
.replace(/(^|\n)(~{3,})/g, (m, lead, run) => lead + "\\~".repeat(run.length))
|
|
3206
|
+
.replace(/<(\/?)(details)\b/gi, "<$1$2")
|
|
3207
|
+
// A content line that starts with `#` becomes a real heading in the export and
|
|
3208
|
+
// silently re-sections the document (measured: a compaction summary containing
|
|
3209
|
+
// "### 伪造标题" produced a section the panel never showed). Escaping turns it
|
|
3210
|
+
// back into text; a Markdown renderer still displays the bare `#`.
|
|
3211
|
+
.replace(/^(\s*)(#{1,6})\s/gm, "$1\\$2 ");
|
|
3212
|
+
}
|
|
3213
|
+
/**
|
|
3214
|
+
* Free text that sits INSIDE a generated line (a heading, a label).
|
|
3215
|
+
*
|
|
3216
|
+
* `proseSafe` keeps newlines, which is right for a paragraph and wrong for a heading:
|
|
3217
|
+
* a tool name or a slash-command's arguments containing "\n### …" forges a section in
|
|
3218
|
+
* the exported Markdown. Flatten first, then apply the same escaping.
|
|
3219
|
+
*/
|
|
3220
|
+
function inlineSafe(content) {
|
|
3221
|
+
return proseSafe(asText(content).replace(/\s+/g, " ").trim());
|
|
3016
3222
|
}
|
|
3017
3223
|
function fencedBlock(content, lang) {
|
|
3018
3224
|
const text = String(content ?? "");
|
|
@@ -3141,6 +3347,27 @@ window.__ModuleLoader__.load({
|
|
|
3141
3347
|
return out;
|
|
3142
3348
|
}
|
|
3143
3349
|
/** Block-level split. Returns descriptors; see mdInline for the inline level. */
|
|
3350
|
+
/**
|
|
3351
|
+
* Is this line a Markdown table separator (`|---|:--:|`)?
|
|
3352
|
+
*
|
|
3353
|
+
* Equivalent to `/^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/`, but linear. The regex was
|
|
3354
|
+
* quadratic on failure: two overlapping classes around the mandatory `-` let it
|
|
3355
|
+
* re-split a long dash run for every possible position.
|
|
3356
|
+
*/
|
|
3357
|
+
const WHITESPACE_CHAR = /\s/;
|
|
3358
|
+
function isTableSeparator(line) {
|
|
3359
|
+
if (typeof line !== "string") return false;
|
|
3360
|
+
let dashes = 0;
|
|
3361
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
3362
|
+
const ch = line[i];
|
|
3363
|
+
if (ch === "-") { dashes += 1; continue; }
|
|
3364
|
+
// `\s` in the original class, plus the pipe. Testing one character at a time
|
|
3365
|
+
// keeps the whole thing linear and preserves CRLF and Unicode-space behaviour.
|
|
3366
|
+
if (ch === "|" || ch === ":" || WHITESPACE_CHAR.test(ch)) continue;
|
|
3367
|
+
return false;
|
|
3368
|
+
}
|
|
3369
|
+
return dashes > 0;
|
|
3370
|
+
}
|
|
3144
3371
|
function mdBlocks(src) {
|
|
3145
3372
|
const lines = String(src ?? "").replace(/\r\n?/g, "\n").split("\n");
|
|
3146
3373
|
const blocks = [];
|
|
@@ -3174,7 +3401,12 @@ window.__ModuleLoader__.load({
|
|
|
3174
3401
|
continue;
|
|
3175
3402
|
}
|
|
3176
3403
|
// Table: a header row followed by a |---|---| separator.
|
|
3177
|
-
|
|
3404
|
+
// The separator test used to be `/^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/`. Its two
|
|
3405
|
+
// character classes overlap on `-`, so a long dash run that FAILS backtracks over
|
|
3406
|
+
// every split: measured 2,000 hyphens 96 ms, 4,000 575 ms, 8,000 2.1 s,
|
|
3407
|
+
// 16,000 7.4 s — a synchronous stall inside the detail panel, on content a model
|
|
3408
|
+
// can emit. Same predicate, one linear pass (§13.84).
|
|
3409
|
+
if (line.includes("|") && i + 1 < lines.length && isTableSeparator(lines[i + 1])) {
|
|
3178
3410
|
// `\|` is the escape for a literal pipe inside a cell — the only way to
|
|
3179
3411
|
// put one in a table at all. Splitting on every `|` cut such a cell in
|
|
3180
3412
|
// two, so `| a \| b | c |` became THREE columns ("a \", "b", "c") and
|
|
@@ -3236,6 +3468,30 @@ window.__ModuleLoader__.load({
|
|
|
3236
3468
|
}
|
|
3237
3469
|
return blocks;
|
|
3238
3470
|
}
|
|
3471
|
+
/**
|
|
3472
|
+
* Hard caps for text that goes into a STATION CARD.
|
|
3473
|
+
*
|
|
3474
|
+
* A card shows at most four clamped lines, but `dstv_clamp4` only hides the overflow:
|
|
3475
|
+
* the text node and the `title` attribute both kept the whole string. Measured with a
|
|
3476
|
+
* 1 MB assistant message: 1,575 ms to paint one card and 1,000,007 characters in the
|
|
3477
|
+
* DOM (the tooltip alone carried the megabyte). The full text stays available through
|
|
3478
|
+
* copy, the detail panel and the export — the card is a thumbnail, not a viewer.
|
|
3479
|
+
*/
|
|
3480
|
+
// 20 000, not 2 000: group 20 of the browser probe renders a 20k body in full and
|
|
3481
|
+
// requires a one-character edit deep inside it to repaint the card. The cap exists to
|
|
3482
|
+
// stop megabyte messages, not to change what a long-but-normal message looks like.
|
|
3483
|
+
const CARD_TEXT_MAX = 20000;
|
|
3484
|
+
const CARD_TITLE_MAX = 300;
|
|
3485
|
+
/** Clamp a string for rendering inside a card, marking that it was cut. */
|
|
3486
|
+
function cardText(v) {
|
|
3487
|
+
const s = typeof v === "string" ? v : v == null ? "" : String(v);
|
|
3488
|
+
return s.length > CARD_TEXT_MAX ? `${s.slice(0, CARD_TEXT_MAX)}…` : s;
|
|
3489
|
+
}
|
|
3490
|
+
/** Clamp a string for a `title` tooltip: a tooltip longer than this is unreadable. */
|
|
3491
|
+
function cardTitle(v) {
|
|
3492
|
+
const s = typeof v === "string" ? v : v == null ? "" : String(v);
|
|
3493
|
+
return s.length > CARD_TITLE_MAX ? `${s.slice(0, CARD_TITLE_MAX)}…` : s;
|
|
3494
|
+
}
|
|
3239
3495
|
/** Markdown with markers stripped, for one-line previews. */
|
|
3240
3496
|
function markdownToPlain(src) {
|
|
3241
3497
|
let out = "";
|
|
@@ -3300,21 +3556,29 @@ window.__ModuleLoader__.load({
|
|
|
3300
3556
|
L.push("");
|
|
3301
3557
|
pushSubLines(L, sub, 1, t);
|
|
3302
3558
|
}
|
|
3559
|
+
if (cell.subCallsTruncated === true && Number.isSafeInteger(cell.subCallsTotal)) {
|
|
3560
|
+
L.push("");
|
|
3561
|
+
L.push(`> ${t("detail.subCallsCut").replace("{shown}", fmtInt(cell.subCalls.length)).replace("{total}", fmtInt(cell.subCallsTotal))}`);
|
|
3562
|
+
}
|
|
3303
3563
|
}
|
|
3304
3564
|
}
|
|
3305
3565
|
} else if (st.kind === "orphan-tool") {
|
|
3306
|
-
L.push(`### ⤷ ${t("node.orphanTool")} · ${st.name}`);
|
|
3566
|
+
L.push(`### ⤷ ${t(st.replayOf !== null && st.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${st.name}`);
|
|
3307
3567
|
L.push("");
|
|
3308
|
-
L.push(`_${t("orphan.badge")} · ${anchorOf(st) ?? "—"}_`);
|
|
3568
|
+
L.push(`_${t(st.replayOf !== null && st.replayOf !== void 0 ? "orphan.replayBadge" : "orphan.badge").replace("{seq}", String(st.replayOf ?? ""))} · ${anchorOf(st) ?? "—"}_`);
|
|
3309
3569
|
if (st.args !== "") { L.push(""); L.push(...fencedBlock(prettyArgs(st.args) || st.args, "json")); }
|
|
3310
3570
|
if (st.displayText !== "") { L.push(""); L.push(...fencedBlock(st.displayText.length > 4000 ? `${st.displayText.slice(0, 4000)}\n…(${fmtInt(st.displayText.length)} ${t("detail.chars")})` : st.displayText)); }
|
|
3571
|
+
if (st.subCallsTruncated === true && Number.isSafeInteger(st.subCallsTotal)) {
|
|
3572
|
+
L.push("");
|
|
3573
|
+
L.push(`> ${t("detail.subCallsCut").replace("{shown}", fmtInt((st.subCalls || []).length)).replace("{total}", fmtInt(st.subCallsTotal))}`);
|
|
3574
|
+
}
|
|
3311
3575
|
} else if (st.kind === "compaction") {
|
|
3312
3576
|
L.push(`### ♺ ${st.label}${Number.isSafeInteger(st.count) ? ` _(${numOr(st.count)} ${t("meta.steps")} / ${fmtTokens(st.tokens)} ${t("meta.tokens")})_` : ""}`);
|
|
3313
|
-
if (st.summary !== "") { L.push(""); L.push(st.summary); }
|
|
3314
|
-
if (st.crequest?.outputText) { L.push(""); L.push(`<details><summary>${t("detail.compactionOutput")}</summary>`); L.push(""); L.push(st.crequest.outputText); L.push("</details>"); }
|
|
3577
|
+
if (st.summary !== "") { L.push(""); L.push(proseSafe(st.summary)); }
|
|
3578
|
+
if (st.crequest?.outputText) { L.push(""); L.push(`<details><summary>${t("detail.compactionOutput")}</summary>`); L.push(""); L.push(proseSafe(st.crequest.outputText)); L.push("</details>"); }
|
|
3315
3579
|
} else if (st.kind === "error") {
|
|
3316
3580
|
L.push(`### ✗ ${st.label}${st.code != null ? ` \`${st.code}\`` : ""}`);
|
|
3317
|
-
L.push(""); L.push(st.message
|
|
3581
|
+
L.push(""); L.push(st.message ? proseSafe(st.message) : "…");
|
|
3318
3582
|
} else if (st.kind === "retry") {
|
|
3319
3583
|
// The detail panel shows the retry counter, the provider and the error
|
|
3320
3584
|
// code; the export showed none of them, so the Markdown copy of a failed
|
|
@@ -3327,12 +3591,12 @@ window.__ModuleLoader__.load({
|
|
|
3327
3591
|
if (st.code != null) retryBits.push(`code: ${st.code}`);
|
|
3328
3592
|
if (st.retryState) retryBits.push(String(st.retryState));
|
|
3329
3593
|
L.push(`### ↻ ${st.label}${retryBits.length > 0 ? ` (${retryBits.join(" · ")})` : ""}`);
|
|
3330
|
-
if (st.message) { L.push(""); L.push(st.message); }
|
|
3594
|
+
if (st.message) { L.push(""); L.push(proseSafe(st.message)); }
|
|
3331
3595
|
} else if (st.kind === "maxTokens") {
|
|
3332
3596
|
L.push(`### ⛔ ${st.label}`);
|
|
3333
3597
|
} else if (st.kind === "command") {
|
|
3334
|
-
L.push(`### ⚡ /${st.name}${st.args !== "" ? ` ${st.args}` : ""}`);
|
|
3335
|
-
if (st.outcomeText) { L.push(""); L.push(st.outcomeText); }
|
|
3598
|
+
L.push(`### ⚡ /${inlineSafe(st.name)}${st.args !== "" ? ` ${inlineSafe(st.args)}` : ""}`);
|
|
3599
|
+
if (st.outcomeText) { L.push(""); L.push(proseSafe(st.outcomeText)); }
|
|
3336
3600
|
} else if (st.kind === "unknown") {
|
|
3337
3601
|
L.push(`### ? ${t("node.unknown")}${st.eventType ? ` \`${st.eventType}\`` : ""}`);
|
|
3338
3602
|
if (st.payload) { L.push(""); L.push(...fencedBlock(st.payload, "json")); }
|
|
@@ -3677,6 +3941,10 @@ window.__ModuleLoader__.load({
|
|
|
3677
3941
|
// applied to a completely different transcript. `sessionKey` arrives from the
|
|
3678
3942
|
// slot's `inject`; when the host does not provide one, behaviour is unchanged.
|
|
3679
3943
|
const sessionRef = (0, react.useRef)(sessionKey);
|
|
3944
|
+
// The session key that the CURRENT `revealed`/`query` values belong to. They lag one
|
|
3945
|
+
// render behind a key change (the clear is scheduled, not applied), and writing that
|
|
3946
|
+
// pair under the new key leaked one session's position into another.
|
|
3947
|
+
const stateKeyRef = (0, react.useRef)(sessionKey);
|
|
3680
3948
|
// ── view state that survives a tab switch ─────────────────────────────
|
|
3681
3949
|
// The host UNMOUNTS this panel when the reader looks at the conversation and
|
|
3682
3950
|
// remounts it on return (measured: root count 0 → 1). Without this, every
|
|
@@ -3695,7 +3963,11 @@ window.__ModuleLoader__.load({
|
|
|
3695
3963
|
// moment the reader typed a query — while the timeline had not moved at all —
|
|
3696
3964
|
// and then the FIRST "next" went to match 2, so match 1 was only reachable by
|
|
3697
3965
|
// wrapping all the way round.
|
|
3698
|
-
|
|
3966
|
+
// The CURRENT match is tracked by STATION ID, not by array index. An index into
|
|
3967
|
+
// `matches` silently changes meaning when the station list grows: after a page
|
|
3968
|
+
// load the counter read "2/3" while the selection still sat on the record that
|
|
3969
|
+
// used to be match 2 of 2 and had become match 3 of 3.
|
|
3970
|
+
const [matchId, setMatchId] = (0, react.useState)(null);
|
|
3699
3971
|
const [follow, setFollow] = (0, react.useState)(true);
|
|
3700
3972
|
const [panelFull, setPanelFull] = (0, react.useState)(false);
|
|
3701
3973
|
const [anchorNote, setAnchorNote] = (0, react.useState)(null);
|
|
@@ -3762,9 +4034,13 @@ window.__ModuleLoader__.load({
|
|
|
3762
4034
|
requests: snap.requests,
|
|
3763
4035
|
callSchemas: snap.callSchemas,
|
|
3764
4036
|
runningCalls: snap.runningCalls,
|
|
4037
|
+
// Passed through for the "system prompt sits outside the loaded window"
|
|
4038
|
+
// case: the contract leaves `request.prompt.system` EMPTY there, and the
|
|
4039
|
+
// real text only exists on the snapshot.
|
|
4040
|
+
systemPrompts: snap.systemPrompts,
|
|
3765
4041
|
partial: partialRef.current
|
|
3766
4042
|
}, t),
|
|
3767
|
-
[snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, partialSig, streamTick, t]
|
|
4043
|
+
[snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, snap.systemPrompts, partialSig, streamTick, t]
|
|
3768
4044
|
);
|
|
3769
4045
|
const stations = tree.stations;
|
|
3770
4046
|
const stationsRef = (0, react.useRef)(stations);
|
|
@@ -3802,14 +4078,36 @@ window.__ModuleLoader__.load({
|
|
|
3802
4078
|
setFollow(true);
|
|
3803
4079
|
setRevealed(null); // overview: show the whole new transcript
|
|
3804
4080
|
setQueryRaw("");
|
|
3805
|
-
|
|
4081
|
+
setMatchId(null);
|
|
3806
4082
|
setOlderNote(null);
|
|
3807
4083
|
setPanelFull(false);
|
|
3808
4084
|
setTab("detail");
|
|
4085
|
+
// The anchor box kept the previous conversation's text: harmless (it is not
|
|
4086
|
+
// stored, and the note is fixed wording) but it reads as if it still referred to
|
|
4087
|
+
// the session on screen. Everything else in this reset block is per-session, so
|
|
4088
|
+
// this belongs here too.
|
|
4089
|
+
setAnchorInput("");
|
|
4090
|
+
setAnchorNote(null);
|
|
3809
4091
|
}, [sessionKey]);
|
|
3810
4092
|
|
|
3811
4093
|
// Remember where the reader was, so a host-initiated remount resumes there.
|
|
4094
|
+
//
|
|
4095
|
+
// The key and the VALUES can belong to different sessions for one render: when
|
|
4096
|
+
// `sessionKey` changes, the reset effect above only SCHEDULES the clear, so this
|
|
4097
|
+
// effect still sees the previous session's `revealed`/`query` next to the NEW key.
|
|
4098
|
+
// Writing that pair files session A's position under session B, and the next mount
|
|
4099
|
+
// of B then restores a selection it never had.
|
|
4100
|
+
//
|
|
4101
|
+
// HONEST LIMIT: probe group 8b catches the SYMPTOM ("view state leaked into
|
|
4102
|
+
// another session") but does not isolate this guard — removing it leaves the probe
|
|
4103
|
+
// green in 2/2 runs (§13.78 hit the same wall with the cache-scope clear). The guard
|
|
4104
|
+
// stays because the mis-write is wrong on its face, not because a red would prove it.
|
|
3812
4105
|
(0, react.useEffect)(() => {
|
|
4106
|
+
if (stateKeyRef.current !== sessionKey) {
|
|
4107
|
+
// Values in this render still belong to the previous session; drop them.
|
|
4108
|
+
stateKeyRef.current = sessionKey;
|
|
4109
|
+
return;
|
|
4110
|
+
}
|
|
3813
4111
|
writeViewState(sessionKey, revealed, queryRaw);
|
|
3814
4112
|
}, [sessionKey, revealed, queryRaw]);
|
|
3815
4113
|
|
|
@@ -3951,15 +4249,23 @@ window.__ModuleLoader__.load({
|
|
|
3951
4249
|
const stepPrev = () => {
|
|
3952
4250
|
setPlaying(false);
|
|
3953
4251
|
setFollow(false);
|
|
3954
|
-
|
|
3955
|
-
|
|
4252
|
+
// Functional update: held-down arrow keys arrive faster than React can re-render,
|
|
4253
|
+
// and reading `revealed` from the closure merged those repeats into a single step.
|
|
4254
|
+
// Measured: 20 synthetic presses in one tick advanced ONE station; with a 200 ms gap
|
|
4255
|
+
// they advanced 20. Real key auto-repeat sits in between, so the updater form is the
|
|
4256
|
+
// honest one.
|
|
4257
|
+
setRevealed((r) => {
|
|
4258
|
+
if (r === null) return N > 0 ? Math.min(N, Math.max(1, N)) : null;
|
|
4259
|
+
return r > 1 ? r - 1 : r;
|
|
4260
|
+
});
|
|
3956
4261
|
};
|
|
3957
4262
|
const stepNext = () => {
|
|
3958
4263
|
setPlaying(false);
|
|
3959
4264
|
setFollow(false);
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4265
|
+
setRevealed((r) => {
|
|
4266
|
+
if (r === null) return N > 0 ? 1 : null;
|
|
4267
|
+
return r < N ? r + 1 : null;
|
|
4268
|
+
});
|
|
3963
4269
|
};
|
|
3964
4270
|
const toEnd = () => {
|
|
3965
4271
|
setPlaying(false);
|
|
@@ -4208,7 +4514,7 @@ window.__ModuleLoader__.load({
|
|
|
4208
4514
|
|
|
4209
4515
|
// ── follow mode: keep the newest station in view while live ──────────
|
|
4210
4516
|
(0, react.useEffect)(() => {
|
|
4211
|
-
if (!follow ||
|
|
4517
|
+
if (!follow || !followTipRef.current) return;
|
|
4212
4518
|
const sc = scrollerRef.current;
|
|
4213
4519
|
if (sc === null) return;
|
|
4214
4520
|
try { sc.scrollLeft = sc.scrollWidth; } catch { /* noop */ }
|
|
@@ -4220,7 +4526,9 @@ window.__ModuleLoader__.load({
|
|
|
4220
4526
|
const matchSet = (0, react.useMemo)(() => new Set(matches), [matches]);
|
|
4221
4527
|
const searching = query !== "";
|
|
4222
4528
|
const scopeNote = searchScopeNote(hasMore, loadingOlder, t);
|
|
4223
|
-
(0, react.
|
|
4529
|
+
const matchPtr = (0, react.useMemo)(() => (matchId === null ? -1
|
|
4530
|
+
: matches.findIndex((i) => stations[i]?.id === matchId)), [matchId, matches, stations]);
|
|
4531
|
+
(0, react.useEffect)(() => { setMatchId(null); }, [query]);
|
|
4224
4532
|
const gotoMatch = (dir) => {
|
|
4225
4533
|
if (matches.length === 0) return;
|
|
4226
4534
|
// A fresh query has no current match yet, so the FIRST step has to land on an
|
|
@@ -4228,7 +4536,7 @@ window.__ModuleLoader__.load({
|
|
|
4228
4536
|
// where the match set shrank between keystrokes.
|
|
4229
4537
|
const base = matchPtr < 0 || matchPtr >= matches.length ? (dir > 0 ? -1 : 0) : matchPtr;
|
|
4230
4538
|
const next = ((base + dir) % matches.length + matches.length) % matches.length;
|
|
4231
|
-
|
|
4539
|
+
setMatchId(stations[matches[next]]?.id ?? null);
|
|
4232
4540
|
seek(matches[next]);
|
|
4233
4541
|
};
|
|
4234
4542
|
const onSearchKey = (ev) => {
|
|
@@ -4261,7 +4569,12 @@ window.__ModuleLoader__.load({
|
|
|
4261
4569
|
* (a selected `e30` became `e20`). Station ids are stable across rebuilds, so
|
|
4262
4570
|
* remember the selected id and re-derive the position from it.
|
|
4263
4571
|
*/
|
|
4264
|
-
|
|
4572
|
+
// `undefined` = "not recorded yet", `null` = "recorded, the overview is selected".
|
|
4573
|
+
// The distinction matters: a remount restores `revealed` BEFORE the station list
|
|
4574
|
+
// arrives, and writing `null` at that moment froze the pin as "nothing selected"
|
|
4575
|
+
// for good — the next page load then kept the INDEX and showed a different record
|
|
4576
|
+
// (measured: T6 → T3 after a remount onto an empty first frame).
|
|
4577
|
+
const selectedIdRef = (0, react.useRef)(void 0);
|
|
4265
4578
|
const stationsSignature = (0, react.useMemo)(() => stations.map((st) => st.id).join("\u0000"), [stations]);
|
|
4266
4579
|
// Read the station from the list directly: `activeStation` is declared further
|
|
4267
4580
|
// down, and touching a `const` before its declaration throws ReferenceError on
|
|
@@ -4271,20 +4584,45 @@ window.__ModuleLoader__.load({
|
|
|
4271
4584
|
// backwards page (same position, different station) and OVERWROTE the pinned
|
|
4272
4585
|
// id with whatever now sat at that index, so the repair effect then "confirmed"
|
|
4273
4586
|
// the wrong station. Verified live: e29532 became e28913 after loading history.
|
|
4274
|
-
|
|
4587
|
+
// Seeded with a SENTINEL, not with `revealed`. On a remount the view restores a
|
|
4588
|
+
// selection from storage, so initialising with the restored number made the first
|
|
4589
|
+
// effect run look like "nothing changed" and `selectedIdRef` was never written. The
|
|
4590
|
+
// pin-by-id repair then had nothing to work with, and the first page load after a
|
|
4591
|
+
// remount kept the INDEX instead of the station: measured "6 / 10 用户 T6" became
|
|
4592
|
+
// "6 / 13 用户 T3" once three older stations were prepended.
|
|
4593
|
+
const prevRevealedRef = (0, react.useRef)(void 0);
|
|
4594
|
+
// "The reader is at the LIVE TIP" — recorded when the SELECTION changes, using the
|
|
4595
|
+
// station count at that moment. Follow mode used to scroll only in the overview
|
|
4596
|
+
// (`revealed === null`), so with a station selected a newly streamed record stayed
|
|
4597
|
+
// off-screen even though 跟随 was on: measured 13 stations, station 13 selected,
|
|
4598
|
+
// a 14th arrives, `scrollLeft` unchanged and the new card 268 px past the right
|
|
4599
|
+
// edge. Appending a station must not clear this flag; only a deliberate jump to an
|
|
4600
|
+
// older record does.
|
|
4601
|
+
const followTipRef = (0, react.useRef)(true);
|
|
4275
4602
|
(0, react.useEffect)(() => {
|
|
4276
4603
|
const selectionChanged = prevRevealedRef.current !== revealed;
|
|
4277
4604
|
prevRevealedRef.current = revealed;
|
|
4278
|
-
|
|
4605
|
+
// Re-run when the COUNT changes too: a restored selection can arrive before the
|
|
4606
|
+
// station list does, and without this the pin stayed unrecorded for ever.
|
|
4607
|
+
// Paging is still safe — once an id is recorded, `!changed` bails out below.
|
|
4608
|
+
if (!selectionChanged && selectedIdRef.current !== void 0) return;
|
|
4609
|
+
followTipRef.current = revealed === null
|
|
4610
|
+
|| revealed >= stationsRef.current.length;
|
|
4611
|
+
if (revealed === null) { selectedIdRef.current = null; return; }
|
|
4612
|
+
// No stations yet: leave the pin UNRECORDED rather than recording "nothing",
|
|
4613
|
+
// so the arrival of the list can still fill it in.
|
|
4614
|
+
if (stationsRef.current.length === 0) return;
|
|
4279
4615
|
selectedIdRef.current = revealed === null ? null
|
|
4280
4616
|
: (stationsRef.current[Math.min(stationsRef.current.length - 1, Math.max(0, revealed - 1))]?.id ?? null);
|
|
4281
4617
|
// stationsRef is intentionally read through the ref: depending on `stations`
|
|
4282
4618
|
// here would re-fire on paging, which is the bug being fixed.
|
|
4283
4619
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4284
|
-
}, [revealed]);
|
|
4620
|
+
}, [revealed, N]);
|
|
4285
4621
|
(0, react.useEffect)(() => {
|
|
4286
4622
|
const id = selectedIdRef.current;
|
|
4287
|
-
|
|
4623
|
+
// `void 0` means the pin has not been recorded yet (data was not ready); do not
|
|
4624
|
+
// treat that as "the overview is selected".
|
|
4625
|
+
if (id === null || id === void 0) return;
|
|
4288
4626
|
const at = stations.findIndex((st) => st.id === id);
|
|
4289
4627
|
// Gone from the window (should not happen for a prepend) or already correct.
|
|
4290
4628
|
if (at < 0 || at + 1 === revealed) return;
|
|
@@ -4411,6 +4749,12 @@ window.__ModuleLoader__.load({
|
|
|
4411
4749
|
// scrolling to the top. Bail out on any modifier combination.
|
|
4412
4750
|
if (ev.ctrlKey === true || ev.metaKey === true || ev.altKey === true) return;
|
|
4413
4751
|
const tag = ev.target && ev.target.tagName ? String(ev.target.tagName).toLowerCase() : "";
|
|
4752
|
+
// Bail out when the key belongs to a text field. HONEST STATUS: with today's markup
|
|
4753
|
+
// this branch is UNREACHABLE — every input inside the panel (search, anchor) has its
|
|
4754
|
+
// own onKeyDown that calls stopPropagation for every key, so nothing arrives here from
|
|
4755
|
+
// a field. It is kept as a guard for the next field someone adds, and the probe
|
|
4756
|
+
// assertion ("End inside the anchor box does not clear the selection") therefore
|
|
4757
|
+
// cannot be made to fail by deleting this line; do not mistake it for coverage.
|
|
4414
4758
|
if (tag === "input" || tag === "textarea" || tag === "select" || (ev.target && ev.target.isContentEditable === true)) return;
|
|
4415
4759
|
if (k === "/" || k === "f") {
|
|
4416
4760
|
if (searchRef.current !== null && typeof searchRef.current.focus === "function") { searchRef.current.focus(); ev.preventDefault(); }
|
|
@@ -4588,7 +4932,12 @@ window.__ModuleLoader__.load({
|
|
|
4588
4932
|
type: "search",
|
|
4589
4933
|
autoComplete: "off",
|
|
4590
4934
|
"aria-label": t("search.label"),
|
|
4591
|
-
|
|
4935
|
+
// Bind the RAW text, not the trimmed match string. Rendering the
|
|
4936
|
+
// trimmed value made a controlled input swallow the space the user
|
|
4937
|
+
// had just typed: "alpha␣" was re-rendered as "alpha", so the next
|
|
4938
|
+
// word ran into it ("alphabeta") and a phrase search could never be
|
|
4939
|
+
// typed one key at a time. Matching still uses `query` (trimmed).
|
|
4940
|
+
value: queryRaw,
|
|
4592
4941
|
placeholder: t("action.search"),
|
|
4593
4942
|
onChange: (ev) => setQueryRaw(ev.target != null ? ev.target.value : ""),
|
|
4594
4943
|
onKeyDown: onSearchKey
|
|
@@ -4764,7 +5113,12 @@ window.__ModuleLoader__.load({
|
|
|
4764
5113
|
// stats.toolMs`), not by this station's own maximum. Mixing only the station
|
|
4765
5114
|
// fields meant every cached bar kept its old width when a DIFFERENT station
|
|
4766
5115
|
// became the slowest one — a stale proportion bar, caught by review.
|
|
4767
|
-
|
|
5116
|
+
// Hash the EFFECTIVE denominator, not both inputs. `stats.toolMs` is only a
|
|
5117
|
+
// fallback for a zero max, but hashing it made every card depend on the SUM of
|
|
5118
|
+
// all tool durations: one slow tool changed the total, so a 900-station window
|
|
5119
|
+
// rebuilt all 900 cards to widen a single bar. Measured by the perf review:
|
|
5120
|
+
// 900 rebuilds -> 1 with the effective denominator.
|
|
5121
|
+
mix(Math.max(1, stats.maxToolMs || stats.toolMs));
|
|
4768
5122
|
mix(s.outcomeText); mix(s.outcomeKind);
|
|
4769
5123
|
if (Array.isArray(s.meta)) { mix(s.meta.length); for (const m of s.meta) mix(m); }
|
|
4770
5124
|
else mix(s.meta);
|
|
@@ -4782,8 +5136,63 @@ window.__ModuleLoader__.load({
|
|
|
4782
5136
|
mix(c.durationMs); mix(c.isError === true); mix(c.running === true);
|
|
4783
5137
|
}
|
|
4784
5138
|
} else mix(-1);
|
|
4785
|
-
|
|
5139
|
+
// The hash alone is not enough: FNV-1a is 32-bit and `mix` folds a number into
|
|
5140
|
+
// 64 bits of state, so two REAL inputs can land on the same value. Measured by
|
|
5141
|
+
// review: seq-identical user stations at time 1700000000000 and 1704294967296
|
|
5142
|
+
// produced the same signature, and the cached card kept 06:13:20 while the
|
|
5143
|
+
// minimap tick (whose signature carries `fmtClock`) had already moved to 23:16:07.
|
|
5144
|
+
// Appending the RENDERED text of the two derived values the card shows gives a
|
|
5145
|
+
// second, non-hash channel — a collision now has to happen in both.
|
|
5146
|
+
//
|
|
5147
|
+
// `s.turn` was missing entirely: a station re-projected from turn 1 to turn 2
|
|
5148
|
+
// kept an aria-label reading "轮次 1" while the projection said 2.
|
|
5149
|
+
return h.toString(36)
|
|
5150
|
+
+ "\u0002" + fmtClock(s.time)
|
|
5151
|
+
+ "\u0002" + (s.turn === null || s.turn === void 0 ? "" : String(s.turn));
|
|
4786
5152
|
};
|
|
5153
|
+
/**
|
|
5154
|
+
* Sub-calls can nest (a tool that itself calls tools). The detail panel rendered
|
|
5155
|
+
* ONE level: everything from `sub.subCalls` down was invisible, while both the
|
|
5156
|
+
* single-step copy and the whole-trace export printed the whole chain — so the
|
|
5157
|
+
* screen showed strictly less than the file you could copy from it.
|
|
5158
|
+
*
|
|
5159
|
+
* Recursive now. `depth` only feeds the React key and a data attribute; there is
|
|
5160
|
+
* no visual indentation budget to blow.
|
|
5161
|
+
*/
|
|
5162
|
+
const renderSubCalls = (subs, depth) => subs.map((sub, i) => {
|
|
5163
|
+
const subPretty = prettyArgs(sub.argsRaw);
|
|
5164
|
+
const nested = Array.isArray(sub.subCalls) ? sub.subCalls : [];
|
|
5165
|
+
return jsxs("div", {
|
|
5166
|
+
className: "dstv_subCard",
|
|
5167
|
+
"data-depth": depth > 0 ? String(depth) : undefined,
|
|
5168
|
+
children: [
|
|
5169
|
+
jsxs("span", {
|
|
5170
|
+
className: "dstv_subHead",
|
|
5171
|
+
children: [
|
|
5172
|
+
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"),
|
|
5173
|
+
jsx("span", { className: "tname", children: `${depth > 0 ? "↳↳" : "↳"} ${sub.name}` }, "sName"),
|
|
5174
|
+
jsx("span", { className: "dstv_chips", children: [
|
|
5175
|
+
sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
|
|
5176
|
+
sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
|
|
5177
|
+
sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
|
|
5178
|
+
] }, "sChips")
|
|
5179
|
+
]
|
|
5180
|
+
}, "sHead"),
|
|
5181
|
+
sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
|
|
5182
|
+
jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sASum"),
|
|
5183
|
+
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sACode") }, "sAInner")
|
|
5184
|
+
] }, "sArgs") : null,
|
|
5185
|
+
sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
|
|
5186
|
+
jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sRSum"),
|
|
5187
|
+
jsx("div", { className: "inner", children: jsxs("div", { children: [
|
|
5188
|
+
jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
|
|
5189
|
+
jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
|
|
5190
|
+
] }) }, "sRInner")
|
|
5191
|
+
] }, "sRes") : null,
|
|
5192
|
+
nested.length > 0 ? jsx("div", { className: "dstv_subKids", children: renderSubCalls(nested, depth + 1) }, "sKids") : null
|
|
5193
|
+
]
|
|
5194
|
+
}, `ts${depth}-${i}`);
|
|
5195
|
+
});
|
|
4787
5196
|
const renderStationCard = (s, cardKey) => {
|
|
4788
5197
|
if (s.kind === "user") {
|
|
4789
5198
|
return jsxs("div", {
|
|
@@ -4791,7 +5200,7 @@ window.__ModuleLoader__.load({
|
|
|
4791
5200
|
children: [
|
|
4792
5201
|
jsx("span", { className: "dstv_name", children: s.who }, "uName"),
|
|
4793
5202
|
s.time != null ? jsx("span", { className: "dstv_spanRow", children: jsx("span", { className: "dstv_spanEdge", children: fmtClock(s.time) }, "uClk") }, "uSpan") : null,
|
|
4794
|
-
jsx("div", { className: "dstv_text dstv_clamp3", title: s.text, children: s.text || "…" }, "uText")
|
|
5203
|
+
jsx("div", { className: "dstv_text dstv_clamp3", title: cardTitle(s.text), children: cardText(s.text) || "…" }, "uText")
|
|
4795
5204
|
]
|
|
4796
5205
|
}, cardKey);
|
|
4797
5206
|
}
|
|
@@ -4829,8 +5238,8 @@ window.__ModuleLoader__.load({
|
|
|
4829
5238
|
className: "dstv_cellRow",
|
|
4830
5239
|
children: [
|
|
4831
5240
|
jsx("span", { className: "dstv_cellName", children: t("node.assistant") }, "aName"),
|
|
4832
|
-
cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cell.thinking, children: `💭 ${markdownToPlain(cell.thinking)}` }, "aThink") : null,
|
|
4833
|
-
cell.text !== "" ? jsx("div", { className: "dstv_text dstv_clamp2", title: cell.text, children: markdownToPlain(cell.text) }, "aText") : null
|
|
5241
|
+
cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(cell.thinking), children: `💭 ${cardText(markdownToPlain(cardText(cell.thinking)))}` }, "aThink") : null,
|
|
5242
|
+
cell.text !== "" ? jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(cell.text), children: cardText(markdownToPlain(cardText(cell.text))) }, "aText") : null
|
|
4834
5243
|
]
|
|
4835
5244
|
}, `a${cell.id}`);
|
|
4836
5245
|
}
|
|
@@ -4869,12 +5278,20 @@ window.__ModuleLoader__.load({
|
|
|
4869
5278
|
className: "dstv_name",
|
|
4870
5279
|
children: [
|
|
4871
5280
|
jsx("span", { className: s.isError ? "dstv_bad" : "dstv_ok", children: s.isError ? "✗" : "⤷" }, "oIcon"),
|
|
4872
|
-
|
|
4873
|
-
|
|
5281
|
+
// A compaction REPLAY is a different thing from "the call is outside
|
|
5282
|
+
// the window": the call is right there and was already answered.
|
|
5283
|
+
// Saying the call is missing sends the reader looking for a bug.
|
|
5284
|
+
`${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}`,
|
|
5285
|
+
jsx("span", {
|
|
5286
|
+
className: "dstv_chips",
|
|
5287
|
+
children: [jsx("span", { className: "dstv_chip info", children: s.replayOf !== null && s.replayOf !== void 0
|
|
5288
|
+
? t("orphan.replayBadge").replace("{seq}", String(s.replayOf))
|
|
5289
|
+
: t("orphan.badge") }, "oBadge")]
|
|
5290
|
+
}, "oChips")
|
|
4874
5291
|
]
|
|
4875
5292
|
}, "oName"),
|
|
4876
|
-
s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: s.args, children: s.args }, "oArgs") : null,
|
|
4877
|
-
jsx("div", { className: "dstv_text dstv_clamp4", title: body, children: body }, "oText")
|
|
5293
|
+
s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(s.args), children: cardText(s.args) }, "oArgs") : null,
|
|
5294
|
+
jsx("div", { className: "dstv_text dstv_clamp4", title: cardTitle(body), children: cardText(body) }, "oText")
|
|
4878
5295
|
]
|
|
4879
5296
|
}, cardKey);
|
|
4880
5297
|
}
|
|
@@ -4883,7 +5300,7 @@ window.__ModuleLoader__.load({
|
|
|
4883
5300
|
className: "dstv_hcard compactionCard",
|
|
4884
5301
|
children: [
|
|
4885
5302
|
jsx("span", { className: "dstv_name", children: `♺ ${t("node.compaction")}` }, "cName"),
|
|
4886
|
-
jsx("div", { className: "dstv_text dstv_clamp2", title: s.summary, children: s.summary || "…" }, "cText")
|
|
5303
|
+
jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.summary), children: cardText(s.summary) || "…" }, "cText")
|
|
4887
5304
|
]
|
|
4888
5305
|
}, cardKey);
|
|
4889
5306
|
}
|
|
@@ -4892,7 +5309,7 @@ window.__ModuleLoader__.load({
|
|
|
4892
5309
|
className: "dstv_hcard errorCard",
|
|
4893
5310
|
children: [
|
|
4894
5311
|
jsx("span", { className: "dstv_name", children: `✗ ${t("node.error")}` }, "eName"),
|
|
4895
|
-
jsx("div", { className: "dstv_text dstv_clamp2", title: s.message, children: s.message || "…" }, "eText")
|
|
5312
|
+
jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "eText")
|
|
4896
5313
|
]
|
|
4897
5314
|
}, cardKey);
|
|
4898
5315
|
}
|
|
@@ -4901,7 +5318,7 @@ window.__ModuleLoader__.load({
|
|
|
4901
5318
|
className: "dstv_hcard retryCard",
|
|
4902
5319
|
children: [
|
|
4903
5320
|
jsx("span", { className: "dstv_name", children: `↻ ${t("node.retry")}${Number.isFinite(s.retry) ? ` #${s.retry}` : ""}` }, "rName"),
|
|
4904
|
-
jsx("div", { className: "dstv_text sec dstv_clamp2", title: s.message, children: s.message || "…" }, "rText")
|
|
5321
|
+
jsx("div", { className: "dstv_text sec dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "rText")
|
|
4905
5322
|
]
|
|
4906
5323
|
}, cardKey);
|
|
4907
5324
|
}
|
|
@@ -4920,7 +5337,7 @@ window.__ModuleLoader__.load({
|
|
|
4920
5337
|
`${t("node.unknown")}${s.eventType !== "" ? ` · ${s.eventType}` : ""}`,
|
|
4921
5338
|
jsx("span", { className: "dstv_chips", children: jsx("span", { className: "dstv_chip", children: `seq ${s.seq}` }, "ukSeq") }, "ukChips")
|
|
4922
5339
|
] }, "ukName"),
|
|
4923
|
-
s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: s.payload, children: s.payload }, "ukText") : null
|
|
5340
|
+
s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: cardTitle(s.payload), children: cardText(s.payload) }, "ukText") : null
|
|
4924
5341
|
]
|
|
4925
5342
|
}, cardKey);
|
|
4926
5343
|
}
|
|
@@ -4958,6 +5375,15 @@ window.__ModuleLoader__.load({
|
|
|
4958
5375
|
if (s.kind === "maxTokens") k = "error";
|
|
4959
5376
|
const done = reached && (s.kind !== "step" || !s.live);
|
|
4960
5377
|
const matched = searching && matchSet.has(i);
|
|
5378
|
+
// Two DIFFERENT derived values, and the signature must hash each one.
|
|
5379
|
+
// `data-active` is `revealed !== null && i === R - 1`; the tab stop is that
|
|
5380
|
+
// OR the overview's first tick. Hashing only the tab stop made the two states
|
|
5381
|
+
// collide at i == 0: overview gives tab=1/active=0, selecting the first
|
|
5382
|
+
// station gives tab=1/active=1, so the cached tick kept `data-active`
|
|
5383
|
+
// undefined and the strip highlighted nothing (measured: three stations,
|
|
5384
|
+
// overview, click tick 0 → cards show selection 0, minimap active set []).
|
|
5385
|
+
const tickActive = revealed !== null && i === R - 1;
|
|
5386
|
+
const tickTab = tickActive || (revealed === null && i === 0);
|
|
4961
5387
|
// Same element-identity trick as the station cards: an unchanged tick keeps
|
|
4962
5388
|
// its element and React skips it (§13.72).
|
|
4963
5389
|
const tickSig = s.kind + "\u0002" + String(i) + "\u0002" + (reached ? "1" : "0")
|
|
@@ -4971,7 +5397,8 @@ window.__ModuleLoader__.load({
|
|
|
4971
5397
|
// overview half (`revealed === null && i === 0`). Hashing only the active
|
|
4972
5398
|
// half left tick 0 with `tabIndex: 0` after any selection, so the strip had
|
|
4973
5399
|
// TWO tab stops (measured: [0, 5] after selecting station 5).
|
|
4974
|
-
+ "\u0002" + (
|
|
5400
|
+
+ "\u0002" + (tickTab ? "1" : "0")
|
|
5401
|
+
+ "\u0002" + (tickActive ? "1" : "0")
|
|
4975
5402
|
// `data-k` reads the DERIVED kind, which is "tool" for a step that contains
|
|
4976
5403
|
// one — hash the value actually used rather than re-deriving it here.
|
|
4977
5404
|
+ "\u0002" + k
|
|
@@ -4986,7 +5413,7 @@ window.__ModuleLoader__.load({
|
|
|
4986
5413
|
"data-k": k,
|
|
4987
5414
|
"data-done": done ? "true" : undefined,
|
|
4988
5415
|
"data-dim": reached ? undefined : "true",
|
|
4989
|
-
"data-active":
|
|
5416
|
+
"data-active": tickActive ? "true" : undefined,
|
|
4990
5417
|
"data-live": s.kind === "step" && s.live === true ? "true" : undefined,
|
|
4991
5418
|
"data-match": matched ? "true" : undefined,
|
|
4992
5419
|
// Roving tabindex, same as the station list. This strip is a SECOND
|
|
@@ -4997,7 +5424,7 @@ window.__ModuleLoader__.load({
|
|
|
4997
5424
|
// ...but exactly one tick must stay reachable, or the whole strip
|
|
4998
5425
|
// disappears from the keyboard in the overview state. Same rule as
|
|
4999
5426
|
// the station list: the active one, else the first.
|
|
5000
|
-
tabIndex:
|
|
5427
|
+
tabIndex: tickTab ? 0 : -1,
|
|
5001
5428
|
// `s.label` is undefined for user stations, so the tooltip read
|
|
5002
5429
|
// "undefined · 6:13:20 AM" and the button had no accessible name at
|
|
5003
5430
|
// all. Fall back to the kind and always expose aria-label.
|
|
@@ -5216,7 +5643,7 @@ window.__ModuleLoader__.load({
|
|
|
5216
5643
|
if (s.kind === "orphan-tool") {
|
|
5217
5644
|
const body = s.displayText !== "" ? s.displayText : t("orphan.noText");
|
|
5218
5645
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
5219
|
-
jsx("span", { className: "dstv_dLabel", children: `${t("node.orphanTool")} · ${s.name}` }, "oLbl"),
|
|
5646
|
+
jsx("span", { className: "dstv_dLabel", children: `${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}` }, "oLbl"),
|
|
5220
5647
|
jsx("div", { className: "dstv_dSection", children: [
|
|
5221
5648
|
jsx("span", { className: "dstv_chip info", children: t("orphan.badge") }, "oBadge"),
|
|
5222
5649
|
jsx("span", { className: "dstv_chip", children: `callId ${s.callId}` }, "oCid")
|
|
@@ -5289,40 +5716,10 @@ window.__ModuleLoader__.load({
|
|
|
5289
5716
|
] }, `dr${cell.id}`) : null,
|
|
5290
5717
|
cell.resultText === "" && !cell.isError && !cell.running ? jsx("span", { className: "dstv_dLabel sec", children: t("detail.noResult") }, "tNoRes") : null,
|
|
5291
5718
|
cell.subCalls.length > 0 ? jsxs("details", { className: "dstv_det", open: cell.subCalls.some((sub) => sub.isError), children: [
|
|
5292
|
-
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"),
|
|
5719
|
+
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"),
|
|
5293
5720
|
jsx("div", {
|
|
5294
5721
|
className: "inner",
|
|
5295
|
-
children: cell.subCalls
|
|
5296
|
-
const subPretty = prettyArgs(sub.argsRaw);
|
|
5297
|
-
return jsxs("div", {
|
|
5298
|
-
className: "dstv_subCard",
|
|
5299
|
-
children: [
|
|
5300
|
-
jsxs("span", {
|
|
5301
|
-
className: "dstv_subHead",
|
|
5302
|
-
children: [
|
|
5303
|
-
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"),
|
|
5304
|
-
jsx("span", { className: "tname", children: `↳ ${sub.name}` }, "sName"),
|
|
5305
|
-
jsx("span", { className: "dstv_chips", children: [
|
|
5306
|
-
sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
|
|
5307
|
-
sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
|
|
5308
|
-
sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
|
|
5309
|
-
] }, "sChips")
|
|
5310
|
-
]
|
|
5311
|
-
}, "sHead"),
|
|
5312
|
-
sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
|
|
5313
|
-
jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sArgSum"),
|
|
5314
|
-
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sArgCode") }, "sArgInner")
|
|
5315
|
-
] }, "sArgs") : null,
|
|
5316
|
-
sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
|
|
5317
|
-
jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sResSum"),
|
|
5318
|
-
jsx("div", { className: "inner", children: jsxs("div", { children: [
|
|
5319
|
-
jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
|
|
5320
|
-
jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
|
|
5321
|
-
] }) }, "sResInner")
|
|
5322
|
-
] }, "sRes") : null
|
|
5323
|
-
]
|
|
5324
|
-
}, `ts${i}`);
|
|
5325
|
-
})
|
|
5722
|
+
children: renderSubCalls(cell.subCalls, 0)
|
|
5326
5723
|
}, "tSubInner")
|
|
5327
5724
|
] }, `ds${cell.id}`) : null
|
|
5328
5725
|
] }, `dt${cell.id}`);
|
|
@@ -5422,6 +5819,12 @@ window.__ModuleLoader__.load({
|
|
|
5422
5819
|
// fields can be drifted. Normalise ONCE here — every reader below
|
|
5423
5820
|
// (`tools.map`, the JSON previews, the React keys) then sees a safe shape.
|
|
5424
5821
|
const tools = safeToolList(req.prompt?.tools);
|
|
5822
|
+
// The contract says `prompt.system` is EMPTY when the system node sits outside the
|
|
5823
|
+
// loaded window; the snapshot still carries it (`systemFrom`, filled by the fold).
|
|
5824
|
+
// Showing "0 chars" there was a silent lie about what the model saw.
|
|
5825
|
+
const savedPrompt = req.systemFrom !== null && req.systemFrom !== void 0 ? req.systemFrom : null;
|
|
5826
|
+
const systemText = (req.prompt?.system ?? "") !== "" ? req.prompt.system
|
|
5827
|
+
: (savedPrompt !== null ? String(savedPrompt.text ?? "") : "");
|
|
5425
5828
|
const diff = req.promptDiff ?? null;
|
|
5426
5829
|
const evidenceChips = evidenceOf(req, activeMessages, hasMore);
|
|
5427
5830
|
|
|
@@ -5432,7 +5835,7 @@ window.__ModuleLoader__.load({
|
|
|
5432
5835
|
temperature: cfg.temperature,
|
|
5433
5836
|
reasoningEffort: cfg.reasoningEffort,
|
|
5434
5837
|
maxTokens: cfg.maxTokens,
|
|
5435
|
-
system:
|
|
5838
|
+
system: systemText,
|
|
5436
5839
|
tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })),
|
|
5437
5840
|
messages: messages.map((m) => m.role === "note"
|
|
5438
5841
|
? { role: "user", content: [{ type: "text", text: m.text }] }
|
|
@@ -5446,7 +5849,7 @@ window.__ModuleLoader__.load({
|
|
|
5446
5849
|
// else; the request tab was the only place that called JSON directly.
|
|
5447
5850
|
const payloadJson = safeJsonPreview(payload, Number.MAX_SAFE_INTEGER, 2);
|
|
5448
5851
|
const sysToolsJson = safeJsonPreview(tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })), Number.MAX_SAFE_INTEGER, 2);
|
|
5449
|
-
const sysJson = safeJsonPreview({ system:
|
|
5852
|
+
const sysJson = safeJsonPreview({ system: systemText, tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })) }, Number.MAX_SAFE_INTEGER, 2);
|
|
5450
5853
|
|
|
5451
5854
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
5452
5855
|
// config + lifecycle chips
|
|
@@ -5499,13 +5902,14 @@ window.__ModuleLoader__.load({
|
|
|
5499
5902
|
req.prompt !== null ? jsxs("div", { className: "dstv_dSection", children: [
|
|
5500
5903
|
jsxs("div", { className: "dstv_dSecHead", children: [
|
|
5501
5904
|
jsx("span", { children: `🧠 ${t("detail.systemPrompt")}` }, "spHead"),
|
|
5502
|
-
jsx("span", { className: "sub", children: `${fmtInt(
|
|
5905
|
+
jsx("span", { className: "sub", children: `${fmtInt(systemText.length)} ${t("detail.chars")}` }, "spLen"),
|
|
5906
|
+
savedPrompt !== null ? jsx("span", { className: "sub", children: t("detail.systemOutside").replace("{seq}", String(savedPrompt.seq)) }, "spOut") : null,
|
|
5503
5907
|
jsx("span", { className: "grow" }, "spGrow"),
|
|
5504
5908
|
jsx(CopyBtn, { text: sysJson, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "spCopy")
|
|
5505
5909
|
] }, "spSecHead"),
|
|
5506
5910
|
jsxs("details", { className: "dstv_det", open: false, children: [
|
|
5507
5911
|
jsx("summary", { children: [t("detail.systemPrompt")] }, "spSum"),
|
|
5508
|
-
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children:
|
|
5912
|
+
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children: systemText !== "" ? systemText : t("detail.systemNone") }, "spCode") }, "spInner")
|
|
5509
5913
|
] }, "spDet")
|
|
5510
5914
|
] }, "spSec") : null,
|
|
5511
5915
|
// tool catalog
|
|
@@ -5644,7 +6048,18 @@ window.__ModuleLoader__.load({
|
|
|
5644
6048
|
okLabel: t("anchor.copied"),
|
|
5645
6049
|
failLabel: t("anchor.copyFailed")
|
|
5646
6050
|
}, "dExportStep"),
|
|
5647
|
-
jsx("button", {
|
|
6051
|
+
jsx("button", {
|
|
6052
|
+
type: "button",
|
|
6053
|
+
className: "dstv_btn dstv_panelToggle",
|
|
6054
|
+
title: panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
|
|
6055
|
+
// A glyph is not a name. Chromium's AX tree announced this control as
|
|
6056
|
+
// "button, ⤢" — the arrow is a picture, and a screen reader user had
|
|
6057
|
+
// to guess what it does. The title alone is a tooltip, not a name.
|
|
6058
|
+
"aria-label": panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
|
|
6059
|
+
"aria-expanded": panelFull ? "true" : "false",
|
|
6060
|
+
onClick: () => setPanelFull((v) => !v),
|
|
6061
|
+
children: panelFull ? "⤡" : "⤢"
|
|
6062
|
+
}, "dToggle")
|
|
5648
6063
|
]
|
|
5649
6064
|
}, "dHead"),
|
|
5650
6065
|
// The key must include WHAT is being rendered, not just where. An error
|
|
@@ -5672,7 +6087,7 @@ window.__ModuleLoader__.load({
|
|
|
5672
6087
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.turns) }, "kvNum"), jsx("span", { children: t("node.turn") }, "kvLbl")] }, "kTurns"),
|
|
5673
6088
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.steps) }, "kvNum"), jsx("span", { children: t("node.step") }, "kvLbl")] }, "kSteps"),
|
|
5674
6089
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.tools) }, "kvNum"), jsx("span", { children: t("node.tool") }, "kvLbl")] }, "kTools"),
|
|
5675
|
-
jsxs("span", { className: `dstv_kpi${stats.errors > 0 ? " err" : ""}`, children: [jsx("b", { children: String(stats.errors) }, "kvNum"), jsx("span", { children: t("kpi.
|
|
6090
|
+
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"),
|
|
5676
6091
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtDur(stats.toolMs) }, "kvNum"), jsx("span", { children: t("kpi.toolTime") }, "kvLbl")] }, "kDur"),
|
|
5677
6092
|
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,
|
|
5678
6093
|
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,
|