dsh-timeback 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,8 +53,10 @@ files: s0 s1 s2 s3 │ └─ C′ (new branch, context
53
53
  ## Where it appears
54
54
 
55
55
  - **Notes board** — its own right-sidebar tab (open it from the Timeback panel
56
- header or the sidebar guide): a global Markdown board for hand-written notes
57
- and for notes written by the session through `timeback_note`.
56
+ header or the sidebar guide): a Markdown board **scoped to the current
57
+ workspace** (different workspaces keep separate boards; sessions in the same
58
+ directory share one), for hand-written notes and for notes written by the
59
+ session through `timeback_note`.
58
60
  - **Card notes** — every canvas card has a 📝 button; the Markdown note shows on
59
61
  the card and in the detail pane.
60
62
  - **Workspace menu / New Session row**: the workspace-level recording switch
@@ -104,7 +106,7 @@ desktop app):
104
106
  ```bash
105
107
  # From npm (published: https://www.npmjs.com/package/dsh-timeback)
106
108
  dsh plugin --profile web add dsh-timeback
107
- dsh plugin --profile web add dsh-timeback@0.7.5 # pin a release
109
+ dsh plugin --profile web add dsh-timeback@0.7.6 # pin a release
108
110
 
109
111
  # Straight from GitHub (no npm release needed)
110
112
  dsh plugin --profile web add github:<owner>/dsh-timeback
@@ -171,7 +173,11 @@ caches are excluded by default (configurable), keeping snapshots small and fast.
171
173
 
172
174
  ## Notes board (记录板 · sticky notes)
173
175
 
174
- The board is a **sticky-note canvas** with a graph-paper background:
176
+ The board is a **sticky-note canvas** with a graph-paper background. Boards are
177
+ scoped to the workspace directory, so two projects never mix their notes; the
178
+ old global board is migrated into the first workspace that opens the board.
179
+ Clicking outside the note editor saves the draft automatically (the explicit
180
+ “cancel” button is the only way to discard).
175
181
 
176
182
  - **Movable sticky notes** — every Markdown note is a card you can drag around the
177
183
  grid; positions and colours are remembered per board.
@@ -296,7 +302,7 @@ lock error after reloading, remove leftover `*.lock` files under
296
302
  | `timeback_checkpoint` | Create a manual checkpoint (conversation position + workspace snapshot). In `capture: workspace` mode this requires the workspace to be enabled; with `capture: off` it stays available as an explicit action |
297
303
  | `timeback_rewind` | Rewind: `branch-and-files` (default), `branch-only`, or `files-only` |
298
304
  | `timeback_workspace` | `list` / `enable` / `disable` the recording switch for one workspace (or the current one). It is a user-only privacy decision: the agent may only change it after an explicit request |
299
- | `timeback_note` | Read/write the global Markdown notes board (`list`, `create`, `update`, `delete`); rewinds restore the board with the conversation |
305
+ | `timeback_note` | Read/write this workspace's Markdown notes board (`list`, `create`, `update`, `delete`); rewinds restore the board with the conversation |
300
306
 
301
307
  ## Limitations
302
308
 
package/client.js CHANGED
@@ -23,7 +23,7 @@ window.__ModuleLoader__.load({
23
23
  const REFRESH_MS = 3000
24
24
  const MAX_ROWS = 240
25
25
  /** Bump together with package.json so a stale browser bundle is obvious. */
26
- const BUILD = '0.7.5+sticky'
26
+ const BUILD = '0.7.6+sticky'
27
27
  /** Set by apply(): opens another Session in the main column. */
28
28
  let openSessionBridge = null
29
29
  /** Set by apply(): opens the Timeback tab in the right sidebar. */
@@ -182,6 +182,7 @@ window.__ModuleLoader__.load({
182
182
  'board.deleted': '记录已删除',
183
183
  'board.count': '{count} 条记录 · 版本 v{version}',
184
184
  'board.resetSize': '默认大小',
185
+ 'board.autosaveHint': '点击弹窗外会自动保存',
185
186
  'board.resizeHint': '可拖拽弹框右边缘、下边缘或右下角调整大小',
186
187
  'board.error': '记录板操作失败:{error}',
187
188
  'board.agentHint': '提示:让会话调用 timeback_note 工具即可把结论写进记录板;回溯时记录板会一起回退。',
@@ -346,7 +347,7 @@ window.__ModuleLoader__.load({
346
347
  'note.saved': 'Card note saved',
347
348
  'note.removed': 'Card note deleted',
348
349
  'board.title': 'Notes board',
349
- 'board.subtitle': 'Global Markdown notes · rewinds restore them too',
350
+ 'board.subtitle': 'This workspace’s Markdown notes · rewinds restore them too',
350
351
  'md.bold': 'Bold',
351
352
  'md.italic': 'Italic',
352
353
  'md.strike': 'Strikethrough',
@@ -369,7 +370,7 @@ window.__ModuleLoader__.load({
369
370
  'md.hint': 'Type directly: select text and press a toolbar button to format it immediately (e.g. select 你好 and press B). Source and preview tabs are still available.',
370
371
  'board.newSticky': 'New sticky',
371
372
  'board.stickyColor': 'Sticky colour',
372
- 'board.stickyHint': 'Sticky notes are draggable; draw on the grid or on a note, erase strokes with the eraser.',
373
+ 'board.stickyHint': 'Sticky notes are draggable; draw on the grid or on a note, erase strokes with the eraser. Clicking outside the editor auto-saves.',
373
374
  'board.resizeNote': 'Drag to resize the sticky',
374
375
  'board.drawOnSticky': 'Draw on stickies',
375
376
  'board.drawOnStickyOn': 'Sticky drawing: on',
@@ -431,6 +432,7 @@ window.__ModuleLoader__.load({
431
432
  'board.deleted': 'Note deleted',
432
433
  'board.count': '{count} notes · version v{version}',
433
434
  'board.resetSize': 'Default size',
435
+ 'board.autosaveHint': 'Clicking outside the dialog saves automatically',
434
436
  'board.resizeHint': 'Drag the right edge, bottom edge or bottom-right corner to resize',
435
437
  'board.error': 'Notes board failed: {error}',
436
438
  'board.agentHint': 'Tip: ask the session to use the timeback_note tool; rewinds roll the board back with the conversation.',
@@ -619,7 +621,7 @@ window.__ModuleLoader__.load({
619
621
  .tb-link.current{stroke-width:2.6;opacity:1;filter:drop-shadow(0 0 3px currentColor)}
620
622
  .tb-lane-label{position:absolute;transform:translateY(-50%);max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;line-height:16px;border:1px solid;border-radius:999px;padding:0 8px;background:var(--dsw-alias-bg-base,#16181d);color:var(--dsw-alias-label-secondary,#9aa0a6);opacity:.85}
621
623
  .tb-lane-label.current{opacity:1;font-weight:600}
622
- .tb-card{position:absolute;width:246px;height:116px;animation:tb-card-pop .19s ease-out;box-sizing:border-box;border-radius:12px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.96));box-shadow:0 2px 8px rgba(0,0,0,.18);padding:8px 10px;display:flex;flex-direction:column;gap:5px;cursor:pointer;overflow:hidden;transition:box-shadow .12s, border-color .12s, transform .12s}
624
+ .tb-card{position:absolute;width:246px;height:116px;animation:tb-card-fade .15s ease-out;box-sizing:border-box;border-radius:12px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.96));box-shadow:0 2px 8px rgba(0,0,0,.18);padding:8px 10px;display:flex;flex-direction:column;gap:5px;cursor:pointer;overflow:hidden;transition:box-shadow .12s, border-color .12s, transform .12s;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
623
625
  .tb-card:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--tb-color,#4d7cfe);opacity:.55;border-radius:12px 0 0 12px}
624
626
  .tb-card:hover{transform:translateY(-1px);box-shadow:0 6px 16px rgba(0,0,0,.26)}
625
627
  .tb-folder-slot{position:absolute;z-index:0;border:2px dashed var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6);border-radius:14px;background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color,#4176e6) 10%, transparent);display:flex;align-items:center;justify-content:center;pointer-events:none;animation:tb-slot-in .16s ease-out}
@@ -636,19 +638,22 @@ window.__ModuleLoader__.load({
636
638
  .tb-card.current{border-color:var(--tb-color,#4d7cfe);box-shadow:0 0 0 2px color-mix(in srgb, var(--tb-color,#4d7cfe) 32%, transparent), 0 6px 16px rgba(0,0,0,.24)}
637
639
  .tb-card.selected{border-color:var(--tb-color,#4d7cfe);box-shadow:0 0 0 3px color-mix(in srgb, var(--tb-color,#4d7cfe) 42%, transparent), 0 8px 20px rgba(0,0,0,.3)}
638
640
  .tb-card-head{display:flex;align-items:center;gap:6px;min-height:18px}
639
- .tb-card-branch{font-size:10.5px;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:96px;line-height:16px}
640
- .tb-card-badge{font-size:10.5px;font-weight:700;line-height:16px;border-radius:999px;padding:0 7px;color:var(--tb-color,#4d7cfe);border:1px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 55%, transparent);background:color-mix(in srgb, var(--tb-color,#4d7cfe) 12%, transparent);white-space:nowrap}
641
+ .tb-card-branch{font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:96px;line-height:16px}
642
+ .tb-card-badge{font-size:11px;font-weight:700;line-height:16px;border-radius:999px;padding:0 7px;color:var(--tb-color,#4d7cfe);border:1px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 55%, transparent);background:color-mix(in srgb, var(--tb-color,#4d7cfe) 12%, transparent);white-space:nowrap}
641
643
  .tb-card-spacer{flex:1}
642
644
  .tb-card-time{font-size:10px;color:var(--dsw-alias-label-tertiary,#8a919c);white-space:nowrap}
643
645
  .tb-card-dot{width:7px;height:7px;border-radius:50%;background:var(--tb-color,#4d7cfe);box-shadow:0 0 0 3px color-mix(in srgb, var(--tb-color,#4d7cfe) 25%, transparent)}
644
- .tb-card-prompt{font-size:11.5px;line-height:1.45;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;flex:1;word-break:break-word}
646
+ .tb-card-prompt{font-size:12px;line-height:1.45;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;flex:1;word-break:break-word}
645
647
  .tb-card-foot{display:flex;align-items:center;gap:5px;flex-wrap:wrap;font-size:10px;min-height:16px}
646
648
  .tb-card-chip{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));border-radius:4px;padding:0 4px;line-height:14px;color:var(--dsw-alias-label-tertiary,#8a919c)}
647
649
  .tb-card-chip.manual{border-style:dashed}
648
650
  .tb-card-chip.warn{color:var(--dsw-alias-state-warning-primary,#f0b23e);border-color:currentColor}
649
- .tb-card-action{margin-left:auto;appearance:none;border:1px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 45%, transparent);background:color-mix(in srgb, var(--tb-color,#4d7cfe) 12%, transparent);color:var(--tb-color,#4d7cfe);border-radius:4px;padding:0 5px;line-height:15px;font-size:9.5px;cursor:pointer;white-space:nowrap}
651
+ .tb-card-action{margin-left:auto;appearance:none;border:1px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 45%, transparent);background:color-mix(in srgb, var(--tb-color,#4d7cfe) 12%, transparent);color:var(--tb-color,#4d7cfe);border-radius:4px;padding:0 5px;line-height:15px;font-size:10px;cursor:pointer;white-space:nowrap}
650
652
  .tb-card-action:hover{background:color-mix(in srgb, var(--tb-color,#4d7cfe) 24%, transparent)}
651
653
  .tb-card.folder{border-style:dashed;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05))}
654
+ .tb-card.folder:not(.expanded){height:172px}
655
+ .tb-card.folder>.tb-card-head,.tb-card.folder>.tb-card-prompt,.tb-card.folder>.tb-card-foot{flex:0 0 auto}
656
+ .tb-card.folder:not(.expanded)>.tb-folder-members{flex:1;min-height:0}
652
657
  .tb-card.folder.expanded{width:370px;height:auto;min-height:116px;max-height:460px;z-index:6;overflow:auto;cursor:grab;background:var(--dsw-alias-bg-layer-2,rgba(28,32,40,.98))}
653
658
  .tb-folder-expanded{display:flex;flex-direction:column;gap:3px;overflow:auto;min-height:0}
654
659
  .tb-folder-hint{font-size:10px;line-height:1.4;color:var(--dsw-alias-label-tertiary,#8a919c);margin-bottom:1px}
@@ -661,16 +666,16 @@ window.__ModuleLoader__.load({
661
666
  .tb-folder-ghost-label{font-weight:700;color:var(--dsw-alias-label-primary,#e6e6e6);white-space:nowrap}
662
667
  .tb-folder-ghost-prompt{color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
663
668
  .tb-folder-ghost.dropping{animation:tb-ghost-drop .2s ease-in forwards}
664
- @keyframes tb-card-pop{from{opacity:0;transform:scale(.72) translateY(4px)}to{opacity:1;transform:scale(1) translateY(0)}}
669
+ @keyframes tb-card-fade{from{opacity:0}to{opacity:1}}
665
670
  @keyframes tb-ghost-drop{to{opacity:0;transform:scale(.18) translateY(2px);filter:blur(1px)}}
666
671
  .tb-folder-members{display:flex;flex-direction:column;gap:2px;overflow:hidden;flex:1;min-height:0}
667
672
  .tb-folder-member{font-size:10.5px;line-height:1.35;color:var(--dsw-alias-label-secondary,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:4px;padding:1px 4px;background:var(--dsw-alias-bg-base,rgba(0,0,0,.18))}
668
673
  .tb-card-action.danger{border-color:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 55%, transparent);background:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 10%, transparent);color:var(--dsw-alias-state-error-primary,#ff7a59)}
669
674
  .tb-card-action.danger:hover{background:color-mix(in srgb, var(--dsw-alias-state-error-primary,#ff7a59) 22%, transparent)}
670
675
  .tb-card:active{cursor:grabbing}
671
- .tb-card-note{font-size:10.5px;line-height:1.35;color:var(--dsw-alias-label-primary,#d7dbe2);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-word;border-left:2px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 65%, transparent);padding-left:6px}
676
+ .tb-card-note{font-size:11px;line-height:1.35;color:var(--dsw-alias-label-primary,#d7dbe2);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-word;border-left:2px solid color-mix(in srgb, var(--tb-color,#4d7cfe) 65%, transparent);padding-left:6px}
672
677
  .tb-card-prompt.withnote{-webkit-line-clamp:1;font-size:11px}
673
- .tb-card-editnote{margin-left:auto;appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05));color:var(--dsw-alias-label-secondary,#9aa0a6);border-radius:4px;padding:0 5px;line-height:15px;font-size:9.5px;cursor:pointer;white-space:nowrap}
678
+ .tb-card-editnote{margin-left:auto;appearance:none;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.05));color:var(--dsw-alias-label-secondary,#9aa0a6);border-radius:4px;padding:0 5px;line-height:15px;font-size:10px;cursor:pointer;white-space:nowrap}
674
679
  .tb-card-editnote:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}
675
680
  .tb-card-editnote.has{color:var(--tb-color,#4d7cfe);border-color:color-mix(in srgb, var(--tb-color,#4d7cfe) 50%, transparent)}
676
681
  .tb-overlay{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.35);display:flex;justify-content:flex-end;align-items:stretch}
@@ -1142,6 +1147,8 @@ window.__ModuleLoader__.load({
1142
1147
  /** Card dimensions and spacing of the conversation canvas. */
1143
1148
  const CARD_WIDTH = 246
1144
1149
  const CARD_HEIGHT = 116
1150
+ /** Collapsed folder cards are taller so member rows and the footer never clip. */
1151
+ const FOLDER_CARD_HEIGHT = 172
1145
1152
  const CARD_GAP_X = 54
1146
1153
  const CARD_GAP_Y = 38
1147
1154
  const CANVAS_PAD = 46
@@ -1498,6 +1505,7 @@ window.__ModuleLoader__.load({
1498
1505
  prompt: null,
1499
1506
  note: null,
1500
1507
  checkpoints: [],
1508
+ height: FOLDER_CARD_HEIGHT,
1501
1509
  onPath: members.some((member) => member.onPath),
1502
1510
  createdAt: members[0].createdAt ?? null,
1503
1511
  },
@@ -1573,8 +1581,9 @@ window.__ModuleLoader__.load({
1573
1581
  for (const card of cards) card.isCurrentPosition = card.key === currentKey
1574
1582
  const minX = cards.length === 0 ? 0 : Math.min(...cards.map((card) => card.x))
1575
1583
  const minY = cards.length === 0 ? 0 : Math.min(...cards.map((card) => card.y))
1584
+ const cardHeight = (card) => (card.kind === 'folder' && !card.expanded ? FOLDER_CARD_HEIGHT : CARD_HEIGHT)
1576
1585
  const maxX = cards.length === 0 ? 320 : Math.max(...cards.map((card) => card.x + CARD_WIDTH))
1577
- const maxY = cards.length === 0 ? 220 : Math.max(...cards.map((card) => card.y + CARD_HEIGHT))
1586
+ const maxY = cards.length === 0 ? 220 : Math.max(...cards.map((card) => card.y + cardHeight(card)))
1578
1587
  // Cards may carry negative coordinates after a drag. The world layer keeps
1579
1588
  // a fixed origin (no per-frame offset feedback) so dragging behaves the
1580
1589
  // same in every direction; the camera translate reveals negative space.
@@ -1924,7 +1933,7 @@ window.__ModuleLoader__.load({
1924
1933
  left: targetCard.x - 5,
1925
1934
  top: targetCard.y - 5,
1926
1935
  width: CARD_WIDTH + 10,
1927
- height: CARD_HEIGHT + 10,
1936
+ height: (targetCard.kind === 'folder' ? FOLDER_CARD_HEIGHT : CARD_HEIGHT) + 10,
1928
1937
  },
1929
1938
  'aria-hidden': true,
1930
1939
  },
@@ -2362,7 +2371,12 @@ window.__ModuleLoader__.load({
2362
2371
  const world = worldRef.current
2363
2372
  if (world) {
2364
2373
  const camera = cameraRef.current
2365
- world.style.transform = `translate(${camera.x}px, ${camera.y}px) scale(${camera.scale})`
2374
+ // Snap the translation to real device pixels. A fractional CSS px
2375
+ // offset makes the browser rasterize every card's text on a half pixel,
2376
+ // which is what looks "糊" on desktop WebViews.
2377
+ const ratio = typeof window !== 'undefined' && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1
2378
+ const snap = (value) => Math.round(value * ratio) / ratio
2379
+ world.style.transform = `translate(${snap(camera.x)}px, ${snap(camera.y)}px) scale(${camera.scale})`
2366
2380
  }
2367
2381
  if (announceZoom) setZoom(cameraRef.current.scale)
2368
2382
  }
@@ -2377,7 +2391,11 @@ window.__ModuleLoader__.load({
2377
2391
  const height = viewport.clientHeight || 320
2378
2392
  const spanX = Math.max(1, current.maxX - current.minX)
2379
2393
  const spanY = Math.max(1, current.maxY - current.minY)
2380
- const scale = Math.min(1.15, Math.max(0.35, Math.min((width - 28) / spanX, (height - 28) / spanY)))
2394
+ let scale = Math.min(1.15, Math.max(0.35, Math.min((width - 28) / spanX, (height - 28) / spanY)))
2395
+ // Prefer exactly 1x (crisp text) when the content almost fits; otherwise
2396
+ // quantize to 2 decimals so the world transform is not a repeating float.
2397
+ if (scale >= 0.92 && scale <= 1.15) scale = 1
2398
+ else scale = Math.round(scale * 100) / 100
2381
2399
  cameraRef.current = {
2382
2400
  scale,
2383
2401
  x: (width - spanX * scale) / 2 - current.minX * scale,
@@ -2606,7 +2624,7 @@ window.__ModuleLoader__.load({
2606
2624
  // Dropping back on the expanded folder itself keeps the card filed.
2607
2625
  if (
2608
2626
  worldX >= folderCard.x && worldX <= folderCard.x + CARD_WIDTH &&
2609
- worldY >= folderCard.y && worldY <= folderCard.y + CARD_HEIGHT
2627
+ worldY >= folderCard.y && worldY <= folderCard.y + FOLDER_CARD_HEIGHT
2610
2628
  ) return
2611
2629
  detachFolderMember(folderCard.folderId, member.key, {
2612
2630
  x: Math.round(worldX - CARD_WIDTH / 2),
@@ -2712,7 +2730,8 @@ window.__ModuleLoader__.load({
2712
2730
  const candidate = cards[index]
2713
2731
  if (candidate.key === card.key) continue
2714
2732
  if (worldX < candidate.x || worldX > candidate.x + CARD_WIDTH) continue
2715
- if (worldY < candidate.y || worldY > candidate.y + CARD_HEIGHT) continue
2733
+ const candidateHeight = candidate.kind === 'folder' ? FOLDER_CARD_HEIGHT : CARD_HEIGHT
2734
+ if (worldY < candidate.y || worldY > candidate.y + candidateHeight) continue
2716
2735
  return candidate
2717
2736
  }
2718
2737
  return null
@@ -2818,6 +2837,17 @@ window.__ModuleLoader__.load({
2818
2837
  })
2819
2838
  }
2820
2839
 
2840
+ /** Saving close for the card-note sheet: outside clicks never discard text. */
2841
+ const dismissCardNoteSaving = async () => {
2842
+ const editor = noteEditor
2843
+ if (!editor || editor.busy) return
2844
+ if (editor.text.trim() === '' && !editor.card.note) {
2845
+ setNoteEditor(null)
2846
+ return
2847
+ }
2848
+ await saveCardNote(false)
2849
+ }
2850
+
2821
2851
  /** Save (or clear) the note on the card being edited. */
2822
2852
  const saveCardNote = async (clear) => {
2823
2853
  const editor = noteEditor
@@ -3060,7 +3090,7 @@ window.__ModuleLoader__.load({
3060
3090
  noteEditor
3061
3091
  ? h(
3062
3092
  'div',
3063
- { className: 'tb-overlay', onClick: () => { if (!noteEditor.busy) setNoteEditor(null) } },
3093
+ { className: 'tb-overlay', onClick: dismissCardNoteSaving },
3064
3094
  h(
3065
3095
  'div',
3066
3096
  { className: 'tb-note-dialog', role: 'dialog', 'aria-modal': true, onClick: (event) => event.stopPropagation() },
@@ -4344,6 +4374,8 @@ window.__ModuleLoader__.load({
4344
4374
 
4345
4375
  function BoardPanel(props) {
4346
4376
  const t = typeof props?.t === 'function' ? props.t : (key) => key
4377
+ const boardSessionId = typeof props?.sessionId === 'string' ? props.sessionId : ''
4378
+ const boardScope = (body) => (boardSessionId ? { ...body, sessionId: boardSessionId } : body)
4347
4379
  const [state, setState] = React.useState({ loading: true, board: null, error: null })
4348
4380
  const [draft, setDraft] = React.useState(null)
4349
4381
  const [busy, setBusy] = React.useState('')
@@ -4434,7 +4466,7 @@ window.__ModuleLoader__.load({
4434
4466
 
4435
4467
  const refresh = React.useCallback(async () => {
4436
4468
  try {
4437
- const body = await request('notes')
4469
+ const body = await request(`notes${boardSessionId ? `?session=${encodeURIComponent(boardSessionId)}` : ''}`)
4438
4470
  const board = body.board ?? null
4439
4471
  setState({ loading: false, board, error: null })
4440
4472
  if (board) {
@@ -4601,7 +4633,7 @@ window.__ModuleLoader__.load({
4601
4633
  saveTimerRef.current = setTimeout(async () => {
4602
4634
  saveTimerRef.current = null
4603
4635
  try {
4604
- const body = await request('action', { method: 'POST', body: { action: 'board-canvas', canvas: next } })
4636
+ const body = await request('action', { method: 'POST', body: boardScope({ action: 'board-canvas', canvas: next }) })
4605
4637
  setState((previous) => ({ ...previous, board: body.board ?? previous.board, error: null }))
4606
4638
  } catch (error) {
4607
4639
  setState((previous) => ({ ...previous, error: error?.message || String(error) }))
@@ -4617,7 +4649,7 @@ window.__ModuleLoader__.load({
4617
4649
  clearTimeout(saveTimerRef.current)
4618
4650
  saveTimerRef.current = null
4619
4651
  }
4620
- const body = await request('action', { method: 'POST', body: { action: 'board-canvas', canvas: next } })
4652
+ const body = await request('action', { method: 'POST', body: boardScope({ action: 'board-canvas', canvas: next }) })
4621
4653
  setState((previous) => ({ ...previous, board: body.board ?? previous.board, error: null }))
4622
4654
  return body
4623
4655
  }
@@ -4736,6 +4768,15 @@ window.__ModuleLoader__.load({
4736
4768
  const closeDraft = () => {
4737
4769
  if (draft && !draft.busy) setDraft(null)
4738
4770
  }
4771
+ /** Clicking the dimmed area saves instead of silently discarding the note. */
4772
+ const dismissDraftSaving = async () => {
4773
+ if (!draft || draft.busy) return
4774
+ if (draft.title.trim() === '' && draft.body.trim() === '') {
4775
+ setDraft(null)
4776
+ return
4777
+ }
4778
+ await saveDraft()
4779
+ }
4739
4780
  const focusEntry = (id) => {
4740
4781
  setSelected(id)
4741
4782
  try {
@@ -4750,7 +4791,7 @@ window.__ModuleLoader__.load({
4750
4791
  try {
4751
4792
  const body = await request('action', {
4752
4793
  method: 'POST',
4753
- body: { action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body },
4794
+ body: boardScope({ action: 'note-save', ...(draft.id ? { id: draft.id } : {}), title: draft.title, body: draft.body }),
4754
4795
  })
4755
4796
  let board = body.board ?? state.board
4756
4797
  setState({ loading: false, board, error: null })
@@ -4794,7 +4835,7 @@ window.__ModuleLoader__.load({
4794
4835
  if (!confirmed) return
4795
4836
  setBusy(id)
4796
4837
  try {
4797
- const body = await request('action', { method: 'POST', body: { action: 'note-delete', id } })
4838
+ const body = await request('action', { method: 'POST', body: boardScope({ action: 'note-delete', id }) })
4798
4839
  setState({ loading: false, board: body.board ?? state.board, error: null })
4799
4840
  const next = cloneBoardCanvas(canvasRef.current)
4800
4841
  delete next.notes[id]
@@ -5742,7 +5783,7 @@ window.__ModuleLoader__.load({
5742
5783
  draft
5743
5784
  ? h(
5744
5785
  'div',
5745
- { className: 'tb-overlay center', onClick: closeDraft },
5786
+ { className: 'tb-overlay center', onClick: dismissDraftSaving },
5746
5787
  h(
5747
5788
  'div',
5748
5789
  {
@@ -5804,7 +5845,7 @@ window.__ModuleLoader__.load({
5804
5845
  disabled: draft.busy,
5805
5846
  placeholder: t('board.bodyPlaceholder'),
5806
5847
  }),
5807
- h('div', { className: 'tb-ws-hint' }, t('board.resizeHint')),
5848
+ h('div', { className: 'tb-ws-hint' }, `${t('board.resizeHint')} · ${t('board.autosaveHint')}`),
5808
5849
  draft.error ? h('div', { className: 'tb-feedback err' }, format(t('board.error'), { error: draft.error })) : null,
5809
5850
  h(
5810
5851
  'div',
package/docs/MARKET.md CHANGED
@@ -78,12 +78,12 @@ dshmarket;要让所有人的 dshmarket 搜到,必须走下一节的公共目
78
78
 
79
79
  ## 4. npm(已发布 0.6.0)
80
80
 
81
- `dsh-timeback@0.7.5` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
81
+ `dsh-timeback@0.7.6` 已发布到官方 npm(<https://www.npmjs.com/package/dsh-timeback>),
82
82
  用户可以直接安装/固定版本:
83
83
 
84
84
  ```bash
