@marver-design/marver 0.29.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +2 -1
  3. package/dist/{anchor-check-DhlpKl2K.mjs → anchor-check-Bv4o-R2T.mjs} +1 -1
  4. package/dist/{build-CWbrb2bl.mjs → build-zWGXSzly.mjs} +5 -4
  5. package/dist/cli.mjs +5 -5
  6. package/dist/{daemon-Sc_z8gT6.mjs → daemon-CChgWJNq.mjs} +2 -2
  7. package/dist/{dev-DWBKQhxf.mjs → dev-DOgIITpT.mjs} +8 -8
  8. package/dist/{perf-Denssrko.mjs → perf-6MOTHxay.mjs} +710 -99
  9. package/dist/perf-BCxAo0IS.mjs +1743 -0
  10. package/dist/{plugin-DqoZB-D6.mjs → plugin-CFWBcAba.mjs} +928 -539
  11. package/dist/{poster-CrsjqhY4.mjs → poster-DPPpQiva.mjs} +1 -1
  12. package/dist/{publish-bakes-DW-NDgU2.mjs → publish-bakes-_Zx8crP3.mjs} +2 -2
  13. package/dist/{recover-GtJ9UDAB.mjs → recover-mDUVsnPd.mjs} +1 -1
  14. package/dist/{shot-T04Ixrvq.mjs → shot-d4h_hJi9.mjs} +3 -3
  15. package/docs/app.md +194 -0
  16. package/docs/performance.md +100 -19
  17. package/package.json +1 -1
  18. package/src/client/frame-host/bridge.js +17 -8
  19. package/src/client/frame-host/inplace.ts +124 -0
  20. package/src/client/frame-host/inspect.d.ts +1 -0
  21. package/src/client/frame-host/inspect.js +13 -4
  22. package/src/client/frame-host/main.tsx +12 -3
  23. package/src/client/frame-host/messages.ts +85 -0
  24. package/src/client/frame-host/signals.d.ts +15 -0
  25. package/src/client/frame-host/signals.js +219 -0
  26. package/src/client/recorder-level.ts +41 -0
  27. package/src/client/shell/App.tsx +158 -88
  28. package/src/client/shell/BoardList.tsx +103 -48
  29. package/src/client/shell/Comments.tsx +66 -42
  30. package/src/client/shell/ContextMenu.tsx +3 -2
  31. package/src/client/shell/JamSurface.tsx +116 -71
  32. package/src/client/shell/LockedApp.tsx +19 -3
  33. package/src/client/shell/Play.tsx +94 -58
  34. package/src/client/shell/StatusPicker.tsx +19 -9
  35. package/src/client/shell/Toolbar.tsx +15 -7
  36. package/src/client/shell/api.ts +18 -4
  37. package/src/client/shell/app-bridge.ts +12 -6
  38. package/src/client/shell/app-perf.ts +31 -1
  39. package/src/client/shell/canvas/Canvas.tsx +17 -6
  40. package/src/client/shell/canvas/FrameNode.tsx +25 -12
  41. package/src/client/shell/canvas/Sticky.tsx +4 -2
  42. package/src/client/shell/canvas/ctl.ts +2 -0
  43. package/src/client/shell/canvas/ready-watch.ts +4 -0
  44. package/src/client/shell/canvas/sleep.ts +2 -0
  45. package/src/client/shell/canvas/updates.ts +13 -6
  46. package/src/client/shell/commands.ts +765 -0
  47. package/src/client/shell/comments-store.ts +42 -27
  48. package/src/client/shell/goto.ts +11 -6
  49. package/src/client/shell/jam-keys.ts +141 -75
  50. package/src/client/shell/jam-lane.tsx +19 -12
  51. package/src/client/shell/jam-panel.tsx +61 -48
  52. package/src/client/shell/jam-session.tsx +41 -37
  53. package/src/client/shell/jam-state.ts +9 -1
  54. package/src/client/shell/jam-surface-parts.tsx +8 -6
  55. package/src/client/shell/jam-ui.tsx +9 -6
  56. package/src/client/shell/jam-voice.ts +4 -2
  57. package/src/client/shell/main.tsx +7 -1
  58. package/src/client/shell/marks-ui.tsx +11 -0
  59. package/src/client/shell/perf.ts +51 -5
  60. package/src/client/shell/recorder-core.ts +4 -1
  61. package/src/client/shell/recorder-hmr.ts +36 -0
  62. package/src/client/shell/recorder-reloads.ts +264 -0
  63. package/src/client/shell/recorder-seams.ts +116 -0
  64. package/src/client/shell/recorder-self.ts +73 -0
  65. package/src/client/shell/recorder-signals-core.ts +139 -0
  66. package/src/client/shell/recorder-signals.ts +485 -0
  67. package/src/client/shell/recorder.ts +118 -43
  68. package/src/client/shell/store.ts +112 -32
  69. package/src/client/shell/whiteout-probes.ts +3 -1
  70. package/src/client/stage/main.tsx +10 -5
  71. package/src/shared/app-api.ts +28 -6
  72. package/src/shared/app-perf.ts +99 -6
  73. package/src/shared/app-report.ts +586 -0
  74. package/src/shared/perf-records.ts +445 -0
  75. package/src/shared/perf-run.ts +6 -2
  76. package/dist/perf-jam-CLkERSHo.mjs +0 -642
