dsh-plugin-memory 0.19.5 → 0.21.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/CHANGELOG.md +26 -0
- package/README.md +1 -0
- package/README.zh.md +1 -0
- package/docs/market/index.json +2 -2
- package/docs/superpowers/plans/2026-11-16-memory-timeline.md +358 -0
- package/docs/superpowers/specs/2026-11-16-memory-timeline-design.md +153 -0
- package/lib/client.js +578 -63
- package/lib/index.js +30 -0
- package/lib/timeline.js +164 -0
- package/lib/types/index.d.ts +23 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -179,6 +179,29 @@ window.__ModuleLoader__.load({
|
|
|
179
179
|
graphRevealFallback: '打开失败,已复制路径;在 Finder 里按 ⌘⇧G 粘贴路径即可跳转',
|
|
180
180
|
graphSidebarFailed: '侧栏打开失败:',
|
|
181
181
|
graphSidebarOutside: '该文件不在当前会话的工作区内,侧栏无法预览;已用系统文件管理器打开',
|
|
182
|
+
memoryViewGraph: '图谱',
|
|
183
|
+
memoryViewTimeline: '时间轴',
|
|
184
|
+
timelineLoading: '正在读取记忆时间轴…',
|
|
185
|
+
timelineShowAll: '显示全部事件(含笔记/过程)',
|
|
186
|
+
timelineHint: '双击事件打开对应页面 · 支持搜索与类型过滤(概览条 + 事件列表)',
|
|
187
|
+
timelineRangeWeek: '最近 7 天',
|
|
188
|
+
timelineRangeMonth: '最近 30 天',
|
|
189
|
+
timelineRangeAll: '全部',
|
|
190
|
+
timelineSearchPlaceholder: '搜索事件(标题 / 日期 / 类型)…',
|
|
191
|
+
timelineFilterEmpty: '没有匹配的事件',
|
|
192
|
+
timelineDayCount: '{count} 条',
|
|
193
|
+
timelineOpenHint: '双击打开对应页面',
|
|
194
|
+
timelineFilteredStats: '筛选后 {shown} 条',
|
|
195
|
+
timelineOpenError: '打开失败',
|
|
196
|
+
timelineNoMemoryDir: '找不到记忆目录',
|
|
197
|
+
timelineRevealed: '已在系统文件管理器中打开',
|
|
198
|
+
timelineNoPage: '该事件没有对应页面,已打开 log.md',
|
|
199
|
+
timelineStats: '共 {events} 条事件 · {first} → {last}',
|
|
200
|
+
timelineLegendFix: '修复',
|
|
201
|
+
timelineLegendFeat: '功能',
|
|
202
|
+
timelineLegendPublish: '发布',
|
|
203
|
+
timelineLegendDecision: '决策',
|
|
204
|
+
timelineLegendOther: '其他',
|
|
182
205
|
graphStats: '{pages} 页 · {links} 条页间互链 · {tagEdges} 条共享 tag',
|
|
183
206
|
graphIndexRoutes: '{count} 条索引路由(虚线)',
|
|
184
207
|
graphIsolated: '{count} 页暂时孤立',
|
|
@@ -338,6 +361,29 @@ window.__ModuleLoader__.load({
|
|
|
338
361
|
graphRevealFallback: 'Reveal failed; the path was copied — paste it in your file manager to jump there',
|
|
339
362
|
graphSidebarFailed: 'Sidebar open failed: ',
|
|
340
363
|
graphSidebarOutside: 'This file is outside the current session workspace, so the sidebar cannot preview it; opened it in the OS file manager instead',
|
|
364
|
+
memoryViewGraph: 'Graph',
|
|
365
|
+
memoryViewTimeline: 'Timeline',
|
|
366
|
+
timelineLoading: 'Loading the memory timeline…',
|
|
367
|
+
timelineShowAll: 'Show all events (including notes/process)',
|
|
368
|
+
timelineHint: 'Double-click an event to open its page · search and filter by type (overview bar + event list)',
|
|
369
|
+
timelineRangeWeek: 'Last 7 days',
|
|
370
|
+
timelineRangeMonth: 'Last 30 days',
|
|
371
|
+
timelineRangeAll: 'All',
|
|
372
|
+
timelineSearchPlaceholder: 'Search events (title / date / kind)…',
|
|
373
|
+
timelineFilterEmpty: 'No matching events',
|
|
374
|
+
timelineDayCount: '{count} events',
|
|
375
|
+
timelineOpenHint: 'Double-click to open the page',
|
|
376
|
+
timelineFilteredStats: '{shown} shown',
|
|
377
|
+
timelineOpenError: 'Open failed',
|
|
378
|
+
timelineNoMemoryDir: 'Memory directory not found',
|
|
379
|
+
timelineRevealed: 'Opened in the OS file manager',
|
|
380
|
+
timelineNoPage: 'This event has no linked page, so log.md was opened instead',
|
|
381
|
+
timelineStats: '{events} events · {first} → {last}',
|
|
382
|
+
timelineLegendFix: 'fix',
|
|
383
|
+
timelineLegendFeat: 'feature',
|
|
384
|
+
timelineLegendPublish: 'release',
|
|
385
|
+
timelineLegendDecision: 'decision',
|
|
386
|
+
timelineLegendOther: 'other',
|
|
341
387
|
graphStats: '{pages} pages · {links} page links · {tagEdges} shared tags',
|
|
342
388
|
graphIndexRoutes: '{count} index routes (dashed)',
|
|
343
389
|
graphIsolated: '{count} pages isolated',
|
|
@@ -555,17 +601,52 @@ window.__ModuleLoader__.load({
|
|
|
555
601
|
// `gen` bumps after every successful config write so the read-only health
|
|
556
602
|
// card re-mounts and re-reads the store (e.g. after a memoryDir switch).
|
|
557
603
|
const [gen, setGen] = React.useState(0)
|
|
604
|
+
// Two projections of the same store: the relationship graph and the
|
|
605
|
+
// timeline. Only the active one is mounted, so the graph's polling stops
|
|
606
|
+
// while the timeline is open (and vice versa).
|
|
607
|
+
const [view, setView] = React.useState('graph')
|
|
608
|
+
const activeView = view === 'timeline' ? 'timeline' : 'graph'
|
|
558
609
|
const t = useT(props)
|
|
610
|
+
const tabStyle = (active) => ({
|
|
611
|
+
appearance: 'none',
|
|
612
|
+
border: '1px solid var(--dsw-alias-border-l2, #3a3c42)',
|
|
613
|
+
background: active ? 'var(--dsw-alias-bg-layer-2, #34363d)' : 'transparent',
|
|
614
|
+
color: active ? 'var(--dsw-alias-label-primary, #fff)' : 'var(--dsw-alias-label-secondary, #9aa0aa)',
|
|
615
|
+
borderRadius: '6px',
|
|
616
|
+
padding: '4px 12px',
|
|
617
|
+
fontSize: '12px',
|
|
618
|
+
cursor: 'pointer',
|
|
619
|
+
})
|
|
559
620
|
return React.createElement(LocaleContext.Provider, { value: t },
|
|
560
|
-
React.createElement('div', { 'data-dsh-memory-panel': '', style: { padding: '8px 0' } },
|
|
621
|
+
React.createElement('div', { 'data-dsh-memory-panel': '', style: { padding: '8px 0', overflowAnchor: 'none' } },
|
|
561
622
|
React.createElement(SectionBoundary, null,
|
|
562
623
|
React.createElement(SoulCard),
|
|
563
624
|
),
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
625
|
+
React.createElement('div', { role: 'tablist', style: { display: 'flex', gap: '6px', padding: '2px 2px 8px' } },
|
|
626
|
+
React.createElement('button', {
|
|
627
|
+
type: 'button',
|
|
628
|
+
role: 'tab',
|
|
629
|
+
'aria-selected': activeView === 'graph',
|
|
630
|
+
onClick: () => setView('graph'),
|
|
631
|
+
style: tabStyle(activeView === 'graph'),
|
|
632
|
+
}, t('memoryViewGraph')),
|
|
633
|
+
React.createElement('button', {
|
|
634
|
+
type: 'button',
|
|
635
|
+
role: 'tab',
|
|
636
|
+
'aria-selected': activeView === 'timeline',
|
|
637
|
+
onClick: () => setView('timeline'),
|
|
638
|
+
style: tabStyle(activeView === 'timeline'),
|
|
639
|
+
}, t('memoryViewTimeline')),
|
|
568
640
|
),
|
|
641
|
+
// The active projection follows the soul card: the thing people open
|
|
642
|
+
// the panel for should be visible without scrolling.
|
|
643
|
+
activeView === 'graph'
|
|
644
|
+
? React.createElement(SectionBoundary, { key: `graph-${gen}` },
|
|
645
|
+
React.createElement(GraphCard),
|
|
646
|
+
)
|
|
647
|
+
: React.createElement(SectionBoundary, { key: `timeline-${gen}` },
|
|
648
|
+
React.createElement(TimelineCard),
|
|
649
|
+
),
|
|
569
650
|
React.createElement(SectionBoundary, null,
|
|
570
651
|
React.createElement(MemoryForm, { onSaved: () => setGen((value) => value + 1) }),
|
|
571
652
|
),
|
|
@@ -1620,22 +1701,28 @@ window.__ModuleLoader__.load({
|
|
|
1620
1701
|
}
|
|
1621
1702
|
|
|
1622
1703
|
/** 图谱的过渡/入场样式:拖动时不要过渡,松手后要滑回去。 */
|
|
1704
|
+
const GRAPH_STYLES = [
|
|
1705
|
+
'#dsh-memory-graph-style + * {}',
|
|
1706
|
+
'.dsh-memory-graph-svg g { transition: transform .18s cubic-bezier(.2,.8,.2,1); }',
|
|
1707
|
+
'.dsh-memory-graph-svg.anim-off g { transition: none; }',
|
|
1708
|
+
'.dsh-memory-graph-svg.dragging g { transition: none; }',
|
|
1709
|
+
'.dsh-memory-graph-svg.entering g { transform: scale(.08); opacity: 0; }',
|
|
1710
|
+
'.dsh-memory-graph-svg.graph-drop g { transition: transform .32s cubic-bezier(.2,.9,.2,1.05); }',
|
|
1711
|
+
'.dsh-memory-graph-svg circle, .dsh-memory-graph-svg text { transition: opacity .12s; }',
|
|
1712
|
+
'.dsh-memory-graph-svg.hovering g:not(.lit) circle,' +
|
|
1713
|
+
'.dsh-memory-graph-svg.hovering g:not(.lit) text { opacity: .18; }',
|
|
1714
|
+
].join('\n')
|
|
1623
1715
|
function ensureGraphStyles() {
|
|
1624
|
-
if (typeof document === 'undefined'
|
|
1716
|
+
if (typeof document === 'undefined') return
|
|
1717
|
+
const existing = document.getElementById('dsh-memory-graph-style')
|
|
1718
|
+
if (existing !== null) {
|
|
1719
|
+
if (existing.textContent !== GRAPH_STYLES) existing.textContent = GRAPH_STYLES
|
|
1720
|
+
return
|
|
1721
|
+
}
|
|
1625
1722
|
const style = document.createElement('style')
|
|
1626
1723
|
style.id = 'dsh-memory-graph-style'
|
|
1627
|
-
style.textContent =
|
|
1628
|
-
|
|
1629
|
-
'.dsh-memory-graph-svg g { transition: transform .18s cubic-bezier(.2,.8,.2,1); }',
|
|
1630
|
-
'.dsh-memory-graph-svg.anim-off g { transition: none; }',
|
|
1631
|
-
'.dsh-memory-graph-svg.dragging g { transition: none; }',
|
|
1632
|
-
'.dsh-memory-graph-svg.entering g { transform: scale(.08); opacity: 0; }',
|
|
1633
|
-
'.dsh-memory-graph-svg.graph-drop g { transition: transform .32s cubic-bezier(.2,.9,.2,1.05); }',
|
|
1634
|
-
'.dsh-memory-graph-svg circle, .dsh-memory-graph-svg text { transition: opacity .12s; }',
|
|
1635
|
-
'.dsh-memory-graph-svg.hovering g:not(.lit) circle,' +
|
|
1636
|
-
'.dsh-memory-graph-svg.hovering g:not(.lit) text { opacity: .18; }',
|
|
1637
|
-
].join('\n')
|
|
1638
|
-
document.head.appendChild(style)
|
|
1724
|
+
style.textContent = GRAPH_STYLES
|
|
1725
|
+
if (document.head && typeof document.head.appendChild === 'function') document.head.appendChild(style)
|
|
1639
1726
|
}
|
|
1640
1727
|
|
|
1641
1728
|
/**
|
|
@@ -2006,23 +2093,10 @@ window.__ModuleLoader__.load({
|
|
|
2006
2093
|
setQuery('')
|
|
2007
2094
|
}
|
|
2008
2095
|
|
|
2009
|
-
|
|
2010
|
-
const copyPathToClipboard = async (id) => {
|
|
2011
|
-
try {
|
|
2012
|
-
const response = await fetch(`${GRAPH_PATH_URL}?id=${encodeURIComponent(id)}`)
|
|
2013
|
-
const body = await response.json().catch(() => ({}))
|
|
2014
|
-
if (!response.ok || typeof body.path !== 'string') throw new Error(body.error ?? `GET ${response.status}`)
|
|
2015
|
-
if (typeof navigator === 'undefined' || !navigator.clipboard?.writeText) throw new Error('clipboard unavailable')
|
|
2016
|
-
await navigator.clipboard.writeText(body.path)
|
|
2017
|
-
return true
|
|
2018
|
-
} catch {
|
|
2019
|
-
return false
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2096
|
+
// Clipboard fallback is shared with the timeline (module-level helper).
|
|
2023
2097
|
/** 「复制路径」按钮。 */
|
|
2024
2098
|
const copyNodePath = async (id) => {
|
|
2025
|
-
setNotice((await
|
|
2099
|
+
setNotice((await copyMemoryPathToClipboard(id)) ? t('graphCopied') : t('graphCopyFailed'))
|
|
2026
2100
|
}
|
|
2027
2101
|
|
|
2028
2102
|
/** 「在 Finder 中显示」按钮 + 双击节点;失败时自动复制路径兜底。 */
|
|
@@ -2040,15 +2114,13 @@ window.__ModuleLoader__.load({
|
|
|
2040
2114
|
.then(() => setNotice(noticeAfterSuccess))
|
|
2041
2115
|
.catch(async (error) => {
|
|
2042
2116
|
const message = error instanceof Error ? error.message : String(error)
|
|
2043
|
-
const copied = await
|
|
2117
|
+
const copied = await copyMemoryPathToClipboard(id)
|
|
2044
2118
|
setNotice(copied ? t('graphRevealFallback') : `${t('graphRevealFailed')}${message}`)
|
|
2045
2119
|
})
|
|
2046
2120
|
}
|
|
2047
2121
|
|
|
2048
2122
|
/** 双击节点:优先在 DSH 右侧栏打开该 md 文件;不可用时回退系统文件管理器。 */
|
|
2049
2123
|
const openInSidebar = async (id) => {
|
|
2050
|
-
const sidebar = resolveSidebarRight()
|
|
2051
|
-
if (!sidebar || typeof sidebar.openResource !== 'function') return { ok: false, reason: 'sidebar-unavailable' }
|
|
2052
2124
|
let pathInfo
|
|
2053
2125
|
try {
|
|
2054
2126
|
pathInfo = await fetch(`${GRAPH_PATH_URL}?id=${encodeURIComponent(id)}`).then((response) => response.json())
|
|
@@ -2056,33 +2128,9 @@ window.__ModuleLoader__.load({
|
|
|
2056
2128
|
return { ok: false, reason: 'path-fetch-failed' }
|
|
2057
2129
|
}
|
|
2058
2130
|
if (!pathInfo || pathInfo.ok !== true || typeof pathInfo.path !== 'string') return { ok: false, reason: 'path-unresolved' }
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
session = await fetch(SESSION_URL).then((response) => response.json())
|
|
2063
|
-
} catch {
|
|
2064
|
-
return { ok: false, reason: 'session-fetch-failed' }
|
|
2065
|
-
}
|
|
2066
|
-
if (!session || session.ok !== true || typeof session.sessionId !== 'string') return { ok: false, reason: 'no-session' }
|
|
2067
|
-
const root = typeof session.cwd === 'string' && session.cwd.length > 0
|
|
2068
|
-
? session.cwd.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
2069
|
-
: undefined
|
|
2070
|
-
const encodePath = (path) => path.split('/')
|
|
2071
|
-
.map((segment, index) => (index === 0 && /^[A-Za-z]:$/.test(segment) ? segment : encodeURIComponent(segment)))
|
|
2072
|
-
.join('/')
|
|
2073
|
-
// The sidebar only opens `session/<id>/<relative>` addresses; an
|
|
2074
|
-
// absolute address has no authorized session and cannot be claimed.
|
|
2075
|
-
if (root === undefined || (absolute !== root && !absolute.startsWith(`${root}/`))) {
|
|
2076
|
-
return { ok: false, reason: 'outside-workspace' }
|
|
2077
|
-
}
|
|
2078
|
-
const relative = absolute.slice(root.length).replace(/^\/+/, '')
|
|
2079
|
-
const address = `dsh-resource://file/session/${encodeURIComponent(session.sessionId)}/${encodePath(relative)}`
|
|
2080
|
-
try {
|
|
2081
|
-
await sidebar.openResource(address)
|
|
2082
|
-
} catch (error) {
|
|
2083
|
-
return { ok: false, reason: error instanceof Error ? error.message : String(error) }
|
|
2084
|
-
}
|
|
2085
|
-
return { ok: true }
|
|
2131
|
+
// Shared with the timeline: resolve the sidebar service, then open the
|
|
2132
|
+
// session-relative address (absolute addresses cannot be claimed).
|
|
2133
|
+
return openMemoryPath(pathInfo.path)
|
|
2086
2134
|
}
|
|
2087
2135
|
const openNode = (id) => {
|
|
2088
2136
|
const message = (result) => result.reason === 'outside-workspace'
|
|
@@ -2443,6 +2491,459 @@ window.__ModuleLoader__.load({
|
|
|
2443
2491
|
})
|
|
2444
2492
|
|
|
2445
2493
|
/** 记忆图谱卡片:负责取数(含轮询)与生命周期,渲染交给 GraphView。 */
|
|
2494
|
+
|
|
2495
|
+
// ---------------- 记忆时间轴(v0.20) ----------------
|
|
2496
|
+
//
|
|
2497
|
+
// A second projection of the same store as the graph: one horizontal
|
|
2498
|
+
// "metro line" of log events. All geometry lives in pure functions so the
|
|
2499
|
+
// vm tests can exercise zoom granularity, label crowding and the initial
|
|
2500
|
+
// viewport without a DOM; the card only wires state and pointer events.
|
|
2501
|
+
const TIMELINE_URL = '/api/memory/timeline'
|
|
2502
|
+
const TIMELINE_REFRESH_MS = 20000
|
|
2503
|
+
const TIMELINE_DAY_MS = 86400000
|
|
2504
|
+
/** Process-noise kinds hidden unless "show all events" is on. */
|
|
2505
|
+
const TIMELINE_NOISE = new Set(['note','digest','install','uninstall','setup','bootstrap','task','probe','recall','consolidate','ops','schedule','export'])
|
|
2506
|
+
const TIMELINE_GROUPS = {
|
|
2507
|
+
fix: 'fix', bugfix: 'fix', repair: 'fix',
|
|
2508
|
+
feat: 'feat', feature: 'feat', implement: 'feat', impl: 'feat',
|
|
2509
|
+
publish: 'publish', release: 'publish', deliverable: 'publish',
|
|
2510
|
+
decision: 'decision', design: 'decision',
|
|
2511
|
+
}
|
|
2512
|
+
const TIMELINE_GROUP_COLORS = { fix: '#e5484d', feat: '#30a46c', publish: '#0091ff', decision: '#8e4ec6', other: '#d97706' }
|
|
2513
|
+
const timelineGroupOf = (kind) => TIMELINE_GROUPS[kind] ?? 'other'
|
|
2514
|
+
const timelineDateMs = (date) => Date.parse(`${date}T00:00:00Z`)
|
|
2515
|
+
|
|
2516
|
+
function visibleTimelineEvents(events, showAll) {
|
|
2517
|
+
const list = Array.isArray(events)
|
|
2518
|
+
? events.filter((event) => event !== null && typeof event === 'object'
|
|
2519
|
+
&& typeof event.date === 'string' && typeof event.title === 'string')
|
|
2520
|
+
: []
|
|
2521
|
+
return showAll ? list : list.filter((event) => !TIMELINE_NOISE.has(event.kind))
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/** Time-range presets for the overview/list view (days). */
|
|
2525
|
+
const TIMELINE_RANGES = { week: 7, month: 30, all: Infinity }
|
|
2526
|
+
const TIMELINE_GROUP_ORDER = ['fix', 'feat', 'publish', 'decision', 'other']
|
|
2527
|
+
|
|
2528
|
+
/** Start of the selected range, anchored on the newest supplied event. */
|
|
2529
|
+
function timelineRangeStart(events, rangeKey) {
|
|
2530
|
+
const list = Array.isArray(events)
|
|
2531
|
+
? events.filter((event) => event !== null && typeof event === 'object' && typeof event.date === 'string')
|
|
2532
|
+
: []
|
|
2533
|
+
if (list.length === 0) return undefined
|
|
2534
|
+
const days = TIMELINE_RANGES[rangeKey]
|
|
2535
|
+
if (days === undefined || !Number.isFinite(days)) return timelineDateMs(list[0].date)
|
|
2536
|
+
const last = timelineDateMs(list[list.length - 1].date)
|
|
2537
|
+
return last - days * TIMELINE_DAY_MS
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* Filter events for the list view: free-text query over title/date/kind,
|
|
2542
|
+
* type groups and an optional lower time bound.
|
|
2543
|
+
*/
|
|
2544
|
+
function filterTimelineEvents(events, options = {}) {
|
|
2545
|
+
const query = typeof options.query === 'string' ? options.query.trim().toLowerCase() : ''
|
|
2546
|
+
const groups = Array.isArray(options.groups) && options.groups.length > 0 && options.groups.length < 5
|
|
2547
|
+
? new Set(options.groups)
|
|
2548
|
+
: undefined
|
|
2549
|
+
const since = Number.isFinite(options.since) ? options.since : undefined
|
|
2550
|
+
return (Array.isArray(events) ? events : []).filter((event) => {
|
|
2551
|
+
if (event === null || typeof event !== 'object' || typeof event.date !== 'string') return false
|
|
2552
|
+
if (since !== undefined && timelineDateMs(event.date) < since) return false
|
|
2553
|
+
const group = typeof event.group === 'string' ? event.group : timelineGroupOf(event.kind)
|
|
2554
|
+
if (groups !== undefined && !groups.has(group)) return false
|
|
2555
|
+
if (query.length > 0) {
|
|
2556
|
+
const haystack = `${event.date} ${event.kind} ${event.title}`.toLowerCase()
|
|
2557
|
+
if (!haystack.includes(query)) return false
|
|
2558
|
+
}
|
|
2559
|
+
return true
|
|
2560
|
+
})
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Per-day buckets for the overview bar: count and per-group totals.
|
|
2565
|
+
* @returns {{ date: string, count: number, groups: Record<string, number> }[]}
|
|
2566
|
+
*/
|
|
2567
|
+
function buildDayBuckets(events) {
|
|
2568
|
+
const byDay = new Map()
|
|
2569
|
+
for (const event of Array.isArray(events) ? events : []) {
|
|
2570
|
+
if (event === null || typeof event !== 'object' || typeof event.date !== 'string') continue
|
|
2571
|
+
const group = typeof event.group === 'string' ? event.group : timelineGroupOf(event.kind)
|
|
2572
|
+
if (!byDay.has(event.date)) byDay.set(event.date, { date: event.date, count: 0, groups: {} })
|
|
2573
|
+
const bucket = byDay.get(event.date)
|
|
2574
|
+
bucket.count += 1
|
|
2575
|
+
bucket.groups[group] = (bucket.groups[group] ?? 0) + 1
|
|
2576
|
+
}
|
|
2577
|
+
return [...byDay.values()].sort((a, b) => (a.date < b.date ? -1 : a.date > b.date ? 1 : 0))
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/** The dominant group of one bucket (for the bar colour). */
|
|
2581
|
+
function dominantTimelineGroup(bucket) {
|
|
2582
|
+
let best = 'other'
|
|
2583
|
+
let bestCount = 0
|
|
2584
|
+
for (const group of TIMELINE_GROUP_ORDER) {
|
|
2585
|
+
const count = bucket.groups?.[group] ?? 0
|
|
2586
|
+
if (count > bestCount) {
|
|
2587
|
+
best = group
|
|
2588
|
+
bestCount = count
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
return best
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
/**
|
|
2595
|
+
* Scroll one day group into view INSIDE the list container only. Returns
|
|
2596
|
+
* the new scrollTop (or 0 when there is nothing to do); pure so behaviour
|
|
2597
|
+
* tests can drive it with a tiny fake DOM object.
|
|
2598
|
+
*/
|
|
2599
|
+
function scrollDayWithinList(listNode, date) {
|
|
2600
|
+
if (listNode === null || typeof listNode !== 'object') return 0
|
|
2601
|
+
const target = typeof listNode.querySelector === 'function' ? listNode.querySelector(`[data-day="${date}"]`) : null
|
|
2602
|
+
if (target === null || target === undefined) return 0
|
|
2603
|
+
if (typeof listNode.getBoundingClientRect !== 'function' || typeof target.getBoundingClientRect !== 'function') return 0
|
|
2604
|
+
const listRect = listNode.getBoundingClientRect()
|
|
2605
|
+
const targetRect = target.getBoundingClientRect()
|
|
2606
|
+
const next = Math.max(0, (Number(listNode.scrollTop) || 0) + (targetRect.top - listRect.top) - 2)
|
|
2607
|
+
listNode.scrollTop = next
|
|
2608
|
+
return next
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
/** Timeline stylesheet (injected once, refreshed when its content changes). */
|
|
2612
|
+
const TIMELINE_STYLES = [
|
|
2613
|
+
'.dsh-mem-tl-filters{display:flex;flex-direction:column;gap:6px;margin-bottom:10px;font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0aa)}',
|
|
2614
|
+
'.dsh-mem-tl-row1{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
|
|
2615
|
+
'.dsh-mem-tl-range{display:inline-flex;border:1px solid var(--dsw-alias-border-l2,#3a3c42);border-radius:7px;overflow:hidden}',
|
|
2616
|
+
'.dsh-mem-tl-range button{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#9aa0aa);padding:3px 10px;font-size:12px;cursor:pointer}',
|
|
2617
|
+
'.dsh-mem-tl-range button.dsh-mem-tl-on{background:var(--dsw-alias-bg-layer-2,#34363d);color:var(--dsw-alias-label-primary,#fff);font-weight:600}',
|
|
2618
|
+
'.dsh-mem-tl-search{flex:1;min-width:150px;appearance:none;border:1px solid var(--dsw-alias-border-l2,#3a3c42);background:var(--dsw-alias-bg-layer-1,#1b1c1f);color:var(--dsw-alias-label-primary,#e6e7ea);border-radius:6px;padding:4px 8px;font-size:12px;outline:none}',
|
|
2619
|
+
'.dsh-mem-tl-search:focus{border-color:var(--dsw-alias-label-secondary,#8b929e)}',
|
|
2620
|
+
'.dsh-mem-tl-row2{display:flex;align-items:center;gap:6px;flex-wrap:wrap}',
|
|
2621
|
+
'.dsh-mem-tl-typechip{display:inline-flex;align-items:center;gap:5px;border:1px solid transparent;border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary,#9aa0aa);padding:2px 8px;font-size:11px;cursor:pointer;opacity:.55}',
|
|
2622
|
+
'.dsh-mem-tl-typechip.dsh-mem-tl-on{opacity:1;border-color:var(--dsw-alias-border-l2,#3a3c42);background:var(--dsw-alias-bg-layer-2,#2a2b30);color:var(--dsw-alias-label-primary,#e6e7ea)}',
|
|
2623
|
+
'.dsh-mem-tl-typechip i{width:6px;height:6px;border-radius:50%;display:inline-block}',
|
|
2624
|
+
'.dsh-mem-tl-showall{display:flex;align-items:center;gap:6px;cursor:pointer;font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0aa)}',
|
|
2625
|
+
'.dsh-mem-tl-countflow{margin-left:auto;font-size:11px;color:var(--dsw-alias-label-secondary,#8b929e);font-variant-numeric:tabular-nums}',
|
|
2626
|
+
'.dsh-mem-tl-overview{display:flex;align-items:flex-end;gap:2px;height:48px;padding:2px 0 0;margin-bottom:10px;overflow:hidden;border-bottom:1px solid var(--dsw-alias-border-l2,#2b2d33)}',
|
|
2627
|
+
'.dsh-mem-tl-daybar{flex:1;min-width:2px;max-width:14px;border-radius:3px 3px 0 0;cursor:pointer;opacity:.72;transition:opacity .15s}',
|
|
2628
|
+
'.dsh-mem-tl-daybar:hover{opacity:1}',
|
|
2629
|
+
'.dsh-mem-tl-list{border:1px solid var(--dsw-alias-border-l2,#3a3c42);border-radius:10px;max-height:280px;overflow:auto;overflow-anchor:none;overscroll-behavior:contain;overscroll-behavior-y:contain}',
|
|
2630
|
+
'.dsh-mem-tl-daygroup{border-bottom:1px solid var(--dsw-alias-border-l2,#2b2d33)}',
|
|
2631
|
+
'.dsh-mem-tl-daygroup:last-child{border-bottom:0}',
|
|
2632
|
+
'.dsh-mem-tl-dayhead{display:flex;align-items:baseline;gap:8px;padding:4px 10px;background:var(--dsw-alias-bg-layer-2,#232428);font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0aa);font-variant-numeric:tabular-nums;position:sticky;top:0;z-index:1}',
|
|
2633
|
+
'.dsh-mem-tl-row{display:flex;align-items:center;gap:8px;padding:4px 10px;font-size:12px;line-height:1.35;cursor:pointer;border-left:2px solid transparent}',
|
|
2634
|
+
'.dsh-mem-tl-row:hover{background:var(--dsw-alias-bg-layer-2,#2a2b30)}',
|
|
2635
|
+
'.dsh-mem-tl-row.dsh-mem-tl-rowsel{background:var(--dsw-alias-bg-layer-2,#30323a);border-left-color:var(--dsw-alias-label-secondary,#8b929e)}',
|
|
2636
|
+
'.dsh-mem-tl-dot{flex:none;width:7px;height:7px;border-radius:50%}',
|
|
2637
|
+
'.dsh-mem-tl-kind{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0aa);min-width:30px}',
|
|
2638
|
+
'.dsh-mem-tl-title{flex:1;color:var(--dsw-alias-label-primary,#e6e7ea);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
2639
|
+
'.dsh-mem-tl-path{flex:none;color:var(--dsw-alias-label-secondary,#8b929e);font-size:10.5px;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.7}',
|
|
2640
|
+
'.dsh-mem-tl-empty{padding:18px;text-align:center;font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0aa)}',
|
|
2641
|
+
'.dsh-mem-tl-notice{font-size:11px;color:var(--dsw-alias-label-secondary,#8b929e);margin-top:10px;opacity:.8}',
|
|
2642
|
+
].join('\n')
|
|
2643
|
+
function ensureTimelineStyles() {
|
|
2644
|
+
if (typeof document === 'undefined') return
|
|
2645
|
+
const existing = document.getElementById('dsh-memory-timeline-style')
|
|
2646
|
+
if (existing !== null) {
|
|
2647
|
+
// A stale stylesheet from an older build must not shadow the new rules.
|
|
2648
|
+
if (existing.textContent !== TIMELINE_STYLES) existing.textContent = TIMELINE_STYLES
|
|
2649
|
+
return
|
|
2650
|
+
}
|
|
2651
|
+
const style = document.createElement('style')
|
|
2652
|
+
style.id = 'dsh-memory-timeline-style'
|
|
2653
|
+
style.textContent = TIMELINE_STYLES
|
|
2654
|
+
if (document.head && typeof document.head.appendChild === 'function') document.head.appendChild(style)
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
/**
|
|
2658
|
+
* Open an absolute memory-library path in the right sidebar (shared by the
|
|
2659
|
+
* graph node reveal and the timeline event open).
|
|
2660
|
+
* @returns {Promise<{ ok: true } | { ok: false, reason: string }>}
|
|
2661
|
+
*/
|
|
2662
|
+
async function openMemoryPath(absolutePath) {
|
|
2663
|
+
const sidebar = resolveSidebarRight()
|
|
2664
|
+
if (!sidebar || typeof sidebar.openResource !== 'function') return { ok: false, reason: 'sidebar-unavailable' }
|
|
2665
|
+
const absolute = String(absolutePath).replace(/\\/g, '/')
|
|
2666
|
+
let session
|
|
2667
|
+
try {
|
|
2668
|
+
session = await fetch(SESSION_URL).then((response) => response.json())
|
|
2669
|
+
} catch {
|
|
2670
|
+
return { ok: false, reason: 'session-fetch-failed' }
|
|
2671
|
+
}
|
|
2672
|
+
if (!session || session.ok !== true || typeof session.sessionId !== 'string') return { ok: false, reason: 'no-session' }
|
|
2673
|
+
const root = typeof session.cwd === 'string' && session.cwd.length > 0
|
|
2674
|
+
? session.cwd.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
2675
|
+
: undefined
|
|
2676
|
+
const encodePath = (path) => path.split('/')
|
|
2677
|
+
.map((segment, index) => (index === 0 && /^[A-Za-z]:$/.test(segment) ? segment : encodeURIComponent(segment)))
|
|
2678
|
+
.join('/')
|
|
2679
|
+
// The sidebar only opens `session/<id>/<relative>` addresses; an absolute
|
|
2680
|
+
// address has no authorized session and cannot be claimed.
|
|
2681
|
+
if (root === undefined || (absolute !== root && !absolute.startsWith(`${root}/`))) {
|
|
2682
|
+
return { ok: false, reason: 'outside-workspace' }
|
|
2683
|
+
}
|
|
2684
|
+
const relative = absolute.slice(root.length).replace(/^\/+/, '')
|
|
2685
|
+
const address = `dsh-resource://file/session/${encodeURIComponent(session.sessionId)}/${encodePath(relative)}`
|
|
2686
|
+
try {
|
|
2687
|
+
await sidebar.openResource(address)
|
|
2688
|
+
} catch (error) {
|
|
2689
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) }
|
|
2690
|
+
}
|
|
2691
|
+
return { ok: true }
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
/** POST /api/memory/reveal to reveal a store-relative path in the OS file manager. */
|
|
2695
|
+
async function revealMemoryPath(relativePath) {
|
|
2696
|
+
try {
|
|
2697
|
+
const response = await fetch(GRAPH_REVEAL_URL, {
|
|
2698
|
+
method: 'POST',
|
|
2699
|
+
headers: { 'content-type': 'application/json' },
|
|
2700
|
+
body: JSON.stringify({ id: relativePath }),
|
|
2701
|
+
})
|
|
2702
|
+
return response.ok === true
|
|
2703
|
+
} catch {
|
|
2704
|
+
return false
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
/** Resolve a store-relative path to its absolute path and copy it. */
|
|
2709
|
+
async function copyMemoryPathToClipboard(id) {
|
|
2710
|
+
try {
|
|
2711
|
+
const response = await fetch(`${GRAPH_PATH_URL}?id=${encodeURIComponent(id)}`)
|
|
2712
|
+
const body = await response.json().catch(() => ({}))
|
|
2713
|
+
if (!response.ok || typeof body.path !== 'string') throw new Error(body.error ?? `GET ${response.status}`)
|
|
2714
|
+
if (typeof navigator === 'undefined' || !navigator.clipboard?.writeText) throw new Error('clipboard unavailable')
|
|
2715
|
+
await navigator.clipboard.writeText(body.path)
|
|
2716
|
+
return true
|
|
2717
|
+
} catch {
|
|
2718
|
+
return false
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
/** Open the page a timeline event points at (falls back to log.md). */
|
|
2723
|
+
async function openTimelineEvent(event, options = {}) {
|
|
2724
|
+
const setNotice = typeof options.setNotice === 'function' ? options.setNotice : () => {}
|
|
2725
|
+
const t = typeof options.t === 'function' ? options.t : fallbackT
|
|
2726
|
+
let config
|
|
2727
|
+
try {
|
|
2728
|
+
config = await fetch(CONFIG_URL).then((response) => (response.ok ? response.json() : undefined))
|
|
2729
|
+
} catch {
|
|
2730
|
+
config = undefined
|
|
2731
|
+
}
|
|
2732
|
+
const memoryDir = typeof config?.memoryDir === 'string' && config.memoryDir.length > 0
|
|
2733
|
+
? config.memoryDir.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
2734
|
+
: undefined
|
|
2735
|
+
if (memoryDir === undefined) {
|
|
2736
|
+
setNotice(t('timelineNoMemoryDir'))
|
|
2737
|
+
return { ok: false, reason: 'no-memory-dir' }
|
|
2738
|
+
}
|
|
2739
|
+
const relative = typeof event?.path === 'string' && event.path.length > 0 ? event.path : 'log.md'
|
|
2740
|
+
const result = await openMemoryPath(`${memoryDir}/${relative}`)
|
|
2741
|
+
if (result.ok === true) {
|
|
2742
|
+
if (typeof event?.path !== 'string' || event.path.length === 0) setNotice(t('timelineNoPage'))
|
|
2743
|
+
return result
|
|
2744
|
+
}
|
|
2745
|
+
// The sidebar only previews files inside the session workspace and the
|
|
2746
|
+
// memory store usually lives elsewhere: reveal the file instead of
|
|
2747
|
+
// claiming success that never happened (same fallback as graph nodes).
|
|
2748
|
+
if (await revealMemoryPath(relative)) {
|
|
2749
|
+
setNotice(typeof event?.path === 'string' && event.path.length > 0 ? t('timelineRevealed') : t('timelineNoPage'))
|
|
2750
|
+
return result
|
|
2751
|
+
}
|
|
2752
|
+
setNotice((await copyMemoryPathToClipboard(relative)) ? t('graphRevealFallback') : t('timelineOpenError'))
|
|
2753
|
+
return result
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
function TimelineCard(props) {
|
|
2757
|
+
const t = useT(props)
|
|
2758
|
+
ensureTimelineStyles()
|
|
2759
|
+
// `initialPayload` lets tests (and embeds) render the ready state without
|
|
2760
|
+
// a fetch; the normal host path leaves it undefined.
|
|
2761
|
+
const [payload, setPayload] = React.useState(props?.initialPayload)
|
|
2762
|
+
const [status, setStatus] = React.useState(props?.initialPayload === undefined ? 'loading' : 'ready')
|
|
2763
|
+
const [range, setRange] = React.useState('month')
|
|
2764
|
+
const [query, setQuery] = React.useState('')
|
|
2765
|
+
const [groups, setGroups] = React.useState(TIMELINE_GROUP_ORDER.slice())
|
|
2766
|
+
const activeGroups = Array.isArray(groups) ? groups : TIMELINE_GROUP_ORDER
|
|
2767
|
+
const [showAll, setShowAll] = React.useState(false)
|
|
2768
|
+
const [notice, setNotice] = React.useState(undefined)
|
|
2769
|
+
const [selectedKey, setSelectedKey] = React.useState(undefined)
|
|
2770
|
+
const listRef = React.useRef(null)
|
|
2771
|
+
|
|
2772
|
+
React.useEffect(() => {
|
|
2773
|
+
let alive = true
|
|
2774
|
+
const load = () => {
|
|
2775
|
+
fetch(TIMELINE_URL)
|
|
2776
|
+
.then(async (response) => {
|
|
2777
|
+
if (!response.ok) throw new Error(`GET ${response.status}`)
|
|
2778
|
+
return response.json()
|
|
2779
|
+
})
|
|
2780
|
+
.then((value) => {
|
|
2781
|
+
if (!alive) return
|
|
2782
|
+
setPayload(value)
|
|
2783
|
+
setStatus('ready')
|
|
2784
|
+
})
|
|
2785
|
+
.catch(() => {
|
|
2786
|
+
if (alive) setStatus((current) => (current === 'ready' ? 'ready' : 'failed'))
|
|
2787
|
+
})
|
|
2788
|
+
}
|
|
2789
|
+
load()
|
|
2790
|
+
const timer = typeof setInterval === 'function' ? setInterval(load, TIMELINE_REFRESH_MS) : undefined
|
|
2791
|
+
return () => {
|
|
2792
|
+
alive = false
|
|
2793
|
+
if (timer !== undefined) clearInterval(timer)
|
|
2794
|
+
}
|
|
2795
|
+
}, [])
|
|
2796
|
+
|
|
2797
|
+
if (status === 'loading') {
|
|
2798
|
+
return React.createElement('div', { style: { ...cardStyle, fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)' } }, t('timelineLoading'))
|
|
2799
|
+
}
|
|
2800
|
+
if (status === 'failed' && payload === undefined) return null
|
|
2801
|
+
|
|
2802
|
+
const allEvents = payload && Array.isArray(payload.events) ? payload.events : []
|
|
2803
|
+
const stats = payload && payload.stats ? payload.stats : {}
|
|
2804
|
+
const visible = visibleTimelineEvents(allEvents, showAll)
|
|
2805
|
+
const since = timelineRangeStart(visible, range)
|
|
2806
|
+
const filtered = filterTimelineEvents(visible, { query, groups: activeGroups, since })
|
|
2807
|
+
const buckets = buildDayBuckets(filtered)
|
|
2808
|
+
const maxBucket = buckets.reduce((max, bucket) => Math.max(max, bucket.count), 1)
|
|
2809
|
+
|
|
2810
|
+
// newest-first day groups for the list
|
|
2811
|
+
const days = new Map()
|
|
2812
|
+
for (const event of filtered) {
|
|
2813
|
+
if (!days.has(event.date)) days.set(event.date, [])
|
|
2814
|
+
days.get(event.date).push(event)
|
|
2815
|
+
}
|
|
2816
|
+
const dayEntries = [...days.entries()].sort((a, b) => (a[0] < b[0] ? 1 : a[0] > b[0] ? -1 : 0))
|
|
2817
|
+
|
|
2818
|
+
const groupLabel = (group) => group === 'fix'
|
|
2819
|
+
? t('timelineLegendFix')
|
|
2820
|
+
: group === 'feat'
|
|
2821
|
+
? t('timelineLegendFeat')
|
|
2822
|
+
: group === 'publish'
|
|
2823
|
+
? t('timelineLegendPublish')
|
|
2824
|
+
: group === 'decision'
|
|
2825
|
+
? t('timelineLegendDecision')
|
|
2826
|
+
: t('timelineLegendOther')
|
|
2827
|
+
|
|
2828
|
+
const groupColor = (group) => TIMELINE_GROUP_COLORS[group] ?? TIMELINE_GROUP_COLORS.other
|
|
2829
|
+
|
|
2830
|
+
const toggleGroup = (group) => {
|
|
2831
|
+
setGroups((current) => {
|
|
2832
|
+
const list = Array.isArray(current) ? current : TIMELINE_GROUP_ORDER
|
|
2833
|
+
return list.includes(group)
|
|
2834
|
+
? (list.length === 1 ? list : list.filter((item) => item !== group))
|
|
2835
|
+
: [...list, group]
|
|
2836
|
+
})
|
|
2837
|
+
}
|
|
2838
|
+
const scrollToDay = (date) => {
|
|
2839
|
+
setSelectedKey(undefined)
|
|
2840
|
+
try {
|
|
2841
|
+
scrollDayWithinList(listRef.current, date)
|
|
2842
|
+
} catch {
|
|
2843
|
+
// scrolling is best-effort
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
const rangeButtons = ['week', 'month', 'all'].map((key) =>
|
|
2848
|
+
React.createElement('button', {
|
|
2849
|
+
key,
|
|
2850
|
+
type: 'button',
|
|
2851
|
+
className: range === key ? 'dsh-mem-tl-on' : undefined,
|
|
2852
|
+
onClick: () => setRange(key),
|
|
2853
|
+
}, key === 'week' ? t('timelineRangeWeek') : key === 'month' ? t('timelineRangeMonth') : t('timelineRangeAll')),
|
|
2854
|
+
)
|
|
2855
|
+
|
|
2856
|
+
const filters = React.createElement('div', { className: 'dsh-mem-tl-filters' },
|
|
2857
|
+
React.createElement('div', { className: 'dsh-mem-tl-row1' },
|
|
2858
|
+
React.createElement('span', { className: 'dsh-mem-tl-range' }, rangeButtons),
|
|
2859
|
+
React.createElement('input', {
|
|
2860
|
+
className: 'dsh-mem-tl-search',
|
|
2861
|
+
type: 'search',
|
|
2862
|
+
value: query,
|
|
2863
|
+
placeholder: t('timelineSearchPlaceholder'),
|
|
2864
|
+
onChange: (event) => setQuery(event.target.value ?? ''),
|
|
2865
|
+
}),
|
|
2866
|
+
React.createElement('label', { className: 'dsh-mem-tl-showall' },
|
|
2867
|
+
React.createElement('input', { type: 'checkbox', checked: showAll, onChange: (event) => setShowAll(event.target.checked === true) }),
|
|
2868
|
+
t('timelineShowAll'),
|
|
2869
|
+
),
|
|
2870
|
+
React.createElement('span', { className: 'dsh-mem-tl-countflow' },
|
|
2871
|
+
fill(t('timelineFilteredStats'), { shown: String(filtered.length) })),
|
|
2872
|
+
),
|
|
2873
|
+
React.createElement('div', { className: 'dsh-mem-tl-row2' },
|
|
2874
|
+
TIMELINE_GROUP_ORDER.map((group) =>
|
|
2875
|
+
React.createElement('button', {
|
|
2876
|
+
key: group,
|
|
2877
|
+
type: 'button',
|
|
2878
|
+
className: `dsh-mem-tl-typechip${activeGroups.includes(group) ? ' dsh-mem-tl-on' : ''}`,
|
|
2879
|
+
onClick: () => toggleGroup(group),
|
|
2880
|
+
'aria-pressed': activeGroups.includes(group),
|
|
2881
|
+
},
|
|
2882
|
+
React.createElement('i', { style: { background: groupColor(group) } }),
|
|
2883
|
+
groupLabel(group),
|
|
2884
|
+
),
|
|
2885
|
+
),
|
|
2886
|
+
),
|
|
2887
|
+
)
|
|
2888
|
+
|
|
2889
|
+
const overview = React.createElement('div', { className: 'dsh-mem-tl-overview' },
|
|
2890
|
+
buckets.map((bucket) =>
|
|
2891
|
+
React.createElement('div', {
|
|
2892
|
+
key: bucket.date,
|
|
2893
|
+
className: 'dsh-mem-tl-daybar',
|
|
2894
|
+
style: {
|
|
2895
|
+
height: `${Math.max(4, Math.round((bucket.count / maxBucket) * 38) + 4)}px`,
|
|
2896
|
+
background: groupColor(dominantTimelineGroup(bucket)),
|
|
2897
|
+
},
|
|
2898
|
+
title: `${bucket.date} · ${fill(t('timelineDayCount'), { count: String(bucket.count) })}`,
|
|
2899
|
+
onClick: () => scrollToDay(bucket.date),
|
|
2900
|
+
})),
|
|
2901
|
+
)
|
|
2902
|
+
|
|
2903
|
+
const list = React.createElement('div', { className: 'dsh-mem-tl-list', ref: listRef },
|
|
2904
|
+
dayEntries.length === 0
|
|
2905
|
+
? React.createElement('div', { className: 'dsh-mem-tl-empty' }, t('timelineFilterEmpty'))
|
|
2906
|
+
: dayEntries.map(([date, dayEvents]) =>
|
|
2907
|
+
React.createElement('div', { key: date, className: 'dsh-mem-tl-daygroup', 'data-day': date },
|
|
2908
|
+
React.createElement('div', { className: 'dsh-mem-tl-dayhead' },
|
|
2909
|
+
React.createElement('span', null, date),
|
|
2910
|
+
React.createElement('span', null, fill(t('timelineDayCount'), { count: String(dayEvents.length) })),
|
|
2911
|
+
),
|
|
2912
|
+
dayEvents.map((event, index) => {
|
|
2913
|
+
const key = `${date}-${index}`
|
|
2914
|
+
const group = typeof event.group === 'string' ? event.group : timelineGroupOf(event.kind)
|
|
2915
|
+
return React.createElement('div', {
|
|
2916
|
+
key,
|
|
2917
|
+
className: `dsh-mem-tl-row${selectedKey === key ? ' dsh-mem-tl-rowsel' : ''}`,
|
|
2918
|
+
title: event.title.length > 0 ? `${event.title}\n${t('timelineOpenHint')}` : t('timelineOpenHint'),
|
|
2919
|
+
onClick: () => setSelectedKey(key),
|
|
2920
|
+
onDoubleClick: () => { openTimelineEvent(event, { t, setNotice }) },
|
|
2921
|
+
},
|
|
2922
|
+
React.createElement('span', { className: 'dsh-mem-tl-dot', style: { background: groupColor(group) } }),
|
|
2923
|
+
React.createElement('span', { className: 'dsh-mem-tl-kind' }, groupLabel(group)),
|
|
2924
|
+
React.createElement('span', { className: 'dsh-mem-tl-title' }, event.title),
|
|
2925
|
+
typeof event.path === 'string' && event.path.length > 0
|
|
2926
|
+
? React.createElement('span', { className: 'dsh-mem-tl-path' }, event.path)
|
|
2927
|
+
: null,
|
|
2928
|
+
)
|
|
2929
|
+
}),
|
|
2930
|
+
))
|
|
2931
|
+
)
|
|
2932
|
+
|
|
2933
|
+
return React.createElement('div', { style: cardStyle },
|
|
2934
|
+
React.createElement('div', { style: { display: 'flex', alignItems: 'baseline', gap: '10px', flexWrap: 'wrap', marginBottom: '8px' } },
|
|
2935
|
+
React.createElement('span', { style: { fontSize: '13px', fontWeight: 600 } }, t('memoryViewTimeline')),
|
|
2936
|
+
React.createElement('span', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #9aa0aa)' } },
|
|
2937
|
+
fill(t('timelineStats'), { events: String(allEvents.length), first: String(stats.first ?? ''), last: String(stats.last ?? '') })),
|
|
2938
|
+
),
|
|
2939
|
+
filters,
|
|
2940
|
+
buckets.length > 0 ? overview : null,
|
|
2941
|
+
list,
|
|
2942
|
+
notice !== undefined ? React.createElement('div', { className: 'dsh-mem-tl-notice' }, notice) : null,
|
|
2943
|
+
React.createElement('div', { className: 'dsh-mem-tl-notice' }, t('timelineHint')),
|
|
2944
|
+
)
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2446
2947
|
function GraphCard(props) {
|
|
2447
2948
|
const t = useT(props)
|
|
2448
2949
|
const [graph, setGraph] = React.useState(undefined)
|
|
@@ -2651,6 +3152,20 @@ window.__ModuleLoader__.load({
|
|
|
2651
3152
|
InsightsCard,
|
|
2652
3153
|
GraphCard,
|
|
2653
3154
|
GraphView,
|
|
3155
|
+
TimelineCard,
|
|
3156
|
+
visibleTimelineEvents,
|
|
3157
|
+
timelineGroupOf,
|
|
3158
|
+
timelineRangeStart,
|
|
3159
|
+
filterTimelineEvents,
|
|
3160
|
+
buildDayBuckets,
|
|
3161
|
+
dominantTimelineGroup,
|
|
3162
|
+
scrollDayWithinList,
|
|
3163
|
+
revealMemoryPath,
|
|
3164
|
+
copyMemoryPathToClipboard,
|
|
3165
|
+
TIMELINE_GROUP_ORDER,
|
|
3166
|
+
openTimelineEvent,
|
|
3167
|
+
openMemoryPath,
|
|
3168
|
+
TIMELINE_URL,
|
|
2654
3169
|
DICTS,
|
|
2655
3170
|
LOCALE_NS,
|
|
2656
3171
|
fallbackT,
|