85
85
  dsh plugin --profile web add dsh-timeback
86
- dsh plugin --profile web add dsh-timeback@0.7.5
86
+ dsh plugin --profile web add dsh-timeback@0.7.6
87
87
  ```
88
88
 
89
89
  awesome 目录 CI 会从 npm 自动补充映射,之后市场安装和更新会走 registry。发布流程参考:
@@ -207,7 +207,7 @@ git tag v0.6.2 && git push origin v0.6.2
207
207
 
208
208
  ## 6. 发布前检查清单
209
209
 
210
- - [ ] `node --test test/*.test.js` 全绿(当前 40 个)
210
+ - [ ] `node --test test/*.test.js` 全绿(当前 65 个)
211
211
  - [ ] `package.json` 的 `version` 与 `client.js` 里的 `BUILD` 一致
212
212
  - [ ] `npm pack --dry-run` 里包含 `index.js`、`client.js`、`src/`、`locale/`、`icon.svg`、`cordis.patch.yml`
213
213
  - [ ] `LICENSE`、`ACKNOWLEDGEMENTS.md`、`README.md` 是当前行为(记录按工作区开关、删除=截断分支+归档)
@@ -221,4 +221,10 @@ git tag v0.6.2 && git push origin v0.6.2
221
221
  - **安装后插件没有 Host 行**:检查仓库根是否还有 `package.json` 的 `dsh.bundle.patch` 和 `cordis.patch.yml`;
222
222
  - **`engines.dsh` 不匹配**:DSH 安装时会拒绝;用 `>=0.2.2-rc.1 <0.3.0-0` 覆盖当前 rc 系列,升级 DSH 大版本时同步调整;
223
223
  - **工作区默认不记录**:这是设计(隐私);用户需在面板/工作区菜单/新会话行勾选;
224
+ - **发布后市场要等 24 小时才显示可更新**:这是 pnpm 11/12 的供应链保护 `minimumReleaseAge`,默认 1440 分钟(24h);dshmarket 会把过新的版本先标记为“等待”。管理员可在 profile 的 `pnpm-workspace.yaml` 放宽,例如 `minimumReleaseAge: 0`,或只豁免本插件:
225
+ ```yaml
226
+ minimumReleaseAgeExclude:
227
+ - dsh-timeback
228
+ ```
229
+ Desktop 版可能通过环境变量 `pnpm_config_minimum_release_age` 强制该窗口,需在 Desktop 设置/环境里调整。
224
230
  - **“删除后续”不是物理删除**:DSH 会话日志 append-only,本插件用“创建截断分支 + 归档旧会话”实现,旧会话可在 DSH 侧栏归档列表恢复。
package/index.js CHANGED
@@ -315,7 +315,9 @@ export function apply(ctx, rawConfig) {
315
315
  return
316
316
  }
317
317
  if (pathname === `${config.routePath}/api/notes`) {
318
- writeJson(res, 200, { ok: true, board: await service.board() }, req)
318
+ const sessionId = url.searchParams.get('session') ?? undefined
319
+ const cwd = url.searchParams.get('cwd') ?? undefined
320
+ writeJson(res, 200, { ok: true, board: await service.board({ sessionId, cwd }) }, req)
319
321
  return
320
322
  }
321
323
  if (pathname === `${config.routePath}/api/tree`) {
@@ -399,11 +401,30 @@ export function apply(ctx, rawConfig) {
399
401
  return
400
402
  }
401
403
  if (action === 'board-canvas') {
402
- writeJson(res, 200, await service.saveBoardCanvas(body.canvas ?? {}), req)
404
+ writeJson(
405
+ res,
406
+ 200,
407
+ await service.saveBoardCanvas(body.canvas ?? {}, {
408
+ sessionId: typeof body.sessionId === 'string' && body.sessionId !== '' ? body.sessionId : undefined,
409
+ cwd: typeof body.cwd === 'string' && body.cwd !== '' ? body.cwd : undefined,
410
+ }),
411
+ req,
412
+ )
403
413
  return
404
414
  }
405
415
  if (action === 'notes-list') {
406
- writeJson(res, 200, { ok: true, board: await service.board() }, req)
416
+ writeJson(
417
+ res,
418
+ 200,
419
+ {
420
+ ok: true,
421
+ board: await service.board({
422
+ sessionId: typeof body.sessionId === 'string' && body.sessionId !== '' ? body.sessionId : undefined,
423
+ cwd: typeof body.cwd === 'string' && body.cwd !== '' ? body.cwd : undefined,
424
+ }),
425
+ },
426
+ req,
427
+ )
407
428
  return
408
429
  }
409
430
  if (action === 'note-save') {
@@ -425,7 +446,15 @@ export function apply(ctx, rawConfig) {
425
446
  return
426
447
  }
427
448
  if (action === 'note-delete') {
428
- writeJson(res, 200, await service.deleteBoardNote(typeof body.id === 'string' ? body.id : ''), req)
449
+ writeJson(
450
+ res,
451
+ 200,
452
+ await service.deleteBoardNote(typeof body.id === 'string' ? body.id : '', {
453
+ sessionId: typeof body.sessionId === 'string' && body.sessionId !== '' ? body.sessionId : undefined,
454
+ cwd: typeof body.cwd === 'string' && body.cwd !== '' ? body.cwd : undefined,
455
+ }),
456
+ req,
457
+ )
429
458
  return
430
459
  }
431
460
  if (action === 'card-note') {
@@ -523,7 +552,7 @@ export function apply(ctx, rawConfig) {
523
552
  ctx.tools.register(
524
553
  tool(
525
554
  'timeback_note',
526
- '在时间回溯的全局 Markdown 记录板上读写记录。记录板与工作区无关、所有会话共享;回溯到某个检查点时,记录板也会一起恢复到该检查点时的状态。action=list 查看;create 新建(title/body,body 为 Markdown);update 修改(id/title/body);delete 删除(id)。用户让你记录笔记、决策、进展或结论时使用它。',
555
+ '在时间回溯的 Markdown 记录板上读写记录。记录板按工作区隔离:不同工作区/目录各有自己的记录板,同一工作区的所有会话共享;回溯到某个检查点时,记录板也会一起恢复到该检查点时的状态。action=list 查看;create 新建(title/body,body 为 Markdown);update 修改(id/title/body);delete 删除(id)。用户让你记录笔记、决策、进展或结论时使用它。',
527
556
  {
528
557
  action: { type: 'string', enum: ['list', 'create', 'update', 'delete'], description: 'list/create/update/delete' },
529
558
  id: { type: 'string', description: 'update/delete 的记录 id(nt-…)' },
@@ -533,16 +562,15 @@ export function apply(ctx, rawConfig) {
533
562
  },
534
563
  ['action'],
535
564
  async (args, exec) => {
565
+ const toolSessionId = typeof args.sessionId === 'string' && args.sessionId !== '' ? args.sessionId : exec?.agent?.session?.id
536
566
  if (args.action === 'list') {
537
- const sessionId = typeof args.sessionId === 'string' && args.sessionId !== '' ? args.sessionId : exec?.agent?.session?.id
538
- return { ok: true, ...(await service.board()), sessionId: sessionId ?? null }
567
+ return { ok: true, ...(await service.board({ sessionId: toolSessionId })), sessionId: toolSessionId ?? null }
539
568
  }
540
569
  if (args.action === 'create') {
541
- const sessionId = typeof args.sessionId === 'string' && args.sessionId !== '' ? args.sessionId : exec?.agent?.session?.id
542
- return service.saveBoardNote({ title: args.title, body: args.body, sessionId }, 'agent')
570
+ return service.saveBoardNote({ title: args.title, body: args.body, sessionId: toolSessionId }, 'agent')
543
571
  }
544
- if (args.action === 'update') return service.saveBoardNote({ id: args.id, title: args.title, body: args.body }, 'agent')
545
- if (args.action === 'delete') return service.deleteBoardNote(String(args.id ?? ''))
572
+ if (args.action === 'update') return service.saveBoardNote({ id: args.id, title: args.title, body: args.body, sessionId: toolSessionId }, 'agent')
573
+ if (args.action === 'delete') return service.deleteBoardNote(String(args.id ?? ''), { sessionId: toolSessionId })
546
574
  throw new TimebackError(`未知操作:${String(args.action)}`, 'timeback/action-unknown')
547
575
  },
548
576
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-timeback",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Conversation tree with per-turn workspace snapshots for DeepSeek Harness: branch at any checkpoint and restore the files that turn had.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/service.js CHANGED
@@ -8,9 +8,10 @@
8
8
  * event sequence numbers; nothing here appends Session events.
9
9
  */