@@ -9,9 +9,10 @@ import { PHASE_LABEL, STATUS_LABEL } from '../../shared/status.ts'
9
9
  import { canvasCtl } from './canvas/Canvas.tsx'
10
10
  import { isLatest, navigated, switchFor } from './goto.ts'
11
11
  import { rollup } from '../../shared/marks.ts'
12
- import { Bubble, useAsks } from './marks-ui.tsx'
12
+ import { Bubble, markSeenFrom, useAsks } from './marks-ui.tsx'
13
13
  import { Tip } from './Tip.tsx'
14
14
  import { copyToClipboard, type MenuItem, type MenuOpener } from './ContextMenu.tsx'
15
+ import { cmd, keysOf, withCmd, withCmds, type CmdHandle, type CmdOpts } from './commands.ts'
15
16
  import { ArrowLineUpIcon, CardsIcon, CheckIcon, FolderIcon, FrameCornersIcon, FolderMinusIcon, FolderOpenIcon, FolderPlusIcon, PencilSimpleIcon, SignpostIcon } from './icons.tsx'
16
17
  import {
17
18
  applyDrop, boardsIn, createFolder, deleteFolder, depthOf, folderEntries, folderIn, folderOf, foldersIn, holdsFolders, humanize, INDENT, isOwnSlot, labelOf, listIn, moveBoard, moveFolderToRoot, newFolderSlot, parentOf, readTitle,
@@ -63,6 +64,12 @@ export function AddToBoard({ frame, close }: { frame: string; close: () => void
63
64
  type Naming = { kind: 'board' | 'folder'; name: string } | { kind: 'new'; index: number; board?: string; parent: string | null }
64
65
  /** A mutation as intent: applied to whichever tree is current, so a 409 can replay it. */
65
66
  type Intent = (tree: TreeItem[]) => TreeItem[] | null
67
+ /** An intent in the queue, and the command behind it (spec 30): it ends on the tree write that carries it. */
68
+ type Queued = { intent: Intent; h: CmdHandle }
69
+ /** A name write's refusal as its code (spec 30) - the answer's own words never reach a record. */
70
+ const nameCode = (error?: string): 'exists' | 'invalid' | 'api' => (/already exists/i.test(error ?? '') ? 'exists' : /^invalid\b/i.test(error ?? '') ? 'invalid' : 'api')
71
+ /** The board whose status picker is open (StatusPicker's `data-board`). */
72
+ const statusPicking = (): string | undefined => document.querySelector<HTMLElement>('[data-status-picker]')?.dataset.board
66
73
 
67
74
  export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
68
75
  const board = useStore((s) => s.board)
@@ -73,7 +80,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
73
80
  const marks = useStore((s) => s.marks)
74
81
  const asks = useAsks()
75
82
  const framesOf = (boards: string[]) => boards.flatMap((b) => marks?.boards[b] ?? [])
76
- const seeAll = (boards: string[]): MenuItem[] => (!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => useStore.getState().markSeen(framesOf(boards)) }] : []) // board slug → type and status (spec 20)
83
+ const seeAll = (boards: string[]): MenuItem[] => (!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => markSeenFrom({ via: 'context', in: 'shell' }, framesOf(boards)) }] : []) // board slug → type and status (spec 20)
77
84
  const label = (n: string) => labelOf(n, titles[n]) // a board's label; a folder's is labelOf(name, item.title)
