@niracler/encore 0.3.0 → 0.4.1
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 +42 -108
- package/README.zh-CN.md +42 -108
- package/bin/encore.mjs +9 -100
- package/package.json +3 -2
- package/player/encore-player.css +44 -48
- package/player/encore-player.js +293 -313
- package/schema/session.schema.json +10 -2
- package/skills/encore/SKILL.md +2 -2
- package/src/antigravity-context.mjs +122 -0
- package/src/antigravity-context.proto +43 -0
- package/src/antigravity.mjs +160 -0
- package/src/common.mjs +7 -4
- package/src/detect.mjs +96 -51
- package/src/external-files.mjs +22 -5
- package/src/i18n.mjs +9 -9
- package/src/index.d.ts +8 -2
- package/src/index.mjs +17 -6
- package/src/player-runtime.mjs +109 -128
- package/src/render.mjs +54 -87
- package/src/session-picker.mjs +163 -0
- package/src/timeline.mjs +117 -85
package/player/encore-player.js
CHANGED
|
@@ -52,13 +52,13 @@ const DICTS = {
|
|
|
52
52
|
emptyHintEnd: ',体验完整对话与上下文生长',
|
|
53
53
|
activeContext: '上下文快照',
|
|
54
54
|
snapInitial: '初始上下文',
|
|
55
|
-
|
|
55
|
+
initialUsageMissing: '初始用量未记录',
|
|
56
|
+
usageMissing: '用量未记录',
|
|
57
|
+
notRecorded: '未记录',
|
|
58
|
+
unknownCapacity: '上限未知',
|
|
56
59
|
snapCurrent: '第 {step} / {total} 步',
|
|
57
60
|
usedSuffix: '已用',
|
|
58
61
|
freeSpaceTitle: '剩余窗口 (Free Space)',
|
|
59
|
-
autoCompactTriggerTitle: '自动压缩触发线 (80%)',
|
|
60
|
-
headroomTitle: '压缩预留空间 (Autocompact Headroom)',
|
|
61
|
-
outputReserveTitle: '模型最大输出预留 (Max Output Reserve)',
|
|
62
62
|
legendSys: '系统提示词',
|
|
63
63
|
legendSchema: '工具定义',
|
|
64
64
|
legendUser: '用户消息',
|
|
@@ -190,13 +190,13 @@ const DICTS = {
|
|
|
190
190
|
emptyHintEnd: ' to replay the conversation and live context growth',
|
|
191
191
|
activeContext: 'Context Snapshot',
|
|
192
192
|
snapInitial: 'Initial Context',
|
|
193
|
-
|
|
193
|
+
initialUsageMissing: 'Initial usage not recorded',
|
|
194
|
+
usageMissing: 'Usage not recorded',
|
|
195
|
+
notRecorded: 'Not recorded',
|
|
196
|
+
unknownCapacity: 'Unknown limit',
|
|
194
197
|
snapCurrent: 'Step {step} / {total}',
|
|
195
198
|
usedSuffix: 'used',
|
|
196
199
|
freeSpaceTitle: 'Free Context Space',
|
|
197
|
-
autoCompactTriggerTitle: 'Auto-compaction Trigger (80%)',
|
|
198
|
-
headroomTitle: 'Autocompact Headroom (12%)',
|
|
199
|
-
outputReserveTitle: 'Max Output Reserve (8%)',
|
|
200
200
|
legendSys: 'System Prompt',
|
|
201
201
|
legendSchema: 'Tool Schemas',
|
|
202
202
|
legendUser: 'User Messages',
|
|
@@ -256,7 +256,7 @@ const DICTS = {
|
|
|
256
256
|
tlControlsAria: 'Playback controls',
|
|
257
257
|
tlJumpAria: 'Jump to step {step}: {label}',
|
|
258
258
|
tlStepMeta: 'Step {step} · {time}',
|
|
259
|
-
tlCompressPin: '
|
|
259
|
+
tlCompressPin: 'Compaction #{seq}',
|
|
260
260
|
tlCompressTitle: '🗜 Compaction #{seq} (-{dropped}k)',
|
|
261
261
|
tlPromptTitle: '💬 Turn #{turn}: {summary}',
|
|
262
262
|
tlStepFallback: 'Step details',
|
|
@@ -503,6 +503,7 @@ function resolveWindowCapacity(tool = 'codex', model = '', contextWindow = 0) {
|
|
|
503
503
|
return { tokens: contextWindow, label }
|
|
504
504
|
}
|
|
505
505
|
const t = String(tool || '').toLowerCase()
|
|
506
|
+
if (t.startsWith('antigravity')) return { tokens: null, label: null }
|
|
506
507
|
const m = String(model || '').toLowerCase()
|
|
507
508
|
if (
|
|
508
509
|
t.startsWith('claude') ||
|
|
@@ -935,7 +936,7 @@ function assignFramesToGroups(rawGroups, frames = [], t) {
|
|
|
935
936
|
}
|
|
936
937
|
|
|
937
938
|
function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames = [], sessionStart = '', sessionMeta = {}, t) {
|
|
938
|
-
|
|
939
|
+
let windowSpec = resolveWindowCapacity(sessionTool, sessionModel, sessionMeta.contextWindow)
|
|
939
940
|
const initCtx = sessionMeta.initialContext || {}
|
|
940
941
|
const rawGroups = []
|
|
941
942
|
let work = []
|
|
@@ -966,25 +967,32 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
966
967
|
id: rec.id,
|
|
967
968
|
tag: rec.tag || '',
|
|
968
969
|
title: rec.title,
|
|
969
|
-
meta: rec.meta,
|
|
970
|
+
meta: observedOnly && rec.stepIndex >= 0 ? undefined : rec.meta,
|
|
970
971
|
payload: rec.payload,
|
|
971
972
|
...(rec.images?.length ? { images: rec.images } : {}),
|
|
972
973
|
}
|
|
973
974
|
return entry
|
|
974
975
|
}
|
|
975
976
|
|
|
976
|
-
|
|
977
|
-
const
|
|
977
|
+
// Antigravity metadata may contain only part of the mounted context.
|
|
978
|
+
const observedOnly = sessionTool.startsWith('antigravity')
|
|
979
|
+
function initialRecords(key, defaults) {
|
|
980
|
+
const records = initCtx[key] || []
|
|
981
|
+
const entries = records.length || observedOnly ? records : defaults(sessionTool, sessionStart)
|
|
982
|
+
return entries.map(record => registerRecord({ ...record, stepIndex: -1 }))
|
|
983
|
+
}
|
|
984
|
+
const sysRecords = initialRecords('sys', defaultSystemPrompts)
|
|
985
|
+
const schemaRecords = initialRecords('schema', defaultToolSchemas)
|
|
978
986
|
const schemaIdSet = new Set(schemaRecords.map(r => r.id))
|
|
979
987
|
for (const r of schemaRecords) if (r.title) schemaIdSet.add(`schema-dyn-${String(r.title).replace(/[^a-zA-Z0-9_-]/g, '_')}`)
|
|
980
988
|
const userRecords = []
|
|
981
989
|
let toolRecords = []
|
|
982
|
-
const skillRecords = (
|
|
990
|
+
const skillRecords = initialRecords('skill', defaultSkillCatalog)
|
|
983
991
|
const knownSkillNames = new Set(skillRecords.map(r => r.title).filter(Boolean))
|
|
984
992
|
const msgRecords = []
|
|
985
|
-
const memRecords = (
|
|
993
|
+
const memRecords = initialRecords('mem', defaultInjectedContext)
|
|
986
994
|
|
|
987
|
-
const sumTokEst = list => list.reduce((acc, r) => acc + (r.tokEst
|
|
995
|
+
const sumTokEst = list => list.reduce((acc, r) => acc + (r.tokEst ?? (observedOnly ? 0 : 600)), 0)
|
|
988
996
|
const sysTokens = sumTokEst(sysRecords)
|
|
989
997
|
let schemaTokens = sumTokEst(schemaRecords)
|
|
990
998
|
let userTokens = 0
|
|
@@ -997,7 +1005,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
997
1005
|
let uncalibratedDelta = 0
|
|
998
1006
|
const allTools = []
|
|
999
1007
|
const allSkills = []
|
|
1000
|
-
const allMemories = ['AGENTS.md']
|
|
1008
|
+
const allMemories = observedOnly ? [] : ['AGENTS.md']
|
|
1001
1009
|
const allChanges = []
|
|
1002
1010
|
let latestUserPrompt = ''
|
|
1003
1011
|
let toolSeq = 0
|
|
@@ -1014,7 +1022,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1014
1022
|
let dUser = userTokens
|
|
1015
1023
|
let dMsg = msgTokens
|
|
1016
1024
|
let dTool = toolTokens
|
|
1017
|
-
if (lastRealTotal > 0) {
|
|
1025
|
+
if (lastRealTotal > 0 && !observedOnly) {
|
|
1018
1026
|
const target = lastRealTotal + uncalibratedDelta
|
|
1019
1027
|
const fixed = dSys + dSchema + dMem + dSkill
|
|
1020
1028
|
const dyn = dUser + dMsg + dTool
|
|
@@ -1037,6 +1045,11 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1037
1045
|
return { sys: dSys, schema: dSchema, user: dUser, mem: dMem, skill: dSkill, msg: dMsg, tool: dTool }
|
|
1038
1046
|
}
|
|
1039
1047
|
|
|
1048
|
+
function reportedBuckets(disp, recorded) {
|
|
1049
|
+
if (!observedOnly) return disp
|
|
1050
|
+
return Object.fromEntries(Object.keys(disp).map(key => [key, recorded?.[key] ?? null]))
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1040
1053
|
const assembleCategoryList = (stepIdx, countsBefore, toksBefore, disp) => {
|
|
1041
1054
|
const curTotal = disp.sys + disp.schema + disp.user + disp.mem + disp.msg + disp.tool + disp.skill
|
|
1042
1055
|
const kindPct = value => Math.round((value / Math.max(1, curTotal)) * 100)
|
|
@@ -1061,10 +1074,10 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1061
1074
|
color,
|
|
1062
1075
|
itemCount: records.length,
|
|
1063
1076
|
count: t('itemCount', { n: records.length }),
|
|
1064
|
-
tok: `≈${(curTok / 1000).toFixed(1)}k`,
|
|
1065
|
-
pct: `${kindPct(curTok)}%`,
|
|
1077
|
+
tok: curTok == null ? t('notRecorded') : `≈${(curTok / 1000).toFixed(1)}k`,
|
|
1078
|
+
pct: observedOnly || curTok == null ? '' : `${kindPct(curTok)}%`,
|
|
1066
1079
|
delta: stepIdx >= 0 ? fmtCountDelta(records.length, prevCount) : '',
|
|
1067
|
-
tokDelta: stepIdx >= 0 ? fmtTokDelta(curTok, prevTok) : '',
|
|
1080
|
+
tokDelta: stepIdx >= 0 && !observedOnly ? fmtTokDelta(curTok, prevTok) : '',
|
|
1068
1081
|
itemIds,
|
|
1069
1082
|
newIds,
|
|
1070
1083
|
items: itemIds.map(rid => ({ ...contextRecords[rid], isNew: newSet.has(rid) })),
|
|
@@ -1083,9 +1096,15 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1083
1096
|
|
|
1084
1097
|
let prevDisp = computeDisplayBuckets()
|
|
1085
1098
|
const initTotal = prevDisp.sys + prevDisp.schema + prevDisp.user + prevDisp.mem + prevDisp.skill + prevDisp.msg + prevDisp.tool
|
|
1086
|
-
|
|
1087
|
-
const
|
|
1099
|
+
let observedUsage = initCtx.estimatedTokens ?? null
|
|
1100
|
+
const openingTokens = observedOnly ? observedUsage : initTotal
|
|
1101
|
+
const initCap = observedOnly ? windowSpec.tokens : Math.max(windowSpec.tokens, Math.ceil(initTotal * 1.25))
|
|
1102
|
+
const initCapPct = val => (!initCap || val <= 0 ? 0 : Number((Math.max(0.4, (val / initCap) * 100)).toFixed(2)))
|
|
1088
1103
|
const initKindPct = val => Math.round((val / Math.max(1, initTotal)) * 100)
|
|
1104
|
+
const openingByKind = Object.fromEntries(Object.entries(initCtx)
|
|
1105
|
+
.filter(([, records]) => Array.isArray(records) && records.some(record => record.tokEst != null))
|
|
1106
|
+
.map(([key, records]) => [key, sumTokEst(records)]))
|
|
1107
|
+
const initialBuckets = reportedBuckets(prevDisp, openingByKind)
|
|
1089
1108
|
const zeroCounts = {
|
|
1090
1109
|
sys: sysRecords.length,
|
|
1091
1110
|
schema: schemaRecords.length,
|
|
@@ -1096,12 +1115,13 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1096
1115
|
tool: 0,
|
|
1097
1116
|
}
|
|
1098
1117
|
const initialSnapshot = {
|
|
1099
|
-
pct: Number(
|
|
1118
|
+
pct: initCap && openingTokens != null ? Number(((openingTokens / initCap) * 100).toFixed(1)) : null,
|
|
1100
1119
|
windowTokens: windowSpec.tokens,
|
|
1101
1120
|
windowLabel: windowSpec.label,
|
|
1102
|
-
totalTokens:
|
|
1121
|
+
totalTokens: openingTokens,
|
|
1122
|
+
...(observedOnly && openingTokens != null && { estimated: true }),
|
|
1103
1123
|
deltaTokens: 0,
|
|
1104
|
-
segments: {
|
|
1124
|
+
segments: observedOnly ? { used: initCap && openingTokens != null ? Math.min(openingTokens / initCap * 100, 100) : 0 } : {
|
|
1105
1125
|
sys: initCapPct(prevDisp.sys),
|
|
1106
1126
|
schema: initCapPct(prevDisp.schema),
|
|
1107
1127
|
user: 0,
|
|
@@ -1110,7 +1130,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1110
1130
|
msg: 0,
|
|
1111
1131
|
tool: 0,
|
|
1112
1132
|
},
|
|
1113
|
-
pctByKind: {
|
|
1133
|
+
pctByKind: observedOnly ? {} : {
|
|
1114
1134
|
sys: initKindPct(prevDisp.sys),
|
|
1115
1135
|
schema: initKindPct(prevDisp.schema),
|
|
1116
1136
|
user: 0,
|
|
@@ -1119,8 +1139,8 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1119
1139
|
msg: 0,
|
|
1120
1140
|
tool: 0,
|
|
1121
1141
|
},
|
|
1122
|
-
tokensByKind:
|
|
1123
|
-
categories: assembleCategoryList(-1, zeroCounts, prevDisp,
|
|
1142
|
+
tokensByKind: initialBuckets,
|
|
1143
|
+
categories: assembleCategoryList(-1, zeroCounts, prevDisp, initialBuckets),
|
|
1124
1144
|
}
|
|
1125
1145
|
|
|
1126
1146
|
const steps = rawGroups.map((group, index) => {
|
|
@@ -1176,7 +1196,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1176
1196
|
payload: String(first.text || ''),
|
|
1177
1197
|
...(first.images?.length ? { images: first.images } : {}),
|
|
1178
1198
|
}))
|
|
1179
|
-
for (const skill of extractSkillNames(first, knownSkillNames)) {
|
|
1199
|
+
for (const skill of observedOnly ? [] : extractSkillNames(first, knownSkillNames)) {
|
|
1180
1200
|
if (!allSkills.includes(skill)) {
|
|
1181
1201
|
allSkills.push(skill)
|
|
1182
1202
|
const skTok = 1800
|
|
@@ -1204,59 +1224,68 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1204
1224
|
} else if (group.groupType === 'compact') {
|
|
1205
1225
|
compactSeq++
|
|
1206
1226
|
const cItem = first
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
}))
|
|
1227
|
+
if (observedOnly) {
|
|
1228
|
+
compactInfo = { seq: compactSeq, title: t('compactTitle', { seq: compactSeq }) }
|
|
1229
|
+
if (cItem.text) {
|
|
1230
|
+
compactInfo.content = cItem.text
|
|
1231
|
+
compactInfo.docId = `compact-doc-${index}`
|
|
1232
|
+
memRecords.push(registerRecord({ id: `compact-summary-${compactSeq}`, tag: 'Checkpoint',
|
|
1233
|
+
title: compactInfo.title, payload: cItem.text, stepIndex: index }))
|
|
1234
|
+
}
|
|
1235
|
+
} else {
|
|
1236
|
+
const preTokens = cItem.preTokens || prevTotal
|
|
1237
|
+
const archivedTools = toolRecords.length
|
|
1238
|
+
const postTokens = cItem.postTokens || Math.min(preTokens, Math.max(24000, Math.round(preTokens * 0.28)))
|
|
1239
|
+
const droppedTokens = cItem.droppedTokens || Math.max(0, preTokens - postTokens)
|
|
1240
|
+
const summaryText = String(cItem.text || cItem.summary || 'Context Compaction Summary').trim()
|
|
1241
|
+
const sumTok = Math.max(1200, Math.round(summaryText.length * 0.35))
|
|
1242
|
+
const docId = `compact-doc-${index}`
|
|
1243
|
+
const recId = `compact-summary-${compactSeq}`
|
|
1244
|
+
|
|
1245
|
+
toolRecords = []
|
|
1246
|
+
toolTokens = 0
|
|
1247
|
+
userTokens = Math.round(userTokens * 0.35)
|
|
1248
|
+
msgTokens = Math.round(msgTokens * 0.25)
|
|
1249
|
+
memTokens += sumTok
|
|
1250
|
+
lastRealTotal = postTokens
|
|
1251
|
+
uncalibratedDelta = 0
|
|
1252
|
+
const rawFixed = sysTokens + schemaTokens + memTokens + skillTokens
|
|
1253
|
+
if (postTokens > 0 && rawFixed > postTokens * 0.85) {
|
|
1254
|
+
mountScale = (postTokens * 0.72) / rawFixed
|
|
1255
|
+
}
|
|
1237
1256
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
title: cItem.summary || t('compactTitle', { seq: cItem.seq || compactSeq }),
|
|
1248
|
-
content: summaryText,
|
|
1249
|
-
}
|
|
1257
|
+
memRecords.push(registerRecord({
|
|
1258
|
+
id: recId,
|
|
1259
|
+
stepIndex: index,
|
|
1260
|
+
tokEst: sumTok,
|
|
1261
|
+
tag: 'Compact',
|
|
1262
|
+
title: `${t('compactTitle', { seq: cItem.seq || compactSeq })} (${(preTokens / 1000).toFixed(1)}k → ${(postTokens / 1000).toFixed(1)}k)`,
|
|
1263
|
+
meta: `-${(droppedTokens / 1000).toFixed(1)}k tok · ${stepTime}s`,
|
|
1264
|
+
payload: summaryText,
|
|
1265
|
+
}))
|
|
1250
1266
|
|
|
1267
|
+
compactInfo = {
|
|
1268
|
+
seq: cItem.seq || compactSeq,
|
|
1269
|
+
trigger: cItem.trigger || 'auto',
|
|
1270
|
+
preTokens,
|
|
1271
|
+
postTokens,
|
|
1272
|
+
droppedTokens,
|
|
1273
|
+
archivedTools,
|
|
1274
|
+
docId,
|
|
1275
|
+
recId,
|
|
1276
|
+
title: cItem.summary || t('compactTitle', { seq: cItem.seq || compactSeq }),
|
|
1277
|
+
content: summaryText,
|
|
1278
|
+
}
|
|
1279
|
+
inBrief = `${(preTokens / 1000).toFixed(1)}k → ${(postTokens / 1000).toFixed(1)}k`
|
|
1280
|
+
responseBrief = t('archivedTools', { n: archivedTools, tokens: (droppedTokens / 1000).toFixed(1) })
|
|
1281
|
+
}
|
|
1251
1282
|
kind = 'compact'
|
|
1252
1283
|
primaryCat = 'mem'
|
|
1253
1284
|
speedLabel = '0.8×'
|
|
1254
1285
|
dwellMs = 2100
|
|
1255
1286
|
spotlight = 'context-compact'
|
|
1256
1287
|
detailTitle = t('compactTitle', { seq: compactInfo.seq })
|
|
1257
|
-
detailSnippet =
|
|
1258
|
-
inBrief = `${(preTokens / 1000).toFixed(1)}k → ${(postTokens / 1000).toFixed(1)}k`
|
|
1259
|
-
responseBrief = t('archivedTools', { n: archivedTools, tokens: (droppedTokens / 1000).toFixed(1) })
|
|
1288
|
+
detailSnippet = (compactInfo.content || '').slice(0, 260)
|
|
1260
1289
|
} else if (group.groupType === 'assistant') {
|
|
1261
1290
|
msgSeq++
|
|
1262
1291
|
const cleanReply = (first.text || '').replace(/\s+/g, ' ').trim()
|
|
@@ -1297,7 +1326,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1297
1326
|
allTools.push(...extracted.tools)
|
|
1298
1327
|
allChanges.push(...extracted.changes)
|
|
1299
1328
|
|
|
1300
|
-
for (const memName of extracted.memories) {
|
|
1329
|
+
for (const memName of observedOnly ? [] : extracted.memories) {
|
|
1301
1330
|
if (!allMemories.includes(memName)) {
|
|
1302
1331
|
allMemories.push(memName)
|
|
1303
1332
|
const memTok = 1100
|
|
@@ -1334,14 +1363,14 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1334
1363
|
|
|
1335
1364
|
const rawMontage = []
|
|
1336
1365
|
for (const item of toolItems) {
|
|
1337
|
-
const dynSchema = resolveDynamicSchema(item, index, schemaIdSet)
|
|
1366
|
+
const dynSchema = !observedOnly && resolveDynamicSchema(item, index, schemaIdSet)
|
|
1338
1367
|
if (dynSchema) {
|
|
1339
1368
|
schemaIdSet.add(dynSchema.id)
|
|
1340
1369
|
schemaTokens += dynSchema.tokEst
|
|
1341
1370
|
stepEstimatedDelta += dynSchema.tokEst
|
|
1342
1371
|
schemaRecords.push(registerRecord(dynSchema))
|
|
1343
1372
|
}
|
|
1344
|
-
for (const skill of extractSkillNames(item, knownSkillNames)) {
|
|
1373
|
+
for (const skill of observedOnly ? [] : extractSkillNames(item, knownSkillNames)) {
|
|
1345
1374
|
if (!allSkills.includes(skill)) {
|
|
1346
1375
|
allSkills.push(skill)
|
|
1347
1376
|
const skTok = 1800
|
|
@@ -1476,13 +1505,23 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1476
1505
|
|
|
1477
1506
|
const disp = computeDisplayBuckets()
|
|
1478
1507
|
prevDisp = disp
|
|
1479
|
-
const
|
|
1480
|
-
const
|
|
1481
|
-
const
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1508
|
+
const bucketTotal = disp.sys + disp.schema + disp.user + disp.mem + disp.msg + disp.tool + disp.skill
|
|
1509
|
+
const previousUsage = observedOnly ? observedUsage : prevTotal
|
|
1510
|
+
const request = observedOnly && group.items.findLast(item => item.contextTokens != null || item.contextTokenEstimates || item.contextWindow != null)
|
|
1511
|
+
const sample = request?.contextTokens
|
|
1512
|
+
if (observedOnly) {
|
|
1513
|
+
const limit = group.items.findLast(item => item.contextWindow != null)?.contextWindow
|
|
1514
|
+
if (limit != null) windowSpec = resolveWindowCapacity(sessionTool, sessionModel, limit)
|
|
1515
|
+
observedUsage = sample ?? null
|
|
1516
|
+
}
|
|
1517
|
+
const totalTokens = observedOnly ? observedUsage : bucketTotal
|
|
1518
|
+
const deltaTokens = totalTokens == null || previousUsage == null ? null : totalTokens - previousUsage
|
|
1519
|
+
const capacity = observedOnly ? windowSpec.tokens : Math.max(windowSpec.tokens, Math.ceil(totalTokens * 1.25))
|
|
1520
|
+
const pct = capacity && totalTokens != null ? Number(((totalTokens / capacity) * 100).toFixed(1)) : null
|
|
1521
|
+
const capPct = value => (!capacity || value <= 0 ? 0 : Number((Math.max(0.4, (value / capacity) * 100)).toFixed(2)))
|
|
1522
|
+
const kindPct = value => Math.round((value / Math.max(1, bucketTotal)) * 100)
|
|
1523
|
+
const buckets = reportedBuckets(disp, request?.contextTokenEstimates)
|
|
1524
|
+
const categories = assembleCategoryList(index, prevCounts, prevToks, buckets)
|
|
1486
1525
|
|
|
1487
1526
|
return {
|
|
1488
1527
|
index,
|
|
@@ -1508,8 +1547,9 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1508
1547
|
windowTokens: windowSpec.tokens,
|
|
1509
1548
|
windowLabel: windowSpec.label,
|
|
1510
1549
|
totalTokens,
|
|
1550
|
+
...(observedOnly && totalTokens != null && { estimated: false }),
|
|
1511
1551
|
deltaTokens,
|
|
1512
|
-
segments: {
|
|
1552
|
+
segments: observedOnly ? { used: Math.min(pct ?? 0, 100) } : {
|
|
1513
1553
|
sys: capPct(disp.sys),
|
|
1514
1554
|
schema: capPct(disp.schema),
|
|
1515
1555
|
user: capPct(disp.user),
|
|
@@ -1518,7 +1558,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1518
1558
|
skill: capPct(disp.skill),
|
|
1519
1559
|
mem: capPct(disp.mem),
|
|
1520
1560
|
},
|
|
1521
|
-
pctByKind: {
|
|
1561
|
+
pctByKind: observedOnly ? {} : {
|
|
1522
1562
|
sys: kindPct(disp.sys),
|
|
1523
1563
|
schema: kindPct(disp.schema),
|
|
1524
1564
|
user: kindPct(disp.user),
|
|
@@ -1527,15 +1567,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
|
|
|
1527
1567
|
skill: kindPct(disp.skill),
|
|
1528
1568
|
mem: kindPct(disp.mem),
|
|
1529
1569
|
},
|
|
1530
|
-
tokensByKind:
|
|
1531
|
-
sys: disp.sys,
|
|
1532
|
-
schema: disp.schema,
|
|
1533
|
-
user: disp.user,
|
|
1534
|
-
msg: disp.msg,
|
|
1535
|
-
tool: disp.tool,
|
|
1536
|
-
skill: disp.skill,
|
|
1537
|
-
mem: disp.mem,
|
|
1538
|
-
},
|
|
1570
|
+
tokensByKind: buckets,
|
|
1539
1571
|
chips: {
|
|
1540
1572
|
tools: uniqueRecent(allTools, 6),
|
|
1541
1573
|
skills: uniqueRecent(allSkills, 4),
|
|
@@ -1832,6 +1864,9 @@ const escape = escapeHtml
|
|
|
1832
1864
|
const toolLabels = {
|
|
1833
1865
|
codex: 'Codex',
|
|
1834
1866
|
workbuddy: 'WorkBuddy',
|
|
1867
|
+
antigravity: 'Antigravity',
|
|
1868
|
+
'antigravity-app': 'Antigravity App',
|
|
1869
|
+
'antigravity-cli': 'Antigravity CLI',
|
|
1835
1870
|
'claude-code': 'Claude Code',
|
|
1836
1871
|
'claude-ai': 'Claude',
|
|
1837
1872
|
}
|
|
@@ -1910,7 +1945,7 @@ function thumbs(names, baseUrl = '') {
|
|
|
1910
1945
|
if (!names?.length) return ''
|
|
1911
1946
|
return `<span class="session-thumbs">${names.map(name => {
|
|
1912
1947
|
const url = escape(resolveAsset(name, baseUrl))
|
|
1913
|
-
return `<a href="${url}" target="_blank" rel="noopener noreferrer"><img src="${url}" alt="" width="96" loading="lazy"></a>`
|
|
1948
|
+
return `<a href="${url}" data-lightbox-src="${url}" target="_blank" rel="noopener noreferrer"><img src="${url}" alt="" width="96" loading="lazy"></a>`
|
|
1914
1949
|
}).join('')}</span>`
|
|
1915
1950
|
}
|
|
1916
1951
|
|
|
@@ -1984,74 +2019,34 @@ function renderStepArtifacts(stepMeta, { skipImages = [], renderMd, t, baseUrl =
|
|
|
1984
2019
|
function renderTimelineBar(line, t) {
|
|
1985
2020
|
const steps = line.steps || []
|
|
1986
2021
|
const total = steps.length
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
} else if (
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
if (
|
|
2013
|
-
pin.showText = true
|
|
2014
|
-
occupiedPcts.push(pin.pct)
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
for (const pin of rawPins) {
|
|
2018
|
-
if (pin.pinType === 'frame' && canShowText(pin.pct)) {
|
|
2019
|
-
pin.showText = true
|
|
2020
|
-
occupiedPcts.push(pin.pct)
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
for (const pin of rawPins) {
|
|
2024
|
-
if (pin.pinType === 'doc' && canShowText(pin.pct)) {
|
|
2025
|
-
pin.showText = true
|
|
2026
|
-
occupiedPcts.push(pin.pct)
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
if (rawPins.length <= 14) {
|
|
2030
|
-
for (const pin of rawPins) {
|
|
2031
|
-
if (pin.pinType === 'turn' && canShowText(pin.pct)) {
|
|
2032
|
-
pin.showText = true
|
|
2033
|
-
occupiedPcts.push(pin.pct)
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2022
|
+
const pins = []
|
|
2023
|
+
const cells = ['<span class="session-tl-cell"></span>']
|
|
2024
|
+
for (const [idx, step] of steps.entries()) {
|
|
2025
|
+
const frame = step.frames?.find(frame => frame.who === 'ai') || step.frames?.[0]
|
|
2026
|
+
const doc = step.docs?.[0]
|
|
2027
|
+
let kind = ''
|
|
2028
|
+
let label = ''
|
|
2029
|
+
let icon = ''
|
|
2030
|
+
if (step.compactInfo) {
|
|
2031
|
+
kind = 'compress'
|
|
2032
|
+
label = t('tlCompressPin', { seq: step.compactInfo.seq })
|
|
2033
|
+
icon = '🗜'
|
|
2034
|
+
} else if (frame) {
|
|
2035
|
+
kind = 'frame'
|
|
2036
|
+
label = frame.label
|
|
2037
|
+
icon = '🖼'
|
|
2038
|
+
} else if (doc) {
|
|
2039
|
+
kind = 'doc'
|
|
2040
|
+
label = doc.title
|
|
2041
|
+
icon = '📄'
|
|
2042
|
+
} else if (step.kind === 'prompt') {
|
|
2043
|
+
kind = 'turn'
|
|
2044
|
+
label = t('tlPromptTitle', { turn: step.turn, summary: short(step.summary || '', 40) })
|
|
2045
|
+
}
|
|
2046
|
+
cells.push(`<span class="session-tl-cell ${kind}"></span>`)
|
|
2047
|
+
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>`)
|
|
2036
2048
|
}
|
|
2037
2049
|
|
|
2038
|
-
const pinsHtml = rawPins.map(pin => {
|
|
2039
|
-
const text = pin.pinType === 'compress'
|
|
2040
|
-
? (pin.showText ? `🗜 ${escape(short(pin.label, 11))}` : '🗜')
|
|
2041
|
-
: pin.pinType === 'frame'
|
|
2042
|
-
? (pin.showText ? `🖼 ${escape(short(pin.label, 8))}` : '🖼')
|
|
2043
|
-
: pin.pinType === 'doc'
|
|
2044
|
-
? (pin.showText ? `📄 ${escape(short(pin.label, 8))}` : '📄')
|
|
2045
|
-
: (pin.showText ? `💬 #${pin.turn}` : '')
|
|
2046
|
-
const cls = `session-tl-pin is-${pin.pinType}${pin.showText ? ' has-label' : ' is-compact'}`
|
|
2047
|
-
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>`
|
|
2048
|
-
}).join('')
|
|
2049
|
-
|
|
2050
|
-
const segsHtml = steps.map((s, idx) => (
|
|
2051
|
-
`<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>`
|
|
2052
|
-
)).join('')
|
|
2053
|
-
const segGap = total > 360 ? '0px' : total > 160 ? '1px' : '2px'
|
|
2054
|
-
|
|
2055
2050
|
return `<footer class="session-timeline-bar" data-session-timeline aria-label="${escape(t('tlAria'))}">
|
|
2056
2051
|
<div class="session-transport" role="group" aria-label="${escape(t('tlControlsAria'))}">
|
|
2057
2052
|
<button type="button" class="session-nav-btn" data-session-prev disabled aria-label="${escape(t('prevStep'))}">◀</button>
|
|
@@ -2060,10 +2055,12 @@ function renderTimelineBar(line, t) {
|
|
|
2060
2055
|
<span class="session-speed-badge" data-session-speed><b>0</b> / ${total} · 00:00</span>
|
|
2061
2056
|
</div>
|
|
2062
2057
|
<div class="session-tl-track-wrap" data-tl-track>
|
|
2063
|
-
<span class="session-composer-progress" data-session-progress aria-hidden="true"></span>
|
|
2064
2058
|
<div class="session-tl-pop" data-tl-pop hidden></div>
|
|
2065
|
-
|
|
2066
|
-
<div class="session-tl-
|
|
2059
|
+
${pins.length ? `<div class="session-tl-pins">${pins.join('')}</div>` : ''}
|
|
2060
|
+
<div class="session-tl-rail" style="--tl-count:${total + 1}">
|
|
2061
|
+
<div class="session-tl-cells" aria-hidden="true">${cells.join('')}</div>
|
|
2062
|
+
<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'}>
|
|
2063
|
+
</div>
|
|
2067
2064
|
</div>
|
|
2068
2065
|
</footer>`
|
|
2069
2066
|
}
|
|
@@ -2104,9 +2101,19 @@ function renderBrowserCategories(categories = [], t) {
|
|
|
2104
2101
|
}).join('')
|
|
2105
2102
|
}
|
|
2106
2103
|
|
|
2104
|
+
function contextUsageLabel(snapshot, t, opening = false) {
|
|
2105
|
+
if (snapshot.totalTokens == null) return t(opening ? 'initialUsageMissing' : 'usageMissing')
|
|
2106
|
+
if (snapshot.estimated != null) return (snapshot.estimated ? '≈' : '') + snapshot.totalTokens.toLocaleString(t.lang)
|
|
2107
|
+
return (snapshot.totalTokens / 1000).toFixed(1) + 'k'
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
function categoryUsageLabel(value, t) {
|
|
2111
|
+
return value == null ? t('notRecorded') : `≈${(value / 1000).toFixed(1)}k`
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2107
2114
|
function contextSidebar(line, t) {
|
|
2108
2115
|
const initial = line.initialSnapshot
|
|
2109
|
-
const tok = n =>
|
|
2116
|
+
const tok = n => categoryUsageLabel(n, t)
|
|
2110
2117
|
return `<aside class="session-context-aside" aria-label="${escape(t('activeContext'))}" data-session-aside>
|
|
2111
2118
|
<section class="sp-aside-sec" aria-label="${escape(t('activeContext'))}">
|
|
2112
2119
|
<div class="sp-sec-head">
|
|
@@ -2114,22 +2121,13 @@ function contextSidebar(line, t) {
|
|
|
2114
2121
|
<span class="sp-sec-snap" data-context-snap>${escape(t('snapInitial'))}</span>
|
|
2115
2122
|
</div>
|
|
2116
2123
|
<div class="lc-overview-num">
|
|
2117
|
-
<b data-context-tot>${escape((initial
|
|
2118
|
-
<span>/ <span data-context-win>${escape(initial.windowLabel || '
|
|
2119
|
-
<span class="lc-overview-pct"><b data-context-pct>${
|
|
2124
|
+
<b data-context-tot>${escape(contextUsageLabel(initial, t, true))}</b>
|
|
2125
|
+
<span>/ <span data-context-win>${escape(initial.windowLabel || t('unknownCapacity'))}</span><span data-capacity-unit${initial.windowLabel ? '' : ' hidden'}> tokens</span></span>
|
|
2126
|
+
<span class="lc-overview-pct"${initial.pct == null ? ' hidden' : ''}><b data-context-pct>${initial.pct == null ? '' : initial.pct + '%'}</b>${escape(t('usedSuffix'))}</span>
|
|
2120
2127
|
</div>
|
|
2121
|
-
<div class="lc-stacked" data-stacked-bar>
|
|
2122
|
-
|
|
2123
|
-
<div class="lc-stacked-seg is-schema" data-seg="schema" data-cat-key="schema" style="width:${initial.segments.schema}%"></div>
|
|
2124
|
-
<div class="lc-stacked-seg is-user" data-seg="user" data-cat-key="user" style="width:${initial.segments.user}%"></div>
|
|
2125
|
-
<div class="lc-stacked-seg is-mem" data-seg="mem" data-cat-key="mem" style="width:${initial.segments.mem}%"></div>
|
|
2126
|
-
<div class="lc-stacked-seg is-skill" data-seg="skill" data-cat-key="skill" style="width:${initial.segments.skill}%"></div>
|
|
2127
|
-
<div class="lc-stacked-seg is-msg" data-seg="msg" data-cat-key="msg" style="width:${initial.segments.msg}%"></div>
|
|
2128
|
-
<div class="lc-stacked-seg is-tool" data-seg="tool" data-cat-key="tool" style="width:${initial.segments.tool}%"></div>
|
|
2128
|
+
<div class="lc-stacked" data-stacked-bar${initial.pct == null ? ' hidden' : ''}>
|
|
2129
|
+
${Object.entries(initial.segments).map(([key, width]) => `<div class="lc-stacked-seg is-${escape(key)}" data-seg="${escape(key)}"${key === 'used' ? '' : ` data-cat-key="${escape(key)}"`} style="width:${Number(width)}%"></div>`).join('')}
|
|
2129
2130
|
<div class="lc-stacked-free" title="${escape(t('freeSpaceTitle'))}"></div>
|
|
2130
|
-
<div class="lc-trigger" style="left:80%" title="${escape(t('autoCompactTriggerTitle'))}"></div>
|
|
2131
|
-
<div class="lc-reserve lc-reserve-headroom" style="left:80%;width:12%" title="${escape(t('headroomTitle'))}"></div>
|
|
2132
|
-
<div class="lc-reserve lc-reserve-output" style="left:92%;width:8%" title="${escape(t('outputReserveTitle'))}"></div>
|
|
2133
2131
|
</div>
|
|
2134
2132
|
<div class="lc-legend" data-lc-legend>
|
|
2135
2133
|
<span class="lc-chip" data-cat-key="sys"><i class="session-cat-dot is-sys"></i><span class="lc-chip-label">${escape(t('legendSys'))}</span><span class="lc-chip-nums" data-pro-tok="sys">${escape(tok(initial.tokensByKind.sys))}</span></span>
|
|
@@ -2280,9 +2278,10 @@ function renderLog(session, line, { t, baseUrl = '' }) {
|
|
|
2280
2278
|
const postK = ci.postTokens ? `${(ci.postTokens / 1000).toFixed(1)}k` : ''
|
|
2281
2279
|
const dropK = ci.droppedTokens ? `${(ci.droppedTokens / 1000).toFixed(1)}k` : ''
|
|
2282
2280
|
const tpl = ci.docId && ci.content ? `<template data-doc-html="${escape(ci.docId)}">${render(ci.content)}</template>` : ''
|
|
2283
|
-
const badgeText = ci.trigger === 'manual' ? t('compactManual') : ci.trigger === 'handoff' ? t('compactHandoff') : t('compactAuto')
|
|
2281
|
+
const badgeText = !ci.trigger ? '' : ci.trigger === 'manual' ? t('compactManual') : ci.trigger === 'handoff' ? t('compactHandoff') : t('compactAuto')
|
|
2282
|
+
const eventTime = item.time ? `<time datetime="${escape(item.time)}">${escape(wallClock(item.time, 0, true))}</time>` : ''
|
|
2284
2283
|
const freedText = dropK ? t('compactFreed', { tokens: dropK }) : ''
|
|
2285
|
-
entries.push(`${stamp(item.t, stepIndex - 1)}<li class="session-entry session-compact" data-step="${stepIndex - 1}" data-echo-cat="tool" data-kind="compact" data-t="${item.t}"><div class="session-compact-card"><span class="session-compact-icon" aria-hidden="true">🗜</span><div class="session-compact-main"><div class="session-compact-head"><b>${escape(t('compactTitle', { seq: ci.seq || 1 }))}</b
|
|
2284
|
+
entries.push(`${stamp(item.t, stepIndex - 1)}<li class="session-entry session-compact" data-step="${stepIndex - 1}" data-echo-cat="tool" data-kind="compact" data-t="${item.t}"><div class="session-compact-card"><span class="session-compact-icon" aria-hidden="true">🗜</span><div class="session-compact-main"><div class="session-compact-head"><b>${escape(t('compactTitle', { seq: ci.seq || 1 }))}</b>${eventTime}${badgeText ? `<span class="session-compact-tag">${escape(badgeText)}</span>` : ''}${preK && postK ? `<span class="session-compact-meter">${escape(preK)} → ${escape(postK)}${escape(freedText)}</span>` : ''}</div>${ci.archivedTools != null ? `<p class="session-compact-desc">${escape(t('compactDesc', { count: ci.archivedTools }))}</p>` : ''}</div>${ci.docId ? `<button type="button" class="session-compact-btn" data-doc-open="${escape(ci.docId)}" data-doc-title="${escape(ci.title || t('compactModalTitle'))}">${escape(t('compactViewBtn'))}</button>${tpl}` : ''}</div></li>`)
|
|
2286
2285
|
} else {
|
|
2287
2286
|
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>`)
|
|
2288
2287
|
}
|
|
@@ -2561,11 +2560,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2561
2560
|
const stageTrigger = containerEl.querySelector('[data-session-stage-trigger]')
|
|
2562
2561
|
const composerText = containerEl.querySelector('[data-session-composer-text]')
|
|
2563
2562
|
const sendBtn = containerEl.querySelector('[data-session-send]')
|
|
2564
|
-
const progressBar = containerEl.querySelector('[data-session-progress]')
|
|
2565
2563
|
const timelineBar = containerEl.querySelector('[data-session-timeline]')
|
|
2566
2564
|
const tlTrack = timelineBar?.querySelector('[data-tl-track]')
|
|
2567
2565
|
const tlPop = timelineBar?.querySelector('[data-tl-pop]')
|
|
2568
|
-
const
|
|
2566
|
+
const tlRange = tlTrack?.querySelector('[data-tl-range]')
|
|
2567
|
+
const cells = tlTrack?.querySelector('.session-tl-cells')?.children
|
|
2569
2568
|
const tlPins = timelineBar ? [...timelineBar.querySelectorAll('[data-tl-jump]')] : []
|
|
2570
2569
|
const lightbox = containerEl.querySelector('[data-session-lightbox]')
|
|
2571
2570
|
const lightboxImg = lightbox?.querySelector('[data-lightbox-img]')
|
|
@@ -2591,8 +2590,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2591
2590
|
let curTime = 0
|
|
2592
2591
|
let playHead = initialStep
|
|
2593
2592
|
let prevRenderedHead = initialStep
|
|
2594
|
-
let selectedIdx = initialStep
|
|
2595
|
-
let userClickedInspect = false
|
|
2596
2593
|
let isInitialMount = true
|
|
2597
2594
|
let playing = false
|
|
2598
2595
|
let stepBusy = false
|
|
@@ -2714,13 +2711,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2714
2711
|
stepBusy = false
|
|
2715
2712
|
}
|
|
2716
2713
|
|
|
2717
|
-
function updateProgressHairline(idx = playHead) {
|
|
2718
|
-
if (!progressBar) return
|
|
2719
|
-
const ratio = steps.length > 0 && idx >= 0 ? Math.max(0, Math.min(1, (idx + 0.5) / steps.length)) : 0
|
|
2720
|
-
progressBar.style.opacity = idx >= 0 || playing ? '1' : '0'
|
|
2721
|
-
progressBar.style.transform = `scaleX(${ratio.toFixed(4)})`
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
2714
|
function rawPromptTextOf(stepIdx) {
|
|
2725
2715
|
const step = steps[stepIdx]
|
|
2726
2716
|
if (!step || step.kind !== 'prompt') return ''
|
|
@@ -2800,10 +2790,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2800
2790
|
return idx < 0 ? buildPrePromptStep() : model.selectStep(idx)
|
|
2801
2791
|
}
|
|
2802
2792
|
|
|
2803
|
-
function currentSelectedState() {
|
|
2804
|
-
return stateForIndex(selectedIdx)
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
2793
|
if (play) play.hidden = false
|
|
2808
2794
|
attachAttachmentReaders(containerEl, t, () => { if (playing) setPlaying(false) })
|
|
2809
2795
|
if (log) log.classList.add('is-staged')
|
|
@@ -2849,10 +2835,9 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2849
2835
|
|
|
2850
2836
|
function applyEchoHighlight() {
|
|
2851
2837
|
if (!asidePane) return
|
|
2852
|
-
|
|
2853
|
-
stackedBar?.classList.toggle('lc-stacked-dim', Boolean(activeKey))
|
|
2838
|
+
stackedBar?.classList.toggle('lc-stacked-dim', Boolean(hoverCat))
|
|
2854
2839
|
asidePane.querySelectorAll('[data-cat-key]').forEach(el => {
|
|
2855
|
-
const match =
|
|
2840
|
+
const match = hoverCat && el.dataset.catKey === hoverCat
|
|
2856
2841
|
el.classList.toggle('lc-stacked-seg-on', Boolean(match && el.classList.contains('lc-stacked-seg')))
|
|
2857
2842
|
el.classList.toggle('lc-chip-on', Boolean(match && el.classList.contains('lc-chip')))
|
|
2858
2843
|
})
|
|
@@ -2865,6 +2850,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2865
2850
|
entry.addEventListener('click', event => {
|
|
2866
2851
|
const lbBtn = event.target.closest('[data-lightbox-src]')
|
|
2867
2852
|
if (lbBtn && lightbox && lightboxImg) {
|
|
2853
|
+
event.preventDefault()
|
|
2868
2854
|
event.stopPropagation()
|
|
2869
2855
|
if (playing) setPlaying(false)
|
|
2870
2856
|
lightbox.classList.remove('is-doc')
|
|
@@ -2902,18 +2888,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2902
2888
|
}
|
|
2903
2889
|
if (event.target.closest('a, audio, video, summary, button')) return
|
|
2904
2890
|
if (stepIndex > playHead) return
|
|
2905
|
-
|
|
2906
|
-
const step = steps[stepIndex]
|
|
2907
|
-
selectedIdx = stepIndex
|
|
2908
|
-
userClickedInspect = true
|
|
2909
|
-
openCat = step?.primaryCat || null
|
|
2910
|
-
follow = false
|
|
2911
|
-
render()
|
|
2912
|
-
if (openCat) {
|
|
2913
|
-
requestAnimationFrame(() => {
|
|
2914
|
-
asidePane?.querySelector(`[data-browser-cat="${openCat}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
|
2915
|
-
})
|
|
2916
|
-
}
|
|
2891
|
+
jumpToStep(stepIndex)
|
|
2917
2892
|
})
|
|
2918
2893
|
entry.addEventListener('mouseenter', () => {
|
|
2919
2894
|
if (stepIndex > playHead) return
|
|
@@ -2934,18 +2909,23 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2934
2909
|
if (snapLabel) {
|
|
2935
2910
|
if (stepState.index < 0) {
|
|
2936
2911
|
snapLabel.textContent = t('snapInitial')
|
|
2937
|
-
} else if (selectedIdx < playHead) {
|
|
2938
|
-
snapLabel.textContent = t('snapInspect', { step: stepState.index + 1, total: steps.length })
|
|
2939
2912
|
} else {
|
|
2940
2913
|
snapLabel.textContent = t('snapCurrent', { step: stepState.index + 1, total: steps.length })
|
|
2941
2914
|
}
|
|
2942
2915
|
}
|
|
2943
2916
|
const totEl = asidePane.querySelector('[data-context-tot]')
|
|
2944
|
-
if (totEl) totEl.textContent =
|
|
2917
|
+
if (totEl) totEl.textContent = contextUsageLabel(snap, t, stepState.index < 0)
|
|
2945
2918
|
const winEl = asidePane.querySelector('[data-context-win]')
|
|
2946
|
-
if (winEl
|
|
2919
|
+
if (winEl) winEl.textContent = snap.windowLabel || t('unknownCapacity')
|
|
2920
|
+
const unit = asidePane.querySelector('[data-capacity-unit]')
|
|
2921
|
+
if (unit) unit.hidden = !snap.windowLabel
|
|
2947
2922
|
const pctEl = asidePane.querySelector('[data-context-pct]')
|
|
2948
|
-
if (pctEl)
|
|
2923
|
+
if (pctEl) {
|
|
2924
|
+
pctEl.parentElement.hidden = snap.pct == null
|
|
2925
|
+
pctEl.textContent = snap.pct == null ? '' : snap.pct + '%'
|
|
2926
|
+
}
|
|
2927
|
+
const bar = asidePane.querySelector('[data-stacked-bar]')
|
|
2928
|
+
if (bar) bar.hidden = snap.pct == null
|
|
2949
2929
|
|
|
2950
2930
|
for (const [key, val] of Object.entries(snap.segments || {})) {
|
|
2951
2931
|
const seg = asidePane.querySelector(`[data-seg="${key}"]`)
|
|
@@ -2954,7 +2934,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
2954
2934
|
|
|
2955
2935
|
for (const [key, val] of Object.entries(snap.tokensByKind || {})) {
|
|
2956
2936
|
const tokEl = asidePane.querySelector(`[data-pro-tok="${key}"]`)
|
|
2957
|
-
if (tokEl) tokEl.textContent =
|
|
2937
|
+
if (tokEl) tokEl.textContent = categoryUsageLabel(val, t)
|
|
2958
2938
|
}
|
|
2959
2939
|
|
|
2960
2940
|
const browserBox = asidePane.querySelector('[data-context-browser]')
|
|
@@ -3036,22 +3016,24 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3036
3016
|
if (event.target === lightbox) closeLightbox()
|
|
3037
3017
|
})
|
|
3038
3018
|
|
|
3019
|
+
let hoverStep = null
|
|
3039
3020
|
function renderTimelineHover(idx) {
|
|
3040
|
-
if (!tlPop) return
|
|
3021
|
+
if (!tlPop || hoverStep === idx) return
|
|
3022
|
+
hoverStep = idx
|
|
3041
3023
|
if (idx === null || idx < 0 || idx >= steps.length) {
|
|
3042
3024
|
tlPop.hidden = true
|
|
3043
3025
|
return
|
|
3044
3026
|
}
|
|
3045
3027
|
const s = steps[idx]
|
|
3046
3028
|
const pct = steps.length > 0 ? Math.min(88, Math.max(12, ((idx + 0.5) / steps.length) * 100)) : 50
|
|
3047
|
-
const frame = s.frames?.[0]
|
|
3029
|
+
const frame = s.frames?.find(frame => frame.who === 'ai') || s.frames?.[0]
|
|
3048
3030
|
const doc = s.docs?.[0]
|
|
3049
3031
|
const ci = s.compactInfo
|
|
3050
3032
|
const thumbHtml = frame
|
|
3051
3033
|
? `<span class="session-tl-pop-thumb"><img src="${escapeHtml(frame.img)}" alt=""></span>`
|
|
3052
3034
|
: ''
|
|
3053
3035
|
const headTitle = ci
|
|
3054
|
-
? t('tlCompressTitle', { seq: ci.seq, dropped: (
|
|
3036
|
+
? (ci.droppedTokens == null ? t('compactTitle', { seq: ci.seq }) : t('tlCompressTitle', { seq: ci.seq, dropped: (ci.droppedTokens / 1000).toFixed(0) }))
|
|
3055
3037
|
: frame
|
|
3056
3038
|
? `🖼 ${frame.label}`
|
|
3057
3039
|
: doc
|
|
@@ -3059,51 +3041,76 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3059
3041
|
: s.kind === 'prompt'
|
|
3060
3042
|
? t('tlPromptTitle', { turn: s.turn, summary: shorten(s.summary || '', 20) })
|
|
3061
3043
|
: shorten(s.summary || t('tlStepFallback'), 24)
|
|
3062
|
-
const tokStr =
|
|
3063
|
-
tlPop.style.left =
|
|
3064
|
-
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'))}
|
|
3044
|
+
const tokStr = contextUsageLabel(s.contextSnapshot, t)
|
|
3045
|
+
tlPop.style.left = `clamp(min(130px, 50%), ${pct.toFixed(1)}%, max(50%, 100% - 130px))`
|
|
3046
|
+
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>`
|
|
3065
3047
|
tlPop.hidden = false
|
|
3066
3048
|
}
|
|
3067
3049
|
|
|
3068
|
-
function
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3050
|
+
function jumpToStep(idx) {
|
|
3051
|
+
setPlaying(false)
|
|
3052
|
+
// A seek shows the completed Step immediately, including a one-Step jump.
|
|
3053
|
+
prevRenderedHead = idx
|
|
3054
|
+
goToStage(idx)
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
function seekFromTimeline(idx) {
|
|
3058
|
+
const before = tlTrack.getBoundingClientRect()
|
|
3059
|
+
jumpToStep(idx)
|
|
3060
|
+
// On mobile the context list sits above the rail and can grow by several screens.
|
|
3061
|
+
if (before.top >= 0 && before.bottom <= window.innerHeight) {
|
|
3062
|
+
const delta = tlTrack.getBoundingClientRect().top - before.top
|
|
3063
|
+
if (delta) window.scrollBy({ top: delta, behavior: 'instant' })
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
const priority = { compress: 0, frame: 1, doc: 2, turn: 3 }
|
|
3068
|
+
const labelOrder = [...tlPins].sort((a, b) => priority[a.dataset.kind] - priority[b.dataset.kind])
|
|
3069
|
+
function fitTimelineLabels() {
|
|
3070
|
+
const width = tlTrack.clientWidth
|
|
3071
|
+
const occupied = []
|
|
3072
|
+
// Fit full captions first. A crowded milestone can still appear as an icon.
|
|
3073
|
+
for (const pin of labelOrder) pin.classList.remove('is-visible', 'is-compact')
|
|
3074
|
+
for (const compact of [false, true]) {
|
|
3075
|
+
const candidates = labelOrder.filter(pin => !pin.classList.contains('is-visible') && (compact || pin.dataset.kind !== 'turn'))
|
|
3076
|
+
for (const pin of candidates) pin.classList.toggle('is-compact', compact)
|
|
3077
|
+
const measured = candidates.map(pin => ({ pin, size: pin.offsetWidth }))
|
|
3078
|
+
for (const { pin, size } of measured) {
|
|
3079
|
+
const anchor = (Number(pin.dataset.tlJump) + 1.5) / (steps.length + 1) * width
|
|
3080
|
+
const left = Math.max(0, Math.min(width - size, anchor - size / 2))
|
|
3081
|
+
const right = left + size
|
|
3082
|
+
if (right > width || occupied.some(span => right + 4 > span.left && left < span.right + 4)) continue
|
|
3083
|
+
pin.style.left = `${left}px`
|
|
3084
|
+
pin.classList.add('is-visible')
|
|
3085
|
+
occupied.push({ left, right })
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
const labelObserver = tlPins.length ? new ResizeObserver(fitTimelineLabels) : null
|
|
3091
|
+
if (labelObserver) labelObserver.observe(tlTrack)
|
|
3092
|
+
tlRange?.addEventListener('input', () => seekFromTimeline(tlRange.valueAsNumber - 1))
|
|
3093
|
+
tlRange?.addEventListener('pointerdown', () => { if (playing) setPlaying(false) })
|
|
3094
|
+
tlTrack?.addEventListener('pointermove', event => {
|
|
3095
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3096
|
+
if (pin) return renderTimelineHover(Number(pin.dataset.tlJump))
|
|
3097
|
+
if (event.target !== tlRange || !steps.length) return renderTimelineHover(null)
|
|
3098
|
+
const rect = tlRange.getBoundingClientRect()
|
|
3099
|
+
const step = Math.floor((event.clientX - rect.left) / rect.width * (steps.length + 1))
|
|
3100
|
+
renderTimelineHover(Math.max(0, Math.min(steps.length - 1, step - 1)))
|
|
3100
3101
|
})
|
|
3101
|
-
tlTrack?.addEventListener('
|
|
3102
|
+
tlTrack?.addEventListener('focusin', event => {
|
|
3103
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3104
|
+
renderTimelineHover(pin ? Number(pin.dataset.tlJump) : playHead)
|
|
3105
|
+
})
|
|
3106
|
+
tlTrack?.addEventListener('focusout', () => renderTimelineHover(null))
|
|
3107
|
+
tlTrack?.addEventListener('keydown', event => {
|
|
3108
|
+
if (event.key === 'Escape') renderTimelineHover(null)
|
|
3109
|
+
})
|
|
3110
|
+
tlTrack?.addEventListener('pointerleave', () => renderTimelineHover(null))
|
|
3102
3111
|
tlTrack?.addEventListener('click', event => {
|
|
3103
|
-
const
|
|
3104
|
-
if (
|
|
3105
|
-
const idx = Number(el.dataset.tlJump ?? el.dataset.tlStep)
|
|
3106
|
-
if (Number.isFinite(idx)) jumpViaTimeline(idx)
|
|
3112
|
+
const pin = event.target.closest('[data-tl-jump]')
|
|
3113
|
+
if (pin) seekFromTimeline(Number(pin.dataset.tlJump))
|
|
3107
3114
|
})
|
|
3108
3115
|
|
|
3109
3116
|
asidePane?.addEventListener('click', event => {
|
|
@@ -3133,7 +3140,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3133
3140
|
if (chipOrSeg) {
|
|
3134
3141
|
const catId = chipOrSeg.dataset.catKey
|
|
3135
3142
|
openCat = openCat === catId ? null : catId
|
|
3136
|
-
renderContextSidebar(
|
|
3143
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
3137
3144
|
asidePane.querySelector(`[data-browser-cat="${catId}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
|
3138
3145
|
return
|
|
3139
3146
|
}
|
|
@@ -3141,7 +3148,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3141
3148
|
if (catBtn && !catBtn.disabled) {
|
|
3142
3149
|
const catId = catBtn.dataset.browserCatToggle
|
|
3143
3150
|
openCat = openCat === catId ? null : catId
|
|
3144
|
-
renderContextSidebar(
|
|
3151
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
3145
3152
|
return
|
|
3146
3153
|
}
|
|
3147
3154
|
const itemBtn = event.target.closest('[data-browser-item-toggle]')
|
|
@@ -3149,7 +3156,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3149
3156
|
const itemId = itemBtn.dataset.browserItemToggle
|
|
3150
3157
|
if (openItems.has(itemId)) openItems.delete(itemId)
|
|
3151
3158
|
else openItems.add(itemId)
|
|
3152
|
-
renderContextSidebar(
|
|
3159
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
3153
3160
|
}
|
|
3154
3161
|
})
|
|
3155
3162
|
|
|
@@ -3378,7 +3385,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3378
3385
|
}
|
|
3379
3386
|
|
|
3380
3387
|
function runHeadChoreography(headState, headEntry, animateNewStep, steppedForwardOne) {
|
|
3381
|
-
updateProgressHairline()
|
|
3382
3388
|
if (!animateNewStep) return
|
|
3383
3389
|
clearStepAnimations()
|
|
3384
3390
|
|
|
@@ -3422,7 +3428,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3422
3428
|
if (headState.kind === 'compact') {
|
|
3423
3429
|
setComposerVisual('running')
|
|
3424
3430
|
openCat = 'tool'
|
|
3425
|
-
renderContextSidebar(
|
|
3431
|
+
renderContextSidebar(stateForIndex(playHead))
|
|
3426
3432
|
if (headEntry && !calm.matches && typeof headEntry.animate === 'function') {
|
|
3427
3433
|
activeAnims.push(headEntry.animate(
|
|
3428
3434
|
[
|
|
@@ -3451,7 +3457,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3451
3457
|
|
|
3452
3458
|
function render() {
|
|
3453
3459
|
const headState = stateForIndex(playHead)
|
|
3454
|
-
const selectedState = currentSelectedState()
|
|
3455
3460
|
curTime = headState.index < 0 ? 0 : headState.t
|
|
3456
3461
|
const x = (playerData.end > 0 ? ((curTime / playerData.end) * width) : 0).toFixed(1)
|
|
3457
3462
|
if (head) {
|
|
@@ -3472,45 +3477,26 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3472
3477
|
play.setAttribute('aria-label', atEnd ? t('replayAria') : t('playAria'))
|
|
3473
3478
|
}
|
|
3474
3479
|
|
|
3475
|
-
renderContextSidebar(
|
|
3476
|
-
const
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3480
|
+
renderContextSidebar(headState)
|
|
3481
|
+
const stepNumber = playHead + 1
|
|
3482
|
+
if (speedBadge) speedBadge.innerHTML = `<b>${stepNumber}</b> / ${steps.length} · ${elapsedClock(curTime)}`
|
|
3483
|
+
if (tlRange) {
|
|
3484
|
+
tlRange.value = String(stepNumber)
|
|
3485
|
+
tlRange.setAttribute('aria-valuetext', t('tlStepMeta', { step: stepNumber, time: elapsedClock(curTime) }))
|
|
3481
3486
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
})
|
|
3487
|
+
if (cells) {
|
|
3488
|
+
for (let i = 0; i < cells.length; i++) {
|
|
3489
|
+
cells[i].classList.toggle('is-past', i > 0 && i < stepNumber)
|
|
3490
|
+
cells[i].classList.toggle('is-active', i === stepNumber)
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
if (tlRange?.matches(':focus-visible')) renderTimelineHover(playHead)
|
|
3494
|
+
for (const pin of tlPins) pin.classList.toggle('is-on', Number(pin.dataset.tlJump) === playHead)
|
|
3491
3495
|
|
|
3492
3496
|
let latestVisibleEntry
|
|
3493
3497
|
for (const item of stepEntries) {
|
|
3494
3498
|
const future = item.stepIndex > playHead
|
|
3495
3499
|
item.entry.classList.toggle('is-future', future)
|
|
3496
|
-
const isInspectSelected = !future && userClickedInspect && item.stepIndex === selectedIdx
|
|
3497
|
-
item.entry.classList.toggle('is-selected', isInspectSelected)
|
|
3498
|
-
|
|
3499
|
-
let tag = item.entry.querySelector('.session-inspect-tag')
|
|
3500
|
-
if (isInspectSelected) {
|
|
3501
|
-
if (!tag) {
|
|
3502
|
-
tag = document.createElement('span')
|
|
3503
|
-
tag.className = 'session-inspect-tag'
|
|
3504
|
-
item.entry.prepend(tag)
|
|
3505
|
-
}
|
|
3506
|
-
const stTime = steps[selectedIdx]?.t || 0
|
|
3507
|
-
tag.textContent = t.lang === 'en'
|
|
3508
|
-
? `Snapshot #${selectedIdx + 1} · ${elapsedClock(stTime)}`
|
|
3509
|
-
: `快照 #${selectedIdx + 1} · ${elapsedClock(stTime)}`
|
|
3510
|
-
} else if (tag) {
|
|
3511
|
-
tag.remove()
|
|
3512
|
-
}
|
|
3513
|
-
|
|
3514
3500
|
if (!future) latestVisibleEntry = item.entry
|
|
3515
3501
|
}
|
|
3516
3502
|
for (const aux of auxEntries) {
|
|
@@ -3544,8 +3530,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3544
3530
|
activate()
|
|
3545
3531
|
if (shouldScroll) camera.resumeFollow()
|
|
3546
3532
|
playHead = Math.max(-1, Math.min(steps.length - 1, nextIdx))
|
|
3547
|
-
selectedIdx = playHead
|
|
3548
|
-
userClickedInspect = false
|
|
3549
3533
|
openCat = playHead < 0 ? null : (steps[playHead]?.primaryCat || null)
|
|
3550
3534
|
follow = shouldScroll
|
|
3551
3535
|
animatedHead = -2
|
|
@@ -3569,7 +3553,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3569
3553
|
const nextDraft = next?.kind === 'prompt' ? rawPromptTextOf(next.index) : ''
|
|
3570
3554
|
if (nextDraft) setComposerVisual('draft', nextDraft)
|
|
3571
3555
|
else setComposerVisual('idle')
|
|
3572
|
-
updateProgressHairline()
|
|
3573
3556
|
return
|
|
3574
3557
|
}
|
|
3575
3558
|
activate()
|
|
@@ -3578,19 +3561,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3578
3561
|
clearStepAnimations()
|
|
3579
3562
|
playHead = -1
|
|
3580
3563
|
prevRenderedHead = -1
|
|
3581
|
-
selectedIdx = -1
|
|
3582
|
-
userClickedInspect = false
|
|
3583
3564
|
openCat = null
|
|
3584
3565
|
follow = true
|
|
3585
3566
|
animatedHead = -1
|
|
3586
3567
|
render()
|
|
3587
3568
|
}
|
|
3588
|
-
if (selectedIdx < playHead) {
|
|
3589
|
-
selectedIdx = playHead
|
|
3590
|
-
userClickedInspect = false
|
|
3591
|
-
openCat = steps[playHead]?.primaryCat || null
|
|
3592
|
-
render()
|
|
3593
|
-
}
|
|
3594
3569
|
if (!stepBusy) {
|
|
3595
3570
|
if (playHead < 0) {
|
|
3596
3571
|
const firstDraft = steps[0]?.kind === 'prompt' ? rawPromptTextOf(0) : ''
|
|
@@ -3691,6 +3666,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
|
|
|
3691
3666
|
destroy() {
|
|
3692
3667
|
clearStepAnimations()
|
|
3693
3668
|
camera.stop()
|
|
3669
|
+
labelObserver?.disconnect()
|
|
3694
3670
|
appEl.removeEventListener('keydown', onKeyDown)
|
|
3695
3671
|
},
|
|
3696
3672
|
goToStage,
|
|
@@ -3718,6 +3694,10 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
|
|
|
3718
3694
|
const appNode = el.querySelector('.session-app')
|
|
3719
3695
|
const activeLang = resolveLang(options.lang || el.dataset.lang || appNode?.dataset.encoreLang || 'zh')
|
|
3720
3696
|
const playerData = JSON.parse(preRenderedData.textContent)
|
|
3697
|
+
const footer = el.querySelector('[data-session-timeline]')
|
|
3698
|
+
if (footer && !footer.querySelector('.session-tl-cells')) {
|
|
3699
|
+
footer.outerHTML = renderTimelineBar(playerData, createTranslator(activeLang))
|
|
3700
|
+
}
|
|
3721
3701
|
const activeController = attachPlayerController(el, playerData, {
|
|
3722
3702
|
lang: activeLang,
|
|
3723
3703
|
initialStep: options.initialStep ?? -1,
|
|
@@ -3760,7 +3740,7 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
|
|
|
3760
3740
|
if (activeController) activeController.destroy()
|
|
3761
3741
|
activeLang = resolveLang(lang)
|
|
3762
3742
|
const line = timeline(session, { lang: activeLang })
|
|
3763
|
-
el.innerHTML = renderPlayerWidget(session, line, { lang: activeLang, baseUrl
|
|
3743
|
+
el.innerHTML = renderPlayerWidget(session, line, { ...options, lang: activeLang, baseUrl })
|
|
3764
3744
|
if (session.title && document.querySelectorAll('[data-encore-player]').length <= 1) {
|
|
3765
3745
|
document.title = `${session.title} · Encore`
|
|
3766
3746
|
}
|