@niracler/encore 0.3.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.
@@ -52,7 +52,6 @@ const DICTS = {
52
52
  emptyHintEnd: ',体验完整对话与上下文生长',
53
53
  activeContext: '上下文快照',
54
54
  snapInitial: '初始上下文',
55
- snapInspect: '回看:第 {step} / {total} 步',
56
55
  snapCurrent: '第 {step} / {total} 步',
57
56
  usedSuffix: '已用',
58
57
  freeSpaceTitle: '剩余窗口 (Free Space)',
@@ -190,7 +189,6 @@ const DICTS = {
190
189
  emptyHintEnd: ' to replay the conversation and live context growth',
191
190
  activeContext: 'Context Snapshot',
192
191
  snapInitial: 'Initial Context',
193
- snapInspect: 'Inspecting: Step {step} / {total}',
194
192
  snapCurrent: 'Step {step} / {total}',
195
193
  usedSuffix: 'used',
196
194
  freeSpaceTitle: 'Free Context Space',
@@ -256,7 +254,7 @@ const DICTS = {
256
254
  tlControlsAria: 'Playback controls',
257
255
  tlJumpAria: 'Jump to step {step}: {label}',
258
256
  tlStepMeta: 'Step {step} · {time}',
259
- tlCompressPin: 'Compact #{seq}',
257
+ tlCompressPin: 'Compaction #{seq}',
260
258
  tlCompressTitle: '🗜 Compaction #{seq} (-{dropped}k)',
261
259
  tlPromptTitle: '💬 Turn #{turn}: {summary}',
262
260
  tlStepFallback: 'Step details',
@@ -973,16 +971,23 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
973
971
  return entry
974
972
  }
975
973
 
976
- const sysRecords = (initCtx.sys?.length ? initCtx.sys : defaultSystemPrompts(sessionTool)).map(r => registerRecord({ ...r, stepIndex: -1 }))
977
- const schemaRecords = (initCtx.schema?.length ? initCtx.schema : defaultToolSchemas(sessionTool)).map(r => registerRecord({ ...r, stepIndex: -1 }))
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)
978
983
  const schemaIdSet = new Set(schemaRecords.map(r => r.id))
979
984
  for (const r of schemaRecords) if (r.title) schemaIdSet.add(`schema-dyn-${String(r.title).replace(/[^a-zA-Z0-9_-]/g, '_')}`)
980
985
  const userRecords = []
981
986
  let toolRecords = []
982
- const skillRecords = (initCtx.skill?.length ? initCtx.skill : defaultSkillCatalog()).map(r => registerRecord({ ...r, stepIndex: -1 }))
987
+ const skillRecords = initialRecords('skill', defaultSkillCatalog)
983
988
  const knownSkillNames = new Set(skillRecords.map(r => r.title).filter(Boolean))
984
989
  const msgRecords = []
985
- const memRecords = (initCtx.mem?.length ? initCtx.mem : defaultInjectedContext(sessionTool, sessionStart)).map(r => registerRecord({ ...r, stepIndex: -1 }))
990
+ const memRecords = initialRecords('mem', defaultInjectedContext)
986
991
 
987
992
  const sumTokEst = list => list.reduce((acc, r) => acc + (r.tokEst || 600), 0)
988
993
  const sysTokens = sumTokEst(sysRecords)
@@ -997,7 +1002,7 @@ function buildSteps(items, end, sessionTool = 'codex', sessionModel = '', frames
997
1002
  let uncalibratedDelta = 0
998
1003
  const allTools = []
999
1004
  const allSkills = []
1000
- const allMemories = ['AGENTS.md']
1005
+ const allMemories = observedOnly ? [] : ['AGENTS.md']
1001
1006
  const allChanges = []
1002
1007
  let latestUserPrompt = ''
1003
1008
  let toolSeq = 0
@@ -1832,6 +1837,9 @@ const escape = escapeHtml
1832
1837
  const toolLabels = {
1833
1838
  codex: 'Codex',
1834
1839
  workbuddy: 'WorkBuddy',
1840
+ antigravity: 'Antigravity',
1841
+ 'antigravity-app': 'Antigravity App',
1842
+ 'antigravity-cli': 'Antigravity CLI',
1835
1843
  'claude-code': 'Claude Code',
1836
1844
  'claude-ai': 'Claude',
1837
1845
  }
@@ -1910,7 +1918,7 @@ function thumbs(names, baseUrl = '') {
1910
1918
  if (!names?.length) return ''
1911
1919
  return `<span class="session-thumbs">${names.map(name => {
1912
1920
  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>`
1921
+ return `<a href="${url}" data-lightbox-src="${url}" target="_blank" rel="noopener noreferrer"><img src="${url}" alt="" width="96" loading="lazy"></a>`
1914
1922
  }).join('')}</span>`
1915
1923
  }
1916
1924
 
@@ -1984,74 +1992,34 @@ function renderStepArtifacts(stepMeta, { skipImages = [], renderMd, t, baseUrl =
1984
1992
  function renderTimelineBar(line, t) {
1985
1993
  const steps = line.steps || []
1986
1994
  const total = steps.length
1987
- const rawPins = []
1988
- steps.forEach((s, idx) => {
1989
- const pct = total > 0 ? ((idx + 0.5) / total) * 100 : 0
1990
- if (s.compactInfo) {
1991
- const droppedK = ((s.compactInfo.droppedTokens || 0) / 1000).toFixed(0)
1992
- rawPins.push({
1993
- idx,
1994
- pct,
1995
- pinType: 'compress',
1996
- label: `${t('tlCompressPin', { seq: s.compactInfo.seq })}${droppedK > 0 ? ` (-${droppedK}k)` : ''}`,
1997
- turn: s.turn,
1998
- })
1999
- } else if (s.frames?.length) {
2000
- const aiFrame = s.frames.find(f => f.who === 'ai') || s.frames[0]
2001
- rawPins.push({ idx, pct, pinType: 'frame', label: aiFrame.label, turn: s.turn })
2002
- } else if (s.docs?.length) {
2003
- rawPins.push({ idx, pct, pinType: 'doc', label: s.docs[0].title, turn: s.turn })
2004
- } else if (s.kind === 'prompt') {
2005
- rawPins.push({ idx, pct, pinType: 'turn', label: `#${s.turn}`, turn: s.turn })
2006
- }
2007
- })
2008
-
2009
- const occupiedPcts = []
2010
- const canShowText = pct => pct >= 5 && pct <= 95 && occupiedPcts.every(p => Math.abs(p - pct) >= 11)
2011
- for (const pin of rawPins) {
2012
- if (pin.pinType === 'compress' && canShowText(pin.pct)) {
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
- }
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>`)
2036
2021
  }
2037
2022
 
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
2023
  return `<footer class="session-timeline-bar" data-session-timeline aria-label="${escape(t('tlAria'))}">
2056
2024
  <div class="session-transport" role="group" aria-label="${escape(t('tlControlsAria'))}">
2057
2025
  <button type="button" class="session-nav-btn" data-session-prev disabled aria-label="${escape(t('prevStep'))}">◀</button>
@@ -2060,10 +2028,12 @@ function renderTimelineBar(line, t) {
2060
2028
  <span class="session-speed-badge" data-session-speed><b>0</b> / ${total} · 00:00</span>
2061
2029
  </div>
2062
2030
  <div class="session-tl-track-wrap" data-tl-track>
2063
- <span class="session-composer-progress" data-session-progress aria-hidden="true"></span>
2064
2031
  <div class="session-tl-pop" data-tl-pop hidden></div>
2065
- <div class="session-tl-pins" data-tl-pins>${pinsHtml}</div>
2066
- <div class="session-tl-segs" style="--tl-gap:${segGap}" data-tl-segs>${segsHtml}</div>
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>
2067
2037
  </div>
2068
2038
  </footer>`
2069
2039
  }
@@ -2561,11 +2531,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2561
2531
  const stageTrigger = containerEl.querySelector('[data-session-stage-trigger]')
2562
2532
  const composerText = containerEl.querySelector('[data-session-composer-text]')
2563
2533
  const sendBtn = containerEl.querySelector('[data-session-send]')
2564
- const progressBar = containerEl.querySelector('[data-session-progress]')
2565
2534
  const timelineBar = containerEl.querySelector('[data-session-timeline]')
2566
2535
  const tlTrack = timelineBar?.querySelector('[data-tl-track]')
2567
2536
  const tlPop = timelineBar?.querySelector('[data-tl-pop]')
2568
- const tlSegs = timelineBar ? [...timelineBar.querySelectorAll('[data-tl-step]')] : []
2537
+ const tlRange = tlTrack?.querySelector('[data-tl-range]')
2538
+ const cells = tlTrack?.querySelector('.session-tl-cells')?.children
2569
2539
  const tlPins = timelineBar ? [...timelineBar.querySelectorAll('[data-tl-jump]')] : []
2570
2540
  const lightbox = containerEl.querySelector('[data-session-lightbox]')
2571
2541
  const lightboxImg = lightbox?.querySelector('[data-lightbox-img]')
@@ -2591,8 +2561,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2591
2561
  let curTime = 0
2592
2562
  let playHead = initialStep
2593
2563
  let prevRenderedHead = initialStep
2594
- let selectedIdx = initialStep
2595
- let userClickedInspect = false
2596
2564
  let isInitialMount = true
2597
2565
  let playing = false
2598
2566
  let stepBusy = false
@@ -2714,13 +2682,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2714
2682
  stepBusy = false
2715
2683
  }
2716
2684
 
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
2685
  function rawPromptTextOf(stepIdx) {
2725
2686
  const step = steps[stepIdx]
2726
2687
  if (!step || step.kind !== 'prompt') return ''
@@ -2800,10 +2761,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2800
2761
  return idx < 0 ? buildPrePromptStep() : model.selectStep(idx)
2801
2762
  }
2802
2763
 
2803
- function currentSelectedState() {
2804
- return stateForIndex(selectedIdx)
2805
- }
2806
-
2807
2764
  if (play) play.hidden = false
2808
2765
  attachAttachmentReaders(containerEl, t, () => { if (playing) setPlaying(false) })
2809
2766
  if (log) log.classList.add('is-staged')
@@ -2849,10 +2806,9 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2849
2806
 
2850
2807
  function applyEchoHighlight() {
2851
2808
  if (!asidePane) return
2852
- const activeKey = hoverCat || (userClickedInspect ? openCat : null)
2853
- stackedBar?.classList.toggle('lc-stacked-dim', Boolean(activeKey))
2809
+ stackedBar?.classList.toggle('lc-stacked-dim', Boolean(hoverCat))
2854
2810
  asidePane.querySelectorAll('[data-cat-key]').forEach(el => {
2855
- const match = activeKey && el.dataset.catKey === activeKey
2811
+ const match = hoverCat && el.dataset.catKey === hoverCat
2856
2812
  el.classList.toggle('lc-stacked-seg-on', Boolean(match && el.classList.contains('lc-stacked-seg')))
2857
2813
  el.classList.toggle('lc-chip-on', Boolean(match && el.classList.contains('lc-chip')))
2858
2814
  })
@@ -2865,6 +2821,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2865
2821
  entry.addEventListener('click', event => {
2866
2822
  const lbBtn = event.target.closest('[data-lightbox-src]')
2867
2823
  if (lbBtn && lightbox && lightboxImg) {
2824
+ event.preventDefault()
2868
2825
  event.stopPropagation()
2869
2826
  if (playing) setPlaying(false)
2870
2827
  lightbox.classList.remove('is-doc')
@@ -2902,18 +2859,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2902
2859
  }
2903
2860
  if (event.target.closest('a, audio, video, summary, button')) return
2904
2861
  if (stepIndex > playHead) return
2905
- if (playing) setPlaying(false)
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
- }
2862
+ jumpToStep(stepIndex)
2917
2863
  })
2918
2864
  entry.addEventListener('mouseenter', () => {
2919
2865
  if (stepIndex > playHead) return
@@ -2934,8 +2880,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
2934
2880
  if (snapLabel) {
2935
2881
  if (stepState.index < 0) {
2936
2882
  snapLabel.textContent = t('snapInitial')
2937
- } else if (selectedIdx < playHead) {
2938
- snapLabel.textContent = t('snapInspect', { step: stepState.index + 1, total: steps.length })
2939
2883
  } else {
2940
2884
  snapLabel.textContent = t('snapCurrent', { step: stepState.index + 1, total: steps.length })
2941
2885
  }
@@ -3036,15 +2980,17 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3036
2980
  if (event.target === lightbox) closeLightbox()
3037
2981
  })
3038
2982
 
2983
+ let hoverStep = null
3039
2984
  function renderTimelineHover(idx) {
3040
- if (!tlPop) return
2985
+ if (!tlPop || hoverStep === idx) return
2986
+ hoverStep = idx
3041
2987
  if (idx === null || idx < 0 || idx >= steps.length) {
3042
2988
  tlPop.hidden = true
3043
2989
  return
3044
2990
  }
3045
2991
  const s = steps[idx]
3046
2992
  const pct = steps.length > 0 ? Math.min(88, Math.max(12, ((idx + 0.5) / steps.length) * 100)) : 50
3047
- const frame = s.frames?.[0]
2993
+ const frame = s.frames?.find(frame => frame.who === 'ai') || s.frames?.[0]
3048
2994
  const doc = s.docs?.[0]
3049
2995
  const ci = s.compactInfo
3050
2996
  const thumbHtml = frame
@@ -3060,50 +3006,75 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3060
3006
  ? t('tlPromptTitle', { turn: s.turn, summary: shorten(s.summary || '', 20) })
3061
3007
  : shorten(s.summary || t('tlStepFallback'), 24)
3062
3008
  const tokStr = `${((s.contextSnapshot?.totalTokens || 0) / 1000).toFixed(1)}k`
3063
- tlPop.style.left = `${pct.toFixed(1)}%`
3009
+ tlPop.style.left = `clamp(min(130px, 50%), ${pct.toFixed(1)}%, max(50%, 100% - 130px))`
3064
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>`
3065
3011
  tlPop.hidden = false
3066
3012
  }
3067
3013
 
3068
- function jumpViaTimeline(idx) {
3069
- const clamped = Math.max(0, Math.min(steps.length - 1, idx))
3070
- if (playing) setPlaying(false)
3071
- activate()
3072
- if (clamped > playHead) {
3073
- clearStepAnimations()
3074
- playHead = clamped
3075
- prevRenderedHead = clamped
3076
- animatedHead = clamped
3077
- selectedIdx = clamped
3078
- userClickedInspect = false
3079
- openCat = steps[clamped]?.primaryCat || null
3080
- const next = steps[playHead + 1]
3081
- const nextDraft = next?.kind === 'prompt' ? rawPromptTextOf(next.index) : ''
3082
- if (nextDraft) setComposerVisual('draft', nextDraft)
3083
- else setComposerVisual('idle')
3084
- follow = true
3085
- render()
3086
- } else {
3087
- selectedIdx = clamped
3088
- userClickedInspect = clamped < playHead
3089
- openCat = steps[clamped]?.primaryCat || null
3090
- follow = false
3091
- render()
3092
- const targetEntry = stepEntries.find(e => e.stepIndex === clamped)?.entry
3093
- if (targetEntry) camera.frameEntry(targetEntry, false)
3094
- }
3095
- }
3096
-
3097
- tlTrack?.addEventListener('mouseover', event => {
3098
- const h = event.target.closest('[data-tl-hover]')
3099
- renderTimelineHover(h ? Number(h.dataset.tlHover) : null)
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
+ }
3051
+ }
3052
+ }
3053
+
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)
3100
3069
  })