78
85
  const [tree, setTree] = useState<TreeItem[]>([])
79
86
  const [read, setRead] = useState(false) // the first tree read has answered
@@ -87,7 +94,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
87
94
  // unconfirmed state - only ever to the files. Reads are latest-wins by sequence.
88
95
  const confirmedRef = useRef<TreeItem[]>([])
89
96
  const baseRef = useRef<TreeBase>({ boards: {}, folders: null }) // the hashes the confirmed tree was read from
90
- const queueRef = useRef<Intent[]>([]) // applied on screen, not yet written
97
+ const queueRef = useRef<Queued[]>([]) // applied on screen, not yet written
91
98
  const flushing = useRef(false)
92
99
  const loadSeq = useRef(0)
93
100
  const commitBusy = useRef(false) // guards Enter+blur firing two commits
@@ -95,7 +102,8 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
95
102
  // drag runs on pointer events, NOT native drag-and-drop: native DnD hands the cursor to
96
103
  // the OS (arrow/move), so a grabbing hand can't persist. Owning the gesture lets us hold
97
104
  // the grabbing cursor for the whole drag via a body class.
98
- const gestureRef = useRef<{ pointerId: number; startX: number; startY: number; item: Drag; dragging: boolean; el: HTMLElement; x: number; y: number } | null>(null)
105
+ // `h`: the press became a drag (spec 30) - its `board-move` or `folder-move`, which its release takes, else cancelled
106
+ const gestureRef = useRef<{ pointerId: number; startX: number; startY: number; item: Drag; dragging: boolean; h?: CmdHandle; el: HTMLElement; x: number; y: number } | null>(null)
99
107
  const treeRef = useRef(tree)
100
108
  treeRef.current = tree
101
109
  const namingRef = useRef(naming) // commit reads the LIVE naming state, never a stale closure (Escape, then a late blur)
@@ -104,7 +112,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
104
112
  /** The confirmed tree with the queue projected on top - what the human sees. */
105
113
  const show = () => {
106
114
  let t = confirmedRef.current
107
- for (const intent of queueRef.current) t = intent(t) ?? t
115
+ for (const q of queueRef.current) t = q.intent(t) ?? t
108
116
  treeRef.current = t
109
117
  setTree(t)
110
118
  }
@@ -170,8 +178,10 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
170
178
  return next
171
179
  })
172
180
  }
181
+ const toggleFolder = (folder: string, open: boolean) => { cmd('folder-toggle', { via: 'click', in: 'shell' }); setOpen(folder, open) }
173
182
  const pick = async (name: string) => {
174
183
  if (name === useStore.getState().board) return
184
+ cmd('board-open', { via: 'click', in: 'shell', board: name }) // ends on this board's load: its steps, `settled`, a cut (#49)
175
185
  const nav = navigated() // a link still finding its board gives way
176
186
  if (await switchFor(name, nav)) setTimeout(() => { if (isLatest(nav)) canvasCtl.fitAll() }, 60) // unless a newer one has the camera
177
187
  }
@@ -181,10 +191,10 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
181
191
  * concurrent agent or tab wrote first) re-reads the files and replays the whole batch on
182
192
  * what is there now, once. A terminal failure drops the batch, says so, and re-reads -