10
10
 
11
- import { randomUUID } from 'node:crypto'
11
+ import { createHash, randomUUID } from 'node:crypto'
12
12
  import { promises as fs } from 'node:fs'
13
13
  import path from 'node:path'
14
+ import { NotesStore } from './notes.js'
14
15
  import { workspaceContains, workspaceKey } from './registry.js'
15
16
 
16
17
  /** A user-facing operation failure. */
@@ -73,6 +74,76 @@ export class TimebackService {
73
74
  this.sessionTitle = options.sessionTitle ?? null
74
75
  this.workspaceRegistry = options.workspaceRegistry ?? null
75
76
  this.notes = options.notes ?? null
77
+ this.scopedNotes = new Map()
78
+ this.notesInit = Promise.resolve()
79
+ }
80
+
81
+ /**
82
+ * Notes board for one workspace directory (each workspace gets its own board).
83
+ * The legacy global board is migrated into the first workspace that asks for
84
+ * a board; every other workspace starts empty.
85
+ * @param cwd - canonical workspace directory, or null for the legacy global board.
86
+ * @returns {Promise<NotesStore|null>}
87
+ */
88
+ async notesFor(cwd) {
89
+ if (!this.notes) return null
90
+ if (!cwd) return this.openNotes(this.notes)
91
+ const canonical = await this.canonicalDir(cwd)
92
+ const id = createHash('sha1').update(canonical).digest('hex').slice(0, 16)
93
+ const cached = this.scopedNotes.get(id)
94
+ if (cached) return this.openNotes(cached)
95
+ const dir = path.join(this.config.dataDir, 'boards', id)
96
+ this.notesInit = this.notesInit.then(async () => {
97
+ try {
98
+ await fs.access(path.join(dir, 'notes.json'))
99
+ return
100
+ } catch {
101
+ // First access to this workspace's board.
102
+ }
103
+ await fs.mkdir(dir, { recursive: true, mode: 0o700 })
104
+ const marker = path.join(this.config.dataDir, 'boards', '.legacy-copied')
105
+ let copied = false
106
+ try {
107
+ await fs.access(marker)
108
+ copied = true
109
+ } catch {
110
+ copied = false
111
+ }
112
+ if (!copied) {
113
+ try {
114
+ await fs.copyFile(this.notes.file, path.join(dir, 'notes.json'))
115
+ await fs.cp(this.notes.historyDir, path.join(dir, 'notes-history'), { recursive: true }).catch(() => {})
116
+ } catch {
117
+ // No legacy board, or it could not be copied: start empty.
118
+ }
119
+ await fs.writeFile(marker, new Date().toISOString(), 'utf8').catch(() => {})
120
+ }
121
+ })
122
+ await this.notesInit
123
+ const raced = this.scopedNotes.get(id)
124
+ if (raced) return this.openNotes(raced)
125
+ const store = new NotesStore({ dataDir: dir, logger: this.logger })
126
+ await store.open()
127
+ this.scopedNotes.set(id, store)
128
+ return store
129
+ }
130
+
131
+ async openNotes(store) {
132
+ await store.open()
133
+ return store
134
+ }
135
+
136
+ /** Notes board selected by an explicit session/cwd (legacy board when absent). */
137
+ async notesForInput(input = {}) {
138
+ if (!input || (!input.cwd && !input.sessionId)) return this.notesFor(null)
139
+ const cwd = await this.resolveWorkspace(input)
140
+ return this.notesFor(cwd)
141
+ }
142
+
143
+ /** Current board version of the workspace a session/cwd belongs to. */
144
+ async notesVersionFor(cwd) {
145
+ const notes = await this.notesFor(cwd)
146
+ return notes?.version ?? null
76
147
  }
