dsh-trajectory-traceview-plus 0.11.5 → 0.11.7
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 +183 -1
- package/README.en.md +24 -13
- package/README.md +34 -18
- package/docs/DESIGN.md +309 -8
- package/docs/PROVENANCE.md +9 -2
- package/lib/client.js +549 -115
- 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 +296 -41
- 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
|
}
|
|
@@ -2131,7 +2259,22 @@ window.__ModuleLoader__.load({
|
|
|
2131
2259
|
const p = snap?.partial;
|
|
2132
2260
|
if (p != null && Array.isArray(p.blocks) && p.blocks.length > 0) {
|
|
2133
2261
|
const turn = typeof p.turn === "number" ? p.turn : 0;
|
|
2134
|
-
|
|
2262
|
+
// The in-flight step belongs at the END of its turn, not just after the turn's
|
|
2263
|
+
// first event. `+0.5` was added to the turn's EARLIEST seq, so a partial that
|
|
2264
|
+
// arrived while steps 1 and 2 already existed sorted BEFORE step 1: the
|
|
2265
|
+
// "running" card appeared to the left of finished work (measured order
|
|
2266
|
+
// user → step3(live) → step1 → step2). Take the turn's largest known seq.
|
|
2267
|
+
const seq = (() => {
|
|
2268
|
+
if (lastTurnEntry == null) return 0.5;
|
|
2269
|
+
let maxSeq = lastTurnEntry.seq;
|
|
2270
|
+
for (const st0 of lastTurnEntry.steps?.values() ?? []) {
|
|
2271
|
+
if (Number.isFinite(st0.seq) && st0.seq > maxSeq) maxSeq = st0.seq;
|
|
2272
|
+
}
|
|
2273
|
+
for (const s0 of lastTurnEntry.stations) {
|
|
2274
|
+
if (Number.isFinite(s0.seq) && s0.seq > maxSeq) maxSeq = s0.seq;
|
|
2275
|
+
}
|
|
2276
|
+
return maxSeq + 0.5;
|
|
2277
|
+
})();
|
|
2135
2278
|
flushUser(turn, seq);
|
|
2136
2279
|
const e = ensureTurn(turn, seq);
|
|
2137
2280
|
const step = stepOf(p.step);
|
|
@@ -2202,19 +2345,27 @@ window.__ModuleLoader__.load({
|
|
|
2202
2345
|
} else if (b.kind === "tool-call") {
|
|
2203
2346
|
if (claimedCall(turn, b.callId)) continue;
|
|
2204
2347
|
claimCall(turn, b.callId);
|
|
2205
|
-
const res = takeResult(b.callId);
|
|
2348
|
+
const res = takeResult(b.callId, turn, seq);
|
|
2206
2349
|
st.toolCount += 1;
|
|
2207
2350
|
if (res?.isError === true) st.hasError = true;
|
|
2208
2351
|
const schema = schemasById.get(b.callId);
|
|
2352
|
+
const subPack3 = mapSubCalls(res?.subCalls, t);
|
|
2209
2353
|
st.cells.push({
|
|
2210
2354
|
id: cellId("t", b.callId, st.cells.length), kind: "tool", callId: b.callId,
|
|
2211
2355
|
name: typeof b.name === "string" && b.name !== "" ? b.name : t("node.tool"),
|
|
2212
2356
|
args: argsText(b.argsRaw),
|
|
2213
2357
|
resultText: res !== undefined ? blocksText(res.content, t) : "",
|
|
2358
|
+
// The result's own seq. A copied `tvp1:e19` anchor used to die the moment a page
|
|
2359
|
+
// load brought in the call header: seq 19 stopped being a station of its own and became
|
|
2360
|
+
// a cell of the step at 15, so the anchor said "not loaded" while the output was on
|
|
2361
|
+
// screen. `resultSeq` lets the resolver walk that back to the owning step.
|
|
2362
|
+
resultSeq: res !== undefined && Number.isSafeInteger(res.seq) ? res.seq : null,
|
|
2214
2363
|
isError: res?.isError === true,
|
|
2215
2364
|
errorName: res?.error?.name,
|
|
2216
2365
|
durationMs: null, running: res === undefined,
|
|
2217
|
-
subCalls:
|
|
2366
|
+
subCalls: subPack3.list,
|
|
2367
|
+
subCallsTotal: subPack3.total,
|
|
2368
|
+
subCallsTruncated: subPack3.truncated,
|
|
2218
2369
|
schema: schema != null ? { name: schema.name, description: schema.description, parameters: schema.parameters } : null
|
|
2219
2370
|
});
|
|
2220
2371
|
}
|
|
@@ -2228,7 +2379,7 @@ window.__ModuleLoader__.load({
|
|
|
2228
2379
|
// Binary search: `turnsBySeq` is already sorted. The previous linear scan ran
|
|
2229
2380
|
// once per compaction/special event, so a log with many of both cost
|
|
2230
2381
|
// O(events x turns) — measured 105 ms at 1000 turns, and it grows from there.
|
|
2231
|
-
const turnForSeq = (s) => {
|
|
2382
|
+
const turnForSeq = (s, turnHint) => {
|
|
2232
2383
|
let lo = 0;
|
|
2233
2384
|
let hi = turnsBySeq.length - 1;
|
|
2234
2385
|
let best = null;
|
|
@@ -2237,7 +2388,21 @@ window.__ModuleLoader__.load({
|
|
|
2237
2388
|
if (turnsBySeq[mid].seq <= s) { best = turnsBySeq[mid]; lo = mid + 1; }
|
|
2238
2389
|
else hi = mid - 1;
|
|
2239
2390
|
}
|
|
2240
|
-
|
|
2391
|
+
if (best !== null) return best;
|
|
2392
|
+
// The event sits BEFORE every turn boundary in this window. That is the normal
|
|
2393
|
+
// shape after paging: a page can start on a tool RESULT whose call sits above
|
|
2394
|
+
// it, and the result's own turn then has no boundary at or before its seq.
|
|
2395
|
+
//
|
|
2396
|
+
// The fallback used to be `lastTurnEntry` — the turn created LAST — so the
|
|
2397
|
+
// orphan was filed under the newest turn and `ensureTurn` lowered that turn's
|
|
2398
|
+
// seq to the orphan's. Sorting by seq then put the NEWEST turn first and split
|
|
2399
|
+
// the timeline: turn 68 → 65 → 66 → 67, with ~1h52m of apparent rewind in the
|
|
2400
|
+
// gap bars, and the export filed the result under the wrong turn (§13.83).
|
|
2401
|
+
//
|
|
2402
|
+
// Prefer the event's OWN turn when the log states one (the orphan's node
|
|
2403
|
+
// carries `turn`), else the earliest turn — never the last.
|
|
2404
|
+
const hinted = turnMap.get(typeof turnHint === "number" ? turnHint : NaN);
|
|
2405
|
+
return hinted ?? turnsBySeq[0] ?? ensureTurn(0, s);
|
|
2241
2406
|
};
|
|
2242
2407
|
const consumedCompactionReqs = new Set();
|
|
2243
2408
|
// Index the exact-replacementSeq match instead of scanning every request per
|
|
@@ -2254,7 +2419,7 @@ window.__ModuleLoader__.load({
|
|
|
2254
2419
|
}
|
|
2255
2420
|
for (const n of nodes) {
|
|
2256
2421
|
if (n.kind === "compaction") {
|
|
2257
|
-
const e = turnForSeq(n.seq);
|
|
2422
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2258
2423
|
// Pair with the compaction provider request: exact replacementSeq
|
|
2259
2424
|
// match first, else the nearest unconsumed compaction request that
|
|
2260
2425
|
// completed within a minute before this marker landed.
|
|
@@ -2269,6 +2434,13 @@ window.__ModuleLoader__.load({
|
|
|
2269
2434
|
let best = null;
|
|
2270
2435
|
for (const r of compactionReqs) {
|
|
2271
2436
|
if (consumedCompactionReqs.has(r)) continue;
|
|
2437
|
+
// A request that NAMES a different replacementSeq belongs to that
|
|
2438
|
+
// marker. Time-proximity used to override the declaration, so a
|
|
2439
|
+
// marker at seq 20 displayed the output of the request for seq 10 —
|
|
2440
|
+
// a marker outside the window — and `unplacedRequests` stayed 0, so
|
|
2441
|
+
// nothing said the text was someone else's. Leaving it unconsumed
|
|
2442
|
+
// makes the view report it instead of borrowing it.
|
|
2443
|
+
if (Number.isSafeInteger(r.replacementSeq) && r.replacementSeq !== n.seq) continue;
|
|
2272
2444
|
const doneAt = Number.isFinite(r.completedAt) ? r.completedAt : r.startedAt;
|
|
2273
2445
|
if (!Number.isFinite(doneAt)) continue;
|
|
2274
2446
|
const gap = n.time - doneAt;
|
|
@@ -2319,7 +2491,7 @@ window.__ModuleLoader__.load({
|
|
|
2319
2491
|
const e = ensureTurn(typeof n.turn === "number" ? n.turn : 0, n.seq);
|
|
2320
2492
|
e.stations.push({ id: `x${n.seq}`, kind: "maxTokens", time: n.time, seq: n.seq, label: t("node.maxTokens") });
|
|
2321
2493
|
} else if (n.kind === "command") {
|
|
2322
|
-
const e = turnForSeq(n.seq);
|
|
2494
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2323
2495
|
e.stations.push({
|
|
2324
2496
|
id: `c${n.seq}`, kind: "command", time: n.time, seq: n.seq,
|
|
2325
2497
|
name: asText(n.name) !== "" ? asText(n.name) : `/${asText(n.commandId) || "?"}`, args: asText(n.args),
|
|
@@ -2330,7 +2502,7 @@ window.__ModuleLoader__.load({
|
|
|
2330
2502
|
// The contract's own fallback surface. Rendering nothing would hide a
|
|
2331
2503
|
// real event that exists in the session log, and the review tool's whole
|
|
2332
2504
|
// promise is that what the log recorded is what the reader sees.
|
|
2333
|
-
const e = turnForSeq(n.seq);
|
|
2505
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2334
2506
|
e.stations.push({
|
|
2335
2507
|
id: `k${n.seq}`, kind: "unknown", time: n.time, seq: n.seq,
|
|
2336
2508
|
eventType: typeof n.type === "string" ? n.type : "",
|
|
@@ -2372,9 +2544,10 @@ window.__ModuleLoader__.load({
|
|
|
2372
2544
|
return `ot${base}${seen === 0 ? "" : `_${String(seen)}`}`;
|
|
2373
2545
|
};
|
|
2374
2546
|
for (const n of orphans) {
|
|
2375
|
-
const e = turnForSeq(n.seq);
|
|
2547
|
+
const e = turnForSeq(n.seq, n.turn);
|
|
2376
2548
|
const text = blocksText(n.content, t);
|
|
2377
|
-
const
|
|
2549
|
+
const subCallPack = mapSubCalls(n.subCalls, t);
|
|
2550
|
+
const subCalls = subCallPack.list;
|
|
2378
2551
|
// Anchor issuance is centralized in the "special stations" branch below
|
|
2379
2552
|
// (it re-checks `seq` for integer-ness and stamps anchorKey/synthetic).
|
|
2380
2553
|
e.stations.push({
|
|
@@ -2401,6 +2574,14 @@ window.__ModuleLoader__.load({
|
|
|
2401
2574
|
displayText: text !== "" ? text : (n.error?.code ?? n.error?.name ?? ""),
|
|
2402
2575
|
isError: n.isError === true,
|
|
2403
2576
|
subCalls,
|
|
2577
|
+
subCallsTotal: subCallPack.total,
|
|
2578
|
+
subCallsTruncated: subCallPack.truncated,
|
|
2579
|
+
// Set when this same callId ALREADY produced a result earlier in the window —
|
|
2580
|
+
// i.e. this is a compaction replay, not a missing call.
|
|
2581
|
+
replayOf: (() => {
|
|
2582
|
+
const used = consumedByCallId.get(n.callId);
|
|
2583
|
+
return used !== void 0 && used.length > 0 ? used[0] : null;
|
|
2584
|
+
})(),
|
|
2404
2585
|
hasError: n.isError === true
|
|
2405
2586
|
});
|
|
2406
2587
|
}
|
|
@@ -2410,9 +2591,9 @@ window.__ModuleLoader__.load({
|
|
|
2410
2591
|
// Sort turns by their earliest known seq first (turn 0 "system events" may
|
|
2411
2592
|
// be created late by a stray compaction/command and would otherwise land last).
|
|
2412
2593
|
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() ?? [])
|
|
2594
|
+
let mseq = orderKey(e.seq);
|
|
2595
|
+
for (const st of e.stations) mseq = Math.min(mseq, orderKey(st.seq));
|
|
2596
|
+
for (const st of e.steps?.values() ?? []) mseq = Math.min(mseq, orderKey(st.seq));
|
|
2416
2597
|
e.minSeq = mseq;
|
|
2417
2598
|
}
|
|
2418
2599
|
turns.sort((a, b) => a.minSeq - b.minSeq);
|
|
@@ -2426,7 +2607,7 @@ window.__ModuleLoader__.load({
|
|
|
2426
2607
|
const turnNodes = turns.map((e) => {
|
|
2427
2608
|
const pieceList = [];
|
|
2428
2609
|
for (const s of e.stations) {
|
|
2429
|
-
pieceList.push({ at: s.seq, kind: s.kind, data: s });
|
|
2610
|
+
pieceList.push({ at: orderKey(s.seq), kind: s.kind, data: s });
|
|
2430
2611
|
if (s.kind === "orphan-tool") {
|
|
2431
2612
|
stats.tools += 1;
|
|
2432
2613
|
if (s.isError === true) stats.errors += 1;
|
|
@@ -2435,7 +2616,7 @@ window.__ModuleLoader__.load({
|
|
|
2435
2616
|
const stepNums = e.steps === void 0 ? [] : [...e.steps.keys()].sort((a, b) => a - b);
|
|
2436
2617
|
for (const s of stepNums) {
|
|
2437
2618
|
const st = e.steps.get(s);
|
|
2438
|
-
pieceList.push({ at: st.seq, kind: "step", data: st, stepNum: s });
|
|
2619
|
+
pieceList.push({ at: orderKey(st.seq), kind: "step", data: st, stepNum: s });
|
|
2439
2620
|
}
|
|
2440
2621
|
pieceList.sort((a, b) => a.at - b.at);
|
|
2441
2622
|
|
|
@@ -2508,6 +2689,15 @@ window.__ModuleLoader__.load({
|
|
|
2508
2689
|
tools: Array.isArray(found.prompt.tools) ? found.prompt.tools : [],
|
|
2509
2690
|
systemChars: typeof found.prompt.system === "string" ? found.prompt.system.length : 0
|
|
2510
2691
|
} : null,
|
|
2692
|
+
// Present only when the request header's own prompt text is empty AND an older
|
|
2693
|
+
// system event exists: the reader then sees the real text, labelled as coming from
|
|
2694
|
+
// outside the window, instead of "0 chars".
|
|
2695
|
+
systemFrom: (() => {
|
|
2696
|
+
const own = found.prompt != null && typeof found.prompt.system === "string" ? found.prompt.system : "";
|
|
2697
|
+
if (own !== "") return null;
|
|
2698
|
+
const older = systemPromptBefore(Number(r.startSeq));
|
|
2699
|
+
return older !== null ? { seq: Number(older.seq), text: older.text, update: older.update === true } : null;
|
|
2700
|
+
})(),
|
|
2511
2701
|
promptChangeKind: r.promptChange?.kind ?? null,
|
|
2512
2702
|
promptDiff: promptDiffOf(r.promptChange, found.prompt),
|
|
2513
2703
|
startSeq: r.startSeq ?? null
|
|
@@ -2771,7 +2961,8 @@ window.__ModuleLoader__.load({
|
|
|
2771
2961
|
: station.kind === "user" ? t("node.user")
|
|
2772
2962
|
: station.kind === "error" ? t("node.error")
|
|
2773
2963
|
: station.kind === "compaction" ? t("node.compaction")
|
|
2774
|
-
:
|
|
2964
|
+
// Same distinction as the card: a compaction replay is not a missing call.
|
|
2965
|
+
: station.kind === "orphan-tool" ? t(station.replayOf !== null && station.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")
|
|
2775
2966
|
: station.kind === "unknown" ? t("node.unknown")
|
|
2776
2967
|
: String(station.kind);
|
|
2777
2968
|
const parts = [`${position} / ${total}`, kind];
|
|
@@ -2933,6 +3124,16 @@ window.__ModuleLoader__.load({
|
|
|
2933
3124
|
// again here duplicated every sub-call result in the export.
|
|
2934
3125
|
pushSubLines(L, sub, 1, t);
|
|
2935
3126
|
}
|
|
3127
|
+
// Say it when the list was cut. A file that silently stops at 1,999 of
|
|
3128
|
+
// 20,000 reads as "this was everything", which is the one outcome this
|
|
3129
|
+
// view promises never to produce.
|
|
3130
|
+
if (cell.subCallsTruncated === true && Number.isSafeInteger(cell.subCallsTotal)) {
|
|
3131
|
+
const shown = (cell.subCalls ?? []).length;
|
|
3132
|
+
L.push("");
|
|
3133
|
+
L.push(`> ${typeof t === "function"
|
|
3134
|
+
? t("detail.subCallsCut").replace("{shown}", fmtInt(shown)).replace("{total}", fmtInt(cell.subCallsTotal))
|
|
3135
|
+
: `showing the first ${String(shown)} of ${String(cell.subCallsTotal)}`}`);
|
|
3136
|
+
}
|
|
2936
3137
|
L.push("");
|
|
2937
3138
|
}
|
|
2938
3139
|
}
|
|
@@ -3012,7 +3213,27 @@ window.__ModuleLoader__.load({
|
|
|
3012
3213
|
// "[object Object]".
|
|
3013
3214
|
return asText(content)
|
|
3014
3215
|
.replace(/`{3,}/g, (run) => "\\`".repeat(run.length))
|
|
3015
|
-
|
|
3216
|
+
// GFM fences with TILDES too, and only backticks were escaped: prose ending in an
|
|
3217
|
+
// unclosed "~~~" turned every following station into code (verified with Pandoc
|
|
3218
|
+
// by the boundary review). Same treatment: leading tildes of a run this long
|
|
3219
|
+
// get escaped, so the run is no longer a fence opener.
|
|
3220
|
+
.replace(/(^|\n)(~{3,})/g, (m, lead, run) => lead + "\\~".repeat(run.length))
|
|
3221
|
+
.replace(/<(\/?)(details)\b/gi, "<$1$2")
|
|
3222
|
+
// A content line that starts with `#` becomes a real heading in the export and
|
|
3223
|
+
// silently re-sections the document (measured: a compaction summary containing
|
|
3224
|
+
// "### 伪造标题" produced a section the panel never showed). Escaping turns it
|
|
3225
|
+
// back into text; a Markdown renderer still displays the bare `#`.
|
|
3226
|
+
.replace(/^(\s*)(#{1,6})\s/gm, "$1\\$2 ");
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Free text that sits INSIDE a generated line (a heading, a label).
|
|
3230
|
+
*
|
|
3231
|
+
* `proseSafe` keeps newlines, which is right for a paragraph and wrong for a heading:
|
|
3232
|
+
* a tool name or a slash-command's arguments containing "\n### …" forges a section in
|
|
3233
|
+
* the exported Markdown. Flatten first, then apply the same escaping.
|
|
3234
|
+
*/
|
|
3235
|
+
function inlineSafe(content) {
|
|
3236
|
+
return proseSafe(asText(content).replace(/\s+/g, " ").trim());
|
|
3016
3237
|
}
|
|
3017
3238
|
function fencedBlock(content, lang) {
|
|
3018
3239
|
const text = String(content ?? "");
|
|
@@ -3141,6 +3362,27 @@ window.__ModuleLoader__.load({
|
|
|
3141
3362
|
return out;
|
|
3142
3363
|
}
|
|
3143
3364
|
/** Block-level split. Returns descriptors; see mdInline for the inline level. */
|
|
3365
|
+
/**
|
|
3366
|
+
* Is this line a Markdown table separator (`|---|:--:|`)?
|
|
3367
|
+
*
|
|
3368
|
+
* Equivalent to `/^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/`, but linear. The regex was
|
|
3369
|
+
* quadratic on failure: two overlapping classes around the mandatory `-` let it
|
|
3370
|
+
* re-split a long dash run for every possible position.
|
|
3371
|
+
*/
|
|
3372
|
+
const WHITESPACE_CHAR = /\s/;
|
|
3373
|
+
function isTableSeparator(line) {
|
|
3374
|
+
if (typeof line !== "string") return false;
|
|
3375
|
+
let dashes = 0;
|
|
3376
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
3377
|
+
const ch = line[i];
|
|
3378
|
+
if (ch === "-") { dashes += 1; continue; }
|
|
3379
|
+
// `\s` in the original class, plus the pipe. Testing one character at a time
|
|
3380
|
+
// keeps the whole thing linear and preserves CRLF and Unicode-space behaviour.
|
|
3381
|
+
if (ch === "|" || ch === ":" || WHITESPACE_CHAR.test(ch)) continue;
|
|
3382
|
+
return false;
|
|
3383
|
+
}
|
|
3384
|
+
return dashes > 0;
|
|
3385
|
+
}
|
|
3144
3386
|
function mdBlocks(src) {
|
|
3145
3387
|
const lines = String(src ?? "").replace(/\r\n?/g, "\n").split("\n");
|
|
3146
3388
|
const blocks = [];
|
|
@@ -3174,7 +3416,12 @@ window.__ModuleLoader__.load({
|
|
|
3174
3416
|
continue;
|
|
3175
3417
|
}
|
|
3176
3418
|
// Table: a header row followed by a |---|---| separator.
|
|
3177
|
-
|
|
3419
|
+
// The separator test used to be `/^\s*\|?[\s:|-]*-[\s:|-]*\|?\s*$/`. Its two
|
|
3420
|
+
// character classes overlap on `-`, so a long dash run that FAILS backtracks over
|
|
3421
|
+
// every split: measured 2,000 hyphens 96 ms, 4,000 575 ms, 8,000 2.1 s,
|
|
3422
|
+
// 16,000 7.4 s — a synchronous stall inside the detail panel, on content a model
|
|
3423
|
+
// can emit. Same predicate, one linear pass (§13.84).
|
|
3424
|
+
if (line.includes("|") && i + 1 < lines.length && isTableSeparator(lines[i + 1])) {
|
|
3178
3425
|
// `\|` is the escape for a literal pipe inside a cell — the only way to
|
|
3179
3426
|
// put one in a table at all. Splitting on every `|` cut such a cell in
|
|
3180
3427
|
// two, so `| a \| b | c |` became THREE columns ("a \", "b", "c") and
|
|
@@ -3236,6 +3483,30 @@ window.__ModuleLoader__.load({
|
|
|
3236
3483
|
}
|
|
3237
3484
|
return blocks;
|
|
3238
3485
|
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Hard caps for text that goes into a STATION CARD.
|
|
3488
|
+
*
|
|
3489
|
+
* A card shows at most four clamped lines, but `dstv_clamp4` only hides the overflow:
|
|
3490
|
+
* the text node and the `title` attribute both kept the whole string. Measured with a
|
|
3491
|
+
* 1 MB assistant message: 1,575 ms to paint one card and 1,000,007 characters in the
|
|
3492
|
+
* DOM (the tooltip alone carried the megabyte). The full text stays available through
|
|
3493
|
+
* copy, the detail panel and the export — the card is a thumbnail, not a viewer.
|
|
3494
|
+
*/
|
|
3495
|
+
// 20 000, not 2 000: group 20 of the browser probe renders a 20k body in full and
|
|
3496
|
+
// requires a one-character edit deep inside it to repaint the card. The cap exists to
|
|
3497
|
+
// stop megabyte messages, not to change what a long-but-normal message looks like.
|
|
3498
|
+
const CARD_TEXT_MAX = 20000;
|
|
3499
|
+
const CARD_TITLE_MAX = 300;
|
|
3500
|
+
/** Clamp a string for rendering inside a card, marking that it was cut. */
|
|
3501
|
+
function cardText(v) {
|
|
3502
|
+
const s = typeof v === "string" ? v : v == null ? "" : String(v);
|
|
3503
|
+
return s.length > CARD_TEXT_MAX ? `${s.slice(0, CARD_TEXT_MAX)}…` : s;
|
|
3504
|
+
}
|
|
3505
|
+
/** Clamp a string for a `title` tooltip: a tooltip longer than this is unreadable. */
|
|
3506
|
+
function cardTitle(v) {
|
|
3507
|
+
const s = typeof v === "string" ? v : v == null ? "" : String(v);
|
|
3508
|
+
return s.length > CARD_TITLE_MAX ? `${s.slice(0, CARD_TITLE_MAX)}…` : s;
|
|
3509
|
+
}
|
|
3239
3510
|
/** Markdown with markers stripped, for one-line previews. */
|
|
3240
3511
|
function markdownToPlain(src) {
|
|
3241
3512
|
let out = "";
|
|
@@ -3247,7 +3518,11 @@ window.__ModuleLoader__.load({
|
|
|
3247
3518
|
L.push(`# ${t("export.title")}`);
|
|
3248
3519
|
L.push("");
|
|
3249
3520
|
const s = tree.stats;
|
|
3250
|
-
|
|
3521
|
+
// The header KPI strip carries FIVE numbers, and the export carried four: a
|
|
3522
|
+
// reader who saw "900 ms 工具总耗时" on screen and pasted the export into a bug
|
|
3523
|
+
// report lost exactly that number. Same rule as the warning lines below — the
|
|
3524
|
+
// file states what the screen states.
|
|
3525
|
+
L.push(`> ${t("node.turn")} ${s.turns} · ${t("node.step")} ${s.steps} · ${t("node.tool")} ${s.tools} · ${t("kpi.errors")} ${s.errors} · ${t("kpi.toolTime")} ${fmtDur(s.toolMs)} · ${t("kpi.tokensIn")} ${fmtTokens(s.tokensIn)} · ${t("kpi.tokensOut")} ${fmtTokens(s.tokensOut)}${s.lastModel ? ` · ${s.lastModel}` : ""}`);
|
|
3251
3526
|
// The panel warns about a damaged or drifting log in its header; the export used
|
|
3252
3527
|
// to state only the totals, so a saved "study notes" file silently claimed a
|
|
3253
3528
|
// clean read of a log the screen was actively flagging. Same rule as the error
|
|
@@ -3300,21 +3575,29 @@ window.__ModuleLoader__.load({
|
|
|
3300
3575
|
L.push("");
|
|
3301
3576
|
pushSubLines(L, sub, 1, t);
|
|
3302
3577
|
}
|
|
3578
|
+
if (cell.subCallsTruncated === true && Number.isSafeInteger(cell.subCallsTotal)) {
|
|
3579
|
+
L.push("");
|
|
3580
|
+
L.push(`> ${t("detail.subCallsCut").replace("{shown}", fmtInt(cell.subCalls.length)).replace("{total}", fmtInt(cell.subCallsTotal))}`);
|
|
3581
|
+
}
|
|
3303
3582
|
}
|
|
3304
3583
|
}
|
|
3305
3584
|
} else if (st.kind === "orphan-tool") {
|
|
3306
|
-
L.push(`### ⤷ ${t("node.orphanTool")} · ${st.name}`);
|
|
3585
|
+
L.push(`### ⤷ ${t(st.replayOf !== null && st.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${st.name}`);
|
|
3307
3586
|
L.push("");
|
|
3308
|
-
L.push(`_${t("orphan.badge")} · ${anchorOf(st) ?? "—"}_`);
|
|
3587
|
+
L.push(`_${t(st.replayOf !== null && st.replayOf !== void 0 ? "orphan.replayBadge" : "orphan.badge").replace("{seq}", String(st.replayOf ?? ""))} · ${anchorOf(st) ?? "—"}_`);
|
|
3309
3588
|
if (st.args !== "") { L.push(""); L.push(...fencedBlock(prettyArgs(st.args) || st.args, "json")); }
|
|
3310
3589
|
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)); }
|
|
3590
|
+
if (st.subCallsTruncated === true && Number.isSafeInteger(st.subCallsTotal)) {
|
|
3591
|
+
L.push("");
|
|
3592
|
+
L.push(`> ${t("detail.subCallsCut").replace("{shown}", fmtInt((st.subCalls || []).length)).replace("{total}", fmtInt(st.subCallsTotal))}`);
|
|
3593
|
+
}
|
|
3311
3594
|
} else if (st.kind === "compaction") {
|
|
3312
3595
|
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>"); }
|
|
3596
|
+
if (st.summary !== "") { L.push(""); L.push(proseSafe(st.summary)); }
|
|
3597
|
+
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
3598
|
} else if (st.kind === "error") {
|
|
3316
3599
|
L.push(`### ✗ ${st.label}${st.code != null ? ` \`${st.code}\`` : ""}`);
|
|
3317
|
-
L.push(""); L.push(st.message
|
|
3600
|
+
L.push(""); L.push(st.message ? proseSafe(st.message) : "…");
|
|
3318
3601
|
} else if (st.kind === "retry") {
|
|
3319
3602
|
// The detail panel shows the retry counter, the provider and the error
|
|
3320
3603
|
// code; the export showed none of them, so the Markdown copy of a failed
|
|
@@ -3327,12 +3610,12 @@ window.__ModuleLoader__.load({
|
|
|
3327
3610
|
if (st.code != null) retryBits.push(`code: ${st.code}`);
|
|
3328
3611
|
if (st.retryState) retryBits.push(String(st.retryState));
|
|
3329
3612
|
L.push(`### ↻ ${st.label}${retryBits.length > 0 ? ` (${retryBits.join(" · ")})` : ""}`);
|
|
3330
|
-
if (st.message) { L.push(""); L.push(st.message); }
|
|
3613
|
+
if (st.message) { L.push(""); L.push(proseSafe(st.message)); }
|
|
3331
3614
|
} else if (st.kind === "maxTokens") {
|
|
3332
3615
|
L.push(`### ⛔ ${st.label}`);
|
|
3333
3616
|
} else if (st.kind === "command") {
|
|
3334
|
-
L.push(`### ⚡ /${st.name}${st.args !== "" ? ` ${st.args}` : ""}`);
|
|
3335
|
-
if (st.outcomeText) { L.push(""); L.push(st.outcomeText); }
|
|
3617
|
+
L.push(`### ⚡ /${inlineSafe(st.name)}${st.args !== "" ? ` ${inlineSafe(st.args)}` : ""}`);
|
|
3618
|
+
if (st.outcomeText) { L.push(""); L.push(proseSafe(st.outcomeText)); }
|
|
3336
3619
|
} else if (st.kind === "unknown") {
|
|
3337
3620
|
L.push(`### ? ${t("node.unknown")}${st.eventType ? ` \`${st.eventType}\`` : ""}`);
|
|
3338
3621
|
if (st.payload) { L.push(""); L.push(...fencedBlock(st.payload, "json")); }
|
|
@@ -3677,6 +3960,10 @@ window.__ModuleLoader__.load({
|
|
|
3677
3960
|
// applied to a completely different transcript. `sessionKey` arrives from the
|
|
3678
3961
|
// slot's `inject`; when the host does not provide one, behaviour is unchanged.
|
|
3679
3962
|
const sessionRef = (0, react.useRef)(sessionKey);
|
|
3963
|
+
// The session key that the CURRENT `revealed`/`query` values belong to. They lag one
|
|
3964
|
+
// render behind a key change (the clear is scheduled, not applied), and writing that
|
|
3965
|
+
// pair under the new key leaked one session's position into another.
|
|
3966
|
+
const stateKeyRef = (0, react.useRef)(sessionKey);
|
|
3680
3967
|
// ── view state that survives a tab switch ─────────────────────────────
|
|
3681
3968
|
// The host UNMOUNTS this panel when the reader looks at the conversation and
|
|
3682
3969
|
// remounts it on return (measured: root count 0 → 1). Without this, every
|
|
@@ -3695,7 +3982,11 @@ window.__ModuleLoader__.load({
|
|
|
3695
3982
|
// moment the reader typed a query — while the timeline had not moved at all —
|
|
3696
3983
|
// and then the FIRST "next" went to match 2, so match 1 was only reachable by
|
|
3697
3984
|
// wrapping all the way round.
|
|
3698
|
-
|
|
3985
|
+
// The CURRENT match is tracked by STATION ID, not by array index. An index into
|
|
3986
|
+
// `matches` silently changes meaning when the station list grows: after a page
|
|
3987
|
+
// load the counter read "2/3" while the selection still sat on the record that
|
|
3988
|
+
// used to be match 2 of 2 and had become match 3 of 3.
|
|
3989
|
+
const [matchId, setMatchId] = (0, react.useState)(null);
|
|
3699
3990
|
const [follow, setFollow] = (0, react.useState)(true);
|
|
3700
3991
|
const [panelFull, setPanelFull] = (0, react.useState)(false);
|
|
3701
3992
|
const [anchorNote, setAnchorNote] = (0, react.useState)(null);
|
|
@@ -3762,9 +4053,13 @@ window.__ModuleLoader__.load({
|
|
|
3762
4053
|
requests: snap.requests,
|
|
3763
4054
|
callSchemas: snap.callSchemas,
|
|
3764
4055
|
runningCalls: snap.runningCalls,
|
|
4056
|
+
// Passed through for the "system prompt sits outside the loaded window"
|
|
4057
|
+
// case: the contract leaves `request.prompt.system` EMPTY there, and the
|
|
4058
|
+
// real text only exists on the snapshot.
|
|
4059
|
+
systemPrompts: snap.systemPrompts,
|
|
3765
4060
|
partial: partialRef.current
|
|
3766
4061
|
}, t),
|
|
3767
|
-
[snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, partialSig, streamTick, t]
|
|
4062
|
+
[snap.eventNodes, snap.requests, snap.callSchemas, snap.runningCalls, snap.systemPrompts, partialSig, streamTick, t]
|
|
3768
4063
|
);
|
|
3769
4064
|
const stations = tree.stations;
|
|
3770
4065
|
const stationsRef = (0, react.useRef)(stations);
|
|
@@ -3802,14 +4097,36 @@ window.__ModuleLoader__.load({
|
|
|
3802
4097
|
setFollow(true);
|
|
3803
4098
|
setRevealed(null); // overview: show the whole new transcript
|
|
3804
4099
|
setQueryRaw("");
|
|
3805
|
-
|
|
4100
|
+
setMatchId(null);
|
|
3806
4101
|
setOlderNote(null);
|
|
3807
4102
|
setPanelFull(false);
|
|
3808
4103
|
setTab("detail");
|
|
4104
|
+
// The anchor box kept the previous conversation's text: harmless (it is not
|
|
4105
|
+
// stored, and the note is fixed wording) but it reads as if it still referred to
|
|
4106
|
+
// the session on screen. Everything else in this reset block is per-session, so
|
|
4107
|
+
// this belongs here too.
|
|
4108
|
+
setAnchorInput("");
|
|
4109
|
+
setAnchorNote(null);
|
|
3809
4110
|
}, [sessionKey]);
|
|
3810
4111
|
|
|
3811
4112
|
// Remember where the reader was, so a host-initiated remount resumes there.
|
|
4113
|
+
//
|
|
4114
|
+
// The key and the VALUES can belong to different sessions for one render: when
|
|
4115
|
+
// `sessionKey` changes, the reset effect above only SCHEDULES the clear, so this
|
|
4116
|
+
// effect still sees the previous session's `revealed`/`query` next to the NEW key.
|
|
4117
|
+
// Writing that pair files session A's position under session B, and the next mount
|
|
4118
|
+
// of B then restores a selection it never had.
|
|
4119
|
+
//
|
|
4120
|
+
// HONEST LIMIT: probe group 8b catches the SYMPTOM ("view state leaked into
|
|
4121
|
+
// another session") but does not isolate this guard — removing it leaves the probe
|
|
4122
|
+
// green in 2/2 runs (§13.78 hit the same wall with the cache-scope clear). The guard
|
|
4123
|
+
// stays because the mis-write is wrong on its face, not because a red would prove it.
|
|
3812
4124
|
(0, react.useEffect)(() => {
|
|
4125
|
+
if (stateKeyRef.current !== sessionKey) {
|
|
4126
|
+
// Values in this render still belong to the previous session; drop them.
|
|
4127
|
+
stateKeyRef.current = sessionKey;
|
|
4128
|
+
return;
|
|
4129
|
+
}
|
|
3813
4130
|
writeViewState(sessionKey, revealed, queryRaw);
|
|
3814
4131
|
}, [sessionKey, revealed, queryRaw]);
|
|
3815
4132
|
|
|
@@ -3951,15 +4268,23 @@ window.__ModuleLoader__.load({
|
|
|
3951
4268
|
const stepPrev = () => {
|
|
3952
4269
|
setPlaying(false);
|
|
3953
4270
|
setFollow(false);
|
|
3954
|
-
|
|
3955
|
-
|
|
4271
|
+
// Functional update: held-down arrow keys arrive faster than React can re-render,
|
|
4272
|
+
// and reading `revealed` from the closure merged those repeats into a single step.
|
|
4273
|
+
// Measured: 20 synthetic presses in one tick advanced ONE station; with a 200 ms gap
|
|
4274
|
+
// they advanced 20. Real key auto-repeat sits in between, so the updater form is the
|
|
4275
|
+
// honest one.
|
|
4276
|
+
setRevealed((r) => {
|
|
4277
|
+
if (r === null) return N > 0 ? Math.min(N, Math.max(1, N)) : null;
|
|
4278
|
+
return r > 1 ? r - 1 : r;
|
|
4279
|
+
});
|
|
3956
4280
|
};
|
|
3957
4281
|
const stepNext = () => {
|
|
3958
4282
|
setPlaying(false);
|
|
3959
4283
|
setFollow(false);
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4284
|
+
setRevealed((r) => {
|
|
4285
|
+
if (r === null) return N > 0 ? 1 : null;
|
|
4286
|
+
return r < N ? r + 1 : null;
|
|
4287
|
+
});
|
|
3963
4288
|
};
|
|
3964
4289
|
const toEnd = () => {
|
|
3965
4290
|
setPlaying(false);
|
|
@@ -4208,7 +4533,7 @@ window.__ModuleLoader__.load({
|
|
|
4208
4533
|
|
|
4209
4534
|
// ── follow mode: keep the newest station in view while live ──────────
|
|
4210
4535
|
(0, react.useEffect)(() => {
|
|
4211
|
-
if (!follow ||
|
|
4536
|
+
if (!follow || !followTipRef.current) return;
|
|
4212
4537
|
const sc = scrollerRef.current;
|
|
4213
4538
|
if (sc === null) return;
|
|
4214
4539
|
try { sc.scrollLeft = sc.scrollWidth; } catch { /* noop */ }
|
|
@@ -4220,7 +4545,9 @@ window.__ModuleLoader__.load({
|
|
|
4220
4545
|
const matchSet = (0, react.useMemo)(() => new Set(matches), [matches]);
|
|
4221
4546
|
const searching = query !== "";
|
|
4222
4547
|
const scopeNote = searchScopeNote(hasMore, loadingOlder, t);
|
|
4223
|
-
(0, react.
|
|
4548
|
+
const matchPtr = (0, react.useMemo)(() => (matchId === null ? -1
|
|
4549
|
+
: matches.findIndex((i) => stations[i]?.id === matchId)), [matchId, matches, stations]);
|
|
4550
|
+
(0, react.useEffect)(() => { setMatchId(null); }, [query]);
|
|
4224
4551
|
const gotoMatch = (dir) => {
|
|
4225
4552
|
if (matches.length === 0) return;
|
|
4226
4553
|
// A fresh query has no current match yet, so the FIRST step has to land on an
|
|
@@ -4228,7 +4555,7 @@ window.__ModuleLoader__.load({
|
|
|
4228
4555
|
// where the match set shrank between keystrokes.
|
|
4229
4556
|
const base = matchPtr < 0 || matchPtr >= matches.length ? (dir > 0 ? -1 : 0) : matchPtr;
|
|
4230
4557
|
const next = ((base + dir) % matches.length + matches.length) % matches.length;
|
|
4231
|
-
|
|
4558
|
+
setMatchId(stations[matches[next]]?.id ?? null);
|
|
4232
4559
|
seek(matches[next]);
|
|
4233
4560
|
};
|
|
4234
4561
|
const onSearchKey = (ev) => {
|
|
@@ -4261,7 +4588,12 @@ window.__ModuleLoader__.load({
|
|
|
4261
4588
|
* (a selected `e30` became `e20`). Station ids are stable across rebuilds, so
|
|
4262
4589
|
* remember the selected id and re-derive the position from it.
|
|
4263
4590
|
*/
|
|
4264
|
-
|
|
4591
|
+
// `undefined` = "not recorded yet", `null` = "recorded, the overview is selected".
|
|
4592
|
+
// The distinction matters: a remount restores `revealed` BEFORE the station list
|
|
4593
|
+
// arrives, and writing `null` at that moment froze the pin as "nothing selected"
|
|
4594
|
+
// for good — the next page load then kept the INDEX and showed a different record
|
|
4595
|
+
// (measured: T6 → T3 after a remount onto an empty first frame).
|
|
4596
|
+
const selectedIdRef = (0, react.useRef)(void 0);
|
|
4265
4597
|
const stationsSignature = (0, react.useMemo)(() => stations.map((st) => st.id).join("\u0000"), [stations]);
|
|
4266
4598
|
// Read the station from the list directly: `activeStation` is declared further
|
|
4267
4599
|
// down, and touching a `const` before its declaration throws ReferenceError on
|
|
@@ -4271,20 +4603,45 @@ window.__ModuleLoader__.load({
|
|
|
4271
4603
|
// backwards page (same position, different station) and OVERWROTE the pinned
|
|
4272
4604
|
// id with whatever now sat at that index, so the repair effect then "confirmed"
|
|
4273
4605
|
// the wrong station. Verified live: e29532 became e28913 after loading history.
|
|
4274
|
-
|
|
4606
|
+
// Seeded with a SENTINEL, not with `revealed`. On a remount the view restores a
|
|
4607
|
+
// selection from storage, so initialising with the restored number made the first
|
|
4608
|
+
// effect run look like "nothing changed" and `selectedIdRef` was never written. The
|
|
4609
|
+
// pin-by-id repair then had nothing to work with, and the first page load after a
|
|
4610
|
+
// remount kept the INDEX instead of the station: measured "6 / 10 用户 T6" became
|
|
4611
|
+
// "6 / 13 用户 T3" once three older stations were prepended.
|
|
4612
|
+
const prevRevealedRef = (0, react.useRef)(void 0);
|
|
4613
|
+
// "The reader is at the LIVE TIP" — recorded when the SELECTION changes, using the
|
|
4614
|
+
// station count at that moment. Follow mode used to scroll only in the overview
|
|
4615
|
+
// (`revealed === null`), so with a station selected a newly streamed record stayed
|
|
4616
|
+
// off-screen even though 跟随 was on: measured 13 stations, station 13 selected,
|
|
4617
|
+
// a 14th arrives, `scrollLeft` unchanged and the new card 268 px past the right
|
|
4618
|
+
// edge. Appending a station must not clear this flag; only a deliberate jump to an
|
|
4619
|
+
// older record does.
|
|
4620
|
+
const followTipRef = (0, react.useRef)(true);
|
|
4275
4621
|
(0, react.useEffect)(() => {
|
|
4276
4622
|
const selectionChanged = prevRevealedRef.current !== revealed;
|
|
4277
4623
|
prevRevealedRef.current = revealed;
|
|
4278
|
-
|
|
4624
|
+
// Re-run when the COUNT changes too: a restored selection can arrive before the
|
|
4625
|
+
// station list does, and without this the pin stayed unrecorded for ever.
|
|
4626
|
+
// Paging is still safe — once an id is recorded, `!changed` bails out below.
|
|
4627
|
+
if (!selectionChanged && selectedIdRef.current !== void 0) return;
|
|
4628
|
+
followTipRef.current = revealed === null
|
|
4629
|
+
|| revealed >= stationsRef.current.length;
|
|
4630
|
+
if (revealed === null) { selectedIdRef.current = null; return; }
|
|
4631
|
+
// No stations yet: leave the pin UNRECORDED rather than recording "nothing",
|
|
4632
|
+
// so the arrival of the list can still fill it in.
|
|
4633
|
+
if (stationsRef.current.length === 0) return;
|
|
4279
4634
|
selectedIdRef.current = revealed === null ? null
|
|
4280
4635
|
: (stationsRef.current[Math.min(stationsRef.current.length - 1, Math.max(0, revealed - 1))]?.id ?? null);
|
|
4281
4636
|
// stationsRef is intentionally read through the ref: depending on `stations`
|
|
4282
4637
|
// here would re-fire on paging, which is the bug being fixed.
|
|
4283
4638
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4284
|
-
}, [revealed]);
|
|
4639
|
+
}, [revealed, N]);
|
|
4285
4640
|
(0, react.useEffect)(() => {
|
|
4286
4641
|
const id = selectedIdRef.current;
|
|
4287
|
-
|
|
4642
|
+
// `void 0` means the pin has not been recorded yet (data was not ready); do not
|
|
4643
|
+
// treat that as "the overview is selected".
|
|
4644
|
+
if (id === null || id === void 0) return;
|
|
4288
4645
|
const at = stations.findIndex((st) => st.id === id);
|
|
4289
4646
|
// Gone from the window (should not happen for a prepend) or already correct.
|
|
4290
4647
|
if (at < 0 || at + 1 === revealed) return;
|
|
@@ -4411,6 +4768,12 @@ window.__ModuleLoader__.load({
|
|
|
4411
4768
|
// scrolling to the top. Bail out on any modifier combination.
|
|
4412
4769
|
if (ev.ctrlKey === true || ev.metaKey === true || ev.altKey === true) return;
|
|
4413
4770
|
const tag = ev.target && ev.target.tagName ? String(ev.target.tagName).toLowerCase() : "";
|
|
4771
|
+
// Bail out when the key belongs to a text field. HONEST STATUS: with today's markup
|
|
4772
|
+
// this branch is UNREACHABLE — every input inside the panel (search, anchor) has its
|
|
4773
|
+
// own onKeyDown that calls stopPropagation for every key, so nothing arrives here from
|
|
4774
|
+
// a field. It is kept as a guard for the next field someone adds, and the probe
|
|
4775
|
+
// assertion ("End inside the anchor box does not clear the selection") therefore
|
|
4776
|
+
// cannot be made to fail by deleting this line; do not mistake it for coverage.
|
|
4414
4777
|
if (tag === "input" || tag === "textarea" || tag === "select" || (ev.target && ev.target.isContentEditable === true)) return;
|
|
4415
4778
|
if (k === "/" || k === "f") {
|
|
4416
4779
|
if (searchRef.current !== null && typeof searchRef.current.focus === "function") { searchRef.current.focus(); ev.preventDefault(); }
|
|
@@ -4588,7 +4951,12 @@ window.__ModuleLoader__.load({
|
|
|
4588
4951
|
type: "search",
|
|
4589
4952
|
autoComplete: "off",
|
|
4590
4953
|
"aria-label": t("search.label"),
|
|
4591
|
-
|
|
4954
|
+
// Bind the RAW text, not the trimmed match string. Rendering the
|
|
4955
|
+
// trimmed value made a controlled input swallow the space the user
|
|
4956
|
+
// had just typed: "alpha␣" was re-rendered as "alpha", so the next
|
|
4957
|
+
// word ran into it ("alphabeta") and a phrase search could never be
|
|
4958
|
+
// typed one key at a time. Matching still uses `query` (trimmed).
|
|
4959
|
+
value: queryRaw,
|
|
4592
4960
|
placeholder: t("action.search"),
|
|
4593
4961
|
onChange: (ev) => setQueryRaw(ev.target != null ? ev.target.value : ""),
|
|
4594
4962
|
onKeyDown: onSearchKey
|
|
@@ -4764,7 +5132,12 @@ window.__ModuleLoader__.load({
|
|
|
4764
5132
|
// stats.toolMs`), not by this station's own maximum. Mixing only the station
|
|
4765
5133
|
// fields meant every cached bar kept its old width when a DIFFERENT station
|
|
4766
5134
|
// became the slowest one — a stale proportion bar, caught by review.
|
|
4767
|
-
|
|
5135
|
+
// Hash the EFFECTIVE denominator, not both inputs. `stats.toolMs` is only a
|
|
5136
|
+
// fallback for a zero max, but hashing it made every card depend on the SUM of
|
|
5137
|
+
// all tool durations: one slow tool changed the total, so a 900-station window
|
|
5138
|
+
// rebuilt all 900 cards to widen a single bar. Measured by the perf review:
|
|
5139
|
+
// 900 rebuilds -> 1 with the effective denominator.
|
|
5140
|
+
mix(Math.max(1, stats.maxToolMs || stats.toolMs));
|
|
4768
5141
|
mix(s.outcomeText); mix(s.outcomeKind);
|
|
4769
5142
|
if (Array.isArray(s.meta)) { mix(s.meta.length); for (const m of s.meta) mix(m); }
|
|
4770
5143
|
else mix(s.meta);
|
|
@@ -4782,8 +5155,63 @@ window.__ModuleLoader__.load({
|
|
|
4782
5155
|
mix(c.durationMs); mix(c.isError === true); mix(c.running === true);
|
|
4783
5156
|
}
|
|
4784
5157
|
} else mix(-1);
|
|
4785
|
-
|
|
5158
|
+
// The hash alone is not enough: FNV-1a is 32-bit and `mix` folds a number into
|
|
5159
|
+
// 64 bits of state, so two REAL inputs can land on the same value. Measured by
|
|
5160
|
+
// review: seq-identical user stations at time 1700000000000 and 1704294967296
|
|
5161
|
+
// produced the same signature, and the cached card kept 06:13:20 while the
|
|
5162
|
+
// minimap tick (whose signature carries `fmtClock`) had already moved to 23:16:07.
|
|
5163
|
+
// Appending the RENDERED text of the two derived values the card shows gives a
|
|
5164
|
+
// second, non-hash channel — a collision now has to happen in both.
|
|
5165
|
+
//
|
|
5166
|
+
// `s.turn` was missing entirely: a station re-projected from turn 1 to turn 2
|
|
5167
|
+
// kept an aria-label reading "轮次 1" while the projection said 2.
|
|
5168
|
+
return h.toString(36)
|
|
5169
|
+
+ "\u0002" + fmtClock(s.time)
|
|
5170
|
+
+ "\u0002" + (s.turn === null || s.turn === void 0 ? "" : String(s.turn));
|
|
4786
5171
|
};
|
|
5172
|
+
/**
|
|
5173
|
+
* Sub-calls can nest (a tool that itself calls tools). The detail panel rendered
|
|
5174
|
+
* ONE level: everything from `sub.subCalls` down was invisible, while both the
|
|
5175
|
+
* single-step copy and the whole-trace export printed the whole chain — so the
|
|
5176
|
+
* screen showed strictly less than the file you could copy from it.
|
|
5177
|
+
*
|
|
5178
|
+
* Recursive now. `depth` only feeds the React key and a data attribute; there is
|
|
5179
|
+
* no visual indentation budget to blow.
|
|
5180
|
+
*/
|
|
5181
|
+
const renderSubCalls = (subs, depth) => subs.map((sub, i) => {
|
|
5182
|
+
const subPretty = prettyArgs(sub.argsRaw);
|
|
5183
|
+
const nested = Array.isArray(sub.subCalls) ? sub.subCalls : [];
|
|
5184
|
+
return jsxs("div", {
|
|
5185
|
+
className: "dstv_subCard",
|
|
5186
|
+
"data-depth": depth > 0 ? String(depth) : undefined,
|
|
5187
|
+
children: [
|
|
5188
|
+
jsxs("span", {
|
|
5189
|
+
className: "dstv_subHead",
|
|
5190
|
+
children: [
|
|
5191
|
+
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"),
|
|
5192
|
+
jsx("span", { className: "tname", children: `${depth > 0 ? "↳↳" : "↳"} ${sub.name}` }, "sName"),
|
|
5193
|
+
jsx("span", { className: "dstv_chips", children: [
|
|
5194
|
+
sub.running ? jsx("span", { className: "dstv_chip run", children: t("chip.running") }, "sRun") : null,
|
|
5195
|
+
sub.isError ? jsx("span", { className: "dstv_chip err", children: sub.errorName != null ? String(sub.errorName) : t("chip.error") }, "sErr") : null,
|
|
5196
|
+
sub.durationMs != null ? jsx("span", { className: "dstv_chip", children: fmtMs(sub.durationMs) }, "sDur") : null
|
|
5197
|
+
] }, "sChips")
|
|
5198
|
+
]
|
|
5199
|
+
}, "sHead"),
|
|
5200
|
+
sub.argsRaw !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
|
|
5201
|
+
jsx("summary", { children: [t("detail.args"), jsx("span", { className: "sub", children: `${sub.argsRaw.length}${t("detail.chars")}` }, "sALen")] }, "sASum"),
|
|
5202
|
+
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", children: subPretty !== "" ? subPretty : t("detail.noArgs") }, "sACode") }, "sAInner")
|
|
5203
|
+
] }, "sArgs") : null,
|
|
5204
|
+
sub.resultText !== "" ? jsxs("details", { className: "dstv_det", open: sub.isError, children: [
|
|
5205
|
+
jsx("summary", { children: [sub.isError ? `✗ ${t("detail.result")}` : `✓ ${t("detail.result")}`, jsx("span", { className: "sub", children: String(sub.resultText.length) }, "sRLen")] }, "sRSum"),
|
|
5206
|
+
jsx("div", { className: "inner", children: jsxs("div", { children: [
|
|
5207
|
+
jsx(CopyBtn, { text: sub.resultText, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "sResCopy"),
|
|
5208
|
+
jsx("div", { className: "dstv_code", style: { marginTop: 4 }, children: sub.resultText }, "sResCode")
|
|
5209
|
+
] }) }, "sRInner")
|
|
5210
|
+
] }, "sRes") : null,
|
|
5211
|
+
nested.length > 0 ? jsx("div", { className: "dstv_subKids", children: renderSubCalls(nested, depth + 1) }, "sKids") : null
|
|
5212
|
+
]
|
|
5213
|
+
}, `ts${depth}-${i}`);
|
|
5214
|
+
});
|
|
4787
5215
|
const renderStationCard = (s, cardKey) => {
|
|
4788
5216
|
if (s.kind === "user") {
|
|
4789
5217
|
return jsxs("div", {
|
|
@@ -4791,7 +5219,7 @@ window.__ModuleLoader__.load({
|
|
|
4791
5219
|
children: [
|
|
4792
5220
|
jsx("span", { className: "dstv_name", children: s.who }, "uName"),
|
|
4793
5221
|
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")
|
|
5222
|
+
jsx("div", { className: "dstv_text dstv_clamp3", title: cardTitle(s.text), children: cardText(s.text) || "…" }, "uText")
|
|
4795
5223
|
]
|
|
4796
5224
|
}, cardKey);
|
|
4797
5225
|
}
|
|
@@ -4829,8 +5257,8 @@ window.__ModuleLoader__.load({
|
|
|
4829
5257
|
className: "dstv_cellRow",
|
|
4830
5258
|
children: [
|
|
4831
5259
|
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
|
|
5260
|
+
cell.thinking !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(cell.thinking), children: `💭 ${cardText(markdownToPlain(cardText(cell.thinking)))}` }, "aThink") : null,
|
|
5261
|
+
cell.text !== "" ? jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(cell.text), children: cardText(markdownToPlain(cardText(cell.text))) }, "aText") : null
|
|
4834
5262
|
]
|
|
4835
5263
|
}, `a${cell.id}`);
|
|
4836
5264
|
}
|
|
@@ -4869,12 +5297,20 @@ window.__ModuleLoader__.load({
|
|
|
4869
5297
|
className: "dstv_name",
|
|
4870
5298
|
children: [
|
|
4871
5299
|
jsx("span", { className: s.isError ? "dstv_bad" : "dstv_ok", children: s.isError ? "✗" : "⤷" }, "oIcon"),
|
|
4872
|
-
|
|
4873
|
-
|
|
5300
|
+
// A compaction REPLAY is a different thing from "the call is outside
|
|
5301
|
+
// the window": the call is right there and was already answered.
|
|
5302
|
+
// Saying the call is missing sends the reader looking for a bug.
|
|
5303
|
+
`${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}`,
|
|
5304
|
+
jsx("span", {
|
|
5305
|
+
className: "dstv_chips",
|
|
5306
|
+
children: [jsx("span", { className: "dstv_chip info", children: s.replayOf !== null && s.replayOf !== void 0
|
|
5307
|
+
? t("orphan.replayBadge").replace("{seq}", String(s.replayOf))
|
|
5308
|
+
: t("orphan.badge") }, "oBadge")]
|
|
5309
|
+
}, "oChips")
|
|
4874
5310
|
]
|
|
4875
5311
|
}, "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")
|
|
5312
|
+
s.args !== "" ? jsx("div", { className: "dstv_text dstv_clamp2 sec", title: cardTitle(s.args), children: cardText(s.args) }, "oArgs") : null,
|
|
5313
|
+
jsx("div", { className: "dstv_text dstv_clamp4", title: cardTitle(body), children: cardText(body) }, "oText")
|
|
4878
5314
|
]
|
|
4879
5315
|
}, cardKey);
|
|
4880
5316
|
}
|
|
@@ -4883,7 +5319,7 @@ window.__ModuleLoader__.load({
|
|
|
4883
5319
|
className: "dstv_hcard compactionCard",
|
|
4884
5320
|
children: [
|
|
4885
5321
|
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")
|
|
5322
|
+
jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.summary), children: cardText(s.summary) || "…" }, "cText")
|
|
4887
5323
|
]
|
|
4888
5324
|
}, cardKey);
|
|
4889
5325
|
}
|
|
@@ -4892,7 +5328,7 @@ window.__ModuleLoader__.load({
|
|
|
4892
5328
|
className: "dstv_hcard errorCard",
|
|
4893
5329
|
children: [
|
|
4894
5330
|
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")
|
|
5331
|
+
jsx("div", { className: "dstv_text dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "eText")
|
|
4896
5332
|
]
|
|
4897
5333
|
}, cardKey);
|
|
4898
5334
|
}
|
|
@@ -4901,7 +5337,7 @@ window.__ModuleLoader__.load({
|
|
|
4901
5337
|
className: "dstv_hcard retryCard",
|
|
4902
5338
|
children: [
|
|
4903
5339
|
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")
|
|
5340
|
+
jsx("div", { className: "dstv_text sec dstv_clamp2", title: cardTitle(s.message), children: cardText(s.message) || "…" }, "rText")
|
|
4905
5341
|
]
|
|
4906
5342
|
}, cardKey);
|
|
4907
5343
|
}
|
|
@@ -4920,7 +5356,7 @@ window.__ModuleLoader__.load({
|
|
|
4920
5356
|
`${t("node.unknown")}${s.eventType !== "" ? ` · ${s.eventType}` : ""}`,
|
|
4921
5357
|
jsx("span", { className: "dstv_chips", children: jsx("span", { className: "dstv_chip", children: `seq ${s.seq}` }, "ukSeq") }, "ukChips")
|
|
4922
5358
|
] }, "ukName"),
|
|
4923
|
-
s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: s.payload, children: s.payload }, "ukText") : null
|
|
5359
|
+
s.payload !== "" ? jsx("div", { className: "dstv_text sec dstv_clamp3", title: cardTitle(s.payload), children: cardText(s.payload) }, "ukText") : null
|
|
4924
5360
|
]
|
|
4925
5361
|
}, cardKey);
|
|
4926
5362
|
}
|
|
@@ -4958,6 +5394,15 @@ window.__ModuleLoader__.load({
|
|
|
4958
5394
|
if (s.kind === "maxTokens") k = "error";
|
|
4959
5395
|
const done = reached && (s.kind !== "step" || !s.live);
|
|
4960
5396
|
const matched = searching && matchSet.has(i);
|
|
5397
|
+
// Two DIFFERENT derived values, and the signature must hash each one.
|
|
5398
|
+
// `data-active` is `revealed !== null && i === R - 1`; the tab stop is that
|
|
5399
|
+
// OR the overview's first tick. Hashing only the tab stop made the two states
|
|
5400
|
+
// collide at i == 0: overview gives tab=1/active=0, selecting the first
|
|
5401
|
+
// station gives tab=1/active=1, so the cached tick kept `data-active`
|
|
5402
|
+
// undefined and the strip highlighted nothing (measured: three stations,
|
|
5403
|
+
// overview, click tick 0 → cards show selection 0, minimap active set []).
|
|
5404
|
+
const tickActive = revealed !== null && i === R - 1;
|
|
5405
|
+
const tickTab = tickActive || (revealed === null && i === 0);
|
|
4961
5406
|
// Same element-identity trick as the station cards: an unchanged tick keeps
|
|
4962
5407
|
// its element and React skips it (§13.72).
|
|
4963
5408
|
const tickSig = s.kind + "\u0002" + String(i) + "\u0002" + (reached ? "1" : "0")
|
|
@@ -4971,7 +5416,8 @@ window.__ModuleLoader__.load({
|
|
|
4971
5416
|
// overview half (`revealed === null && i === 0`). Hashing only the active
|
|
4972
5417
|
// half left tick 0 with `tabIndex: 0` after any selection, so the strip had
|
|
4973
5418
|
// TWO tab stops (measured: [0, 5] after selecting station 5).
|
|
4974
|
-
+ "\u0002" + (
|
|
5419
|
+
+ "\u0002" + (tickTab ? "1" : "0")
|
|
5420
|
+
+ "\u0002" + (tickActive ? "1" : "0")
|
|
4975
5421
|
// `data-k` reads the DERIVED kind, which is "tool" for a step that contains
|
|
4976
5422
|
// one — hash the value actually used rather than re-deriving it here.
|
|
4977
5423
|
+ "\u0002" + k
|
|
@@ -4986,7 +5432,7 @@ window.__ModuleLoader__.load({
|
|
|
4986
5432
|
"data-k": k,
|
|
4987
5433
|
"data-done": done ? "true" : undefined,
|
|
4988
5434
|
"data-dim": reached ? undefined : "true",
|
|
4989
|
-
"data-active":
|
|
5435
|
+
"data-active": tickActive ? "true" : undefined,
|
|
4990
5436
|
"data-live": s.kind === "step" && s.live === true ? "true" : undefined,
|
|
4991
5437
|
"data-match": matched ? "true" : undefined,
|
|
4992
5438
|
// Roving tabindex, same as the station list. This strip is a SECOND
|
|
@@ -4997,7 +5443,7 @@ window.__ModuleLoader__.load({
|
|
|
4997
5443
|
// ...but exactly one tick must stay reachable, or the whole strip
|
|
4998
5444
|
// disappears from the keyboard in the overview state. Same rule as
|
|
4999
5445
|
// the station list: the active one, else the first.
|
|
5000
|
-
tabIndex:
|
|
5446
|
+
tabIndex: tickTab ? 0 : -1,
|
|
5001
5447
|
// `s.label` is undefined for user stations, so the tooltip read
|
|
5002
5448
|
// "undefined · 6:13:20 AM" and the button had no accessible name at
|
|
5003
5449
|
// all. Fall back to the kind and always expose aria-label.
|
|
@@ -5216,7 +5662,7 @@ window.__ModuleLoader__.load({
|
|
|
5216
5662
|
if (s.kind === "orphan-tool") {
|
|
5217
5663
|
const body = s.displayText !== "" ? s.displayText : t("orphan.noText");
|
|
5218
5664
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
5219
|
-
jsx("span", { className: "dstv_dLabel", children: `${t("node.orphanTool")} · ${s.name}` }, "oLbl"),
|
|
5665
|
+
jsx("span", { className: "dstv_dLabel", children: `${t(s.replayOf !== null && s.replayOf !== void 0 ? "node.replayedTool" : "node.orphanTool")} · ${s.name}` }, "oLbl"),
|
|
5220
5666
|
jsx("div", { className: "dstv_dSection", children: [
|
|
5221
5667
|
jsx("span", { className: "dstv_chip info", children: t("orphan.badge") }, "oBadge"),
|
|
5222
5668
|
jsx("span", { className: "dstv_chip", children: `callId ${s.callId}` }, "oCid")
|
|
@@ -5289,40 +5735,10 @@ window.__ModuleLoader__.load({
|
|
|
5289
5735
|
] }, `dr${cell.id}`) : null,
|
|
5290
5736
|
cell.resultText === "" && !cell.isError && !cell.running ? jsx("span", { className: "dstv_dLabel sec", children: t("detail.noResult") }, "tNoRes") : null,
|
|
5291
5737
|
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"),
|
|
5738
|
+
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
5739
|
jsx("div", {
|
|
5294
5740
|
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
|
-
})
|
|
5741
|
+
children: renderSubCalls(cell.subCalls, 0)
|
|
5326
5742
|
}, "tSubInner")
|
|
5327
5743
|
] }, `ds${cell.id}`) : null
|
|
5328
5744
|
] }, `dt${cell.id}`);
|
|
@@ -5422,6 +5838,12 @@ window.__ModuleLoader__.load({
|
|
|
5422
5838
|
// fields can be drifted. Normalise ONCE here — every reader below
|
|
5423
5839
|
// (`tools.map`, the JSON previews, the React keys) then sees a safe shape.
|
|
5424
5840
|
const tools = safeToolList(req.prompt?.tools);
|
|
5841
|
+
// The contract says `prompt.system` is EMPTY when the system node sits outside the
|
|
5842
|
+
// loaded window; the snapshot still carries it (`systemFrom`, filled by the fold).
|
|
5843
|
+
// Showing "0 chars" there was a silent lie about what the model saw.
|
|
5844
|
+
const savedPrompt = req.systemFrom !== null && req.systemFrom !== void 0 ? req.systemFrom : null;
|
|
5845
|
+
const systemText = (req.prompt?.system ?? "") !== "" ? req.prompt.system
|
|
5846
|
+
: (savedPrompt !== null ? String(savedPrompt.text ?? "") : "");
|
|
5425
5847
|
const diff = req.promptDiff ?? null;
|
|
5426
5848
|
const evidenceChips = evidenceOf(req, activeMessages, hasMore);
|
|
5427
5849
|
|
|
@@ -5432,7 +5854,7 @@ window.__ModuleLoader__.load({
|
|
|
5432
5854
|
temperature: cfg.temperature,
|
|
5433
5855
|
reasoningEffort: cfg.reasoningEffort,
|
|
5434
5856
|
maxTokens: cfg.maxTokens,
|
|
5435
|
-
system:
|
|
5857
|
+
system: systemText,
|
|
5436
5858
|
tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })),
|
|
5437
5859
|
messages: messages.map((m) => m.role === "note"
|
|
5438
5860
|
? { role: "user", content: [{ type: "text", text: m.text }] }
|
|
@@ -5446,7 +5868,7 @@ window.__ModuleLoader__.load({
|
|
|
5446
5868
|
// else; the request tab was the only place that called JSON directly.
|
|
5447
5869
|
const payloadJson = safeJsonPreview(payload, Number.MAX_SAFE_INTEGER, 2);
|
|
5448
5870
|
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:
|
|
5871
|
+
const sysJson = safeJsonPreview({ system: systemText, tools: tools.map((tool) => ({ name: tool.name, description: tool.description, parameters: tool.parameters })) }, Number.MAX_SAFE_INTEGER, 2);
|
|
5450
5872
|
|
|
5451
5873
|
return jsxs("div", { className: "dstv_dBody", children: [
|
|
5452
5874
|
// config + lifecycle chips
|
|
@@ -5499,13 +5921,14 @@ window.__ModuleLoader__.load({
|
|
|
5499
5921
|
req.prompt !== null ? jsxs("div", { className: "dstv_dSection", children: [
|
|
5500
5922
|
jsxs("div", { className: "dstv_dSecHead", children: [
|
|
5501
5923
|
jsx("span", { children: `🧠 ${t("detail.systemPrompt")}` }, "spHead"),
|
|
5502
|
-
jsx("span", { className: "sub", children: `${fmtInt(
|
|
5924
|
+
jsx("span", { className: "sub", children: `${fmtInt(systemText.length)} ${t("detail.chars")}` }, "spLen"),
|
|
5925
|
+
savedPrompt !== null ? jsx("span", { className: "sub", children: t("detail.systemOutside").replace("{seq}", String(savedPrompt.seq)) }, "spOut") : null,
|
|
5503
5926
|
jsx("span", { className: "grow" }, "spGrow"),
|
|
5504
5927
|
jsx(CopyBtn, { text: sysJson, label: t("detail.copy"), okLabel: t("detail.copied"), failLabel: t("anchor.copyFailed") }, "spCopy")
|
|
5505
5928
|
] }, "spSecHead"),
|
|
5506
5929
|
jsxs("details", { className: "dstv_det", open: false, children: [
|
|
5507
5930
|
jsx("summary", { children: [t("detail.systemPrompt")] }, "spSum"),
|
|
5508
|
-
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children:
|
|
5931
|
+
jsx("div", { className: "inner", children: jsx("div", { className: "dstv_code", style: { maxHeight: 220 }, children: systemText !== "" ? systemText : t("detail.systemNone") }, "spCode") }, "spInner")
|
|
5509
5932
|
] }, "spDet")
|
|
5510
5933
|
] }, "spSec") : null,
|
|
5511
5934
|
// tool catalog
|
|
@@ -5644,7 +6067,18 @@ window.__ModuleLoader__.load({
|
|
|
5644
6067
|
okLabel: t("anchor.copied"),
|
|
5645
6068
|
failLabel: t("anchor.copyFailed")
|
|
5646
6069
|
}, "dExportStep"),
|
|
5647
|
-
jsx("button", {
|
|
6070
|
+
jsx("button", {
|
|
6071
|
+
type: "button",
|
|
6072
|
+
className: "dstv_btn dstv_panelToggle",
|
|
6073
|
+
title: panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
|
|
6074
|
+
// A glyph is not a name. Chromium's AX tree announced this control as
|
|
6075
|
+
// "button, ⤢" — the arrow is a picture, and a screen reader user had
|
|
6076
|
+
// to guess what it does. The title alone is a tooltip, not a name.
|
|
6077
|
+
"aria-label": panelFull ? t("action.collapsePanel") : t("action.expandPanel"),
|
|
6078
|
+
"aria-expanded": panelFull ? "true" : "false",
|
|
6079
|
+
onClick: () => setPanelFull((v) => !v),
|
|
6080
|
+
children: panelFull ? "⤡" : "⤢"
|
|
6081
|
+
}, "dToggle")
|
|
5648
6082
|
]
|
|
5649
6083
|
}, "dHead"),
|
|
5650
6084
|
// The key must include WHAT is being rendered, not just where. An error
|
|
@@ -5672,7 +6106,7 @@ window.__ModuleLoader__.load({
|
|
|
5672
6106
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.turns) }, "kvNum"), jsx("span", { children: t("node.turn") }, "kvLbl")] }, "kTurns"),
|
|
5673
6107
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: String(stats.steps) }, "kvNum"), jsx("span", { children: t("node.step") }, "kvLbl")] }, "kSteps"),
|
|
5674
6108
|
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.
|
|
6109
|
+
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
6110
|
jsxs("span", { className: "dstv_kpi", children: [jsx("b", { children: fmtDur(stats.toolMs) }, "kvNum"), jsx("span", { children: t("kpi.toolTime") }, "kvLbl")] }, "kDur"),
|
|
5677
6111
|
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
6112
|
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,
|