183
193
  * the screen returns to the files, never to another unconfirmed state. Returns false when
184
- * the intent cannot apply to what is shown (nothing queued). */
185
- const mutate = (intent: Intent): boolean => {
186
- if (!intent(treeRef.current)) return false
187
- queueRef.current.push(intent)
194
+ * the intent cannot apply to what is shown (nothing queued; a tree change took over from `h`). */
195
+ const mutate = (intent: Intent, h: CmdHandle): boolean => {
196
+ if (!intent(treeRef.current)) { h.cancel('edited'); return false }
197
+ queueRef.current.push({ intent, h })
188
198
  show()
189
199
  void flush()
190
200
  return true
@@ -197,23 +207,38 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
197
207
  const batch = [...queueRef.current]
198
208
  // an intent the fresh tree no longer admits (its board or folder vanished) is dropped
199
209
  // and said out loud, never silently counted as done
210
+ let dropped = new Set<Queued>()
200
211
  const reduce = (t: TreeItem[]) => {
201
- let dropped = 0
202
- const tree = batch.reduce<TreeItem[]>((acc, i) => { const n = i(acc); if (!n) dropped++; return n ?? acc }, t)
203
- if (dropped) useStore.getState().toast(dropped === batch.length ? 'that move no longer applies' : 'some moves no longer apply')
212
+ dropped = new Set()
213
+ const tree = batch.reduce<TreeItem[]>((acc, q) => { const n = q.intent(acc); if (!n) dropped.add(q); return n ?? acc }, t)
214
+ if (dropped.size) useStore.getState().toast(dropped.size === batch.length ? 'that move no longer applies' : 'some moves no longer apply')
204
215
  return tree
205
216
  }
206
217
  const done = () => { queueRef.current.splice(0, batch.length); show() } // written, or given up on - off the screen's projection either way
218
+ // the commands this batch carries end on its write's answer (spec 30); a dropped intent wrote nothing, a tree change took over
219
+ const answered = (ok: boolean, error?: string) => {
220
+ for (const q of batch) {
221
+ if (!ok) q.h.fail(q.h.name === 'folder-rename' ? nameCode(error) : 'api')
222
+ else if (dropped.has(q)) q.h.cancel('edited')
223
+ else q.h.done()
224
+ }
225
+ }
226
+ // the write names the commands it carries (spec 30 #18), long after their turns - a dropped intent is not in it
227
+ const arrange = () => {
228
+ const tree = reduce(confirmedRef.current)
229
+ return withCmds(batch.flatMap((q) => (q.h.id && !dropped.has(q) ? [q.h.id] : [])), () => useStore.getState().arrangeBoards(tree, baseRef.current))
230
+ }
207
231
  try {
208
- let r = await useStore.getState().arrangeBoards(reduce(confirmedRef.current), baseRef.current)
232
+ let r = await arrange()
209
233
  if (!r.ok && r.stale) {
210
- if (!(await load())) { done(); useStore.getState().toast('boards changed - try again'); break }
211
- r = await useStore.getState().arrangeBoards(reduce(confirmedRef.current), baseRef.current)
234
+ if (!(await load())) { done(); answered(false); useStore.getState().toast('boards changed - try again'); break }
235
+ r = await arrange()
212
236
  }
213
237
  done()
238
+ answered(r.ok, r.ok ? undefined : r.error)
214
239
  if (!r.ok) { useStore.getState().toast(r.error ?? 'could not save order'); await load(); break }
215
240
  await load() // the write moved the hashes on; the next batch needs the true base
216
- } catch { done(); useStore.getState().toast('could not save order'); await load(); break }
241
+ } catch { done(); answered(false); useStore.getState().toast('could not save order'); await load(); break }
217
242
  }