3101
- tlTrack?.addEventListener('mouseleave', () => renderTimelineHover(null))
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))
3102
3075
  tlTrack?.addEventListener('click', event => {
3103
- const el = event.target.closest('[data-tl-jump], [data-tl-step]')
3104
- if (!el) return
3105
- const idx = Number(el.dataset.tlJump ?? el.dataset.tlStep)
3106
- if (Number.isFinite(idx)) jumpViaTimeline(idx)
3076
+ const pin = event.target.closest('[data-tl-jump]')
3077
+ if (pin) seekFromTimeline(Number(pin.dataset.tlJump))
3107
3078
  })
3108
3079
 
3109
3080
  asidePane?.addEventListener('click', event => {
@@ -3133,7 +3104,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3133
3104
  if (chipOrSeg) {
3134
3105
  const catId = chipOrSeg.dataset.catKey
3135
3106
  openCat = openCat === catId ? null : catId
3136
- renderContextSidebar(currentSelectedState())
3107
+ renderContextSidebar(stateForIndex(playHead))
3137
3108
  asidePane.querySelector(`[data-browser-cat="${catId}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
3138
3109
  return
3139
3110
  }
@@ -3141,7 +3112,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3141
3112
  if (catBtn && !catBtn.disabled) {
3142
3113
  const catId = catBtn.dataset.browserCatToggle
3143
3114
  openCat = openCat === catId ? null : catId
3144
- renderContextSidebar(currentSelectedState())
3115
+ renderContextSidebar(stateForIndex(playHead))
3145
3116
  return
3146
3117
  }
3147
3118
  const itemBtn = event.target.closest('[data-browser-item-toggle]')
@@ -3149,7 +3120,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3149
3120
  const itemId = itemBtn.dataset.browserItemToggle
3150
3121
  if (openItems.has(itemId)) openItems.delete(itemId)
3151
3122
  else openItems.add(itemId)
3152
- renderContextSidebar(currentSelectedState())
3123
+ renderContextSidebar(stateForIndex(playHead))
3153
3124
  }
3154
3125
  })
3155
3126
 
@@ -3378,7 +3349,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3378
3349
  }
3379
3350
 
3380
3351
  function runHeadChoreography(headState, headEntry, animateNewStep, steppedForwardOne) {
3381
- updateProgressHairline()
3382
3352
  if (!animateNewStep) return
3383
3353
  clearStepAnimations()
3384
3354
 
@@ -3422,7 +3392,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3422
3392
  if (headState.kind === 'compact') {
3423
3393
  setComposerVisual('running')
3424
3394
  openCat = 'tool'
3425
- renderContextSidebar(currentSelectedState())
3395
+ renderContextSidebar(stateForIndex(playHead))
3426
3396
  if (headEntry && !calm.matches && typeof headEntry.animate === 'function') {
3427
3397
  activeAnims.push(headEntry.animate(
3428
3398
  [
@@ -3451,7 +3421,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3451
3421
 
3452
3422
  function render() {
3453
3423
  const headState = stateForIndex(playHead)
3454
- const selectedState = currentSelectedState()
3455
3424
  curTime = headState.index < 0 ? 0 : headState.t
3456
3425
  const x = (playerData.end > 0 ? ((curTime / playerData.end) * width) : 0).toFixed(1)
3457
3426
  if (head) {
@@ -3472,45 +3441,26 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3472
3441
  play.setAttribute('aria-label', atEnd ? t('replayAria') : t('playAria'))
3473
3442
  }
3474
3443
 
3475
- renderContextSidebar(selectedState)
3476
- const shownIdx = userClickedInspect && selectedIdx >= 0 ? selectedIdx : playHead
3477
- const shownTime = shownIdx < 0 ? 0 : (steps[shownIdx]?.t || 0)
3478
- updateProgressHairline(shownIdx)
3479
- if (speedBadge) {
3480
- speedBadge.innerHTML = `<b>${Math.max(0, shownIdx + 1)}</b> / ${steps.length} · ${elapsedClock(shownTime)}`
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) }))
3481
3450
  }
3482
- tlSegs.forEach((seg, idx) => {
3483
- seg.classList.toggle('is-past', idx <= playHead && idx !== shownIdx)
3484
- seg.classList.toggle('is-active', idx === shownIdx && shownIdx >= 0)
3485
- })
3486
- tlPins.forEach(pin => {
3487
- const pIdx = Number(pin.dataset.tlJump)
3488
- pin.classList.toggle('is-on', pIdx === shownIdx && shownIdx >= 0)
3489
- pin.classList.toggle('is-reached', pIdx <= playHead)
3490
- })
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)
3491
3459
 
3492
3460
  let latestVisibleEntry
3493
3461
  for (const item of stepEntries) {
3494
3462
  const future = item.stepIndex > playHead
3495
3463
  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
3464
  if (!future) latestVisibleEntry = item.entry
3515
3465
  }
3516
3466
  for (const aux of auxEntries) {
@@ -3544,8 +3494,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3544
3494
  activate()
3545
3495
  if (shouldScroll) camera.resumeFollow()
3546
3496
  playHead = Math.max(-1, Math.min(steps.length - 1, nextIdx))
3547
- selectedIdx = playHead
3548
- userClickedInspect = false
3549
3497
  openCat = playHead < 0 ? null : (steps[playHead]?.primaryCat || null)
3550
3498
  follow = shouldScroll
3551
3499
  animatedHead = -2
@@ -3569,7 +3517,6 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3569
3517
  const nextDraft = next?.kind === 'prompt' ? rawPromptTextOf(next.index) : ''
3570
3518
  if (nextDraft) setComposerVisual('draft', nextDraft)
3571
3519
  else setComposerVisual('idle')
3572
- updateProgressHairline()
3573
3520
  return
3574
3521
  }
3575
3522
  activate()
@@ -3578,19 +3525,11 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3578
3525
  clearStepAnimations()
3579
3526
  playHead = -1
3580
3527
  prevRenderedHead = -1
3581
- selectedIdx = -1
3582
- userClickedInspect = false
3583
3528
  openCat = null
3584
3529
  follow = true
3585
3530
  animatedHead = -1
3586
3531
  render()
3587
3532
  }
3588
- if (selectedIdx < playHead) {
3589
- selectedIdx = playHead
3590
- userClickedInspect = false
3591
- openCat = steps[playHead]?.primaryCat || null
3592
- render()
3593
- }
3594
3533
  if (!stepBusy) {
3595
3534
  if (playHead < 0) {
3596
3535
  const firstDraft = steps[0]?.kind === 'prompt' ? rawPromptTextOf(0) : ''
@@ -3691,6 +3630,7 @@ function attachPlayerController(containerEl, playerData, { lang = 'zh', initialS
3691
3630
  destroy() {
3692
3631
  clearStepAnimations()
3693
3632
  camera.stop()
3633
+ labelObserver?.disconnect()
3694
3634
  appEl.removeEventListener('keydown', onKeyDown)
3695
3635
  },
3696
3636
  goToStage,
@@ -3718,6 +3658,10 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
3718
3658
  const appNode = el.querySelector('.session-app')
3719
3659
  const activeLang = resolveLang(options.lang || el.dataset.lang || appNode?.dataset.encoreLang || 'zh')
3720
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
+ }
3721
3665
  const activeController = attachPlayerController(el, playerData, {
3722
3666
  lang: activeLang,
3723
3667
  initialStep: options.initialStep ?? -1,
@@ -3760,7 +3704,7 @@ async function createEncorePlayer(targetEl, sourceOrSession, options = {}) {
3760
3704
  if (activeController) activeController.destroy()
3761
3705
  activeLang = resolveLang(lang)
3762
3706
  const line = timeline(session, { lang: activeLang })
3763
- el.innerHTML = renderPlayerWidget(session, line, { lang: activeLang, baseUrl, showLangToggle: options.showLangToggle })
3707
+ el.innerHTML = renderPlayerWidget(session, line, { ...options, lang: activeLang, baseUrl })
3764
3708
  if (session.title && document.querySelectorAll('[data-encore-player]').length <= 1) {
3765
3709
  document.title = `${session.title} · Encore`
3766
3710
  }
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "tool": {
14
14
  "type": "string",
15
- "enum": ["codex", "claude-code", "claude-ai", "workbuddy"],
15
+ "enum": ["codex", "claude-code", "claude-ai", "workbuddy", "antigravity", "antigravity-app", "antigravity-cli"],
16
16
  "description": "Source AI agent environment identifier."
17
17
  },
18
18
  "model": {
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: encore
3
3
  description: >
4
- Export, curate, and rebuild portable AI Agent replays (Codex, Claude Code, Claude.ai, WorkBuddy) with Encore.
4
+ Export, curate, and rebuild portable AI Agent replays (Codex, Claude Code, Claude.ai, WorkBuddy, Antigravity App and CLI) with Encore.
5
5
  Use when the user asks to export a Raw Log into a Replay, curate `session.json`, select and label `.webp` Frames, review packaged Attachments or Deliverables, write a title and opening description, or redact residual sensitive details before publishing.
6
6
  ---
7
7
 
8
8
  # Encore — Session Replay & Curation Skill
9
9
 
10
- Encore turns a Raw Log from **Codex**, **Claude Code**, **Claude.ai**, or **WorkBuddy** into a portable **Replay** rendered by the standalone **Player** (**Left**: Turns, Tool calls, Sub-agents, Attachments, Deliverables, and Frames; **Right**: live Context Snapshot inspector and Compaction boundaries; **Bottom**: Step timeline).
10
+ Encore turns a Raw Log from **Codex**, **Claude Code**, **Claude.ai**, **WorkBuddy**, or **Antigravity** into a portable **Replay** rendered by the standalone **Player** (**Left**: Turns, Tool calls, Sub-agents, Attachments, Deliverables, and Frames; **Right**: live Context Snapshot inspector and Compaction boundaries; **Bottom**: Step timeline).
11
11
 
12
12
  While `npx @niracler/encore@latest` builds an immediately playable Replay, this skill guides **Curation** before publishing.
13
13