dsh-plugin-memory 0.20.0 → 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 +13 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/docs/market/index.json +2 -2
- package/lib/client.js +346 -348
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.21.0] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- 时间轴滚动只发生在列表内部(移除 `scrollIntoView`,改用列表 `scrollTop`;面板/列表启用 `overflow-anchor: none` 与 `overscroll-behavior: contain`),点击 tab 或日期不再把设置面板顶走。
|
|
10
|
+
- 双击事件失败时不再谎称「已打开」:先调用 `/api/memory/reveal` 在系统文件管理器中定位,失败再复制绝对路径兜底。
|
|
11
|
+
- 勾选「显示全部事件」+「全部」范围时,早于首个关键事件的笔记/过程事件不再被丢弃。
|
|
12
|
+
- 空结果只显示一次提示;列表行 tooltip 显示完整标题。
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **时间轴视图重构(轨道 → 概览条 + 事件列表)**:按「鸡肋」复盘调整——轨道压缩为按天密度概览条(点击跳转到该日),主区域改为事件列表(按日期倒序分组,显示类型徽标 / 完整标题 / 关联页面,双击打开);新增「最近 7 天 / 30 天 / 全部」范围、标题/日期/类型搜索、5 类事件过滤、筛选计数;移除旧的站点缩放联动与标签碰撞布局(含死代码与对应测试)。
|
|
17
|
+
|
|
5
18
|
## [0.20.0] - 2026-11-16
|
|
6
19
|
|
|
7
20
|
### Added
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ then install **Memory** from the list. (A JSON index in the official format, ser
|
|
|
48
48
|
- **A companion** — digest nudge, proactive recall, weekly growth recap, context-sensitive tone; shared speech floor with other proactive plugins.
|
|
49
49
|
- **Portable** — plain markdown + git, `pack`/`unpack`, optional auto-commit.
|
|
50
50
|
- **Memory graph** — interactive 3D sphere: rotate / zoom / drag nodes, search-to-focus, hover or click to light up neighbours; select a node → **Reveal in Finder** or **Copy path**; **double-click a node to open its file in the DSH sidebar** (falls back to the OS file manager).
|
|
51
|
-
- **Timeline** — the same store
|
|
51
|
+
- **Timeline** — the same store as an event log with a density overview bar: pick last 7 days / last 30 days / all, search by title/date/kind, filter by event type, click a day bar to jump; double-click an event to open its page (falls back to `log.md`); follows the light/dark DSH theme.
|
|
52
52
|
- **Health tools** — dashboard, `checkup`, `lint`, `doctor`, automatic `last_access` stamping.
|
|
53
53
|
- **Zero build, bilingual panel, hot-editable config.**
|
|
54
54
|
|
package/README.zh.md
CHANGED
|
@@ -48,7 +48,7 @@ https://raw.githubusercontent.com/LittleBlackTong/dsh-plugin-memory/main/docs/ma
|
|
|
48
48
|
- **像个搭子** —— digest 提醒、主动追忆、每周成长回顾、按语境调语气;与其它主动插件共享发言权仲裁。
|
|
49
49
|
- **可迁移** —— 纯 markdown + git,`pack`/`unpack` 搬家,可选自动提交。
|
|
50
50
|
- **记忆图谱** —— 可交互 3D 球面:旋转/缩放/拖节点整理、搜索定位、悬停或点击点亮邻居;选中节点可 **在 Finder 中显示** 或 **复制路径**;**双击节点直接在 DSH 侧栏打开该文件**(打不开时回退系统文件管理器)。
|
|
51
|
-
- **时间轴** ——
|
|
51
|
+
- **时间轴** —— 概览条 + 事件列表:按天密度的概览条点击跳转,主区域按日期倒序列出事件(类型徽标 / 完整标题 / 关联页面,双击打开);支持最近 7 天 / 30 天 / 全部、标题/日期/类型搜索、5 类事件过滤;深浅主题自适应。
|
|
52
52
|
- **健康工具** —— 看板、`checkup`、`lint`、`doctor`、自动 `last_access`。
|
|
53
53
|
- **零构建、面板双语、配置热改。**
|
|
54
54
|
|
package/docs/market/index.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -182,23 +182,26 @@ window.__ModuleLoader__.load({
|
|
|
182
182
|
memoryViewGraph: '图谱',
|
|
183
183
|
memoryViewTimeline: '时间轴',
|
|
184
184
|
timelineLoading: '正在读取记忆时间轴…',
|
|
185
|
-
timelineEmpty: '还没有可展示的记忆事件',
|
|
186
185
|
timelineShowAll: '显示全部事件(含笔记/过程)',
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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: '已在系统文件管理器中打开',
|
|
190
198
|
timelineNoPage: '该事件没有对应页面,已打开 log.md',
|
|
191
|
-
timelineOpenFailed: '打开失败:',
|
|
192
199
|
timelineStats: '共 {events} 条事件 · {first} → {last}',
|
|
193
|
-
timelineScaleDay: '日',
|
|
194
200
|
timelineLegendFix: '修复',
|
|
195
201
|
timelineLegendFeat: '功能',
|
|
196
202
|
timelineLegendPublish: '发布',
|
|
197
203
|
timelineLegendDecision: '决策',
|
|
198
204
|
timelineLegendOther: '其他',
|
|
199
|
-
timelineScaleWeek: '周',
|
|
200
|
-
timelineScaleMonth: '月',
|
|
201
|
-
timelineScaleYear: '年',
|
|
202
205
|
graphStats: '{pages} 页 · {links} 条页间互链 · {tagEdges} 条共享 tag',
|
|
203
206
|
graphIndexRoutes: '{count} 条索引路由(虚线)',
|
|
204
207
|
graphIsolated: '{count} 页暂时孤立',
|
|
@@ -361,23 +364,26 @@ window.__ModuleLoader__.load({
|
|
|
361
364
|
memoryViewGraph: 'Graph',
|
|
362
365
|
memoryViewTimeline: 'Timeline',
|
|
363
366
|
timelineLoading: 'Loading the memory timeline…',
|
|
364
|
-
timelineEmpty: 'No memory events to show yet',
|
|
365
367
|
timelineShowAll: 'Show all events (including notes/process)',
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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',
|
|
369
380
|
timelineNoPage: 'This event has no linked page, so log.md was opened instead',
|
|
370
|
-
timelineOpenFailed: 'Open failed: ',
|
|
371
381
|
timelineStats: '{events} events · {first} → {last}',
|
|
372
|
-
timelineScaleDay: 'day',
|
|
373
382
|
timelineLegendFix: 'fix',
|
|
374
383
|
timelineLegendFeat: 'feature',
|
|
375
384
|
timelineLegendPublish: 'release',
|
|
376
385
|
timelineLegendDecision: 'decision',
|
|
377
386
|
timelineLegendOther: 'other',
|
|
378
|
-
timelineScaleWeek: 'week',
|
|
379
|
-
timelineScaleMonth: 'month',
|
|
380
|
-
timelineScaleYear: 'year',
|
|
381
387
|
graphStats: '{pages} pages · {links} page links · {tagEdges} shared tags',
|
|
382
388
|
graphIndexRoutes: '{count} index routes (dashed)',
|
|
383
389
|
graphIsolated: '{count} pages isolated',
|
|
@@ -599,6 +605,7 @@ window.__ModuleLoader__.load({
|
|
|
599
605
|
// timeline. Only the active one is mounted, so the graph's polling stops
|
|
600
606
|
// while the timeline is open (and vice versa).
|
|
601
607
|
const [view, setView] = React.useState('graph')
|
|
608
|
+
const activeView = view === 'timeline' ? 'timeline' : 'graph'
|
|
602
609
|
const t = useT(props)
|
|
603
610
|
const tabStyle = (active) => ({
|
|
604
611
|
appearance: 'none',
|
|
@@ -611,7 +618,7 @@ window.__ModuleLoader__.load({
|
|
|
611
618
|
cursor: 'pointer',
|
|
612
619
|
})
|
|
613
620
|
return React.createElement(LocaleContext.Provider, { value: t },
|
|
614
|
-
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' } },
|
|
615
622
|
React.createElement(SectionBoundary, null,
|
|
616
623
|
React.createElement(SoulCard),
|
|
617
624
|
),
|
|
@@ -619,21 +626,21 @@ window.__ModuleLoader__.load({
|
|
|
619
626
|
React.createElement('button', {
|
|
620
627
|
type: 'button',
|
|
621
628
|
role: 'tab',
|
|
622
|
-
'aria-selected':
|
|
629
|
+
'aria-selected': activeView === 'graph',
|
|
623
630
|
onClick: () => setView('graph'),
|
|
624
|
-
style: tabStyle(
|
|
631
|
+
style: tabStyle(activeView === 'graph'),
|
|
625
632
|
}, t('memoryViewGraph')),
|
|
626
633
|
React.createElement('button', {
|
|
627
634
|
type: 'button',
|
|
628
635
|
role: 'tab',
|
|
629
|
-
'aria-selected':
|
|
636
|
+
'aria-selected': activeView === 'timeline',
|
|
630
637
|
onClick: () => setView('timeline'),
|
|
631
|
-
style: tabStyle(
|
|
638
|
+
style: tabStyle(activeView === 'timeline'),
|
|
632
639
|
}, t('memoryViewTimeline')),
|
|
633
640
|
),
|
|
634
641
|
// The active projection follows the soul card: the thing people open
|
|
635
642
|
// the panel for should be visible without scrolling.
|
|
636
|
-
|
|
643
|
+
activeView === 'graph'
|
|
637
644
|
? React.createElement(SectionBoundary, { key: `graph-${gen}` },
|
|
638
645
|
React.createElement(GraphCard),
|
|
639
646
|
)
|
|
@@ -1694,22 +1701,28 @@ window.__ModuleLoader__.load({
|
|
|
1694
1701
|
}
|
|
1695
1702
|
|
|
1696
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')
|
|
1697
1715
|
function ensureGraphStyles() {
|
|
1698
|
-
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
|
+
}
|
|
1699
1722
|
const style = document.createElement('style')
|
|
1700
1723
|
style.id = 'dsh-memory-graph-style'
|
|
1701
|
-
style.textContent =
|
|
1702
|
-
|
|
1703
|
-
'.dsh-memory-graph-svg g { transition: transform .18s cubic-bezier(.2,.8,.2,1); }',
|
|
1704
|
-
'.dsh-memory-graph-svg.anim-off g { transition: none; }',
|
|
1705
|
-
'.dsh-memory-graph-svg.dragging g { transition: none; }',
|
|
1706
|
-
'.dsh-memory-graph-svg.entering g { transform: scale(.08); opacity: 0; }',
|
|
1707
|
-
'.dsh-memory-graph-svg.graph-drop g { transition: transform .32s cubic-bezier(.2,.9,.2,1.05); }',
|
|
1708
|
-
'.dsh-memory-graph-svg circle, .dsh-memory-graph-svg text { transition: opacity .12s; }',
|
|
1709
|
-
'.dsh-memory-graph-svg.hovering g:not(.lit) circle,' +
|
|
1710
|
-
'.dsh-memory-graph-svg.hovering g:not(.lit) text { opacity: .18; }',
|
|
1711
|
-
].join('\n')
|
|
1712
|
-
document.head.appendChild(style)
|
|
1724
|
+
style.textContent = GRAPH_STYLES
|
|
1725
|
+
if (document.head && typeof document.head.appendChild === 'function') document.head.appendChild(style)
|
|
1713
1726
|
}
|
|
1714
1727
|
|
|
1715
1728
|
/**
|
|
@@ -2080,23 +2093,10 @@ window.__ModuleLoader__.load({
|
|
|
2080
2093
|
setQuery('')
|
|
2081
2094
|
}
|
|
2082
2095
|
|
|
2083
|
-
|
|
2084
|
-
const copyPathToClipboard = async (id) => {
|
|
2085
|
-
try {
|
|
2086
|
-
const response = await fetch(`${GRAPH_PATH_URL}?id=${encodeURIComponent(id)}`)
|
|
2087
|
-
const body = await response.json().catch(() => ({}))
|
|
2088
|
-
if (!response.ok || typeof body.path !== 'string') throw new Error(body.error ?? `GET ${response.status}`)
|
|
2089
|
-
if (typeof navigator === 'undefined' || !navigator.clipboard?.writeText) throw new Error('clipboard unavailable')
|
|
2090
|
-
await navigator.clipboard.writeText(body.path)
|
|
2091
|
-
return true
|
|
2092
|
-
} catch {
|
|
2093
|
-
return false
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2096
|
+
// Clipboard fallback is shared with the timeline (module-level helper).
|
|
2097
2097
|
/** 「复制路径」按钮。 */
|
|
2098
2098
|
const copyNodePath = async (id) => {
|
|
2099
|
-
setNotice((await
|
|
2099
|
+
setNotice((await copyMemoryPathToClipboard(id)) ? t('graphCopied') : t('graphCopyFailed'))
|
|
2100
2100
|
}
|
|
2101
2101
|
|
|
2102
2102
|
/** 「在 Finder 中显示」按钮 + 双击节点;失败时自动复制路径兜底。 */
|
|
@@ -2114,7 +2114,7 @@ window.__ModuleLoader__.load({
|
|
|
2114
2114
|
.then(() => setNotice(noticeAfterSuccess))
|
|
2115
2115
|
.catch(async (error) => {
|
|
2116
2116
|
const message = error instanceof Error ? error.message : String(error)
|
|
2117
|
-
const copied = await
|
|
2117
|
+
const copied = await copyMemoryPathToClipboard(id)
|
|
2118
2118
|
setNotice(copied ? t('graphRevealFallback') : `${t('graphRevealFailed')}${message}`)
|
|
2119
2119
|
})
|
|
2120
2120
|
}
|
|
@@ -2500,7 +2500,6 @@ window.__ModuleLoader__.load({
|
|
|
2500
2500
|
// viewport without a DOM; the card only wires state and pointer events.
|
|
2501
2501
|
const TIMELINE_URL = '/api/memory/timeline'
|
|
2502
2502
|
const TIMELINE_REFRESH_MS = 20000
|
|
2503
|
-
const TIMELINE_HEIGHT = 340
|
|
2504
2503
|
const TIMELINE_DAY_MS = 86400000
|
|
2505
2504
|
/** Process-noise kinds hidden unless "show all events" is on. */
|
|
2506
2505
|
const TIMELINE_NOISE = new Set(['note','digest','install','uninstall','setup','bootstrap','task','probe','recall','consolidate','ops','schedule','export'])
|
|
@@ -2513,16 +2512,6 @@ window.__ModuleLoader__.load({
|
|
|
2513
2512
|
const TIMELINE_GROUP_COLORS = { fix: '#e5484d', feat: '#30a46c', publish: '#0091ff', decision: '#8e4ec6', other: '#d97706' }
|
|
2514
2513
|
const timelineGroupOf = (kind) => TIMELINE_GROUPS[kind] ?? 'other'
|
|
2515
2514
|
const timelineDateMs = (date) => Date.parse(`${date}T00:00:00Z`)
|
|
2516
|
-
const isTimelineNoise = (kind) => TIMELINE_NOISE.has(kind)
|
|
2517
|
-
const pad2 = (value) => String(value).padStart(2, '0')
|
|
2518
|
-
|
|
2519
|
-
/** Zoom density → calendar granularity (day/week/month/year). */
|
|
2520
|
-
function scaleFor(pxPerDay) {
|
|
2521
|
-
if (!Number.isFinite(pxPerDay) || pxPerDay >= 30) return 'day'
|
|
2522
|
-
if (pxPerDay >= 7) return 'week'
|
|
2523
|
-
if (pxPerDay >= 1.6) return 'month'
|
|
2524
|
-
return 'year'
|
|
2525
|
-
}
|
|
2526
2515
|
|
|
2527
2516
|
function visibleTimelineEvents(events, showAll) {
|
|
2528
2517
|
const list = Array.isArray(events)
|
|
@@ -2532,149 +2521,136 @@ window.__ModuleLoader__.load({
|
|
|
2532
2521
|
return showAll ? list : list.filter((event) => !TIMELINE_NOISE.has(event.kind))
|
|
2533
2522
|
}
|
|
2534
2523
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
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
|
|
2540
2538
|
}
|
|
2541
2539
|
|
|
2542
2540
|
/**
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2541
|
+
* Filter events for the list view: free-text query over title/date/kind,
|
|
2542
|
+
* type groups and an optional lower time bound.
|
|
2545
2543
|
*/
|
|
2546
|
-
function
|
|
2547
|
-
const
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
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
|
+
})
|
|
2557
2561
|
}
|
|
2558
2562
|
|
|
2559
2563
|
/**
|
|
2560
|
-
*
|
|
2561
|
-
*
|
|
2562
|
-
* @returns {{ axis: { left: number, width: number }, ticks: object[], stations: object[], labels: object[], first?: string, last?: string }}
|
|
2564
|
+
* Per-day buckets for the overview bar: count and per-group totals.
|
|
2565
|
+
* @returns {{ date: string, count: number, groups: Record<string, number> }[]}
|
|
2563
2566
|
*/
|
|
2564
|
-
function
|
|
2565
|
-
const list = visibleTimelineEvents(events, showAll)
|
|
2566
|
-
const px = Number.isFinite(pxPerDay) && pxPerDay > 0 ? pxPerDay : 54
|
|
2567
|
-
const w = Number.isFinite(width) && width > 0 ? width : 720
|
|
2568
|
-
const dx = Number.isFinite(offset) ? offset : 0
|
|
2569
|
-
const empty = { axis: { left: 0, width: 0 }, ticks: [], stations: [], labels: [], first: undefined, last: undefined }
|
|
2570
|
-
if (list.length === 0) return empty
|
|
2571
|
-
const minT = timelineDateMs(list[0].date)
|
|
2572
|
-
const maxT = timelineDateMs(list[list.length - 1].date)
|
|
2573
|
-
if (!Number.isFinite(minT) || !Number.isFinite(maxT)) return empty
|
|
2574
|
-
const xFor = (t) => ((t - minT) / TIMELINE_DAY_MS) * px + dx
|
|
2575
|
-
const scale = scaleFor(px)
|
|
2576
|
-
const ticks = []
|
|
2577
|
-
const pushTick = (t, label) => {
|
|
2578
|
-
const x = xFor(t)
|
|
2579
|
-
if (x >= -80 && x <= w + 80) ticks.push({ x, label })
|
|
2580
|
-
}
|
|
2581
|
-
if (scale === 'day') {
|
|
2582
|
-
const step = Math.max(7, Math.ceil(70 / px / 7) * 7)
|
|
2583
|
-
for (let t = minT; t <= maxT; t += step * TIMELINE_DAY_MS) pushTick(t, timelineDateLabel(t))
|
|
2584
|
-
} else if (scale === 'week') {
|
|
2585
|
-
let t = minT - ((new Date(minT).getUTCDay() + 6) % 7) * TIMELINE_DAY_MS
|
|
2586
|
-
for (; t <= maxT; t += 14 * TIMELINE_DAY_MS) pushTick(t, timelineDateLabel(t))
|
|
2587
|
-
} else if (scale === 'month') {
|
|
2588
|
-
const firstYear = new Date(minT).getUTCFullYear()
|
|
2589
|
-
const lastYear = new Date(maxT).getUTCFullYear()
|
|
2590
|
-
for (let year = firstYear; year <= lastYear; year += 1) {
|
|
2591
|
-
for (let month = 0; month < 12; month += 1) {
|
|
2592
|
-
const t = Date.UTC(year, month, 1)
|
|
2593
|
-
if (t < minT - 31 * TIMELINE_DAY_MS || t > maxT + 31 * TIMELINE_DAY_MS) continue
|
|
2594
|
-
pushTick(t, timelineDateLabel(t, 'ym'))
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
} else {
|
|
2598
|
-
const lastYear = new Date(maxT).getUTCFullYear()
|
|
2599
|
-
for (let year = new Date(minT).getUTCFullYear() - 1; year <= lastYear + 1; year += 1) {
|
|
2600
|
-
const t = Date.UTC(year, 0, 1)
|
|
2601
|
-
if (t < minT - 60 * TIMELINE_DAY_MS || t > maxT + 60 * TIMELINE_DAY_MS) continue
|
|
2602
|
-
pushTick(t, String(year))
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
// Stations: same-day events fan out horizontally and zigzag vertically.
|
|
2567
|
+
function buildDayBuckets(events) {
|
|
2606
2568
|
const byDay = new Map()
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
byDay.
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
|
-
// Labels: keep only the ones that do not collide with the left neighbour.
|
|
2630
|
-
const labels = []
|
|
2631
|
-
let lastRight = -Infinity
|
|
2632
|
-
for (const station of [...stations].sort((a, b) => a.x - b.x)) {
|
|
2633
|
-
const text = station.title.length > 22 ? `${station.title.slice(0, 21)}…` : station.title
|
|
2634
|
-
const labelWidth = Math.min(200, text.length * 11 + 14)
|
|
2635
|
-
if (station.x - labelWidth / 2 - lastRight < 8) continue
|
|
2636
|
-
labels.push({ x: station.x, y: station.y > TIMELINE_HEIGHT / 2 ? station.y + 22 : station.y - 22, text, width: labelWidth })
|
|
2637
|
-
lastRight = station.x + labelWidth / 2
|
|
2638
|
-
}
|
|
2639
|
-
const axisLeft = xFor(minT) - 40
|
|
2640
|
-
return {
|
|
2641
|
-
axis: { left: axisLeft, width: Math.max(0, xFor(maxT) + 40 - axisLeft) },
|
|
2642
|
-
ticks,
|
|
2643
|
-
stations,
|
|
2644
|
-
labels,
|
|
2645
|
-
first: list[0].date,
|
|
2646
|
-
last: list[list.length - 1].date,
|
|
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
|
+
}
|
|
2647
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
|
|
2648
2609
|
}
|
|
2649
2610
|
|
|
2650
|
-
/**
|
|
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')
|
|
2651
2643
|
function ensureTimelineStyles() {
|
|
2652
|
-
if (typeof document === 'undefined'
|
|
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
|
+
}
|
|
2653
2651
|
const style = document.createElement('style')
|
|
2654
2652
|
style.id = 'dsh-memory-timeline-style'
|
|
2655
|
-
style.textContent =
|
|
2656
|
-
'.dsh-mem-tl-stage{position:relative;height:' + TIMELINE_HEIGHT + 'px;overflow:hidden;cursor:grab;user-select:none;border:1px solid var(--dsw-alias-border-l2,#3a3c42);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#1d1e22)}',
|
|
2657
|
-
'.dsh-mem-tl-stage.dsh-mem-tl-drag{cursor:grabbing}',
|
|
2658
|
-
'.dsh-mem-tl-axis{position:absolute;top:50%;height:2px;background:var(--dsw-alias-border-l2,#4b4d55);border-radius:2px}',
|
|
2659
|
-
'.dsh-mem-tl-tick{position:absolute;top:calc(50% + 52px);transform:translateX(-50%);font-size:10.5px;color:var(--dsw-alias-label-secondary,#9aa0aa);white-space:nowrap;font-variant-numeric:tabular-nums}',
|
|
2660
|
-
'.dsh-mem-tl-tick::before{content:"";position:absolute;left:50%;top:-9px;width:1px;height:9px;background:var(--dsw-alias-border-l2,#3a3c42)}',
|
|
2661
|
-
'.dsh-mem-tl-station{position:absolute;transform:translate(-50%,-50%);border-radius:50%;cursor:pointer;border:2px solid var(--dsw-alias-bg-layer-1,#1b1c1f);box-shadow:0 0 0 3px rgba(0,0,0,.12)}',
|
|
2662
|
-
'.dsh-mem-tl-station:hover{box-shadow:0 0 0 3px rgba(120,140,180,.25)}',
|
|
2663
|
-
'.dsh-mem-tl-station.dsh-mem-tl-sel{box-shadow:0 0 0 3px rgba(120,140,180,.55)}',
|
|
2664
|
-
'.dsh-mem-tl-label{position:absolute;transform:translate(-50%,-50%);font-size:11px;line-height:1;color:var(--dsw-alias-label-secondary,#9aa0aa);background:var(--dsw-alias-bg-layer-1,rgba(20,21,24,.72));padding:3px 5px;border-radius:4px;white-space:nowrap;pointer-events:none;border:1px solid var(--dsw-alias-border-l2,#2b2d33);overflow:hidden;text-overflow:ellipsis}',
|
|
2665
|
-
'.dsh-mem-tl-detail{display:flex;gap:10px;align-items:baseline;font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0aa);min-height:20px;margin-top:8px}',
|
|
2666
|
-
'.dsh-mem-tl-detail .dsh-mem-tl-dot{flex:none;width:9px;height:9px;border-radius:50%;transform:translateY(1px)}',
|
|
2667
|
-
'.dsh-mem-tl-detail .dsh-mem-tl-date{flex:none;color:var(--dsw-alias-label-secondary,#8b929e);font-variant-numeric:tabular-nums}',
|
|
2668
|
-
'.dsh-mem-tl-detail .dsh-mem-tl-kind{flex:none;padding:1px 6px;border-radius:4px;background:var(--dsw-alias-bg-layer-2,#2f3137);color:var(--dsw-alias-label-secondary,#c9cdd4);font-size:11px}',
|
|
2669
|
-
'.dsh-mem-tl-detail .dsh-mem-tl-text{color:var(--dsw-alias-label-primary,#e6e7ea)}',
|
|
2670
|
-
'.dsh-mem-tl-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:8px;font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0aa)}',
|
|
2671
|
-
'.dsh-mem-tl-toolbar button{appearance:none;border:1px solid var(--dsw-alias-border-l2,#3a3c42);background:var(--dsw-alias-bg-layer-2,#2a2b30);color:var(--dsw-alias-label-secondary,#9aa0aa);border-radius:6px;padding:3px 8px;font-size:12px;cursor:pointer}',
|
|
2672
|
-
'.dsh-mem-tl-toolbar button:hover{color:var(--dsw-alias-label-primary,#fff)}',
|
|
2673
|
-
'.dsh-mem-tl-toolbar label{display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none}',
|
|
2674
|
-
'.dsh-mem-tl-legend{display:flex;gap:10px;margin-left:auto;flex-wrap:wrap;font-size:11px}',
|
|
2675
|
-
'.dsh-mem-tl-legend i{display:inline-block;width:7px;height:7px;border-radius:50%;margin-right:4px;vertical-align:middle}',
|
|
2676
|
-
'.dsh-mem-tl-notice{font-size:12px;color:var(--dsw-alias-label-secondary,#9aa0aa);margin-top:6px}',
|
|
2677
|
-
].join('\n')
|
|
2653
|
+
style.textContent = TIMELINE_STYLES
|
|
2678
2654
|
if (document.head && typeof document.head.appendChild === 'function') document.head.appendChild(style)
|
|
2679
2655
|
}
|
|
2680
2656
|
|
|
@@ -2715,6 +2691,34 @@ window.__ModuleLoader__.load({
|
|
|
2715
2691
|
return { ok: true }
|
|
2716
2692
|
}
|
|
2717
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
|
+
|
|
2718
2722
|
/** Open the page a timeline event points at (falls back to log.md). */
|
|
2719
2723
|
async function openTimelineEvent(event, options = {}) {
|
|
2720
2724
|
const setNotice = typeof options.setNotice === 'function' ? options.setNotice : () => {}
|
|
@@ -2729,7 +2733,7 @@ window.__ModuleLoader__.load({
|
|
|
2729
2733
|
? config.memoryDir.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
2730
2734
|
: undefined
|
|
2731
2735
|
if (memoryDir === undefined) {
|
|
2732
|
-
setNotice(
|
|
2736
|
+
setNotice(t('timelineNoMemoryDir'))
|
|
2733
2737
|
return { ok: false, reason: 'no-memory-dir' }
|
|
2734
2738
|
}
|
|
2735
2739
|
const relative = typeof event?.path === 'string' && event.path.length > 0 ? event.path : 'log.md'
|
|
@@ -2738,25 +2742,32 @@ window.__ModuleLoader__.load({
|
|
|
2738
2742
|
if (typeof event?.path !== 'string' || event.path.length === 0) setNotice(t('timelineNoPage'))
|
|
2739
2743
|
return result
|
|
2740
2744
|
}
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
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'))
|
|
2744
2753
|
return result
|
|
2745
2754
|
}
|
|
2746
2755
|
|
|
2747
2756
|
function TimelineCard(props) {
|
|
2748
2757
|
const t = useT(props)
|
|
2749
2758
|
ensureTimelineStyles()
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
const [
|
|
2753
|
-
const [
|
|
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
|
|
2754
2767
|
const [showAll, setShowAll] = React.useState(false)
|
|
2755
|
-
const [selected, setSelected] = React.useState(undefined)
|
|
2756
2768
|
const [notice, setNotice] = React.useState(undefined)
|
|
2757
|
-
const [
|
|
2758
|
-
const
|
|
2759
|
-
const dragRef = React.useRef(undefined)
|
|
2769
|
+
const [selectedKey, setSelectedKey] = React.useState(undefined)
|
|
2770
|
+
const listRef = React.useRef(null)
|
|
2760
2771
|
|
|
2761
2772
|
React.useEffect(() => {
|
|
2762
2773
|
let alive = true
|
|
@@ -2783,169 +2794,151 @@ window.__ModuleLoader__.load({
|
|
|
2783
2794
|
}
|
|
2784
2795
|
}, [])
|
|
2785
2796
|
|
|
2786
|
-
React.useEffect(() => {
|
|
2787
|
-
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
2788
|
-
const measure = () => {
|
|
2789
|
-
const node = stageRef.current
|
|
2790
|
-
if (node && typeof node.clientWidth === 'number' && node.clientWidth > 0) setWidth(node.clientWidth)
|
|
2791
|
-
}
|
|
2792
|
-
measure()
|
|
2793
|
-
window.addEventListener('resize', measure)
|
|
2794
|
-
return () => window.removeEventListener('resize', measure)
|
|
2795
|
-
}, [])
|
|
2796
|
-
|
|
2797
|
-
const events = payload && Array.isArray(payload.events) ? payload.events : []
|
|
2798
|
-
const stats = payload && payload.stats ? payload.stats : {}
|
|
2799
|
-
const layoutWidth = width > 0 ? width : 720
|
|
2800
|
-
const resolvedOffset = offset === null ? initialTimelineOffset({ events, width: layoutWidth, pxPerDay }) : offset
|
|
2801
|
-
const layout = React.useMemo(
|
|
2802
|
-
() => computeTimelineLayout({ events, width: layoutWidth, offset: resolvedOffset, pxPerDay, showAll }),
|
|
2803
|
-
[events, layoutWidth, resolvedOffset, pxPerDay, showAll],
|
|
2804
|
-
)
|
|
2805
|
-
const clampOffset = (value) => {
|
|
2806
|
-
if (layout.first === undefined || layout.last === undefined) return 0
|
|
2807
|
-
const span = (timelineDateMs(layout.last) - timelineDateMs(layout.first)) / TIMELINE_DAY_MS * pxPerDay
|
|
2808
|
-
return Math.min(60, Math.max(layoutWidth - 40 - span, value))
|
|
2809
|
-
}
|
|
2810
|
-
const scaleKey = scaleFor(pxPerDay)
|
|
2811
|
-
const scaleLabel = scaleKey === 'day'
|
|
2812
|
-
? t('timelineScaleDay')
|
|
2813
|
-
: scaleKey === 'week'
|
|
2814
|
-
? t('timelineScaleWeek')
|
|
2815
|
-
: scaleKey === 'month'
|
|
2816
|
-
? t('timelineScaleMonth')
|
|
2817
|
-
: t('timelineScaleYear')
|
|
2818
|
-
|
|
2819
|
-
const onPointerDown = (event) => {
|
|
2820
|
-
dragRef.current = { x: event.clientX, startOffset: resolvedOffset }
|
|
2821
|
-
if (event.currentTarget && event.currentTarget.classList) event.currentTarget.classList.add('dsh-mem-tl-drag')
|
|
2822
|
-
}
|
|
2823
|
-
const onPointerMove = (event) => {
|
|
2824
|
-
const drag = dragRef.current
|
|
2825
|
-
if (drag === undefined) return
|
|
2826
|
-
setOffset(clampOffset(drag.startOffset + (event.clientX - drag.x)))
|
|
2827
|
-
}
|
|
2828
|
-
const stopDrag = (event) => {
|
|
2829
|
-
dragRef.current = undefined
|
|
2830
|
-
if (event && event.currentTarget && event.currentTarget.classList) event.currentTarget.classList.remove('dsh-mem-tl-drag')
|
|
2831
|
-
}
|
|
2832
|
-
const backToToday = () => {
|
|
2833
|
-
setOffset(null)
|
|
2834
|
-
setPxPerDay(54)
|
|
2835
|
-
}
|
|
2836
|
-
|
|
2837
|
-
// Wheel zooms the track, never the settings panel: React's onWheel is a
|
|
2838
|
-
// passive listener (preventDefault is ignored), so the stage gets a
|
|
2839
|
-
// native non-passive listener once it exists. stopPropagation keeps the
|
|
2840
|
-
// surrounding scroll container from moving as well.
|
|
2841
|
-
const wheelStateRef = React.useRef({ pxPerDay: 54, offset: 0 })
|
|
2842
|
-
wheelStateRef.current = { pxPerDay, offset: resolvedOffset }
|
|
2843
|
-
React.useEffect(() => {
|
|
2844
|
-
const node = stageRef.current
|
|
2845
|
-
if (!node || typeof node.addEventListener !== 'function') return undefined
|
|
2846
|
-
const onTimelineWheel = (event) => {
|
|
2847
|
-
event.preventDefault()
|
|
2848
|
-
event.stopPropagation()
|
|
2849
|
-
const rect = typeof node.getBoundingClientRect === 'function' ? node.getBoundingClientRect() : { left: 0 }
|
|
2850
|
-
const mouseX = event.clientX - rect.left
|
|
2851
|
-
const current = wheelStateRef.current
|
|
2852
|
-
const ratio = event.deltaY < 0 ? 1.18 : 1 / 1.18
|
|
2853
|
-
const next = Math.min(240, Math.max(1.4, current.pxPerDay * ratio))
|
|
2854
|
-
setOffset(mouseX - (mouseX - current.offset) * (next / current.pxPerDay))
|
|
2855
|
-
setPxPerDay(next)
|
|
2856
|
-
}
|
|
2857
|
-
node.addEventListener('wheel', onTimelineWheel, { passive: false })
|
|
2858
|
-
return () => {
|
|
2859
|
-
if (typeof node.removeEventListener === 'function') node.removeEventListener('wheel', onTimelineWheel)
|
|
2860
|
-
}
|
|
2861
|
-
}, [status, events.length])
|
|
2862
|
-
|
|
2863
2797
|
if (status === 'loading') {
|
|
2864
2798
|
return React.createElement('div', { style: { ...cardStyle, fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #888)' } }, t('timelineLoading'))
|
|
2865
2799
|
}
|
|
2866
2800
|
if (status === 'failed' && payload === undefined) return null
|
|
2867
2801
|
|
|
2868
|
-
const
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
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) })),
|
|
2878
2872
|
),
|
|
2879
|
-
React.createElement('
|
|
2880
|
-
|
|
2881
|
-
React.createElement('
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
? t('timelineLegendDecision')
|
|
2891
|
-
: t('timelineLegendOther'),
|
|
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),
|
|
2892
2884
|
),
|
|
2893
2885
|
),
|
|
2894
2886
|
),
|
|
2895
2887
|
)
|
|
2896
2888
|
|
|
2897
|
-
const
|
|
2898
|
-
|
|
2899
|
-
className: 'dsh-mem-tl-stage',
|
|
2900
|
-
style: { height: TIMELINE_HEIGHT },
|
|
2901
|
-
onPointerDown,
|
|
2902
|
-
onPointerMove,
|
|
2903
|
-
onPointerUp: stopDrag,
|
|
2904
|
-
onPointerCancel: stopDrag,
|
|
2905
|
-
},
|
|
2906
|
-
React.createElement('div', { className: 'dsh-mem-tl-axis', style: { left: layout.axis.left, width: layout.axis.width } }),
|
|
2907
|
-
layout.ticks.map((tick, index) =>
|
|
2908
|
-
React.createElement('div', { key: `tick-${index}`, className: 'dsh-mem-tl-tick', style: { left: tick.x } }, tick.label),
|
|
2909
|
-
),
|
|
2910
|
-
layout.stations.map((station, index) =>
|
|
2889
|
+
const overview = React.createElement('div', { className: 'dsh-mem-tl-overview' },
|
|
2890
|
+
buckets.map((bucket) =>
|
|
2911
2891
|
React.createElement('div', {
|
|
2912
|
-
key:
|
|
2913
|
-
className:
|
|
2892
|
+
key: bucket.date,
|
|
2893
|
+
className: 'dsh-mem-tl-daybar',
|
|
2914
2894
|
style: {
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
width: station.size,
|
|
2918
|
-
height: station.size,
|
|
2919
|
-
background: TIMELINE_GROUP_COLORS[station.group] ?? TIMELINE_GROUP_COLORS.other,
|
|
2895
|
+
height: `${Math.max(4, Math.round((bucket.count / maxBucket) * 38) + 4)}px`,
|
|
2896
|
+
background: groupColor(dominantTimelineGroup(bucket)),
|
|
2920
2897
|
},
|
|
2921
|
-
title: `${
|
|
2922
|
-
onClick: () =>
|
|
2923
|
-
|
|
2924
|
-
}),
|
|
2925
|
-
),
|
|
2926
|
-
layout.labels.map((label, index) =>
|
|
2927
|
-
React.createElement('div', { key: `label-${index}`, className: 'dsh-mem-tl-label', style: { left: label.x, top: label.y, maxWidth: label.width } }, label.text),
|
|
2928
|
-
),
|
|
2898
|
+
title: `${bucket.date} · ${fill(t('timelineDayCount'), { count: String(bucket.count) })}`,
|
|
2899
|
+
onClick: () => scrollToDay(bucket.date),
|
|
2900
|
+
})),
|
|
2929
2901
|
)
|
|
2930
2902
|
|
|
2931
|
-
const
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
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
|
+
)
|
|
2939
2932
|
|
|
2940
2933
|
return React.createElement('div', { style: cardStyle },
|
|
2941
2934
|
React.createElement('div', { style: { display: 'flex', alignItems: 'baseline', gap: '10px', flexWrap: 'wrap', marginBottom: '8px' } },
|
|
2942
2935
|
React.createElement('span', { style: { fontSize: '13px', fontWeight: 600 } }, t('memoryViewTimeline')),
|
|
2943
2936
|
React.createElement('span', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-secondary, #9aa0aa)' } },
|
|
2944
|
-
fill(t('timelineStats'), { events: String(
|
|
2937
|
+
fill(t('timelineStats'), { events: String(allEvents.length), first: String(stats.first ?? ''), last: String(stats.last ?? '') })),
|
|
2945
2938
|
),
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2939
|
+
filters,
|
|
2940
|
+
buckets.length > 0 ? overview : null,
|
|
2941
|
+
list,
|
|
2949
2942
|
notice !== undefined ? React.createElement('div', { className: 'dsh-mem-tl-notice' }, notice) : null,
|
|
2950
2943
|
React.createElement('div', { className: 'dsh-mem-tl-notice' }, t('timelineHint')),
|
|
2951
2944
|
)
|
|
@@ -3160,11 +3153,16 @@ window.__ModuleLoader__.load({
|
|
|
3160
3153
|
GraphCard,
|
|
3161
3154
|
GraphView,
|
|
3162
3155
|
TimelineCard,
|
|
3163
|
-
scaleFor,
|
|
3164
|
-
computeTimelineLayout,
|
|
3165
|
-
initialTimelineOffset,
|
|
3166
3156
|
visibleTimelineEvents,
|
|
3167
3157
|
timelineGroupOf,
|
|
3158
|
+
timelineRangeStart,
|
|
3159
|
+
filterTimelineEvents,
|
|
3160
|
+
buildDayBuckets,
|
|
3161
|
+
dominantTimelineGroup,
|
|
3162
|
+
scrollDayWithinList,
|
|
3163
|
+
revealMemoryPath,
|
|
3164
|
+
copyMemoryPathToClipboard,
|
|
3165
|
+
TIMELINE_GROUP_ORDER,
|
|
3168
3166
|
openTimelineEvent,
|
|
3169
3167
|
openMemoryPath,
|
|
3170
3168
|
TIMELINE_URL,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-memory",
|
|
3
3
|
"description": "Long-term memory plugin for DeepSeek Harness: persistent cross-session markdown memory with a soul/persona file, auto-injected at every session start, plus remember/recall/consolidate/forget workflows and portable migration tooling.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|