218
243
  } finally {
219
244
  flushing.current = false
@@ -229,22 +254,27 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
229
254
  // never moves it. A new folder mints its slug from the title once. Typing exactly what the
230
255
  // slug reads as anyway ("Research" for `research`) clears the title - the file stays clean.
231
256
  // An empty entry, or the label unchanged, means never mind.
232
- const commit = async (raw: string) => {
257
+ // The command starts where the name is DECIDED (spec 30): Enter or leaving the field saves, Esc backs out.
258
+ const namingCmd = (n: Naming, how: CmdOpts) => cmd(n.kind === 'board' ? 'board-rename' : n.kind === 'folder' ? 'folder-rename' : 'folder-new', { ...how, ...(n.kind === 'board' ? { board: n.name } : {}) })
259
+ const commit = async (raw: string, how: CmdOpts) => {
233
260
  const n = namingRef.current
234
261
  if (!n || commitBusy.current) return // Enter already fired this (or Escape cancelled); ignore the follow-up blur
235
262
  commitBusy.current = true
263
+ const h = namingCmd(n, how)
236
264
  try {
237
265
  const title = readTitle(raw)
238
- if (!title) { setNaming(null); return }
266
+ if (!title) { h.cancel(); setNaming(null); return }
239
267
  // two rows reading alike would be a trap: a name another board (folder) already shows stays editing
240
- const taken = (kind: 'board' | 'folder') => useStore.getState().toast(`a ${kind} called "${title}" already exists`)
268
+ const taken = (kind: 'board' | 'folder') => { h.fail('exists'); useStore.getState().toast(`a ${kind} called "${title}" already exists`) }
241
269
  const stored = (slug: string) => (title === humanize(slug) ? '' : title)
242
270
  if (n.kind === 'board') {
243
- if (title === label(n.name)) { setNaming(null); return }
271
+ if (title === label(n.name)) { h.cancel(); setNaming(null); return }
244
272
  if (boardsIn(tree).some((b) => b !== n.name && label(b) === title)) { taken('board'); return }
245
- let r = await useStore.getState().renameBoard(n.name, stored(n.name), baseRef.current.boards[n.name])
246
- if (!r.ok && r.stale && await load()) r = await useStore.getState().renameBoard(n.name, stored(n.name), baseRef.current.boards[n.name]) // the file moved on (a drag just before, an agent): re-read, once more
247
- if (!r.ok) { useStore.getState().toast(r.error ?? 'rename failed'); return } // stay editing
273
+ const rename = () => withCmd(h.id, () => useStore.getState().renameBoard(n.name, stored(n.name), baseRef.current.boards[n.name]))
274
+ let r = await rename()
275
+ if (!r.ok && r.stale && await load()) r = await rename() // the file moved on (a drag just before, an agent): re-read, once more
276
+ if (!r.ok) { h.fail(nameCode(r.error)); useStore.getState().toast(r.error ?? 'rename failed'); return } // stay editing
277
+ h.done()
248
278
  setNaming(null)
249
279
  refresh()
250
280
  return
@@ -252,10 +282,10 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
252
282
  const folderLabels = folderEntries(tree).map((e) => e.folder).filter((f) => n.kind !== 'folder' || f.name !== n.name).map((f) => labelOf(f.name, f.title))
253
283
  if (n.kind === 'folder') {
254
284
  const current = folderIn(tree, n.name)
255
- if (!current || title === labelOf(n.name, current.title)) { setNaming(null); return }
285
+ if (!current || title === labelOf(n.name, current.title)) { h.cancel(); setNaming(null); return }
256
286
  if (folderLabels.includes(title)) { taken('folder'); return }
257
287
  setNaming(null)
258
- mutate((t) => retitleFolder(t, n.name, stored(n.name)))
288
+ mutate((t) => retitleFolder(t, n.name, stored(n.name)), h)
259
289
  return
260
290
  }
261
291
  if (n.kind !== 'new') return
@@ -264,8 +294,9 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
264
294
  const slug = slugFor(title, foldersIn(tree)) // "Old stuff" → old-stuff (-2 past a namesake); "🚀" alone → folder
265
295
  setNaming(null)
266
296
  setOpen(slug, true) // a new folder opens, whatever an old namesake left behind
267
- if (!mutate((t) => createFolder(t, slug, index, withBoard, stored(slug) || undefined, parent))) useStore.getState().toast(withBoard ? 'that board is gone - nothing changed' : 'that folder is gone - nothing changed')
268
- } finally { commitBusy.current = false }
297
+ if (!mutate((t) => createFolder(t, slug, index, withBoard, stored(slug) || undefined, parent), h)) useStore.getState().toast(withBoard ? 'that board is gone - nothing changed' : 'that folder is gone - nothing changed')
298
+ } catch (e) { h.fail('api'); throw e }
299
+ finally { commitBusy.current = false }
269
300
  }
270
301
 
271
302
  // ---- drag and drop: one pointer gesture for board rows and folder rows ----
@@ -294,6 +325,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
294
325
  const g = gestureRef.current
295
326
  gestureRef.current = null
296
327
  if (g) { try { g.el.releasePointerCapture(g.pointerId) } catch { /* already released */ } }
328
+ g?.h?.cancel() // a drag given up: Esc, focus lost, the pointer lost (a release took its handle)
297
329
  document.body.classList.remove('sh-board-dragging')
298
330
  setDrag(null)
299
331
  showDrop(null)
@@ -311,6 +343,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
311
343
  if (!g.dragging) {
312
344
  if (Math.hypot(e.clientX - g.startX, e.clientY - g.startY) < 5) return // click vs drag threshold
313
345
  g.dragging = true
346
+ g.h = cmd(g.item.kind === 'board' ? 'board-move' : 'folder-move', { via: 'drag', in: 'shell', ...(g.item.kind === 'board' ? { board: g.item.name } : {}) })
314
347
  setDrag(g.item)
315
348
  document.body.classList.add('sh-board-dragging') // holds the grabbing cursor for the whole drag
316
349
  }
@@ -336,22 +369,36 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
336
369
  const panel = rootRef.current?.closest('.sh-panel')?.getBoundingClientRect()
337
370
  const inside = !!panel && e.clientX >= panel.left && e.clientX < panel.right && e.clientY >= panel.top && e.clientY < panel.bottom
338
371
  const target = dragged && inside ? dropRef.current : null
372
+ const h = g.h
373
+ g.h = undefined // this release ends it, not the reset
339
374
  resetPointer()
340
- if (dragged) {
341
- if (!target) return
375
+ if (h) {
376
+ if (!target) { h.cancel(); return }
342
377
  if ('into' in target) setOpen(target.into, true) // show where it landed
343
- mutate((t) => applyDrop(t, item, target))
378
+ mutate((t) => applyDrop(t, item, target), h)
344
379
  }
345
380
  else if (item.kind === 'board') void pick(item.name) // a tap switches boards (the trailing mouse click is ignored)
346
- else setOpen(item.name, !!closed[item.name]) // a tap on a folder toggles it
381
+ else toggleFolder(item.name, !!closed[item.name]) // a tap on a folder toggles it
347
382
  }
348
383
  // cancel a drag on Escape (capture phase, so the app's global Escape never sees it) or focus loss
384
+ // ...and a status picker closed with nothing chosen (spec 30): ContextMenu's own Esc and press close it, and these
385
+ // run first, added at mount where its are added when a menu opens
349
386
  useEffect(() => {
350
- const onEsc = (e: KeyboardEvent) => { if (e.key === 'Escape' && gestureRef.current?.dragging) { e.preventDefault(); e.stopPropagation(); resetPointer() } }
387
+ const onEsc = (e: KeyboardEvent) => {
388
+ if (e.key !== 'Escape') return
389
+ if (gestureRef.current?.dragging) { e.preventDefault(); e.stopPropagation(); resetPointer(); return }
390
+ const board = statusPicking()
391
+ if (board) cmd('board-status', { via: 'key', in: 'shell', keys: keysOf(e), board }).cancel()
392
+ }
393
+ const onPress = (e: PointerEvent) => {
394
+ const board = statusPicking()
395
+ if (board && !(e.target instanceof Element && e.target.closest('.sh-ctxmenu'))) cmd('board-status', { via: 'click', in: 'shell', board }).cancel()
396
+ }
351
397
  const onBlur = () => { if (gestureRef.current) resetPointer() }
352
398
  window.addEventListener('keydown', onEsc, true)
399
+ window.addEventListener('pointerdown', onPress)
353
400
  window.addEventListener('blur', onBlur)
354
- return () => { window.removeEventListener('keydown', onEsc, true); window.removeEventListener('blur', onBlur); resetPointer() }
401
+ return () => { window.removeEventListener('keydown', onEsc, true); window.removeEventListener('pointerdown', onPress); window.removeEventListener('blur', onBlur); resetPointer() }
355
402
  // eslint-disable-next-line react-hooks/exhaustive-deps
356
403
  }, [])
357
404
 
@@ -362,20 +409,24 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
362
409
  }
363
410
  /** A person's status decision (the picker): written into the board file, its hash checked - a
364
411
  * write that lost a race re-reads and tries once more, like a rename. */
365
- const setStatus = async (n: string, status: StatusWord | null, reason?: string) => {
366
- let r = await useStore.getState().setBoardStatus(n, status, reason, baseRef.current.boards[n])
367
- if (!r.ok && r.stale && await load()) r = await useStore.getState().setBoardStatus(n, status, reason, baseRef.current.boards[n])
368
- if (!r.ok) { useStore.getState().toast(r.error ?? 'status not saved'); return }
369
- refresh() // a clear: what the evidence says now
412
+ const setStatus = async (n: string, status: StatusWord | null, reason: string | undefined, h: CmdHandle) => {
413
+ try {
414
+ const write = () => withCmd(h.id, () => useStore.getState().setBoardStatus(n, status, reason, baseRef.current.boards[n]))
415
+ let r = await write()
416
+ if (!r.ok && r.stale && await load()) r = await write()
417
+ if (!r.ok) { h.fail('api'); useStore.getState().toast(r.error ?? 'status not saved'); return }
418
+ h.done()
419
+ refresh() // a clear: what the evidence says now
420
+ } catch (e) { h.fail('api'); throw e }
370
421
  }
371
422
  const boardMenu = (n: string, parent: string | null): MenuItem[] => {
372
- const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`board: ${n}`, 'path copied') }, ...seeAll([n])]
423
+ const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`board: ${n}`, 'path copied', cmd('copy-path', { via: 'context', in: 'shell', board: n })) }, ...seeAll([n])]
373
424
  if (PUBLISHED) return items
