@tanzz/dsh-explore 0.1.0 → 0.3.0
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/README.md +145 -96
- package/README.zh-CN.md +200 -0
- package/client.js +2821 -299
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -23,15 +23,21 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
ink: 'var(--dsw-alias-label-primary)',
|
|
24
24
|
ink2: 'var(--dsw-alias-label-secondary)',
|
|
25
25
|
ink3: 'var(--dsw-alias-label-secondary)',
|
|
26
|
+
// Reasoning reads as a footnote to the answer, so it sits one step
|
|
27
|
+
// quieter than the body text.
|
|
28
|
+
ink4: 'var(--dsw-alias-label-tertiary)',
|
|
26
29
|
line: 'var(--dsw-alias-border-l2)',
|
|
27
30
|
card: 'var(--dsw-alias-bg-layer-1)',
|
|
31
|
+
// Floating surfaces (menus) take the overlay level: on a dark theme a
|
|
32
|
+
// menu painted with the card colour would disappear into the card under
|
|
33
|
+
// it, and this is the level the host reserves for exactly that case.
|
|
34
|
+
overlay: 'var(--dsw-alias-bg-overlay)',
|
|
28
35
|
cardEdge: 'var(--dsw-alias-border-l1)',
|
|
29
36
|
canvas: 'var(--dsw-alias-bg-base)',
|
|
30
37
|
code: 'var(--dsw-alias-markdown-code-block)',
|
|
31
38
|
// A `label-primary` tint keeps the chip visible on a white card (the
|
|
32
39
|
// markdown inline-code token is nearly white in the light theme).
|
|
33
40
|
codeInline: 'color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent)',
|
|
34
|
-
scrim: 'var(--dsw-alias-bg-mask-1)',
|
|
35
41
|
warn: 'var(--dsw-alias-state-error-primary)',
|
|
36
42
|
ok: 'var(--dsw-alias-state-success-primary)',
|
|
37
43
|
};
|
|
@@ -39,6 +45,110 @@ window.__ModuleLoader__.load({
|
|
|
39
45
|
const NODE_H = 212;
|
|
40
46
|
const GAP_X = 44;
|
|
41
47
|
const GAP_Y = 76;
|
|
48
|
+
const LAYOUT_DIRECTION_KEY = 'dsh-explore:layout-direction';
|
|
49
|
+
|
|
50
|
+
function readLayoutDirection() {
|
|
51
|
+
try {
|
|
52
|
+
return window.localStorage.getItem(LAYOUT_DIRECTION_KEY) === 'horizontal' ? 'horizontal' : 'vertical';
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return 'vertical';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function saveLayoutDirection(direction) {
|
|
59
|
+
try {
|
|
60
|
+
window.localStorage.setItem(LAYOUT_DIRECTION_KEY, direction);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
/* Layout remains available for this view when storage is blocked. */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Card display presets. A card is the overview; the reader is the close-up.
|
|
67
|
+
// These three sizes decide how much of that overview is text: the card
|
|
68
|
+
// width and, with it, how many lines of the answer the preview shows.
|
|
69
|
+
// `maskAt` is the length at which the bottom fade starts (it exists to hide
|
|
70
|
+
// the cut, not to report overflow) and `truncate` bounds how much Markdown
|
|
71
|
+
// the card parses — the reader always renders the whole answer.
|
|
72
|
+
const CARD_SIZE_KEY = 'dsh-explore:card-size';
|
|
73
|
+
const CARD_SIZES = {
|
|
74
|
+
compact: { width: 288, preview: 112, maskAt: 240, truncate: 900 },
|
|
75
|
+
standard: { width: NODE_W, preview: 146, maskAt: 320, truncate: 1400 },
|
|
76
|
+
roomy: { width: 448, preview: 264, maskAt: 640, truncate: 3200 },
|
|
77
|
+
};
|
|
78
|
+
const CARD_SIZE_ORDER = ['compact', 'standard', 'roomy'];
|
|
79
|
+
const CARD_SIZE_LABELS = {
|
|
80
|
+
compact: 'view.cardSizeCompact',
|
|
81
|
+
standard: 'view.cardSizeStandard',
|
|
82
|
+
roomy: 'view.cardSizeRoomy',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function readCardSize() {
|
|
86
|
+
try {
|
|
87
|
+
const stored = window.localStorage.getItem(CARD_SIZE_KEY);
|
|
88
|
+
return stored && Object.prototype.hasOwnProperty.call(CARD_SIZES, stored) ? stored : 'standard';
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return 'standard';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function saveCardSize(size) {
|
|
95
|
+
try {
|
|
96
|
+
window.localStorage.setItem(CARD_SIZE_KEY, size);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
/* The presets still work for this view when storage is blocked. */
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// The reader's width is a separate preference: reading a long answer wants
|
|
103
|
+
// more line length than the canvas overview does, and the right width
|
|
104
|
+
// depends on the screen and on the text. Two presets cover both cases.
|
|
105
|
+
const READER_WIDTH_KEY = 'dsh-explore:reader-width';
|
|
106
|
+
const READER_WIDTHS = {
|
|
107
|
+
standard: 'min(820px, calc(100vw - 68px))',
|
|
108
|
+
wide: 'min(1200px, calc(100vw - 48px))',
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
function readReaderWidth() {
|
|
112
|
+
try {
|
|
113
|
+
return window.localStorage.getItem(READER_WIDTH_KEY) === 'wide' ? 'wide' : 'standard';
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return 'standard';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function saveReaderWidth(width) {
|
|
120
|
+
try {
|
|
121
|
+
window.localStorage.setItem(READER_WIDTH_KEY, width);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
/* Keep the current width for this view when storage is blocked. */
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Every branch is a real forked session, so it is a real row in the DSH
|
|
128
|
+
// workspace. Fork cannot create a child "subtask" row from a client plugin
|
|
129
|
+
// (only host subagent sessions get hidden/nested rows), so the only
|
|
130
|
+
// supported way to keep the workspace list quiet is the archive: the
|
|
131
|
+
// session stays readable and retainable, it just stops being listed and
|
|
132
|
+
// stops accepting prompts. This preference decides whether a branch that
|
|
133
|
+
// has finished its turn is put there; the toolbar can switch both ways.
|
|
134
|
+
const BRANCH_MODE_KEY = 'dsh-explore:branch-sessions';
|
|
135
|
+
|
|
136
|
+
function readBranchMode() {
|
|
137
|
+
try {
|
|
138
|
+
return window.localStorage.getItem(BRANCH_MODE_KEY) === 'quiet' ? 'quiet' : 'listed';
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return 'listed';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function saveBranchMode(mode) {
|
|
145
|
+
try {
|
|
146
|
+
window.localStorage.setItem(BRANCH_MODE_KEY, mode === 'quiet' ? 'quiet' : 'listed');
|
|
147
|
+
} catch (error) {
|
|
148
|
+
/* The choice still applies to this view when storage is blocked. */
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
42
152
|
// Font families follow Settings → Appearance. DSH composes the user's list
|
|
43
153
|
// with its own default stack on body (`--dsw-font-family` /
|
|
44
154
|
// `--ds-font-family-code`), so reading the composed tokens keeps glyph
|
|
@@ -72,17 +182,30 @@ window.__ModuleLoader__.load({
|
|
|
72
182
|
'view.zoomOut': '缩小画布',
|
|
73
183
|
'view.zoomIn': '放大画布',
|
|
74
184
|
'view.zoomLevel': '当前缩放比例',
|
|
185
|
+
'view.layoutGroup': '布局方向',
|
|
186
|
+
'view.layoutVertical': '上下布局',
|
|
187
|
+
'view.layoutHorizontal': '左右布局',
|
|
188
|
+
'view.layoutTitle': '切换左右布局和上下布局',
|
|
75
189
|
'view.fit': '适应画布',
|
|
76
190
|
'view.fitTitle': '缩放到能看见整棵树',
|
|
77
191
|
'view.latest': '定位最新',
|
|
78
192
|
'view.latestTitle': '展开路径并定位到最新创建的节点',
|
|
79
193
|
'view.latestTitleEmpty': '还没有节点',
|
|
194
|
+
'view.cardSizeGroup': '卡片信息量',
|
|
195
|
+
'view.cardSizeCompact': '紧凑',
|
|
196
|
+
'view.cardSizeStandard': '标准',
|
|
197
|
+
'view.cardSizeRoomy': '宽松',
|
|
198
|
+
'view.branchesShown': '分支记录:在工作区',
|
|
199
|
+
'view.branchesShownTitle': '把已完成的分支会话收进归档,工作区只留主会话',
|
|
200
|
+
'view.branchesQuiet': '分支记录:已归档',
|
|
201
|
+
'view.branchesQuietTitle': '把本树的分支会话恢复到工作区',
|
|
80
202
|
'view.empty.title': '这棵树还是空的',
|
|
81
203
|
'view.empty.hint': '回到 Chat 问一句,这里就会长出第一个节点。',
|
|
82
204
|
'view.empty.report': '若已经问过却是空的,把这一行告我:事件 {events} · 会话 {state}。',
|
|
83
205
|
|
|
84
206
|
'card.noQuestion': '(无问题)',
|
|
85
207
|
'card.questionReply': '(回答上一轮的提问)',
|
|
208
|
+
'card.imageAlt': '附图',
|
|
86
209
|
'card.latestBadge': '最新',
|
|
87
210
|
'card.latestTitle': '这是最新创建的节点',
|
|
88
211
|
'card.status.thinking': '思考中',
|
|
@@ -99,11 +222,6 @@ window.__ModuleLoader__.load({
|
|
|
99
222
|
'card.delete': '删除这个节点',
|
|
100
223
|
'card.deleteTitle': '隐藏这个节点和它下面的所有分支',
|
|
101
224
|
'card.deleteConfirm': '删除这个节点和它下面的所有分支?(随时可恢复)',
|
|
102
|
-
'card.readTitle': '点击全屏阅读',
|
|
103
|
-
'card.expandTitle': '展开整段回答',
|
|
104
|
-
'card.collapseTitle': '收起这段回答',
|
|
105
|
-
'card.expand': '展开回答',
|
|
106
|
-
'card.collapse': '收起回答',
|
|
107
225
|
'card.fullscreen': '全屏阅读',
|
|
108
226
|
'card.fullscreenTitle': '全屏阅读完整回答',
|
|
109
227
|
'card.unfoldBranch': '展开这一枝',
|
|
@@ -116,6 +234,10 @@ window.__ModuleLoader__.load({
|
|
|
116
234
|
'card.cost.context': '上下文 {value}',
|
|
117
235
|
'card.cost.cached': '缓存 {value}',
|
|
118
236
|
|
|
237
|
+
'card.think': '思考过程',
|
|
238
|
+
'card.thinkMeta': '{count} 字',
|
|
239
|
+
'card.thinkTruncated': '(只保留了最新的 {count} 字思考)',
|
|
240
|
+
|
|
119
241
|
'live.calling': '正在调用 {tool}',
|
|
120
242
|
'live.outputting': '正在输出…',
|
|
121
243
|
'live.thinking': '正在思考…',
|
|
@@ -136,6 +258,11 @@ window.__ModuleLoader__.load({
|
|
|
136
258
|
'reader.hint': 'Esc 关闭 · 点背景关闭',
|
|
137
259
|
'reader.branch': '分支',
|
|
138
260
|
'reader.mainline': '主线',
|
|
261
|
+
'reader.widthGroup': '阅读宽度',
|
|
262
|
+
'reader.paneGroup': '阅读内容',
|
|
263
|
+
'reader.paneAnswer': '最终结果',
|
|
264
|
+
'reader.widthStandard': '标准宽',
|
|
265
|
+
'reader.widthWide': '较宽',
|
|
139
266
|
|
|
140
267
|
'error.title': '树视图出错了',
|
|
141
268
|
'error.reload': '重新载入视图',
|
|
@@ -169,17 +296,30 @@ window.__ModuleLoader__.load({
|
|
|
169
296
|
'view.zoomOut': 'Zoom out',
|
|
170
297
|
'view.zoomIn': 'Zoom in',
|
|
171
298
|
'view.zoomLevel': 'Current zoom level',
|
|
299
|
+
'view.layoutGroup': 'Layout direction',
|
|
300
|
+
'view.layoutVertical': 'Top to bottom',
|
|
301
|
+
'view.layoutHorizontal': 'Left to right',
|
|
302
|
+
'view.layoutTitle': 'Switch between left-to-right and top-to-bottom layouts',
|
|
172
303
|
'view.fit': 'Fit canvas',
|
|
173
304
|
'view.fitTitle': 'Zoom out to show the whole tree',
|
|
174
305
|
'view.latest': 'Jump to latest',
|
|
175
306
|
'view.latestTitle': 'Expand the path and jump to the newest node',
|
|
176
307
|
'view.latestTitleEmpty': 'No nodes yet',
|
|
308
|
+
'view.cardSizeGroup': 'Card size',
|
|
309
|
+
'view.cardSizeCompact': 'Compact',
|
|
310
|
+
'view.cardSizeStandard': 'Standard',
|
|
311
|
+
'view.cardSizeRoomy': 'Roomy',
|
|
312
|
+
'view.branchesShown': 'Branch rows: in workspace',
|
|
313
|
+
'view.branchesShownTitle': 'Move finished branch sessions into the archive, leaving only the main session in the workspace',
|
|
314
|
+
'view.branchesQuiet': 'Branch rows: archived',
|
|
315
|
+
'view.branchesQuietTitle': 'Bring this tree\'s branch sessions back into the workspace',
|
|
177
316
|
'view.empty.title': 'This tree is still empty',
|
|
178
317
|
'view.empty.hint': 'Ask something in Chat and the first node will grow here.',
|
|
179
318
|
'view.empty.report': 'If you already asked and this is still empty, tell me: {events} events · session {state}.',
|
|
180
319
|
|
|
181
320
|
'card.noQuestion': '(no question)',
|
|
182
321
|
'card.questionReply': '(replying to the previous question)',
|
|
322
|
+
'card.imageAlt': 'Attached image',
|
|
183
323
|
'card.latestBadge': 'Latest',
|
|
184
324
|
'card.latestTitle': 'The newest node in this tree',
|
|
185
325
|
'card.status.thinking': 'Thinking',
|
|
@@ -196,11 +336,6 @@ window.__ModuleLoader__.load({
|
|
|
196
336
|
'card.delete': 'Delete this node',
|
|
197
337
|
'card.deleteTitle': 'Hide this node and every branch under it',
|
|
198
338
|
'card.deleteConfirm': 'Delete this node and all branches under it? (reversible)',
|
|
199
|
-
'card.readTitle': 'Click to read in full screen',
|
|
200
|
-
'card.expandTitle': 'Expand this answer',
|
|
201
|
-
'card.collapseTitle': 'Collapse this answer',
|
|
202
|
-
'card.expand': 'Expand answer',
|
|
203
|
-
'card.collapse': 'Collapse answer',
|
|
204
339
|
'card.fullscreen': 'Read full screen',
|
|
205
340
|
'card.fullscreenTitle': 'Read the complete answer in full screen',
|
|
206
341
|
'card.unfoldBranch': 'Expand this branch',
|
|
@@ -213,6 +348,10 @@ window.__ModuleLoader__.load({
|
|
|
213
348
|
'card.cost.context': 'context {value}',
|
|
214
349
|
'card.cost.cached': 'cached {value}',
|
|
215
350
|
|
|
351
|
+
'card.think': 'Reasoning',
|
|
352
|
+
'card.thinkMeta': '{count} chars',
|
|
353
|
+
'card.thinkTruncated': '(only the newest {count} chars of reasoning are kept)',
|
|
354
|
+
|
|
216
355
|
'live.calling': 'Calling {tool}',
|
|
217
356
|
'live.outputting': 'Writing…',
|
|
218
357
|
'live.thinking': 'Thinking…',
|
|
@@ -233,6 +372,11 @@ window.__ModuleLoader__.load({
|
|
|
233
372
|
'reader.hint': 'Esc or click the backdrop to close',
|
|
234
373
|
'reader.branch': 'Branch',
|
|
235
374
|
'reader.mainline': 'Main line',
|
|
375
|
+
'reader.widthGroup': 'Reading width',
|
|
376
|
+
'reader.paneGroup': 'Reading pane',
|
|
377
|
+
'reader.paneAnswer': 'Final answer',
|
|
378
|
+
'reader.widthStandard': 'Standard',
|
|
379
|
+
'reader.widthWide': 'Wider',
|
|
236
380
|
|
|
237
381
|
'error.title': 'The tree view crashed',
|
|
238
382
|
'error.reload': 'Reload the view',
|
|
@@ -248,17 +392,656 @@ window.__ModuleLoader__.load({
|
|
|
248
392
|
'error.submitFailed': 'Submit failed: {reason}',
|
|
249
393
|
'error.loadOlderFailed': 'Could not load earlier history: {reason}',
|
|
250
394
|
},
|
|
395
|
+
de: {
|
|
396
|
+
'view.tab': 'Endlose Erkundung',
|
|
397
|
+
'view.heading': 'Endlose Erkundung',
|
|
398
|
+
'view.nodes': '{count} Knoten',
|
|
399
|
+
'view.running': '{count} Zweige laufen',
|
|
400
|
+
'view.runningTitle': 'Zum nächsten laufenden Knoten springen',
|
|
401
|
+
'view.awaiting': '{count} warten auf dich',
|
|
402
|
+
'view.awaitingTitle': 'Zum Knoten springen, der auf dich wartet',
|
|
403
|
+
'view.loadOlder': 'Frühere laden',
|
|
404
|
+
'view.restoreHidden': '{count} ausgeblendet · Wiederherstellen',
|
|
405
|
+
'view.restoreHiddenTitle': 'Gelöschte Knoten und Zweige wiederherstellen',
|
|
406
|
+
'view.searchPlaceholder': 'Knoten suchen',
|
|
407
|
+
'view.searchLabel': 'Knoten suchen',
|
|
408
|
+
'view.zoomGroup': 'Leinwand-Zoom',
|
|
409
|
+
'view.zoomOut': 'Verkleinern',
|
|
410
|
+
'view.zoomIn': 'Vergrößern',
|
|
411
|
+
'view.zoomLevel': 'Aktuelle Zoomstufe',
|
|
412
|
+
'view.layoutHorizontal': 'Links nach rechts',
|
|
413
|
+
'view.layoutTitle': 'Zwischen Links-nach-rechts und Oben-nach-unten wechseln',
|
|
414
|
+
'view.fit': 'Leinwand einpassen',
|
|
415
|
+
'view.fitTitle': 'Herauszoomen, bis der ganze Baum sichtbar ist',
|
|
416
|
+
'view.latest': 'Zum Neuesten',
|
|
417
|
+
'view.latestTitle': 'Pfad ausklappen und zum neuesten Knoten springen',
|
|
418
|
+
'view.latestTitleEmpty': 'Noch keine Knoten',
|
|
419
|
+
'view.cardSizeGroup': 'Kartengröße',
|
|
420
|
+
'view.cardSizeCompact': 'Kompakt',
|
|
421
|
+
'view.cardSizeStandard': 'Standard',
|
|
422
|
+
'view.cardSizeRoomy': 'Geräumig',
|
|
423
|
+
'view.branchesShown': 'Zweigzeilen: im Arbeitsbereich',
|
|
424
|
+
'view.branchesShownTitle': 'Abgeschlossene Zweig-Sitzungen ins Archiv verschieben, sodass nur die Hauptsitzung im Arbeitsbereich bleibt',
|
|
425
|
+
'view.branchesQuiet': 'Zweigzeilen: archiviert',
|
|
426
|
+
'view.branchesQuietTitle': 'Die Zweig-Sitzungen dieses Baums zurück in den Arbeitsbereich holen',
|
|
427
|
+
'view.empty.title': 'Dieser Baum ist noch leer',
|
|
428
|
+
'view.empty.hint': 'Stelle im Chat eine Frage, dann wächst hier der erste Knoten.',
|
|
429
|
+
'view.empty.report': 'Wenn du schon gefragt hast und es hier noch leer ist, sag mir: {events} Ereignisse · Sitzung {state}.',
|
|
430
|
+
'card.noQuestion': '(keine Frage)',
|
|
431
|
+
'card.questionReply': '(Antwort auf die vorherige Frage)',
|
|
432
|
+
'card.imageAlt': 'Angehängtes Bild',
|
|
433
|
+
'card.latestBadge': 'Neuestes',
|
|
434
|
+
'card.latestTitle': 'Der neueste Knoten in diesem Baum',
|
|
435
|
+
'card.status.thinking': 'Denkt nach',
|
|
436
|
+
'card.status.streaming': 'Antwortet',
|
|
437
|
+
'card.status.error': 'Fehler',
|
|
438
|
+
'card.status.stopped': 'Angehalten',
|
|
439
|
+
'card.status.done': 'Fertig',
|
|
440
|
+
'card.status.awaiting': 'Braucht Antwort',
|
|
441
|
+
'card.status.awaitingApproval': 'Braucht Freigabe',
|
|
442
|
+
'card.stop': 'Stoppen',
|
|
443
|
+
'card.stopTitle': 'Diesen Zweig stoppen',
|
|
444
|
+
'card.ask': 'Auf diesem Zweig nachfragen',
|
|
445
|
+
'card.more': 'Weitere Aktionen',
|
|
446
|
+
'card.delete': 'Diesen Knoten löschen',
|
|
447
|
+
'card.deleteTitle': 'Diesen Knoten und alle Zweige darunter ausblenden',
|
|
448
|
+
'card.deleteConfirm': 'Diesen Knoten und alle Zweige darunter löschen? (umkehrbar)',
|
|
449
|
+
'card.fullscreen': 'Vollbild lesen',
|
|
450
|
+
'card.fullscreenTitle': 'Die vollständige Antwort im Vollbild lesen',
|
|
451
|
+
'card.unfoldBranch': 'Diesen Zweig ausklappen',
|
|
452
|
+
'card.foldBranch': 'Diesen Zweig einklappen',
|
|
453
|
+
'card.unfoldDescendants': '{count} Nachfolger ausklappen',
|
|
454
|
+
'card.foldDescendants': '{count} Nachfolger einklappen',
|
|
455
|
+
'card.descendants': '{count} Nachfolger',
|
|
456
|
+
'card.truncated': '\n\n… (im Vollbild die vollständige Antwort lesen)',
|
|
457
|
+
'card.cost.elapsed': 'Dauer {value}',
|
|
458
|
+
'card.cost.context': 'Kontext {value}',
|
|
459
|
+
'card.cost.cached': 'Cache {value}',
|
|
460
|
+
'card.think': 'Gedankengang',
|
|
461
|
+
'card.thinkMeta': '{count} Zeichen',
|
|
462
|
+
'card.thinkTruncated': '(nur die neuesten {count} Zeichen Gedankengang bleiben erhalten)',
|
|
463
|
+
'live.calling': 'Ruft {tool} auf',
|
|
464
|
+
'live.outputting': 'Schreibt…',
|
|
465
|
+
'live.thinking': 'Denkt nach…',
|
|
466
|
+
'live.starting': 'Startet…',
|
|
467
|
+
'live.awaiting': 'Wartet auf deine Antwort…',
|
|
468
|
+
'live.awaitingApproval': 'Wartet auf deine Freigabe…',
|
|
469
|
+
'live.step': 'Schritt {step}',
|
|
470
|
+
'composer.placeholder': 'Auf diesem Zweig nachfragen… (Enter senden, Shift+Enter neue Zeile)',
|
|
471
|
+
'composer.label': 'Nachfrage',
|
|
472
|
+
'composer.from': 'Ausgehend von „{question}…“',
|
|
473
|
+
'composer.cancel': 'Abbrechen',
|
|
474
|
+
'composer.send': 'Senden',
|
|
475
|
+
'reader.close': 'Schließen (Esc)',
|
|
476
|
+
'reader.closeLabel': 'Leser schließen',
|
|
477
|
+
'reader.noAnswer': '(noch keine Antwort)',
|
|
478
|
+
'reader.hint': 'Esc oder Klick auf den Hintergrund zum Schließen',
|
|
479
|
+
'reader.branch': 'Zweig',
|
|
480
|
+
'reader.mainline': 'Hauptlinie',
|
|
481
|
+
'reader.widthGroup': 'Lesebreite',
|
|
482
|
+
'reader.paneGroup': 'Leseinhalt',
|
|
483
|
+
'reader.paneAnswer': 'Endergebnis',
|
|
484
|
+
'reader.widthStandard': 'Standard',
|
|
485
|
+
'reader.widthWide': 'Breiter',
|
|
486
|
+
'error.title': 'Die Baumansicht ist abgestürzt',
|
|
487
|
+
'error.reload': 'Ansicht neu laden',
|
|
488
|
+
'error.hint': 'Die Leinwand-Daten sind sicher; nur diese Darstellung ist fehlgeschlagen.',
|
|
489
|
+
'error.sessionNotOpen': 'Die Sitzung ist noch nicht geöffnet und kann daher nicht projiziert werden.',
|
|
490
|
+
'error.noBinding': 'Die Sitzung hat keine Bindung zurückgegeben.',
|
|
491
|
+
'error.openFailed': 'Sitzung konnte nicht geöffnet werden: {reason}',
|
|
492
|
+
'error.forkFailed': 'Fork fehlgeschlagen: {reason}',
|
|
493
|
+
'error.branchUnopenable': 'Die Zweig-Sitzung konnte nicht geöffnet werden: {reason}',
|
|
494
|
+
'error.branchNoBinding': 'Die Zweig-Sitzung konnte nicht geöffnet werden: {reason}',
|
|
495
|
+
'error.branchNoUsableBinding': 'Die Zweig-Sitzung hat keine brauchbare Bindung zurückgegeben.',
|
|
496
|
+
'error.submitFailed': 'Übermittlung fehlgeschlagen: {reason}',
|
|
497
|
+
'error.loadOlderFailed': 'Frühere Verlaufsdaten konnten nicht geladen werden: {reason}',
|
|
498
|
+
'view.layoutGroup': 'Layout-Richtung',
|
|
499
|
+
'view.layoutVertical': 'Oben nach unten',
|
|
500
|
+
},
|
|
501
|
+
es: {
|
|
502
|
+
'view.tab': 'Exploración infinita',
|
|
503
|
+
'view.heading': 'Exploración infinita',
|
|
504
|
+
'view.nodes': '{count} nodos',
|
|
505
|
+
'view.running': '{count} ramas en curso',
|
|
506
|
+
'view.runningTitle': 'Ir al siguiente nodo en curso',
|
|
507
|
+
'view.awaiting': '{count} esperando tu respuesta',
|
|
508
|
+
'view.awaitingTitle': 'Ir al nodo que espera tu respuesta',
|
|
509
|
+
'view.loadOlder': 'Cargar anteriores',
|
|
510
|
+
'view.restoreHidden': '{count} ocultos · Restaurar',
|
|
511
|
+
'view.restoreHiddenTitle': 'Restaurar los nodos y ramas eliminados',
|
|
512
|
+
'view.searchPlaceholder': 'Buscar nodos',
|
|
513
|
+
'view.searchLabel': 'Buscar nodos',
|
|
514
|
+
'view.zoomGroup': 'Zoom del lienzo',
|
|
515
|
+
'view.zoomOut': 'Alejar',
|
|
516
|
+
'view.zoomIn': 'Acercar',
|
|
517
|
+
'view.zoomLevel': 'Nivel de zoom actual',
|
|
518
|
+
'view.layoutHorizontal': 'De izquierda a derecha',
|
|
519
|
+
'view.layoutTitle': 'Alternar entre diseño de izquierda a derecha y de arriba abajo',
|
|
520
|
+
'view.fit': 'Ajustar lienzo',
|
|
521
|
+
'view.fitTitle': 'Alejar hasta ver el árbol completo',
|
|
522
|
+
'view.latest': 'Ir a lo más reciente',
|
|
523
|
+
'view.latestTitle': 'Expandir la ruta e ir al nodo más reciente',
|
|
524
|
+
'view.latestTitleEmpty': 'Aún no hay nodos',
|
|
525
|
+
'view.cardSizeGroup': 'Tamaño de tarjeta',
|
|
526
|
+
'view.cardSizeCompact': 'Compacta',
|
|
527
|
+
'view.cardSizeStandard': 'Estándar',
|
|
528
|
+
'view.cardSizeRoomy': 'Amplia',
|
|
529
|
+
'view.branchesShown': 'Ramas: en el espacio',
|
|
530
|
+
'view.branchesShownTitle': 'Mover las sesiones de rama terminadas al archivo y dejar solo la sesión principal en el espacio de trabajo',
|
|
531
|
+
'view.branchesQuiet': 'Ramas: archivadas',
|
|
532
|
+
'view.branchesQuietTitle': 'Devolver al espacio de trabajo las sesiones de rama de este árbol',
|
|
533
|
+
'view.empty.title': 'Este árbol aún está vacío',
|
|
534
|
+
'view.empty.hint': 'Pregunta algo en Chat y el primer nodo crecerá aquí.',
|
|
535
|
+
'view.empty.report': 'Si ya preguntaste y esto sigue vacío, dime: {events} eventos · sesión {state}.',
|
|
536
|
+
'card.noQuestion': '(sin pregunta)',
|
|
537
|
+
'card.questionReply': '(respondiendo a la pregunta anterior)',
|
|
538
|
+
'card.imageAlt': 'Imagen adjunta',
|
|
539
|
+
'card.latestBadge': 'Último',
|
|
540
|
+
'card.latestTitle': 'El nodo más reciente de este árbol',
|
|
541
|
+
'card.status.thinking': 'Pensando',
|
|
542
|
+
'card.status.streaming': 'Respondiendo',
|
|
543
|
+
'card.status.error': 'Error',
|
|
544
|
+
'card.status.stopped': 'Detenido',
|
|
545
|
+
'card.status.done': 'Listo',
|
|
546
|
+
'card.status.awaiting': 'Necesita respuesta',
|
|
547
|
+
'card.status.awaitingApproval': 'Necesita aprobación',
|
|
548
|
+
'card.stop': 'Detener',
|
|
549
|
+
'card.stopTitle': 'Detener esta rama',
|
|
550
|
+
'card.ask': 'Seguir preguntando en esta rama',
|
|
551
|
+
'card.more': 'Más acciones',
|
|
552
|
+
'card.delete': 'Eliminar este nodo',
|
|
553
|
+
'card.deleteTitle': 'Ocultar este nodo y todas las ramas que cuelgan de él',
|
|
554
|
+
'card.deleteConfirm': '¿Eliminar este nodo y todas sus ramas? (reversible)',
|
|
555
|
+
'card.fullscreen': 'Pantalla completa',
|
|
556
|
+
'card.fullscreenTitle': 'Leer la respuesta completa a pantalla completa',
|
|
557
|
+
'card.unfoldBranch': 'Expandir esta rama',
|
|
558
|
+
'card.foldBranch': 'Contraer esta rama',
|
|
559
|
+
'card.unfoldDescendants': 'Expandir {count} descendientes',
|
|
560
|
+
'card.foldDescendants': 'Contraer {count} descendientes',
|
|
561
|
+
'card.descendants': '{count} descendientes',
|
|
562
|
+
'card.truncated': '\n\n… (abre a pantalla completa para ver la respuesta completa)',
|
|
563
|
+
'card.cost.elapsed': 'duró {value}',
|
|
564
|
+
'card.cost.context': 'contexto {value}',
|
|
565
|
+
'card.cost.cached': 'caché {value}',
|
|
566
|
+
'card.think': 'Razonamiento',
|
|
567
|
+
'card.thinkMeta': '{count} caracteres',
|
|
568
|
+
'card.thinkTruncated': '(solo se conservan los {count} caracteres más recientes del razonamiento)',
|
|
569
|
+
'live.calling': 'Llamando a {tool}',
|
|
570
|
+
'live.outputting': 'Escribiendo…',
|
|
571
|
+
'live.thinking': 'Pensando…',
|
|
572
|
+
'live.starting': 'Iniciando…',
|
|
573
|
+
'live.awaiting': 'Esperando tu respuesta…',
|
|
574
|
+
'live.awaitingApproval': 'Esperando tu aprobación…',
|
|
575
|
+
'live.step': 'paso {step}',
|
|
576
|
+
'composer.placeholder': 'Pregunta de nuevo en esta rama… (Enter para enviar, Shift+Enter para nueva línea)',
|
|
577
|
+
'composer.label': 'Texto de seguimiento',
|
|
578
|
+
'composer.from': 'A partir de «{question}…»',
|
|
579
|
+
'composer.cancel': 'Cancelar',
|
|
580
|
+
'composer.send': 'Enviar',
|
|
581
|
+
'reader.close': 'Cerrar (Esc)',
|
|
582
|
+
'reader.closeLabel': 'Cerrar el lector',
|
|
583
|
+
'reader.noAnswer': '(aún sin respuesta)',
|
|
584
|
+
'reader.hint': 'Esc o clic en el fondo para cerrar',
|
|
585
|
+
'reader.branch': 'Rama',
|
|
586
|
+
'reader.mainline': 'Línea principal',
|
|
587
|
+
'reader.widthGroup': 'Ancho de lectura',
|
|
588
|
+
'reader.paneGroup': 'Contenido de lectura',
|
|
589
|
+
'reader.paneAnswer': 'Resultado final',
|
|
590
|
+
'reader.widthStandard': 'Estándar',
|
|
591
|
+
'reader.widthWide': 'Más ancho',
|
|
592
|
+
'error.title': 'La vista de árbol falló',
|
|
593
|
+
'error.reload': 'Recargar la vista',
|
|
594
|
+
'error.hint': 'Los datos del lienzo están a salvo; solo falló este render.',
|
|
595
|
+
'error.sessionNotOpen': 'La sesión aún no está abierta, así que no se puede proyectar.',
|
|
596
|
+
'error.noBinding': 'La sesión no devolvió ninguna vinculación.',
|
|
597
|
+
'error.openFailed': 'No se pudo abrir la sesión: {reason}',
|
|
598
|
+
'error.forkFailed': 'Falló la bifurcación: {reason}',
|
|
599
|
+
'error.branchUnopenable': 'No se pudo abrir la sesión de la rama: {reason}',
|
|
600
|
+
'error.branchNoBinding': 'No se pudo abrir la sesión de la rama: {reason}',
|
|
601
|
+
'error.branchNoUsableBinding': 'La sesión de la rama no devolvió una vinculación utilizable.',
|
|
602
|
+
'error.submitFailed': 'No se pudo enviar: {reason}',
|
|
603
|
+
'error.loadOlderFailed': 'No se pudo cargar el historial anterior: {reason}',
|
|
604
|
+
'view.layoutGroup': 'Dirección del diseño',
|
|
605
|
+
'view.layoutVertical': 'De arriba abajo',
|
|
606
|
+
},
|
|
607
|
+
fr: {
|
|
608
|
+
'view.tab': 'Exploration infinie',
|
|
609
|
+
'view.heading': 'Exploration infinie',
|
|
610
|
+
'view.nodes': '{count} nœuds',
|
|
611
|
+
'view.running': '{count} branches en cours',
|
|
612
|
+
'view.runningTitle': 'Aller au prochain nœud en cours',
|
|
613
|
+
'view.awaiting': '{count} en attente de vous',
|
|
614
|
+
'view.awaitingTitle': 'Aller au nœud qui attend votre réponse',
|
|
615
|
+
'view.loadOlder': 'Charger les précédents',
|
|
616
|
+
'view.restoreHidden': '{count} masqués · Restaurer',
|
|
617
|
+
'view.restoreHiddenTitle': 'Restaurer les nœuds et branches supprimés',
|
|
618
|
+
'view.searchPlaceholder': 'Rechercher des nœuds',
|
|
619
|
+
'view.searchLabel': 'Rechercher des nœuds',
|
|
620
|
+
'view.zoomGroup': 'Zoom du canevas',
|
|
621
|
+
'view.zoomOut': 'Dézoomer',
|
|
622
|
+
'view.zoomIn': 'Zoomer',
|
|
623
|
+
'view.zoomLevel': 'Niveau de zoom actuel',
|
|
624
|
+
'view.layoutHorizontal': 'De gauche à droite',
|
|
625
|
+
'view.layoutTitle': 'Basculer entre disposition de gauche à droite et de haut en bas',
|
|
626
|
+
'view.fit': 'Ajuster le canevas',
|
|
627
|
+
'view.fitTitle': 'Dézoomer pour afficher tout l’arbre',
|
|
628
|
+
'view.latest': 'Aller au plus récent',
|
|
629
|
+
'view.latestTitle': 'Déplier le chemin et aller au nœud le plus récent',
|
|
630
|
+
'view.latestTitleEmpty': 'Aucun nœud pour l’instant',
|
|
631
|
+
'view.cardSizeGroup': 'Taille des cartes',
|
|
632
|
+
'view.cardSizeCompact': 'Compacte',
|
|
633
|
+
'view.cardSizeStandard': 'Standard',
|
|
634
|
+
'view.cardSizeRoomy': 'Large',
|
|
635
|
+
'view.branchesShown': 'Branches : dans l’espace',
|
|
636
|
+
'view.branchesShownTitle': 'Déplacer les sessions de branche terminées vers l’archive pour ne garder que la session principale',
|
|
637
|
+
'view.branchesQuiet': 'Branches : archivées',
|
|
638
|
+
'view.branchesQuietTitle': 'Ramener dans l’espace de travail les sessions de branche de cet arbre',
|
|
639
|
+
'view.empty.title': 'Cet arbre est encore vide',
|
|
640
|
+
'view.empty.hint': 'Posez une question dans Chat et le premier nœud poussera ici.',
|
|
641
|
+
'view.empty.report': 'Si vous avez déjà posé une question et que c’est toujours vide, dites-moi : {events} événements · session {state}.',
|
|
642
|
+
'card.noQuestion': '(aucune question)',
|
|
643
|
+
'card.questionReply': '(réponse à la question précédente)',
|
|
644
|
+
'card.imageAlt': 'Image jointe',
|
|
645
|
+
'card.latestBadge': 'Dernier',
|
|
646
|
+
'card.latestTitle': 'Le nœud le plus récent de cet arbre',
|
|
647
|
+
'card.status.thinking': 'Réflexion',
|
|
648
|
+
'card.status.streaming': 'Réponse en cours',
|
|
649
|
+
'card.status.error': 'Erreur',
|
|
650
|
+
'card.status.stopped': 'Arrêté',
|
|
651
|
+
'card.status.done': 'Terminé',
|
|
652
|
+
'card.status.awaiting': 'Réponse attendue',
|
|
653
|
+
'card.status.awaitingApproval': 'Approbation attendue',
|
|
654
|
+
'card.stop': 'Arrêter',
|
|
655
|
+
'card.stopTitle': 'Arrêter cette branche',
|
|
656
|
+
'card.ask': 'Relancer sur cette branche',
|
|
657
|
+
'card.more': 'Plus d’actions',
|
|
658
|
+
'card.delete': 'Supprimer ce nœud',
|
|
659
|
+
'card.deleteTitle': 'Masquer ce nœud et toutes les branches en dessous',
|
|
660
|
+
'card.deleteConfirm': 'Supprimer ce nœud et toutes les branches en dessous ? (réversible)',
|
|
661
|
+
'card.fullscreen': 'Plein écran',
|
|
662
|
+
'card.fullscreenTitle': 'Lire la réponse complète en plein écran',
|
|
663
|
+
'card.unfoldBranch': 'Déplier cette branche',
|
|
664
|
+
'card.foldBranch': 'Replier cette branche',
|
|
665
|
+
'card.unfoldDescendants': 'Déplier {count} descendants',
|
|
666
|
+
'card.foldDescendants': 'Replier {count} descendants',
|
|
667
|
+
'card.descendants': '{count} descendants',
|
|
668
|
+
'card.truncated': '\n\n… (ouvrez le plein écran pour la réponse complète)',
|
|
669
|
+
'card.cost.elapsed': 'durée {value}',
|
|
670
|
+
'card.cost.context': 'contexte {value}',
|
|
671
|
+
'card.cost.cached': 'cache {value}',
|
|
672
|
+
'card.think': 'Raisonnement',
|
|
673
|
+
'card.thinkMeta': '{count} caractères',
|
|
674
|
+
'card.thinkTruncated': '(seuls les {count} derniers caractères du raisonnement sont conservés)',
|
|
675
|
+
'live.calling': 'Appel de {tool}',
|
|
676
|
+
'live.outputting': 'Écriture…',
|
|
677
|
+
'live.thinking': 'En réflexion…',
|
|
678
|
+
'live.starting': 'Démarrage…',
|
|
679
|
+
'live.awaiting': 'En attente de votre réponse…',
|
|
680
|
+
'live.awaitingApproval': 'En attente de votre approbation…',
|
|
681
|
+
'live.step': 'étape {step}',
|
|
682
|
+
'composer.placeholder': 'Relancer sur cette branche… (Entrée pour envoyer, Maj+Entrée pour une nouvelle ligne)',
|
|
683
|
+
'composer.label': 'Texte de suivi',
|
|
684
|
+
'composer.from': 'À partir de « {question}… »',
|
|
685
|
+
'composer.cancel': 'Annuler',
|
|
686
|
+
'composer.send': 'Envoyer',
|
|
687
|
+
'reader.close': 'Fermer (Échap)',
|
|
688
|
+
'reader.closeLabel': 'Fermer le lecteur',
|
|
689
|
+
'reader.noAnswer': '(pas encore de réponse)',
|
|
690
|
+
'reader.hint': 'Échap ou clic sur l’arrière-plan pour fermer',
|
|
691
|
+
'reader.branch': 'Branche',
|
|
692
|
+
'reader.mainline': 'Ligne principale',
|
|
693
|
+
'reader.widthGroup': 'Largeur de lecture',
|
|
694
|
+
'reader.paneGroup': 'Contenu de lecture',
|
|
695
|
+
'reader.paneAnswer': 'Résultat final',
|
|
696
|
+
'reader.widthStandard': 'Standard',
|
|
697
|
+
'reader.widthWide': 'Plus large',
|
|
698
|
+
'error.title': 'La vue arborescente a planté',
|
|
699
|
+
'error.reload': 'Recharger la vue',
|
|
700
|
+
'error.hint': 'Les données du canevas sont intactes ; seul ce rendu a échoué.',
|
|
701
|
+
'error.sessionNotOpen': 'La session n’est pas encore ouverte ; elle ne peut donc pas être projetée.',
|
|
702
|
+
'error.noBinding': 'La session n’a renvoyé aucune liaison.',
|
|
703
|
+
'error.openFailed': 'Impossible d’ouvrir la session : {reason}',
|
|
704
|
+
'error.forkFailed': 'Échec de l’embranchement : {reason}',
|
|
705
|
+
'error.branchUnopenable': 'Impossible d’ouvrir la session de la branche : {reason}',
|
|
706
|
+
'error.branchNoBinding': 'Impossible d’ouvrir la session de la branche : {reason}',
|
|
707
|
+
'error.branchNoUsableBinding': 'La session de la branche n’a renvoyé aucune liaison utilisable.',
|
|
708
|
+
'error.submitFailed': 'Échec de l’envoi : {reason}',
|
|
709
|
+
'error.loadOlderFailed': 'Impossible de charger l’historique précédent : {reason}',
|
|
710
|
+
'view.layoutGroup': 'Sens de la disposition',
|
|
711
|
+
'view.layoutVertical': 'De haut en bas',
|
|
712
|
+
},
|
|
713
|
+
ja: {
|
|
714
|
+
'view.tab': '無限探索',
|
|
715
|
+
'view.heading': '無限探索',
|
|
716
|
+
'view.nodes': '{count} 個のノード',
|
|
717
|
+
'view.running': '{count} ブランチ実行中',
|
|
718
|
+
'view.runningTitle': '次に実行中のノードへ移動',
|
|
719
|
+
'view.awaiting': '{count} 件が対応待ち',
|
|
720
|
+
'view.awaitingTitle': 'あなたの対応を待つノードへ移動',
|
|
721
|
+
'view.loadOlder': '以前を読み込む',
|
|
722
|
+
'view.restoreHidden': '{count} 件非表示 · 復元',
|
|
723
|
+
'view.restoreHiddenTitle': '削除したノードとブランチを復元',
|
|
724
|
+
'view.searchPlaceholder': 'ノードを検索',
|
|
725
|
+
'view.searchLabel': 'ノードを検索',
|
|
726
|
+
'view.zoomGroup': 'キャンバスのズーム',
|
|
727
|
+
'view.zoomOut': '縮小',
|
|
728
|
+
'view.zoomIn': '拡大',
|
|
729
|
+
'view.zoomLevel': '現在のズーム率',
|
|
730
|
+
'view.layoutHorizontal': '左右配置',
|
|
731
|
+
'view.layoutTitle': '左右配置と上下配置を切り替える',
|
|
732
|
+
'view.fit': 'キャンバスに合わせる',
|
|
733
|
+
'view.fitTitle': 'ツリー全体が見えるまで縮小',
|
|
734
|
+
'view.latest': '最新へ移動',
|
|
735
|
+
'view.latestTitle': '経路を展開して最新のノードへ移動',
|
|
736
|
+
'view.latestTitleEmpty': 'ノードはまだありません',
|
|
737
|
+
'view.cardSizeGroup': 'カードの情報量',
|
|
738
|
+
'view.cardSizeCompact': 'コンパクト',
|
|
739
|
+
'view.cardSizeStandard': '標準',
|
|
740
|
+
'view.cardSizeRoomy': 'ゆったり',
|
|
741
|
+
'view.branchesShown': 'ブランチ記録:ワークスペース',
|
|
742
|
+
'view.branchesShownTitle': '完了したブランチセッションをアーカイブし、ワークスペースにはメインセッションだけを残します',
|
|
743
|
+
'view.branchesQuiet': 'ブランチ記録:アーカイブ済み',
|
|
744
|
+
'view.branchesQuietTitle': 'このツリーのブランチセッションをワークスペースに戻します',
|
|
745
|
+
'view.empty.title': 'このツリーはまだ空です',
|
|
746
|
+
'view.empty.hint': 'Chat で質問すると、ここに最初のノードが生まれます。',
|
|
747
|
+
'view.empty.report': 'すでに質問したのに空のままなら、次を伝えてください:イベント {events} · セッション {state}。',
|
|
748
|
+
'card.noQuestion': '(質問なし)',
|
|
749
|
+
'card.questionReply': '(前の質問への回答)',
|
|
750
|
+
'card.imageAlt': '添付画像',
|
|
751
|
+
'card.latestBadge': '最新',
|
|
752
|
+
'card.latestTitle': 'このツリーで最新のノード',
|
|
753
|
+
'card.status.thinking': '思考中',
|
|
754
|
+
'card.status.streaming': '回答中',
|
|
755
|
+
'card.status.error': 'エラー',
|
|
756
|
+
'card.status.stopped': '停止しました',
|
|
757
|
+
'card.status.done': '完了',
|
|
758
|
+
'card.status.awaiting': '回答待ち',
|
|
759
|
+
'card.status.awaitingApproval': '承認待ち',
|
|
760
|
+
'card.stop': '停止',
|
|
761
|
+
'card.stopTitle': 'このブランチを停止',
|
|
762
|
+
'card.ask': 'このブランチで追加質問',
|
|
763
|
+
'card.more': 'その他の操作',
|
|
764
|
+
'card.delete': 'このノードを削除',
|
|
765
|
+
'card.deleteTitle': 'このノードとその下のすべてのブランチを非表示',
|
|
766
|
+
'card.deleteConfirm': 'このノードとその下のすべてのブランチを削除しますか?(復元できます)',
|
|
767
|
+
'card.fullscreen': '全画面で読む',
|
|
768
|
+
'card.fullscreenTitle': '完全な回答を全画面で読む',
|
|
769
|
+
'card.unfoldBranch': 'このブランチを展開',
|
|
770
|
+
'card.foldBranch': 'このブランチを折りたたむ',
|
|
771
|
+
'card.unfoldDescendants': '子孫 {count} 件を展開',
|
|
772
|
+
'card.foldDescendants': '子孫 {count} 件を折りたたむ',
|
|
773
|
+
'card.descendants': '子孫 {count} 件',
|
|
774
|
+
'card.truncated': '\n\n…(全画面で完全な回答を表示)',
|
|
775
|
+
'card.cost.elapsed': '所要 {value}',
|
|
776
|
+
'card.cost.context': 'コンテキスト {value}',
|
|
777
|
+
'card.cost.cached': 'キャッシュ {value}',
|
|
778
|
+
'card.think': '思考',
|
|
779
|
+
'card.thinkMeta': '{count} 文字',
|
|
780
|
+
'card.thinkTruncated': '(最新の思考 {count} 文字のみ保持)',
|
|
781
|
+
'live.calling': '{tool} を呼び出し中',
|
|
782
|
+
'live.outputting': '出力中…',
|
|
783
|
+
'live.thinking': '考えています…',
|
|
784
|
+
'live.starting': '開始中…',
|
|
785
|
+
'live.awaiting': '回答をお待ちしています…',
|
|
786
|
+
'live.awaitingApproval': '承認をお待ちしています…',
|
|
787
|
+
'live.step': 'ステップ {step}',
|
|
788
|
+
'composer.placeholder': 'このブランチで追加質問…(Enter で送信、Shift+Enter で改行)',
|
|
789
|
+
'composer.label': '追加質問の内容',
|
|
790
|
+
'composer.from': '「{question}…」から開始',
|
|
791
|
+
'composer.cancel': 'キャンセル',
|
|
792
|
+
'composer.send': '送信',
|
|
793
|
+
'reader.close': '閉じる(Esc)',
|
|
794
|
+
'reader.closeLabel': 'リーダーを閉じる',
|
|
795
|
+
'reader.noAnswer': '(まだ回答はありません)',
|
|
796
|
+
'reader.hint': 'Esc または背景をクリックで閉じる',
|
|
797
|
+
'reader.branch': 'ブランチ',
|
|
798
|
+
'reader.mainline': '本線',
|
|
799
|
+
'reader.widthGroup': '閲覧幅',
|
|
800
|
+
'reader.paneGroup': '表示する内容',
|
|
801
|
+
'reader.paneAnswer': '最終結果',
|
|
802
|
+
'reader.widthStandard': '標準幅',
|
|
803
|
+
'reader.widthWide': '広め',
|
|
804
|
+
'error.title': 'ツリービューでエラーが発生しました',
|
|
805
|
+
'error.reload': 'ビューを再読み込み',
|
|
806
|
+
'error.hint': 'キャンバスのデータは失われていません。描画だけが失敗しました。',
|
|
807
|
+
'error.sessionNotOpen': 'セッションがまだ開いていないため、投影できません。',
|
|
808
|
+
'error.noBinding': 'セッションからバインディングが返されませんでした。',
|
|
809
|
+
'error.openFailed': 'セッションを開けませんでした:{reason}',
|
|
810
|
+
'error.forkFailed': 'フォークに失敗しました:{reason}',
|
|
811
|
+
'error.branchUnopenable': 'ブランチセッションを開けませんでした:{reason}',
|
|
812
|
+
'error.branchNoBinding': 'ブランチセッションを開けませんでした:{reason}',
|
|
813
|
+
'error.branchNoUsableBinding': 'ブランチセッションから使用可能なバインディングが返されませんでした。',
|
|
814
|
+
'error.submitFailed': '送信に失敗しました:{reason}',
|
|
815
|
+
'error.loadOlderFailed': '以前の履歴を読み込めませんでした:{reason}',
|
|
816
|
+
'view.layoutGroup': 'レイアウト方向',
|
|
817
|
+
'view.layoutVertical': '上から下',
|
|
818
|
+
},
|
|
819
|
+
pt: {
|
|
820
|
+
'view.tab': 'Exploração infinita',
|
|
821
|
+
'view.heading': 'Exploração infinita',
|
|
822
|
+
'view.nodes': '{count} nós',
|
|
823
|
+
'view.running': '{count} ramos em execução',
|
|
824
|
+
'view.runningTitle': 'Ir para o próximo nó em execução',
|
|
825
|
+
'view.awaiting': '{count} aguardando você',
|
|
826
|
+
'view.awaitingTitle': 'Ir para o nó que aguarda você',
|
|
827
|
+
'view.loadOlder': 'Carregar anteriores',
|
|
828
|
+
'view.restoreHidden': '{count} ocultos · Restaurar',
|
|
829
|
+
'view.restoreHiddenTitle': 'Restaurar nós e ramos excluídos',
|
|
830
|
+
'view.searchPlaceholder': 'Buscar nós',
|
|
831
|
+
'view.searchLabel': 'Buscar nós',
|
|
832
|
+
'view.zoomGroup': 'Zoom do canvas',
|
|
833
|
+
'view.zoomOut': 'Afastar',
|
|
834
|
+
'view.zoomIn': 'Aproximar',
|
|
835
|
+
'view.zoomLevel': 'Nível de zoom atual',
|
|
836
|
+
'view.layoutHorizontal': 'Da esquerda para a direita',
|
|
837
|
+
'view.layoutTitle': 'Alternar entre layout da esquerda para a direita e de cima para baixo',
|
|
838
|
+
'view.fit': 'Ajustar canvas',
|
|
839
|
+
'view.fitTitle': 'Afastar até mostrar a árvore inteira',
|
|
840
|
+
'view.latest': 'Ir para o mais recente',
|
|
841
|
+
'view.latestTitle': 'Expandir o caminho e ir para o nó mais recente',
|
|
842
|
+
'view.latestTitleEmpty': 'Ainda não há nós',
|
|
843
|
+
'view.cardSizeGroup': 'Tamanho do cartão',
|
|
844
|
+
'view.cardSizeCompact': 'Compacto',
|
|
845
|
+
'view.cardSizeStandard': 'Padrão',
|
|
846
|
+
'view.cardSizeRoomy': 'Amplo',
|
|
847
|
+
'view.branchesShown': 'Ramos: no espaço',
|
|
848
|
+
'view.branchesShownTitle': 'Mover as sessões de ramo concluídas para o arquivo, deixando só a sessão principal no espaço de trabalho',
|
|
849
|
+
'view.branchesQuiet': 'Ramos: arquivados',
|
|
850
|
+
'view.branchesQuietTitle': 'Trazer de volta ao espaço de trabalho as sessões de ramo desta árvore',
|
|
851
|
+
'view.empty.title': 'Esta árvore ainda está vazia',
|
|
852
|
+
'view.empty.hint': 'Pergunte algo no Chat e o primeiro nó vai crescer aqui.',
|
|
853
|
+
'view.empty.report': 'Se você já perguntou e isto continua vazio, me diga: {events} eventos · sessão {state}.',
|
|
854
|
+
'card.noQuestion': '(sem pergunta)',
|
|
855
|
+
'card.questionReply': '(respondendo à pergunta anterior)',
|
|
856
|
+
'card.imageAlt': 'Imagem anexada',
|
|
857
|
+
'card.latestBadge': 'Recente',
|
|
858
|
+
'card.latestTitle': 'O nó mais recente desta árvore',
|
|
859
|
+
'card.status.thinking': 'Pensando',
|
|
860
|
+
'card.status.streaming': 'Respondendo',
|
|
861
|
+
'card.status.error': 'Erro',
|
|
862
|
+
'card.status.stopped': 'Interrompido',
|
|
863
|
+
'card.status.done': 'Concluído',
|
|
864
|
+
'card.status.awaiting': 'Aguardando resposta',
|
|
865
|
+
'card.status.awaitingApproval': 'Aguardando aprovação',
|
|
866
|
+
'card.stop': 'Parar',
|
|
867
|
+
'card.stopTitle': 'Parar este ramo',
|
|
868
|
+
'card.ask': 'Perguntar novamente neste ramo',
|
|
869
|
+
'card.more': 'Mais ações',
|
|
870
|
+
'card.delete': 'Excluir este nó',
|
|
871
|
+
'card.deleteTitle': 'Ocultar este nó e todos os ramos abaixo dele',
|
|
872
|
+
'card.deleteConfirm': 'Excluir este nó e todos os ramos abaixo dele? (reversível)',
|
|
873
|
+
'card.fullscreen': 'Tela cheia',
|
|
874
|
+
'card.fullscreenTitle': 'Ler a resposta completa em tela cheia',
|
|
875
|
+
'card.unfoldBranch': 'Expandir este ramo',
|
|
876
|
+
'card.foldBranch': 'Recolher este ramo',
|
|
877
|
+
'card.unfoldDescendants': 'Expandir {count} descendentes',
|
|
878
|
+
'card.foldDescendants': 'Recolher {count} descendentes',
|
|
879
|
+
'card.descendants': '{count} descendentes',
|
|
880
|
+
'card.truncated': '\n\n… (abra em tela cheia para ver a resposta completa)',
|
|
881
|
+
'card.cost.elapsed': 'levou {value}',
|
|
882
|
+
'card.cost.context': 'contexto {value}',
|
|
883
|
+
'card.cost.cached': 'cache {value}',
|
|
884
|
+
'card.think': 'Raciocínio',
|
|
885
|
+
'card.thinkMeta': '{count} caracteres',
|
|
886
|
+
'card.thinkTruncated': '(apenas os {count} caracteres mais recentes do raciocínio são mantidos)',
|
|
887
|
+
'live.calling': 'Chamando {tool}',
|
|
888
|
+
'live.outputting': 'Escrevendo…',
|
|
889
|
+
'live.thinking': 'Pensando…',
|
|
890
|
+
'live.starting': 'Iniciando…',
|
|
891
|
+
'live.awaiting': 'Aguardando sua resposta…',
|
|
892
|
+
'live.awaitingApproval': 'Aguardando sua aprovação…',
|
|
893
|
+
'live.step': 'etapa {step}',
|
|
894
|
+
'composer.placeholder': 'Pergunte novamente neste ramo… (Enter para enviar, Shift+Enter para nova linha)',
|
|
895
|
+
'composer.label': 'Texto da pergunta',
|
|
896
|
+
'composer.from': 'A partir de “{question}…”',
|
|
897
|
+
'composer.cancel': 'Cancelar',
|
|
898
|
+
'composer.send': 'Enviar',
|
|
899
|
+
'reader.close': 'Fechar (Esc)',
|
|
900
|
+
'reader.closeLabel': 'Fechar o leitor',
|
|
901
|
+
'reader.noAnswer': '(ainda sem resposta)',
|
|
902
|
+
'reader.hint': 'Esc ou clique no fundo para fechar',
|
|
903
|
+
'reader.branch': 'Ramo',
|
|
904
|
+
'reader.mainline': 'Linha principal',
|
|
905
|
+
'reader.widthGroup': 'Largura de leitura',
|
|
906
|
+
'reader.paneGroup': 'Conteúdo da leitura',
|
|
907
|
+
'reader.paneAnswer': 'Resultado final',
|
|
908
|
+
'reader.widthStandard': 'Padrão',
|
|
909
|
+
'reader.widthWide': 'Mais largo',
|
|
910
|
+
'error.title': 'A visualização em árvore falhou',
|
|
911
|
+
'error.reload': 'Recarregar a visualização',
|
|
912
|
+
'error.hint': 'Os dados do canvas estão seguros; apenas esta renderização falhou.',
|
|
913
|
+
'error.sessionNotOpen': 'A sessão ainda não está aberta, então não pode ser projetada.',
|
|
914
|
+
'error.noBinding': 'A sessão não retornou nenhuma vinculação.',
|
|
915
|
+
'error.openFailed': 'Não foi possível abrir a sessão: {reason}',
|
|
916
|
+
'error.forkFailed': 'Falha na bifurcação: {reason}',
|
|
917
|
+
'error.branchUnopenable': 'Não foi possível abrir a sessão do ramo: {reason}',
|
|
918
|
+
'error.branchNoBinding': 'Não foi possível abrir a sessão do ramo: {reason}',
|
|
919
|
+
'error.branchNoUsableBinding': 'A sessão do ramo não retornou uma vinculação utilizável.',
|
|
920
|
+
'error.submitFailed': 'Falha no envio: {reason}',
|
|
921
|
+
'error.loadOlderFailed': 'Não foi possível carregar o histórico anterior: {reason}',
|
|
922
|
+
'view.layoutGroup': 'Direção do layout',
|
|
923
|
+
'view.layoutVertical': 'De cima para baixo',
|
|
924
|
+
},
|
|
925
|
+
ru: {
|
|
926
|
+
'view.tab': 'Бесконечное исследование',
|
|
927
|
+
'view.heading': 'Бесконечное исследование',
|
|
928
|
+
'view.nodes': 'Узлов: {count}',
|
|
929
|
+
'view.running': 'Ветки в работе: {count}',
|
|
930
|
+
'view.runningTitle': 'Перейти к следующему работающему узлу',
|
|
931
|
+
'view.awaiting': 'Ждут вас: {count}',
|
|
932
|
+
'view.awaitingTitle': 'Перейти к узлу, который ждёт вас',
|
|
933
|
+
'view.loadOlder': 'Загрузить ранее',
|
|
934
|
+
'view.restoreHidden': 'Скрыто {count} · Восстановить',
|
|
935
|
+
'view.restoreHiddenTitle': 'Восстановить удалённые узлы и ветки',
|
|
936
|
+
'view.searchPlaceholder': 'Поиск узлов',
|
|
937
|
+
'view.searchLabel': 'Поиск узлов',
|
|
938
|
+
'view.zoomGroup': 'Масштаб холста',
|
|
939
|
+
'view.zoomOut': 'Уменьшить',
|
|
940
|
+
'view.zoomIn': 'Увеличить',
|
|
941
|
+
'view.zoomLevel': 'Текущий масштаб',
|
|
942
|
+
'view.layoutHorizontal': 'Слева направо',
|
|
943
|
+
'view.layoutTitle': 'Переключить раскладку слева направо и сверху вниз',
|
|
944
|
+
'view.fit': 'Вписать холст',
|
|
945
|
+
'view.fitTitle': 'Уменьшить, чтобы показать всё дерево',
|
|
946
|
+
'view.latest': 'К последнему',
|
|
947
|
+
'view.latestTitle': 'Развернуть путь и перейти к новейшему узлу',
|
|
948
|
+
'view.latestTitleEmpty': 'Узлов пока нет',
|
|
949
|
+
'view.cardSizeGroup': 'Размер карточки',
|
|
950
|
+
'view.cardSizeCompact': 'Компактный',
|
|
951
|
+
'view.cardSizeStandard': 'Стандартный',
|
|
952
|
+
'view.cardSizeRoomy': 'Просторный',
|
|
953
|
+
'view.branchesShown': 'Ветки: в рабочем пространстве',
|
|
954
|
+
'view.branchesShownTitle': 'Переместить завершённые сеансы веток в архив, оставив в рабочем пространстве только основной сеанс',
|
|
955
|
+
'view.branchesQuiet': 'Ветки: в архиве',
|
|
956
|
+
'view.branchesQuietTitle': 'Вернуть сеансы веток этого дерева в рабочее пространство',
|
|
957
|
+
'view.empty.title': 'Это дерево пока пустое',
|
|
958
|
+
'view.empty.hint': 'Спросите что-нибудь в Chat, и здесь появится первый узел.',
|
|
959
|
+
'view.empty.report': 'Если вы уже спрашивали, а здесь по-прежнему пусто, сообщите: события {events} · сеанс {state}.',
|
|
960
|
+
'card.noQuestion': '(без вопроса)',
|
|
961
|
+
'card.questionReply': '(ответ на предыдущий вопрос)',
|
|
962
|
+
'card.imageAlt': 'Прикреплённое изображение',
|
|
963
|
+
'card.latestBadge': 'Последний',
|
|
964
|
+
'card.latestTitle': 'Самый новый узел в этом дереве',
|
|
965
|
+
'card.status.thinking': 'Думает',
|
|
966
|
+
'card.status.streaming': 'Отвечает',
|
|
967
|
+
'card.status.error': 'Ошибка',
|
|
968
|
+
'card.status.stopped': 'Остановлено',
|
|
969
|
+
'card.status.done': 'Готово',
|
|
970
|
+
'card.status.awaiting': 'Нужен ответ',
|
|
971
|
+
'card.status.awaitingApproval': 'Нужно подтверждение',
|
|
972
|
+
'card.stop': 'Остановить',
|
|
973
|
+
'card.stopTitle': 'Остановить эту ветку',
|
|
974
|
+
'card.ask': 'Задать вопрос на этой ветке',
|
|
975
|
+
'card.more': 'Ещё действия',
|
|
976
|
+
'card.delete': 'Удалить этот узел',
|
|
977
|
+
'card.deleteTitle': 'Скрыть этот узел и все ветки под ним',
|
|
978
|
+
'card.deleteConfirm': 'Удалить этот узел и все ветки под ним? (обратимо)',
|
|
979
|
+
'card.fullscreen': 'Во весь экран',
|
|
980
|
+
'card.fullscreenTitle': 'Прочитать полный ответ во весь экран',
|
|
981
|
+
'card.unfoldBranch': 'Развернуть эту ветку',
|
|
982
|
+
'card.foldBranch': 'Свернуть эту ветку',
|
|
983
|
+
'card.unfoldDescendants': 'Развернуть {count} потомков',
|
|
984
|
+
'card.foldDescendants': 'Свернуть {count} потомков',
|
|
985
|
+
'card.descendants': 'Потомков: {count}',
|
|
986
|
+
'card.truncated': '\n\n… (откройте на весь экран, чтобы прочитать полный ответ)',
|
|
987
|
+
'card.cost.elapsed': 'заняло {value}',
|
|
988
|
+
'card.cost.context': 'контекст {value}',
|
|
989
|
+
'card.cost.cached': 'кэш {value}',
|
|
990
|
+
'card.think': 'Рассуждения',
|
|
991
|
+
'card.thinkMeta': '{count} симв.',
|
|
992
|
+
'card.thinkTruncated': '(сохранены только последние {count} симв. рассуждений)',
|
|
993
|
+
'live.calling': 'Вызов {tool}',
|
|
994
|
+
'live.outputting': 'Пишет…',
|
|
995
|
+
'live.thinking': 'Думает…',
|
|
996
|
+
'live.starting': 'Запуск…',
|
|
997
|
+
'live.awaiting': 'Ждёт вашего ответа…',
|
|
998
|
+
'live.awaitingApproval': 'Ждёт вашего подтверждения…',
|
|
999
|
+
'live.step': 'шаг {step}',
|
|
1000
|
+
'composer.placeholder': 'Задайте уточнение на этой ветке… (Enter — отправить, Shift+Enter — новая строка)',
|
|
1001
|
+
'composer.label': 'Текст уточнения',
|
|
1002
|
+
'composer.from': 'Начиная с «{question}…»',
|
|
1003
|
+
'composer.cancel': 'Отмена',
|
|
1004
|
+
'composer.send': 'Отправить',
|
|
1005
|
+
'reader.close': 'Закрыть (Esc)',
|
|
1006
|
+
'reader.closeLabel': 'Закрыть режим чтения',
|
|
1007
|
+
'reader.noAnswer': '(ответа пока нет)',
|
|
1008
|
+
'reader.hint': 'Esc или клик по фону, чтобы закрыть',
|
|
1009
|
+
'reader.branch': 'Ветка',
|
|
1010
|
+
'reader.mainline': 'Основная линия',
|
|
1011
|
+
'reader.widthGroup': 'Ширина чтения',
|
|
1012
|
+
'reader.paneGroup': 'Содержимое чтения',
|
|
1013
|
+
'reader.paneAnswer': 'Итоговый ответ',
|
|
1014
|
+
'reader.widthStandard': 'Стандартная',
|
|
1015
|
+
'reader.widthWide': 'Широкая',
|
|
1016
|
+
'error.title': 'Древовидное представление упало',
|
|
1017
|
+
'error.reload': 'Перезагрузить представление',
|
|
1018
|
+
'error.hint': 'Данные холста не потеряны; не удалась только эта отрисовка.',
|
|
1019
|
+
'error.sessionNotOpen': 'Сеанс ещё не открыт, поэтому его нельзя спроецировать.',
|
|
1020
|
+
'error.noBinding': 'Сеанс не вернул привязку.',
|
|
1021
|
+
'error.openFailed': 'Не удалось открыть сеанс: {reason}',
|
|
1022
|
+
'error.forkFailed': 'Не удалось создать ответвление: {reason}',
|
|
1023
|
+
'error.branchUnopenable': 'Не удалось открыть сеанс ветки: {reason}',
|
|
1024
|
+
'error.branchNoBinding': 'Не удалось открыть сеанс ветки: {reason}',
|
|
1025
|
+
'error.branchNoUsableBinding': 'Сеанс ветки не вернул пригодную привязку.',
|
|
1026
|
+
'error.submitFailed': 'Не удалось отправить: {reason}',
|
|
1027
|
+
'error.loadOlderFailed': 'Не удалось загрузить более раннюю историю: {reason}',
|
|
1028
|
+
'view.layoutGroup': 'Направление макета',
|
|
1029
|
+
'view.layoutVertical': 'Сверху вниз',
|
|
1030
|
+
},
|
|
251
1031
|
};
|
|
252
1032
|
|
|
253
1033
|
const localeListeners = new Set();
|
|
254
1034
|
|
|
255
1035
|
/** Look a key up in the built-in table when the locale service is absent. */
|
|
256
1036
|
function fallbackTranslate(key, params) {
|
|
257
|
-
const
|
|
258
|
-
? String(document.documentElement.lang)
|
|
1037
|
+
const raw = typeof document !== 'undefined' && document.documentElement.lang
|
|
1038
|
+
? String(document.documentElement.lang)
|
|
259
1039
|
: 'zh';
|
|
260
|
-
|
|
261
|
-
|
|
1040
|
+
// `pt-BR` and `zh-CN` are the same table as `pt` and `zh`; the region
|
|
1041
|
+
// subtag only matters to the locale service, not to our flat keys.
|
|
1042
|
+
const lang = raw.toLowerCase().split(/[-_]/)[0];
|
|
1043
|
+
const table = DICT[lang] || DICT.en;
|
|
1044
|
+
const template = table[key] ?? DICT.en[key] ?? DICT.zh[key] ?? key;
|
|
262
1045
|
if (!params) return template;
|
|
263
1046
|
return template.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match));
|
|
264
1047
|
}
|
|
@@ -295,11 +1078,334 @@ window.__ModuleLoader__.load({
|
|
|
295
1078
|
return out;
|
|
296
1079
|
}
|
|
297
1080
|
|
|
1081
|
+
/**
|
|
1082
|
+
* The image blocks of one prompt, in content order.
|
|
1083
|
+
*
|
|
1084
|
+
* A prompt's content is an array of blocks, and text is only one kind: an
|
|
1085
|
+
* attachment is a sibling block. Its `attachment` is already the ref the
|
|
1086
|
+
* host's image reader takes, so it is kept as-is.
|
|
1087
|
+
*/
|
|
1088
|
+
function imagesOf(content) {
|
|
1089
|
+
if (!Array.isArray(content)) return [];
|
|
1090
|
+
const images = [];
|
|
1091
|
+
for (const block of content) {
|
|
1092
|
+
if (!block || block.type !== 'image') continue;
|
|
1093
|
+
const ref = block.attachment;
|
|
1094
|
+
if (!ref || !ref.attachmentId || !ref.mediaType) continue;
|
|
1095
|
+
images.push(ref);
|
|
1096
|
+
}
|
|
1097
|
+
return images;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Whether two image lists are the same attachments in the same order.
|
|
1102
|
+
*
|
|
1103
|
+
* Projection runs on every live chunk, and a fresh array per run would
|
|
1104
|
+
* otherwise count as a change and re-persist the whole tree.
|
|
1105
|
+
*/
|
|
1106
|
+
function sameImages(a, b) {
|
|
1107
|
+
if (a === b) return true;
|
|
1108
|
+
if (!a || !b || a.length !== b.length) return false;
|
|
1109
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
1110
|
+
if (a[index].attachmentId !== b[index].attachmentId) return false;
|
|
1111
|
+
}
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
298
1115
|
function seqOf(entry) {
|
|
299
1116
|
const event = entry && entry.event;
|
|
300
1117
|
return event && typeof event.seq === 'number' ? event.seq : 0;
|
|
301
1118
|
}
|
|
302
1119
|
|
|
1120
|
+
// ---------------------------------------------------------------- reasoning
|
|
1121
|
+
// The model writes its thinking as `reasoning` content blocks: live as a
|
|
1122
|
+
// `reasoning-delta` chunk, and settled as a `{ type: 'reasoning', text }`
|
|
1123
|
+
// block inside the durable `assistant/message`. Both reach a client plugin
|
|
1124
|
+
// through the same event window, so one accumulator serves the running tail
|
|
1125
|
+
// and the finished transcript.
|
|
1126
|
+
//
|
|
1127
|
+
// A provider that does not think emits no reasoning at all — the card then
|
|
1128
|
+
// simply has nothing to show, which is why the section is hidden rather
|
|
1129
|
+
// than rendered empty.
|
|
1130
|
+
|
|
1131
|
+
/** The reasoning blocks inside one assistant message, in order. */
|
|
1132
|
+
function reasoningBlocksOfMessage(message) {
|
|
1133
|
+
const content = message && message.content;
|
|
1134
|
+
if (!Array.isArray(content)) return [];
|
|
1135
|
+
const blocks = [];
|
|
1136
|
+
for (const block of content) {
|
|
1137
|
+
if (block && block.type === 'reasoning' && typeof block.text === 'string' && block.text.trim()) {
|
|
1138
|
+
blocks.push(block.text);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
return blocks;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* The key of one reasoning block inside one step.
|
|
1146
|
+
*
|
|
1147
|
+
* The host frames both the live chunks and the settled message with the
|
|
1148
|
+
* same `turn` and `step`, and a step can hold several reasoning blocks
|
|
1149
|
+
* (one per content-block index). The index is part of the key so two
|
|
1150
|
+
* blocks in the same step do not overwrite each other.
|
|
1151
|
+
*/
|
|
1152
|
+
function reasoningKey(turn, step, index) {
|
|
1153
|
+
const base = reasoningStepPrefix(turn, step);
|
|
1154
|
+
return typeof index === 'number' ? base + index : base;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* The prefix every reasoning block of one step shares.
|
|
1159
|
+
*
|
|
1160
|
+
* The trailing separator is what makes the prefix safe: without it, step
|
|
1161
|
+
* `1` of turn `1` would also match step `11` of turn `1`.
|
|
1162
|
+
*/
|
|
1163
|
+
function reasoningStepPrefix(turn, step) {
|
|
1164
|
+
const base = typeof turn === 'number' && typeof step === 'number'
|
|
1165
|
+
? turn + ':' + step + '#'
|
|
1166
|
+
: 'unknown#';
|
|
1167
|
+
return base;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* The cap on how much reasoning a card keeps.
|
|
1172
|
+
*
|
|
1173
|
+
* A long agent turn can think for hundreds of kilobytes. The card shows
|
|
1174
|
+
* the newest thinking, so the cap keeps the *tail*: the oldest paragraphs
|
|
1175
|
+
* are dropped, and the fact that something was dropped is recorded so the
|
|
1176
|
+
* reader knows the text is not the whole story.
|
|
1177
|
+
*
|
|
1178
|
+
* The cap is enforced inside the accumulator rather than at render time,
|
|
1179
|
+
* so a streaming turn never builds a string larger than this.
|
|
1180
|
+
*/
|
|
1181
|
+
const REASONING_LIMIT = 12000;
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* A fresh reasoning accumulator: one segment per reasoning block.
|
|
1185
|
+
*
|
|
1186
|
+
* `received` records how many characters each block ever delivered. The
|
|
1187
|
+
* amount dropped is *derived* from it (`received - kept`) rather than
|
|
1188
|
+
* accumulated as a counter: a block is trimmed more than once in normal
|
|
1189
|
+
* use — once while it streams, again when its settled block replaces the
|
|
1190
|
+
* streamed draft — so a running counter would report the same characters
|
|
1191
|
+
* as dropped twice, and would keep claiming a loss after a settled block
|
|
1192
|
+
* replaced a long draft with a short one.
|
|
1193
|
+
*/
|
|
1194
|
+
function reasoningState() {
|
|
1195
|
+
return { segments: new Map(), received: new Map() };
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Count the bytes of a streamed fragment as arrived.
|
|
1200
|
+
*
|
|
1201
|
+
* This must be an addition, not a maximum of the kept length: the trim
|
|
1202
|
+
* cuts the fragment back off immediately, so `kept` plateaus at the cap
|
|
1203
|
+
* and a "max kept" would report one chunk's worth of loss for a turn that
|
|
1204
|
+
* actually dropped tens of kilobytes.
|
|
1205
|
+
*/
|
|
1206
|
+
function addReceived(state, key, length) {
|
|
1207
|
+
state.received.set(key, (state.received.get(key) || 0) + length);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* The two reasoning fields a card needs: the kept text, and how much the
|
|
1212
|
+
* cap dropped. Keeping them separate lets a collapsed row admit that the
|
|
1213
|
+
* text is partial without gluing a notice onto the reasoning itself.
|
|
1214
|
+
*/
|
|
1215
|
+
function reasoningFieldsOf(state) {
|
|
1216
|
+
return {
|
|
1217
|
+
reasoning: reasoningTextOf(state),
|
|
1218
|
+
reasoningDropped: droppedReasoningOf(state),
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/** Whether a chunk belongs to the model's reasoning. */
|
|
1223
|
+
function isReasoningChunk(chunk) {
|
|
1224
|
+
if (!chunk) return false;
|
|
1225
|
+
if (chunk.type === 'reasoning-delta') return true;
|
|
1226
|
+
if (chunk.type === 'block-end') return Boolean(chunk.block && chunk.block.type === 'reasoning');
|
|
1227
|
+
if (chunk.type === 'block-start') return chunk.blockType === 'reasoning';
|
|
1228
|
+
return false;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Fold one live chunk into a reasoning accumulator.
|
|
1233
|
+
*
|
|
1234
|
+
* `reasoning-delta` appends to the block's segment; `block-end` replaces it
|
|
1235
|
+
* with the block the host settled.
|
|
1236
|
+
*/
|
|
1237
|
+
function applyReasoningChunk(state, chunk, turn, step) {
|
|
1238
|
+
if (!chunk) return state;
|
|
1239
|
+
const index = typeof chunk.index === 'number' ? chunk.index : undefined;
|
|
1240
|
+
const key = reasoningKey(turn, step, index);
|
|
1241
|
+
if (chunk.type === 'reasoning-delta' && typeof chunk.text === 'string') {
|
|
1242
|
+
const previous = state.segments.get(key);
|
|
1243
|
+
state.segments.set(key, (previous || '') + chunk.text);
|
|
1244
|
+
// Bytes arrived, however much the trim keeps of them.
|
|
1245
|
+
addReceived(state, key, chunk.text.length);
|
|
1246
|
+
trimReasoning(state);
|
|
1247
|
+
return state;
|
|
1248
|
+
}
|
|
1249
|
+
if (chunk.type === 'block-end' && chunk.block && chunk.block.type === 'reasoning'
|
|
1250
|
+
&& typeof chunk.block.text === 'string' && chunk.block.text.trim()) {
|
|
1251
|
+
// The settled block is the authoritative full text of this block, so
|
|
1252
|
+
// it replaces both the streamed draft and its arrived-bytes tally.
|
|
1253
|
+
// An empty block says nothing and must not wipe what arrived.
|
|
1254
|
+
state.segments.set(key, chunk.block.text);
|
|
1255
|
+
state.received.set(key, chunk.block.text.length);
|
|
1256
|
+
trimReasoning(state);
|
|
1257
|
+
return state;
|
|
1258
|
+
}
|
|
1259
|
+
if (chunk.type === 'block-start' && chunk.blockType === 'reasoning') {
|
|
1260
|
+
if (!state.segments.has(key)) state.segments.set(key, '');
|
|
1261
|
+
}
|
|
1262
|
+
return state;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Merge one settled step's reasoning into the accumulator.
|
|
1267
|
+
*
|
|
1268
|
+
* The settled blocks are that step's complete thinking, so they replace
|
|
1269
|
+
* what was streamed for the step instead of being appended to it.
|
|
1270
|
+
* Transient chunks are retired when the step settles, so the durable
|
|
1271
|
+
* message is the only reliable source once it has landed.
|
|
1272
|
+
*/
|
|
1273
|
+
function mergeSettledReasoning(state, blocks, turn, step) {
|
|
1274
|
+
if (!Array.isArray(blocks) || !blocks.length) return state;
|
|
1275
|
+
// Replace the whole step: the settled blocks are the step's final
|
|
1276
|
+
// thinking, and the streamed draft for them is gone by now. The
|
|
1277
|
+
// `received` marks go with them, so a short settled block does not
|
|
1278
|
+
// inherit the draft's dropped-chars claim.
|
|
1279
|
+
const prefix = reasoningStepPrefix(turn, step);
|
|
1280
|
+
for (const key of [...state.segments.keys()]) {
|
|
1281
|
+
if (key.startsWith(prefix)) state.segments.delete(key);
|
|
1282
|
+
}
|
|
1283
|
+
for (const key of [...state.received.keys()]) {
|
|
1284
|
+
if (key.startsWith(prefix)) state.received.delete(key);
|
|
1285
|
+
}
|
|
1286
|
+
blocks.forEach((text, index) => {
|
|
1287
|
+
if (typeof text !== 'string' || !text.trim()) return;
|
|
1288
|
+
const key = reasoningKey(turn, step, index);
|
|
1289
|
+
state.segments.set(key, text);
|
|
1290
|
+
// The settled block is the truth for this block, so it replaces the
|
|
1291
|
+
// streamed tally rather than adding to it.
|
|
1292
|
+
state.received.set(key, text.length);
|
|
1293
|
+
});
|
|
1294
|
+
trimReasoning(state);
|
|
1295
|
+
return state;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Drop the reasoning of a retried step.
|
|
1300
|
+
*
|
|
1301
|
+
* A retry reuses the same turn and step, so the failed attempt's thinking
|
|
1302
|
+
* would otherwise be concatenated with the successful one. The attempt
|
|
1303
|
+
* that is about to run starts from a clean slate, which is what the
|
|
1304
|
+
* official Trajectory view does too.
|
|
1305
|
+
*/
|
|
1306
|
+
function resetStepReasoning(state, turn, step) {
|
|
1307
|
+
if (!state) return state;
|
|
1308
|
+
const prefix = reasoningStepPrefix(turn, step);
|
|
1309
|
+
for (const key of [...state.segments.keys()]) {
|
|
1310
|
+
if (key.startsWith(prefix)) state.segments.delete(key);
|
|
1311
|
+
}
|
|
1312
|
+
for (const key of [...state.received.keys()]) {
|
|
1313
|
+
if (key.startsWith(prefix)) state.received.delete(key);
|
|
1314
|
+
}
|
|
1315
|
+
return state;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Drop the oldest reasoning until the accumulator fits the cap.
|
|
1320
|
+
*
|
|
1321
|
+
* The oldest block goes first: the reader cares about what the agent is
|
|
1322
|
+
* doing now, and the newest blocks are the ones still in play. Trimming
|
|
1323
|
+
* only shortens the kept text — how much was dropped is derived later
|
|
1324
|
+
* from `received`, so trimming twice never double-counts.
|
|
1325
|
+
*/
|
|
1326
|
+
function trimReasoning(state) {
|
|
1327
|
+
let total = 0;
|
|
1328
|
+
for (const text of state.segments.values()) total += text.length;
|
|
1329
|
+
if (total <= REASONING_LIMIT) return;
|
|
1330
|
+
for (const [key, text] of state.segments) {
|
|
1331
|
+
if (total <= REASONING_LIMIT) break;
|
|
1332
|
+
const excess = total - REASONING_LIMIT;
|
|
1333
|
+
const cut = Math.min(text.length, excess);
|
|
1334
|
+
if (cut <= 0) continue;
|
|
1335
|
+
state.segments.set(key, text.slice(cut));
|
|
1336
|
+
total -= cut;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/** How many characters the cap has dropped, derived from what arrived. */
|
|
1341
|
+
function droppedReasoningOf(state) {
|
|
1342
|
+
if (!state || !state.segments || !state.received) return 0;
|
|
1343
|
+
let dropped = 0;
|
|
1344
|
+
for (const [key, text] of state.segments) {
|
|
1345
|
+
const received = state.received.get(key) || text.length;
|
|
1346
|
+
if (received > text.length) dropped += received - text.length;
|
|
1347
|
+
}
|
|
1348
|
+
return dropped;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* The accumulated reasoning, one block's thinking per paragraph group.
|
|
1353
|
+
*
|
|
1354
|
+
* The dropped-chars count is *not* baked into this string: the card needs
|
|
1355
|
+
* it as metadata so a collapsed row can still say the text is partial,
|
|
1356
|
+
* and the reader wants the reasoning itself, not a notice glued to it.
|
|
1357
|
+
*/
|
|
1358
|
+
function reasoningTextOf(state) {
|
|
1359
|
+
if (!state || !state.segments) return '';
|
|
1360
|
+
const parts = [];
|
|
1361
|
+
for (const text of state.segments.values()) {
|
|
1362
|
+
if (text && text.trim()) parts.push(text);
|
|
1363
|
+
}
|
|
1364
|
+
return parts.join('\n\n');
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* The newest thing the model wrote, in one line.
|
|
1369
|
+
*
|
|
1370
|
+
* While a branch runs this is the only honest answer to "what is it
|
|
1371
|
+
* doing right now": the most recent line of its thinking, not a summary
|
|
1372
|
+
* of a paragraph it started a while ago.
|
|
1373
|
+
*/
|
|
1374
|
+
function reasoningTail(text) {
|
|
1375
|
+
if (!text) return '';
|
|
1376
|
+
const lines = String(text).split(/\r?\n/);
|
|
1377
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
1378
|
+
const trimmed = lines[index].trim();
|
|
1379
|
+
if (!trimmed) continue;
|
|
1380
|
+
return trimmed.replace(/\*\*/g, '').slice(0, 200);
|
|
1381
|
+
}
|
|
1382
|
+
return '';
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* What one node has to read, as one value.
|
|
1387
|
+
*
|
|
1388
|
+
* The card and the reader are two sizes of the same document, so they must
|
|
1389
|
+
* agree about what the node holds; deriving that in one place is also what
|
|
1390
|
+
* stops an enlarge affordance from promising a body the node cannot fill.
|
|
1391
|
+
* `kind` is computed from the node's own content and is never passed in.
|
|
1392
|
+
*
|
|
1393
|
+
* 'none' nothing written yet
|
|
1394
|
+
* 'reasoning' a chain of thinking and no answer yet
|
|
1395
|
+
* 'result' an answer, which may or may not have a chain behind it
|
|
1396
|
+
*/
|
|
1397
|
+
function readingOf(node) {
|
|
1398
|
+
const answer = (node && node.answer) || '';
|
|
1399
|
+
const reasoning = (node && node.reasoning) || '';
|
|
1400
|
+
const hasReasoning = reasoning.trim().length > 0;
|
|
1401
|
+
return {
|
|
1402
|
+
kind: answer.trim() ? 'result' : hasReasoning ? 'reasoning' : 'none',
|
|
1403
|
+
hasReasoning,
|
|
1404
|
+
reasoningChars: reasoning.trim().length,
|
|
1405
|
+
dropped: (node && node.reasoningDropped) || 0,
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
|
|
303
1409
|
function maxDurableSeq(entries) {
|
|
304
1410
|
let max = 0;
|
|
305
1411
|
for (const entry of entries) {
|
|
@@ -415,6 +1521,9 @@ window.__ModuleLoader__.load({
|
|
|
415
1521
|
function projectTurns(entries, sessionRunning) {
|
|
416
1522
|
const turns = [];
|
|
417
1523
|
let current = null;
|
|
1524
|
+
// Reasoning is accumulated across the whole turn: a turn is one user
|
|
1525
|
+
// question and the model may think in several steps before answering.
|
|
1526
|
+
let reasoning = reasoningState();
|
|
418
1527
|
for (let index = 0; index < entries.length; index += 1) {
|
|
419
1528
|
const entry = entries[index];
|
|
420
1529
|
if (!entry || !entry.event) continue;
|
|
@@ -428,6 +1537,13 @@ window.__ModuleLoader__.load({
|
|
|
428
1537
|
if (chunk && chunk.type === 'text-delta' && typeof chunk.text === 'string') {
|
|
429
1538
|
current.streamText = (current.streamText || '') + chunk.text;
|
|
430
1539
|
current.answer = current.streamText;
|
|
1540
|
+
} else if (chunk && isReasoningChunk(chunk)) {
|
|
1541
|
+
// Only reasoning chunks touch the reasoning text: a text or
|
|
1542
|
+
// tool-call token must not rebuild a multi-kilobyte string.
|
|
1543
|
+
// The host frames a chunk with the same turn/step as the
|
|
1544
|
+
// message that will settle it.
|
|
1545
|
+
applyReasoningChunk(reasoning, chunk, data.turn, data.step);
|
|
1546
|
+
Object.assign(current, reasoningFieldsOf(reasoning));
|
|
431
1547
|
}
|
|
432
1548
|
}
|
|
433
1549
|
continue;
|
|
@@ -435,14 +1551,21 @@ window.__ModuleLoader__.load({
|
|
|
435
1551
|
if (entry.type !== 'event') continue;
|
|
436
1552
|
if (event.type === 'turn/start') {
|
|
437
1553
|
current = {
|
|
438
|
-
question: '', answer: '', answerSeq: 0, qSeq: 0, status: 'running',
|
|
1554
|
+
question: '', images: [], answer: '', answerSeq: 0, qSeq: 0, status: 'running',
|
|
439
1555
|
real: false, kind: '', costFrom: index, streamText: '',
|
|
440
1556
|
step: 0, tool: '', startedAt: typeof event.time === 'number' ? event.time : 0,
|
|
441
1557
|
awaiting: '', pendingQuestions: new Set(), pendingApprovals: new Set(),
|
|
1558
|
+
reasoning: '',
|
|
442
1559
|
};
|
|
1560
|
+
reasoning = reasoningState();
|
|
443
1561
|
turns.push(current);
|
|
444
1562
|
} else if (event.type === 'step/start') {
|
|
445
1563
|
if (current) current.step = typeof data.step === 'number' ? data.step : current.step + 1;
|
|
1564
|
+
} else if (event.type === 'llm/retry' || event.type === 'llm/retry-started') {
|
|
1565
|
+
// A retry reuses the same turn and step, so the failed attempt's
|
|
1566
|
+
// thinking has to go before the new attempt's arrives.
|
|
1567
|
+
resetStepReasoning(reasoning, data.turn, data.step);
|
|
1568
|
+
if (current) Object.assign(current, reasoningFieldsOf(reasoning));
|
|
446
1569
|
} else if (event.type === 'tool/call') {
|
|
447
1570
|
if (current) {
|
|
448
1571
|
if (data.name) current.tool = String(data.name);
|
|
@@ -470,11 +1593,15 @@ window.__ModuleLoader__.load({
|
|
|
470
1593
|
const target = current || turns[turns.length - 1];
|
|
471
1594
|
if (target) {
|
|
472
1595
|
const text = textOf(data.content);
|
|
473
|
-
|
|
1596
|
+
const images = imagesOf(data.content);
|
|
1597
|
+
// A prompt that is only an image is still a prompt: the card would
|
|
1598
|
+
// otherwise stay empty while the answer arrives under it.
|
|
1599
|
+
if ((text.trim() || images.length) && isRealPrompt(data)) {
|
|
474
1600
|
const kind = sourceKindOf(data) || '';
|
|
475
1601
|
target.question = kind === 'user-question-reply'
|
|
476
1602
|
? (questionReplyTextOf(data) || T('card.questionReply'))
|
|
477
1603
|
: text;
|
|
1604
|
+
target.images = images;
|
|
478
1605
|
target.real = true;
|
|
479
1606
|
target.kind = kind;
|
|
480
1607
|
target.qSeq = typeof event.seq === 'number' ? event.seq : 0;
|
|
@@ -488,6 +1615,12 @@ window.__ModuleLoader__.load({
|
|
|
488
1615
|
target.answer = text;
|
|
489
1616
|
target.streamText = text;
|
|
490
1617
|
}
|
|
1618
|
+
// The settled message carries the step's reasoning blocks.
|
|
1619
|
+
const settled = reasoningBlocksOfMessage(data.message);
|
|
1620
|
+
if (settled.length) {
|
|
1621
|
+
mergeSettledReasoning(reasoning, settled, data.turn, data.step);
|
|
1622
|
+
Object.assign(target, reasoningFieldsOf(reasoning));
|
|
1623
|
+
}
|
|
491
1624
|
target.answerSeq = typeof event.seq === 'number' ? event.seq : target.answerSeq;
|
|
492
1625
|
}
|
|
493
1626
|
} else if (event.type === 'turn/end') {
|
|
@@ -525,7 +1658,7 @@ window.__ModuleLoader__.load({
|
|
|
525
1658
|
delete turn.pendingQuestions;
|
|
526
1659
|
delete turn.pendingApprovals;
|
|
527
1660
|
}
|
|
528
|
-
return turns.filter((turn) => turn.real && (turn.question.trim() || turn.answer.trim()));
|
|
1661
|
+
return turns.filter((turn) => turn.real && (turn.question.trim() || turn.answer.trim() || turn.images.length));
|
|
529
1662
|
}
|
|
530
1663
|
|
|
531
1664
|
/** Read one branch session's own events (everything after `baseline`). */
|
|
@@ -539,14 +1672,18 @@ window.__ModuleLoader__.load({
|
|
|
539
1672
|
let startedAt = 0;
|
|
540
1673
|
const pendingQuestions = new Set();
|
|
541
1674
|
const pendingApprovals = new Set();
|
|
1675
|
+
// A branch reasons over its own steps, exactly like the mainline.
|
|
1676
|
+
const reasoning = reasoningState();
|
|
542
1677
|
const cost = turnCost(entries, baseline);
|
|
543
1678
|
for (const entry of entries) {
|
|
544
1679
|
const event = entry && entry.event;
|
|
545
1680
|
if (!event) continue;
|
|
546
1681
|
if (entry.type === 'transient') {
|
|
547
1682
|
if (event.type === 'assistant/live-chunk' && seqOf(entry) > baseline) {
|
|
548
|
-
const
|
|
1683
|
+
const data = event.data || {};
|
|
1684
|
+
const chunk = data.chunk;
|
|
549
1685
|
if (chunk && chunk.type === 'text-delta' && typeof chunk.text === 'string') text += chunk.text;
|
|
1686
|
+
else if (isReasoningChunk(chunk)) applyReasoningChunk(reasoning, chunk, data.turn, data.step);
|
|
550
1687
|
}
|
|
551
1688
|
continue;
|
|
552
1689
|
}
|
|
@@ -562,6 +1699,11 @@ window.__ModuleLoader__.load({
|
|
|
562
1699
|
} else if (event.type === 'step/start') {
|
|
563
1700
|
const data = event.data || {};
|
|
564
1701
|
step = typeof data.step === 'number' ? data.step : step + 1;
|
|
1702
|
+
} else if (event.type === 'llm/retry' || event.type === 'llm/retry-started') {
|
|
1703
|
+
// A retry reuses the same turn and step, so the failed attempt's
|
|
1704
|
+
// thinking has to go before the new attempt's arrives.
|
|
1705
|
+
const data = event.data || {};
|
|
1706
|
+
resetStepReasoning(reasoning, data.turn, data.step);
|
|
565
1707
|
} else if (event.type === 'tool/call') {
|
|
566
1708
|
const data = event.data || {};
|
|
567
1709
|
if (data.name) tool = String(data.name);
|
|
@@ -586,6 +1728,8 @@ window.__ModuleLoader__.load({
|
|
|
586
1728
|
answer = finalText;
|
|
587
1729
|
text = finalText;
|
|
588
1730
|
}
|
|
1731
|
+
const settled = reasoningBlocksOfMessage(data.message);
|
|
1732
|
+
if (settled.length) mergeSettledReasoning(reasoning, settled, data.turn, data.step);
|
|
589
1733
|
}
|
|
590
1734
|
answerSeq = seq;
|
|
591
1735
|
} else if (event.type === 'turn/end') {
|
|
@@ -596,7 +1740,10 @@ window.__ModuleLoader__.load({
|
|
|
596
1740
|
}
|
|
597
1741
|
}
|
|
598
1742
|
const awaiting = ended ? '' : (pendingQuestions.size ? 'question' : pendingApprovals.size ? 'approval' : '');
|
|
599
|
-
return {
|
|
1743
|
+
return {
|
|
1744
|
+
text, answer, answerSeq, ended, cost, step, tool, startedAt, awaiting,
|
|
1745
|
+
...reasoningFieldsOf(reasoning),
|
|
1746
|
+
};
|
|
600
1747
|
}
|
|
601
1748
|
|
|
602
1749
|
// ----------------------------------------------------------------- layout
|
|
@@ -769,13 +1916,72 @@ window.__ModuleLoader__.load({
|
|
|
769
1916
|
return result;
|
|
770
1917
|
}
|
|
771
1918
|
|
|
772
|
-
function layoutTree(nodes, collapsed, heights) {
|
|
1919
|
+
function layoutTree(nodes, collapsed, heights, direction, cardWidth) {
|
|
1920
|
+
// Cards can be sized by the user; geometry follows the width they chose.
|
|
1921
|
+
const cardW = Number.isFinite(cardWidth) && cardWidth > 0 ? cardWidth : NODE_W;
|
|
773
1922
|
const childrenOf = childrenMapOf(nodes);
|
|
774
1923
|
const kids = (node) => (collapsed[node.id] ? [] : childrenOf.get(node.id) || []);
|
|
775
1924
|
const roots = childrenOf.get('@root') || [];
|
|
776
|
-
const widths = new Map();
|
|
777
1925
|
const depthOf = depthMapOf(nodes);
|
|
778
1926
|
|
|
1927
|
+
if (direction === 'horizontal') {
|
|
1928
|
+
const spans = new Map();
|
|
1929
|
+
const positions = new Map();
|
|
1930
|
+
const edges = [];
|
|
1931
|
+
const heightOf = (node) => heights[node.id] || NODE_H;
|
|
1932
|
+
function measure(node) {
|
|
1933
|
+
const list = kids(node);
|
|
1934
|
+
const childSpan = list.reduce((total, child, index) => total + measure(child) + (index ? GAP_X : 0), 0);
|
|
1935
|
+
const span = Math.max(heightOf(node), childSpan);
|
|
1936
|
+
spans.set(node.id, span);
|
|
1937
|
+
return span;
|
|
1938
|
+
}
|
|
1939
|
+
function place(node, top) {
|
|
1940
|
+
const list = kids(node);
|
|
1941
|
+
const ownHeight = heightOf(node);
|
|
1942
|
+
const span = spans.get(node.id);
|
|
1943
|
+
const childSpan = list.reduce((total, child, index) => total + spans.get(child.id) + (index ? GAP_X : 0), 0);
|
|
1944
|
+
let cursor = top + (span - childSpan) / 2;
|
|
1945
|
+
for (const child of list) {
|
|
1946
|
+
place(child, cursor);
|
|
1947
|
+
cursor += spans.get(child.id) + GAP_X;
|
|
1948
|
+
}
|
|
1949
|
+
let center = top + span / 2;
|
|
1950
|
+
if (list.length) {
|
|
1951
|
+
const first = list[0];
|
|
1952
|
+
const last = list[list.length - 1];
|
|
1953
|
+
center = (positions.get(first.id).y + heightOf(first) / 2 + positions.get(last.id).y + heightOf(last) / 2) / 2;
|
|
1954
|
+
}
|
|
1955
|
+
const y = Math.max(top, Math.min(top + span - ownHeight, center - ownHeight / 2));
|
|
1956
|
+
positions.set(node.id, { x: (depthOf.get(node.id) || 0) * (cardW + GAP_Y), y });
|
|
1957
|
+
}
|
|
1958
|
+
let top = 0;
|
|
1959
|
+
for (const root of roots) {
|
|
1960
|
+
measure(root);
|
|
1961
|
+
place(root, top);
|
|
1962
|
+
top += spans.get(root.id) + GAP_X * 2;
|
|
1963
|
+
}
|
|
1964
|
+
let maxX = 0;
|
|
1965
|
+
let maxY = 0;
|
|
1966
|
+
for (const node of nodes) {
|
|
1967
|
+
const pos = positions.get(node.id);
|
|
1968
|
+
if (!pos) continue;
|
|
1969
|
+
const height = heightOf(node);
|
|
1970
|
+
maxX = Math.max(maxX, pos.x + cardW);
|
|
1971
|
+
maxY = Math.max(maxY, pos.y + height);
|
|
1972
|
+
for (const child of kids(node)) {
|
|
1973
|
+
const childPos = positions.get(child.id);
|
|
1974
|
+
if (childPos) edges.push({
|
|
1975
|
+
id: node.id + '>' + child.id,
|
|
1976
|
+
x1: pos.x + cardW, y1: pos.y + height / 2,
|
|
1977
|
+
x2: childPos.x, y2: childPos.y + heightOf(child) / 2,
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
return { positions, edges, width: maxX, height: maxY, roots };
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
const widths = new Map();
|
|
779
1985
|
const rowHeight = [];
|
|
780
1986
|
for (const node of nodes) {
|
|
781
1987
|
const depth = depthOf.get(node.id);
|
|
@@ -792,14 +1998,14 @@ window.__ModuleLoader__.load({
|
|
|
792
1998
|
function measure(node) {
|
|
793
1999
|
const list = kids(node);
|
|
794
2000
|
if (list.length === 0) {
|
|
795
|
-
widths.set(node.id,
|
|
796
|
-
return
|
|
2001
|
+
widths.set(node.id, cardW);
|
|
2002
|
+
return cardW;
|
|
797
2003
|
}
|
|
798
2004
|
let total = 0;
|
|
799
2005
|
list.forEach((child, index) => {
|
|
800
2006
|
total += measure(child) + (index > 0 ? GAP_X : 0);
|
|
801
2007
|
});
|
|
802
|
-
const width = Math.max(
|
|
2008
|
+
const width = Math.max(cardW, total);
|
|
803
2009
|
widths.set(node.id, width);
|
|
804
2010
|
return width;
|
|
805
2011
|
}
|
|
@@ -810,7 +2016,7 @@ window.__ModuleLoader__.load({
|
|
|
810
2016
|
const list = kids(node);
|
|
811
2017
|
const depth = depthOf.get(node.id) || 0;
|
|
812
2018
|
if (list.length === 0) {
|
|
813
|
-
positions.set(node.id, { x: left + (widths.get(node.id) -
|
|
2019
|
+
positions.set(node.id, { x: left + (widths.get(node.id) - cardW) / 2, y: rowTop[depth] || 0 });
|
|
814
2020
|
return;
|
|
815
2021
|
}
|
|
816
2022
|
let cursor = left;
|
|
@@ -818,9 +2024,9 @@ window.__ModuleLoader__.load({
|
|
|
818
2024
|
place(child, cursor);
|
|
819
2025
|
cursor += widths.get(child.id) + GAP_X;
|
|
820
2026
|
}
|
|
821
|
-
const first = positions.get(list[0].id).x +
|
|
822
|
-
const last = positions.get(list[list.length - 1].id).x +
|
|
823
|
-
positions.set(node.id, { x: (first + last) / 2 -
|
|
2027
|
+
const first = positions.get(list[0].id).x + cardW / 2;
|
|
2028
|
+
const last = positions.get(list[list.length - 1].id).x + cardW / 2;
|
|
2029
|
+
positions.set(node.id, { x: (first + last) / 2 - cardW / 2, y: rowTop[depth] || 0 });
|
|
824
2030
|
}
|
|
825
2031
|
|
|
826
2032
|
let x = 0;
|
|
@@ -840,9 +2046,9 @@ window.__ModuleLoader__.load({
|
|
|
840
2046
|
if (!kidPos) continue;
|
|
841
2047
|
edges.push({
|
|
842
2048
|
id: node.id + '>' + kidNode.id,
|
|
843
|
-
x1: parentPos.x +
|
|
2049
|
+
x1: parentPos.x + cardW / 2,
|
|
844
2050
|
y1: parentPos.y + parentHeight,
|
|
845
|
-
x2: kidPos.x +
|
|
2051
|
+
x2: kidPos.x + cardW / 2,
|
|
846
2052
|
y2: kidPos.y,
|
|
847
2053
|
});
|
|
848
2054
|
}
|
|
@@ -851,7 +2057,7 @@ window.__ModuleLoader__.load({
|
|
|
851
2057
|
let maxX = 0;
|
|
852
2058
|
let maxY = 0;
|
|
853
2059
|
for (const [id, pos] of positions) {
|
|
854
|
-
maxX = Math.max(maxX, pos.x +
|
|
2060
|
+
maxX = Math.max(maxX, pos.x + cardW);
|
|
855
2061
|
maxY = Math.max(maxY, pos.y + (heights[id] || NODE_H));
|
|
856
2062
|
}
|
|
857
2063
|
for (const node of nodes) {
|
|
@@ -916,9 +2122,22 @@ window.__ModuleLoader__.load({
|
|
|
916
2122
|
// only masks it and its subtree here.
|
|
917
2123
|
hidden: {},
|
|
918
2124
|
archived: [],
|
|
2125
|
+
// Branch sessions this tree put into DSH's archive so the workspace
|
|
2126
|
+
// list stays readable. Kept apart from `archived` (which is owned by
|
|
2127
|
+
// deletion/restore): restoring a deleted node must not surface a
|
|
2128
|
+
// session the branch policy deliberately quieted.
|
|
2129
|
+
quieted: [],
|
|
2130
|
+
// The tree's copy of the branch-row policy. The preference itself is
|
|
2131
|
+
// persisted globally; keeping the effective value here means a blocked
|
|
2132
|
+
// localStorage cannot make the toolbar and the turn-end hook disagree.
|
|
2133
|
+
branchMode: readBranchMode(),
|
|
919
2134
|
selectedId: null,
|
|
920
2135
|
composingId: null,
|
|
921
|
-
|
|
2136
|
+
// The enlarged card: which node is open and which of its two bodies is
|
|
2137
|
+
// on screen. One value rather than a boolean beside an id, so "a node
|
|
2138
|
+
// with no pane" and "a pane with no node" cannot be represented — and
|
|
2139
|
+
// a caller cannot ask for a body the node has not written.
|
|
2140
|
+
reading: null,
|
|
922
2141
|
draft: '',
|
|
923
2142
|
loaded: false,
|
|
924
2143
|
error: null,
|
|
@@ -936,6 +2155,7 @@ window.__ModuleLoader__.load({
|
|
|
936
2155
|
if (saved.collapsed && typeof saved.collapsed === 'object') state.collapsed = saved.collapsed;
|
|
937
2156
|
if (saved.hidden && typeof saved.hidden === 'object') state.hidden = saved.hidden;
|
|
938
2157
|
if (Array.isArray(saved.archived)) state.archived = saved.archived;
|
|
2158
|
+
if (Array.isArray(saved.quieted)) state.quieted = saved.quieted;
|
|
939
2159
|
}
|
|
940
2160
|
} catch (error) {
|
|
941
2161
|
/* ignore corrupt state */
|
|
@@ -944,11 +2164,24 @@ window.__ModuleLoader__.load({
|
|
|
944
2164
|
function writeNow() {
|
|
945
2165
|
try {
|
|
946
2166
|
const payload = {
|
|
2167
|
+
// Reasoning is deliberately NOT persisted here.
|
|
2168
|
+
//
|
|
2169
|
+
// Two reasons. It is re-derived from the session log on every
|
|
2170
|
+
// projection, so a copy here only duplicates bytes. And it is the
|
|
2171
|
+
// one field that can reach tens of kilobytes per node, which is
|
|
2172
|
+
// exactly what would push this snapshot into the localStorage
|
|
2173
|
+
// quota — and this snapshot also holds the parent links, which
|
|
2174
|
+
// are the only thing here that *cannot* be rebuilt. Losing those
|
|
2175
|
+
// flattens the tree, so the large derivable field gives way.
|
|
947
2176
|
nodes: state.nodes.map((node) => ({
|
|
948
2177
|
id: node.id,
|
|
949
2178
|
parentId: node.parentId,
|
|
950
2179
|
sessionId: node.sessionId,
|
|
951
2180
|
question: node.question,
|
|
2181
|
+
// Small refs, not the bytes: unlike reasoning this is not the
|
|
2182
|
+
// quota risk, and a restored card keeps its thumbnails before
|
|
2183
|
+
// the log page that holds them has loaded.
|
|
2184
|
+
images: node.images || [],
|
|
952
2185
|
answer: node.answer,
|
|
953
2186
|
status: node.status,
|
|
954
2187
|
answerSeq: node.answerSeq,
|
|
@@ -962,6 +2195,8 @@ window.__ModuleLoader__.load({
|
|
|
962
2195
|
collapsed: state.collapsed,
|
|
963
2196
|
hidden: state.hidden,
|
|
964
2197
|
archived: state.archived,
|
|
2198
|
+
quieted: state.quieted,
|
|
2199
|
+
branchMode: state.branchMode,
|
|
965
2200
|
};
|
|
966
2201
|
window.localStorage.setItem(STORE_PREFIX + rootId, JSON.stringify(payload));
|
|
967
2202
|
} catch (error) {
|
|
@@ -1033,7 +2268,10 @@ window.__ModuleLoader__.load({
|
|
|
1033
2268
|
parentId,
|
|
1034
2269
|
sessionId: rootId,
|
|
1035
2270
|
question: turn.question,
|
|
2271
|
+
images: turn.images || [],
|
|
1036
2272
|
answer: turn.answer,
|
|
2273
|
+
reasoning: turn.reasoning || '',
|
|
2274
|
+
reasoningDropped: turn.reasoningDropped || 0,
|
|
1037
2275
|
status: turn.status,
|
|
1038
2276
|
answerSeq: turn.answerSeq,
|
|
1039
2277
|
kind: 'root',
|
|
@@ -1050,7 +2288,10 @@ window.__ModuleLoader__.load({
|
|
|
1050
2288
|
} else if (
|
|
1051
2289
|
existing.parentId !== next.parentId ||
|
|
1052
2290
|
existing.question !== next.question ||
|
|
2291
|
+
!sameImages(existing.images, next.images) ||
|
|
1053
2292
|
existing.answer !== next.answer ||
|
|
2293
|
+
(existing.reasoning || '') !== next.reasoning ||
|
|
2294
|
+
(existing.reasoningDropped || 0) !== next.reasoningDropped ||
|
|
1054
2295
|
existing.answerSeq !== next.answerSeq ||
|
|
1055
2296
|
existing.status !== next.status ||
|
|
1056
2297
|
(existing.awaiting || '') !== next.awaiting ||
|
|
@@ -1122,12 +2363,31 @@ window.__ModuleLoader__.load({
|
|
|
1122
2363
|
state.selectedId = id;
|
|
1123
2364
|
emit();
|
|
1124
2365
|
},
|
|
2366
|
+
/**
|
|
2367
|
+
* Open the enlarged card on the body this node can actually fill.
|
|
2368
|
+
*
|
|
2369
|
+
* It takes no option for the body: the card must not be able to ask
|
|
2370
|
+
* for a mode, or the several affordances that open it drift apart
|
|
2371
|
+
* again — which is exactly how "read" and "read the reasoning" became
|
|
2372
|
+
* two different buttons on one card.
|
|
2373
|
+
*/
|
|
1125
2374
|
openReader(id) {
|
|
1126
|
-
state.
|
|
2375
|
+
const node = state.nodes.find((candidate) => candidate.id === id);
|
|
2376
|
+
if (!node) return;
|
|
2377
|
+
state.reading = { nodeId: id, pane: readingOf(node).kind === 'reasoning' ? 'reasoning' : 'result' };
|
|
2378
|
+
emit();
|
|
2379
|
+
},
|
|
2380
|
+
setReaderPane(pane) {
|
|
2381
|
+
if (!state.reading) return;
|
|
2382
|
+
const node = state.nodes.find((candidate) => candidate.id === state.reading.nodeId);
|
|
2383
|
+
// A body the node has not written is not a pane: refuse it here
|
|
2384
|
+
// rather than render an empty document under a pressed segment.
|
|
2385
|
+
if (pane === 'reasoning' && !readingOf(node).hasReasoning) return;
|
|
2386
|
+
state.reading = { ...state.reading, pane: pane === 'reasoning' ? 'reasoning' : 'result' };
|
|
1127
2387
|
emit();
|
|
1128
2388
|
},
|
|
1129
2389
|
closeReader() {
|
|
1130
|
-
state.
|
|
2390
|
+
state.reading = null;
|
|
1131
2391
|
emit();
|
|
1132
2392
|
},
|
|
1133
2393
|
toggleCollapse(id) {
|
|
@@ -1161,6 +2421,21 @@ window.__ModuleLoader__.load({
|
|
|
1161
2421
|
persist();
|
|
1162
2422
|
emit();
|
|
1163
2423
|
},
|
|
2424
|
+
setQuieted(ids) {
|
|
2425
|
+
state.quieted = Array.isArray(ids) ? ids.slice() : [];
|
|
2426
|
+
persist();
|
|
2427
|
+
emit();
|
|
2428
|
+
},
|
|
2429
|
+
setBranchMode(mode) {
|
|
2430
|
+
state.branchMode = mode === 'quiet' ? 'quiet' : 'listed';
|
|
2431
|
+
persist();
|
|
2432
|
+
emit();
|
|
2433
|
+
},
|
|
2434
|
+
/** Drop measured heights, e.g. when the cards change width. */
|
|
2435
|
+
resetHeights() {
|
|
2436
|
+
state.heights = {};
|
|
2437
|
+
emit();
|
|
2438
|
+
},
|
|
1164
2439
|
compose(id) {
|
|
1165
2440
|
state.composingId = id;
|
|
1166
2441
|
state.selectedId = id;
|
|
@@ -1235,6 +2510,142 @@ window.__ModuleLoader__.load({
|
|
|
1235
2510
|
}
|
|
1236
2511
|
}
|
|
1237
2512
|
|
|
2513
|
+
/**
|
|
2514
|
+
* The conversation service's image reader, or null.
|
|
2515
|
+
*
|
|
2516
|
+
* Read through `get` and kept out of the plugin's `inject` list on
|
|
2517
|
+
* purpose: a host without it must still load the view, only without
|
|
2518
|
+
* thumbnails, so an absent service may never be a load-time failure.
|
|
2519
|
+
*/
|
|
2520
|
+
function imageService() {
|
|
2521
|
+
try {
|
|
2522
|
+
return (ctx && typeof ctx.get === 'function' && ctx.get('uiConversation')) || null;
|
|
2523
|
+
} catch (error) {
|
|
2524
|
+
return null;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
/** A URL the host already resolved, or undefined when none is cached. */
|
|
2529
|
+
function peekImage(sessionId, ref) {
|
|
2530
|
+
const service = imageService();
|
|
2531
|
+
if (!service || typeof service.peekImageUrl !== 'function') return undefined;
|
|
2532
|
+
try {
|
|
2533
|
+
return service.peekImageUrl(sessionId, ref) || undefined;
|
|
2534
|
+
} catch (error) {
|
|
2535
|
+
return undefined;
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
/** Resolve one attachment to a URL; rejects when the host cannot. */
|
|
2540
|
+
function loadImage(sessionId, ref) {
|
|
2541
|
+
const service = imageService();
|
|
2542
|
+
if (!service || typeof service.imageUrl !== 'function') {
|
|
2543
|
+
return Promise.reject(new Error('uiConversation is not available'));
|
|
2544
|
+
}
|
|
2545
|
+
try {
|
|
2546
|
+
return Promise.resolve(service.imageUrl(sessionId, ref));
|
|
2547
|
+
} catch (error) {
|
|
2548
|
+
return Promise.reject(error);
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
/** Archive one session; returns whether the host accepted the call. */
|
|
2553
|
+
function archiveSession(sessionId) {
|
|
2554
|
+
const workspaces = workspacesOf();
|
|
2555
|
+
if (!workspaces || typeof workspaces.archiveSession !== 'function') return false;
|
|
2556
|
+
try {
|
|
2557
|
+
const result = workspaces.archiveSession(sessionId, { stopActivity: true });
|
|
2558
|
+
if (result && typeof result.catch === 'function') result.catch(() => undefined);
|
|
2559
|
+
return true;
|
|
2560
|
+
} catch (error) {
|
|
2561
|
+
return false;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
function unarchiveSession(sessionId) {
|
|
2566
|
+
const workspaces = workspacesOf();
|
|
2567
|
+
if (!workspaces || typeof workspaces.unarchiveSession !== 'function') return false;
|
|
2568
|
+
try {
|
|
2569
|
+
const result = workspaces.unarchiveSession(sessionId);
|
|
2570
|
+
if (result && typeof result.catch === 'function') result.catch(() => undefined);
|
|
2571
|
+
return true;
|
|
2572
|
+
} catch (error) {
|
|
2573
|
+
return false;
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
/** Sessions still referenced by a visible node of this tree. */
|
|
2578
|
+
function visibleSessionsOf(store) {
|
|
2579
|
+
const snapshot = store.getSnapshot();
|
|
2580
|
+
const hidden = hiddenSetOf(snapshot.nodes, snapshot.hidden);
|
|
2581
|
+
const sessions = new Set();
|
|
2582
|
+
for (const node of snapshot.nodes) {
|
|
2583
|
+
if (hidden.has(node.id) || !node.sessionId) continue;
|
|
2584
|
+
sessions.add(node.sessionId);
|
|
2585
|
+
}
|
|
2586
|
+
return sessions;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
/**
|
|
2590
|
+
* Put a finished branch session into the archive.
|
|
2591
|
+
*
|
|
2592
|
+
* A branch is a real session, so DSH lists it next to the root session.
|
|
2593
|
+
* Forking cannot create a child "subtask" row from a client plugin, and
|
|
2594
|
+
* archived sessions stay readable through the same retain/binding path
|
|
2595
|
+
* the tree already uses — so archiving is how a finished branch stops
|
|
2596
|
+
* taking a top-level row. Only finished turns are quieted: an archived
|
|
2597
|
+
* session refuses prompts, and a branch that is still running or waiting
|
|
2598
|
+
* must stay promptable.
|
|
2599
|
+
*/
|
|
2600
|
+
function quietBranch(store, sessionId) {
|
|
2601
|
+
const snapshot = store.getSnapshot();
|
|
2602
|
+
if (!sessionId || (snapshot.branchMode || readBranchMode()) !== 'quiet') return;
|
|
2603
|
+
const quieted = Array.isArray(snapshot.quieted) ? snapshot.quieted : [];
|
|
2604
|
+
if (quieted.indexOf(sessionId) >= 0) return;
|
|
2605
|
+
if (!archiveSession(sessionId)) return;
|
|
2606
|
+
store.setQuieted(quieted.concat(sessionId));
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Switch this tree's branch sessions between "listed" and "quieted".
|
|
2611
|
+
*
|
|
2612
|
+
* Existing finished branches migrate in both directions; running or
|
|
2613
|
+
* waiting branches are left alone. A tombstoned node's session stays
|
|
2614
|
+
* archived either way: its restore path is the tombstone, not this
|
|
2615
|
+
* preference.
|
|
2616
|
+
*/
|
|
2617
|
+
function setBranchListing(rootId, mode) {
|
|
2618
|
+
const store = storeFor(rootId);
|
|
2619
|
+
const snapshot = store.getSnapshot();
|
|
2620
|
+
const visible = visibleSessionsOf(store);
|
|
2621
|
+
saveBranchMode(mode);
|
|
2622
|
+
store.setBranchMode(mode);
|
|
2623
|
+
if (mode === 'quiet') {
|
|
2624
|
+
const quieted = new Set(Array.isArray(snapshot.quieted) ? snapshot.quieted : []);
|
|
2625
|
+
for (const node of snapshot.nodes) {
|
|
2626
|
+
if (node.kind !== 'branch' || !node.sessionId || !visible.has(node.sessionId)) continue;
|
|
2627
|
+
if (RUNNING_STATUSES.indexOf(node.status) >= 0) continue;
|
|
2628
|
+
if (node.awaiting === 'question' || node.awaiting === 'approval') continue;
|
|
2629
|
+
// Already archived by this policy; do not re-issue the call.
|
|
2630
|
+
if (quieted.has(node.sessionId)) continue;
|
|
2631
|
+
if (!archiveSession(node.sessionId)) continue;
|
|
2632
|
+
quieted.add(node.sessionId);
|
|
2633
|
+
}
|
|
2634
|
+
store.setQuieted([...quieted]);
|
|
2635
|
+
return 'quiet';
|
|
2636
|
+
}
|
|
2637
|
+
// The tree only unarchives what it archived. A session whose node is
|
|
2638
|
+
// tombstoned, or whose unarchive was not accepted, stays on the list:
|
|
2639
|
+
// dropping it here would strand it archived and untracked forever.
|
|
2640
|
+
const remaining = [];
|
|
2641
|
+
for (const sessionId of snapshot.quieted || []) {
|
|
2642
|
+
if (!visible.has(sessionId)) { remaining.push(sessionId); continue; }
|
|
2643
|
+
if (!unarchiveSession(sessionId)) remaining.push(sessionId);
|
|
2644
|
+
}
|
|
2645
|
+
store.setQuieted(remaining);
|
|
2646
|
+
return 'listed';
|
|
2647
|
+
}
|
|
2648
|
+
|
|
1238
2649
|
/**
|
|
1239
2650
|
* Tombstone a node and its subtree. Archived sessions are remembered so
|
|
1240
2651
|
* "恢复" can put them back into the session list.
|
|
@@ -1254,6 +2665,7 @@ window.__ModuleLoader__.load({
|
|
|
1254
2665
|
visibleSessions.add(node.sessionId);
|
|
1255
2666
|
}
|
|
1256
2667
|
const archived = Array.isArray(after.archived) ? after.archived.slice() : [];
|
|
2668
|
+
const quieted = new Set(Array.isArray(after.quieted) ? after.quieted : []);
|
|
1257
2669
|
const workspaces = workspacesOf();
|
|
1258
2670
|
let changed = false;
|
|
1259
2671
|
for (const node of after.nodes) {
|
|
@@ -1262,6 +2674,9 @@ window.__ModuleLoader__.load({
|
|
|
1262
2674
|
// Never archive the root session, nor a session a visible node still points at.
|
|
1263
2675
|
if (!sessionId || sessionId === rootId) continue;
|
|
1264
2676
|
if (visibleSessions.has(sessionId) || archived.indexOf(sessionId) >= 0) continue;
|
|
2677
|
+
// Already quieted by the branch policy: deleting the node must not
|
|
2678
|
+
// later pull that session back into the workspace through "恢复".
|
|
2679
|
+
if (quieted.has(sessionId)) continue;
|
|
1265
2680
|
if (!workspaces || typeof workspaces.archiveSession !== 'function') continue;
|
|
1266
2681
|
try {
|
|
1267
2682
|
const result = workspaces.archiveSession(sessionId, { stopActivity: true });
|
|
@@ -1291,6 +2706,21 @@ window.__ModuleLoader__.load({
|
|
|
1291
2706
|
}
|
|
1292
2707
|
}
|
|
1293
2708
|
store.restoreHidden();
|
|
2709
|
+
if ((store.getSnapshot().branchMode || readBranchMode()) !== 'listed') return;
|
|
2710
|
+
// A branch quieted before its node was deleted stays archived through
|
|
2711
|
+
// the tombstone. Once the node is back and the policy is listed, that
|
|
2712
|
+
// session has to come back too.
|
|
2713
|
+
const restored = store.getSnapshot();
|
|
2714
|
+
const sessions = new Set();
|
|
2715
|
+
for (const node of restored.nodes) if (node.sessionId) sessions.add(node.sessionId);
|
|
2716
|
+
const remaining = [];
|
|
2717
|
+
let changed = false;
|
|
2718
|
+
for (const sessionId of restored.quieted || []) {
|
|
2719
|
+
if (!sessions.has(sessionId)) { remaining.push(sessionId); continue; }
|
|
2720
|
+
if (!unarchiveSession(sessionId)) { remaining.push(sessionId); continue; }
|
|
2721
|
+
changed = true;
|
|
2722
|
+
}
|
|
2723
|
+
if (changed) store.setQuieted(remaining);
|
|
1294
2724
|
}
|
|
1295
2725
|
|
|
1296
2726
|
function remember(sessionId, rootId, nodeId) {
|
|
@@ -1440,6 +2870,10 @@ window.__ModuleLoader__.load({
|
|
|
1440
2870
|
if (read2.answerSeq) changes.answerSeq = read2.answerSeq;
|
|
1441
2871
|
if (read2.step !== (current.step || 0)) changes.step = read2.step;
|
|
1442
2872
|
if (read2.tool !== (current.tool || '')) changes.tool = read2.tool;
|
|
2873
|
+
if ((read2.reasoning || '') !== (current.reasoning || '')) changes.reasoning = read2.reasoning || '';
|
|
2874
|
+
if ((read2.reasoningDropped || 0) !== (current.reasoningDropped || 0)) {
|
|
2875
|
+
changes.reasoningDropped = read2.reasoningDropped || 0;
|
|
2876
|
+
}
|
|
1443
2877
|
const awaiting = read2.awaiting || '';
|
|
1444
2878
|
if (awaiting !== (current.awaiting || '')) changes.awaiting = awaiting;
|
|
1445
2879
|
if (read2.startedAt && read2.startedAt !== current.startedAt) changes.startedAt = read2.startedAt;
|
|
@@ -1458,6 +2892,15 @@ window.__ModuleLoader__.load({
|
|
|
1458
2892
|
changes.status = 'streaming';
|
|
1459
2893
|
}
|
|
1460
2894
|
if (Object.keys(changes).length) store.patch(nodeId, changes);
|
|
2895
|
+
// A branch that finished while the view was elsewhere is quieted on
|
|
2896
|
+
// the first read that sees its end, so reopening a tree applies the
|
|
2897
|
+
// same policy as watching the turn finish live.
|
|
2898
|
+
// Only a real turn end may quiet a branch. `running === false` is
|
|
2899
|
+
// also what a parked question/approval and a cold, not-yet-hydrated
|
|
2900
|
+
// session look like; archiving those would make them unanswerable.
|
|
2901
|
+
if (read2.ended && !read2.awaiting && running !== true && current.sessionId) {
|
|
2902
|
+
quietBranch(store, current.sessionId);
|
|
2903
|
+
}
|
|
1461
2904
|
};
|
|
1462
2905
|
read();
|
|
1463
2906
|
binding.eventSource.subscribe(read);
|
|
@@ -1479,6 +2922,27 @@ window.__ModuleLoader__.load({
|
|
|
1479
2922
|
// A tombstoned node cannot be forked from even if a stale card asks.
|
|
1480
2923
|
if (hiddenSetOf(snapshot.nodes, snapshot.hidden).has(parentNode.id)) return;
|
|
1481
2924
|
const nodeId = 'b-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 6);
|
|
2925
|
+
// Forking from a branch the archive holds is fine for the log, but the
|
|
2926
|
+
// archive is not where new work starts: bring the parent back for the
|
|
2927
|
+
// fork, then quiet it again. Only the child runs.
|
|
2928
|
+
const parentQuieted = (snapshot.quieted || []).indexOf(parentNode.sessionId) >= 0;
|
|
2929
|
+
if (parentQuieted) {
|
|
2930
|
+
// Wait for the unarchive: a fire-and-forget call could race the fork.
|
|
2931
|
+
try {
|
|
2932
|
+
await Promise.resolve(unarchiveSession(parentNode.sessionId));
|
|
2933
|
+
} catch (error) {
|
|
2934
|
+
/* the fork only needs the log, so keep going */
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
// Re-quiet only when the policy still owns this session. Switching the
|
|
2938
|
+
// tree to "listed" while the fork was in flight must not sneak the
|
|
2939
|
+
// parent back into the archive untracked.
|
|
2940
|
+
const requietParent = () => {
|
|
2941
|
+
const latest = store.getSnapshot();
|
|
2942
|
+
if ((latest.branchMode || readBranchMode()) !== 'quiet') return;
|
|
2943
|
+
if ((latest.quieted || []).indexOf(parentNode.sessionId) < 0) return;
|
|
2944
|
+
archiveSession(parentNode.sessionId);
|
|
2945
|
+
};
|
|
1482
2946
|
let childId;
|
|
1483
2947
|
try {
|
|
1484
2948
|
childId = await ctx.sessions.fork({
|
|
@@ -1486,9 +2950,11 @@ window.__ModuleLoader__.load({
|
|
|
1486
2950
|
atSeq: parentNode.answerSeq || undefined,
|
|
1487
2951
|
});
|
|
1488
2952
|
} catch (error) {
|
|
2953
|
+
if (parentQuieted) requietParent();
|
|
1489
2954
|
store.setError(T('error.forkFailed', { reason: String((error && error.message) || error) }));
|
|
1490
2955
|
return;
|
|
1491
2956
|
}
|
|
2957
|
+
if (parentQuieted) requietParent();
|
|
1492
2958
|
remember(childId, rootId, nodeId);
|
|
1493
2959
|
store.upsert({
|
|
1494
2960
|
id: nodeId,
|
|
@@ -1570,6 +3036,15 @@ window.__ModuleLoader__.load({
|
|
|
1570
3036
|
const awaiting = read.awaiting || '';
|
|
1571
3037
|
const node = store.getNode(nodeId);
|
|
1572
3038
|
if (node && awaiting !== (node.awaiting || '')) store.patch(nodeId, { awaiting });
|
|
3039
|
+
// The branch's reasoning arrives with the same events as its answer,
|
|
3040
|
+
// so it is patched in the same breath.
|
|
3041
|
+
if (node && ((read.reasoning || '') !== (node.reasoning || '')
|
|
3042
|
+
|| (read.reasoningDropped || 0) !== (node.reasoningDropped || 0))) {
|
|
3043
|
+
store.patch(nodeId, {
|
|
3044
|
+
reasoning: read.reasoning || '',
|
|
3045
|
+
reasoningDropped: read.reasoningDropped || 0,
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
1573
3048
|
if (read.ended) {
|
|
1574
3049
|
unsubscribe();
|
|
1575
3050
|
try {
|
|
@@ -1577,6 +3052,9 @@ window.__ModuleLoader__.load({
|
|
|
1577
3052
|
} catch (error) {
|
|
1578
3053
|
/* ignore */
|
|
1579
3054
|
}
|
|
3055
|
+
// The turn is over, so this session will only ever be read: put
|
|
3056
|
+
// it into the archive and keep the workspace list to the tree.
|
|
3057
|
+
quietBranch(store, childId);
|
|
1580
3058
|
}
|
|
1581
3059
|
} finally {
|
|
1582
3060
|
busy = false;
|
|
@@ -1603,73 +3081,361 @@ window.__ModuleLoader__.load({
|
|
|
1603
3081
|
}
|
|
1604
3082
|
}
|
|
1605
3083
|
|
|
1606
|
-
return {
|
|
3084
|
+
return {
|
|
3085
|
+
rootOf, storeFor, ensureProjection, ensureOpen, branch, loadOlder,
|
|
3086
|
+
deleteSubtree, restoreHidden, setBranchListing, peekImage, loadImage,
|
|
3087
|
+
};
|
|
1607
3088
|
}
|
|
1608
3089
|
|
|
1609
3090
|
// -------------------------------------------------------------- markdown
|
|
1610
3091
|
const MD = {
|
|
1611
3092
|
body: { fontSize: 12, lineHeight: 1.72, color: C.ink2, wordBreak: 'break-word' },
|
|
1612
|
-
h1: { fontSize: '1.
|
|
1613
|
-
h2: { fontSize: '1.
|
|
1614
|
-
h3: { fontSize: '1.
|
|
3093
|
+
h1: { fontSize: '1.3em', fontWeight: 700, color: C.ink, margin: '0.7em 0 0.3em', lineHeight: 1.35 },
|
|
3094
|
+
h2: { fontSize: '1.16em', fontWeight: 700, color: C.ink, margin: '0.65em 0 0.28em', lineHeight: 1.38 },
|
|
3095
|
+
h3: { fontSize: '1.06em', fontWeight: 600, color: C.ink, margin: '0.58em 0 0.24em', lineHeight: 1.4 },
|
|
3096
|
+
h4: { fontSize: '1.01em', fontWeight: 600, color: C.ink, margin: '0.52em 0 0.22em', lineHeight: 1.42 },
|
|
3097
|
+
h5: { fontSize: '0.98em', fontWeight: 600, color: C.ink3, margin: '0.48em 0 0.2em', lineHeight: 1.42 },
|
|
3098
|
+
h6: { fontSize: '0.96em', fontWeight: 600, color: C.ink3, margin: '0.44em 0 0.18em', lineHeight: 1.42 },
|
|
1615
3099
|
p: { margin: '0 0 0.5em' },
|
|
1616
|
-
ul: { margin: '0 0 0.5em', paddingLeft: '1.
|
|
3100
|
+
ul: { margin: '0 0 0.5em', paddingLeft: '1.4em' },
|
|
1617
3101
|
ol: { margin: '0 0 0.5em', paddingLeft: '1.5em' },
|
|
1618
3102
|
li: { margin: '0 0 0.16em' },
|
|
3103
|
+
checkbox: { marginRight: '0.4em', verticalAlign: 'middle' },
|
|
1619
3104
|
quote: {
|
|
1620
3105
|
margin: '0 0 0.5em', paddingLeft: '0.75em', borderLeft: '2px solid ' + C.line,
|
|
1621
3106
|
color: C.ink3,
|
|
1622
3107
|
},
|
|
1623
3108
|
hr: { border: 'none', borderTop: '1px solid ' + C.line, margin: '0.75em 0' },
|
|
1624
3109
|
codeBlock: {
|
|
1625
|
-
margin:
|
|
3110
|
+
margin: 0, padding: '0.55em 0.75em', borderRadius: 6, background: C.code,
|
|
1626
3111
|
border: '1px solid ' + C.line, fontFamily: MONO,
|
|
1627
3112
|
fontSize: '0.9em', lineHeight: 1.6, whiteSpace: 'pre-wrap', overflowX: 'auto', color: C.ink,
|
|
1628
3113
|
},
|
|
3114
|
+
codeLang: {
|
|
3115
|
+
margin: '0 0 0.3em', fontSize: '0.78em', letterSpacing: '0.04em',
|
|
3116
|
+
color: C.ink4, fontFamily: MONO, textTransform: 'uppercase',
|
|
3117
|
+
},
|
|
1629
3118
|
inlineCode: {
|
|
1630
3119
|
fontFamily: MONO, fontSize: '0.92em',
|
|
1631
3120
|
background: C.codeInline, borderRadius: 3, padding: '0 0.28em', color: C.ink,
|
|
1632
3121
|
},
|
|
1633
3122
|
link: { color: C.accent, textDecoration: 'none' },
|
|
3123
|
+
image: {
|
|
3124
|
+
display: 'block', maxWidth: '100%', height: 'auto',
|
|
3125
|
+
margin: '0.4em 0', borderRadius: 6,
|
|
3126
|
+
},
|
|
1634
3127
|
strong: { fontWeight: 700, color: C.ink },
|
|
1635
3128
|
};
|
|
1636
3129
|
|
|
3130
|
+
/*
|
|
3131
|
+
* Why this is a renderer and not a Markdown library.
|
|
3132
|
+
*
|
|
3133
|
+
* The view has no dependencies and ships as one file the host loads, so it
|
|
3134
|
+
* cannot pull in a parser. What it can do is cover the subset an answer
|
|
3135
|
+
* actually uses and be explicit about the rest: reference links, footnotes
|
|
3136
|
+
* and raw HTML blocks are passed through as text rather than half-rendered.
|
|
3137
|
+
*
|
|
3138
|
+
* Raw HTML is never injected — every string here becomes a React text node,
|
|
3139
|
+
* so a model that writes a script tag gets the characters, not an element.
|
|
3140
|
+
* That is also why this is safe to run on model output.
|
|
3141
|
+
*/
|
|
3142
|
+
|
|
3143
|
+
/** Only these schemes may become a live link. */
|
|
3144
|
+
function safeHref(raw) {
|
|
3145
|
+
const url = String(raw || '').trim();
|
|
3146
|
+
if (!url) return null;
|
|
3147
|
+
if (/^(https?:|mailto:)/i.test(url)) return url;
|
|
3148
|
+
// Relative links and fragment anchors are fine. Anything else — notably
|
|
3149
|
+
// javascript: and data: — would turn model output into script execution.
|
|
3150
|
+
if (/^(\/|\.{1,2}\/|#)/.test(url)) return url;
|
|
3151
|
+
return null;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
/** Strip the angle brackets or quotes a URL may be wrapped in. */
|
|
3155
|
+
function cleanUrl(raw) {
|
|
3156
|
+
return String(raw || '').trim().replace(/^<|>$/g, '').replace(/^["']|["']$/g, '');
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
/** Index of the closing `marker` at or after `from`, or -1 when unclosed. */
|
|
3160
|
+
function closeOf(text, from, marker) {
|
|
3161
|
+
let found = text.indexOf(marker, from);
|
|
3162
|
+
while (found >= 0) {
|
|
3163
|
+
if (text[found - 1] !== '\\') return found;
|
|
3164
|
+
found = text.indexOf(marker, found + marker.length);
|
|
3165
|
+
}
|
|
3166
|
+
return -1;
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
/**
|
|
3170
|
+
* A slash command or skill call: `/name` with whitespace on both sides.
|
|
3171
|
+
* The host marks the same shape in sent text with its own skill matcher
|
|
3172
|
+
* (`skillReferenceRule`), and the canvas reads that shape so a call reads
|
|
3173
|
+
* as a call instead of as prose. `/usr/bin` and `and/or` stay text: the
|
|
3174
|
+
* head needs a boundary on each side, not just a slash.
|
|
3175
|
+
*
|
|
3176
|
+
* Anchored `^` because it is run against `text.slice(at)`: without it the
|
|
3177
|
+
* scan would silently accept a later slash that happens to be bounded and
|
|
3178
|
+
* chip the wrong token.
|
|
3179
|
+
*/
|
|
3180
|
+
const SLASH_COMMAND = /^\/([\w-]+)(?!\S)/;
|
|
3181
|
+
|
|
3182
|
+
function commandChip(token, key) {
|
|
3183
|
+
return h('span', { key, className: 'dsh-tree-command' }, token);
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
/** Plain text with every slash command rendered as the chip. */
|
|
3187
|
+
function commandTextNodes(text, keyBase) {
|
|
3188
|
+
const source = String(text === undefined || text === null ? '' : text);
|
|
3189
|
+
const out = [];
|
|
3190
|
+
let start = 0;
|
|
3191
|
+
let cursor = 0;
|
|
3192
|
+
while (cursor < source.length) {
|
|
3193
|
+
const at = source.indexOf('/', cursor);
|
|
3194
|
+
if (at < 0) break;
|
|
3195
|
+
// Word-boundary discipline: the trigger sits at the start or after
|
|
3196
|
+
// whitespace, so `x/name` never matches.
|
|
3197
|
+
if (at > 0 && !/\s/.test(source[at - 1])) { cursor = at + 1; continue; }
|
|
3198
|
+
const match = SLASH_COMMAND.exec(source.slice(at));
|
|
3199
|
+
if (!match) { cursor = at + 1; continue; }
|
|
3200
|
+
if (at > start) out.push(source.slice(start, at));
|
|
3201
|
+
out.push(commandChip(match[0], keyBase + '-c' + at));
|
|
3202
|
+
start = at + match[0].length;
|
|
3203
|
+
cursor = start;
|
|
3204
|
+
}
|
|
3205
|
+
if (start < source.length) out.push(source.slice(start));
|
|
3206
|
+
return out.length ? out : [source];
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
/**
|
|
3210
|
+
* Inline Markdown: escapes, code spans, emphasis, strikethrough, images,
|
|
3211
|
+
* links, autolinks and hard breaks.
|
|
3212
|
+
*/
|
|
1637
3213
|
function inlineNodes(text, keyBase) {
|
|
1638
3214
|
const out = [];
|
|
1639
|
-
const
|
|
1640
|
-
let
|
|
1641
|
-
let match;
|
|
3215
|
+
const source = String(text === undefined || text === null ? '' : text);
|
|
3216
|
+
let buffer = '';
|
|
1642
3217
|
let index = 0;
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
target: '_blank',
|
|
1658
|
-
rel: 'noreferrer noopener',
|
|
1659
|
-
style: MD.link,
|
|
1660
|
-
}, link ? link[1] : token));
|
|
1661
|
-
} else {
|
|
1662
|
-
out.push(h('em', { key }, token.slice(1, -1)));
|
|
3218
|
+
const nextKey = () => keyBase + '-' + (index++);
|
|
3219
|
+
const flush = () => { if (buffer) { out.push(buffer); buffer = ''; } };
|
|
3220
|
+
let i = 0;
|
|
3221
|
+
while (i < source.length) {
|
|
3222
|
+
const ch = source[i];
|
|
3223
|
+
// A slash command or skill call is a chip, not prose.
|
|
3224
|
+
if (ch === '/' && (i === 0 || /\s/.test(source[i - 1]))) {
|
|
3225
|
+
const match = SLASH_COMMAND.exec(source.slice(i));
|
|
3226
|
+
if (match) {
|
|
3227
|
+
flush();
|
|
3228
|
+
out.push(commandChip(match[0], nextKey()));
|
|
3229
|
+
i += match[0].length;
|
|
3230
|
+
continue;
|
|
3231
|
+
}
|
|
1663
3232
|
}
|
|
1664
|
-
|
|
3233
|
+
// Backslash escape: the next character is literal.
|
|
3234
|
+
if (ch === '\\' && i + 1 < source.length && /[\\`*_{}[\]()#+\-.!>~|]/.test(source[i + 1])) {
|
|
3235
|
+
buffer += source[i + 1];
|
|
3236
|
+
i += 2;
|
|
3237
|
+
continue;
|
|
3238
|
+
}
|
|
3239
|
+
// A backslash at the end of a line is a hard break.
|
|
3240
|
+
if (ch === '\\' && source[i + 1] === '\n') {
|
|
3241
|
+
flush();
|
|
3242
|
+
out.push(h('br', { key: nextKey() }));
|
|
3243
|
+
i += 2;
|
|
3244
|
+
continue;
|
|
3245
|
+
}
|
|
3246
|
+
if (ch === '\n') {
|
|
3247
|
+
// Two trailing spaces are a hard break; any other newline is a space,
|
|
3248
|
+
// since a card is a narrow column where a stray newline reads as a
|
|
3249
|
+
// broken word.
|
|
3250
|
+
if (/ $/.test(buffer)) {
|
|
3251
|
+
buffer = buffer.replace(/ +$/, '');
|
|
3252
|
+
flush();
|
|
3253
|
+
out.push(h('br', { key: nextKey() }));
|
|
3254
|
+
} else {
|
|
3255
|
+
buffer += ' ';
|
|
3256
|
+
}
|
|
3257
|
+
i += 1;
|
|
3258
|
+
continue;
|
|
3259
|
+
}
|
|
3260
|
+
// Code span: a run of N backticks closed by the same run.
|
|
3261
|
+
if (ch === '`') {
|
|
3262
|
+
const run = /^`+/.exec(source.slice(i))[0];
|
|
3263
|
+
const close = source.indexOf(run, i + run.length);
|
|
3264
|
+
if (close > i) {
|
|
3265
|
+
flush();
|
|
3266
|
+
const inner = source.slice(i + run.length, close).replace(/^ | $/g, '');
|
|
3267
|
+
out.push(h('code', { key: nextKey(), style: MD.inlineCode }, inner));
|
|
3268
|
+
i = close + run.length;
|
|
3269
|
+
continue;
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
// Image: 
|
|
3273
|
+
if (ch === '!' && source[i + 1] === '[') {
|
|
3274
|
+
const match = /^!\[([^\]]*)\]\(\s*((?:[^()\s]|\([^()]*\))+)(?:\s+"([^"]*)")?\s*\)/.exec(source.slice(i));
|
|
3275
|
+
if (match) {
|
|
3276
|
+
flush();
|
|
3277
|
+
const href = safeHref(cleanUrl(match[2]));
|
|
3278
|
+
if (href) {
|
|
3279
|
+
out.push(h('img', {
|
|
3280
|
+
key: nextKey(), src: href, alt: match[1] || '',
|
|
3281
|
+
title: match[3] || undefined, loading: 'lazy', style: MD.image,
|
|
3282
|
+
}));
|
|
3283
|
+
} else {
|
|
3284
|
+
out.push(match[1] || match[2]);
|
|
3285
|
+
}
|
|
3286
|
+
i += match[0].length;
|
|
3287
|
+
continue;
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
// Link: [text](href "title")
|
|
3291
|
+
if (ch === '[') {
|
|
3292
|
+
const match = /^\[([^\]]*)\]\(\s*((?:[^()\s]|\([^()]*\))+)(?:\s+"([^"]*)")?\s*\)/.exec(source.slice(i));
|
|
3293
|
+
if (match) {
|
|
3294
|
+
flush();
|
|
3295
|
+
const href = safeHref(cleanUrl(match[2]));
|
|
3296
|
+
const label = match[1] || match[2];
|
|
3297
|
+
if (href) {
|
|
3298
|
+
out.push(h('a', {
|
|
3299
|
+
key: nextKey(), href, target: '_blank', rel: 'noreferrer noopener',
|
|
3300
|
+
title: match[3] || undefined, style: MD.link,
|
|
3301
|
+
}, inlineNodes(label, nextKey())));
|
|
3302
|
+
} else {
|
|
3303
|
+
out.push(label);
|
|
3304
|
+
}
|
|
3305
|
+
i += match[0].length;
|
|
3306
|
+
continue;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
// Autolink: <https://example.com>
|
|
3310
|
+
if (ch === '<') {
|
|
3311
|
+
const match = /^<((?:https?:|mailto:)[^>\s]+)>/.exec(source.slice(i));
|
|
3312
|
+
if (match) {
|
|
3313
|
+
flush();
|
|
3314
|
+
out.push(h('a', {
|
|
3315
|
+
key: nextKey(), href: match[1], target: '_blank',
|
|
3316
|
+
rel: 'noreferrer noopener', style: MD.link,
|
|
3317
|
+
}, match[1].replace(/^mailto:/, '')));
|
|
3318
|
+
i += match[0].length;
|
|
3319
|
+
continue;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
// A bare URL outside a link is still a link.
|
|
3323
|
+
if ((ch === 'h' || ch === 'H') && /^https?:\/\//i.test(source.slice(i, i + 8))) {
|
|
3324
|
+
const match = /^https?:\/\/[^\s<>()]+/i.exec(source.slice(i));
|
|
3325
|
+
if (match) {
|
|
3326
|
+
const url = match[0].replace(/[.,;:!?'"]+$/, '');
|
|
3327
|
+
flush();
|
|
3328
|
+
out.push(h('a', {
|
|
3329
|
+
key: nextKey(), href: url, target: '_blank',
|
|
3330
|
+
rel: 'noreferrer noopener', style: MD.link,
|
|
3331
|
+
}, url));
|
|
3332
|
+
i += url.length;
|
|
3333
|
+
continue;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
// Strikethrough, strong and emphasis. The inner text is parsed again so
|
|
3337
|
+
// that strong-wrapping-code and nested emphasis come out right.
|
|
3338
|
+
if (ch === '~' && source[i + 1] === '~') {
|
|
3339
|
+
const close = closeOf(source, i + 2, '~~');
|
|
3340
|
+
if (close > i) {
|
|
3341
|
+
flush();
|
|
3342
|
+
out.push(h('del', { key: nextKey() }, inlineNodes(source.slice(i + 2, close), nextKey())));
|
|
3343
|
+
i = close + 2;
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
if ((ch === '*' && source[i + 1] === '*') || (ch === '_' && source[i + 1] === '_')) {
|
|
3348
|
+
const marker = ch + ch;
|
|
3349
|
+
const close = closeOf(source, i + 2, marker);
|
|
3350
|
+
if (close > i) {
|
|
3351
|
+
flush();
|
|
3352
|
+
out.push(h('strong', { key: nextKey(), style: MD.strong },
|
|
3353
|
+
inlineNodes(source.slice(i + 2, close), nextKey())));
|
|
3354
|
+
i = close + 2;
|
|
3355
|
+
continue;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
if (ch === '*' || ch === '_') {
|
|
3359
|
+
const close = closeOf(source, i + 1, ch);
|
|
3360
|
+
if (close > i) {
|
|
3361
|
+
flush();
|
|
3362
|
+
out.push(h('em', { key: nextKey() }, inlineNodes(source.slice(i + 1, close), nextKey())));
|
|
3363
|
+
i = close + 1;
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
buffer += ch;
|
|
3368
|
+
i += 1;
|
|
1665
3369
|
}
|
|
1666
|
-
|
|
3370
|
+
flush();
|
|
1667
3371
|
return out;
|
|
1668
3372
|
}
|
|
1669
3373
|
|
|
1670
|
-
/**
|
|
3374
|
+
/** Leading indentation of a line, with tabs counted as four spaces. */
|
|
3375
|
+
function indentOf(line) {
|
|
3376
|
+
const lead = /^[ \t]*/.exec(line)[0];
|
|
3377
|
+
return lead.replace(/\t/g, ' ').length;
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3380
|
+
/**
|
|
3381
|
+
* Read one list block, including nesting.
|
|
3382
|
+
*
|
|
3383
|
+
* The walk is indentation-based: an item at the list's own indent starts a
|
|
3384
|
+
* new entry, and anything deeper belongs to the entry above and is rendered
|
|
3385
|
+
* as nested blocks — which is what makes a sub-bullet read as a child
|
|
3386
|
+
* instead of a second flat item, the single most common shape in an answer.
|
|
3387
|
+
*/
|
|
3388
|
+
function parseListBlock(lines, start) {
|
|
3389
|
+
const ordered = /^\s*\d+[.)]\s+/.test(lines[start]);
|
|
3390
|
+
const baseIndent = indentOf(lines[start]);
|
|
3391
|
+
const itemRe = ordered ? /^(\s*)(\d+)[.)]\s+(.*)$/ : /^(\s*)[-*+]\s+(.*)$/;
|
|
3392
|
+
const items = [];
|
|
3393
|
+
let startNumber = 1;
|
|
3394
|
+
let i = start;
|
|
3395
|
+
while (i < lines.length) {
|
|
3396
|
+
const line = lines[i];
|
|
3397
|
+
if (/^\s*$/.test(line)) {
|
|
3398
|
+
// A blank line only ends the list when the next non-blank line is not
|
|
3399
|
+
// another item of this list.
|
|
3400
|
+
let j = i + 1;
|
|
3401
|
+
while (j < lines.length && /^\s*$/.test(lines[j])) j += 1;
|
|
3402
|
+
if (j < lines.length && indentOf(lines[j]) === baseIndent && itemRe.test(lines[j])) {
|
|
3403
|
+
i = j;
|
|
3404
|
+
continue;
|
|
3405
|
+
}
|
|
3406
|
+
break;
|
|
3407
|
+
}
|
|
3408
|
+
const match = itemRe.exec(line);
|
|
3409
|
+
const indent = indentOf(line);
|
|
3410
|
+
if (match && indent === baseIndent) {
|
|
3411
|
+
if (ordered && items.length === 0) startNumber = parseInt(match[2], 10) || 1;
|
|
3412
|
+
items.push({ text: ordered ? match[3] : match[2], rest: [] });
|
|
3413
|
+
i += 1;
|
|
3414
|
+
continue;
|
|
3415
|
+
}
|
|
3416
|
+
if (!items.length) break;
|
|
3417
|
+
if (indent > baseIndent) {
|
|
3418
|
+
items[items.length - 1].rest.push(line.slice(Math.min(indent, baseIndent + 2)));
|
|
3419
|
+
i += 1;
|
|
3420
|
+
continue;
|
|
3421
|
+
}
|
|
3422
|
+
break;
|
|
3423
|
+
}
|
|
3424
|
+
return { items, ordered, startNumber, next: i };
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
/** A fenced code block, with its info string kept as a visible label. */
|
|
3428
|
+
function renderCodeBlock(language, body, key) {
|
|
3429
|
+
const lang = String(language || '').trim().split(/\s+/)[0];
|
|
3430
|
+
const label = lang ? h('div', { style: MD.codeLang }, lang) : null;
|
|
3431
|
+
return h('div', { key, style: { margin: '0 0 0.6em' } },
|
|
3432
|
+
label,
|
|
3433
|
+
h('pre', { style: MD.codeBlock }, body.join('\n')));
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
/** Small block-level Markdown renderer. */
|
|
1671
3437
|
function renderMarkdown(text) {
|
|
1672
|
-
const source = String(text || '').replace(/\r\n
|
|
3438
|
+
const source = String(text || '').replace(/\r\n?/g, '\n');
|
|
1673
3439
|
if (!source.trim()) return null;
|
|
1674
3440
|
const lines = source.split('\n');
|
|
1675
3441
|
const blocks = [];
|
|
@@ -1678,82 +3444,201 @@ window.__ModuleLoader__.load({
|
|
|
1678
3444
|
|
|
1679
3445
|
while (i < lines.length) {
|
|
1680
3446
|
const line = lines[i];
|
|
1681
|
-
|
|
3447
|
+
if (/^\s*$/.test(line)) { i += 1; continue; }
|
|
3448
|
+
|
|
3449
|
+
// Fenced code: three or more backticks or tildes, closed by at least as
|
|
3450
|
+
// many of the same character.
|
|
3451
|
+
const fence = /^\s*(`{3,}|~{3,})(.*)$/.exec(line);
|
|
1682
3452
|
if (fence) {
|
|
3453
|
+
const marker = fence[1];
|
|
3454
|
+
const closer = new RegExp('^\\s*' + (marker[0] === '`' ? '`' : '~') + '{' + marker.length + ',}\\s*$');
|
|
1683
3455
|
const body = [];
|
|
1684
3456
|
i += 1;
|
|
1685
|
-
while (i < lines.length &&
|
|
3457
|
+
while (i < lines.length && !closer.test(lines[i])) {
|
|
1686
3458
|
body.push(lines[i]);
|
|
1687
3459
|
i += 1;
|
|
1688
3460
|
}
|
|
1689
3461
|
i += 1;
|
|
1690
|
-
blocks.push(
|
|
3462
|
+
blocks.push(renderCodeBlock(fence[2], body, 'b' + blockKey));
|
|
1691
3463
|
blockKey += 1;
|
|
1692
3464
|
continue;
|
|
1693
3465
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
const
|
|
1699
|
-
|
|
3466
|
+
|
|
3467
|
+
// Indented code block: four spaces. A list continuation never reaches
|
|
3468
|
+
// here, because the list branch above consumes it.
|
|
3469
|
+
if (/^ {4}\S/.test(line)) {
|
|
3470
|
+
const body = [];
|
|
3471
|
+
while (i < lines.length && (/^ {4}/.test(lines[i]) || /^\s*$/.test(lines[i]))) {
|
|
3472
|
+
body.push(lines[i].replace(/^ {4}/, ''));
|
|
3473
|
+
i += 1;
|
|
3474
|
+
}
|
|
3475
|
+
while (body.length && /^\s*$/.test(body[body.length - 1])) body.pop();
|
|
3476
|
+
blocks.push(renderCodeBlock('', body, 'b' + blockKey));
|
|
3477
|
+
blockKey += 1;
|
|
3478
|
+
continue;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
// ATX heading -> a real heading element, so the reader has a document
|
|
3482
|
+
// structure and a screen reader announces it as one.
|
|
3483
|
+
const atx = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(line);
|
|
3484
|
+
if (atx) {
|
|
3485
|
+
const level = atx[1].length;
|
|
3486
|
+
blocks.push(h('h' + level, { key: 'b' + blockKey, style: MD['h' + level] },
|
|
3487
|
+
inlineNodes(atx[2], 'h' + blockKey)));
|
|
1700
3488
|
blockKey += 1;
|
|
1701
3489
|
i += 1;
|
|
1702
3490
|
continue;
|
|
1703
3491
|
}
|
|
1704
|
-
|
|
3492
|
+
|
|
3493
|
+
// Setext heading: a text line underlined by === or ---.
|
|
3494
|
+
if (i + 1 < lines.length && /^\s*(=+|-{2,})\s*$/.test(lines[i + 1])
|
|
3495
|
+
&& !/^\s*([-*+]|\d+[.)])\s+/.test(line) && !/^\s*\|/.test(line)) {
|
|
3496
|
+
const level = /^\s*=/.test(lines[i + 1]) ? 1 : 2;
|
|
3497
|
+
blocks.push(h('h' + level, { key: 'b' + blockKey, style: MD['h' + level] },
|
|
3498
|
+
inlineNodes(line.trim(), 'h' + blockKey)));
|
|
3499
|
+
blockKey += 1;
|
|
3500
|
+
i += 2;
|
|
3501
|
+
continue;
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
if (/^\s*([-*_])\s*\1\s*\1[\s\-*_]*$/.test(line)) {
|
|
1705
3505
|
blocks.push(h('hr', { key: 'b' + blockKey, style: MD.hr }));
|
|
1706
3506
|
blockKey += 1;
|
|
1707
3507
|
i += 1;
|
|
1708
3508
|
continue;
|
|
1709
3509
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
3510
|
+
|
|
3511
|
+
if (/^\s*[-*+]\s+/.test(line) || /^\s*\d+[.)]\s+/.test(line)) {
|
|
3512
|
+
const parsed = parseListBlock(lines, i);
|
|
3513
|
+
i = parsed.next;
|
|
3514
|
+
const tag = parsed.ordered ? 'ol' : 'ul';
|
|
3515
|
+
blocks.push(h(tag, {
|
|
3516
|
+
key: 'b' + blockKey,
|
|
3517
|
+
style: parsed.ordered ? MD.ol : MD.ul,
|
|
3518
|
+
start: parsed.ordered && parsed.startNumber !== 1 ? parsed.startNumber : undefined,
|
|
3519
|
+
}, parsed.items.map((item, n) => {
|
|
3520
|
+
const task = /^\[([ xX])\]\s+/.exec(item.text);
|
|
3521
|
+
const content = task ? item.text.slice(task[0].length) : item.text;
|
|
3522
|
+
const children = [];
|
|
3523
|
+
if (task) {
|
|
3524
|
+
children.push(h('input', {
|
|
3525
|
+
key: 't' + n, type: 'checkbox', checked: task[1] !== ' ',
|
|
3526
|
+
disabled: true, readOnly: true, style: MD.checkbox,
|
|
3527
|
+
}));
|
|
3528
|
+
}
|
|
3529
|
+
children.push(...inlineNodes(content, 'b' + blockKey + '-' + n));
|
|
3530
|
+
if (item.rest.length) children.push(...(renderMarkdown(item.rest.join('\n')) || []));
|
|
3531
|
+
return h('li', { key: 'l' + n, style: MD.li }, children);
|
|
3532
|
+
})));
|
|
1718
3533
|
blockKey += 1;
|
|
1719
3534
|
continue;
|
|
1720
3535
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
3536
|
+
|
|
3537
|
+
// Block quote: recurse, so a list or a fence inside a quote renders.
|
|
3538
|
+
if (/^\s*>/.test(line)) {
|
|
3539
|
+
const quoted = [];
|
|
3540
|
+
while (i < lines.length && (/^\s*>/.test(lines[i]) || /^\s*$/.test(lines[i]))) {
|
|
3541
|
+
if (/^\s*$/.test(lines[i])) {
|
|
3542
|
+
const next = lines[i + 1];
|
|
3543
|
+
if (next === undefined || !/^\s*>/.test(next)) break;
|
|
3544
|
+
quoted.push('');
|
|
3545
|
+
i += 1;
|
|
3546
|
+
continue;
|
|
3547
|
+
}
|
|
3548
|
+
quoted.push(lines[i].replace(/^\s*>\s?/, ''));
|
|
1725
3549
|
i += 1;
|
|
1726
3550
|
}
|
|
1727
|
-
blocks.push(h('
|
|
1728
|
-
|
|
3551
|
+
blocks.push(h('blockquote', { key: 'b' + blockKey, style: MD.quote },
|
|
3552
|
+
renderMarkdown(quoted.join('\n')) || null));
|
|
1729
3553
|
blockKey += 1;
|
|
1730
3554
|
continue;
|
|
1731
3555
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
3556
|
+
|
|
3557
|
+
// A GFM table: a pipe row whose next line is the delimiter row. The
|
|
3558
|
+
// delimiter is what separates a table from prose containing pipes.
|
|
3559
|
+
if (/\|/.test(line) && i + 1 < lines.length && isTableDelimiter(lines[i + 1])) {
|
|
3560
|
+
const aligns = splitTableRow(lines[i + 1]).map((cell) => {
|
|
3561
|
+
const left = cell.startsWith(':');
|
|
3562
|
+
const right = cell.endsWith(':');
|
|
3563
|
+
return left && right ? 'center' : right ? 'right' : 'left';
|
|
3564
|
+
});
|
|
3565
|
+
const header = splitTableRow(line);
|
|
3566
|
+
i += 2;
|
|
3567
|
+
const rows = [];
|
|
3568
|
+
while (i < lines.length && /\|/.test(lines[i]) && !/^\s*$/.test(lines[i])) {
|
|
3569
|
+
rows.push(splitTableRow(lines[i]));
|
|
1736
3570
|
i += 1;
|
|
1737
3571
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
3572
|
+
const cellStyle = (index) => ({ textAlign: aligns[index] || 'left' });
|
|
3573
|
+
blocks.push(h('div', { key: 'b' + blockKey, className: 'dsh-tree-table-wrap' },
|
|
3574
|
+
h('table', { className: 'dsh-tree-table' },
|
|
3575
|
+
h('thead', null,
|
|
3576
|
+
h('tr', null, header.map((cell, index) => h('th', {
|
|
3577
|
+
key: 'h' + index,
|
|
3578
|
+
style: cellStyle(index),
|
|
3579
|
+
}, inlineNodes(cell, 'th' + blockKey + '-' + index))))),
|
|
3580
|
+
h('tbody', null, rows.map((row, rowIndex) => h('tr', { key: 'r' + rowIndex },
|
|
3581
|
+
row.map((cell, index) => h('td', {
|
|
3582
|
+
key: 'c' + index,
|
|
3583
|
+
style: cellStyle(index),
|
|
3584
|
+
}, inlineNodes(cell, 'td' + blockKey + '-' + rowIndex + '-' + index)))))))));
|
|
1740
3585
|
blockKey += 1;
|
|
1741
3586
|
continue;
|
|
1742
3587
|
}
|
|
3588
|
+
|
|
3589
|
+
// Paragraph: runs to the next block start.
|
|
1743
3590
|
const paragraph = [];
|
|
1744
3591
|
while (i < lines.length && !/^\s*$/.test(lines[i])
|
|
1745
|
-
&& !/^\s
|
|
1746
|
-
&& !/^\s*
|
|
3592
|
+
&& !/^\s*(`{3,}|~{3,})/.test(lines[i]) && !/^#{1,6}\s+/.test(lines[i])
|
|
3593
|
+
&& !/^\s*[-*+]\s+/.test(lines[i]) && !/^\s*\d+[.)]\s+/.test(lines[i])
|
|
3594
|
+
&& !/^\s*>/.test(lines[i]) && !/^ {4}\S/.test(lines[i])
|
|
3595
|
+
&& !(/^\s*\|/.test(lines[i]) && i + 1 < lines.length && isTableDelimiter(lines[i + 1]))
|
|
3596
|
+
&& !(i + 1 < lines.length && /^\s*(=+|-{2,})\s*$/.test(lines[i + 1]))) {
|
|
1747
3597
|
paragraph.push(lines[i]);
|
|
1748
3598
|
i += 1;
|
|
1749
3599
|
}
|
|
1750
|
-
|
|
3600
|
+
if (!paragraph.length) { i += 1; continue; }
|
|
3601
|
+
blocks.push(h('p', { key: 'b' + blockKey, style: MD.p },
|
|
1751
3602
|
inlineNodes(paragraph.join('\n'), 'p' + blockKey)));
|
|
1752
3603
|
blockKey += 1;
|
|
1753
3604
|
}
|
|
1754
3605
|
return blocks;
|
|
1755
3606
|
}
|
|
1756
3607
|
|
|
3608
|
+
/** Whether a line is a GFM table delimiter row (`| --- | :---: |`). */
|
|
3609
|
+
function isTableDelimiter(line) {
|
|
3610
|
+
if (!line || line.indexOf('-') < 0) return false;
|
|
3611
|
+
const cells = splitTableRow(line);
|
|
3612
|
+
return cells.length > 0 && cells.every((cell) => /^:?-{1,}:?$/.test(cell));
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
/**
|
|
3616
|
+
* Split one table row into cells.
|
|
3617
|
+
*
|
|
3618
|
+
* The outer pipes are optional in GFM, and `\|` is a literal pipe inside a
|
|
3619
|
+
* cell, so it is swapped for a placeholder before splitting and restored
|
|
3620
|
+
* afterwards.
|
|
3621
|
+
*/
|
|
3622
|
+
function splitTableRow(line) {
|
|
3623
|
+
const source = String(line).trim().replace(/^\|/, '').replace(/\|$/, '');
|
|
3624
|
+
const cells = [];
|
|
3625
|
+
let cell = '';
|
|
3626
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
3627
|
+
const ch = source[index];
|
|
3628
|
+
if (ch === '\\' && source[index + 1] === '|') {
|
|
3629
|
+
cell += '\u0000';
|
|
3630
|
+
index += 1;
|
|
3631
|
+
} else if (ch === '|') {
|
|
3632
|
+
cells.push(cell.trim().replace(/\u0000/g, '|'));
|
|
3633
|
+
cell = '';
|
|
3634
|
+
} else {
|
|
3635
|
+
cell += ch;
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
cells.push(cell.trim().replace(/\u0000/g, '|'));
|
|
3639
|
+
return cells;
|
|
3640
|
+
}
|
|
3641
|
+
|
|
1757
3642
|
function Chevron({ dir, size, color }) {
|
|
1758
3643
|
const box = size || 10;
|
|
1759
3644
|
const rotate = dir === 'down' ? 0 : dir === 'up' ? 180 : dir === 'right' ? -90 : 90;
|
|
@@ -1873,21 +3758,41 @@ window.__ModuleLoader__.load({
|
|
|
1873
3758
|
});
|
|
1874
3759
|
}
|
|
1875
3760
|
|
|
3761
|
+
/**
|
|
3762
|
+
* How long the turn has been open, in milliseconds of wall clock.
|
|
3763
|
+
*
|
|
3764
|
+
* This is deliberately not `cost.ms`: `turnCost` can only measure between
|
|
3765
|
+
* durable events, so during one long thinking step it stops moving and then
|
|
3766
|
+
* jumps by minutes when the step settles. An open turn has to be measured
|
|
3767
|
+
* against the clock, clamped at zero so a skewed clock cannot print "-3s".
|
|
3768
|
+
*/
|
|
3769
|
+
function liveElapsedMs(node, now) {
|
|
3770
|
+
if (!node || !node.startedAt || !now) return 0;
|
|
3771
|
+
return Math.max(0, now - node.startedAt);
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
/** Re-render the caller once a second while `active`. */
|
|
3775
|
+
function useTicker(active) {
|
|
3776
|
+
const [, setTick] = useState(0);
|
|
3777
|
+
useEffect(() => {
|
|
3778
|
+
if (!active) return undefined;
|
|
3779
|
+
const timer = setInterval(() => setTick((n) => n + 1), 1000);
|
|
3780
|
+
return () => clearInterval(timer);
|
|
3781
|
+
}, [active]);
|
|
3782
|
+
return Date.now();
|
|
3783
|
+
}
|
|
3784
|
+
|
|
1876
3785
|
/** What the model is doing right now: thinking, calling a tool, or writing. */
|
|
1877
|
-
function LiveProgress({ node }) {
|
|
3786
|
+
function LiveProgress({ node, now }) {
|
|
1878
3787
|
useLocale();
|
|
1879
3788
|
const awaiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
1880
3789
|
const running = awaiting || node.status === 'thinking' || node.status === 'streaming' || node.status === 'running';
|
|
1881
|
-
const [, tick] = useState(0);
|
|
1882
|
-
useEffect(() => {
|
|
1883
|
-
if (!running) return undefined;
|
|
1884
|
-
const timer = setInterval(() => tick((n) => n + 1), 1000);
|
|
1885
|
-
return () => clearInterval(timer);
|
|
1886
|
-
}, [running]);
|
|
1887
3790
|
if (!running) return null;
|
|
1888
3791
|
const tool = node.tool || '';
|
|
1889
3792
|
const step = node.step || 0;
|
|
1890
|
-
|
|
3793
|
+
// The clock lives in the card (one timer for the whole card); this row
|
|
3794
|
+
// only reads it, so the live row and the header can never disagree.
|
|
3795
|
+
const elapsed = Math.round(liveElapsedMs(node, now) / 1000);
|
|
1891
3796
|
// A pending question/approval is not "calling the tool": name the wait so
|
|
1892
3797
|
// the card says the ball is in the user's court.
|
|
1893
3798
|
const label = awaiting
|
|
@@ -1898,8 +3803,14 @@ window.__ModuleLoader__.load({
|
|
|
1898
3803
|
? T('live.outputting')
|
|
1899
3804
|
: step > 0 ? T('live.thinking') : T('live.starting');
|
|
1900
3805
|
return h('div', {
|
|
3806
|
+
className: 'dsh-tree-live',
|
|
1901
3807
|
style: {
|
|
1902
|
-
|
|
3808
|
+
// A fixed row: its label swaps from 正在思考… to 正在调用 read to
|
|
3809
|
+
// 正在输出… and none of them may move the card, so the height is
|
|
3810
|
+
// declared rather than derived from the text. `flex: 0 0 auto` is
|
|
3811
|
+
// load-bearing inside the band: a shrinkable row is compressed to
|
|
3812
|
+
// nothing the moment the answer overflows the fixed window.
|
|
3813
|
+
marginTop: 7, height: 29, flex: '0 0 auto', boxSizing: 'border-box', padding: '6px 8px', borderRadius: 7,
|
|
1903
3814
|
background: C.accentSoft, border: '1px solid ' + C.accentEdge,
|
|
1904
3815
|
display: 'flex', alignItems: 'center', gap: 7,
|
|
1905
3816
|
fontSize: 10.5, color: C.accent, lineHeight: 1.4,
|
|
@@ -1926,19 +3837,181 @@ window.__ModuleLoader__.load({
|
|
|
1926
3837
|
elapsed > 0 ? h('span', { style: { fontVariantNumeric: 'tabular-nums', opacity: 0.6 } }, elapsed + 's') : null);
|
|
1927
3838
|
}
|
|
1928
3839
|
|
|
1929
|
-
|
|
3840
|
+
/**
|
|
3841
|
+
* The card's one line of thinking.
|
|
3842
|
+
*
|
|
3843
|
+
* A status line, not a control: the card has exactly one way to grow, and
|
|
3844
|
+
* it is the footer's read button. Keeping the chain out of the card's
|
|
3845
|
+
* controls is also why this is a single fixed 18px row — the newest
|
|
3846
|
+
* thought is the honest answer to "what is it doing right now", but a
|
|
3847
|
+
* strip that may take one line or two makes the card jump every time the
|
|
3848
|
+
* model starts a new paragraph.
|
|
3849
|
+
*/
|
|
3850
|
+
function ThinkingStrip({ node, reading }) {
|
|
3851
|
+
useLocale();
|
|
3852
|
+
const awaiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
3853
|
+
const running = awaiting || node.status === 'thinking' || node.status === 'streaming' || node.status === 'running';
|
|
3854
|
+
const tail = running ? reasoningTail(node.reasoning || '') : '';
|
|
3855
|
+
// The row exists only when it has something to say. Hiding it cannot move
|
|
3856
|
+
// the card, because everything here lives inside the fixed band.
|
|
3857
|
+
const detail = running ? tail : (reading.hasReasoning ? T('card.thinkMeta', { count: reading.reasoningChars }) : '');
|
|
3858
|
+
if (!detail) return null;
|
|
3859
|
+
return h('div', {
|
|
3860
|
+
className: 'dsh-tree-thinking',
|
|
3861
|
+
title: reading.dropped > 0 ? T('card.thinkTruncated', { count: reading.dropped }) : undefined,
|
|
3862
|
+
style: {
|
|
3863
|
+
// `flex: 0 0 auto` for the same reason as the chip: inside the fixed
|
|
3864
|
+
// band a shrinkable row loses to the answer and collapses to a sliver.
|
|
3865
|
+
marginTop: 5, height: 18, flex: '0 0 auto', boxSizing: 'border-box',
|
|
3866
|
+
display: 'flex', alignItems: 'center', gap: 5,
|
|
3867
|
+
padding: '0 7px', borderRadius: 6,
|
|
3868
|
+
borderLeft: '2px solid ' + C.accentEdge,
|
|
3869
|
+
background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent)',
|
|
3870
|
+
fontSize: 10.5, lineHeight: '18px', color: C.ink4, overflow: 'hidden',
|
|
3871
|
+
},
|
|
3872
|
+
},
|
|
3873
|
+
h('span', { style: { flex: '0 0 auto', color: C.ink3 } }, T('card.think')),
|
|
3874
|
+
h('span', { className: 'dsh-tree-one-line', style: { flex: '1 1 auto', minWidth: 0 } }, detail));
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
/** One body of the enlarged card: the answer, or the chain behind it. */
|
|
3878
|
+
function ReaderPane({ node, reading, pane, api }) {
|
|
3879
|
+
useLocale();
|
|
3880
|
+
if (pane !== 'reasoning') {
|
|
3881
|
+
return h('div', null,
|
|
3882
|
+
h(PromptImages, { api, sessionId: node.sessionId, images: node.images, full: true }),
|
|
3883
|
+
node.answer ? renderMarkdown(node.answer) : T('reader.noAnswer'));
|
|
3884
|
+
}
|
|
3885
|
+
return h('div', null,
|
|
3886
|
+
h('div', {
|
|
3887
|
+
style: {
|
|
3888
|
+
marginBottom: 12, fontSize: 10.8, color: C.ink4,
|
|
3889
|
+
fontVariantNumeric: 'tabular-nums',
|
|
3890
|
+
},
|
|
3891
|
+
},
|
|
3892
|
+
T('card.think'), ' · ', T('card.thinkMeta', { count: reading.reasoningChars }),
|
|
3893
|
+
reading.dropped > 0
|
|
3894
|
+
? h('div', { style: { marginTop: 3 } }, T('card.thinkTruncated', { count: reading.dropped }))
|
|
3895
|
+
: null),
|
|
3896
|
+
// A rule instead of a bordered box: the chain is a document in the
|
|
3897
|
+
// reader's own flow, and a box inside the scroll area would make it a
|
|
3898
|
+
// second scroll target.
|
|
3899
|
+
h('div', { style: { borderLeft: '2px solid ' + C.accentEdge, paddingLeft: 14 } },
|
|
3900
|
+
renderMarkdown(node.reasoning || '')));
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
/**
|
|
3904
|
+
* One image a prompt carried.
|
|
3905
|
+
*
|
|
3906
|
+
* The frame is sized from the attachment's own dimensions, so the card
|
|
3907
|
+
* reserves the space before the bytes arrive and does not jump when they
|
|
3908
|
+
* do. A blob the host has since revoked leaves the frame empty.
|
|
3909
|
+
*/
|
|
3910
|
+
function PromptImage({ api, sessionId, attachment, height, full }) {
|
|
3911
|
+
useLocale();
|
|
3912
|
+
const [url, setUrl] = useState(() => api.peekImage(sessionId, attachment));
|
|
3913
|
+
// The ref object is rebuilt by every projection; key the effect on its id
|
|
3914
|
+
// so a per-token identity change does not re-issue the read.
|
|
3915
|
+
useEffect(() => {
|
|
3916
|
+
if (url) return undefined;
|
|
3917
|
+
let live = true;
|
|
3918
|
+
try {
|
|
3919
|
+
api.loadImage(sessionId, attachment).then((next) => {
|
|
3920
|
+
if (live && next) setUrl(next);
|
|
3921
|
+
}, () => undefined);
|
|
3922
|
+
} catch (error) {
|
|
3923
|
+
/* an attachment the host refuses stays a frame */
|
|
3924
|
+
}
|
|
3925
|
+
return () => { live = false; };
|
|
3926
|
+
}, [api, sessionId, attachment.attachmentId, url]);
|
|
3927
|
+
const label = attachment.name || T('card.imageAlt');
|
|
3928
|
+
// The reader is the close-up. The image keeps its own aspect ratio at the
|
|
3929
|
+
// body's width instead of becoming another thumbnail, which is the only
|
|
3930
|
+
// way a screenshot stays readable.
|
|
3931
|
+
if (full) {
|
|
3932
|
+
return url
|
|
3933
|
+
? h('img', {
|
|
3934
|
+
src: url,
|
|
3935
|
+
alt: label,
|
|
3936
|
+
title: label,
|
|
3937
|
+
loading: 'lazy',
|
|
3938
|
+
width: attachment.width || undefined,
|
|
3939
|
+
height: attachment.height || undefined,
|
|
3940
|
+
style: {
|
|
3941
|
+
display: 'block', maxWidth: '100%', maxHeight: '60vh',
|
|
3942
|
+
width: 'auto', height: 'auto', borderRadius: 6,
|
|
3943
|
+
border: '1px solid ' + C.cardEdge, background: C.canvas,
|
|
3944
|
+
},
|
|
3945
|
+
})
|
|
3946
|
+
: h('span', {
|
|
3947
|
+
'aria-hidden': true,
|
|
3948
|
+
style: {
|
|
3949
|
+
display: 'block', width: 160, height: 90, borderRadius: 6,
|
|
3950
|
+
border: '1px solid ' + C.cardEdge, background: C.canvas,
|
|
3951
|
+
},
|
|
3952
|
+
});
|
|
3953
|
+
}
|
|
3954
|
+
const ratio = attachment.width > 0 && attachment.height > 0
|
|
3955
|
+
? attachment.width + ' / ' + attachment.height
|
|
3956
|
+
: '1 / 1';
|
|
3957
|
+
return h('span', {
|
|
3958
|
+
style: {
|
|
3959
|
+
display: 'block', flex: '0 0 auto', height, aspectRatio: ratio,
|
|
3960
|
+
boxSizing: 'border-box', borderRadius: 6, overflow: 'hidden',
|
|
3961
|
+
border: '1px solid ' + C.cardEdge, background: C.canvas,
|
|
3962
|
+
},
|
|
3963
|
+
}, url
|
|
3964
|
+
? h('img', {
|
|
3965
|
+
src: url,
|
|
3966
|
+
alt: label,
|
|
3967
|
+
title: label,
|
|
3968
|
+
loading: 'lazy',
|
|
3969
|
+
style: { display: 'block', width: '100%', height: '100%', objectFit: 'cover' },
|
|
3970
|
+
})
|
|
3971
|
+
: null);
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
/** A prompt's images in content order, wrapping when the card is narrow. */
|
|
3975
|
+
function PromptImages({ api, sessionId, images, height, full }) {
|
|
3976
|
+
if (!images || images.length === 0) return null;
|
|
3977
|
+
return h('div', {
|
|
3978
|
+
style: {
|
|
3979
|
+
display: 'flex', flexWrap: 'wrap', gap: full ? 8 : 4,
|
|
3980
|
+
margin: full ? '0 0 14px' : '6px 0 4px',
|
|
3981
|
+
},
|
|
3982
|
+
}, images.map((attachment, index) => h(PromptImage, {
|
|
3983
|
+
key: attachment.attachmentId || String(index),
|
|
3984
|
+
api, sessionId, attachment, height, full,
|
|
3985
|
+
})));
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
function NodeCard({ node, selected, dimmed, index, store, api, rootId, match, collapsed, childCount, descendants, isLatest, entering, width, preview }) {
|
|
1930
3989
|
useLocale();
|
|
1931
3990
|
const snapshot = store.getSnapshot();
|
|
1932
3991
|
const composing = snapshot.composingId === node.id;
|
|
1933
|
-
const [expanded, setExpanded] = useState(false);
|
|
1934
3992
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
1935
3993
|
const cardRef = useRef(null);
|
|
3994
|
+
const cardWidth = width || NODE_W;
|
|
3995
|
+
const cardPreview = preview || CARD_SIZES.standard;
|
|
3996
|
+
const images = Array.isArray(node.images) ? node.images : [];
|
|
3997
|
+
// An image-only prompt has no text to print, and the placeholder next to
|
|
3998
|
+
// its thumbnails would read as "the prompt was lost".
|
|
3999
|
+
const question = node.question || '';
|
|
4000
|
+
const questionLabel = question.trim() ? question : images.length ? '' : T('card.noQuestion');
|
|
1936
4001
|
// Freeze this mount's entry decision; streamed tokens do not restart it.
|
|
1937
4002
|
const animateEntry = useRef(entering);
|
|
1938
4003
|
const isRunning = isInProgressNode(node);
|
|
1939
4004
|
const awaiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
4005
|
+
const live = isRunning || awaiting;
|
|
4006
|
+
const reading = readingOf(node);
|
|
4007
|
+
// A running card has a clock. Without it the elapsed time only moved when
|
|
4008
|
+
// a durable event landed, so a long thinking step left the number frozen
|
|
4009
|
+
// for minutes and then jumped — the label looked broken rather than busy.
|
|
4010
|
+
const now = useTicker(isRunning && Boolean(node.startedAt));
|
|
1940
4011
|
const answer = node.answer || '';
|
|
1941
|
-
const answerText = answer.length >
|
|
4012
|
+
const answerText = answer.length > cardPreview.truncate
|
|
4013
|
+
? answer.slice(0, cardPreview.truncate) + T('card.truncated')
|
|
4014
|
+
: answer;
|
|
1942
4015
|
|
|
1943
4016
|
useEffect(() => {
|
|
1944
4017
|
const element = cardRef.current;
|
|
@@ -1971,6 +4044,18 @@ window.__ModuleLoader__.load({
|
|
|
1971
4044
|
: node.status === 'error' ? T('card.status.error')
|
|
1972
4045
|
: node.status === 'stopped' ? T('card.status.stopped')
|
|
1973
4046
|
: T('card.status.done');
|
|
4047
|
+
// A running card's body is a fixed-height window; a settled one shrinks
|
|
4048
|
+
// to its content. The window is what keeps the card — and with it the
|
|
4049
|
+
// whole tree — still while tokens arrive. Shrinking at the end costs one
|
|
4050
|
+
// layout pass per finished branch, which is the trade design.md §6
|
|
4051
|
+
// already makes: pin the position while it streams, lay the tree out
|
|
4052
|
+
// once when the branch is done.
|
|
4053
|
+
const bandStyle = {
|
|
4054
|
+
marginTop: 6, boxSizing: 'border-box',
|
|
4055
|
+
display: 'flex', flexDirection: 'column', overflow: 'hidden',
|
|
4056
|
+
maxHeight: cardPreview.preview,
|
|
4057
|
+
};
|
|
4058
|
+
if (live) bandStyle.height = cardPreview.preview;
|
|
1974
4059
|
|
|
1975
4060
|
return h('div', {
|
|
1976
4061
|
ref: cardRef,
|
|
@@ -1981,24 +4066,27 @@ window.__ModuleLoader__.load({
|
|
|
1981
4066
|
position: 'absolute',
|
|
1982
4067
|
left: 0,
|
|
1983
4068
|
top: 0,
|
|
1984
|
-
width:
|
|
4069
|
+
width: cardWidth,
|
|
1985
4070
|
minHeight: 132,
|
|
1986
4071
|
background: C.card,
|
|
1987
4072
|
border: '1px solid ' + (awaiting || match || selected ? C.accent : C.cardEdge),
|
|
1988
4073
|
borderLeft: '3px solid ' + (selected || isRunning ? C.accent : dimmed ? C.cardEdge : C.line),
|
|
1989
4074
|
borderRadius: 10,
|
|
1990
4075
|
boxShadow: awaiting || selected
|
|
1991
|
-
? '0 0 0 4px ' + C.accentSoft + ',
|
|
4076
|
+
? '0 0 0 4px ' + C.accentSoft + ', var(--dsh-tree-shadow-2)'
|
|
1992
4077
|
: match
|
|
1993
|
-
? '0 0 0 3px ' + C.accentSoft + ',
|
|
1994
|
-
: '
|
|
4078
|
+
? '0 0 0 3px ' + C.accentSoft + ', var(--dsh-tree-shadow-1)'
|
|
4079
|
+
: 'var(--dsh-tree-shadow-1)',
|
|
1995
4080
|
padding: '10px 12px 9px',
|
|
1996
4081
|
opacity: dimmed ? 0.72 : 1,
|
|
1997
4082
|
boxSizing: 'border-box',
|
|
1998
4083
|
cursor: 'pointer',
|
|
1999
4084
|
},
|
|
2000
4085
|
},
|
|
2001
|
-
|
|
4086
|
+
// A reserved header row: the running card carries a [停止] text button
|
|
4087
|
+
// and the settled one a [+] icon button, and those are 26px and 24px.
|
|
4088
|
+
// Without the floor the card drops 2px the moment the turn ends.
|
|
4089
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, marginBottom: 4, minHeight: 26 } },
|
|
2002
4090
|
h(StatusDot, { status: node.status, waiting: awaiting }),
|
|
2003
4091
|
h(Badge, { label: index, tone: C.accent }),
|
|
2004
4092
|
isLatest
|
|
@@ -2011,19 +4099,31 @@ window.__ModuleLoader__.load({
|
|
|
2011
4099
|
}, T('card.latestBadge'))
|
|
2012
4100
|
: null,
|
|
2013
4101
|
h(Badge, { label: statusLabel }),
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
|
|
4102
|
+
// While the turn is open the header clock is wall clock, not the span
|
|
4103
|
+
// between the first and last durable event: the latter is what
|
|
4104
|
+
// `turnCost` can know from the log, and it stops moving the moment the
|
|
4105
|
+
// model thinks for a while without emitting anything durable.
|
|
4106
|
+
(function () {
|
|
4107
|
+
const live = isRunning && node.startedAt && now
|
|
4108
|
+
? {
|
|
4109
|
+
ms: liveElapsedMs(node, now),
|
|
4110
|
+
tokens: node.cost ? node.cost.tokens : 0,
|
|
4111
|
+
cached: node.cost ? node.cost.cached : 0,
|
|
4112
|
+
}
|
|
4113
|
+
: node.cost;
|
|
4114
|
+
if (!live || !(live.ms || live.tokens)) return null;
|
|
4115
|
+
return h('span', {
|
|
4116
|
+
title: [
|
|
4117
|
+
live.ms ? T('card.cost.elapsed', { value: formatCost({ ms: live.ms, tokens: 0 }) }) : '',
|
|
4118
|
+
live.tokens ? T('card.cost.context', { value: formatCost({ ms: 0, tokens: live.tokens }) }) : '',
|
|
4119
|
+
live.cached ? T('card.cost.cached', { value: formatCost({ ms: 0, tokens: live.cached }) }) : '',
|
|
4120
|
+
].filter(Boolean).join(' · '),
|
|
4121
|
+
style: {
|
|
4122
|
+
fontSize: 10.5, color: C.ink3, fontVariantNumeric: 'tabular-nums',
|
|
4123
|
+
whiteSpace: 'nowrap', letterSpacing: '0.02em',
|
|
4124
|
+
},
|
|
4125
|
+
}, formatCost(live));
|
|
4126
|
+
})(),
|
|
2027
4127
|
h('span', { style: { flex: 1 } }),
|
|
2028
4128
|
isRunning
|
|
2029
4129
|
? h('button', {
|
|
@@ -2074,9 +4174,9 @@ window.__ModuleLoader__.load({
|
|
|
2074
4174
|
onMouseDown: (event) => event.stopPropagation(),
|
|
2075
4175
|
onClick: (event) => event.stopPropagation(),
|
|
2076
4176
|
style: {
|
|
2077
|
-
position: 'absolute', top: 28, right: 0, zIndex: 5, background: C.
|
|
4177
|
+
position: 'absolute', top: 28, right: 0, zIndex: 5, background: C.overlay,
|
|
2078
4178
|
border: '1px solid ' + C.cardEdge, borderRadius: 9, padding: 4,
|
|
2079
|
-
boxShadow: '
|
|
4179
|
+
boxShadow: 'var(--dsh-tree-shadow-2)', minWidth: 132,
|
|
2080
4180
|
},
|
|
2081
4181
|
}, h('button', {
|
|
2082
4182
|
onClick: () => {
|
|
@@ -2088,84 +4188,79 @@ window.__ModuleLoader__.load({
|
|
|
2088
4188
|
style: { border: 'none', background: 'transparent', width: '100%', justifyContent: 'flex-start' },
|
|
2089
4189
|
}, T('card.delete'))))
|
|
2090
4190
|
: null),
|
|
4191
|
+
h(PromptImages, { api, sessionId: node.sessionId, images, height: 48 }),
|
|
2091
4192
|
h('div', {
|
|
4193
|
+
className: 'dsh-tree-clamp-3',
|
|
2092
4194
|
style: {
|
|
2093
4195
|
fontSize: 12.5, fontWeight: 600, lineHeight: 1.45, color: C.ink,
|
|
2094
|
-
display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical', overflow: 'hidden',
|
|
2095
4196
|
},
|
|
2096
|
-
},
|
|
4197
|
+
}, questionLabel ? commandTextNodes(questionLabel, 'q') : null),
|
|
4198
|
+
// Everything that grows with the stream lives inside one band. That is
|
|
4199
|
+
// the fix for the card that used to grow and shrink under the reader:
|
|
4200
|
+
// a content-sized answer box plus a one-or-two-line strip moved the
|
|
4201
|
+
// card on almost every token, and every move re-laid out the tree.
|
|
2097
4202
|
h('div', {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
title: answer ? T('card.readTitle') : undefined,
|
|
2104
|
-
style: {
|
|
2105
|
-
...MD.body,
|
|
2106
|
-
marginTop: 6,
|
|
2107
|
-
maxHeight: expanded ? 3000 : 146,
|
|
2108
|
-
overflow: 'hidden',
|
|
2109
|
-
cursor: answer ? 'zoom-in' : 'default',
|
|
2110
|
-
maskImage: (!expanded && answer.length > 320) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
2111
|
-
WebkitMaskImage: (!expanded && answer.length > 320) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
2112
|
-
},
|
|
2113
|
-
}, answer ? renderMarkdown(answerText) : null),
|
|
2114
|
-
h(LiveProgress, { node }),
|
|
2115
|
-
h(Presence, { show: composing, className: 'dsh-tree-composer' },
|
|
2116
|
-
h(Composer, { store, api, rootId, node, active: composing })),
|
|
2117
|
-
answer.length > 260 || childCount > 0
|
|
2118
|
-
? h('div', {
|
|
4203
|
+
className: 'dsh-tree-band',
|
|
4204
|
+
style: bandStyle,
|
|
4205
|
+
},
|
|
4206
|
+
h('div', {
|
|
4207
|
+
className: 'dsh-tree-preview',
|
|
2119
4208
|
style: {
|
|
2120
|
-
|
|
2121
|
-
|
|
4209
|
+
...MD.body,
|
|
4210
|
+
flex: '1 1 auto', minHeight: 0, overflow: 'hidden',
|
|
4211
|
+
maskImage: (answer.length > cardPreview.maskAt) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
4212
|
+
WebkitMaskImage: (answer.length > cardPreview.maskAt) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
2122
4213
|
},
|
|
4214
|
+
}, answer ? renderMarkdown(answerText) : null),
|
|
4215
|
+
h(LiveProgress, { node, now }),
|
|
4216
|
+
h(ThinkingStrip, { node, reading })),
|
|
4217
|
+
h(Presence, { show: composing, className: 'dsh-tree-composer' },
|
|
4218
|
+
h(Composer, { store, api, rootId, node, active: composing })),
|
|
4219
|
+
// One row, always present, with exactly one control that enlarges: the
|
|
4220
|
+
// button. The answer body, the strip and the blank rest of the row all
|
|
4221
|
+
// used to open the same reader too, which is what made "how do I read
|
|
4222
|
+
// this" a guessing game.
|
|
4223
|
+
h('div', {
|
|
4224
|
+
className: 'dsh-tree-actions',
|
|
4225
|
+
style: {
|
|
4226
|
+
marginTop: 9, paddingTop: 7, borderTop: '1px solid ' + C.cardEdge,
|
|
4227
|
+
display: 'flex', alignItems: 'center', gap: 10, minHeight: 22,
|
|
2123
4228
|
},
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round',
|
|
2153
|
-
})))
|
|
2154
|
-
: null,
|
|
2155
|
-
h('span', { style: { flex: 1 } }),
|
|
2156
|
-
childCount > 0
|
|
2157
|
-
? h('button', {
|
|
2158
|
-
onClick: (event) => {
|
|
2159
|
-
event.stopPropagation();
|
|
2160
|
-
store.toggleCollapse(node.id);
|
|
2161
|
-
},
|
|
2162
|
-
title: collapsed ? T('card.unfoldBranch') : T('card.foldBranch'),
|
|
2163
|
-
className: collapsed ? CHIP : LINK,
|
|
4229
|
+
},
|
|
4230
|
+
// The card is a preview, so "read the whole thing" is available on
|
|
4231
|
+
// every card — short answers included. It is a real button (24px
|
|
4232
|
+
// tall) rather than a text link: at a zoomed-out canvas a 16px link
|
|
4233
|
+
// shrinks into a few pixels of hit area, and a missed click reads as
|
|
4234
|
+
// "the button does nothing".
|
|
4235
|
+
h('button', {
|
|
4236
|
+
onClick: (event) => {
|
|
4237
|
+
event.stopPropagation();
|
|
4238
|
+
store.openReader(node.id);
|
|
4239
|
+
},
|
|
4240
|
+
title: T('card.fullscreenTitle'),
|
|
4241
|
+
className: BTN + ' dsh-tree-btn--sm',
|
|
4242
|
+
style: { color: C.accent, cursor: 'zoom-in' },
|
|
4243
|
+
}, T('card.fullscreen'),
|
|
4244
|
+
h('svg', {
|
|
4245
|
+
width: 11, height: 11, viewBox: '0 0 16 16', 'aria-hidden': true,
|
|
4246
|
+
style: { display: 'block', flex: '0 0 auto' },
|
|
4247
|
+
}, h('path', {
|
|
4248
|
+
d: 'M6 2.5H2.5V6 M10 2.5h3.5V6 M6 13.5H2.5V10 M10 13.5h3.5V10',
|
|
4249
|
+
fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round',
|
|
4250
|
+
}))),
|
|
4251
|
+
h('span', { style: { flex: 1 } }),
|
|
4252
|
+
childCount > 0
|
|
4253
|
+
? h('button', {
|
|
4254
|
+
onClick: (event) => {
|
|
4255
|
+
event.stopPropagation();
|
|
4256
|
+
store.toggleCollapse(node.id);
|
|
2164
4257
|
},
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
4258
|
+
title: collapsed ? T('card.unfoldBranch') : T('card.foldBranch'),
|
|
4259
|
+
className: collapsed ? CHIP : LINK,
|
|
4260
|
+
},
|
|
4261
|
+
h(Chevron, { dir: collapsed ? 'right' : 'down', size: 9 }),
|
|
4262
|
+
T(collapsed ? 'card.unfoldDescendants' : 'card.foldDescendants', { count: descendants || childCount }))
|
|
4263
|
+
: null));
|
|
2169
4264
|
}
|
|
2170
4265
|
|
|
2171
4266
|
function Composer({ store, api, rootId, node, active }) {
|
|
@@ -2209,7 +4304,7 @@ window.__ModuleLoader__.load({
|
|
|
2209
4304
|
},
|
|
2210
4305
|
}),
|
|
2211
4306
|
h('div', { style: { display: 'flex', gap: 6, marginTop: 8, alignItems: 'center' } },
|
|
2212
|
-
h('span', { style: { fontSize: 10.5, color: C.ink3
|
|
4307
|
+
h('span', { className: 'dsh-tree-one-line', style: { fontSize: 10.5, color: C.ink3 } },
|
|
2213
4308
|
T('composer.from', { question: (node.question || '').slice(0, 12) })),
|
|
2214
4309
|
h('span', { style: { flex: 1 } }),
|
|
2215
4310
|
h('button', {
|
|
@@ -2233,6 +4328,18 @@ window.__ModuleLoader__.load({
|
|
|
2233
4328
|
for (const node of nodes) seenNodes.current.add(node.id);
|
|
2234
4329
|
}, [nodes]);
|
|
2235
4330
|
const [query, setQuery] = useState('');
|
|
4331
|
+
const [direction, setDirection] = useState(readLayoutDirection);
|
|
4332
|
+
// How much of the answer a card shows is a preference, not a constant:
|
|
4333
|
+
// the same tree is read at different zoom levels on different screens.
|
|
4334
|
+
const [cardSize, setCardSize] = useState(readCardSize);
|
|
4335
|
+
const card = CARD_SIZES[cardSize] || CARD_SIZES.standard;
|
|
4336
|
+
const cardWidth = card.width;
|
|
4337
|
+
// Branch rows: every fork is a real session, so the workspace lists it.
|
|
4338
|
+
// This is the tree's answer to that: finish a branch and it moves into
|
|
4339
|
+
// the archive, or leave the whole tree listed as it has always been.
|
|
4340
|
+
// The effective mode lives in the store so a blocked localStorage cannot
|
|
4341
|
+
// make the toolbar and the turn-end hook disagree.
|
|
4342
|
+
const branchMode = snapshot.branchMode || readBranchMode();
|
|
2236
4343
|
const drag = useRef(null);
|
|
2237
4344
|
const wrapRef = useRef(null);
|
|
2238
4345
|
const searchRef = useRef(null);
|
|
@@ -2264,8 +4371,8 @@ window.__ModuleLoader__.load({
|
|
|
2264
4371
|
return { direct, descendants: descendantCountsOf(liveNodes, childrenOf) };
|
|
2265
4372
|
}, [liveNodes]);
|
|
2266
4373
|
const layout = useMemo(
|
|
2267
|
-
() => layoutTree(liveNodes, collapsedMap, snapshot.heights),
|
|
2268
|
-
[liveNodes, collapsedMap, snapshot.heights]);
|
|
4374
|
+
() => layoutTree(liveNodes, collapsedMap, snapshot.heights, direction, cardWidth),
|
|
4375
|
+
[liveNodes, collapsedMap, snapshot.heights, direction, cardWidth]);
|
|
2269
4376
|
const path = useMemo(
|
|
2270
4377
|
() => (snapshot.selectedId ? pathOf(liveNodes, snapshot.selectedId) : new Set()),
|
|
2271
4378
|
[liveNodes, snapshot.selectedId]);
|
|
@@ -2282,6 +4389,7 @@ window.__ModuleLoader__.load({
|
|
|
2282
4389
|
const labels = useMemo(() => labelMapOf(liveNodes, collapsedMap), [liveNodes, collapsedMap]);
|
|
2283
4390
|
const running = liveNodes.filter((node) => RUNNING_STATUSES.indexOf(node.status) >= 0).length;
|
|
2284
4391
|
const waiting = liveNodes.filter((node) => node.awaiting === 'question' || node.awaiting === 'approval').length;
|
|
4392
|
+
const branchRows = liveNodes.filter((node) => node.kind === 'branch' && node.sessionId).length;
|
|
2285
4393
|
const hiddenCount = hiddenIds.size;
|
|
2286
4394
|
const tombstoned = Object.keys(snapshot.hidden || {}).length;
|
|
2287
4395
|
|
|
@@ -2298,12 +4406,12 @@ window.__ModuleLoader__.load({
|
|
|
2298
4406
|
const pos = layout.positions.get(node.id);
|
|
2299
4407
|
if (!pos) continue;
|
|
2300
4408
|
const height = snapshot.heights[node.id] || NODE_H;
|
|
2301
|
-
if (pos.x +
|
|
4409
|
+
if (pos.x + cardWidth >= left && pos.x <= right && pos.y + height >= top && pos.y <= bottom) {
|
|
2302
4410
|
shown.push(node);
|
|
2303
4411
|
}
|
|
2304
4412
|
}
|
|
2305
4413
|
return shown.length ? shown : liveNodes;
|
|
2306
|
-
}, [liveNodes, layout, view, size, snapshot.heights]);
|
|
4414
|
+
}, [liveNodes, layout, view, size, snapshot.heights, cardWidth]);
|
|
2307
4415
|
|
|
2308
4416
|
/** Reveal first; position only after the expanded layout has committed. */
|
|
2309
4417
|
const focusNode = useCallback((id) => {
|
|
@@ -2316,12 +4424,13 @@ window.__ModuleLoader__.load({
|
|
|
2316
4424
|
if (!pos) { setPendingFocus(null); return; }
|
|
2317
4425
|
const rect = wrapRef.current ? wrapRef.current.getBoundingClientRect() : { width: 900, height: 600 };
|
|
2318
4426
|
const top = (toolbarRef.current ? toolbarRef.current.offsetHeight : 44) + 28;
|
|
4427
|
+
const availableHeight = Math.max(1, rect.height - top);
|
|
2319
4428
|
const height = snapshot.heights[pendingFocus] || NODE_H;
|
|
2320
|
-
const z = Math.max(0.2, Math.min(1, (rect.width - 48) /
|
|
2321
|
-
setView({ z, x: rect.width / 2 - (pos.x +
|
|
2322
|
-
y: top +
|
|
4429
|
+
const z = Math.max(0.2, Math.min(1, (rect.width - 48) / cardWidth, (availableHeight - 32) / height));
|
|
4430
|
+
setView({ z, x: rect.width / 2 - (pos.x + cardWidth / 2) * z,
|
|
4431
|
+
y: top + availableHeight / 2 - (pos.y + height / 2) * z }, true);
|
|
2323
4432
|
setPendingFocus(null);
|
|
2324
|
-
}, [pendingFocus, layout, snapshot.heights]);
|
|
4433
|
+
}, [pendingFocus, layout, snapshot.heights, cardWidth]);
|
|
2325
4434
|
const latest = latestNodeOf(liveNodes);
|
|
2326
4435
|
|
|
2327
4436
|
/** Jump to the next card matching `predicate`, wrapping around. */
|
|
@@ -2365,7 +4474,7 @@ window.__ModuleLoader__.load({
|
|
|
2365
4474
|
announcedRef.current.add(node.id);
|
|
2366
4475
|
// Never yank the canvas out from under the reader overlay, and do not
|
|
2367
4476
|
// steal the viewport when another branch is already waiting.
|
|
2368
|
-
if (firstWait && !store.getSnapshot().
|
|
4477
|
+
if (firstWait && !store.getSnapshot().reading) focusNode(node.id);
|
|
2369
4478
|
}
|
|
2370
4479
|
}, [liveNodes, defaultCollapsedMap, store, focusNode]);
|
|
2371
4480
|
|
|
@@ -2395,8 +4504,45 @@ window.__ModuleLoader__.load({
|
|
|
2395
4504
|
focusNode(hitIds[nextIndex]);
|
|
2396
4505
|
}, [matches, liveNodes, snapshot.selectedId, focusNode]);
|
|
2397
4506
|
|
|
4507
|
+
/**
|
|
4508
|
+
* Whether a wheel event belongs to something that scrolls on its own.
|
|
4509
|
+
*
|
|
4510
|
+
* The canvas claims every wheel event to zoom, so without this guard a
|
|
4511
|
+
* reader scrolling the expanded reasoning text (or the composer) zoomed
|
|
4512
|
+
* the whole canvas instead of scrolling the box under the pointer.
|
|
4513
|
+
*
|
|
4514
|
+
* `overflow-y` comes from the computed style rather than from our own
|
|
4515
|
+
* class names, so a native scrollable — the composer's textarea — is
|
|
4516
|
+
* covered by the same rule. The result distinguishes the two cases that
|
|
4517
|
+
* need different handling:
|
|
4518
|
+
*
|
|
4519
|
+
* 'scroll' — the box can move further in this direction, so the browser
|
|
4520
|
+
* must handle the event natively and the canvas must stay out
|
|
4521
|
+
* of it entirely;
|
|
4522
|
+
* 'edge' — the box is already at that end. The wheel must do nothing
|
|
4523
|
+
* at all: falling through to the zoom is what made the canvas
|
|
4524
|
+
* jump under a reader who had simply reached the bottom.
|
|
4525
|
+
*/
|
|
4526
|
+
function wheelOwner(target, stopAt, deltaY) {
|
|
4527
|
+
if (!target || !stopAt || typeof window === 'undefined') return false;
|
|
4528
|
+
for (let el = target; el && el !== stopAt; el = el.parentElement) {
|
|
4529
|
+
const style = window.getComputedStyle(el);
|
|
4530
|
+
const overflowY = style && style.overflowY;
|
|
4531
|
+
if (overflowY !== 'auto' && overflowY !== 'scroll') continue;
|
|
4532
|
+
const range = el.scrollHeight - el.clientHeight;
|
|
4533
|
+
if (range <= 1) continue;
|
|
4534
|
+
const atTop = el.scrollTop <= 0;
|
|
4535
|
+
const atBottom = el.scrollTop >= range - 1;
|
|
4536
|
+
return deltaY < 0 ? (atTop ? 'edge' : 'scroll') : (atBottom ? 'edge' : 'scroll');
|
|
4537
|
+
}
|
|
4538
|
+
return false;
|
|
4539
|
+
}
|
|
4540
|
+
|
|
2398
4541
|
const onWheel = (event) => {
|
|
4542
|
+
const owned = wheelOwner(event.target, wrapRef.current, event.deltaY);
|
|
4543
|
+
if (owned === 'scroll') return;
|
|
2399
4544
|
event.preventDefault();
|
|
4545
|
+
if (owned === 'edge') return;
|
|
2400
4546
|
const rect = wrapRef.current ? wrapRef.current.getBoundingClientRect() : { left: 0, top: 0 };
|
|
2401
4547
|
const px = event.clientX - rect.left;
|
|
2402
4548
|
const py = event.clientY - rect.top;
|
|
@@ -2458,6 +4604,28 @@ window.__ModuleLoader__.load({
|
|
|
2458
4604
|
}, true);
|
|
2459
4605
|
};
|
|
2460
4606
|
|
|
4607
|
+
const previousDirection = useRef(direction);
|
|
4608
|
+
useEffect(() => {
|
|
4609
|
+
if (previousDirection.current === direction) return;
|
|
4610
|
+
previousDirection.current = direction;
|
|
4611
|
+
if (snapshot.selectedId && layout.positions.has(snapshot.selectedId)) setPendingFocus(snapshot.selectedId);
|
|
4612
|
+
else fit();
|
|
4613
|
+
}, [direction]);
|
|
4614
|
+
|
|
4615
|
+
// A card-size change reflows every card. Keep the selected one where the
|
|
4616
|
+
// user is looking rather than leaving them to hunt the tree again.
|
|
4617
|
+
const previousCardSize = useRef(cardSize);
|
|
4618
|
+
useEffect(() => {
|
|
4619
|
+
if (previousCardSize.current === cardSize) return;
|
|
4620
|
+
previousCardSize.current = cardSize;
|
|
4621
|
+
// Heights were measured against the old card width; keeping them would
|
|
4622
|
+
// lay the new width out with old rows, especially for culled cards
|
|
4623
|
+
// that will not re-render (and therefore never re-measure) soon.
|
|
4624
|
+
store.resetHeights();
|
|
4625
|
+
if (snapshot.selectedId && layout.positions.has(snapshot.selectedId)) setPendingFocus(snapshot.selectedId);
|
|
4626
|
+
else fit();
|
|
4627
|
+
}, [cardSize]);
|
|
4628
|
+
|
|
2461
4629
|
const fittedRef = useRef(false);
|
|
2462
4630
|
useEffect(() => {
|
|
2463
4631
|
if (fittedRef.current || !liveNodes.length || !size.w) return;
|
|
@@ -2492,7 +4660,7 @@ window.__ModuleLoader__.load({
|
|
|
2492
4660
|
|
|
2493
4661
|
return h('div', {
|
|
2494
4662
|
ref: wrapRef,
|
|
2495
|
-
inert: snapshot.
|
|
4663
|
+
inert: snapshot.reading ? true : undefined,
|
|
2496
4664
|
onWheel,
|
|
2497
4665
|
onMouseDown,
|
|
2498
4666
|
onMouseMove,
|
|
@@ -2525,7 +4693,9 @@ window.__ModuleLoader__.load({
|
|
|
2525
4693
|
const active = path.has(edge.id.split('>')[0]) && path.has(edge.id.split('>')[1]);
|
|
2526
4694
|
return h('path', {
|
|
2527
4695
|
key: edge.id,
|
|
2528
|
-
d:
|
|
4696
|
+
d: direction === 'horizontal'
|
|
4697
|
+
? 'M' + edge.x1 + ' ' + edge.y1 + ' C' + (edge.x1 + 40) + ' ' + edge.y1 + ', ' + (edge.x2 - 40) + ' ' + edge.y2 + ', ' + edge.x2 + ' ' + edge.y2
|
|
4698
|
+
: 'M' + edge.x1 + ' ' + edge.y1 + ' C' + edge.x1 + ' ' + (edge.y1 + 40) + ', ' + edge.x2 + ' ' + (edge.y2 - 40) + ', ' + edge.x2 + ' ' + edge.y2,
|
|
2529
4699
|
fill: 'none',
|
|
2530
4700
|
stroke: active ? C.accent : C.line,
|
|
2531
4701
|
strokeWidth: active ? 2 : 1.4,
|
|
@@ -2549,6 +4719,8 @@ window.__ModuleLoader__.load({
|
|
|
2549
4719
|
descendants: counts.descendants.get(node.id) || 0,
|
|
2550
4720
|
isLatest: latest ? latest.id === node.id : false,
|
|
2551
4721
|
entering: !seenNodes.current.has(node.id),
|
|
4722
|
+
width: cardWidth,
|
|
4723
|
+
preview: card,
|
|
2552
4724
|
}));
|
|
2553
4725
|
})),
|
|
2554
4726
|
|
|
@@ -2560,7 +4732,7 @@ window.__ModuleLoader__.load({
|
|
|
2560
4732
|
style: {
|
|
2561
4733
|
position: 'absolute', top: 10, left: 12, right: 12, display: 'flex', gap: 8,
|
|
2562
4734
|
flexWrap: 'wrap', padding: 8, borderRadius: 12, background: C.card,
|
|
2563
|
-
border: '1px solid ' + C.cardEdge, boxShadow: '
|
|
4735
|
+
border: '1px solid ' + C.cardEdge, boxShadow: 'var(--dsh-tree-shadow-1)',
|
|
2564
4736
|
alignItems: 'center', fontSize: 12, color: C.ink3,
|
|
2565
4737
|
},
|
|
2566
4738
|
},
|
|
@@ -2591,6 +4763,18 @@ window.__ModuleLoader__.load({
|
|
|
2591
4763
|
...pillProps(),
|
|
2592
4764
|
}, T('view.restoreHidden', { count: Math.max(hiddenCount, tombstoned) }))
|
|
2593
4765
|
: null,
|
|
4766
|
+
// Branch sessions are real sessions. One control says where they
|
|
4767
|
+
// live: the workspace list, or the archive. Switching also migrates
|
|
4768
|
+
// the branches that already exist in this tree.
|
|
4769
|
+
branchRows > 0
|
|
4770
|
+
? h('button', {
|
|
4771
|
+
onClick: () => {
|
|
4772
|
+
api.setBranchListing(rootId, branchMode === 'quiet' ? 'listed' : 'quiet');
|
|
4773
|
+
},
|
|
4774
|
+
title: branchMode === 'quiet' ? T('view.branchesQuietTitle') : T('view.branchesShownTitle'),
|
|
4775
|
+
...pillProps(),
|
|
4776
|
+
}, branchMode === 'quiet' ? T('view.branchesQuiet') : T('view.branchesShown'))
|
|
4777
|
+
: null,
|
|
2594
4778
|
h('span', { style: { flex: 1 } }),
|
|
2595
4779
|
h('div', {
|
|
2596
4780
|
style: {
|
|
@@ -2638,6 +4822,64 @@ window.__ModuleLoader__.load({
|
|
|
2638
4822
|
onClick: () => zoomBy(1.15),
|
|
2639
4823
|
className: BTN_ICON,
|
|
2640
4824
|
}, h(Icon, { name: 'plus' }))),
|
|
4825
|
+
// Both directions are visible at once, so the current one is a pressed
|
|
4826
|
+
// state rather than something the reader has to infer from the shape of
|
|
4827
|
+
// the canvas. A single toggle whose label never changes cannot say
|
|
4828
|
+
// which way the tree is running.
|
|
4829
|
+
h('div', {
|
|
4830
|
+
role: 'group',
|
|
4831
|
+
'aria-label': T('view.layoutGroup'),
|
|
4832
|
+
title: T('view.layoutTitle'),
|
|
4833
|
+
style: {
|
|
4834
|
+
display: 'flex', alignItems: 'center', gap: 2, padding: 2,
|
|
4835
|
+
border: '1px solid ' + C.cardEdge, borderRadius: 9, background: C.canvas,
|
|
4836
|
+
},
|
|
4837
|
+
},
|
|
4838
|
+
h('button', {
|
|
4839
|
+
className: BTN_SEGMENT,
|
|
4840
|
+
title: T('view.layoutVertical'),
|
|
4841
|
+
'aria-label': T('view.layoutVertical'),
|
|
4842
|
+
'aria-pressed': direction === 'vertical',
|
|
4843
|
+
onClick: () => {
|
|
4844
|
+
if (direction === 'vertical') return;
|
|
4845
|
+
saveLayoutDirection('vertical');
|
|
4846
|
+
setDirection('vertical');
|
|
4847
|
+
},
|
|
4848
|
+
}, h(Icon, { name: 'layoutVertical' })),
|
|
4849
|
+
h('button', {
|
|
4850
|
+
className: BTN_SEGMENT,
|
|
4851
|
+
title: T('view.layoutHorizontal'),
|
|
4852
|
+
'aria-label': T('view.layoutHorizontal'),
|
|
4853
|
+
'aria-pressed': direction === 'horizontal',
|
|
4854
|
+
onClick: () => {
|
|
4855
|
+
if (direction === 'horizontal') return;
|
|
4856
|
+
saveLayoutDirection('horizontal');
|
|
4857
|
+
setDirection('horizontal');
|
|
4858
|
+
},
|
|
4859
|
+
}, h(Icon, { name: 'layoutHorizontal' }))),
|
|
4860
|
+
// Card size is a preference, not a per-session state: the same three
|
|
4861
|
+
// presets are offered everywhere and remembered for this browser.
|
|
4862
|
+
h('div', {
|
|
4863
|
+
role: 'group',
|
|
4864
|
+
'aria-label': T('view.cardSizeGroup'),
|
|
4865
|
+
title: T('view.cardSizeGroup'),
|
|
4866
|
+
style: {
|
|
4867
|
+
display: 'flex', alignItems: 'center', gap: 2, padding: 2,
|
|
4868
|
+
border: '1px solid ' + C.cardEdge, borderRadius: 9, background: C.canvas,
|
|
4869
|
+
},
|
|
4870
|
+
},
|
|
4871
|
+
CARD_SIZE_ORDER.map((size) => h('button', {
|
|
4872
|
+
key: size,
|
|
4873
|
+
className: BTN_SEGMENT,
|
|
4874
|
+
title: T(CARD_SIZE_LABELS[size]),
|
|
4875
|
+
'aria-label': T(CARD_SIZE_LABELS[size]),
|
|
4876
|
+
'aria-pressed': cardSize === size,
|
|
4877
|
+
onClick: () => {
|
|
4878
|
+
if (cardSize === size) return;
|
|
4879
|
+
saveCardSize(size);
|
|
4880
|
+
setCardSize(size);
|
|
4881
|
+
},
|
|
4882
|
+
}, h(Icon, { name: size === 'compact' ? 'cardSmall' : size === 'roomy' ? 'cardRoomy' : 'cardStandard' })))),
|
|
2641
4883
|
h('button', { onClick: fit, className: BTN, title: T('view.fitTitle') }, h(Icon, { name: 'fit' }), T('view.fit')),
|
|
2642
4884
|
h('button', {
|
|
2643
4885
|
disabled: !latest,
|
|
@@ -2653,7 +4895,7 @@ window.__ModuleLoader__.load({
|
|
|
2653
4895
|
style: {
|
|
2654
4896
|
position: 'absolute', right: 12, bottom: 12, width: 168, height: 112,
|
|
2655
4897
|
border: '1px solid ' + C.cardEdge, borderRadius: 8, background: C.card,
|
|
2656
|
-
boxShadow: '
|
|
4898
|
+
boxShadow: 'var(--dsh-tree-shadow-1)', overflow: 'hidden', cursor: 'pointer',
|
|
2657
4899
|
},
|
|
2658
4900
|
onClick: (event) => {
|
|
2659
4901
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
@@ -2697,22 +4939,21 @@ window.__ModuleLoader__.load({
|
|
|
2697
4939
|
const waiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
2698
4940
|
return h('rect', {
|
|
2699
4941
|
key: node.id,
|
|
2700
|
-
x: pos.x, y: pos.y, width:
|
|
4942
|
+
x: pos.x, y: pos.y, width: cardWidth,
|
|
2701
4943
|
height: snapshot.heights[node.id] || NODE_H,
|
|
2702
4944
|
rx: 10,
|
|
2703
4945
|
fill: matches && matches.has(node.id) ? C.accent : waiting ? C.accent : active ? C.accentSoft : C.line,
|
|
2704
4946
|
stroke: active ? C.accent : 'transparent',
|
|
2705
4947
|
strokeWidth: 1 / minimap.scale,
|
|
2706
4948
|
});
|
|
2707
|
-
})
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
})))
|
|
4949
|
+
}),
|
|
4950
|
+
h('rect', {
|
|
4951
|
+
x: -view.x / view.z, y: -view.y / view.z,
|
|
4952
|
+
width: size.w / view.z, height: size.h / view.z,
|
|
4953
|
+
fill: C.accentSoft, fillOpacity: 0.45,
|
|
4954
|
+
stroke: C.accent, strokeWidth: 1.5 / minimap.scale,
|
|
4955
|
+
rx: 6,
|
|
4956
|
+
}))))
|
|
2716
4957
|
: null,
|
|
2717
4958
|
|
|
2718
4959
|
nodes.length === 0
|
|
@@ -2734,25 +4975,63 @@ window.__ModuleLoader__.load({
|
|
|
2734
4975
|
}
|
|
2735
4976
|
|
|
2736
4977
|
function Icon({ name }) {
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
4978
|
+
// A glyph is a stroke path, a list of rounded rects, a list of filled
|
|
4979
|
+
// dots, or a combination. The dots are what make the two layout icons
|
|
4980
|
+
// read as a tree (one parent, two children) instead of as brackets, and
|
|
4981
|
+
// the rects keep the three card sizes on the same radius and stroke.
|
|
4982
|
+
const glyphs = {
|
|
4983
|
+
plus: { d: 'M8 3v10M3 8h10' },
|
|
4984
|
+
minus: { d: 'M3 8h10' },
|
|
4985
|
+
search: { d: 'M11 11l3 3M12 7a5 5 0 1 1-10 0 5 5 0 0 1 10 0' },
|
|
4986
|
+
fit: { d: 'M6 2H2v4M10 2h4v4M2 10v4h4M14 10v4h-4' },
|
|
4987
|
+
latest: { d: 'M8 1v3M8 12v3M1 8h3M12 8h3M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0' },
|
|
4988
|
+
more: { d: 'M3 8h.01M8 8h.01M13 8h.01' },
|
|
4989
|
+
close: { d: 'M4 4l8 8M12 4l-8 8' },
|
|
4990
|
+
// The two layout directions: a parent node, its route and two children.
|
|
4991
|
+
// The direction is the direction of the route, so the pair reads at a
|
|
4992
|
+
// glance even at 16px.
|
|
4993
|
+
layoutVertical: {
|
|
4994
|
+
d: 'M8 6V7.8M4 7.8h8M4 7.8v1.6M12 7.8v1.6',
|
|
4995
|
+
dots: [[8, 4.6, 1.35], [4, 10.8, 1.35], [12, 10.8, 1.35]],
|
|
4996
|
+
},
|
|
4997
|
+
layoutHorizontal: {
|
|
4998
|
+
d: 'M6 8h1.8M7.8 4v8M7.8 4h1.6M7.8 12h1.6',
|
|
4999
|
+
dots: [[4.6, 8, 1.35], [10.8, 4, 1.35], [10.8, 12, 1.35]],
|
|
5000
|
+
},
|
|
5001
|
+
// Card size: three rounded cards of increasing width. Rounded rects
|
|
5002
|
+
// share one radius family, so the set looks drawn rather than typed.
|
|
5003
|
+
cardSmall: { rects: [[5.5, 5.5, 5, 5, 1.2]] },
|
|
5004
|
+
cardStandard: { rects: [[4, 4, 8, 8, 1.5]] },
|
|
5005
|
+
cardRoomy: { rects: [[2.5, 2.5, 11, 11, 1.8]] },
|
|
2744
5006
|
};
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
5007
|
+
const glyph = glyphs[name];
|
|
5008
|
+
if (!glyph) return null;
|
|
5009
|
+
const stroke = {
|
|
5010
|
+
fill: 'none', stroke: 'currentColor', strokeWidth: 1.7,
|
|
2748
5011
|
strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
2749
|
-
}
|
|
5012
|
+
};
|
|
5013
|
+
const parts = [];
|
|
5014
|
+
if (glyph.d) parts.push(h('path', { key: 'path', d: glyph.d, ...stroke }));
|
|
5015
|
+
(glyph.rects || []).forEach((rect, index) => parts.push(h('rect', {
|
|
5016
|
+
key: 'rect-' + index,
|
|
5017
|
+
x: rect[0], y: rect[1], width: rect[2], height: rect[3], rx: rect[4], ...stroke,
|
|
5018
|
+
})));
|
|
5019
|
+
(glyph.dots || []).forEach((dot, index) => parts.push(h('circle', {
|
|
5020
|
+
key: 'dot-' + index, cx: dot[0], cy: dot[1], r: dot[2], fill: 'currentColor',
|
|
5021
|
+
})));
|
|
5022
|
+
return h('svg', {
|
|
5023
|
+
width: 16, height: 16, viewBox: '0 0 16 16', 'aria-hidden': true,
|
|
5024
|
+
style: { display: 'block', flexShrink: 0 },
|
|
5025
|
+
}, parts);
|
|
2750
5026
|
}
|
|
2751
5027
|
|
|
2752
5028
|
// Buttons: all paint lives in CSS so :hover/:active/:focus-visible can exist.
|
|
2753
5029
|
// Inline styles only carry layout that varies per call site.
|
|
2754
5030
|
const BTN = 'dsh-tree-btn';
|
|
2755
5031
|
const BTN_ICON = 'dsh-tree-btn dsh-tree-btn--icon';
|
|
5032
|
+
// A segment inside the layout group: same hit area as an icon button, but
|
|
5033
|
+
// it borrows the group's border instead of drawing its own.
|
|
5034
|
+
const BTN_SEGMENT = 'dsh-tree-btn dsh-tree-btn--icon dsh-tree-btn--segment';
|
|
2756
5035
|
const BTN_PRIMARY = 'dsh-tree-btn dsh-tree-btn--primary';
|
|
2757
5036
|
const CHIP = 'dsh-tree-chip';
|
|
2758
5037
|
const LINK = 'dsh-tree-link';
|
|
@@ -2807,63 +5086,119 @@ window.__ModuleLoader__.load({
|
|
|
2807
5086
|
}
|
|
2808
5087
|
}
|
|
2809
5088
|
|
|
2810
|
-
|
|
5089
|
+
/**
|
|
5090
|
+
* The full-screen reader.
|
|
5091
|
+
*
|
|
5092
|
+
* A native <dialog> opened with `showModal()`, not a hand-built overlay.
|
|
5093
|
+
* The browser then owns everything that is easy to get wrong here: focus is
|
|
5094
|
+
* contained, the page behind is inert, Esc and the back gesture close it,
|
|
5095
|
+
* and it renders in the top layer — which matters here because a card lives
|
|
5096
|
+
* inside the transformed canvas, so a positioned child of it would be
|
|
5097
|
+
* clipped and scaled along with the canvas.
|
|
5098
|
+
*
|
|
5099
|
+
* The plugin therefore writes no focus trap, no Tab handler, no Esc handler
|
|
5100
|
+
* and no focus restoration; it only mirrors the element's `close` event back
|
|
5101
|
+
* into React state.
|
|
5102
|
+
*/
|
|
5103
|
+
function Reader({ node, open, onClose, pane, onPane, api }) {
|
|
2811
5104
|
useLocale();
|
|
2812
|
-
const
|
|
2813
|
-
const closeRef = useRef(null);
|
|
5105
|
+
const dialogRef = useRef(null);
|
|
2814
5106
|
const close = useRef(onClose);
|
|
2815
5107
|
close.current = onClose;
|
|
5108
|
+
// Reading width is personal, not per-node: a long answer wants a longer
|
|
5109
|
+
// measure on a wide screen, and the choice survives closing the reader.
|
|
5110
|
+
const [width, setWidth] = useState(readReaderWidth);
|
|
5111
|
+
const readerWidth = READER_WIDTHS[width] || READER_WIDTHS.standard;
|
|
5112
|
+
// The click that opens the dialog can be followed by a second click (a
|
|
5113
|
+
// nervous double click, or "it did nothing" impatience). Light dismiss
|
|
5114
|
+
// would then close the reader the user was waiting for, which looks
|
|
5115
|
+
// exactly like the button not working. Ignore backdrop clicks for a
|
|
5116
|
+
// moment after opening, then keep the affordance.
|
|
5117
|
+
const openedAt = useRef(0);
|
|
5118
|
+
|
|
5119
|
+
// `show()` would leave the page interactive; the reader is blocking.
|
|
2816
5120
|
useEffect(() => {
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
if (
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
event.preventDefault();
|
|
2830
|
-
if (last) last.focus();
|
|
2831
|
-
} else if (!event.shiftKey && document.activeElement === last) {
|
|
2832
|
-
event.preventDefault();
|
|
2833
|
-
if (first) first.focus();
|
|
5121
|
+
const dialog = dialogRef.current;
|
|
5122
|
+
if (!dialog) return undefined;
|
|
5123
|
+
if (open) {
|
|
5124
|
+
if (!dialog.open) {
|
|
5125
|
+
// A refused showModal() (a host CSS quirk, a stale top-layer
|
|
5126
|
+
// transition) must still surface the reader: fall back to the
|
|
5127
|
+
// non-modal attribute rather than leaving the click with no result.
|
|
5128
|
+
try {
|
|
5129
|
+
if (typeof dialog.showModal === 'function') dialog.showModal();
|
|
5130
|
+
else dialog.setAttribute('open', '');
|
|
5131
|
+
} catch (error) {
|
|
5132
|
+
dialog.setAttribute('open', '');
|
|
2834
5133
|
}
|
|
5134
|
+
// `showModal()` focuses the first focusable descendant, which here
|
|
5135
|
+
// is the close button — and a reflexive Enter would then dismiss
|
|
5136
|
+
// the document the reader just opened. Focusing the dialog itself
|
|
5137
|
+
// (it is the element with `aria-labelledby`) leaves Enter inert and
|
|
5138
|
+
// still hands the first Tab to the close button.
|
|
5139
|
+
if (typeof dialog.focus === 'function') dialog.focus();
|
|
5140
|
+
openedAt.current = Date.now();
|
|
2835
5141
|
}
|
|
2836
|
-
}
|
|
2837
|
-
|
|
5142
|
+
} else if (dialog.open) {
|
|
5143
|
+
dialog.close();
|
|
5144
|
+
}
|
|
5145
|
+
return undefined;
|
|
5146
|
+
}, [open, node && node.id]);
|
|
5147
|
+
|
|
5148
|
+
// Esc, the back gesture and light dismiss all end in a `close` event.
|
|
5149
|
+
//
|
|
5150
|
+
// The dependency is the node, not `[]`: the dialog is not rendered until
|
|
5151
|
+
// a node is open, so an effect that runs once on mount finds no element,
|
|
5152
|
+
// bails out, and never runs again. The browser still dismisses the
|
|
5153
|
+
// element on Esc, but nothing mirrors it back into the store — the canvas
|
|
5154
|
+
// stays inert with no dialog left to close it, and every click in the
|
|
5155
|
+
// view dies until the tab remounts.
|
|
5156
|
+
useEffect(() => {
|
|
5157
|
+
const dialog = dialogRef.current;
|
|
5158
|
+
if (!dialog) return undefined;
|
|
5159
|
+
const onDismiss = () => close.current();
|
|
5160
|
+
// `cancel` fires before the browser closes the dialog, so clearing the
|
|
5161
|
+
// store here lifts the canvas's `inert` before the browser restores
|
|
5162
|
+
// focus to the button that opened the reader. Doing it only on `close`
|
|
5163
|
+
// left focus on <body>, because the opener was still inside an inert
|
|
5164
|
+
// subtree at restore time.
|
|
5165
|
+
const onCancel = () => close.current();
|
|
5166
|
+
dialog.addEventListener('close', onDismiss);
|
|
5167
|
+
dialog.addEventListener('cancel', onCancel);
|
|
2838
5168
|
return () => {
|
|
2839
|
-
|
|
2840
|
-
|
|
5169
|
+
dialog.removeEventListener('close', onDismiss);
|
|
5170
|
+
dialog.removeEventListener('cancel', onCancel);
|
|
2841
5171
|
};
|
|
2842
|
-
}, [
|
|
5172
|
+
}, [node && node.id]);
|
|
2843
5173
|
|
|
2844
5174
|
if (!node) return null;
|
|
2845
|
-
|
|
2846
|
-
|
|
5175
|
+
const reading = readingOf(node);
|
|
5176
|
+
const images = Array.isArray(node.images) ? node.images : [];
|
|
5177
|
+
const question = node.question || '';
|
|
5178
|
+
const questionLabel = question.trim() ? question : images.length ? '' : T('card.noQuestion');
|
|
5179
|
+
const activePane = pane === 'reasoning' && reading.hasReasoning ? 'reasoning' : 'result';
|
|
5180
|
+
const titleId = 'dsh-tree-reader-title-' + (node.id || 'node');
|
|
5181
|
+
return h('dialog', {
|
|
5182
|
+
ref: dialogRef,
|
|
2847
5183
|
className: 'dsh-tree-reader',
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
5184
|
+
// The modal already carries role="dialog" and aria-modal: adding them
|
|
5185
|
+
// here would announce the overlay twice.
|
|
5186
|
+
'aria-labelledby': titleId,
|
|
5187
|
+
// The dialog is focusable so the explicit focus() above can land on it.
|
|
5188
|
+
tabIndex: '-1',
|
|
5189
|
+
// Click-outside dismissal is handled below instead of with `closedby`:
|
|
5190
|
+
// the native light dismiss cannot tell the opening click (or a second
|
|
5191
|
+
// click at the same spot) from a deliberate backdrop click.
|
|
5192
|
+
onClick: (event) => {
|
|
5193
|
+
if (event.target !== dialogRef.current) return; // a click inside the content
|
|
5194
|
+
if (Date.now() - openedAt.current < 350) return; // the click that opened it
|
|
5195
|
+
close.current();
|
|
2852
5196
|
},
|
|
5197
|
+
// Width is a preset rather than a drag handle: a dialog with a resize
|
|
5198
|
+
// grip is one more thing to fight with the keyboard and on touch, and
|
|
5199
|
+
// two widths cover "keep it out of the way" and "give me the line".
|
|
5200
|
+
style: { width: readerWidth, maxWidth: 'calc(100vw - 24px)' },
|
|
2853
5201
|
},
|
|
2854
|
-
h('div', {
|
|
2855
|
-
ref: panelRef,
|
|
2856
|
-
className: 'dsh-tree-reader-panel',
|
|
2857
|
-
role: 'dialog',
|
|
2858
|
-
'aria-modal': true,
|
|
2859
|
-
'aria-label': node.question || T('card.noQuestion'),
|
|
2860
|
-
onClick: (event) => event.stopPropagation(),
|
|
2861
|
-
style: {
|
|
2862
|
-
width: '100%', maxWidth: 820, maxHeight: '100%', background: C.card,
|
|
2863
|
-
borderRadius: 14, boxShadow: '0 20px 60px rgba(0,0,0,0.28)',
|
|
2864
|
-
display: 'flex', flexDirection: 'column', overflow: 'hidden',
|
|
2865
|
-
},
|
|
2866
|
-
},
|
|
2867
5202
|
h('div', {
|
|
2868
5203
|
style: {
|
|
2869
5204
|
padding: '14px 20px 11px', borderBottom: '1px solid ' + C.line,
|
|
@@ -2875,22 +5210,94 @@ window.__ModuleLoader__.load({
|
|
|
2875
5210
|
style: { fontSize: 10.5, color: C.ink3, letterSpacing: '0.05em', marginBottom: 4 },
|
|
2876
5211
|
}, (node.kind === 'branch' ? T('reader.branch') : T('reader.mainline')) + ' · ' + (node.id || '')),
|
|
2877
5212
|
h('div', {
|
|
5213
|
+
id: titleId,
|
|
2878
5214
|
style: { fontSize: 15, fontWeight: 600, lineHeight: 1.5, color: C.ink },
|
|
2879
|
-
},
|
|
5215
|
+
}, questionLabel ? commandTextNodes(questionLabel, 'rq') : null)),
|
|
2880
5216
|
h('button', {
|
|
2881
|
-
ref: closeRef,
|
|
2882
5217
|
onClick: onClose,
|
|
2883
5218
|
title: T('reader.close'),
|
|
2884
5219
|
'aria-label': T('reader.closeLabel'),
|
|
2885
5220
|
className: 'dsh-tree-btn dsh-tree-btn--icon',
|
|
2886
5221
|
style: { width: 30, height: 30, minWidth: 30, minHeight: 30 },
|
|
2887
5222
|
}, h(Icon, { name: 'close' }))),
|
|
5223
|
+
// The two control groups share this row at opposite ends rather than
|
|
5224
|
+
// crowding the title: the pane switch is content navigation, the
|
|
5225
|
+
// width group is a preference, and together they would leave the
|
|
5226
|
+
// question about a third of an 820px header.
|
|
2888
5227
|
h('div', {
|
|
5228
|
+
style: {
|
|
5229
|
+
padding: '6px 20px', borderBottom: '1px solid ' + C.line,
|
|
5230
|
+
display: 'flex', alignItems: 'center', gap: 8, minHeight: 46,
|
|
5231
|
+
boxSizing: 'border-box',
|
|
5232
|
+
},
|
|
5233
|
+
},
|
|
5234
|
+
reading.hasReasoning
|
|
5235
|
+
? h('div', {
|
|
5236
|
+
role: 'group',
|
|
5237
|
+
'aria-label': T('reader.paneGroup'),
|
|
5238
|
+
title: T('reader.paneGroup'),
|
|
5239
|
+
style: {
|
|
5240
|
+
display: 'flex', alignItems: 'center', gap: 2, padding: 2, flex: '0 0 auto',
|
|
5241
|
+
border: '1px solid ' + C.cardEdge, borderRadius: 8, background: C.canvas,
|
|
5242
|
+
},
|
|
5243
|
+
},
|
|
5244
|
+
h('button', {
|
|
5245
|
+
className: BTN + ' dsh-tree-btn--sm',
|
|
5246
|
+
title: T('reader.paneAnswer'),
|
|
5247
|
+
'aria-pressed': activePane === 'result',
|
|
5248
|
+
onClick: () => onPane('result'),
|
|
5249
|
+
}, T('reader.paneAnswer')),
|
|
5250
|
+
h('button', {
|
|
5251
|
+
className: BTN + ' dsh-tree-btn--sm',
|
|
5252
|
+
title: T('card.think'),
|
|
5253
|
+
'aria-pressed': activePane === 'reasoning',
|
|
5254
|
+
onClick: () => onPane('reasoning'),
|
|
5255
|
+
}, T('card.think')))
|
|
5256
|
+
: null,
|
|
5257
|
+
h('span', { style: { flex: 1 } }),
|
|
5258
|
+
h('div', {
|
|
5259
|
+
role: 'group',
|
|
5260
|
+
'aria-label': T('reader.widthGroup'),
|
|
5261
|
+
title: T('reader.widthGroup'),
|
|
5262
|
+
style: {
|
|
5263
|
+
display: 'flex', alignItems: 'center', gap: 2, padding: 2, flex: '0 0 auto',
|
|
5264
|
+
border: '1px solid ' + C.cardEdge, borderRadius: 8, background: C.canvas,
|
|
5265
|
+
},
|
|
5266
|
+
},
|
|
5267
|
+
h('button', {
|
|
5268
|
+
className: BTN + ' dsh-tree-btn--sm',
|
|
5269
|
+
title: T('reader.widthStandard'),
|
|
5270
|
+
'aria-label': T('reader.widthStandard'),
|
|
5271
|
+
'aria-pressed': width === 'standard',
|
|
5272
|
+
onClick: () => {
|
|
5273
|
+
if (width === 'standard') return;
|
|
5274
|
+
saveReaderWidth('standard');
|
|
5275
|
+
setWidth('standard');
|
|
5276
|
+
},
|
|
5277
|
+
}, T('reader.widthStandard')),
|
|
5278
|
+
h('button', {
|
|
5279
|
+
className: BTN + ' dsh-tree-btn--sm',
|
|
5280
|
+
title: T('reader.widthWide'),
|
|
5281
|
+
'aria-label': T('reader.widthWide'),
|
|
5282
|
+
'aria-pressed': width === 'wide',
|
|
5283
|
+
onClick: () => {
|
|
5284
|
+
if (width === 'wide') return;
|
|
5285
|
+
saveReaderWidth('wide');
|
|
5286
|
+
setWidth('wide');
|
|
5287
|
+
},
|
|
5288
|
+
}, T('reader.widthWide')))),
|
|
5289
|
+
h('div', {
|
|
5290
|
+
// One body, one scroll container. Keyed by the pane so switching
|
|
5291
|
+
// starts the other document at its own top instead of inheriting
|
|
5292
|
+
// the offset of the one you left.
|
|
5293
|
+
key: activePane,
|
|
5294
|
+
className: 'dsh-tree-scroll',
|
|
2889
5295
|
style: {
|
|
2890
5296
|
padding: '18px 22px 22px', overflow: 'auto', flex: 1,
|
|
2891
5297
|
...MD.body, fontSize: 13.4, lineHeight: 1.85,
|
|
2892
5298
|
},
|
|
2893
|
-
},
|
|
5299
|
+
}, h(ReaderPane, { node, reading, pane: activePane, api })),
|
|
5300
|
+
|
|
2894
5301
|
h('div', {
|
|
2895
5302
|
style: {
|
|
2896
5303
|
padding: '8px 20px', borderTop: '1px solid ' + C.cardEdge, fontSize: 10.5,
|
|
@@ -2901,7 +5308,7 @@ window.__ModuleLoader__.load({
|
|
|
2901
5308
|
h('span', { style: { flex: 1 } }),
|
|
2902
5309
|
node.cost && (node.cost.ms || node.cost.tokens)
|
|
2903
5310
|
? h('span', null, formatCost(node.cost))
|
|
2904
|
-
: null))
|
|
5311
|
+
: null));
|
|
2905
5312
|
}
|
|
2906
5313
|
|
|
2907
5314
|
function TreeView(props) {
|
|
@@ -2932,20 +5339,40 @@ window.__ModuleLoader__.load({
|
|
|
2932
5339
|
}, []);
|
|
2933
5340
|
|
|
2934
5341
|
const snapshot = store.getSnapshot();
|
|
2935
|
-
const
|
|
5342
|
+
const readingState = snapshot.reading;
|
|
5343
|
+
const reading = readingState ? store.getNode(readingState.nodeId) : undefined;
|
|
2936
5344
|
const readerNode = useRef(null);
|
|
2937
5345
|
if (reading) readerNode.current = reading;
|
|
2938
|
-
|
|
5346
|
+
// A reading id that no longer resolves (the node was pruned or hidden)
|
|
5347
|
+
// would leave the canvas inert with no dialog to close. Treat it as shut.
|
|
5348
|
+
useEffect(() => {
|
|
5349
|
+
if (readingState && !reading) store.closeReader();
|
|
5350
|
+
}, [readingState, reading, store]);
|
|
5351
|
+
|
|
5352
|
+
// The canvas is a view, not an overlay over the host's chrome. The
|
|
5353
|
+
// composer-overlay contract hands it the whole scrollport below the
|
|
5354
|
+
// header, and `ensureStyles()` hides the composer seat for the same
|
|
5355
|
+
// span, so the tab row and the session title keep their own space and
|
|
5356
|
+
// stay clickable no matter what the host's stacking order is.
|
|
2939
5357
|
return h('div', {
|
|
2940
5358
|
ref: hostRef,
|
|
2941
5359
|
className: 'dsh-tree-root',
|
|
5360
|
+
'data-conversation-composer-overlay': '',
|
|
2942
5361
|
style: {
|
|
2943
|
-
position: 'relative', width: '100%', height: '100%', minHeight:
|
|
5362
|
+
position: 'relative', width: '100%', height: '100%', minHeight: 0,
|
|
2944
5363
|
overflow: 'hidden', fontFamily: FONT, color: C.ink, background: C.canvas,
|
|
2945
5364
|
},
|
|
2946
5365
|
},
|
|
2947
5366
|
h(Boundary, null, h(Canvas, { key: rootId, store, api, rootId, size })),
|
|
2948
|
-
h(Reader, {
|
|
5367
|
+
h(Reader, {
|
|
5368
|
+
key: rootId,
|
|
5369
|
+
node: reading || readerNode.current,
|
|
5370
|
+
api,
|
|
5371
|
+
open: Boolean(reading),
|
|
5372
|
+
pane: (readingState && readingState.pane) || 'result',
|
|
5373
|
+
onPane: (pane) => store.setReaderPane(pane),
|
|
5374
|
+
onClose: () => store.closeReader(),
|
|
5375
|
+
}));
|
|
2949
5376
|
}
|
|
2950
5377
|
|
|
2951
5378
|
// ------------------------------------------------------------------ mount
|
|
@@ -2964,10 +5391,59 @@ window.__ModuleLoader__.load({
|
|
|
2964
5391
|
'@keyframes dshTreeSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }',
|
|
2965
5392
|
'@keyframes dshTreePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }',
|
|
2966
5393
|
'.dsh-tree-root { --tree-fast: 120ms; --tree-enter: 240ms; --tree-exit: ' + MOTION_EXIT_MS + 'ms; --tree-ease: cubic-bezier(.2,.8,.2,1); --tree-spring: cubic-bezier(.16,1.3,.3,1); }',
|
|
5394
|
+
// Elevation in two themes. A black-alpha shadow is what gives a card depth
|
|
5395
|
+
// on a white canvas, and on a dark canvas it is invisible — the surface
|
|
5396
|
+
// has to separate by a heavier shadow instead. The three levels are
|
|
5397
|
+
// declared once and read by both themes.
|
|
5398
|
+
'.dsh-tree-root { --dsh-tree-shadow-1: 0 2px 8px rgba(0,0,0,0.05); --dsh-tree-shadow-2: 0 8px 22px rgba(0,0,0,0.12); --dsh-tree-shadow-3: 0 20px 60px rgba(0,0,0,0.28); }',
|
|
5399
|
+
'body[data-ds-dark-theme] .dsh-tree-root { --dsh-tree-shadow-1: 0 2px 10px rgba(0,0,0,0.45); --dsh-tree-shadow-2: 0 10px 28px rgba(0,0,0,0.55); --dsh-tree-shadow-3: 0 22px 64px rgba(0,0,0,0.65); }',
|
|
5400
|
+
// Native affordances follow the host theme too: form controls and
|
|
5401
|
+
// scrollbars take their colour from `color-scheme`, and the plugin's own
|
|
5402
|
+
// scroll areas use the host's scrollbar tokens.
|
|
5403
|
+
'.dsh-tree-root { color-scheme: light; }',
|
|
5404
|
+
'body[data-ds-dark-theme] .dsh-tree-root { color-scheme: dark; }',
|
|
5405
|
+
'.dsh-tree-clamp-3 {',
|
|
5406
|
+
' display: -webkit-box; -webkit-box-orient: vertical;',
|
|
5407
|
+
' -webkit-line-clamp: 3; line-clamp: 3;',
|
|
5408
|
+
' overflow: hidden; overflow-wrap: break-word;',
|
|
5409
|
+
'}',
|
|
5410
|
+
'.dsh-tree-one-line {',
|
|
5411
|
+
' min-inline-size: 0; overflow: hidden; text-overflow: ellipsis;',
|
|
5412
|
+
' white-space: nowrap;',
|
|
5413
|
+
'}',
|
|
5414
|
+
'.dsh-tree-scroll { scrollbar-width: thin; scrollbar-color: var(--dsw-alias-scrollbar-bg-l1) transparent; }',
|
|
5415
|
+
'.dsh-tree-scroll:hover { scrollbar-color: var(--dsw-alias-scrollbar-hover-l1) transparent; }',
|
|
5416
|
+
// Tables: a wide one scrolls sideways inside its own wrapper instead of
|
|
5417
|
+
// widening the card or the reader. The wrapper is the scroll container,
|
|
5418
|
+
// so the table keeps its natural width and cells stay on one line.
|
|
5419
|
+
'.dsh-tree-table-wrap {',
|
|
5420
|
+
' max-width: 100%; margin: 0.7em 0; overflow-x: auto;',
|
|
5421
|
+
' scrollbar-width: thin; scrollbar-color: var(--dsw-alias-scrollbar-bg-l1) transparent;',
|
|
5422
|
+
'}',
|
|
5423
|
+
'.dsh-tree-table {',
|
|
5424
|
+
' border-collapse: collapse; font-size: 0.93em; line-height: 1.5;',
|
|
5425
|
+
' width: max-content; min-width: 100%;',
|
|
5426
|
+
'}',
|
|
5427
|
+
'.dsh-tree-table th, .dsh-tree-table td {',
|
|
5428
|
+
' border: 1px solid var(--dsw-alias-border-l1); padding: 6px 10px;',
|
|
5429
|
+
' vertical-align: top; overflow-wrap: break-word;',
|
|
5430
|
+
'}',
|
|
5431
|
+
'.dsh-tree-table th {',
|
|
5432
|
+
' font-weight: 600; white-space: nowrap;',
|
|
5433
|
+
' background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);',
|
|
5434
|
+
'}',
|
|
5435
|
+
'.dsh-tree-table tbody tr:nth-child(even) td {',
|
|
5436
|
+
' background: color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent);',
|
|
5437
|
+
'}',
|
|
5438
|
+
// The canvas is a view, so the host header (session title and the View
|
|
5439
|
+
// tab row) keeps its own space above the scrollport and never needs a
|
|
5440
|
+
// z-index to survive it. Only the composer seat is given up: the canvas
|
|
5441
|
+
// owns the footer while this View is mounted, and the seat returns the
|
|
5442
|
+
// moment the View unmounts. Scoped off `data-conversation-scroll` rather
|
|
5443
|
+
// than a hashed class so it does not depend on the host's build.
|
|
5444
|
+
'[data-conversation-scroll]:has(> [data-slot="conversation.session"] .dsh-tree-root) > [data-composer-seat] { display: none !important; }',
|
|
2967
5445
|
'@keyframes dshTreeReveal { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }',
|
|
2968
5446
|
'@keyframes dshTreeDismiss { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(3px) scale(.99); } }',
|
|
2969
|
-
'@keyframes dshTreeFadeIn { from { opacity: 0; } to { opacity: 1; } }',
|
|
2970
|
-
'@keyframes dshTreeFadeOut { from { opacity: 1; } to { opacity: 0; } }',
|
|
2971
5447
|
'.dsh-tree-card { transition: opacity var(--tree-enter) var(--tree-ease), box-shadow var(--tree-enter) var(--tree-ease), border-color var(--tree-fast) ease; }',
|
|
2972
5448
|
'.dsh-tree-card--enter { animation: dshTreeReveal var(--tree-enter) var(--tree-ease); }',
|
|
2973
5449
|
'.dsh-tree-presence[data-open="true"] { animation: dshTreeReveal var(--tree-enter) var(--tree-ease); }',
|
|
@@ -2975,10 +5451,44 @@ window.__ModuleLoader__.load({
|
|
|
2975
5451
|
'.dsh-tree-menu { transform-origin: top right; }',
|
|
2976
5452
|
'.dsh-tree-menu[data-open="true"] { animation-timing-function: var(--tree-spring); }',
|
|
2977
5453
|
'.dsh-tree-composer { transform-origin: top center; }',
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
'
|
|
5454
|
+
// A slash command or skill call reads as one token, with the host's
|
|
5455
|
+
// reference-chip treatment: the business accent, a 4px pad and the
|
|
5456
|
+
// shared small radius. `line-height: inherit` keeps the chip on the
|
|
5457
|
+
// text's own baseline, so a card preview does not gain a line.
|
|
5458
|
+
'.dsh-tree-command {',
|
|
5459
|
+
' padding: 0 4px; border-radius: var(--dsw-radius-sm, 4px); line-height: inherit;',
|
|
5460
|
+
' color: var(--dsw-alias-state-business-primary); font-weight: 500; white-space: nowrap;',
|
|
5461
|
+
' background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 10%, transparent);',
|
|
5462
|
+
'}',
|
|
5463
|
+
// The reader is a native modal dialog; only its surface belongs to the
|
|
5464
|
+
// plugin.
|
|
5465
|
+
// The reader opens instantly. An animated top-layer surface is allowed
|
|
5466
|
+
// to leave the reading view invisible for a frame, and a fast
|
|
5467
|
+
// close/reopen pair could leave it stuck mid-transition — from the
|
|
5468
|
+
// user's side the click then looks like it did nothing. The dialog
|
|
5469
|
+
// therefore has no transition of its own; the backdrop still carries
|
|
5470
|
+
// the scrim, so the switch does not read as a page flash.
|
|
5471
|
+
'.dsh-tree-reader {',
|
|
5472
|
+
' margin: auto; padding: 0; border: none; margin-block: auto;',
|
|
5473
|
+
' max-height: calc(100vh - 56px);',
|
|
5474
|
+
' background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary);',
|
|
5475
|
+
' border-radius: 14px; box-shadow: var(--dsh-tree-shadow-3); overflow: hidden;',
|
|
5476
|
+
// MANDATORY: without this, a scroll inside the dialog chains to the page
|
|
5477
|
+
// behind it as soon as the dialog reaches its own scroll boundary.
|
|
5478
|
+
' overscroll-behavior: contain;',
|
|
5479
|
+
'}',
|
|
5480
|
+
// display is set only while open: an unconditional display would override
|
|
5481
|
+
// the closed state and leave the dialog permanently on screen.
|
|
5482
|
+
'.dsh-tree-reader[open] {',
|
|
5483
|
+
' display: flex; flex-direction: column;',
|
|
5484
|
+
'}',
|
|
5485
|
+
// MANDATORY: ::backdrop is not a scroll container by default, so
|
|
5486
|
+
// overscroll-behavior alone would not stop a gesture over the backdrop
|
|
5487
|
+
// from scrolling the page underneath.
|
|
5488
|
+
'.dsh-tree-reader::backdrop {',
|
|
5489
|
+
' background: var(--dsw-alias-bg-mask-1);',
|
|
5490
|
+
' overflow: hidden; overscroll-behavior: contain;',
|
|
5491
|
+
'}',
|
|
2982
5492
|
// Every control shares one geometry so the toolbar reads as one row.
|
|
2983
5493
|
'.dsh-tree-btn {',
|
|
2984
5494
|
' border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1);',
|
|
@@ -3001,7 +5511,19 @@ window.__ModuleLoader__.load({
|
|
|
3001
5511
|
' outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px;',
|
|
3002
5512
|
'}',
|
|
3003
5513
|
'.dsh-tree-btn[disabled] { opacity: 0.45; cursor: default; }',
|
|
5514
|
+
'.dsh-tree-btn[aria-pressed="true"] { color: var(--dsw-alias-brand-primary); border-color: var(--dsw-alias-brand-primary); background: color-mix(in srgb, var(--dsw-alias-brand-primary) 8%, transparent); }',
|
|
3004
5515
|
'.dsh-tree-btn--icon { padding: 0; min-width: 30px; min-height: 30px; }',
|
|
5516
|
+
'.dsh-tree-btn--segment {',
|
|
5517
|
+
' border-color: transparent; background: transparent;',
|
|
5518
|
+
' min-width: 28px; min-height: 26px; border-radius: 7px; color: var(--dsw-alias-label-tertiary);',
|
|
5519
|
+
'}',
|
|
5520
|
+
'.dsh-tree-btn--segment:hover:not([disabled]) {',
|
|
5521
|
+
' border-color: transparent; background: color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);',
|
|
5522
|
+
'}',
|
|
5523
|
+
'.dsh-tree-btn--segment[aria-pressed="true"], .dsh-tree-btn--segment[aria-pressed="true"]:hover {',
|
|
5524
|
+
' border-color: transparent; color: var(--dsw-alias-brand-primary);',
|
|
5525
|
+
' background: color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, transparent);',
|
|
5526
|
+
'}',
|
|
3005
5527
|
'.dsh-tree-btn--primary {',
|
|
3006
5528
|
' background: var(--dsw-alias-button-primary-fill); border-color: var(--dsw-alias-button-primary-fill);',
|
|
3007
5529
|
' color: var(--dsw-alias-label-primary-foreground);',
|
|
@@ -3067,10 +5589,7 @@ window.__ModuleLoader__.load({
|
|
|
3067
5589
|
// the shared "common" namespace, and the service's fallback chain
|
|
3068
5590
|
// serves English to any language we did not translate.
|
|
3069
5591
|
try {
|
|
3070
|
-
ctx.effect(() => ctx.locale.register(NS,
|
|
3071
|
-
zh: DICT.zh,
|
|
3072
|
-
en: DICT.en,
|
|
3073
|
-
}), 'dsh-explore: locale dictionaries');
|
|
5592
|
+
ctx.effect(() => ctx.locale.register(NS, DICT), 'dsh-explore: locale dictionaries');
|
|
3074
5593
|
} catch (error) {
|
|
3075
5594
|
// A profile without the locale plugin still gets the built-in table.
|
|
3076
5595
|
}
|
|
@@ -3111,6 +5630,9 @@ window.__ModuleLoader__.load({
|
|
|
3111
5630
|
loadOlder: runtime.loadOlder,
|
|
3112
5631
|
deleteSubtree: runtime.deleteSubtree,
|
|
3113
5632
|
restoreHidden: runtime.restoreHidden,
|
|
5633
|
+
setBranchListing: runtime.setBranchListing,
|
|
5634
|
+
peekImage: runtime.peekImage,
|
|
5635
|
+
loadImage: runtime.loadImage,
|
|
3114
5636
|
} }),
|
|
3115
5637
|
}, TreeView));
|
|
3116
5638
|
},
|