@tanzz/dsh-explore 0.2.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 +22 -8
- package/README.zh-CN.md +21 -6
- package/client.js +1138 -404
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -63,6 +63,92 @@ window.__ModuleLoader__.load({
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
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
|
+
|
|
66
152
|
// Font families follow Settings → Appearance. DSH composes the user's list
|
|
67
153
|
// with its own default stack on body (`--dsw-font-family` /
|
|
68
154
|
// `--ds-font-family-code`), so reading the composed tokens keeps glyph
|
|
@@ -105,12 +191,21 @@ window.__ModuleLoader__.load({
|
|
|
105
191
|
'view.latest': '定位最新',
|
|
106
192
|
'view.latestTitle': '展开路径并定位到最新创建的节点',
|
|
107
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': '把本树的分支会话恢复到工作区',
|
|
108
202
|
'view.empty.title': '这棵树还是空的',
|
|
109
203
|
'view.empty.hint': '回到 Chat 问一句,这里就会长出第一个节点。',
|
|
110
204
|
'view.empty.report': '若已经问过却是空的,把这一行告我:事件 {events} · 会话 {state}。',
|
|
111
205
|
|
|
112
206
|
'card.noQuestion': '(无问题)',
|
|
113
207
|
'card.questionReply': '(回答上一轮的提问)',
|
|
208
|
+
'card.imageAlt': '附图',
|
|
114
209
|
'card.latestBadge': '最新',
|
|
115
210
|
'card.latestTitle': '这是最新创建的节点',
|
|
116
211
|
'card.status.thinking': '思考中',
|
|
@@ -127,11 +222,6 @@ window.__ModuleLoader__.load({
|
|
|
127
222
|
'card.delete': '删除这个节点',
|
|
128
223
|
'card.deleteTitle': '隐藏这个节点和它下面的所有分支',
|
|
129
224
|
'card.deleteConfirm': '删除这个节点和它下面的所有分支?(随时可恢复)',
|
|
130
|
-
'card.readTitle': '点击全屏阅读',
|
|
131
|
-
'card.expandTitle': '展开整段回答',
|
|
132
|
-
'card.collapseTitle': '收起这段回答',
|
|
133
|
-
'card.expand': '展开回答',
|
|
134
|
-
'card.collapse': '收起回答',
|
|
135
225
|
'card.fullscreen': '全屏阅读',
|
|
136
226
|
'card.fullscreenTitle': '全屏阅读完整回答',
|
|
137
227
|
'card.unfoldBranch': '展开这一枝',
|
|
@@ -145,9 +235,7 @@ window.__ModuleLoader__.load({
|
|
|
145
235
|
'card.cost.cached': '缓存 {value}',
|
|
146
236
|
|
|
147
237
|
'card.think': '思考过程',
|
|
148
|
-
'card.
|
|
149
|
-
'card.thinkCollapseTitle': '收起思考过程',
|
|
150
|
-
'card.thinkMeta': '思考 {count} 字',
|
|
238
|
+
'card.thinkMeta': '{count} 字',
|
|
151
239
|
'card.thinkTruncated': '(只保留了最新的 {count} 字思考)',
|
|
152
240
|
|
|
153
241
|
'live.calling': '正在调用 {tool}',
|
|
@@ -170,6 +258,11 @@ window.__ModuleLoader__.load({
|
|
|
170
258
|
'reader.hint': 'Esc 关闭 · 点背景关闭',
|
|
171
259
|
'reader.branch': '分支',
|
|
172
260
|
'reader.mainline': '主线',
|
|
261
|
+
'reader.widthGroup': '阅读宽度',
|
|
262
|
+
'reader.paneGroup': '阅读内容',
|
|
263
|
+
'reader.paneAnswer': '最终结果',
|
|
264
|
+
'reader.widthStandard': '标准宽',
|
|
265
|
+
'reader.widthWide': '较宽',
|
|
173
266
|
|
|
174
267
|
'error.title': '树视图出错了',
|
|
175
268
|
'error.reload': '重新载入视图',
|
|
@@ -212,12 +305,21 @@ window.__ModuleLoader__.load({
|
|
|
212
305
|
'view.latest': 'Jump to latest',
|
|
213
306
|
'view.latestTitle': 'Expand the path and jump to the newest node',
|
|
214
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',
|
|
215
316
|
'view.empty.title': 'This tree is still empty',
|
|
216
317
|
'view.empty.hint': 'Ask something in Chat and the first node will grow here.',
|
|
217
318
|
'view.empty.report': 'If you already asked and this is still empty, tell me: {events} events · session {state}.',
|
|
218
319
|
|
|
219
320
|
'card.noQuestion': '(no question)',
|
|
220
321
|
'card.questionReply': '(replying to the previous question)',
|
|
322
|
+
'card.imageAlt': 'Attached image',
|
|
221
323
|
'card.latestBadge': 'Latest',
|
|
222
324
|
'card.latestTitle': 'The newest node in this tree',
|
|
223
325
|
'card.status.thinking': 'Thinking',
|
|
@@ -234,11 +336,6 @@ window.__ModuleLoader__.load({
|
|
|
234
336
|
'card.delete': 'Delete this node',
|
|
235
337
|
'card.deleteTitle': 'Hide this node and every branch under it',
|
|
236
338
|
'card.deleteConfirm': 'Delete this node and all branches under it? (reversible)',
|
|
237
|
-
'card.readTitle': 'Click to read in full screen',
|
|
238
|
-
'card.expandTitle': 'Expand this answer',
|
|
239
|
-
'card.collapseTitle': 'Collapse this answer',
|
|
240
|
-
'card.expand': 'Expand answer',
|
|
241
|
-
'card.collapse': 'Collapse answer',
|
|
242
339
|
'card.fullscreen': 'Read full screen',
|
|
243
340
|
'card.fullscreenTitle': 'Read the complete answer in full screen',
|
|
244
341
|
'card.unfoldBranch': 'Expand this branch',
|
|
@@ -252,9 +349,7 @@ window.__ModuleLoader__.load({
|
|
|
252
349
|
'card.cost.cached': 'cached {value}',
|
|
253
350
|
|
|
254
351
|
'card.think': 'Reasoning',
|
|
255
|
-
'card.
|
|
256
|
-
'card.thinkCollapseTitle': 'Collapse the reasoning',
|
|
257
|
-
'card.thinkMeta': '{count} chars of reasoning',
|
|
352
|
+
'card.thinkMeta': '{count} chars',
|
|
258
353
|
'card.thinkTruncated': '(only the newest {count} chars of reasoning are kept)',
|
|
259
354
|
|
|
260
355
|
'live.calling': 'Calling {tool}',
|
|
@@ -277,6 +372,11 @@ window.__ModuleLoader__.load({
|
|
|
277
372
|
'reader.hint': 'Esc or click the backdrop to close',
|
|
278
373
|
'reader.branch': 'Branch',
|
|
279
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',
|
|
280
380
|
|
|
281
381
|
'error.title': 'The tree view crashed',
|
|
282
382
|
'error.reload': 'Reload the view',
|
|
@@ -316,11 +416,20 @@ window.__ModuleLoader__.load({
|
|
|
316
416
|
'view.latest': 'Zum Neuesten',
|
|
317
417
|
'view.latestTitle': 'Pfad ausklappen und zum neuesten Knoten springen',
|
|
318
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',
|
|
319
427
|
'view.empty.title': 'Dieser Baum ist noch leer',
|
|
320
428
|
'view.empty.hint': 'Stelle im Chat eine Frage, dann wächst hier der erste Knoten.',
|
|
321
429
|
'view.empty.report': 'Wenn du schon gefragt hast und es hier noch leer ist, sag mir: {events} Ereignisse · Sitzung {state}.',
|
|
322
430
|
'card.noQuestion': '(keine Frage)',
|
|
323
431
|
'card.questionReply': '(Antwort auf die vorherige Frage)',
|
|
432
|
+
'card.imageAlt': 'Angehängtes Bild',
|
|
324
433
|
'card.latestBadge': 'Neuestes',
|
|
325
434
|
'card.latestTitle': 'Der neueste Knoten in diesem Baum',
|
|
326
435
|
'card.status.thinking': 'Denkt nach',
|
|
@@ -337,11 +446,6 @@ window.__ModuleLoader__.load({
|
|
|
337
446
|
'card.delete': 'Diesen Knoten löschen',
|
|
338
447
|
'card.deleteTitle': 'Diesen Knoten und alle Zweige darunter ausblenden',
|
|
339
448
|
'card.deleteConfirm': 'Diesen Knoten und alle Zweige darunter löschen? (umkehrbar)',
|
|
340
|
-
'card.readTitle': 'Klicken, um im Vollbild zu lesen',
|
|
341
|
-
'card.expandTitle': 'Diese Antwort ausklappen',
|
|
342
|
-
'card.collapseTitle': 'Diese Antwort einklappen',
|
|
343
|
-
'card.expand': 'Antwort ausklappen',
|
|
344
|
-
'card.collapse': 'Antwort einklappen',
|
|
345
449
|
'card.fullscreen': 'Vollbild lesen',
|
|
346
450
|
'card.fullscreenTitle': 'Die vollständige Antwort im Vollbild lesen',
|
|
347
451
|
'card.unfoldBranch': 'Diesen Zweig ausklappen',
|
|
@@ -354,9 +458,7 @@ window.__ModuleLoader__.load({
|
|
|
354
458
|
'card.cost.context': 'Kontext {value}',
|
|
355
459
|
'card.cost.cached': 'Cache {value}',
|
|
356
460
|
'card.think': 'Gedankengang',
|
|
357
|
-
'card.
|
|
358
|
-
'card.thinkCollapseTitle': 'Den Gedankengang einklappen',
|
|
359
|
-
'card.thinkMeta': '{count} Zeichen Gedankengang',
|
|
461
|
+
'card.thinkMeta': '{count} Zeichen',
|
|
360
462
|
'card.thinkTruncated': '(nur die neuesten {count} Zeichen Gedankengang bleiben erhalten)',
|
|
361
463
|
'live.calling': 'Ruft {tool} auf',
|
|
362
464
|
'live.outputting': 'Schreibt…',
|
|
@@ -376,6 +478,11 @@ window.__ModuleLoader__.load({
|
|
|
376
478
|
'reader.hint': 'Esc oder Klick auf den Hintergrund zum Schließen',
|
|
377
479
|
'reader.branch': 'Zweig',
|
|
378
480
|
'reader.mainline': 'Hauptlinie',
|
|
481
|
+
'reader.widthGroup': 'Lesebreite',
|
|
482
|
+
'reader.paneGroup': 'Leseinhalt',
|
|
483
|
+
'reader.paneAnswer': 'Endergebnis',
|
|
484
|
+
'reader.widthStandard': 'Standard',
|
|
485
|
+
'reader.widthWide': 'Breiter',
|
|
379
486
|
'error.title': 'Die Baumansicht ist abgestürzt',
|
|
380
487
|
'error.reload': 'Ansicht neu laden',
|
|
381
488
|
'error.hint': 'Die Leinwand-Daten sind sicher; nur diese Darstellung ist fehlgeschlagen.',
|
|
@@ -415,11 +522,20 @@ window.__ModuleLoader__.load({
|
|
|
415
522
|
'view.latest': 'Ir a lo más reciente',
|
|
416
523
|
'view.latestTitle': 'Expandir la ruta e ir al nodo más reciente',
|
|
417
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',
|
|
418
533
|
'view.empty.title': 'Este árbol aún está vacío',
|
|
419
534
|
'view.empty.hint': 'Pregunta algo en Chat y el primer nodo crecerá aquí.',
|
|
420
535
|
'view.empty.report': 'Si ya preguntaste y esto sigue vacío, dime: {events} eventos · sesión {state}.',
|
|
421
536
|
'card.noQuestion': '(sin pregunta)',
|
|
422
537
|
'card.questionReply': '(respondiendo a la pregunta anterior)',
|
|
538
|
+
'card.imageAlt': 'Imagen adjunta',
|
|
423
539
|
'card.latestBadge': 'Último',
|
|
424
540
|
'card.latestTitle': 'El nodo más reciente de este árbol',
|
|
425
541
|
'card.status.thinking': 'Pensando',
|
|
@@ -436,11 +552,6 @@ window.__ModuleLoader__.load({
|
|
|
436
552
|
'card.delete': 'Eliminar este nodo',
|
|
437
553
|
'card.deleteTitle': 'Ocultar este nodo y todas las ramas que cuelgan de él',
|
|
438
554
|
'card.deleteConfirm': '¿Eliminar este nodo y todas sus ramas? (reversible)',
|
|
439
|
-
'card.readTitle': 'Haz clic para leer a pantalla completa',
|
|
440
|
-
'card.expandTitle': 'Expandir esta respuesta',
|
|
441
|
-
'card.collapseTitle': 'Contraer esta respuesta',
|
|
442
|
-
'card.expand': 'Expandir respuesta',
|
|
443
|
-
'card.collapse': 'Contraer respuesta',
|
|
444
555
|
'card.fullscreen': 'Pantalla completa',
|
|
445
556
|
'card.fullscreenTitle': 'Leer la respuesta completa a pantalla completa',
|
|
446
557
|
'card.unfoldBranch': 'Expandir esta rama',
|
|
@@ -453,9 +564,7 @@ window.__ModuleLoader__.load({
|
|
|
453
564
|
'card.cost.context': 'contexto {value}',
|
|
454
565
|
'card.cost.cached': 'caché {value}',
|
|
455
566
|
'card.think': 'Razonamiento',
|
|
456
|
-
'card.
|
|
457
|
-
'card.thinkCollapseTitle': 'Contraer el razonamiento',
|
|
458
|
-
'card.thinkMeta': '{count} caracteres de razonamiento',
|
|
567
|
+
'card.thinkMeta': '{count} caracteres',
|
|
459
568
|
'card.thinkTruncated': '(solo se conservan los {count} caracteres más recientes del razonamiento)',
|
|
460
569
|
'live.calling': 'Llamando a {tool}',
|
|
461
570
|
'live.outputting': 'Escribiendo…',
|
|
@@ -475,6 +584,11 @@ window.__ModuleLoader__.load({
|
|
|
475
584
|
'reader.hint': 'Esc o clic en el fondo para cerrar',
|
|
476
585
|
'reader.branch': 'Rama',
|
|
477
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',
|
|
478
592
|
'error.title': 'La vista de árbol falló',
|
|
479
593
|
'error.reload': 'Recargar la vista',
|
|
480
594
|
'error.hint': 'Los datos del lienzo están a salvo; solo falló este render.',
|
|
@@ -514,11 +628,20 @@ window.__ModuleLoader__.load({
|
|
|
514
628
|
'view.latest': 'Aller au plus récent',
|
|
515
629
|
'view.latestTitle': 'Déplier le chemin et aller au nœud le plus récent',
|
|
516
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',
|
|
517
639
|
'view.empty.title': 'Cet arbre est encore vide',
|
|
518
640
|
'view.empty.hint': 'Posez une question dans Chat et le premier nœud poussera ici.',
|
|
519
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}.',
|
|
520
642
|
'card.noQuestion': '(aucune question)',
|
|
521
643
|
'card.questionReply': '(réponse à la question précédente)',
|
|
644
|
+
'card.imageAlt': 'Image jointe',
|
|
522
645
|
'card.latestBadge': 'Dernier',
|
|
523
646
|
'card.latestTitle': 'Le nœud le plus récent de cet arbre',
|
|
524
647
|
'card.status.thinking': 'Réflexion',
|
|
@@ -535,11 +658,6 @@ window.__ModuleLoader__.load({
|
|
|
535
658
|
'card.delete': 'Supprimer ce nœud',
|
|
536
659
|
'card.deleteTitle': 'Masquer ce nœud et toutes les branches en dessous',
|
|
537
660
|
'card.deleteConfirm': 'Supprimer ce nœud et toutes les branches en dessous ? (réversible)',
|
|
538
|
-
'card.readTitle': 'Cliquez pour lire en plein écran',
|
|
539
|
-
'card.expandTitle': 'Déplier cette réponse',
|
|
540
|
-
'card.collapseTitle': 'Replier cette réponse',
|
|
541
|
-
'card.expand': 'Déplier la réponse',
|
|
542
|
-
'card.collapse': 'Replier la réponse',
|
|
543
661
|
'card.fullscreen': 'Plein écran',
|
|
544
662
|
'card.fullscreenTitle': 'Lire la réponse complète en plein écran',
|
|
545
663
|
'card.unfoldBranch': 'Déplier cette branche',
|
|
@@ -552,9 +670,7 @@ window.__ModuleLoader__.load({
|
|
|
552
670
|
'card.cost.context': 'contexte {value}',
|
|
553
671
|
'card.cost.cached': 'cache {value}',
|
|
554
672
|
'card.think': 'Raisonnement',
|
|
555
|
-
'card.
|
|
556
|
-
'card.thinkCollapseTitle': 'Replier le raisonnement',
|
|
557
|
-
'card.thinkMeta': '{count} caractères de raisonnement',
|
|
673
|
+
'card.thinkMeta': '{count} caractères',
|
|
558
674
|
'card.thinkTruncated': '(seuls les {count} derniers caractères du raisonnement sont conservés)',
|
|
559
675
|
'live.calling': 'Appel de {tool}',
|
|
560
676
|
'live.outputting': 'Écriture…',
|
|
@@ -574,6 +690,11 @@ window.__ModuleLoader__.load({
|
|
|
574
690
|
'reader.hint': 'Échap ou clic sur l’arrière-plan pour fermer',
|
|
575
691
|
'reader.branch': 'Branche',
|
|
576
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',
|
|
577
698
|
'error.title': 'La vue arborescente a planté',
|
|
578
699
|
'error.reload': 'Recharger la vue',
|
|
579
700
|
'error.hint': 'Les données du canevas sont intactes ; seul ce rendu a échoué.',
|
|
@@ -613,11 +734,20 @@ window.__ModuleLoader__.load({
|
|
|
613
734
|
'view.latest': '最新へ移動',
|
|
614
735
|
'view.latestTitle': '経路を展開して最新のノードへ移動',
|
|
615
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': 'このツリーのブランチセッションをワークスペースに戻します',
|
|
616
745
|
'view.empty.title': 'このツリーはまだ空です',
|
|
617
746
|
'view.empty.hint': 'Chat で質問すると、ここに最初のノードが生まれます。',
|
|
618
747
|
'view.empty.report': 'すでに質問したのに空のままなら、次を伝えてください:イベント {events} · セッション {state}。',
|
|
619
748
|
'card.noQuestion': '(質問なし)',
|
|
620
749
|
'card.questionReply': '(前の質問への回答)',
|
|
750
|
+
'card.imageAlt': '添付画像',
|
|
621
751
|
'card.latestBadge': '最新',
|
|
622
752
|
'card.latestTitle': 'このツリーで最新のノード',
|
|
623
753
|
'card.status.thinking': '思考中',
|
|
@@ -634,11 +764,6 @@ window.__ModuleLoader__.load({
|
|
|
634
764
|
'card.delete': 'このノードを削除',
|
|
635
765
|
'card.deleteTitle': 'このノードとその下のすべてのブランチを非表示',
|
|
636
766
|
'card.deleteConfirm': 'このノードとその下のすべてのブランチを削除しますか?(復元できます)',
|
|
637
|
-
'card.readTitle': 'クリックして全画面で読む',
|
|
638
|
-
'card.expandTitle': 'この回答を展開',
|
|
639
|
-
'card.collapseTitle': 'この回答を折りたたむ',
|
|
640
|
-
'card.expand': '回答を展開',
|
|
641
|
-
'card.collapse': '回答を折りたたむ',
|
|
642
767
|
'card.fullscreen': '全画面で読む',
|
|
643
768
|
'card.fullscreenTitle': '完全な回答を全画面で読む',
|
|
644
769
|
'card.unfoldBranch': 'このブランチを展開',
|
|
@@ -651,9 +776,7 @@ window.__ModuleLoader__.load({
|
|
|
651
776
|
'card.cost.context': 'コンテキスト {value}',
|
|
652
777
|
'card.cost.cached': 'キャッシュ {value}',
|
|
653
778
|
'card.think': '思考',
|
|
654
|
-
'card.
|
|
655
|
-
'card.thinkCollapseTitle': '思考を折りたたむ',
|
|
656
|
-
'card.thinkMeta': '思考 {count} 文字',
|
|
779
|
+
'card.thinkMeta': '{count} 文字',
|
|
657
780
|
'card.thinkTruncated': '(最新の思考 {count} 文字のみ保持)',
|
|
658
781
|
'live.calling': '{tool} を呼び出し中',
|
|
659
782
|
'live.outputting': '出力中…',
|
|
@@ -673,6 +796,11 @@ window.__ModuleLoader__.load({
|
|
|
673
796
|
'reader.hint': 'Esc または背景をクリックで閉じる',
|
|
674
797
|
'reader.branch': 'ブランチ',
|
|
675
798
|
'reader.mainline': '本線',
|
|
799
|
+
'reader.widthGroup': '閲覧幅',
|
|
800
|
+
'reader.paneGroup': '表示する内容',
|
|
801
|
+
'reader.paneAnswer': '最終結果',
|
|
802
|
+
'reader.widthStandard': '標準幅',
|
|
803
|
+
'reader.widthWide': '広め',
|
|
676
804
|
'error.title': 'ツリービューでエラーが発生しました',
|
|
677
805
|
'error.reload': 'ビューを再読み込み',
|
|
678
806
|
'error.hint': 'キャンバスのデータは失われていません。描画だけが失敗しました。',
|
|
@@ -712,11 +840,20 @@ window.__ModuleLoader__.load({
|
|
|
712
840
|
'view.latest': 'Ir para o mais recente',
|
|
713
841
|
'view.latestTitle': 'Expandir o caminho e ir para o nó mais recente',
|
|
714
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',
|
|
715
851
|
'view.empty.title': 'Esta árvore ainda está vazia',
|
|
716
852
|
'view.empty.hint': 'Pergunte algo no Chat e o primeiro nó vai crescer aqui.',
|
|
717
853
|
'view.empty.report': 'Se você já perguntou e isto continua vazio, me diga: {events} eventos · sessão {state}.',
|
|
718
854
|
'card.noQuestion': '(sem pergunta)',
|
|
719
855
|
'card.questionReply': '(respondendo à pergunta anterior)',
|
|
856
|
+
'card.imageAlt': 'Imagem anexada',
|
|
720
857
|
'card.latestBadge': 'Recente',
|
|
721
858
|
'card.latestTitle': 'O nó mais recente desta árvore',
|
|
722
859
|
'card.status.thinking': 'Pensando',
|
|
@@ -733,11 +870,6 @@ window.__ModuleLoader__.load({
|
|
|
733
870
|
'card.delete': 'Excluir este nó',
|
|
734
871
|
'card.deleteTitle': 'Ocultar este nó e todos os ramos abaixo dele',
|
|
735
872
|
'card.deleteConfirm': 'Excluir este nó e todos os ramos abaixo dele? (reversível)',
|
|
736
|
-
'card.readTitle': 'Clique para ler em tela cheia',
|
|
737
|
-
'card.expandTitle': 'Expandir esta resposta',
|
|
738
|
-
'card.collapseTitle': 'Recolher esta resposta',
|
|
739
|
-
'card.expand': 'Expandir resposta',
|
|
740
|
-
'card.collapse': 'Recolher resposta',
|
|
741
873
|
'card.fullscreen': 'Tela cheia',
|
|
742
874
|
'card.fullscreenTitle': 'Ler a resposta completa em tela cheia',
|
|
743
875
|
'card.unfoldBranch': 'Expandir este ramo',
|
|
@@ -750,9 +882,7 @@ window.__ModuleLoader__.load({
|
|
|
750
882
|
'card.cost.context': 'contexto {value}',
|
|
751
883
|
'card.cost.cached': 'cache {value}',
|
|
752
884
|
'card.think': 'Raciocínio',
|
|
753
|
-
'card.
|
|
754
|
-
'card.thinkCollapseTitle': 'Recolher o raciocínio',
|
|
755
|
-
'card.thinkMeta': '{count} caracteres de raciocínio',
|
|
885
|
+
'card.thinkMeta': '{count} caracteres',
|
|
756
886
|
'card.thinkTruncated': '(apenas os {count} caracteres mais recentes do raciocínio são mantidos)',
|
|
757
887
|
'live.calling': 'Chamando {tool}',
|
|
758
888
|
'live.outputting': 'Escrevendo…',
|
|
@@ -772,6 +902,11 @@ window.__ModuleLoader__.load({
|
|
|
772
902
|
'reader.hint': 'Esc ou clique no fundo para fechar',
|
|
773
903
|
'reader.branch': 'Ramo',
|
|
774
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',
|
|
775
910
|
'error.title': 'A visualização em árvore falhou',
|
|
776
911
|
'error.reload': 'Recarregar a visualização',
|
|
777
912
|
'error.hint': 'Os dados do canvas estão seguros; apenas esta renderização falhou.',
|
|
@@ -811,11 +946,20 @@ window.__ModuleLoader__.load({
|
|
|
811
946
|
'view.latest': 'К последнему',
|
|
812
947
|
'view.latestTitle': 'Развернуть путь и перейти к новейшему узлу',
|
|
813
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': 'Вернуть сеансы веток этого дерева в рабочее пространство',
|
|
814
957
|
'view.empty.title': 'Это дерево пока пустое',
|
|
815
958
|
'view.empty.hint': 'Спросите что-нибудь в Chat, и здесь появится первый узел.',
|
|
816
959
|
'view.empty.report': 'Если вы уже спрашивали, а здесь по-прежнему пусто, сообщите: события {events} · сеанс {state}.',
|
|
817
960
|
'card.noQuestion': '(без вопроса)',
|
|
818
961
|
'card.questionReply': '(ответ на предыдущий вопрос)',
|
|
962
|
+
'card.imageAlt': 'Прикреплённое изображение',
|
|
819
963
|
'card.latestBadge': 'Последний',
|
|
820
964
|
'card.latestTitle': 'Самый новый узел в этом дереве',
|
|
821
965
|
'card.status.thinking': 'Думает',
|
|
@@ -832,11 +976,6 @@ window.__ModuleLoader__.load({
|
|
|
832
976
|
'card.delete': 'Удалить этот узел',
|
|
833
977
|
'card.deleteTitle': 'Скрыть этот узел и все ветки под ним',
|
|
834
978
|
'card.deleteConfirm': 'Удалить этот узел и все ветки под ним? (обратимо)',
|
|
835
|
-
'card.readTitle': 'Нажмите, чтобы читать на весь экран',
|
|
836
|
-
'card.expandTitle': 'Развернуть этот ответ',
|
|
837
|
-
'card.collapseTitle': 'Свернуть этот ответ',
|
|
838
|
-
'card.expand': 'Развернуть ответ',
|
|
839
|
-
'card.collapse': 'Свернуть ответ',
|
|
840
979
|
'card.fullscreen': 'Во весь экран',
|
|
841
980
|
'card.fullscreenTitle': 'Прочитать полный ответ во весь экран',
|
|
842
981
|
'card.unfoldBranch': 'Развернуть эту ветку',
|
|
@@ -849,9 +988,7 @@ window.__ModuleLoader__.load({
|
|
|
849
988
|
'card.cost.context': 'контекст {value}',
|
|
850
989
|
'card.cost.cached': 'кэш {value}',
|
|
851
990
|
'card.think': 'Рассуждения',
|
|
852
|
-
'card.
|
|
853
|
-
'card.thinkCollapseTitle': 'Свернуть рассуждения',
|
|
854
|
-
'card.thinkMeta': 'Рассуждения: {count} симв.',
|
|
991
|
+
'card.thinkMeta': '{count} симв.',
|
|
855
992
|
'card.thinkTruncated': '(сохранены только последние {count} симв. рассуждений)',
|
|
856
993
|
'live.calling': 'Вызов {tool}',
|
|
857
994
|
'live.outputting': 'Пишет…',
|
|
@@ -871,6 +1008,11 @@ window.__ModuleLoader__.load({
|
|
|
871
1008
|
'reader.hint': 'Esc или клик по фону, чтобы закрыть',
|
|
872
1009
|
'reader.branch': 'Ветка',
|
|
873
1010
|
'reader.mainline': 'Основная линия',
|
|
1011
|
+
'reader.widthGroup': 'Ширина чтения',
|
|
1012
|
+
'reader.paneGroup': 'Содержимое чтения',
|
|
1013
|
+
'reader.paneAnswer': 'Итоговый ответ',
|
|
1014
|
+
'reader.widthStandard': 'Стандартная',
|
|
1015
|
+
'reader.widthWide': 'Широкая',
|
|
874
1016
|
'error.title': 'Древовидное представление упало',
|
|
875
1017
|
'error.reload': 'Перезагрузить представление',
|
|
876
1018
|
'error.hint': 'Данные холста не потеряны; не удалась только эта отрисовка.',
|
|
@@ -936,6 +1078,40 @@ window.__ModuleLoader__.load({
|
|
|
936
1078
|
return out;
|
|
937
1079
|
}
|
|
938
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
|
+
|
|
939
1115
|
function seqOf(entry) {
|
|
940
1116
|
const event = entry && entry.event;
|
|
941
1117
|
return event && typeof event.seq === 'number' ? event.seq : 0;
|
|
@@ -1188,26 +1364,6 @@ window.__ModuleLoader__.load({
|
|
|
1188
1364
|
return parts.join('\n\n');
|
|
1189
1365
|
}
|
|
1190
1366
|
|
|
1191
|
-
/**
|
|
1192
|
-
* The one-line summary of a reasoning text: the first line of its last
|
|
1193
|
-
* paragraph.
|
|
1194
|
-
*
|
|
1195
|
-
* A collapsed section shows this so the reader learns what the agent was
|
|
1196
|
-
* up to without opening anything. It is deliberately *not* a copy of the
|
|
1197
|
-
* official Chat row, which picks the last completed paragraph's first line
|
|
1198
|
-
* only while streaming and the first line of the whole text once settled.
|
|
1199
|
-
*/
|
|
1200
|
-
function reasoningPreview(text) {
|
|
1201
|
-
if (!text) return '';
|
|
1202
|
-
const source = String(text);
|
|
1203
|
-
// The last paragraph is the freshest thought; take its first line.
|
|
1204
|
-
const paragraphs = source.split(/\r?\n[\t ]*\r?\n/);
|
|
1205
|
-
const last = paragraphs[paragraphs.length - 1] || '';
|
|
1206
|
-
const firstLine = last.split(/\r?\n/).find((line) => line.trim());
|
|
1207
|
-
const chosen = firstLine ? firstLine.trim() : '';
|
|
1208
|
-
return chosen.replace(/\*\*/g, '').slice(0, 200);
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
1367
|
/**
|
|
1212
1368
|
* The newest thing the model wrote, in one line.
|
|
1213
1369
|
*
|
|
@@ -1226,6 +1382,30 @@ window.__ModuleLoader__.load({
|
|
|
1226
1382
|
return '';
|
|
1227
1383
|
}
|
|
1228
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
|
+
|
|
1229
1409
|
function maxDurableSeq(entries) {
|
|
1230
1410
|
let max = 0;
|
|
1231
1411
|
for (const entry of entries) {
|
|
@@ -1371,7 +1551,7 @@ window.__ModuleLoader__.load({
|
|
|
1371
1551
|
if (entry.type !== 'event') continue;
|
|
1372
1552
|
if (event.type === 'turn/start') {
|
|
1373
1553
|
current = {
|
|
1374
|
-
question: '', answer: '', answerSeq: 0, qSeq: 0, status: 'running',
|
|
1554
|
+
question: '', images: [], answer: '', answerSeq: 0, qSeq: 0, status: 'running',
|
|
1375
1555
|
real: false, kind: '', costFrom: index, streamText: '',
|
|
1376
1556
|
step: 0, tool: '', startedAt: typeof event.time === 'number' ? event.time : 0,
|
|
1377
1557
|
awaiting: '', pendingQuestions: new Set(), pendingApprovals: new Set(),
|
|
@@ -1413,11 +1593,15 @@ window.__ModuleLoader__.load({
|
|
|
1413
1593
|
const target = current || turns[turns.length - 1];
|
|
1414
1594
|
if (target) {
|
|
1415
1595
|
const text = textOf(data.content);
|
|
1416
|
-
|
|
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)) {
|
|
1417
1600
|
const kind = sourceKindOf(data) || '';
|
|
1418
1601
|
target.question = kind === 'user-question-reply'
|
|
1419
1602
|
? (questionReplyTextOf(data) || T('card.questionReply'))
|
|
1420
1603
|
: text;
|
|
1604
|
+
target.images = images;
|
|
1421
1605
|
target.real = true;
|
|
1422
1606
|
target.kind = kind;
|
|
1423
1607
|
target.qSeq = typeof event.seq === 'number' ? event.seq : 0;
|
|
@@ -1474,7 +1658,7 @@ window.__ModuleLoader__.load({
|
|
|
1474
1658
|
delete turn.pendingQuestions;
|
|
1475
1659
|
delete turn.pendingApprovals;
|
|
1476
1660
|
}
|
|
1477
|
-
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));
|
|
1478
1662
|
}
|
|
1479
1663
|
|
|
1480
1664
|
/** Read one branch session's own events (everything after `baseline`). */
|
|
@@ -1732,7 +1916,9 @@ window.__ModuleLoader__.load({
|
|
|
1732
1916
|
return result;
|
|
1733
1917
|
}
|
|
1734
1918
|
|
|
1735
|
-
function layoutTree(nodes, collapsed, heights, direction) {
|
|
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;
|
|
1736
1922
|
const childrenOf = childrenMapOf(nodes);
|
|
1737
1923
|
const kids = (node) => (collapsed[node.id] ? [] : childrenOf.get(node.id) || []);
|
|
1738
1924
|
const roots = childrenOf.get('@root') || [];
|
|
@@ -1767,7 +1953,7 @@ window.__ModuleLoader__.load({
|
|
|
1767
1953
|
center = (positions.get(first.id).y + heightOf(first) / 2 + positions.get(last.id).y + heightOf(last) / 2) / 2;
|
|
1768
1954
|
}
|
|
1769
1955
|
const y = Math.max(top, Math.min(top + span - ownHeight, center - ownHeight / 2));
|
|
1770
|
-
positions.set(node.id, { x: (depthOf.get(node.id) || 0) * (
|
|
1956
|
+
positions.set(node.id, { x: (depthOf.get(node.id) || 0) * (cardW + GAP_Y), y });
|
|
1771
1957
|
}
|
|
1772
1958
|
let top = 0;
|
|
1773
1959
|
for (const root of roots) {
|
|
@@ -1781,13 +1967,13 @@ window.__ModuleLoader__.load({
|
|
|
1781
1967
|
const pos = positions.get(node.id);
|
|
1782
1968
|
if (!pos) continue;
|
|
1783
1969
|
const height = heightOf(node);
|
|
1784
|
-
maxX = Math.max(maxX, pos.x +
|
|
1970
|
+
maxX = Math.max(maxX, pos.x + cardW);
|
|
1785
1971
|
maxY = Math.max(maxY, pos.y + height);
|
|
1786
1972
|
for (const child of kids(node)) {
|
|
1787
1973
|
const childPos = positions.get(child.id);
|
|
1788
1974
|
if (childPos) edges.push({
|
|
1789
1975
|
id: node.id + '>' + child.id,
|
|
1790
|
-
x1: pos.x +
|
|
1976
|
+
x1: pos.x + cardW, y1: pos.y + height / 2,
|
|
1791
1977
|
x2: childPos.x, y2: childPos.y + heightOf(child) / 2,
|
|
1792
1978
|
});
|
|
1793
1979
|
}
|
|
@@ -1812,14 +1998,14 @@ window.__ModuleLoader__.load({
|
|
|
1812
1998
|
function measure(node) {
|
|
1813
1999
|
const list = kids(node);
|
|
1814
2000
|
if (list.length === 0) {
|
|
1815
|
-
widths.set(node.id,
|
|
1816
|
-
return
|
|
2001
|
+
widths.set(node.id, cardW);
|
|
2002
|
+
return cardW;
|
|
1817
2003
|
}
|
|
1818
2004
|
let total = 0;
|
|
1819
2005
|
list.forEach((child, index) => {
|
|
1820
2006
|
total += measure(child) + (index > 0 ? GAP_X : 0);
|
|
1821
2007
|
});
|
|
1822
|
-
const width = Math.max(
|
|
2008
|
+
const width = Math.max(cardW, total);
|
|
1823
2009
|
widths.set(node.id, width);
|
|
1824
2010
|
return width;
|
|
1825
2011
|
}
|
|
@@ -1830,7 +2016,7 @@ window.__ModuleLoader__.load({
|
|
|
1830
2016
|
const list = kids(node);
|
|
1831
2017
|
const depth = depthOf.get(node.id) || 0;
|
|
1832
2018
|
if (list.length === 0) {
|
|
1833
|
-
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 });
|
|
1834
2020
|
return;
|
|
1835
2021
|
}
|
|
1836
2022
|
let cursor = left;
|
|
@@ -1838,9 +2024,9 @@ window.__ModuleLoader__.load({
|
|
|
1838
2024
|
place(child, cursor);
|
|
1839
2025
|
cursor += widths.get(child.id) + GAP_X;
|
|
1840
2026
|
}
|
|
1841
|
-
const first = positions.get(list[0].id).x +
|
|
1842
|
-
const last = positions.get(list[list.length - 1].id).x +
|
|
1843
|
-
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 });
|
|
1844
2030
|
}
|
|
1845
2031
|
|
|
1846
2032
|
let x = 0;
|
|
@@ -1860,9 +2046,9 @@ window.__ModuleLoader__.load({
|
|
|
1860
2046
|
if (!kidPos) continue;
|
|
1861
2047
|
edges.push({
|
|
1862
2048
|
id: node.id + '>' + kidNode.id,
|
|
1863
|
-
x1: parentPos.x +
|
|
2049
|
+
x1: parentPos.x + cardW / 2,
|
|
1864
2050
|
y1: parentPos.y + parentHeight,
|
|
1865
|
-
x2: kidPos.x +
|
|
2051
|
+
x2: kidPos.x + cardW / 2,
|
|
1866
2052
|
y2: kidPos.y,
|
|
1867
2053
|
});
|
|
1868
2054
|
}
|
|
@@ -1871,7 +2057,7 @@ window.__ModuleLoader__.load({
|
|
|
1871
2057
|
let maxX = 0;
|
|
1872
2058
|
let maxY = 0;
|
|
1873
2059
|
for (const [id, pos] of positions) {
|
|
1874
|
-
maxX = Math.max(maxX, pos.x +
|
|
2060
|
+
maxX = Math.max(maxX, pos.x + cardW);
|
|
1875
2061
|
maxY = Math.max(maxY, pos.y + (heights[id] || NODE_H));
|
|
1876
2062
|
}
|
|
1877
2063
|
for (const node of nodes) {
|
|
@@ -1936,9 +2122,22 @@ window.__ModuleLoader__.load({
|
|
|
1936
2122
|
// only masks it and its subtree here.
|
|
1937
2123
|
hidden: {},
|
|
1938
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(),
|
|
1939
2134
|
selectedId: null,
|
|
1940
2135
|
composingId: null,
|
|
1941
|
-
|
|
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,
|
|
1942
2141
|
draft: '',
|
|
1943
2142
|
loaded: false,
|
|
1944
2143
|
error: null,
|
|
@@ -1956,6 +2155,7 @@ window.__ModuleLoader__.load({
|
|
|
1956
2155
|
if (saved.collapsed && typeof saved.collapsed === 'object') state.collapsed = saved.collapsed;
|
|
1957
2156
|
if (saved.hidden && typeof saved.hidden === 'object') state.hidden = saved.hidden;
|
|
1958
2157
|
if (Array.isArray(saved.archived)) state.archived = saved.archived;
|
|
2158
|
+
if (Array.isArray(saved.quieted)) state.quieted = saved.quieted;
|
|
1959
2159
|
}
|
|
1960
2160
|
} catch (error) {
|
|
1961
2161
|
/* ignore corrupt state */
|
|
@@ -1978,6 +2178,10 @@ window.__ModuleLoader__.load({
|
|
|
1978
2178
|
parentId: node.parentId,
|
|
1979
2179
|
sessionId: node.sessionId,
|
|
1980
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 || [],
|
|
1981
2185
|
answer: node.answer,
|
|
1982
2186
|
status: node.status,
|
|
1983
2187
|
answerSeq: node.answerSeq,
|
|
@@ -1991,6 +2195,8 @@ window.__ModuleLoader__.load({
|
|
|
1991
2195
|
collapsed: state.collapsed,
|
|
1992
2196
|
hidden: state.hidden,
|
|
1993
2197
|
archived: state.archived,
|
|
2198
|
+
quieted: state.quieted,
|
|
2199
|
+
branchMode: state.branchMode,
|
|
1994
2200
|
};
|
|
1995
2201
|
window.localStorage.setItem(STORE_PREFIX + rootId, JSON.stringify(payload));
|
|
1996
2202
|
} catch (error) {
|
|
@@ -2062,6 +2268,7 @@ window.__ModuleLoader__.load({
|
|
|
2062
2268
|
parentId,
|
|
2063
2269
|
sessionId: rootId,
|
|
2064
2270
|
question: turn.question,
|
|
2271
|
+
images: turn.images || [],
|
|
2065
2272
|
answer: turn.answer,
|
|
2066
2273
|
reasoning: turn.reasoning || '',
|
|
2067
2274
|
reasoningDropped: turn.reasoningDropped || 0,
|
|
@@ -2081,6 +2288,7 @@ window.__ModuleLoader__.load({
|
|
|
2081
2288
|
} else if (
|
|
2082
2289
|
existing.parentId !== next.parentId ||
|
|
2083
2290
|
existing.question !== next.question ||
|
|
2291
|
+
!sameImages(existing.images, next.images) ||
|
|
2084
2292
|
existing.answer !== next.answer ||
|
|
2085
2293
|
(existing.reasoning || '') !== next.reasoning ||
|
|
2086
2294
|
(existing.reasoningDropped || 0) !== next.reasoningDropped ||
|
|
@@ -2155,12 +2363,31 @@ window.__ModuleLoader__.load({
|
|
|
2155
2363
|
state.selectedId = id;
|
|
2156
2364
|
emit();
|
|
2157
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
|
+
*/
|
|
2158
2374
|
openReader(id) {
|
|
2159
|
-
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' };
|
|
2160
2387
|
emit();
|
|
2161
2388
|
},
|
|
2162
2389
|
closeReader() {
|
|
2163
|
-
state.
|
|
2390
|
+
state.reading = null;
|
|
2164
2391
|
emit();
|
|
2165
2392
|
},
|
|
2166
2393
|
toggleCollapse(id) {
|
|
@@ -2194,6 +2421,21 @@ window.__ModuleLoader__.load({
|
|
|
2194
2421
|
persist();
|
|
2195
2422
|
emit();
|
|
2196
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
|
+
},
|
|
2197
2439
|
compose(id) {
|
|
2198
2440
|
state.composingId = id;
|
|
2199
2441
|
state.selectedId = id;
|
|
@@ -2268,6 +2510,142 @@ window.__ModuleLoader__.load({
|
|
|
2268
2510
|
}
|
|
2269
2511
|
}
|
|
2270
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
|
+
|
|
2271
2649
|
/**
|
|
2272
2650
|
* Tombstone a node and its subtree. Archived sessions are remembered so
|
|
2273
2651
|
* "恢复" can put them back into the session list.
|
|
@@ -2287,6 +2665,7 @@ window.__ModuleLoader__.load({
|
|
|
2287
2665
|
visibleSessions.add(node.sessionId);
|
|
2288
2666
|
}
|
|
2289
2667
|
const archived = Array.isArray(after.archived) ? after.archived.slice() : [];
|
|
2668
|
+
const quieted = new Set(Array.isArray(after.quieted) ? after.quieted : []);
|
|
2290
2669
|
const workspaces = workspacesOf();
|
|
2291
2670
|
let changed = false;
|
|
2292
2671
|
for (const node of after.nodes) {
|
|
@@ -2295,6 +2674,9 @@ window.__ModuleLoader__.load({
|
|
|
2295
2674
|
// Never archive the root session, nor a session a visible node still points at.
|
|
2296
2675
|
if (!sessionId || sessionId === rootId) continue;
|
|
2297
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;
|
|
2298
2680
|
if (!workspaces || typeof workspaces.archiveSession !== 'function') continue;
|
|
2299
2681
|
try {
|
|
2300
2682
|
const result = workspaces.archiveSession(sessionId, { stopActivity: true });
|
|
@@ -2324,6 +2706,21 @@ window.__ModuleLoader__.load({
|
|
|
2324
2706
|
}
|
|
2325
2707
|
}
|
|
2326
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);
|
|
2327
2724
|
}
|
|
2328
2725
|
|
|
2329
2726
|
function remember(sessionId, rootId, nodeId) {
|
|
@@ -2495,6 +2892,15 @@ window.__ModuleLoader__.load({
|
|
|
2495
2892
|
changes.status = 'streaming';
|
|
2496
2893
|
}
|
|
2497
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
|
+
}
|
|
2498
2904
|
};
|
|
2499
2905
|
read();
|
|
2500
2906
|
binding.eventSource.subscribe(read);
|
|
@@ -2516,6 +2922,27 @@ window.__ModuleLoader__.load({
|
|
|
2516
2922
|
// A tombstoned node cannot be forked from even if a stale card asks.
|
|
2517
2923
|
if (hiddenSetOf(snapshot.nodes, snapshot.hidden).has(parentNode.id)) return;
|
|
2518
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
|
+
};
|
|
2519
2946
|
let childId;
|
|
2520
2947
|
try {
|
|
2521
2948
|
childId = await ctx.sessions.fork({
|
|
@@ -2523,9 +2950,11 @@ window.__ModuleLoader__.load({
|
|
|
2523
2950
|
atSeq: parentNode.answerSeq || undefined,
|
|
2524
2951
|
});
|
|
2525
2952
|
} catch (error) {
|
|
2953
|
+
if (parentQuieted) requietParent();
|
|
2526
2954
|
store.setError(T('error.forkFailed', { reason: String((error && error.message) || error) }));
|
|
2527
2955
|
return;
|
|
2528
2956
|
}
|
|
2957
|
+
if (parentQuieted) requietParent();
|
|
2529
2958
|
remember(childId, rootId, nodeId);
|
|
2530
2959
|
store.upsert({
|
|
2531
2960
|
id: nodeId,
|
|
@@ -2623,6 +3052,9 @@ window.__ModuleLoader__.load({
|
|
|
2623
3052
|
} catch (error) {
|
|
2624
3053
|
/* ignore */
|
|
2625
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);
|
|
2626
3058
|
}
|
|
2627
3059
|
} finally {
|
|
2628
3060
|
busy = false;
|
|
@@ -2649,7 +3081,10 @@ window.__ModuleLoader__.load({
|
|
|
2649
3081
|
}
|
|
2650
3082
|
}
|
|
2651
3083
|
|
|
2652
|
-
return {
|
|
3084
|
+
return {
|
|
3085
|
+
rootOf, storeFor, ensureProjection, ensureOpen, branch, loadOlder,
|
|
3086
|
+
deleteSubtree, restoreHidden, setBranchListing, peekImage, loadImage,
|
|
3087
|
+
};
|
|
2653
3088
|
}
|
|
2654
3089
|
|
|
2655
3090
|
// -------------------------------------------------------------- markdown
|
|
@@ -2731,6 +3166,46 @@ window.__ModuleLoader__.load({
|
|
|
2731
3166
|
return -1;
|
|
2732
3167
|
}
|
|
2733
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
|
+
|
|
2734
3209
|
/**
|
|
2735
3210
|
* Inline Markdown: escapes, code spans, emphasis, strikethrough, images,
|
|
2736
3211
|
* links, autolinks and hard breaks.
|
|
@@ -2745,6 +3220,16 @@ window.__ModuleLoader__.load({
|
|
|
2745
3220
|
let i = 0;
|
|
2746
3221
|
while (i < source.length) {
|
|
2747
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
|
+
}
|
|
3232
|
+
}
|
|
2748
3233
|
// Backslash escape: the next character is literal.
|
|
2749
3234
|
if (ch === '\\' && i + 1 < source.length && /[\\`*_{}[\]()#+\-.!>~|]/.test(source[i + 1])) {
|
|
2750
3235
|
buffer += source[i + 1];
|
|
@@ -3318,8 +3803,14 @@ window.__ModuleLoader__.load({
|
|
|
3318
3803
|
? T('live.outputting')
|
|
3319
3804
|
: step > 0 ? T('live.thinking') : T('live.starting');
|
|
3320
3805
|
return h('div', {
|
|
3806
|
+
className: 'dsh-tree-live',
|
|
3321
3807
|
style: {
|
|
3322
|
-
|
|
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,
|
|
3323
3814
|
background: C.accentSoft, border: '1px solid ' + C.accentEdge,
|
|
3324
3815
|
display: 'flex', alignItems: 'center', gap: 7,
|
|
3325
3816
|
fontSize: 10.5, color: C.accent, lineHeight: 1.4,
|
|
@@ -3347,158 +3838,180 @@ window.__ModuleLoader__.load({
|
|
|
3347
3838
|
}
|
|
3348
3839
|
|
|
3349
3840
|
/**
|
|
3350
|
-
* The
|
|
3841
|
+
* The card's one line of thinking.
|
|
3351
3842
|
*
|
|
3352
|
-
*
|
|
3353
|
-
*
|
|
3354
|
-
*
|
|
3355
|
-
*
|
|
3356
|
-
*
|
|
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.
|
|
3357
3849
|
*/
|
|
3358
|
-
function
|
|
3850
|
+
function ThinkingStrip({ node, reading }) {
|
|
3359
3851
|
useLocale();
|
|
3360
3852
|
const awaiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
3361
3853
|
const running = awaiting || node.status === 'thinking' || node.status === 'streaming' || node.status === 'running';
|
|
3362
|
-
const
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
},
|
|
3371
|
-
title: T('card.thinkExpandTitle'),
|
|
3372
|
-
className: 'dsh-tree-reasoning-tail dsh-tree-clamp-2',
|
|
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,
|
|
3373
3862
|
style: {
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
marginTop: 5,
|
|
3377
|
-
|
|
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,
|
|
3378
3869
|
background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent)',
|
|
3379
|
-
fontSize: 10.5, color: C.ink4,
|
|
3870
|
+
fontSize: 10.5, lineHeight: '18px', color: C.ink4, overflow: 'hidden',
|
|
3380
3871
|
},
|
|
3381
|
-
},
|
|
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));
|
|
3382
3875
|
}
|
|
3383
3876
|
|
|
3384
|
-
/**
|
|
3385
|
-
|
|
3386
|
-
*
|
|
3387
|
-
* It is a pointer, not a panel. Expanding the thinking inside a 320px card
|
|
3388
|
-
* stretched the card into a very long strip, which is exactly what made it
|
|
3389
|
-
* awkward to use; the reader is where a long answer — and the thinking
|
|
3390
|
-
* behind it — is actually read. So the row says how much there is and opens
|
|
3391
|
-
* the reader, where the chain sits at the top and folds away.
|
|
3392
|
-
*/
|
|
3393
|
-
function ReasoningRow({ node, onOpen }) {
|
|
3877
|
+
/** One body of the enlarged card: the answer, or the chain behind it. */
|
|
3878
|
+
function ReaderPane({ node, reading, pane, api }) {
|
|
3394
3879
|
useLocale();
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
event.stopPropagation();
|
|
3406
|
-
onOpen();
|
|
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',
|
|
3407
3890
|
},
|
|
3408
|
-
title: T('card.thinkExpandTitle'),
|
|
3409
|
-
className: LINK,
|
|
3410
|
-
style: { color: C.accent, gap: 5, maxWidth: '100%' },
|
|
3411
3891
|
},
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
//
|
|
3417
|
-
//
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
marginTop: 3, paddingLeft: 13, fontSize: 10.2,
|
|
3422
|
-
color: C.ink4, fontVariantNumeric: 'tabular-nums',
|
|
3423
|
-
},
|
|
3424
|
-
}, T('card.thinkTruncated', { count: dropped }))
|
|
3425
|
-
: null,
|
|
3426
|
-
preview
|
|
3427
|
-
? h('div', {
|
|
3428
|
-
className: 'dsh-tree-reasoning-preview dsh-tree-clamp-2',
|
|
3429
|
-
style: {
|
|
3430
|
-
marginTop: 4, paddingLeft: 13, fontSize: 10.8, lineHeight: 1.5,
|
|
3431
|
-
color: C.ink4,
|
|
3432
|
-
},
|
|
3433
|
-
}, preview)
|
|
3434
|
-
: null);
|
|
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 || '')));
|
|
3435
3901
|
}
|
|
3436
3902
|
|
|
3437
3903
|
/**
|
|
3438
|
-
*
|
|
3904
|
+
* One image a prompt carried.
|
|
3439
3905
|
*
|
|
3440
|
-
*
|
|
3441
|
-
*
|
|
3442
|
-
*
|
|
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.
|
|
3443
3909
|
*/
|
|
3444
|
-
function
|
|
3910
|
+
function PromptImage({ api, sessionId, attachment, height, full }) {
|
|
3445
3911
|
useLocale();
|
|
3446
|
-
const [
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
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,
|
|
3467
3940
|
style: {
|
|
3468
|
-
|
|
3469
|
-
|
|
3941
|
+
display: 'block', maxWidth: '100%', maxHeight: '60vh',
|
|
3942
|
+
width: 'auto', height: 'auto', borderRadius: 6,
|
|
3943
|
+
border: '1px solid ' + C.cardEdge, background: C.canvas,
|
|
3470
3944
|
},
|
|
3471
|
-
}
|
|
3472
|
-
:
|
|
3473
|
-
|
|
3474
|
-
? h('div', {
|
|
3945
|
+
})
|
|
3946
|
+
: h('span', {
|
|
3947
|
+
'aria-hidden': true,
|
|
3475
3948
|
style: {
|
|
3476
|
-
|
|
3477
|
-
border: '1px solid ' + C.cardEdge,
|
|
3478
|
-
background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)',
|
|
3479
|
-
fontSize: 12.4, lineHeight: 1.78, color: C.ink4,
|
|
3949
|
+
display: 'block', width: 160, height: 90, borderRadius: 6,
|
|
3950
|
+
border: '1px solid ' + C.cardEdge, background: C.canvas,
|
|
3480
3951
|
},
|
|
3481
|
-
}
|
|
3482
|
-
|
|
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);
|
|
3483
3972
|
}
|
|
3484
3973
|
|
|
3485
|
-
|
|
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 }) {
|
|
3486
3989
|
useLocale();
|
|
3487
3990
|
const snapshot = store.getSnapshot();
|
|
3488
3991
|
const composing = snapshot.composingId === node.id;
|
|
3489
|
-
const [expanded, setExpanded] = useState(false);
|
|
3490
3992
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
3491
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');
|
|
3492
4001
|
// Freeze this mount's entry decision; streamed tokens do not restart it.
|
|
3493
4002
|
const animateEntry = useRef(entering);
|
|
3494
4003
|
const isRunning = isInProgressNode(node);
|
|
3495
4004
|
const awaiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
4005
|
+
const live = isRunning || awaiting;
|
|
4006
|
+
const reading = readingOf(node);
|
|
3496
4007
|
// A running card has a clock. Without it the elapsed time only moved when
|
|
3497
4008
|
// a durable event landed, so a long thinking step left the number frozen
|
|
3498
4009
|
// for minutes and then jumped — the label looked broken rather than busy.
|
|
3499
4010
|
const now = useTicker(isRunning && Boolean(node.startedAt));
|
|
3500
4011
|
const answer = node.answer || '';
|
|
3501
|
-
const answerText = answer.length >
|
|
4012
|
+
const answerText = answer.length > cardPreview.truncate
|
|
4013
|
+
? answer.slice(0, cardPreview.truncate) + T('card.truncated')
|
|
4014
|
+
: answer;
|
|
3502
4015
|
|
|
3503
4016
|
useEffect(() => {
|
|
3504
4017
|
const element = cardRef.current;
|
|
@@ -3531,6 +4044,18 @@ window.__ModuleLoader__.load({
|
|
|
3531
4044
|
: node.status === 'error' ? T('card.status.error')
|
|
3532
4045
|
: node.status === 'stopped' ? T('card.status.stopped')
|
|
3533
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;
|
|
3534
4059
|
|
|
3535
4060
|
return h('div', {
|
|
3536
4061
|
ref: cardRef,
|
|
@@ -3541,7 +4066,7 @@ window.__ModuleLoader__.load({
|
|
|
3541
4066
|
position: 'absolute',
|
|
3542
4067
|
left: 0,
|
|
3543
4068
|
top: 0,
|
|
3544
|
-
width:
|
|
4069
|
+
width: cardWidth,
|
|
3545
4070
|
minHeight: 132,
|
|
3546
4071
|
background: C.card,
|
|
3547
4072
|
border: '1px solid ' + (awaiting || match || selected ? C.accent : C.cardEdge),
|
|
@@ -3558,7 +4083,10 @@ window.__ModuleLoader__.load({
|
|
|
3558
4083
|
cursor: 'pointer',
|
|
3559
4084
|
},
|
|
3560
4085
|
},
|
|
3561
|
-
|
|
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 } },
|
|
3562
4090
|
h(StatusDot, { status: node.status, waiting: awaiting }),
|
|
3563
4091
|
h(Badge, { label: index, tone: C.accent }),
|
|
3564
4092
|
isLatest
|
|
@@ -3660,86 +4188,79 @@ window.__ModuleLoader__.load({
|
|
|
3660
4188
|
style: { border: 'none', background: 'transparent', width: '100%', justifyContent: 'flex-start' },
|
|
3661
4189
|
}, T('card.delete'))))
|
|
3662
4190
|
: null),
|
|
4191
|
+
h(PromptImages, { api, sessionId: node.sessionId, images, height: 48 }),
|
|
3663
4192
|
h('div', {
|
|
3664
4193
|
className: 'dsh-tree-clamp-3',
|
|
3665
4194
|
style: {
|
|
3666
4195
|
fontSize: 12.5, fontWeight: 600, lineHeight: 1.45, color: C.ink,
|
|
3667
4196
|
},
|
|
3668
|
-
},
|
|
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.
|
|
3669
4202
|
h('div', {
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
title: answer ? T('card.readTitle') : undefined,
|
|
3676
|
-
style: {
|
|
3677
|
-
...MD.body,
|
|
3678
|
-
marginTop: 6,
|
|
3679
|
-
maxHeight: expanded ? 3000 : 146,
|
|
3680
|
-
overflow: 'hidden',
|
|
3681
|
-
cursor: answer ? 'zoom-in' : 'default',
|
|
3682
|
-
maskImage: (!expanded && answer.length > 320) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
3683
|
-
WebkitMaskImage: (!expanded && answer.length > 320) ? 'linear-gradient(#000 82%, transparent 100%)' : 'none',
|
|
3684
|
-
},
|
|
3685
|
-
}, answer ? renderMarkdown(answerText) : null),
|
|
3686
|
-
h(LiveProgress, { node, now }),
|
|
3687
|
-
h(ReasoningTail, { node, onOpen: () => store.openReader(node.id) }),
|
|
3688
|
-
h(ReasoningRow, { node, onOpen: () => store.openReader(node.id) }),
|
|
3689
|
-
h(Presence, { show: composing, className: 'dsh-tree-composer' },
|
|
3690
|
-
h(Composer, { store, api, rootId, node, active: composing })),
|
|
3691
|
-
answer.length > 260 || childCount > 0
|
|
3692
|
-
? h('div', {
|
|
4203
|
+
className: 'dsh-tree-band',
|
|
4204
|
+
style: bandStyle,
|
|
4205
|
+
},
|
|
4206
|
+
h('div', {
|
|
4207
|
+
className: 'dsh-tree-preview',
|
|
3693
4208
|
style: {
|
|
3694
|
-
|
|
3695
|
-
|
|
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',
|
|
3696
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,
|
|
3697
4228
|
},
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round',
|
|
3727
|
-
})))
|
|
3728
|
-
: null,
|
|
3729
|
-
h('span', { style: { flex: 1 } }),
|
|
3730
|
-
childCount > 0
|
|
3731
|
-
? h('button', {
|
|
3732
|
-
onClick: (event) => {
|
|
3733
|
-
event.stopPropagation();
|
|
3734
|
-
store.toggleCollapse(node.id);
|
|
3735
|
-
},
|
|
3736
|
-
title: collapsed ? T('card.unfoldBranch') : T('card.foldBranch'),
|
|
3737
|
-
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);
|
|
3738
4257
|
},
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
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));
|
|
3743
4264
|
}
|
|
3744
4265
|
|
|
3745
4266
|
function Composer({ store, api, rootId, node, active }) {
|
|
@@ -3796,7 +4317,7 @@ window.__ModuleLoader__.load({
|
|
|
3796
4317
|
}, T('composer.send'))));
|
|
3797
4318
|
}
|
|
3798
4319
|
|
|
3799
|
-
function Canvas({ store, api, rootId, size
|
|
4320
|
+
function Canvas({ store, api, rootId, size }) {
|
|
3800
4321
|
useLocale();
|
|
3801
4322
|
const snapshot = store.getSnapshot();
|
|
3802
4323
|
const nodes = snapshot.nodes;
|
|
@@ -3808,6 +4329,17 @@ window.__ModuleLoader__.load({
|
|
|
3808
4329
|
}, [nodes]);
|
|
3809
4330
|
const [query, setQuery] = useState('');
|
|
3810
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();
|
|
3811
4343
|
const drag = useRef(null);
|
|
3812
4344
|
const wrapRef = useRef(null);
|
|
3813
4345
|
const searchRef = useRef(null);
|
|
@@ -3839,8 +4371,8 @@ window.__ModuleLoader__.load({
|
|
|
3839
4371
|
return { direct, descendants: descendantCountsOf(liveNodes, childrenOf) };
|
|
3840
4372
|
}, [liveNodes]);
|
|
3841
4373
|
const layout = useMemo(
|
|
3842
|
-
() => layoutTree(liveNodes, collapsedMap, snapshot.heights, direction),
|
|
3843
|
-
[liveNodes, collapsedMap, snapshot.heights, direction]);
|
|
4374
|
+
() => layoutTree(liveNodes, collapsedMap, snapshot.heights, direction, cardWidth),
|
|
4375
|
+
[liveNodes, collapsedMap, snapshot.heights, direction, cardWidth]);
|
|
3844
4376
|
const path = useMemo(
|
|
3845
4377
|
() => (snapshot.selectedId ? pathOf(liveNodes, snapshot.selectedId) : new Set()),
|
|
3846
4378
|
[liveNodes, snapshot.selectedId]);
|
|
@@ -3857,6 +4389,7 @@ window.__ModuleLoader__.load({
|
|
|
3857
4389
|
const labels = useMemo(() => labelMapOf(liveNodes, collapsedMap), [liveNodes, collapsedMap]);
|
|
3858
4390
|
const running = liveNodes.filter((node) => RUNNING_STATUSES.indexOf(node.status) >= 0).length;
|
|
3859
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;
|
|
3860
4393
|
const hiddenCount = hiddenIds.size;
|
|
3861
4394
|
const tombstoned = Object.keys(snapshot.hidden || {}).length;
|
|
3862
4395
|
|
|
@@ -3873,12 +4406,12 @@ window.__ModuleLoader__.load({
|
|
|
3873
4406
|
const pos = layout.positions.get(node.id);
|
|
3874
4407
|
if (!pos) continue;
|
|
3875
4408
|
const height = snapshot.heights[node.id] || NODE_H;
|
|
3876
|
-
if (pos.x +
|
|
4409
|
+
if (pos.x + cardWidth >= left && pos.x <= right && pos.y + height >= top && pos.y <= bottom) {
|
|
3877
4410
|
shown.push(node);
|
|
3878
4411
|
}
|
|
3879
4412
|
}
|
|
3880
4413
|
return shown.length ? shown : liveNodes;
|
|
3881
|
-
}, [liveNodes, layout, view, size, snapshot.heights]);
|
|
4414
|
+
}, [liveNodes, layout, view, size, snapshot.heights, cardWidth]);
|
|
3882
4415
|
|
|
3883
4416
|
/** Reveal first; position only after the expanded layout has committed. */
|
|
3884
4417
|
const focusNode = useCallback((id) => {
|
|
@@ -3890,14 +4423,14 @@ window.__ModuleLoader__.load({
|
|
|
3890
4423
|
const pos = layout.positions.get(pendingFocus);
|
|
3891
4424
|
if (!pos) { setPendingFocus(null); return; }
|
|
3892
4425
|
const rect = wrapRef.current ? wrapRef.current.getBoundingClientRect() : { width: 900, height: 600 };
|
|
3893
|
-
const top =
|
|
3894
|
-
const availableHeight = Math.max(1, rect.height - top
|
|
4426
|
+
const top = (toolbarRef.current ? toolbarRef.current.offsetHeight : 44) + 28;
|
|
4427
|
+
const availableHeight = Math.max(1, rect.height - top);
|
|
3895
4428
|
const height = snapshot.heights[pendingFocus] || NODE_H;
|
|
3896
|
-
const z = Math.max(0.2, Math.min(1, (rect.width - 48) /
|
|
3897
|
-
setView({ z, x: rect.width / 2 - (pos.x +
|
|
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,
|
|
3898
4431
|
y: top + availableHeight / 2 - (pos.y + height / 2) * z }, true);
|
|
3899
4432
|
setPendingFocus(null);
|
|
3900
|
-
}, [pendingFocus, layout, snapshot.heights,
|
|
4433
|
+
}, [pendingFocus, layout, snapshot.heights, cardWidth]);
|
|
3901
4434
|
const latest = latestNodeOf(liveNodes);
|
|
3902
4435
|
|
|
3903
4436
|
/** Jump to the next card matching `predicate`, wrapping around. */
|
|
@@ -3941,7 +4474,7 @@ window.__ModuleLoader__.load({
|
|
|
3941
4474
|
announcedRef.current.add(node.id);
|
|
3942
4475
|
// Never yank the canvas out from under the reader overlay, and do not
|
|
3943
4476
|
// steal the viewport when another branch is already waiting.
|
|
3944
|
-
if (firstWait && !store.getSnapshot().
|
|
4477
|
+
if (firstWait && !store.getSnapshot().reading) focusNode(node.id);
|
|
3945
4478
|
}
|
|
3946
4479
|
}, [liveNodes, defaultCollapsedMap, store, focusNode]);
|
|
3947
4480
|
|
|
@@ -4042,14 +4575,14 @@ window.__ModuleLoader__.load({
|
|
|
4042
4575
|
};
|
|
4043
4576
|
|
|
4044
4577
|
/** Height the floating toolbar occupies, so the tree starts below it. */
|
|
4045
|
-
const chromeHeight = () =>
|
|
4578
|
+
const chromeHeight = () => (toolbarRef.current ? toolbarRef.current.offsetHeight : 48) + 22;
|
|
4046
4579
|
|
|
4047
4580
|
const fit = () => {
|
|
4048
4581
|
const rect = wrapRef.current ? wrapRef.current.getBoundingClientRect() : { width: 900, height: 600 };
|
|
4049
4582
|
if (!layout.width || !layout.height) return;
|
|
4050
4583
|
const chrome = chromeHeight();
|
|
4051
4584
|
const availableW = Math.max(200, rect.width - 80);
|
|
4052
|
-
const availableH = Math.max(200, rect.height - chrome -
|
|
4585
|
+
const availableH = Math.max(200, rect.height - chrome - 48);
|
|
4053
4586
|
const z = Math.min(1, Math.min(availableW / layout.width, availableH / layout.height));
|
|
4054
4587
|
const scale = Math.max(0.2, z);
|
|
4055
4588
|
setView({
|
|
@@ -4079,14 +4612,28 @@ window.__ModuleLoader__.load({
|
|
|
4079
4612
|
else fit();
|
|
4080
4613
|
}, [direction]);
|
|
4081
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
|
+
|
|
4082
4629
|
const fittedRef = useRef(false);
|
|
4083
4630
|
useEffect(() => {
|
|
4084
|
-
if (fittedRef.current || !
|
|
4631
|
+
if (fittedRef.current || !liveNodes.length || !size.w) return;
|
|
4085
4632
|
fittedRef.current = true;
|
|
4086
4633
|
const rect = wrapRef.current ? wrapRef.current.getBoundingClientRect() : { width: 900, height: 600 };
|
|
4087
4634
|
const chrome = chromeHeight();
|
|
4088
4635
|
const availableW = Math.max(200, rect.width - 96);
|
|
4089
|
-
const availableH = Math.max(200, rect.height - chrome -
|
|
4636
|
+
const availableH = Math.max(200, rect.height - chrome - 56);
|
|
4090
4637
|
const raw = Math.min(1, availableW / Math.max(1, layout.width), availableH / Math.max(1, layout.height));
|
|
4091
4638
|
const scale = Math.max(0.62, raw);
|
|
4092
4639
|
setView({
|
|
@@ -4094,7 +4641,7 @@ window.__ModuleLoader__.load({
|
|
|
4094
4641
|
x: Math.max(28, (rect.width - layout.width * scale) / 2),
|
|
4095
4642
|
y: chrome,
|
|
4096
4643
|
});
|
|
4097
|
-
}, [liveNodes.length, size.w
|
|
4644
|
+
}, [liveNodes.length, size.w]);
|
|
4098
4645
|
|
|
4099
4646
|
// Ctrl/Cmd+F is the tree's own search while this view is mounted.
|
|
4100
4647
|
useEffect(() => {
|
|
@@ -4113,7 +4660,7 @@ window.__ModuleLoader__.load({
|
|
|
4113
4660
|
|
|
4114
4661
|
return h('div', {
|
|
4115
4662
|
ref: wrapRef,
|
|
4116
|
-
inert: snapshot.
|
|
4663
|
+
inert: snapshot.reading ? true : undefined,
|
|
4117
4664
|
onWheel,
|
|
4118
4665
|
onMouseDown,
|
|
4119
4666
|
onMouseMove,
|
|
@@ -4172,6 +4719,8 @@ window.__ModuleLoader__.load({
|
|
|
4172
4719
|
descendants: counts.descendants.get(node.id) || 0,
|
|
4173
4720
|
isLatest: latest ? latest.id === node.id : false,
|
|
4174
4721
|
entering: !seenNodes.current.has(node.id),
|
|
4722
|
+
width: cardWidth,
|
|
4723
|
+
preview: card,
|
|
4175
4724
|
}));
|
|
4176
4725
|
})),
|
|
4177
4726
|
|
|
@@ -4181,7 +4730,7 @@ window.__ModuleLoader__.load({
|
|
|
4181
4730
|
onMouseDown: (event) => event.stopPropagation(),
|
|
4182
4731
|
onWheel: (event) => event.stopPropagation(),
|
|
4183
4732
|
style: {
|
|
4184
|
-
position: 'absolute', top:
|
|
4733
|
+
position: 'absolute', top: 10, left: 12, right: 12, display: 'flex', gap: 8,
|
|
4185
4734
|
flexWrap: 'wrap', padding: 8, borderRadius: 12, background: C.card,
|
|
4186
4735
|
border: '1px solid ' + C.cardEdge, boxShadow: 'var(--dsh-tree-shadow-1)',
|
|
4187
4736
|
alignItems: 'center', fontSize: 12, color: C.ink3,
|
|
@@ -4214,6 +4763,18 @@ window.__ModuleLoader__.load({
|
|
|
4214
4763
|
...pillProps(),
|
|
4215
4764
|
}, T('view.restoreHidden', { count: Math.max(hiddenCount, tombstoned) }))
|
|
4216
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,
|
|
4217
4778
|
h('span', { style: { flex: 1 } }),
|
|
4218
4779
|
h('div', {
|
|
4219
4780
|
style: {
|
|
@@ -4296,6 +4857,29 @@ window.__ModuleLoader__.load({
|
|
|
4296
4857
|
setDirection('horizontal');
|
|
4297
4858
|
},
|
|
4298
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' })))),
|
|
4299
4883
|
h('button', { onClick: fit, className: BTN, title: T('view.fitTitle') }, h(Icon, { name: 'fit' }), T('view.fit')),
|
|
4300
4884
|
h('button', {
|
|
4301
4885
|
disabled: !latest,
|
|
@@ -4309,7 +4893,7 @@ window.__ModuleLoader__.load({
|
|
|
4309
4893
|
? h('div', {
|
|
4310
4894
|
onMouseDown: (event) => event.stopPropagation(),
|
|
4311
4895
|
style: {
|
|
4312
|
-
position: 'absolute', right: 12, bottom: 12
|
|
4896
|
+
position: 'absolute', right: 12, bottom: 12, width: 168, height: 112,
|
|
4313
4897
|
border: '1px solid ' + C.cardEdge, borderRadius: 8, background: C.card,
|
|
4314
4898
|
boxShadow: 'var(--dsh-tree-shadow-1)', overflow: 'hidden', cursor: 'pointer',
|
|
4315
4899
|
},
|
|
@@ -4355,7 +4939,7 @@ window.__ModuleLoader__.load({
|
|
|
4355
4939
|
const waiting = node.awaiting === 'question' || node.awaiting === 'approval';
|
|
4356
4940
|
return h('rect', {
|
|
4357
4941
|
key: node.id,
|
|
4358
|
-
x: pos.x, y: pos.y, width:
|
|
4942
|
+
x: pos.x, y: pos.y, width: cardWidth,
|
|
4359
4943
|
height: snapshot.heights[node.id] || NODE_H,
|
|
4360
4944
|
rx: 10,
|
|
4361
4945
|
fill: matches && matches.has(node.id) ? C.accent : waiting ? C.accent : active ? C.accentSoft : C.line,
|
|
@@ -4391,23 +4975,54 @@ window.__ModuleLoader__.load({
|
|
|
4391
4975
|
}
|
|
4392
4976
|
|
|
4393
4977
|
function Icon({ name }) {
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
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]] },
|
|
4405
5006
|
};
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
5007
|
+
const glyph = glyphs[name];
|
|
5008
|
+
if (!glyph) return null;
|
|
5009
|
+
const stroke = {
|
|
5010
|
+
fill: 'none', stroke: 'currentColor', strokeWidth: 1.7,
|
|
4409
5011
|
strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
4410
|
-
}
|
|
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);
|
|
4411
5026
|
}
|
|
4412
5027
|
|
|
4413
5028
|
// Buttons: all paint lives in CSS so :hover/:active/:focus-visible can exist.
|
|
@@ -4485,11 +5100,21 @@ window.__ModuleLoader__.load({
|
|
|
4485
5100
|
* and no focus restoration; it only mirrors the element's `close` event back
|
|
4486
5101
|
* into React state.
|
|
4487
5102
|
*/
|
|
4488
|
-
function Reader({ node, open, onClose }) {
|
|
5103
|
+
function Reader({ node, open, onClose, pane, onPane, api }) {
|
|
4489
5104
|
useLocale();
|
|
4490
5105
|
const dialogRef = useRef(null);
|
|
4491
5106
|
const close = useRef(onClose);
|
|
4492
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);
|
|
4493
5118
|
|
|
4494
5119
|
// `show()` would leave the page interactive; the reader is blocking.
|
|
4495
5120
|
useEffect(() => {
|
|
@@ -4497,8 +5122,22 @@ window.__ModuleLoader__.load({
|
|
|
4497
5122
|
if (!dialog) return undefined;
|
|
4498
5123
|
if (open) {
|
|
4499
5124
|
if (!dialog.open) {
|
|
4500
|
-
|
|
4501
|
-
|
|
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', '');
|
|
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();
|
|
4502
5141
|
}
|
|
4503
5142
|
} else if (dialog.open) {
|
|
4504
5143
|
dialog.close();
|
|
@@ -4507,15 +5146,37 @@ window.__ModuleLoader__.load({
|
|
|
4507
5146
|
}, [open, node && node.id]);
|
|
4508
5147
|
|
|
4509
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.
|
|
4510
5156
|
useEffect(() => {
|
|
4511
5157
|
const dialog = dialogRef.current;
|
|
4512
5158
|
if (!dialog) return undefined;
|
|
4513
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();
|
|
4514
5166
|
dialog.addEventListener('close', onDismiss);
|
|
4515
|
-
|
|
4516
|
-
|
|
5167
|
+
dialog.addEventListener('cancel', onCancel);
|
|
5168
|
+
return () => {
|
|
5169
|
+
dialog.removeEventListener('close', onDismiss);
|
|
5170
|
+
dialog.removeEventListener('cancel', onCancel);
|
|
5171
|
+
};
|
|
5172
|
+
}, [node && node.id]);
|
|
4517
5173
|
|
|
4518
5174
|
if (!node) return null;
|
|
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';
|
|
4519
5180
|
const titleId = 'dsh-tree-reader-title-' + (node.id || 'node');
|
|
4520
5181
|
return h('dialog', {
|
|
4521
5182
|
ref: dialogRef,
|
|
@@ -4523,9 +5184,20 @@ window.__ModuleLoader__.load({
|
|
|
4523
5184
|
// The modal already carries role="dialog" and aria-modal: adding them
|
|
4524
5185
|
// here would announce the overlay twice.
|
|
4525
5186
|
'aria-labelledby': titleId,
|
|
4526
|
-
//
|
|
4527
|
-
|
|
4528
|
-
closedby
|
|
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();
|
|
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)' },
|
|
4529
5201
|
},
|
|
4530
5202
|
h('div', {
|
|
4531
5203
|
style: {
|
|
@@ -4540,7 +5212,7 @@ window.__ModuleLoader__.load({
|
|
|
4540
5212
|
h('div', {
|
|
4541
5213
|
id: titleId,
|
|
4542
5214
|
style: { fontSize: 15, fontWeight: 600, lineHeight: 1.5, color: C.ink },
|
|
4543
|
-
},
|
|
5215
|
+
}, questionLabel ? commandTextNodes(questionLabel, 'rq') : null)),
|
|
4544
5216
|
h('button', {
|
|
4545
5217
|
onClick: onClose,
|
|
4546
5218
|
title: T('reader.close'),
|
|
@@ -4548,18 +5220,83 @@ window.__ModuleLoader__.load({
|
|
|
4548
5220
|
className: 'dsh-tree-btn dsh-tree-btn--icon',
|
|
4549
5221
|
style: { width: 30, height: 30, minWidth: 30, minHeight: 30 },
|
|
4550
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.
|
|
4551
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,
|
|
4552
5294
|
className: 'dsh-tree-scroll',
|
|
4553
5295
|
style: {
|
|
4554
5296
|
padding: '18px 22px 22px', overflow: 'auto', flex: 1,
|
|
4555
5297
|
...MD.body, fontSize: 13.4, lineHeight: 1.85,
|
|
4556
5298
|
},
|
|
4557
|
-
},
|
|
4558
|
-
// The thinking comes first: it is what the reader opened the
|
|
4559
|
-
// card for, and folding it keeps the answer itself at the top
|
|
4560
|
-
// of the eye.
|
|
4561
|
-
h(ReasoningDisclosure, { node }),
|
|
4562
|
-
node.answer ? renderMarkdown(node.answer) : T('reader.noAnswer')),
|
|
5299
|
+
}, h(ReaderPane, { node, reading, pane: activePane, api })),
|
|
4563
5300
|
|
|
4564
5301
|
h('div', {
|
|
4565
5302
|
style: {
|
|
@@ -4580,41 +5317,17 @@ window.__ModuleLoader__.load({
|
|
|
4580
5317
|
const rootId = useMemo(() => api.rootOf(sessionId), [sessionId, api]);
|
|
4581
5318
|
const store = useMemo(() => api.storeFor(rootId), [rootId, api]);
|
|
4582
5319
|
const [, force] = useState(0);
|
|
4583
|
-
const anchorRef = useRef(null);
|
|
4584
5320
|
const hostRef = useRef(null);
|
|
4585
|
-
const [
|
|
4586
|
-
const [size, setSize] = useState({ w: 0, h: 0, top: 0, bottom: 0 });
|
|
5321
|
+
const [size, setSize] = useState({ w: 0, h: 0 });
|
|
4587
5322
|
|
|
4588
5323
|
useEffect(() => store.subscribe(() => force((n) => n + 1)), [store]);
|
|
4589
5324
|
useEffect(() => {
|
|
4590
5325
|
api.ensureOpen(rootId, store);
|
|
4591
5326
|
}, [rootId, store, api]);
|
|
4592
|
-
useEffect(() => {
|
|
4593
|
-
const anchor = anchorRef.current;
|
|
4594
|
-
const body = anchor && anchor.closest('[data-conversation-content]');
|
|
4595
|
-
const container = body && body.parentElement;
|
|
4596
|
-
const header = container && (container.querySelector(':scope > header') ||
|
|
4597
|
-
container.querySelector(':scope > [data-slot="conversation.header"] > header'));
|
|
4598
|
-
const composer = body && body.querySelector('[data-composer-seat]');
|
|
4599
|
-
if (!container || !header || !composer) return;
|
|
4600
|
-
try {
|
|
4601
|
-
const { createPortal } = require('react-dom');
|
|
4602
|
-
if (typeof createPortal !== 'function') return;
|
|
4603
|
-
setSize({ w: 0, h: 0, top: 0, bottom: 0 });
|
|
4604
|
-
setSurface({ container, header, composer, createPortal });
|
|
4605
|
-
} catch (error) {
|
|
4606
|
-
/* Hosts without a portal keep the canvas inside the view. */
|
|
4607
|
-
}
|
|
4608
|
-
}, []);
|
|
4609
5327
|
useEffect(() => {
|
|
4610
5328
|
const element = hostRef.current;
|
|
4611
5329
|
if (!element) return undefined;
|
|
4612
|
-
const measure = () => {
|
|
4613
|
-
const rect = element.getBoundingClientRect();
|
|
4614
|
-
const top = surface ? Math.max(0, surface.header.getBoundingClientRect().bottom - rect.top) : 0;
|
|
4615
|
-
const bottom = surface ? Math.max(0, rect.bottom - surface.composer.getBoundingClientRect().top) : 0;
|
|
4616
|
-
setSize({ w: element.clientWidth, h: element.clientHeight, top, bottom, container: surface ? surface.container : null });
|
|
4617
|
-
};
|
|
5330
|
+
const measure = () => setSize({ w: element.clientWidth, h: element.clientHeight });
|
|
4618
5331
|
measure();
|
|
4619
5332
|
if (typeof ResizeObserver === 'undefined') {
|
|
4620
5333
|
window.addEventListener('resize', measure);
|
|
@@ -4622,31 +5335,44 @@ window.__ModuleLoader__.load({
|
|
|
4622
5335
|
}
|
|
4623
5336
|
const observer = new ResizeObserver(measure);
|
|
4624
5337
|
observer.observe(element);
|
|
4625
|
-
if (surface) {
|
|
4626
|
-
observer.observe(surface.header);
|
|
4627
|
-
observer.observe(surface.composer);
|
|
4628
|
-
}
|
|
4629
5338
|
return () => observer.disconnect();
|
|
4630
|
-
}, [
|
|
5339
|
+
}, []);
|
|
4631
5340
|
|
|
4632
5341
|
const snapshot = store.getSnapshot();
|
|
4633
|
-
const
|
|
5342
|
+
const readingState = snapshot.reading;
|
|
5343
|
+
const reading = readingState ? store.getNode(readingState.nodeId) : undefined;
|
|
4634
5344
|
const readerNode = useRef(null);
|
|
4635
5345
|
if (reading) readerNode.current = reading;
|
|
4636
|
-
|
|
4637
|
-
|
|
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.
|
|
5357
|
+
return h('div', {
|
|
4638
5358
|
ref: hostRef,
|
|
4639
|
-
className:
|
|
5359
|
+
className: 'dsh-tree-root',
|
|
5360
|
+
'data-conversation-composer-overlay': '',
|
|
4640
5361
|
style: {
|
|
4641
|
-
position:
|
|
4642
|
-
width: '100%', height: '100%', minHeight: 0, zIndex: surface ? (reading ? 20 : 1) : undefined,
|
|
5362
|
+
position: 'relative', width: '100%', height: '100%', minHeight: 0,
|
|
4643
5363
|
overflow: 'hidden', fontFamily: FONT, color: C.ink, background: C.canvas,
|
|
4644
5364
|
},
|
|
4645
5365
|
},
|
|
4646
|
-
h(Boundary, null, h(Canvas, { key: rootId, store, api, rootId, size
|
|
4647
|
-
h(Reader, {
|
|
4648
|
-
|
|
4649
|
-
|
|
5366
|
+
h(Boundary, null, h(Canvas, { key: rootId, store, api, rootId, size })),
|
|
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
|
+
}));
|
|
4650
5376
|
}
|
|
4651
5377
|
|
|
4652
5378
|
// ------------------------------------------------------------------ mount
|
|
@@ -4676,12 +5402,11 @@ window.__ModuleLoader__.load({
|
|
|
4676
5402
|
// scroll areas use the host's scrollbar tokens.
|
|
4677
5403
|
'.dsh-tree-root { color-scheme: light; }',
|
|
4678
5404
|
'body[data-ds-dark-theme] .dsh-tree-root { color-scheme: dark; }',
|
|
4679
|
-
'.dsh-tree-clamp-
|
|
5405
|
+
'.dsh-tree-clamp-3 {',
|
|
4680
5406
|
' display: -webkit-box; -webkit-box-orient: vertical;',
|
|
4681
|
-
' -webkit-line-clamp:
|
|
5407
|
+
' -webkit-line-clamp: 3; line-clamp: 3;',
|
|
4682
5408
|
' overflow: hidden; overflow-wrap: break-word;',
|
|
4683
5409
|
'}',
|
|
4684
|
-
'.dsh-tree-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }',
|
|
4685
5410
|
'.dsh-tree-one-line {',
|
|
4686
5411
|
' min-inline-size: 0; overflow: hidden; text-overflow: ellipsis;',
|
|
4687
5412
|
' white-space: nowrap;',
|
|
@@ -4710,8 +5435,13 @@ window.__ModuleLoader__.load({
|
|
|
4710
5435
|
'.dsh-tree-table tbody tr:nth-child(even) td {',
|
|
4711
5436
|
' background: color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent);',
|
|
4712
5437
|
'}',
|
|
4713
|
-
|
|
4714
|
-
|
|
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; }',
|
|
4715
5445
|
'@keyframes dshTreeReveal { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }',
|
|
4716
5446
|
'@keyframes dshTreeDismiss { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(3px) scale(.99); } }',
|
|
4717
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; }',
|
|
@@ -4721,36 +5451,37 @@ window.__ModuleLoader__.load({
|
|
|
4721
5451
|
'.dsh-tree-menu { transform-origin: top right; }',
|
|
4722
5452
|
'.dsh-tree-menu[data-open="true"] { animation-timing-function: var(--tree-spring); }',
|
|
4723
5453
|
'.dsh-tree-composer { transform-origin: top center; }',
|
|
4724
|
-
//
|
|
4725
|
-
//
|
|
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.
|
|
4726
5471
|
'.dsh-tree-reader {',
|
|
4727
5472
|
' margin: auto; padding: 0; border: none; margin-block: auto;',
|
|
4728
|
-
' width: min(820px, calc(100vw - 68px)); max-width: calc(100vw - 68px);',
|
|
4729
5473
|
' max-height: calc(100vh - 56px);',
|
|
4730
5474
|
' background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary);',
|
|
4731
5475
|
' border-radius: 14px; box-shadow: var(--dsh-tree-shadow-3); overflow: hidden;',
|
|
4732
5476
|
// MANDATORY: without this, a scroll inside the dialog chains to the page
|
|
4733
5477
|
// behind it as soon as the dialog reaches its own scroll boundary.
|
|
4734
5478
|
' overscroll-behavior: contain;',
|
|
4735
|
-
' opacity: 0;',
|
|
4736
|
-
// MANDATORY for the top layer: display and overlay are discrete, and the
|
|
4737
|
-
// element has to stay in the top layer while it animates out.
|
|
4738
|
-
' transition-property: opacity, transform, display, overlay;',
|
|
4739
|
-
' transition-duration: var(--tree-exit);',
|
|
4740
|
-
' transition-timing-function: ease-out;',
|
|
4741
|
-
' transition-behavior: allow-discrete;',
|
|
4742
5479
|
'}',
|
|
4743
5480
|
// display is set only while open: an unconditional display would override
|
|
4744
5481
|
// the closed state and leave the dialog permanently on screen.
|
|
4745
5482
|
'.dsh-tree-reader[open] {',
|
|
4746
|
-
' display: flex; flex-direction: column;
|
|
4747
|
-
' transition-duration: var(--tree-enter);',
|
|
4748
|
-
'}',
|
|
4749
|
-
'@media (prefers-reduced-motion: no-preference) {',
|
|
4750
|
-
' .dsh-tree-reader { transform: translateY(6px) scale(.985); }',
|
|
4751
|
-
' .dsh-tree-reader[open] { transform: none; }',
|
|
5483
|
+
' display: flex; flex-direction: column;',
|
|
4752
5484
|
'}',
|
|
4753
|
-
'@starting-style { .dsh-tree-reader[open] { opacity: 0; } }',
|
|
4754
5485
|
// MANDATORY: ::backdrop is not a scroll container by default, so
|
|
4755
5486
|
// overscroll-behavior alone would not stop a gesture over the backdrop
|
|
4756
5487
|
// from scrolling the page underneath.
|
|
@@ -4899,6 +5630,9 @@ window.__ModuleLoader__.load({
|
|
|
4899
5630
|
loadOlder: runtime.loadOlder,
|
|
4900
5631
|
deleteSubtree: runtime.deleteSubtree,
|
|
4901
5632
|
restoreHidden: runtime.restoreHidden,
|
|
5633
|
+
setBranchListing: runtime.setBranchListing,
|
|
5634
|
+
peekImage: runtime.peekImage,
|
|
5635
|
+
loadImage: runtime.loadImage,
|
|
4902
5636
|
} }),
|
|
4903
5637
|
}, TreeView));
|
|
4904
5638
|
},
|