374
425
  // a feature or project board: its status first, as Linear puts it - the picker opens in place
375
426
  const m = useStore.getState().boardMeta[n]
376
427
  if (m?.status && m.settable?.length) items.unshift({
377
428
  label: 'Change status…', icon: <StatusIcon status={m.status.status} fill={m.status.fill} />,
378
- panel: (close) => <StatusPicker meta={m} onPick={(s, reason) => { close(); void setStatus(n, s, reason) }} />,
429
+ panel: (close) => <StatusPicker board={n} meta={m} close={close} onPick={setStatus} />,
379
430
  })
380
431
  items.push({ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setNaming({ kind: 'board', name: n }) })
381
432
  // the new folder takes the board's own slot at its own level (a sub-folder inside a top-level
@@ -386,11 +437,11 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
386
437
  const p = folderOf(t, n)
387
438
  const top = p ? parentOf(t, p) ?? p : null // lands right after the top-level folder it was in
388
439
  return moveBoard(t, n, null, top ? rootIndex(t, 'folder', top) + 1 : undefined)
389
- }) })
440
+ }, cmd('board-move', { via: 'context', in: 'shell', board: n })) })
390
441
  return items
391
442
  }
392
443
  const folderMenu = (f: string, boards: string[], parent: string | null): MenuItem[] => {
393
- const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`folder: ${f}${parent ? ` (in ${parent})` : ''} (boards: ${boards.join(', ') || 'none'})`, 'path copied') }]
444
+ const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`folder: ${f}${parent ? ` (in ${parent})` : ''} (boards: ${boards.join(', ') || 'none'})`, 'path copied', cmd('copy-path', { via: 'context', in: 'shell' })) }]
394
445
  if (PUBLISHED) return items
