@niracler/encore 0.2.0 → 0.4.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 +64 -103
- package/README.zh-CN.md +65 -97
- package/bin/encore.mjs +60 -120
- package/package.json +5 -3
- package/player/encore-player.css +125 -44
- package/player/encore-player.js +563 -287
- package/schema/session.schema.json +64 -2
- package/skills/encore/SKILL.md +39 -35
- package/src/antigravity.mjs +162 -0
- package/src/attachment-previews.mjs +169 -0
- package/src/attachment-reader.mjs +169 -0
- package/src/claude-ai.mjs +3 -1
- package/src/claude-code.mjs +11 -7
- package/src/codex.mjs +10 -3
- package/src/common.mjs +30 -7
- package/src/detect.mjs +96 -51
- package/src/external-files.mjs +193 -0
- package/src/i18n.mjs +108 -28
- package/src/index.d.ts +22 -3
- package/src/index.mjs +73 -44
- package/src/markdown.mjs +14 -11
- package/src/player-assets.mjs +4 -1
- package/src/player-runtime.mjs +147 -131
- package/src/render.mjs +83 -83
- package/src/server.mjs +2 -0
- package/src/session-picker.mjs +162 -0
- package/src/timeline.mjs +44 -35
- package/src/workbuddy.mjs +6 -5
package/player/encore-player.js
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
// --- i18n.mjs ---
|
|
4
4
|
const DICTS = {
|
|
5
5
|
zh: {
|
|
6
|
+
workspaceWrite: '工作区可写',
|
|
7
|
+
contextLabel: '上下文',
|
|
8
|
+
itemCount: '{n} 条',
|
|
9
|
+
agentSent: '已派出',
|
|
10
|
+
agentStopped: '已叫停',
|
|
11
|
+
agentRateLimited: '额度中断',
|
|
12
|
+
agentFailed: '失败',
|
|
13
|
+
agentDone: '已交回',
|
|
14
|
+
turnTag: '第 {n} 轮',
|
|
15
|
+
replyTag: '第 {n} 次回复',
|
|
16
|
+
stepTag: '第 {n} 步',
|
|
17
|
+
thinking: '思考',
|
|
18
|
+
reasoning: '推理过程',
|
|
19
|
+
preview: '预览',
|
|
20
|
+
draft: '草稿',
|
|
21
|
+
rule: '规则',
|
|
22
|
+
promptTitle: '提问 #{n}',
|
|
23
|
+
sessionStart: '会话开始',
|
|
24
|
+
userMessage: '用户消息',
|
|
25
|
+
assistantReply: '助手回复',
|
|
26
|
+
appendedPrompt: '已将用户消息加入上下文',
|
|
27
|
+
waitingForTools: '等待助手推理与调用工具',
|
|
28
|
+
synthesizing: '汇总结果({tools})',
|
|
29
|
+
directResponse: '直接回复',
|
|
30
|
+
completedResponse: '回复完成',
|
|
31
|
+
toolCalls: '工具调用 × {n}',
|
|
32
|
+
archivedTools: '已归档 {n} 条工具输出(-{tokens}k tokens)',
|
|
6
33
|
langCode: 'zh-CN',
|
|
7
34
|
toggleLangLabel: 'EN',
|
|
8
35
|
toggleLangTitle: 'Switch to English',
|
|
@@ -19,13 +46,12 @@ const DICTS = {
|
|
|
19
46
|
sendThisPrompt: '发送本轮提问',
|
|
20
47
|
waitNextStep: '等待下一步',
|
|
21
48
|
composerPlaceholder: '向 Agent 发送消息…',
|
|
22
|
-
composerFinished: '会话已结束 ·
|
|
49
|
+
composerFinished: '会话已结束 · 点击上方任意消息可查看当时的上下文快照',
|
|
23
50
|
emptyHintStart: '点击左下角 <b>▶ 播放</b>',
|
|
24
51
|
emptyHintOrSend: ' 或输入框蓝色发送键 <b>↑</b>',
|
|
25
52
|
emptyHintEnd: ',体验完整对话与上下文生长',
|
|
26
|
-
activeContext: '
|
|
27
|
-
snapInitial: '
|
|
28
|
-
snapInspect: '回看:第 {step} / {total} 步',
|
|
53
|
+
activeContext: '上下文快照',
|
|
54
|
+
snapInitial: '初始上下文',
|
|
29
55
|
snapCurrent: '第 {step} / {total} 步',
|
|
30
56
|
usedSuffix: '已用',
|
|
31
57
|
freeSpaceTitle: '剩余窗口 (Free Space)',
|
|
@@ -35,20 +61,20 @@ const DICTS = {
|
|
|
35
61
|
legendSys: '系统提示词',
|
|
36
62
|
legendSchema: '工具定义',
|
|
37
63
|
legendUser: '用户消息',
|
|
38
|
-
legendMem: '
|
|
64
|
+
legendMem: '记忆规则',
|
|
39
65
|
legendSkill: '技能注入',
|
|
40
66
|
legendMsg: '助手回复',
|
|
41
67
|
legendTool: '工具输出',
|
|
42
68
|
catSys: '系统提示词(System Prompt)',
|
|
43
69
|
catSchema: '工具定义(Tool Schemas & MCP)',
|
|
44
70
|
catUser: '用户消息(User Messages)',
|
|
45
|
-
catMem: '
|
|
71
|
+
catMem: '记忆规则(Memory & Rules)',
|
|
46
72
|
catSkill: '技能注入(Skills)',
|
|
47
|
-
catMsg: '助手回复(Assistant
|
|
73
|
+
catMsg: '助手回复(Assistant Replies)',
|
|
48
74
|
catTool: '工具输出(Tool Outputs)',
|
|
49
75
|
contextInspector: '上下文明细',
|
|
50
76
|
contextInspectorHint: '点击色块或消息定格展开',
|
|
51
|
-
emptyCategory: '
|
|
77
|
+
emptyCategory: '当前步骤暂无记录',
|
|
52
78
|
viewFullPayload: '查看完整内容 ↗',
|
|
53
79
|
omittedImages: '({prefix}{count} 张附图未收录)',
|
|
54
80
|
omittedImagesAlso: '另有 ',
|
|
@@ -62,15 +88,29 @@ const DICTS = {
|
|
|
62
88
|
compactModalTitle: '上下文压缩摘要',
|
|
63
89
|
asksYou: '{tool} 问你',
|
|
64
90
|
deliverablesTitle: '交回的成果',
|
|
65
|
-
|
|
91
|
+
inputFiles: '随消息附上的文件',
|
|
92
|
+
fileVerified: '已核对为会话当时的版本',
|
|
93
|
+
fileExportCopy: '已收录导出时的版本,无法确认是否与会话当时一致',
|
|
94
|
+
fileHashMismatch: '已收录导出时的版本,与会话记录的校验值不符',
|
|
95
|
+
fileMissing: '未找到原文件,无法回看',
|
|
96
|
+
fileOutsideRoot: '文件位于资产根目录之外,未收录',
|
|
97
|
+
fileUnreadable: '未能读取原文件,无法回看',
|
|
98
|
+
viewChanges: '查看改动', beforeRevision: '原稿', afterRevision: '校订稿', openSourcePage: '打开这一页',
|
|
99
|
+
readPdf: '阅读报告', readWorkbook: '查看完整表格', downloadFile: '下载 {type}',
|
|
100
|
+
pdfPages: '{n} 页', sheetCount: '{n} 张工作表', sheetName: '工作表', emptySheet: '空白工作表',
|
|
101
|
+
pageNumber: '页码', pdfPage: '第 {n} 页', prevPage: '上一页', nextPage: '下一页',
|
|
102
|
+
zoom: '缩放', fitWidth: '适合宽度', loadingSheet: '正在读取表格…', sheetLoadError: '读取失败,可重新打开预览或下载原文件。',
|
|
103
|
+
landscape: '横版',
|
|
104
|
+
portrait: '竖版',
|
|
105
|
+
subagentReportTitle: '子 Agent 报告 · {label}',
|
|
66
106
|
viewReport: '查看报告',
|
|
67
107
|
refFrameEyebrow: '📎 参考画面',
|
|
68
|
-
aiFrameEyebrow: '🖼
|
|
108
|
+
aiFrameEyebrow: '🖼 过程画面',
|
|
69
109
|
frameSub: '{time} 产出 · 点击放大查看',
|
|
70
110
|
docEyebrow: '📄 中间文稿产出 · {file}',
|
|
71
111
|
docSub: '{time} 写入 · 约 {kb}k 字 · 点击阅读草稿',
|
|
72
112
|
audioEyebrow: '🔊 过程配音试听({count} 段)',
|
|
73
|
-
lightboxDefaultTitle: '
|
|
113
|
+
lightboxDefaultTitle: '画面预览',
|
|
74
114
|
docModalDefaultTitle: '中间文稿预览',
|
|
75
115
|
closePreview: '关闭预览',
|
|
76
116
|
tlAria: '回放时间轴与控制',
|
|
@@ -79,10 +119,10 @@ const DICTS = {
|
|
|
79
119
|
tlStepMeta: '第 {step} 步 · {time}',
|
|
80
120
|
tlCompressPin: '压缩 #{seq}',
|
|
81
121
|
tlCompressTitle: '🗜 上下文压缩 #{seq}(-{dropped}k)',
|
|
82
|
-
tlPromptTitle: '💬
|
|
122
|
+
tlPromptTitle: '💬 第 {turn} 轮:{summary}',
|
|
83
123
|
tlStepFallback: '步骤详情',
|
|
84
124
|
defaultRefFrame: '参考画面 #{n}',
|
|
85
|
-
defaultAiFrame: '
|
|
125
|
+
defaultAiFrame: '过程画面 #{n}',
|
|
86
126
|
defaultAudioClip: '试听片段',
|
|
87
127
|
statSearch: '搜索 {n} 次',
|
|
88
128
|
statOpen: '打开 {n} 个网页',
|
|
@@ -93,13 +133,40 @@ const DICTS = {
|
|
|
93
133
|
statCode: '运行 {n} 段代码',
|
|
94
134
|
statEdit: '写 {n} 个文件',
|
|
95
135
|
statSkill: '加载 {n} 个技能',
|
|
96
|
-
statAgent: '派出 {n}
|
|
97
|
-
statReply: '收到 {n}
|
|
136
|
+
statAgent: '派出 {n} 个子 Agent',
|
|
137
|
+
statReply: '收到 {n} 份子 Agent 报告',
|
|
98
138
|
statOther: '其他操作 {n} 次',
|
|
99
139
|
statSep: ',',
|
|
100
140
|
execToolsFallback: '执行工具',
|
|
101
141
|
},
|
|
102
142
|
en: {
|
|
143
|
+
workspaceWrite: 'Workspace Write',
|
|
144
|
+
contextLabel: 'Context',
|
|
145
|
+
itemCount: '{n} records',
|
|
146
|
+
agentSent: 'Dispatched',
|
|
147
|
+
agentStopped: 'Stopped',
|
|
148
|
+
agentRateLimited: 'Rate limited',
|
|
149
|
+
agentFailed: 'Failed',
|
|
150
|
+
agentDone: 'Returned',
|
|
151
|
+
turnTag: 'Turn #{n}',
|
|
152
|
+
replyTag: 'Reply #{n}',
|
|
153
|
+
stepTag: 'Step {n}',
|
|
154
|
+
thinking: 'Thinking',
|
|
155
|
+
reasoning: 'Reasoning',
|
|
156
|
+
preview: 'Preview',
|
|
157
|
+
draft: 'Draft',
|
|
158
|
+
rule: 'Rule',
|
|
159
|
+
promptTitle: 'Prompt #{n}',
|
|
160
|
+
sessionStart: 'Session start',
|
|
161
|
+
userMessage: 'User message',
|
|
162
|
+
assistantReply: 'Assistant reply',
|
|
163
|
+
appendedPrompt: 'User message appended to context',
|
|
164
|
+
waitingForTools: 'Waiting for agent reasoning and tool calls',
|
|
165
|
+
synthesizing: 'Synthesizing ({tools})',
|
|
166
|
+
directResponse: 'Direct response',
|
|
167
|
+
completedResponse: 'Completed response',
|
|
168
|
+
toolCalls: 'Tool calls × {n}',
|
|
169
|
+
archivedTools: 'Archived {n} tool outputs (-{tokens}k tokens)',
|
|
103
170
|
langCode: 'en',
|
|
104
171
|
toggleLangLabel: '中文',
|
|
105
172
|
toggleLangTitle: '切换到中文',
|
|
@@ -120,9 +187,8 @@ const DICTS = {
|
|
|
120
187
|
emptyHintStart: 'Click <b>▶ Play</b> at the bottom-left',
|
|
121
188
|
emptyHintOrSend: ' or the blue <b>↑</b> send button',
|
|
122
189
|
emptyHintEnd: ' to replay the conversation and live context growth',
|
|
123
|
-
activeContext: '
|
|
124
|
-
snapInitial: '
|
|
125
|
-
snapInspect: 'Inspecting: Step {step} / {total}',
|
|
190
|
+
activeContext: 'Context Snapshot',
|
|
191
|
+
snapInitial: 'Initial Context',
|
|
126
192
|
snapCurrent: 'Step {step} / {total}',
|
|
127
193
|
usedSuffix: 'used',
|
|
128
194
|
freeSpaceTitle: 'Free Context Space',
|
|
@@ -131,7 +197,7 @@ const DICTS = {
|
|
|
131
197
|
outputReserveTitle: 'Max Output Reserve (8%)',
|
|
132
198
|
legendSys: 'System Prompt',
|
|
133
199
|
legendSchema: 'Tool Schemas',
|
|
134
|
-
legendUser: 'User
|
|
200
|
+
legendUser: 'User Messages',
|
|
135
201
|
legendMem: 'Memory & Rules',
|
|
136
202
|
legendSkill: 'Skills',
|
|
137
203
|
legendMsg: 'Assistant',
|
|
@@ -139,13 +205,13 @@ const DICTS = {
|
|
|
139
205
|
catSys: 'System Prompt',
|
|
140
206
|
catSchema: 'Tool Schemas & MCP',
|
|
141
207
|
catUser: 'User Messages',
|
|
142
|
-
catMem: 'Memory &
|
|
208
|
+
catMem: 'Memory & Rules',
|
|
143
209
|
catSkill: 'Skills',
|
|
144
|
-
catMsg: 'Assistant
|
|
210
|
+
catMsg: 'Assistant Replies',
|
|
145
211
|
catTool: 'Tool Outputs',
|
|
146
212
|
contextInspector: 'Context Inspector',
|
|
147
213
|
contextInspectorHint: 'Click a bar segment or message to inspect',
|
|
148
|
-
emptyCategory: 'No
|
|
214
|
+
emptyCategory: 'No records at this step',
|
|
149
215
|
viewFullPayload: 'View full payload ↗',
|
|
150
216
|
omittedImages: '({prefix}{count} attached image(s) omitted)',
|
|
151
217
|
omittedImagesAlso: 'plus ',
|
|
@@ -159,10 +225,24 @@ const DICTS = {
|
|
|
159
225
|
compactModalTitle: 'Compaction Summary',
|
|
160
226
|
asksYou: '{tool} asks',
|
|
161
227
|
deliverablesTitle: 'Deliverables',
|
|
228
|
+
inputFiles: 'Attachments',
|
|
229
|
+
fileVerified: 'Verified against the version in the session',
|
|
230
|
+
fileExportCopy: 'Captured at export. Its version at the time of the session could not be confirmed.',
|
|
231
|
+
fileHashMismatch: 'Captured at export. Its checksum differs from the one recorded in the session.',
|
|
232
|
+
fileMissing: 'Original file not found. No copy is available.',
|
|
233
|
+
fileOutsideRoot: 'Outside the asset roots. No copy was included.',
|
|
234
|
+
fileUnreadable: 'The original file could not be read. No copy is available.',
|
|
235
|
+
viewChanges: 'View changes', beforeRevision: 'Original', afterRevision: 'Revised', openSourcePage: 'Open this page',
|
|
236
|
+
readPdf: 'Read PDF', readWorkbook: 'View workbook', downloadFile: 'Download {type}',
|
|
237
|
+
pdfPages: '{n} pages', sheetCount: '{n} sheets', sheetName: 'Sheet', emptySheet: 'Empty worksheet',
|
|
238
|
+
pageNumber: 'Page', pdfPage: 'Page {n}', prevPage: 'Previous page', nextPage: 'Next page',
|
|
239
|
+
zoom: 'Zoom', fitWidth: 'Fit width', loadingSheet: 'Loading workbook…', sheetLoadError: 'Could not read workbook. Reopen the preview to retry or download the file.',
|
|
240
|
+
landscape: 'Landscape',
|
|
241
|
+
portrait: 'Portrait',
|
|
162
242
|
subagentReportTitle: 'Sub-agent Report · {label}',
|
|
163
243
|
viewReport: 'View Report',
|
|
164
|
-
refFrameEyebrow: '📎 Reference
|
|
165
|
-
aiFrameEyebrow: '🖼
|
|
244
|
+
refFrameEyebrow: '📎 Reference Frame',
|
|
245
|
+
aiFrameEyebrow: '🖼 Agent Frame',
|
|
166
246
|
frameSub: 'Produced at {time} · Click to enlarge',
|
|
167
247
|
docEyebrow: '📄 Draft Document · {file}',
|
|
168
248
|
docSub: 'Written at {time} · ~{kb}k chars · Click to read',
|
|
@@ -174,12 +254,12 @@ const DICTS = {
|
|
|
174
254
|
tlControlsAria: 'Playback controls',
|
|
175
255
|
tlJumpAria: 'Jump to step {step}: {label}',
|
|
176
256
|
tlStepMeta: 'Step {step} · {time}',
|
|
177
|
-
tlCompressPin: '
|
|
257
|
+
tlCompressPin: 'Compaction #{seq}',
|
|
178
258
|
tlCompressTitle: '🗜 Compaction #{seq} (-{dropped}k)',
|
|
179
|
-
tlPromptTitle: '💬
|
|
259
|
+
tlPromptTitle: '💬 Turn #{turn}: {summary}',
|
|
180
260
|
tlStepFallback: 'Step details',
|
|
181
|
-
defaultRefFrame: 'Reference #{n}',
|
|
182
|
-
defaultAiFrame: '
|
|
261
|
+
defaultRefFrame: 'Reference Frame #{n}',
|
|
262
|
+
defaultAiFrame: 'Agent Frame #{n}',
|
|
183
263
|
defaultAudioClip: 'Audio clip',
|
|
184
264
|
statSearch: 'searched {n}x',
|
|
185
265
|
statOpen: 'opened {n} page(s)',
|
|
@@ -286,6 +366,9 @@ function isTableSeparator(line) {
|
|
|
286
366
|
return cells.length > 0 && cells.every(c => /^:?-{2,}:?$/.test(c))
|
|
287
367
|
}
|
|
288
368
|
|
|
369
|
+
const openingFence = /^ {0,3}(`{3,})([^`]*)$/
|
|
370
|
+
const closingFence = /^ {0,3}(`{3,})[ \t]*$/
|
|
371
|
+
|
|
289
372
|
function renderMarkdown(source) {
|
|
290
373
|
const raw = String(source ?? '').replace(/\r\n/g, '\n').trim()
|
|
291
374
|
if (!raw) return ''
|
|
@@ -302,16 +385,17 @@ function renderMarkdown(source) {
|
|
|
302
385
|
continue
|
|
303
386
|
}
|
|
304
387
|
|
|
305
|
-
const fence = line.match(
|
|
388
|
+
const fence = line.match(openingFence)
|
|
306
389
|
if (fence) {
|
|
307
|
-
const lang = fence[1]
|
|
390
|
+
const lang = fence[2].trim().split(/\s+/, 1)[0]
|
|
308
391
|
const codeLines = []
|
|
309
392
|
i++
|
|
310
|
-
while (i < lines.length
|
|
311
|
-
|
|
312
|
-
|
|
393
|
+
while (i < lines.length) {
|
|
394
|
+
const codeLine = lines[i++]
|
|
395
|
+
const close = codeLine.match(closingFence)
|
|
396
|
+
if (close && close[1].length >= fence[1].length) break
|
|
397
|
+
codeLines.push(codeLine)
|
|
313
398
|
}
|
|
314
|
-
if (i < lines.length) i++
|
|
315
399
|
const cls = lang ? ` class="language-${escapeHtml(lang)}"` : ''
|
|
316
400
|
out.push(`<pre><code${cls}>${escapeHtml(codeLines.join('\n'))}</code></pre>`)
|
|
317
401
|
continue
|
|
@@ -377,11 +461,12 @@ function renderMarkdown(source) {
|
|
|
377
461
|
continue
|
|
378
462
|
}
|
|
379
463
|
|
|
380
|
-
const paraLines = []
|
|
464
|
+
const paraLines = [renderInline(line)]
|
|
465
|
+
i++
|
|
381
466
|
while (
|
|
382
467
|
i < lines.length &&
|
|
383
468
|
lines[i].trim() !== '' &&
|
|
384
|
-
|
|
469
|
+
!openingFence.test(lines[i]) &&
|
|
385
470
|
!/^(#{1,6})\s+/.test(lines[i]) &&
|
|
386
471
|
!/^(?:-{3,}|\*{3,}|_{3,})\s*$/.test(lines[i].trim()) &&
|
|
387
472
|
!/^\s*>\s?/.test(lines[i]) &&
|
|
@@ -392,9 +477,7 @@ function renderMarkdown(source) {
|
|
|
392
477
|
paraLines.push(renderInline(lines[i]))
|
|
393
478
|
i++
|
|
394
479
|
}
|
|
395
|
-
|
|
396
|
-
out.push(`<p>${paraLines.join('<br>')}</p>`)
|
|
397
|
-
}
|
|
480
|
+
out.push(`<p>${paraLines.join('<br>')}</p>`)
|
|
398
481
|
}
|
|
399
482
|
|
|
400
483
|
return out.join('\n')
|
|
@@ -563,7 +646,7 @@ function extractStepDocs(toolItems, stepIndex) {
|
|
|
563
646
|
return [...byPath.values()]
|
|
564
647
|
}
|
|
565
648
|
|
|
566
|
-
function extractStepSubagents(toolItems, stepIndex) {
|
|
649
|
+
function extractStepSubagents(toolItems, stepIndex, t) {
|
|
567
650
|
const list = []
|
|
568
651
|
toolItems.forEach((item, idx) => {
|
|
569
652
|
const rawSum = String(item.summary || '')
|
|
@@ -589,17 +672,17 @@ function extractStepSubagents(toolItems, stepIndex) {
|
|
|
589
672
|
const combined = `${rawSum}\n${item.output || ''}`
|
|
590
673
|
const isAsyncSpawn = /^(?:spawn_agent|collaboration__spawn_agent|followup_task|collaboration__followup_task)$/.test(item.name || '')
|
|
591
674
|
let state = 'sent'
|
|
592
|
-
let badge = '
|
|
675
|
+
let badge = t('agentSent')
|
|
593
676
|
let report = ''
|
|
594
677
|
if (/was stopped|中途打断|已取消/i.test(combined)) {
|
|
595
678
|
state = 'stopped'
|
|
596
|
-
badge = '
|
|
679
|
+
badge = t('agentStopped')
|
|
597
680
|
} else if (/failed:|terminated early|rate_limit|hit your session limit|^Error:\s*Failed/im.test(combined)) {
|
|
598
681
|
state = 'failed'
|
|
599
|
-
badge = /limit|429/i.test(combined) ? '
|
|
682
|
+
badge = /limit|429/i.test(combined) ? t('agentRateLimited') : t('agentFailed')
|
|
600
683
|
} else if (item.kind === 'reply' || item.stats?.reply || (!isAsyncSpawn && item.output && item.output.length > 80 && !item.output.trim().startsWith('{'))) {
|
|
601
684
|
state = 'done'
|
|
602
|
-
badge = '
|
|
685
|
+
badge = t('agentDone')
|
|
603
686
|
if (item.output && item.output.length > 40 && !item.output.trim().startsWith('{')) {
|
|
604
687
|
report = String(item.output).trim()
|
|
605
688
|
}
|
|
@@ -863,7 +946,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
863
946
|
}
|
|
864
947
|
for (const item of items) {
|
|
865
948
|
if (item.type === 'tool' || item.type === 'reasoning') {
|
|
949
|
+
if (item.deliverables?.length) flushWork()
|
|
866
950
|
work.push(item)
|
|
951
|
+
if (item.deliverables?.length) flushWork()
|
|
867
952
|
continue
|
|
868
953
|
}
|
|
869
954
|
flushWork()
|
|
@@ -886,16 +971,23 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
886
971
|
return entry
|
|
887
972
|
}
|
|
888
973
|
|
|
889
|
-
|
|
890
|
-
const
|
|
974
|
+
// Antigravity transcripts contain observed steps, with no initial prompt or tool inventory.
|
|
975
|
+
const observedOnly = sessionTool.startsWith('antigravity')
|
|
976
|
+
function initialRecords(key, defaults) {
|
|
977
|
+
const records = initCtx[key] || []
|
|
978
|
+
const entries = records.length || observedOnly ? records : defaults(sessionTool, sessionStart)
|
|
979
|
+
return entries.map(record => registerRecord({ ...record, stepIndex: -1 }))
|
|
980
|
+
}
|
|
981
|
+
const sysRecords = initialRecords('sys', defaultSystemPrompts)
|
|
982
|
+
const schemaRecords = initialRecords('schema', defaultToolSchemas)
|
|
891
983
|
const schemaIdSet = new Set(schemaRecords.map(r => r.id))
|
|
892
984
|
for (const r of schemaRecords) if (r.title) schemaIdSet.add(`schema-dyn-${String(r.title).replace(/[^a-zA-Z0-9_-]/g, '_')}`)
|
|
893
985
|
const userRecords = []
|
|
894
986
|
let toolRecords = []
|
|
895
|
-
const skillRecords = (
|
|
987
|
+
const skillRecords = initialRecords('skill', defaultSkillCatalog)
|
|
896
988
|
const knownSkillNames = new Set(skillRecords.map(r => r.title).filter(Boolean))
|
|
897
989
|
const msgRecords = []
|
|
898
|
-
const memRecords = (
|
|
990
|
+
const memRecords = initialRecords('mem', defaultInjectedContext)
|
|
899
991
|
|
|
900
992
|
const sumTokEst = list => list.reduce((acc, r) => acc + (r.tokEst || 600), 0)
|
|
901
993
|
const sysTokens = sumTokEst(sysRecords)
|
|
@@ -910,7 +1002,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
910
1002
|
let uncalibratedDelta = 0
|
|
911
1003
|
const allTools = []
|
|
912
1004
|
const allSkills = []
|
|
913
|
-
const allMemories = ['AGENTS.md']
|
|
1005
|
+
const allMemories = observedOnly ? [] : ['AGENTS.md']
|
|
914
1006
|
const allChanges = []
|
|
915
1007
|
let latestUserPrompt = ''
|
|
916
1008
|
let toolSeq = 0
|
|
@@ -973,7 +1065,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
973
1065
|
name,
|
|
974
1066
|
color,
|
|
975
1067
|
itemCount: records.length,
|
|
976
|
-
count:
|
|
1068
|
+
count: t('itemCount', { n: records.length }),
|
|
977
1069
|
tok: `≈${(curTok / 1000).toFixed(1)}k`,
|
|
978
1070
|
pct: `${kindPct(curTok)}%`,
|
|
979
1071
|
delta: stepIdx >= 0 ? fmtCountDelta(records.length, prevCount) : '',
|
|
@@ -1083,8 +1175,8 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1083
1175
|
id: `user-${userSeq}`,
|
|
1084
1176
|
stepIndex: index,
|
|
1085
1177
|
tokEst: userTok,
|
|
1086
|
-
tag:
|
|
1087
|
-
title: cleanPromptText.slice(0, 56) || '
|
|
1178
|
+
tag: t('turnTag', { n: turnCount }),
|
|
1179
|
+
title: cleanPromptText.slice(0, 56) || t('userMessage'),
|
|
1088
1180
|
meta: `≈${(userTok / 1000).toFixed(1)}k · ${stepTime}s`,
|
|
1089
1181
|
payload: String(first.text || ''),
|
|
1090
1182
|
...(first.images?.length ? { images: first.images } : {}),
|
|
@@ -1101,7 +1193,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1101
1193
|
tokEst: skTok,
|
|
1102
1194
|
tag: 'SKILL.md',
|
|
1103
1195
|
title: `${skill}/SKILL.md`,
|
|
1104
|
-
meta: `≈${(skTok / 1000).toFixed(1)}k ·
|
|
1196
|
+
meta: `≈${(skTok / 1000).toFixed(1)}k · ${t('turnTag', { n: turnCount })}`,
|
|
1105
1197
|
payload: `# ${skill} (SKILL.md)\nLoaded into active context.`,
|
|
1106
1198
|
}))
|
|
1107
1199
|
}
|
|
@@ -1110,10 +1202,10 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1110
1202
|
primaryCat = 'user'
|
|
1111
1203
|
speedLabel = '1.0×'
|
|
1112
1204
|
dwellMs = 1500
|
|
1113
|
-
detailTitle =
|
|
1205
|
+
detailTitle = t('promptTitle', { n: turnCount })
|
|
1114
1206
|
detailSnippet = (first.text || '').slice(0, 260)
|
|
1115
|
-
inBrief = '
|
|
1116
|
-
responseBrief = '
|
|
1207
|
+
inBrief = t('appendedPrompt')
|
|
1208
|
+
responseBrief = t('waitingForTools')
|
|
1117
1209
|
} else if (group.groupType === 'compact') {
|
|
1118
1210
|
compactSeq++
|
|
1119
1211
|
const cItem = first
|
|
@@ -1166,10 +1258,10 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1166
1258
|
speedLabel = '0.8×'
|
|
1167
1259
|
dwellMs = 2100
|
|
1168
1260
|
spotlight = 'context-compact'
|
|
1169
|
-
detailTitle =
|
|
1261
|
+
detailTitle = t('compactTitle', { seq: compactInfo.seq })
|
|
1170
1262
|
detailSnippet = summaryText.slice(0, 260)
|
|
1171
1263
|
inBrief = `${(preTokens / 1000).toFixed(1)}k → ${(postTokens / 1000).toFixed(1)}k`
|
|
1172
|
-
responseBrief =
|
|
1264
|
+
responseBrief = t('archivedTools', { n: archivedTools, tokens: (droppedTokens / 1000).toFixed(1) })
|
|
1173
1265
|
} else if (group.groupType === 'assistant') {
|
|
1174
1266
|
msgSeq++
|
|
1175
1267
|
const cleanReply = (first.text || '').replace(/\s+/g, ' ').trim()
|
|
@@ -1180,8 +1272,8 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1180
1272
|
id: `msg-${msgSeq}`,
|
|
1181
1273
|
stepIndex: index,
|
|
1182
1274
|
tokEst: msgTok,
|
|
1183
|
-
tag:
|
|
1184
|
-
title: cleanReply.slice(0, 56) || '
|
|
1275
|
+
tag: t('replyTag', { n: msgSeq }),
|
|
1276
|
+
title: cleanReply.slice(0, 56) || t('assistantReply'),
|
|
1185
1277
|
meta: `≈${(msgTok / 1000).toFixed(1)}k · ${stepTime}s`,
|
|
1186
1278
|
payload: String(first.text || ''),
|
|
1187
1279
|
}))
|
|
@@ -1195,17 +1287,17 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1195
1287
|
primaryCat = 'msg'
|
|
1196
1288
|
speedLabel = '1.0×'
|
|
1197
1289
|
dwellMs = 1750
|
|
1198
|
-
detailTitle = '
|
|
1290
|
+
detailTitle = t('assistantReply')
|
|
1199
1291
|
detailSnippet = (first.text || '').slice(0, 260)
|
|
1200
|
-
inBrief = allTools.length ?
|
|
1201
|
-
responseBrief = cleanReply.slice(0, 96) || '
|
|
1292
|
+
inBrief = allTools.length ? t('synthesizing', { tools: allTools.slice(-2).join(', ') }) : t('directResponse')
|
|
1293
|
+
responseBrief = cleanReply.slice(0, 96) || t('completedResponse')
|
|
1202
1294
|
} else {
|
|
1203
1295
|
const toolItems = group.items.filter(item => item.type === 'tool')
|
|
1204
1296
|
const reasoningItems = group.items.filter(item => item.type === 'reasoning')
|
|
1205
1297
|
const stats = sumStats(toolItems)
|
|
1206
1298
|
const extracted = extractFileChips(toolItems)
|
|
1207
1299
|
stepDocs = extractStepDocs(toolItems, index)
|
|
1208
|
-
stepSubagents = extractStepSubagents(toolItems, index)
|
|
1300
|
+
stepSubagents = extractStepSubagents(toolItems, index, t)
|
|
1209
1301
|
stepAudios = extractStepAudios(toolItems, t)
|
|
1210
1302
|
allTools.push(...extracted.tools)
|
|
1211
1303
|
allChanges.push(...extracted.changes)
|
|
@@ -1220,9 +1312,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1220
1312
|
id: `mem-dyn-${memRecords.length + 1}`,
|
|
1221
1313
|
stepIndex: index,
|
|
1222
1314
|
tokEst: memTok,
|
|
1223
|
-
tag: '
|
|
1315
|
+
tag: t('rule'),
|
|
1224
1316
|
title: `${memName}`,
|
|
1225
|
-
meta: `≈${(memTok / 1000).toFixed(1)}k ·
|
|
1317
|
+
meta: `≈${(memTok / 1000).toFixed(1)}k · ${t('stepTag', { n: index + 1 })}`,
|
|
1226
1318
|
payload: `# ${memName}\nLoaded into context during step ${index + 1}.`,
|
|
1227
1319
|
}))
|
|
1228
1320
|
}
|
|
@@ -1238,9 +1330,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1238
1330
|
id: `think-${msgSeq}`,
|
|
1239
1331
|
stepIndex: index,
|
|
1240
1332
|
tokEst: rTok,
|
|
1241
|
-
tag: '
|
|
1333
|
+
tag: t('thinking'),
|
|
1242
1334
|
title: rItem.text.replace(/\s+/g, ' ').trim().slice(0, 54),
|
|
1243
|
-
meta: `≈${(rTok / 1000).toFixed(1)}k ·
|
|
1335
|
+
meta: `≈${(rTok / 1000).toFixed(1)}k · ${t('reasoning')}`,
|
|
1244
1336
|
payload: String(rItem.text),
|
|
1245
1337
|
}))
|
|
1246
1338
|
}
|
|
@@ -1266,7 +1358,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1266
1358
|
tokEst: skTok,
|
|
1267
1359
|
tag: 'SKILL.md',
|
|
1268
1360
|
title: `${skill}/SKILL.md`,
|
|
1269
|
-
meta: `≈${(skTok / 1000).toFixed(1)}k ·
|
|
1361
|
+
meta: `≈${(skTok / 1000).toFixed(1)}k · ${t('stepTag', { n: index + 1 })}`,
|
|
1270
1362
|
payload: String(item.output || item.input || `# ${skill} (SKILL.md)`),
|
|
1271
1363
|
}))
|
|
1272
1364
|
}
|
|
@@ -1306,7 +1398,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1306
1398
|
toolRecords.push(registerRecord({
|
|
1307
1399
|
id: `frame-${++toolSeq}`,
|
|
1308
1400
|
stepIndex: index,
|
|
1309
|
-
tag: '
|
|
1401
|
+
tag: t('preview'),
|
|
1310
1402
|
title: `${fr.label}`,
|
|
1311
1403
|
meta: '≈1.2k tok',
|
|
1312
1404
|
payload: `Preview frame: ${fr.label}`,
|
|
@@ -1314,7 +1406,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1314
1406
|
}))
|
|
1315
1407
|
}
|
|
1316
1408
|
rawMontage.push({
|
|
1317
|
-
tag: '
|
|
1409
|
+
tag: t('preview'),
|
|
1318
1410
|
title: `${fr.label}`,
|
|
1319
1411
|
isSpot: true,
|
|
1320
1412
|
speed: '🖼',
|
|
@@ -1322,7 +1414,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1322
1414
|
}
|
|
1323
1415
|
for (const doc of stepDocs) {
|
|
1324
1416
|
rawMontage.push({
|
|
1325
|
-
tag: '
|
|
1417
|
+
tag: t('draft'),
|
|
1326
1418
|
title: `${doc.title}`,
|
|
1327
1419
|
isSpot: true,
|
|
1328
1420
|
speed: '📄',
|
|
@@ -1369,7 +1461,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1369
1461
|
dwellMs = 1100
|
|
1370
1462
|
}
|
|
1371
1463
|
if (toolItems.length) {
|
|
1372
|
-
detailTitle =
|
|
1464
|
+
detailTitle = t('toolCalls', { n: toolItems.length })
|
|
1373
1465
|
detailSnippet = toolItems.slice(0, 3).map(item => item.summary).join('\n')
|
|
1374
1466
|
const primaryTool = toolItems[0]?.name || 'tool'
|
|
1375
1467
|
inBrief = `${primaryTool} · ${toolItems.slice(0, 2).map(i => i.summary).join(';')}`
|
|
@@ -1460,7 +1552,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1460
1552
|
snippet: detailSnippet,
|
|
1461
1553
|
},
|
|
1462
1554
|
brief: {
|
|
1463
|
-
user: latestUserPrompt || '
|
|
1555
|
+
user: latestUserPrompt || t('sessionStart'),
|
|
1464
1556
|
in: inBrief,
|
|
1465
1557
|
response: responseBrief,
|
|
1466
1558
|
},
|
|
@@ -1567,14 +1659,187 @@ function describeStats(stats, keys = statKeyMap.map(([key]) => key), lang = 'zh'
|
|
|
1567
1659
|
.join(t('statSep'))
|
|
1568
1660
|
}
|
|
1569
1661
|
|
|
1662
|
+
// --- attachment-reader.mjs ---
|
|
1663
|
+
function attachmentTable(rows, { compact = false } = {}) {
|
|
1664
|
+
if (!rows.length) return ''
|
|
1665
|
+
const head = rows[0].map(cell => `<th scope="col">${escapeHtml(cell)}</th>`).join('')
|
|
1666
|
+
const body = rows.slice(1).map(row => {
|
|
1667
|
+
const cells = row.map(value => {
|
|
1668
|
+
const text = String(value ?? '')
|
|
1669
|
+
const content = !compact && text.length > 70
|
|
1670
|
+
? `<details><summary>${escapeHtml(text.slice(0, 52))}…</summary>${escapeHtml(text)}</details>`
|
|
1671
|
+
: escapeHtml(text)
|
|
1672
|
+
return `<td>${content}</td>`
|
|
1673
|
+
})
|
|
1674
|
+
return `<tr>${cells.join('')}</tr>`
|
|
1675
|
+
})
|
|
1676
|
+
return `<table><thead><tr>${head}</tr></thead><tbody>${body.join('')}</tbody></table>`
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
function renderRevision(file, t, url) {
|
|
1680
|
+
const change = file.preview.change
|
|
1681
|
+
if (!change || !file.revision) return ''
|
|
1682
|
+
const revision = file.revision
|
|
1683
|
+
const pdf = file.preview.type === 'pdf'
|
|
1684
|
+
const location = pdf ? t('pdfPage', { n: revision.page }) : `${revision.sheet} · ${revision.cell}`
|
|
1685
|
+
const before = Array.from(change.before), after = Array.from(change.after)
|
|
1686
|
+
const shorter = Math.min(before.length, after.length)
|
|
1687
|
+
let start = 0, end = 0
|
|
1688
|
+
while (start < shorter && before[start] === after[start]) start++
|
|
1689
|
+
while (end < shorter - start && before.at(-1 - end) === after.at(-1 - end)) end++
|
|
1690
|
+
function side(chars, original) {
|
|
1691
|
+
const stop = chars.length - end
|
|
1692
|
+
const tag = original ? 'del' : 'ins'
|
|
1693
|
+
const text = escapeHtml(chars.slice(0, start).join(''))
|
|
1694
|
+
+ `<${tag}>${escapeHtml(chars.slice(start, stop).join(''))}</${tag}>`
|
|
1695
|
+
+ escapeHtml(chars.slice(stop).join(''))
|
|
1696
|
+
const src = url(original ? revision.href : file.href)
|
|
1697
|
+
const link = pdf
|
|
1698
|
+
? `<a href="${escapeHtml(src)}#page=${Number(revision.page)}" target="_blank" rel="noopener noreferrer">${t('openSourcePage')}</a>`
|
|
1699
|
+
: `<a href="${escapeHtml(src)}" download>${t('downloadFile', { type: 'Excel' })}</a>`
|
|
1700
|
+
return `<section><strong>${t(original ? 'beforeRevision' : 'afterRevision')}</strong><p>${text}</p>${link}</section>`
|
|
1701
|
+
}
|
|
1702
|
+
return `<details class="session-revision"><summary>${t('viewChanges')}</summary>
|
|
1703
|
+
<div class="session-revision-context"><b>${escapeHtml(revision.label)}</b><span>${escapeHtml(location)}</span></div>
|
|
1704
|
+
<div class="session-revision-pair">${side(before, true)}${side(after, false)}</div></details>`
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
function renderAttachment(file, t, url) {
|
|
1708
|
+
const preview = file.preview
|
|
1709
|
+
const pdf = preview.type === 'pdf'
|
|
1710
|
+
const type = pdf ? 'PDF' : 'Excel'
|
|
1711
|
+
const action = t(pdf ? 'readPdf' : 'readWorkbook')
|
|
1712
|
+
const count = pdf ? t('pdfPages', { n: preview.pages.length }) : t('sheetCount', { n: preview.count })
|
|
1713
|
+
const download = `<a href="${escapeHtml(url(file.href))}" download${file.availability ? `="${escapeHtml(file.title)}"` : ''}>${t('downloadFile', { type })}</a>`
|
|
1714
|
+
const title = escapeHtml(file.title)
|
|
1715
|
+
const toolbar = pdf
|
|
1716
|
+
? `<button type="button" data-page-prev aria-label="${t('prevPage')}">‹</button>
|
|
1717
|
+
<label>${t('pageNumber')} <input data-page-number type="number" min="1" max="${preview.pages.length}" value="1"> / ${preview.pages.length}</label>
|
|
1718
|
+
<button type="button" data-page-next aria-label="${t('nextPage')}">›</button>
|
|
1719
|
+
<select data-page-zoom aria-label="${t('zoom')}"><option value="100">${t('fitWidth')}</option><option value="125">125%</option><option value="150">150%</option></select>`
|
|
1720
|
+
: `<label>${t('sheetName')} <select data-sheet-picker></select></label>`
|
|
1721
|
+
const content = pdf
|
|
1722
|
+
? `<template>${preview.pages.map((page, i) => `<img loading="lazy" src="${escapeHtml(url(page.src))}" width="${Number(page.width)}" height="${Number(page.height)}" alt="${escapeHtml(t('pdfPage', { n: i + 1 }))}">`).join('')}</template>`
|
|
1723
|
+
: ''
|
|
1724
|
+
const source = pdf ? '' : ` data-workbook-src="${escapeHtml(url(preview.src))}" data-first-sheet="${escapeHtml(preview.sheet)}"`
|
|
1725
|
+
const summary = pdf
|
|
1726
|
+
? `<img class="session-pdf-cover" src="${escapeHtml(url(file.cover || preview.pages[0].src))}" alt="" loading="lazy">`
|
|
1727
|
+
: ''
|
|
1728
|
+
return `<section class="session-attachment" data-attachment="${preview.type}"${source}>
|
|
1729
|
+
<div class="session-attachment-head">${summary}<div><strong>${title}</strong>
|
|
1730
|
+
<small>${type} · ${count}${file.meta ? ' · ' + escapeHtml(file.meta) : ''}</small></div></div>
|
|
1731
|
+
${pdf ? '' : `<div class="session-sheet-sample">${attachmentTable(preview.rows, { compact: true })}</div>`}
|
|
1732
|
+
<div class="session-attachment-actions"><button type="button" data-open-attachment>${action}</button>${download}</div>
|
|
1733
|
+
${renderRevision(file, t, url)}
|
|
1734
|
+
<dialog class="session-attachment-dialog" aria-label="${title}">
|
|
1735
|
+
<header><strong>${title}</strong>${download}<button type="button" data-close-attachment aria-label="${t('closePreview')}">✕</button></header>
|
|
1736
|
+
<div class="session-attachment-toolbar">${toolbar}</div>
|
|
1737
|
+
<div class="session-attachment-viewport" role="region" aria-label="${title}" tabindex="0"></div>
|
|
1738
|
+
</dialog>${content}
|
|
1739
|
+
</section>`
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
function attachPdfReader(card, viewport) {
|
|
1743
|
+
viewport.append(card.querySelector('template').content.cloneNode(true))
|
|
1744
|
+
const pages = [...viewport.querySelectorAll('img')]
|
|
1745
|
+
const number = card.querySelector('[data-page-number]')
|
|
1746
|
+
const previous = card.querySelector('[data-page-prev]')
|
|
1747
|
+
const next = card.querySelector('[data-page-next]')
|
|
1748
|
+
function setPage(n) {
|
|
1749
|
+
number.value = n
|
|
1750
|
+
previous.disabled = n === 1
|
|
1751
|
+
next.disabled = n === pages.length
|
|
1752
|
+
}
|
|
1753
|
+
function jump(n) {
|
|
1754
|
+
n = Math.max(1, Math.min(pages.length, Math.round(n) || 1))
|
|
1755
|
+
pages[n - 1].scrollIntoView({ block: 'start', inline: 'nearest' })
|
|
1756
|
+
setPage(n)
|
|
1757
|
+
}
|
|
1758
|
+
number.addEventListener('change', () => jump(number.valueAsNumber))
|
|
1759
|
+
number.addEventListener('keydown', event => {
|
|
1760
|
+
if (event.key === 'Enter') jump(number.valueAsNumber)
|
|
1761
|
+
})
|
|
1762
|
+
previous.addEventListener('click', () => jump(number.valueAsNumber - 1))
|
|
1763
|
+
next.addEventListener('click', () => jump(number.valueAsNumber + 1))
|
|
1764
|
+
card.querySelector('[data-page-zoom]').addEventListener('change', event => {
|
|
1765
|
+
viewport.style.setProperty('--attachment-page-width', event.target.value + '%')
|
|
1766
|
+
jump(number.valueAsNumber)
|
|
1767
|
+
})
|
|
1768
|
+
viewport.addEventListener('scroll', () => {
|
|
1769
|
+
if (document.activeElement === number) return
|
|
1770
|
+
const top = viewport.getBoundingClientRect().top + 32
|
|
1771
|
+
const i = pages.findIndex(page => page.getBoundingClientRect().bottom > top)
|
|
1772
|
+
setPage(i < 0 ? pages.length : i + 1)
|
|
1773
|
+
}, { passive: true })
|
|
1774
|
+
setPage(1)
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
async function attachWorkbookReader(card, viewport, t) {
|
|
1778
|
+
const response = await fetch(card.dataset.workbookSrc)
|
|
1779
|
+
if (!response.ok) throw new Error('HTTP ' + response.status)
|
|
1780
|
+
const sheets = await response.json()
|
|
1781
|
+
const picker = card.querySelector('[data-sheet-picker]')
|
|
1782
|
+
for (const sheet of sheets) picker.add(new Option(sheet.sheet, sheet.sheet))
|
|
1783
|
+
picker.value = card.dataset.firstSheet
|
|
1784
|
+
function selectSheet() {
|
|
1785
|
+
viewport.innerHTML = attachmentTable(sheets[picker.selectedIndex].data) || escapeHtml(t('emptySheet'))
|
|
1786
|
+
viewport.scrollTo(0, 0)
|
|
1787
|
+
}
|
|
1788
|
+
picker.addEventListener('change', selectSheet)
|
|
1789
|
+
selectSheet()
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
function attachAttachmentReaders(container, t, pauseReplay) {
|
|
1793
|
+
for (const card of container.querySelectorAll('[data-attachment]')) {
|
|
1794
|
+
const revision = card.querySelector('.session-revision')
|
|
1795
|
+
revision?.addEventListener('toggle', () => {
|
|
1796
|
+
if (revision.open) {
|
|
1797
|
+
pauseReplay()
|
|
1798
|
+
revision.scrollIntoView({ block: 'nearest' })
|
|
1799
|
+
}
|
|
1800
|
+
})
|
|
1801
|
+
const dialog = card.querySelector('dialog')
|
|
1802
|
+
const viewport = card.querySelector('.session-attachment-viewport')
|
|
1803
|
+
let initialized = false
|
|
1804
|
+
card.querySelector('[data-open-attachment]').addEventListener('click', async () => {
|
|
1805
|
+
pauseReplay()
|
|
1806
|
+
dialog.showModal()
|
|
1807
|
+
if (initialized) return
|
|
1808
|
+
initialized = true
|
|
1809
|
+
if (card.dataset.attachment === 'pdf') {
|
|
1810
|
+
attachPdfReader(card, viewport)
|
|
1811
|
+
} else {
|
|
1812
|
+
viewport.textContent = t('loadingSheet')
|
|
1813
|
+
try {
|
|
1814
|
+
await attachWorkbookReader(card, viewport, t)
|
|
1815
|
+
} catch {
|
|
1816
|
+
viewport.textContent = t('sheetLoadError')
|
|
1817
|
+
initialized = false
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
})
|
|
1821
|
+
card.querySelector('[data-close-attachment]').addEventListener('click', () => dialog.close())
|
|
1822
|
+
dialog.addEventListener('click', event => {
|
|
1823
|
+
if (event.target === dialog) {
|
|
1824
|
+
const box = dialog.getBoundingClientRect()
|
|
1825
|
+
if (event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom) dialog.close()
|
|
1826
|
+
}
|
|
1827
|
+
})
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1570
1831
|
// --- render.mjs ---
|
|
1571
1832
|
const escape = escapeHtml
|
|
1572
1833
|
|
|
1573
1834
|
|
|
1574
1835
|
|
|
1836
|
+
|
|
1575
1837
|
const toolLabels = {
|
|
1576
1838
|
codex: 'Codex',
|
|
1577
1839
|
workbuddy: 'WorkBuddy',
|
|
1840
|
+
antigravity: 'Antigravity',
|
|
1841
|
+
'antigravity-app': 'Antigravity App',
|
|
1842
|
+
'antigravity-cli': 'Antigravity CLI',
|
|
1578
1843
|
'claude-code': 'Claude Code',
|
|
1579
1844
|
'claude-ai': 'Claude',
|
|
1580
1845
|
}
|
|
@@ -1653,7 +1918,7 @@ function thumbs(names, baseUrl = '') {
|
|
|
1653
1918
|
if (!names?.length) return ''
|
|
1654
1919
|
return `<span class="session-thumbs">${names.map(name => {
|
|
1655
1920
|
const url = escape(resolveAsset(name, baseUrl))
|
|
1656
|
-
return `<a href="${url}" target="_blank" rel="noopener noreferrer"><img src="${url}" alt="" width="96" loading="lazy"></a>`
|
|
1921
|
+
return `<a href="${url}" data-lightbox-src="${url}" target="_blank" rel="noopener noreferrer"><img src="${url}" alt="" width="96" loading="lazy"></a>`
|
|
1657
1922
|
}).join('')}</span>`
|
|
1658
1923
|
}
|
|
1659
1924
|
|
|
@@ -1727,73 +1992,33 @@ function renderStepArtifacts(stepMeta, { skipImages = [], renderMd, t, baseUrl =
|
|
|
1727
1992
|
function renderTimelineBar(line, t) {
|
|
1728
1993
|
const steps = line.steps || []
|
|
1729
1994
|
const total = steps.length
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
} else if (
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
if (
|
|
1756
|
-
pin.showText = true
|
|
1757
|
-
occupiedPcts.push(pin.pct)
|
|
1758
|
-
}
|
|
1995
|
+
const pins = []
|
|
1996
|
+
const cells = ['<span class="session-tl-cell"></span>']
|
|
1997
|
+
for (const [idx, step] of steps.entries()) {
|
|
1998
|
+
const frame = step.frames?.find(frame => frame.who === 'ai') || step.frames?.[0]
|
|
1999
|
+
const doc = step.docs?.[0]
|
|
2000
|
+
let kind = ''
|
|
2001
|
+
let label = ''
|
|
2002
|
+
let icon = ''
|
|
2003
|
+
if (step.compactInfo) {
|
|
2004
|
+
kind = 'compress'
|
|
2005
|
+
label = t('tlCompressPin', { seq: step.compactInfo.seq })
|
|
2006
|
+
icon = '🗜'
|
|
2007
|
+
} else if (frame) {
|
|
2008
|
+
kind = 'frame'
|
|
2009
|
+
label = frame.label
|
|
2010
|
+
icon = '🖼'
|
|
2011
|
+
} else if (doc) {
|
|
2012
|
+
kind = 'doc'
|
|
2013
|
+
label = doc.title
|
|
2014
|
+
icon = '📄'
|
|
2015
|
+
} else if (step.kind === 'prompt') {
|
|
2016
|
+
kind = 'turn'
|
|
2017
|
+
label = t('tlPromptTitle', { turn: step.turn, summary: short(step.summary || '', 40) })
|
|
2018
|
+
}
|
|
2019
|
+
cells.push(`<span class="session-tl-cell ${kind}"></span>`)
|
|
2020
|
+
if (label) pins.push(`<button type="button" class="session-tl-pin" data-kind="${kind}" data-tl-jump="${idx}" aria-label="${escape(t('tlJumpAria', { step: idx + 1, label }))}"><span aria-hidden="true">${icon}</span><span class="session-tl-caption">${escape(label)}</span></button>`)
|
|
1759
2021
|
}
|
|
1760
|
-
for (const pin of rawPins) {
|
|
1761
|
-
if (pin.pinType === 'frame' && canShowText(pin.pct)) {
|
|
1762
|
-
pin.showText = true
|
|
1763
|
-
occupiedPcts.push(pin.pct)
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
for (const pin of rawPins) {
|
|
1767
|
-
if (pin.pinType === 'doc' && canShowText(pin.pct)) {
|
|
1768
|
-
pin.showText = true
|
|
1769
|
-
occupiedPcts.push(pin.pct)
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
if (rawPins.length <= 14) {
|
|
1773
|
-
for (const pin of rawPins) {
|
|
1774
|
-
if (pin.pinType === 'turn' && canShowText(pin.pct)) {
|
|
1775
|
-
pin.showText = true
|
|
1776
|
-
occupiedPcts.push(pin.pct)
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
const pinsHtml = rawPins.map(pin => {
|
|
1782
|
-
const text = pin.pinType === 'compress'
|
|
1783
|
-
? (pin.showText ? `🗜 ${escape(short(pin.label, 11))}` : '🗜')
|
|
1784
|
-
: pin.pinType === 'frame'
|
|
1785
|
-
? (pin.showText ? `🖼 ${escape(short(pin.label, 8))}` : '🖼')
|
|
1786
|
-
: pin.pinType === 'doc'
|
|
1787
|
-
? (pin.showText ? `📄 ${escape(short(pin.label, 8))}` : '📄')
|
|
1788
|
-
: (pin.showText ? `💬 #${pin.turn}` : '')
|
|
1789
|
-
const cls = `session-tl-pin is-${pin.pinType}${pin.showText ? ' has-label' : ' is-compact'}`
|
|
1790
|
-
return `<button type="button" class="${cls}" style="left:${pin.pct.toFixed(2)}%" data-tl-jump="${pin.idx}" data-tl-hover="${pin.idx}" aria-label="${escape(t('tlJumpAria', { step: pin.idx + 1, label: pin.label }))}">${text}</button>`
|
|
1791
|
-
}).join('')
|
|
1792
|
-
|
|
1793
|
-
const segsHtml = steps.map((s, idx) => (
|
|
1794
|
-
`<div class="session-tl-seg${s.compactInfo ? ' has-compress' : s.frames?.length ? ' has-frame' : s.docs?.length ? ' has-doc' : ''}" data-tl-step="${idx}" data-tl-hover="${idx}"></div>`
|
|
1795
|
-
)).join('')
|
|
1796
|
-
const segGap = total > 360 ? '0px' : total > 160 ? '1px' : '2px'
|
|
1797
2022
|
|
|
1798
2023
|
return `<footer class="session-timeline-bar" data-session-timeline aria-label="${escape(t('tlAria'))}">
|
|
1799
2024
|
<div class="session-transport" role="group" aria-label="${escape(t('tlControlsAria'))}">
|
|
@@ -1803,10 +2028,12 @@ function renderTimelineBar(line, t) {
|
|
|
1803
2028
|
<span class="session-speed-badge" data-session-speed><b>0</b> / ${total} · 00:00</span>
|
|
1804
2029
|
</div>
|
|
1805
2030
|
<div class="session-tl-track-wrap" data-tl-track>
|
|
1806
|
-
<span class="session-composer-progress" data-session-progress aria-hidden="true"></span>
|
|
1807
2031
|
<div class="session-tl-pop" data-tl-pop hidden></div>
|
|
1808
|
-
|
|
1809
|
-
<div class="session-tl-
|
|
2032
|
+
${pins.length ? `<div class="session-tl-pins">${pins.join('')}</div>` : ''}
|
|
2033
|
+
<div class="session-tl-rail" style="--tl-count:${total + 1}">
|
|
2034
|
+
<div class="session-tl-cells" aria-hidden="true">${cells.join('')}</div>
|
|
2035
|
+
<input class="session-tl-range" data-tl-range type="range" min="0" max="${total}" step="1" value="0" aria-label="${escape(t('tlAria'))}"${total ? '' : ' disabled'}>
|
|
2036
|
+
</div>
|
|
1810
2037
|
</div>
|
|
1811
2038
|
</footer>`
|
|
1812
2039
|
}
|
|
@@ -1896,12 +2123,51 @@ function contextSidebar(line, t) {
|
|
|
1896
2123
|
</aside>`
|
|
1897
2124
|
}
|
|
1898
2125
|
|
|
2126
|
+
function renderDeliverable(file, t, baseUrl) {
|
|
2127
|
+
if (!file.availability) return renderFileContents(file, t, baseUrl)
|
|
2128
|
+
if (file.availability === 'missing') {
|
|
2129
|
+
const notice = { 'outside-root': 'fileOutsideRoot', unreadable: 'fileUnreadable' }[file.unavailableReason] || 'fileMissing'
|
|
2130
|
+
return `<section class="session-file-missing" data-availability="missing"><strong>${escape(file.title)}</strong><small>${escape(t(notice))}</small></section>`
|
|
2131
|
+
}
|
|
2132
|
+
const notice = t(file.availability === 'verified' ? 'fileVerified' : file.sessionSha256 ? 'fileHashMismatch' : 'fileExportCopy')
|
|
2133
|
+
return `<div class="session-file-copy" data-availability="${escape(file.availability)}"><small>${escape(notice)}</small>${renderFileContents(file, t, baseUrl)}</div>`
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
function renderFileContents(file, t, baseUrl) {
|
|
2137
|
+
if (file.preview?.type === 'xlsx' || file.preview?.pages?.length && file.preview.type === 'pdf') {
|
|
2138
|
+
return renderAttachment(file, t, src => resolveAsset(src, baseUrl))
|
|
2139
|
+
}
|
|
2140
|
+
const href = escape(resolveAsset(file.href, baseUrl))
|
|
2141
|
+
const cover = escape(resolveAsset(file.cover, baseUrl))
|
|
2142
|
+
const title = escape(file.title)
|
|
2143
|
+
const caption = `<b>${title}</b>${file.meta ? `<small>${escape(file.meta)}</small>` : ''}`
|
|
2144
|
+
if (!validVideo.test(file.href)) {
|
|
2145
|
+
if (file.availability) return `<a class="session-file-download" href="${href}" download="${title}">${caption}</a>`
|
|
2146
|
+
return `<a class="session-file" href="${href}" target="_blank" rel="noopener noreferrer">${cover ? `<img src="${cover}" alt="" width="56" height="79" loading="lazy">` : ''}<span>${caption}</span></a>`
|
|
2147
|
+
}
|
|
2148
|
+
const formats = file.portrait?.href ? `<div class="session-video-formats">
|
|
2149
|
+
<button type="button" data-video-format="landscape" data-src="${href}" data-cover="${cover}" aria-pressed="true">${t('landscape')}</button>
|
|
2150
|
+
<button type="button" data-video-format="portrait" data-src="${escape(resolveAsset(file.portrait.href, baseUrl))}" data-cover="${escape(resolveAsset(file.portrait.cover, baseUrl))}" aria-pressed="false">${t('portrait')}</button>
|
|
2151
|
+
</div>` : ''
|
|
2152
|
+
return `<figure class="session-video">
|
|
2153
|
+
<figcaption><span>${caption}</span>${formats}</figcaption>
|
|
2154
|
+
<video controls playsinline loading="lazy" preload="none" width="960" height="540" aria-label="${title}" src="${href}"${cover ? ` poster="${cover}"` : ''}></video>
|
|
2155
|
+
</figure>`
|
|
2156
|
+
}
|
|
2157
|
+
|
|
1899
2158
|
function renderLog(session, line, { t, baseUrl = '' }) {
|
|
1900
2159
|
const tool = toolLabels[session.tool] || session.tool || 'Agent'
|
|
1901
2160
|
const render = text => renderMarkdown(localLinks(text))
|
|
1902
2161
|
const entries = []
|
|
1903
2162
|
let shown = -Infinity
|
|
1904
2163
|
let stepIndex = 0
|
|
2164
|
+
let delivery = 0
|
|
2165
|
+
|
|
2166
|
+
function addFiles(files, step, time, atEnd = false, label = 'deliverablesTitle') {
|
|
2167
|
+
if (!files?.length) return
|
|
2168
|
+
const html = files.map(file => renderDeliverable(file, t, baseUrl)).join('')
|
|
2169
|
+
entries.push(`<li class="session-entry session-ai session-files" data-delivery="${++delivery}"${atEnd ? ' data-final-files' : ''} data-for-step="${step}" data-t="${time}"><div class="session-bubble"><span class="session-who">${escape(t(label))}</span>${html}</div></li>`)
|
|
2170
|
+
}
|
|
1905
2171
|
|
|
1906
2172
|
const stamp = (seconds, forStep) => {
|
|
1907
2173
|
if (seconds - shown < 300) return ''
|
|
@@ -1957,7 +2223,12 @@ function renderLog(session, line, { t, baseUrl = '' }) {
|
|
|
1957
2223
|
|
|
1958
2224
|
for (const item of line.items) {
|
|
1959
2225
|
if (item.type === 'tool' || item.type === 'reasoning') {
|
|
2226
|
+
if (item.deliverables?.length) flush()
|
|
1960
2227
|
work.push(item)
|
|
2228
|
+
if (item.deliverables?.length) {
|
|
2229
|
+
flush()
|
|
2230
|
+
addFiles(item.deliverables, stepIndex - 1, item.t)
|
|
2231
|
+
}
|
|
1961
2232
|
continue
|
|
1962
2233
|
}
|
|
1963
2234
|
flush()
|
|
@@ -1985,20 +2256,10 @@ function renderLog(session, line, { t, baseUrl = '' }) {
|
|
|
1985
2256
|
} else {
|
|
1986
2257
|
entries.push(`${stamp(item.t, stepIndex - 1)}<li class="session-entry session-ai" data-step="${stepIndex - 1}" data-echo-cat="msg" data-kind="reply" data-t="${item.t}"><div class="session-bubble">${item.question ? `<span class="session-who">${escape(t('asksYou', { tool }))}</span>` : ''}<div class="session-ai-body">${render(item.text)}</div>${renderStepArtifacts(stepMeta, { renderMd: render, t, baseUrl })}</div></li>`)
|
|
1987
2258
|
}
|
|
2259
|
+
addFiles(item.deliverables, stepIndex - 1, item.t, false, item.type === 'user' ? 'inputFiles' : 'deliverablesTitle')
|
|
1988
2260
|
}
|
|
1989
2261
|
flush()
|
|
1990
|
-
|
|
1991
|
-
const deliverables = session.deliverables || session.files || []
|
|
1992
|
-
const filesHtml = deliverables.map(file => {
|
|
1993
|
-
const href = escape(resolveAsset(file.href, baseUrl))
|
|
1994
|
-
const cover = file.cover ? escape(resolveAsset(file.cover, baseUrl)) : ''
|
|
1995
|
-
return validVideo.test(file.href)
|
|
1996
|
-
? `<figure class="session-video"><video controls preload="none" playsinline width="960" height="540"${cover ? ` poster="${cover}"` : ''}><source src="${href}" type="video/mp4"></video><figcaption><b>${escape(file.title)}</b>${file.meta ? `<small>${escape(file.meta)}</small>` : ''}</figcaption></figure>`
|
|
1997
|
-
: `<a class="session-file" href="${href}" target="_blank" rel="noopener noreferrer">${cover ? `<img src="${cover}" alt="" width="56" height="79" loading="lazy">` : ''}<span><b>${escape(file.title)}</b>${file.meta ? `<small>${escape(file.meta)}</small>` : ''}</span></a>`
|
|
1998
|
-
}).join('')
|
|
1999
|
-
if (filesHtml) {
|
|
2000
|
-
entries.push(`<li class="session-entry session-ai session-files" data-for-step="${Math.max(0, line.steps.length - 1)}" data-t="${line.end}"><div class="session-bubble"><span class="session-who">${escape(t('deliverablesTitle'))}</span>${filesHtml}</div></li>`)
|
|
2001
|
-
}
|
|
2262
|
+
addFiles(session.deliverables || session.files, Math.max(0, line.steps.length - 1), line.end, true)
|
|
2002
2263
|
return `<ol class="session-log">${entries.join('')}</ol>`
|
|
2003
2264
|
}
|
|
2004
2265
|
|
|
@@ -2131,7 +2392,7 @@ function renderPlayerWidget(session, computedTimeline, {
|
|
|
2131
2392
|
<div class="session-composer-bar">
|
|
2132
2393
|
<span class="session-composer-left">
|
|
2133
2394
|
<span class="session-composer-plus" aria-hidden="true">+</span>
|
|
2134
|
-
<span class="session-composer-perm" data-session-stage-badge
|
|
2395
|
+
<span class="session-composer-perm" data-session-stage-badge>${escape(t('workspaceWrite'))}</span>
|
|
2135
2396
|
</span>
|
|
2136
2397
|
<span class="session-composer-right">
|
|
2137
2398
|
<span class="session-composer-model">${escape(session.model || tool)}</span>
|
|
@@ -2270,11 +2531,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2270
2531
|
const stageTrigger = containerEl.querySelector('[data-session-stage-trigger]')
|
|
2271
2532
|
const composerText = containerEl.querySelector('[data-session-composer-text]')
|
|
2272
2533
|
const sendBtn = containerEl.querySelector('[data-session-send]')
|
|
2273
|
-
const progressBar = containerEl.querySelector('[data-session-progress]')
|
|
2274
2534
|
const timelineBar = containerEl.querySelector('[data-session-timeline]')
|
|
2275
2535
|
const tlTrack = timelineBar?.querySelector('[data-tl-track]')
|
|
2276
2536
|
const tlPop = timelineBar?.querySelector('[data-tl-pop]')
|
|
2277
|
-
const
|
|
2537
|
+
const tlRange = tlTrack?.querySelector('[data-tl-range]')
|
|
2538
|
+
const cells = tlTrack?.querySelector('.session-tl-cells')?.children
|
|
2278
2539
|
const tlPins = timelineBar ? [...timelineBar.querySelectorAll('[data-tl-jump]')] : []
|
|
2279
2540
|
const lightbox = containerEl.querySelector('[data-session-lightbox]')
|
|
2280
2541
|
const lightboxImg = lightbox?.querySelector('[data-lightbox-img]')
|
|
@@ -2300,8 +2561,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2300
2561
|
let curTime = 0
|
|
2301
2562
|
let playHead = initialStep
|
|
2302
2563
|
let prevRenderedHead = initialStep
|
|
2303
|
-
let selectedIdx = initialStep
|
|
2304
|
-
let userClickedInspect = false
|
|
2305
2564
|
let isInitialMount = true
|
|
2306
2565
|
let playing = false
|
|
2307
2566
|
let stepBusy = false
|
|
@@ -2423,13 +2682,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2423
2682
|
stepBusy = false
|
|
2424
2683
|
}
|
|
2425
2684
|
|
|
2426
|
-
function updateProgressHairline(idx = playHead) {
|
|
2427
|
-
if (!progressBar) return
|
|
2428
|
-
const ratio = steps.length > 0 && idx >= 0 ? Math.max(0, Math.min(1, (idx + 0.5) / steps.length)) : 0
|
|
2429
|
-
progressBar.style.opacity = idx >= 0 || playing ? '1' : '0'
|
|
2430
|
-
progressBar.style.transform = `scaleX(${ratio.toFixed(4)})`
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
2685
|
function rawPromptTextOf(stepIdx) {
|
|
2434
2686
|
const step = steps[stepIdx]
|
|
2435
2687
|
if (!step || step.kind !== 'prompt') return ''
|
|
@@ -2509,12 +2761,37 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2509
2761
|
return idx < 0 ? buildPrePromptStep() : model.selectStep(idx)
|
|
2510
2762
|
}
|
|
2511
2763
|
|
|
2512
|
-
function currentSelectedState() {
|
|
2513
|
-
return stateForIndex(selectedIdx)
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
2764
|
if (play) play.hidden = false
|
|
2765
|
+
attachAttachmentReaders(containerEl, t, () => { if (playing) setPlaying(false) })
|
|
2517
2766
|
if (log) log.classList.add('is-staged')
|
|
2767
|
+
for (const formats of containerEl.querySelectorAll('.session-video-formats')) {
|
|
2768
|
+
const figure = formats.closest('figure')
|
|
2769
|
+
const video = figure.querySelector('video')
|
|
2770
|
+
formats.addEventListener('click', async event => {
|
|
2771
|
+
const button = event.target.closest('[data-video-format]')
|
|
2772
|
+
if (!button || button.getAttribute('aria-pressed') === 'true') return
|
|
2773
|
+
const time = video.currentTime
|
|
2774
|
+
const resume = !video.paused && !video.ended
|
|
2775
|
+
formats.querySelector('[aria-pressed="true"]').setAttribute('aria-pressed', 'false')
|
|
2776
|
+
button.setAttribute('aria-pressed', 'true')
|
|
2777
|
+
video.dataset.format = button.dataset.videoFormat
|
|
2778
|
+
if (button.dataset.cover) video.poster = button.dataset.cover
|
|
2779
|
+
else video.removeAttribute('poster')
|
|
2780
|
+
video.preload = time > 0 ? 'metadata' : 'none'
|
|
2781
|
+
video.src = button.dataset.src
|
|
2782
|
+
video.load()
|
|
2783
|
+
if (time > 0) video.currentTime = time
|
|
2784
|
+
figure.scrollIntoView({ block: 'nearest' })
|
|
2785
|
+
if (resume) {
|
|
2786
|
+
try {
|
|
2787
|
+
await video.play()
|
|
2788
|
+
} catch (error) {
|
|
2789
|
+
// Switching again or pausing can interrupt the pending play request.
|
|
2790
|
+
if (error.name !== 'AbortError') throw error
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
})
|
|
2794
|
+
}
|
|
2518
2795
|
if (scrubber) {
|
|
2519
2796
|
scrubber.classList.add('is-ready')
|
|
2520
2797
|
scrubber.removeAttribute('aria-hidden')
|
|
@@ -2529,10 +2806,9 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2529
2806
|
|
|
2530
2807
|
function applyEchoHighlight() {
|
|
2531
2808
|
if (!asidePane) return
|
|
2532
|
-
|
|
2533
|
-
stackedBar?.classList.toggle('lc-stacked-dim', Boolean(activeKey))
|
|
2809
|
+
stackedBar?.classList.toggle('lc-stacked-dim', Boolean(hoverCat))
|
|
2534
2810
|
asidePane.querySelectorAll('[data-cat-key]').forEach(el => {
|
|
2535
|
-
const match =
|
|
2811
|
+
const match = hoverCat && el.dataset.catKey === hoverCat
|
|
2536
2812
|
el.classList.toggle('lc-stacked-seg-on', Boolean(match && el.classList.contains('lc-stacked-seg')))
|
|
2537
2813
|
el.classList.toggle('lc-chip-on', Boolean(match && el.classList.contains('lc-chip')))
|
|
2538
2814
|
})
|
|
@@ -2545,6 +2821,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2545
2821
|
entry.addEventListener('click', event => {
|
|
2546
2822
|
const lbBtn = event.target.closest('[data-lightbox-src]')
|
|
2547
2823
|
if (lbBtn && lightbox && lightboxImg) {
|
|
2824
|
+
event.preventDefault()
|
|
2548
2825
|
event.stopPropagation()
|
|
2549
2826
|
if (playing) setPlaying(false)
|
|
2550
2827
|
lightbox.classList.remove('is-doc')
|
|
@@ -2582,18 +2859,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2582
2859
|
}
|
|
2583
2860
|
if (event.target.closest('a, audio, video, summary, button')) return
|
|
2584
2861
|
if (stepIndex > playHead) return
|
|
2585
|
-
|
|
2586
|
-
const step = steps[stepIndex]
|
|
2587
|
-
selectedIdx = stepIndex
|
|
2588
|
-
userClickedInspect = true
|
|
2589
|
-
openCat = step?.primaryCat || null
|
|
2590
|
-
follow = false
|
|
2591
|
-
render()
|
|
2592
|
-
if (openCat) {
|
|
2593
|
-
requestAnimationFrame(() => {
|
|
2594
|
-
asidePane?.querySelector(`[data-browser-cat="${openCat}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
|
2595
|
-
})
|
|
2596
|
-
}
|
|
2862
|
+
jumpToStep(stepIndex)
|
|
2597
2863
|
})
|
|
2598
2864
|
entry.addEventListener('mouseenter', () => {
|
|
2599
2865
|
if (stepIndex > playHead) return
|
|
@@ -2614,8 +2880,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2614
2880
|
if (snapLabel) {
|
|
2615
2881
|
if (stepState.index < 0) {
|
|
2616
2882
|
snapLabel.textContent = t('snapInitial')
|
|
2617
|
-
} else if (selectedIdx < playHead) {
|
|
2618
|
-
snapLabel.textContent = t('snapInspect', { step: stepState.index + 1, total: steps.length })
|
|
2619
2883
|
} else {
|
|
2620
2884
|
snapLabel.textContent = t('snapCurrent', { step: stepState.index + 1, total: steps.length })
|
|
2621
2885
|
}
|
|
@@ -2716,15 +2980,17 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2716
2980
|
if (event.target === lightbox) closeLightbox()
|
|
2717
2981
|
})
|
|
2718
2982
|
|
|
2983
|
+
let hoverStep = null
|
|
2719
2984
|
function renderTimelineHover(idx) {
|
|
2720
|
-
if (!tlPop) return
|
|
2985
|
+
if (!tlPop || hoverStep === idx) return
|
|
2986
|
+
hoverStep = idx
|
|
2721
2987
|
if (idx === null || idx < 0 || idx >= steps.length) {
|
|
2722
2988
|
tlPop.hidden = true
|
|
2723
2989
|
return
|
|
2724
2990
|
}
|
|
2725
2991
|
const s = steps[idx]
|
|
2726
2992
|
const pct = steps.length > 0 ? Math.min(88, Math.max(12, ((idx + 0.5) / steps.length) * 100)) : 50
|
|
2727
|
-
const frame = s.frames?.[0]
|
|
2993
|
+
const frame = s.frames?.find(frame => frame.who === 'ai') || s.frames?.[0]
|
|
2728
2994
|
const doc = s.docs?.[0]
|
|
2729
2995
|
const ci = s.compactInfo
|
|
2730
2996
|
const thumbHtml = frame
|
|
@@ -2740,50 +3006,75 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2740
3006
|
? t('tlPromptTitle', { turn: s.turn, summary: shorten(s.summary || '', 20) })
|
|
2741
3007
|
: shorten(s.summary || t('tlStepFallback'), 24)
|
|
2742
3008
|
const tokStr = `${((s.contextSnapshot?.totalTokens || 0) / 1000).toFixed(1)}k`
|
|
2743
|
-
tlPop.style.left =
|
|
2744
|
-
tlPop.innerHTML = `${thumbHtml}<span class="session-tl-pop-meta"><small>${escapeHtml(t('tlStepMeta', { step: idx + 1, time: elapsedClock(s.t) }))}</small><b>${escapeHtml(headTitle)}</b><span
|
|
3009
|
+
tlPop.style.left = `clamp(min(130px, 50%), ${pct.toFixed(1)}%, max(50%, 100% - 130px))`
|
|
3010
|
+
tlPop.innerHTML = `${thumbHtml}<span class="session-tl-pop-meta"><small>${escapeHtml(t('tlStepMeta', { step: idx + 1, time: elapsedClock(s.t) }))}</small><b>${escapeHtml(headTitle)}</b><span>${escapeHtml(t('contextLabel'))} ≈${escapeHtml(tokStr)}</span></span>`
|
|
2745
3011
|
tlPop.hidden = false
|
|
2746
3012
|
}
|
|
2747
3013
|
|
|
2748
|
-
function
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
const
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
3014
|
+
function jumpToStep(idx) {
|
|
3015
|
+
setPlaying(false)
|
|
3016
|
+
// A seek shows the completed Step immediately, including a one-Step jump.
|
|
3017
|
+
prevRenderedHead = idx
|
|
3018
|
+
goToStage(idx)
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
function seekFromTimeline(idx) {
|
|
3022
|
+
const before = tlTrack.getBoundingClientRect()
|
|
3023
|
+
jumpToStep(idx)
|
|
3024
|
+
// On mobile the context list sits above the rail and can grow by several screens.
|
|
3025
|
+
if (before.top >= 0 && before.bottom <= window.innerHeight) {
|
|
3026
|
+
const delta = tlTrack.getBoundingClientRect().top - before.top
|
|
3027
|
+
if (delta) window.scrollBy({ top: delta, behavior: 'instant' })
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
const priority = { compress: 0, frame: 1, doc: 2, turn: 3 }
|
|
3032
|
+
const labelOrder = [...tlPins].sort((a, b) => priority[a.dataset.kind] - priority[b.dataset.kind])
|
|
3033
|
+
function fitTimelineLabels() {
|
|
3034
|
+
const width = tlTrack.clientWidth
|
|
3035
|
+
const occupied = []
|
|
3036
|
+
// Fit full captions first. A crowded milestone can still appear as an icon.
|
|
3037
|
+
for (const pin of labelOrder) pin.classList.remove('is-visible', 'is-compact')
|
|
3038
|
+
for (const compact of [false, true]) {
|
|
3039
|
+
const candidates = labelOrder.filter(pin => !pin.classList.contains('is-visible') && (compact || pin.dataset.kind !== 'turn'))
|
|
3040
|
+
for (const pin of candidates) pin.classList.toggle('is-compact', compact)
|
|
3041
|
+
const measured = candidates.map(pin => ({ pin, size: pin.offsetWidth }))
|
|
3042
|
+
for (const { pin, size } of measured) {
|
|
3043
|
+
const anchor = (Number(pin.dataset.tlJump) + 1.5) / (steps.length + 1) * width
|
|
3044
|
+
const left = Math.max(0, Math.min(width - size, anchor - size / 2))
|
|
3045
|
+
const right = left + size
|
|
3046
|
+
if (right > width || occupied.some(span => right + 4 > span.left && left < span.right + 4)) continue
|
|
3047
|
+
pin.style.left = `${left}px`
|
|
3048
|
+
pin.classList.add('is-visible')
|
|
3049
|
+
occupied.push({ left, right })
|
|
3050
|
+
}
|
|
2774
3051
|
}
|
|
2775
3052
|
}
|
|
2776
3053
|
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
3054
|
+
const labelObserver = tlPins.length ? new ResizeObserver(fitTimelineLabels) : null
|
|
3055
|
+
if (labelObserver) labelObserver.observe(tlTrack)
|
|
3056
|
+
tlRange?.addEventListener('input', () => seekFromTimeline(tlRange.valueAsNumber - 1))
|
|
3057
|
+
tlRange?.addEventListener('pointerdown', () => { if (playing) setPlaying(false) })
|
|
3058
|
+
tlTrack?.addEventListener('pointermove', event => {
|
|
3059
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3060
|
+
if (pin) return renderTimelineHover(Number(pin.dataset.tlJump))
|
|
3061
|
+
if (event.target !== tlRange || !steps.length) return renderTimelineHover(null)
|
|
3062
|
+
const rect = tlRange.getBoundingClientRect()
|
|
3063
|
+
const step = Math.floor((event.clientX - rect.left) / rect.width * (steps.length + 1))
|
|
3064
|
+
renderTimelineHover(Math.max(0, Math.min(steps.length - 1, step - 1)))
|
|
3065
|
+
})
|
|
3066
|
+
tlTrack?.addEventListener('focusin', event => {
|
|
3067
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3068
|
+
renderTimelineHover(pin ? Number(pin.dataset.tlJump) : playHead)
|
|
2780
3069
|
})
|
|
2781
|
-
tlTrack?.addEventListener('
|
|
3070
|
+
tlTrack?.addEventListener('focusout', () => renderTimelineHover(null))
|
|
3071
|
+
tlTrack?.addEventListener('keydown', event => {
|
|
3072
|
+
if (event.key === 'Escape') renderTimelineHover(null)
|
|
3073
|
+
})
|
|
3074
|
+
tlTrack?.addEventListener('pointerleave', () => renderTimelineHover(null))
|
|
2782
3075
|
tlTrack?.addEventListener('click', event => {
|
|
2783
|
-
const
|
|
2784
|
-
if (
|
|
2785
|
-
const idx = Number(el.dataset.tlJump ?? el.dataset.tlStep)
|
|
2786
|
-
if (Number.isFinite(idx)) jumpViaTimeline(idx)
|
|
3076
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3077
|
+
if (pin) seekFromTimeline(Number(pin.dataset.tlJump))
|
|
2787
3078
|
})
|
|
2788
3079
|
|
|
2789
3080
|
asidePane?.addEventListener('click', event => {
|
|
@@ -2813,7 +3104,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2813
3104
|
if (chipOrSeg) {
|
|
2814
3105
|
const catId = chipOrSeg.dataset.catKey
|
|
2815
3106
|
openCat = openCat === catId ? null : catId
|
|
2816
|
-
renderContextSidebar(
|
|
3107
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
2817
3108
|
asidePane.querySelector(`[data-browser-cat="${catId}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
|
2818
3109
|
return
|
|
2819
3110
|
}
|
|
@@ -2821,7 +3112,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2821
3112
|
if (catBtn && !catBtn.disabled) {
|
|
2822
3113
|
const catId = catBtn.dataset.browserCatToggle
|
|
2823
3114
|
openCat = openCat === catId ? null : catId
|
|
2824
|
-
renderContextSidebar(
|
|
3115
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
2825
3116
|
return
|
|
2826
3117
|
}
|
|
2827
3118
|
const itemBtn = event.target.closest('[data-browser-item-toggle]')
|
|
@@ -2829,7 +3120,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2829
3120
|
const itemId = itemBtn.dataset.browserItemToggle
|
|
2830
3121
|
if (openItems.has(itemId)) openItems.delete(itemId)
|
|
2831
3122
|
else openItems.add(itemId)
|
|
2832
|
-
renderContextSidebar(
|
|
3123
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
2833
3124
|
}
|
|
2834
3125
|
})
|
|
2835
3126
|
|
|
@@ -3058,7 +3349,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3058
3349
|
}
|
|
3059
3350
|
|
|
3060
3351
|
function runHeadChoreography(headState, headEntry, animateNewStep, steppedForwardOne) {
|
|
3061
|
-
updateProgressHairline()
|
|
3062
3352
|
if (!animateNewStep) return
|
|
3063
3353
|
clearStepAnimations()
|
|
3064
3354
|
|
|
@@ -3102,7 +3392,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3102
3392
|
if (headState.kind === 'compact') {
|
|
3103
3393
|
setComposerVisual('running')
|
|
3104
3394
|
openCat = 'tool'
|
|
3105
|
-
renderContextSidebar(
|
|
3395
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
3106
3396
|
if (headEntry && !calm.matches && typeof headEntry.animate === 'function') {
|
|
3107
3397
|
activeAnims.push(headEntry.animate(
|
|
3108
3398
|
[
|
|
@@ -3131,7 +3421,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3131
3421
|
|
|
3132
3422
|
function render() {
|
|
3133
3423
|
const headState = stateForIndex(playHead)
|
|
3134
|
-
const selectedState = currentSelectedState()
|
|
3135
3424
|
curTime = headState.index < 0 ? 0 : headState.t
|
|
3136
3425
|
const x = (playerData.end > 0 ? ((curTime / playerData.end) * width) : 0).toFixed(1)
|
|
3137
3426
|
if (head) {
|
|
@@ -3152,48 +3441,32 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3152
3441
|
play.setAttribute('aria-label', atEnd ? t('replayAria') : t('playAria'))
|
|
3153
3442
|
}
|
|
3154
3443
|
|
|
3155
|
-
renderContextSidebar(
|
|
3156
|
-
const
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3444
|
+
renderContextSidebar(headState)
|
|
3445
|
+
const stepNumber = playHead + 1
|
|
3446
|
+
if (speedBadge) speedBadge.innerHTML = `<b>${stepNumber}</b> / ${steps.length} · ${elapsedClock(curTime)}`
|
|
3447
|
+
if (tlRange) {
|
|
3448
|
+
tlRange.value = String(stepNumber)
|
|
3449
|
+
tlRange.setAttribute('aria-valuetext', t('tlStepMeta', { step: stepNumber, time: elapsedClock(curTime) }))
|
|
3161
3450
|
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
})
|
|
3451
|
+
if (cells) {
|
|
3452
|
+
for (let i = 0; i < cells.length; i++) {
|
|
3453
|
+
cells[i].classList.toggle('is-past', i > 0 && i < stepNumber)
|
|
3454
|
+
cells[i].classList.toggle('is-active', i === stepNumber)
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
if (tlRange?.matches(':focus-visible')) renderTimelineHover(playHead)
|
|
3458
|
+
for (const pin of tlPins) pin.classList.toggle('is-on', Number(pin.dataset.tlJump) === playHead)
|
|
3171
3459
|
|
|
3172
3460
|
let latestVisibleEntry
|
|
3173
3461
|
for (const item of stepEntries) {
|
|
3174
3462
|
const future = item.stepIndex > playHead
|
|
3175
3463
|
item.entry.classList.toggle('is-future', future)
|
|
3176
|
-
const isInspectSelected = !future && userClickedInspect && item.stepIndex === selectedIdx
|
|
3177
|
-
item.entry.classList.toggle('is-selected', isInspectSelected)
|
|
3178
|
-
|
|
3179
|
-
let tag = item.entry.querySelector('.session-inspect-tag')
|
|
3180
|
-
if (isInspectSelected) {
|
|
3181
|
-
if (!tag) {
|
|
3182
|
-
tag = document.createElement('span')
|
|
3183
|
-
tag.className = 'session-inspect-tag'
|
|
3184
|
-
item.entry.prepend(tag)
|
|
3185
|
-
}
|
|
3186
|
-
const stTime = steps[selectedIdx]?.t || 0
|
|
3187
|
-
tag.textContent = t.lang === 'en'
|
|
3188
|
-
? `Snapshot #${selectedIdx + 1} · ${elapsedClock(stTime)}`
|
|
3189
|
-
: `快照 #${selectedIdx + 1} · ${elapsedClock(stTime)}`
|
|
3190
|
-
} else if (tag) {
|
|
3191
|
-
tag.remove()
|
|
3192
|
-
}
|
|
3193
|
-
|
|
3194
3464
|
if (!future) latestVisibleEntry = item.entry
|
|
3195
3465
|
}
|
|
3196
3466
|
for (const aux of auxEntries) {
|
|
3467
|
+
if (aux.forStep > playHead && aux.entry.matches('.session-files:not(.is-future)')) {
|
|
3468
|
+
aux.entry.querySelectorAll('video').forEach(video => video.pause())
|
|
3469
|
+
}
|
|
3197
3470
|
aux.entry.classList.toggle('is-future', aux.forStep > playHead)
|
|
3198
3471
|
}
|
|
3199
3472
|
|
|
@@ -3221,8 +3494,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3221
3494
|
activate()
|
|
3222
3495
|
if (shouldScroll) camera.resumeFollow()
|
|
3223
3496
|
playHead = Math.max(-1, Math.min(steps.length - 1, nextIdx))
|
|
3224
|
-
selectedIdx = playHead
|
|
3225
|
-
userClickedInspect = false
|
|
3226
3497
|
openCat = playHead < 0 ? null : (steps[playHead]?.primaryCat || null)
|
|
3227
3498
|
follow = shouldScroll
|
|
3228
3499
|
animatedHead = -2
|
|
@@ -3246,7 +3517,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3246
3517
|
const nextDraft = next?.kind === 'prompt' ? rawPromptTextOf(next.index) : ''
|
|
3247
3518
|
if (nextDraft) setComposerVisual('draft', nextDraft)
|
|
3248
3519
|
else setComposerVisual('idle')
|
|
3249
|
-
updateProgressHairline()
|
|
3250
3520
|
return
|
|
3251
3521
|
}
|
|
3252
3522
|
activate()
|
|
@@ -3255,19 +3525,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3255
3525
|
clearStepAnimations()
|
|
3256
3526
|
playHead = -1
|
|
3257
3527
|
prevRenderedHead = -1
|
|
3258
|
-
selectedIdx = -1
|
|
3259
|
-
userClickedInspect = false
|
|
3260
3528
|
openCat = null
|
|
3261
3529
|
follow = true
|
|
3262
3530
|
animatedHead = -1
|
|
3263
3531
|
render()
|
|
3264
3532
|
}
|
|
3265
|
-
if (selectedIdx < playHead) {
|
|
3266
|
-
selectedIdx = playHead
|
|
3267
|
-
userClickedInspect = false
|
|
3268
|
-
openCat = steps[playHead]?.primaryCat || null
|
|
3269
|
-
render()
|
|
3270
|
-
}
|
|
3271
3533
|
if (!stepBusy) {
|
|
3272
3534
|
if (playHead < 0) {
|
|
3273
3535
|
const firstDraft = steps[0]?.kind === 'prompt' ? rawPromptTextOf(0) : ''
|
|
@@ -3321,8 +3583,8 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3321
3583
|
})
|
|
3322
3584
|
|
|
3323
3585
|
const onKeyDown = event => {
|
|
3324
|
-
if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) return
|
|
3325
|
-
if (event.target.closest('input, textarea, select, a, audio, video, summary, [contenteditable]')) return
|
|
3586
|
+
if (lightbox?.open || event.target.closest('dialog[open]') || event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) return
|
|
3587
|
+
if (event.target.closest('input, textarea, select, a, audio, video, .session-video-formats, summary, [contenteditable]')) return
|
|
3326
3588
|
if (event.key === ' ' && event.target.closest('button')) return
|
|
3327
3589
|
if (event.key === 'ArrowLeft') {
|
|
3328
3590
|
setPlaying(false)
|
|
@@ -3337,9 +3599,8 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3337
3599
|
}
|
|
3338
3600
|
event.preventDefault()
|
|
3339
3601
|
}
|
|
3340
|
-
if (
|
|
3341
|
-
|
|
3342
|
-
}
|
|
3602
|
+
if (!appEl.hasAttribute('tabindex')) appEl.tabIndex = -1
|
|
3603
|
+
appEl.addEventListener('keydown', onKeyDown)
|
|
3343
3604
|
|
|
3344
3605
|
if (scrubber) {
|
|
3345
3606
|
const fromPointer = event => {
|
|
@@ -3369,9 +3630,8 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3369
3630
|
destroy() {
|
|
3370
3631
|
clearStepAnimations()
|
|
3371
3632
|
camera.stop()
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
}
|
|
3633
|
+
labelObserver?.disconnect()
|
|
3634
|
+
appEl.removeEventListener('keydown', onKeyDown)
|
|
3375
3635
|
},
|
|
3376
3636
|
goToStage,
|
|
3377
3637
|
setPlaying,
|
|
@@ -3398,6 +3658,10 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
|
|
|
3398
3658
|
const appNode = el.querySelector('.session-app')
|
|
3399
3659
|
const activeLang = resolveLang(options.lang || el.dataset.lang || appNode?.dataset.encoreLang || 'zh')
|
|
3400
3660
|
const playerData = JSON.parse(preRenderedData.textContent)
|
|
3661
|
+
const footer = el.querySelector('[data-session-timeline]')
|
|
3662
|
+
if (footer && !footer.querySelector('.session-tl-cells')) {
|
|
3663
|
+
footer.outerHTML = renderTimelineBar(playerData, createTranslator(activeLang))
|
|
3664
|
+
}
|
|
3401
3665
|
const activeController = attachPlayerController(el, playerData, {
|
|
3402
3666
|
lang: activeLang,
|
|
3403
3667
|
initialStep: options.initialStep ?? -1,
|
|
@@ -3440,7 +3704,7 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
|
|
|
3440
3704
|
if (activeController) activeController.destroy()
|
|
3441
3705
|
activeLang = resolveLang(lang)
|
|
3442
3706
|
const line = timeline(session, { lang: activeLang })
|
|
3443
|
-
el.innerHTML = renderPlayerWidget(session, line, { lang: activeLang, baseUrl })
|
|
3707
|
+
el.innerHTML = renderPlayerWidget(session, line, { ...options, lang: activeLang, baseUrl })
|
|
3444
3708
|
if (session.title && document.querySelectorAll('[data-encore-player]').length <= 1) {
|
|
3445
3709
|
document.title = `${session.title} · Encore`
|
|
3446
3710
|
}
|
|
@@ -3467,7 +3731,19 @@ async function autoMountEncorePlayers() {
|
|
|
3467
3731
|
if (node.dataset.encoreMounted) continue
|
|
3468
3732
|
node.dataset.encoreMounted = '1'
|
|
3469
3733
|
try {
|
|
3470
|
-
await createEncorePlayer(node)
|
|
3734
|
+
const player = await createEncorePlayer(node)
|
|
3735
|
+
const showLinkedDelivery = () => {
|
|
3736
|
+
const match = /^#delivery-(\d+)$/.exec(location.hash)
|
|
3737
|
+
const files = match ? node.querySelector(`[data-delivery="${match[1]}"]`)
|
|
3738
|
+
: location.hash === '#deliverables' && [...node.querySelectorAll('[data-delivery]')].at(-1)
|
|
3739
|
+
if (!files) return
|
|
3740
|
+
const controller = player.getController()
|
|
3741
|
+
controller.setPlaying(false)
|
|
3742
|
+
controller.goToStage(Number(files.dataset.forStep), false)
|
|
3743
|
+
files.scrollIntoView({ block: 'start' })
|
|
3744
|
+
}
|
|
3745
|
+
showLinkedDelivery()
|
|
3746
|
+
window.addEventListener('hashchange', showLinkedDelivery)
|
|
3471
3747
|
} catch (err) {
|
|
3472
3748
|
node.innerHTML = `<div class="encore-load-error">Failed to load session replay: ${escapeHtml(err.message || String(err))}</div>`
|
|
3473
3749
|
}
|