77
148
 
78
149
  /** Prepare persistent state and probe git availability. */
@@ -374,7 +445,7 @@ export class TimebackService {
374
445
  prompt: record.prompt,
375
446
  snapshot: after.snapshot,
376
447
  files: after.files,
377
- boardVersion: this.notes?.version ?? null,
448
+ boardVersion: after.boardVersion ?? null,
378
449
  lastEndSeq: seq,
379
450
  })
380
451
  record.lastTree = checkpoint?.snapshot?.tree ?? record.lastTree
@@ -397,7 +468,6 @@ export class TimebackService {
397
468
  }
398
469
  }
399
470
  if (!record.recording) return null
400
- await this.notes?.open?.()
401
471
  if (record.afterSnapshot) return record.afterSnapshot
402
472
  if (record.afterPromise) return record.afterPromise
403
473
  record.afterPromise = (async () => {
@@ -420,6 +490,7 @@ export class TimebackService {
420
490
  checkpointId,
421
491
  snapshot: { tree: snapshot.tree, cwd: snapshot.cwd, repoId: snapshot.repoId, excludePaths: selection.excludePaths },
422
492
  files: snapshot.files,
493
+ boardVersion: await this.notesVersionFor(cwd),
423
494
  }
424
495
  record.afterSnapshot = result
425
496
  return result
@@ -435,7 +506,6 @@ export class TimebackService {
435
506
  * @returns {Promise<object>} the stored checkpoint.
436
507
  */
437
508
  async capture(input) {
438
- await this.notes?.open?.()
439
509
  const sessionId = String(input.session.id)
440
510
  await this.registry.ensureSession({ sessionId, cwd: input.cwd })
441
511
  const checkpointId = `cp-${randomUUID()}`
@@ -462,7 +532,7 @@ export class TimebackService {
462
532
  prompt: input.prompt,
463
533
  snapshot: { tree: snapshot.tree, cwd: snapshot.cwd, repoId: snapshot.repoId, excludePaths: selection.excludePaths },
464
534
  files: snapshot.files,
465
- boardVersion: this.notes?.version ?? null,
535
+ boardVersion: await this.notesVersionFor(input.cwd),
466
536
  })
467
537
  return checkpoint
468
538
  }
@@ -611,7 +681,7 @@ export class TimebackService {
611
681
  dataDir: this.config.dataDir,
612
682
  currentSessionId,
613
683
  rootSessionId: root.id,
614
- boardVersion: this.notes?.version ?? null,
684
+ boardVersion: await this.notesVersionFor(currentCwd),
615
685
  workspace,
616
686
  sessions,
617
687
  limits: {
@@ -721,9 +791,11 @@ export class TimebackService {
721
791
  // The notes board travels with the rewind: a checkpoint stores the board
722
792
  // version it saw, so rewinding restores that Markdown state too.
723
793
  let board = null
724
- if (this.notes && Number.isSafeInteger(checkpoint.boardVersion)) {
794
+ const boardCwd = checkpoint.snapshot?.cwd ?? session.cwd ?? null
795
+ const boardNotes = await this.notesFor(boardCwd)
796
+ if (boardNotes && Number.isSafeInteger(checkpoint.boardVersion)) {
725
797
  try {
726
- board = await this.notes.restore(checkpoint.boardVersion)
798
+ board = await boardNotes.restore(checkpoint.boardVersion)
727
799
  } catch (error) {
728
800
  this.logger?.warn?.(`timeback: board restore failed: ${error?.message ?? error}`)
729
801
  board = { restoredFrom: checkpoint.boardVersion, error: error?.message ? String(error.message) : String(error) }
@@ -736,7 +808,8 @@ export class TimebackService {
736
808
  if (Number.isSafeInteger(candidate.boardVersion)) referenced.add(candidate.boardVersion)
737
809
  }
738
810
  }
739
- this.notes.pruneHistory(referenced).catch(() => {})
811
+ const stores = [this.notes, ...this.scopedNotes.values()]
812
+ for (const store of stores) store.pruneHistory(referenced).catch(() => {})
740
813
  }
741
814
  return {
742
815
  ok: true,
@@ -846,10 +919,12 @@ export class TimebackService {
846
919
  /* ---------------------------------------------------------------- */
847
920
 
848
921
  /** @returns {Promise<{version:number,updatedAt:number,entries:object[]}>} the Markdown board. */
849
- async board() {
922
+ async board(input = {}) {
850
923
  await this.start()
851
- if (!this.notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
852
- return this.notes.board()
924
+ const notes = await this.notesForInput(input)
925
+ if (!notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
926
+ await notes.open()
927
+ return notes.board()
853
928
  }
854
929
 
855
930
  /**
@@ -859,13 +934,15 @@ export class TimebackService {
859
934
  */
860
935
  async saveBoardNote(input, source = 'user') {
861
936
  await this.start()
862
- if (!this.notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
937
+ const notes = await this.notesForInput(input)
938
+ if (!notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
939
+ await notes.open()
863
940
  const id = typeof input.id === 'string' && input.id !== '' ? input.id : ''
864
941
  const title = typeof input.title === 'string' ? input.title : ''
865
942
  const body = typeof input.body === 'string' ? input.body : ''
866
943
  if (id) {
867
944
  try {
868
- return { ok: true, ...(await this.notes.update(id, { title, body })) }
945
+ return { ok: true, ...(await notes.update(id, { title, body })) }
869
946
  } catch (error) {
870
947
  if (error?.code === 'notes/not-found') throw new TimebackError('记录不存在或已删除', 'timeback/note-unknown')
871
948
  throw error
@@ -874,7 +951,7 @@ export class TimebackService {
874
951
  if (body.trim() === '' && title.trim() === '') throw new TimebackError('记录内容不能为空', 'timeback/note-empty')
875
952
  return {
876
953
  ok: true,
877
- ...(await this.notes.create({
954
+ ...(await notes.create({
878
955
  title,
879
956
  body,
880
957
  source: source === 'agent' ? 'agent' : 'user',
@@ -885,19 +962,23 @@ export class TimebackService {
885
962
  }
886
963
 
887
964
  /** Persist the sticky-note canvas (layout, background strokes, per-note strokes). */
888
- async saveBoardCanvas(canvas) {
965
+ async saveBoardCanvas(canvas, input = {}) {
889
966
  await this.start()
890
- if (!this.notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
891
- return { ok: true, ...(await this.notes.updateCanvas(canvas ?? {})) }
967
+ const notes = await this.notesForInput(input)
968
+ if (!notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
969
+ await notes.open()
970
+ return { ok: true, ...(await notes.updateCanvas(canvas ?? {})) }
892
971
  }
893
972
 
894
973
  /** Delete one board note. */
895
- async deleteBoardNote(id) {
974
+ async deleteBoardNote(id, input = {}) {
896
975
  await this.start()
897
- if (!this.notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
976
+ const notes = await this.notesForInput(input)
977
+ if (!notes) throw new TimebackError('记录板存储不可用', 'timeback/notes-unavailable')
978
+ await notes.open()
898
979
  if (typeof id !== 'string' || id === '') throw new TimebackError('缺少记录 id', 'timeback/note-id-required')
899
980
  try {
900
- return { ok: true, ...(await this.notes.remove(id)) }
981
+ return { ok: true, ...(await notes.remove(id)) }
901
982
  } catch (error) {
902
983
  if (error?.code === 'notes/not-found') throw new TimebackError('记录不存在或已删除', 'timeback/note-unknown')
903
984
  throw error