395
446
  items.push({ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setNaming({ kind: 'folder', name: f }) }, ...seeAll(boards))
396
447
  // two levels: a top-level folder can hold folders; a sub-folder can leave its parent
@@ -398,9 +449,9 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
398
449
  else items.push({ label: 'Move to top level', icon: <ArrowLineUpIcon size={15} />, onClick: () => mutate((t) => {
399
450
  const p = parentOf(t, f)
400
451
  return moveFolderToRoot(t, f, p ? rootIndex(t, 'folder', p) + 1 : undefined)
401
- }) })
452
+ }, cmd('folder-move', { via: 'context', in: 'shell' })) })
402
453
  // folders organise, never own: deleting one moves what it holds up one level, into its place, in order
403
- items.push({ label: 'Delete folder', icon: <FolderMinusIcon size={15} />, onClick: () => { setOpen(f, true); mutate((t) => deleteFolder(t, f)) } })
454
+ items.push({ label: 'Delete folder', icon: <FolderMinusIcon size={15} />, onClick: () => { const h = cmd('folder-delete', { via: 'context', in: 'shell' }); setOpen(f, true); mutate((t) => deleteFolder(t, f), h) } })
404
455
  return items
405
456
  }
406
457
  /** Right-click on the sidebar itself (the Boards header, gaps between rows, the blank space
@@ -436,10 +487,14 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
436
487
  <input autoFocus defaultValue={defaultValue} placeholder={placeholder} spellCheck={false}
437
488
  onFocus={(e) => e.currentTarget.select()}
438
489
  onKeyDown={(e) => {
439
- if (e.key === 'Enter') { e.preventDefault(); void commit(e.currentTarget.value) }
440
- else if (e.key === 'Escape') { e.preventDefault(); setNaming(null) }
490
+ if (e.key === 'Enter') { e.preventDefault(); void commit(e.currentTarget.value, { via: 'key', in: 'shell', keys: keysOf(e) }) }
491
+ else if (e.key === 'Escape') {
492
+ e.preventDefault()
493
+ if (namingRef.current && !commitBusy.current) namingCmd(namingRef.current, { via: 'key', in: 'shell', keys: keysOf(e) }).cancel() // a save in flight keeps its own end
494
+ setNaming(null)
495
+ }
441
496
  }}
442
- onBlur={(e) => { if (namingRef.current) void commit(e.currentTarget.value) }} />
497
+ onBlur={(e) => { if (namingRef.current) void commit(e.currentTarget.value, { via: 'click', in: 'shell' }) }} />
443
498
  )
444
499
  // a new folder being named is drawn at its future slot, its board (if any) already inside;
445
500
  // that board leaves its usual row for the duration. A draft whose parent vanished or can no
@@ -551,7 +606,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
551
606
  rows.push(
552
607
  <button key={`f:${f}`} data-folder-row={f} data-parent={parent ?? undefined} data-depth={depth} data-open={open ? '1' : '0'} data-reorderable={!PUBLISHED || undefined}
553
608
  className={`it folder${indent(depth)}${boards.includes(board) ? ' held' : ''}${dragging ? ' dragging' : ''}${into ? ' drop-into' : ''}${sc.cls}`} style={sc.style}
554
- onClick={(e) => { if (PUBLISHED || e.detail === 0) setOpen(f, !open) }}
609
+ onClick={(e) => { if (PUBLISHED || e.detail === 0) toggleFolder(f, !open) }}
555
610
  onContextMenu={(e) => onMenu(e, folderMenu(f, boards, parent))}
556
611
  onPointerDown={!PUBLISHED ? (e) => onPointerDown(e, item) : undefined}
557
612
  onPointerMove={!PUBLISHED ? onPointerMove : undefined}