@marver-design/marver 0.23.0 → 0.24.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +3 -1
  3. package/dist/{bake-l6N12qgx.mjs → bake-ZhXq-X9f.mjs} +1 -1
  4. package/dist/{board-status-D_lHZZ09.mjs → board-status-BZSzc9Hp.mjs} +1 -1
  5. package/dist/{boards-DbVJlbd5.mjs → boards-BRLnoTC3.mjs} +14 -6
  6. package/dist/{boards-CahYhF5B.mjs → boards-Dv-Ipd8G.mjs} +13 -6
  7. package/dist/{build-CuRhHXcY.mjs → build-ckcinlWH.mjs} +15 -11
  8. package/dist/cli.mjs +10 -10
  9. package/dist/{comments-0d3e274b.mjs → comments-Dx1hCVOT.mjs} +1 -1
  10. package/dist/{config-g-J8NrPn.mjs → config-BUKprFAp.mjs} +1 -1
  11. package/dist/{context-fAtQLHt2.mjs → context-BncTXjLB.mjs} +3 -3
  12. package/dist/{daemon-DZ367fiM.mjs → daemon-CQv73-jM.mjs} +5 -4
  13. package/dist/{dev-R6zvwbqX.mjs → dev-gv4NS6Fk.mjs} +7 -7
  14. package/dist/{init-DAnBlt-V.mjs → init--3Moc4J7.mjs} +9 -4
  15. package/dist/{link-CcfAfKY-.mjs → link-vXjxMHTG.mjs} +3 -3
  16. package/dist/{manifest-BkjJ5OQk.mjs → manifest-cyG3kbhk.mjs} +9 -4
  17. package/dist/{plugin-C1avHL7g.mjs → plugin-Sa08E7wO.mjs} +232 -36
  18. package/dist/{poster-Bc4-3DlQ.mjs → poster-B2QPvKOq.mjs} +1 -1
  19. package/dist/{publish-bakes-DQWn14IY.mjs → publish-bakes-BJR3huhu.mjs} +2 -2
  20. package/dist/{shot-CVOlQHUr.mjs → shot-Cw96h5Kk.mjs} +2 -2
  21. package/dist/{shot-C1YR_Sqx.mjs → shot-Dh6fV1Lm.mjs} +1 -1
  22. package/dist/{work-CJ8OIpBD.mjs → work-CBUfsOOT.mjs} +2 -2
  23. package/dist/{work-CiUvBVa6.mjs → work-ayuL_9Kk.mjs} +1 -1
  24. package/docs/boards-and-folders.md +31 -1
  25. package/docs/live-jam.md +4 -1
  26. package/docs/sticky-notes.md +1 -1
  27. package/package.json +1 -1
  28. package/src/client/content/index.tsx +4 -0
  29. package/src/client/content/md.ts +3 -2
  30. package/src/client/shell/App.tsx +37 -12
  31. package/src/client/shell/BoardList.tsx +27 -7
  32. package/src/client/shell/Play.tsx +2 -0
  33. package/src/client/shell/canvas/Canvas.tsx +2 -0
  34. package/src/client/shell/canvas/FrameNode.tsx +6 -1
  35. package/src/client/shell/comments-store.ts +2 -0
  36. package/src/client/shell/marks-ui.tsx +119 -0
  37. package/src/client/shell/store.ts +110 -9
  38. package/src/client/shell/styles.css +23 -0
  39. package/src/client/shell/tidy.ts +34 -3
  40. package/src/shared/frames.ts +3 -0
  41. package/src/shared/marks.ts +65 -0
@@ -15,6 +15,9 @@ import { poweredByUrl } from '../../shared/utm.ts'
15
15
  import { avatarFallback, useComments } from './comments-store.ts'
16
16
  import { goTo, navigated, revealFrame } from './goto.ts'
17
17
  import { useNotes } from './notes.ts'
18
+ import { contentOnly } from '../../shared/frames.ts'
19
+ import { nextToLook } from '../../shared/marks.ts'
20
+ import { asksNow, Bubble, MarkedRow, useRollup, useSeenOnScreen } from './marks-ui.tsx'
18
21
  import { CommentButton, DevicePicker, HideUIButton, LaserButton, Popover, ThemePicker, toggleHideUI, usePopover } from './Toolbar.tsx'
19
22
 
20
23
  const commentsStore = () => useComments.getState()
@@ -25,8 +28,9 @@ let booted = false // survives Fast Refresh; see the
25
28
  * selected frame - a quiet secondary wash so ancestry survives collapsing the group.
26
29
  * `renaming` swaps the label for an input: the scene's TITLE (its brief's front matter) -
27
30
  * the directory never moves from here. */
28
- function SceneGroup({ name, label, count, held, renaming, onRename, onPick, onContextMenu, children }: { name: string; label: string; count: number; held: boolean; renaming?: boolean; onRename?: (title: string | null) => void; onPick?: () => void; onContextMenu?: (e: ReactMouseEvent) => void; children: ReactNode }) {
31
+ function SceneGroup({ name, label, count, held, renaming, onRename, onPick, onContextMenu, ids, children }: { name: string; label: string; count: number; held: boolean; renaming?: boolean; onRename?: (title: string | null) => void; onPick?: () => void; onContextMenu?: (e: ReactMouseEvent) => void; ids: string[]; children: ReactNode }) {
29
32
  const [open, setOpen] = useState(true)
33
+ const fold = useRollup(open ? [] : ids) // only a folded scene rolls up (spec 25)
30
34
  const done = useRef(false) // Enter then blur: one commit
31
35
  if (renaming) { done.current = false }
32
36
  const finish = (v: string | null) => { if (done.current) return; done.current = true; onRename?.(v) }
@@ -44,7 +48,8 @@ function SceneGroup({ name, label, count, held, renaming, onRename, onPick, onCo
44
48
  <CaretIcon size={11} className="tw" style={{ transform: open ? undefined : 'rotate(-90deg)' }} />
45
49
  {/* the NAME selects every frame in the scene; the caret/row still collapses */}
46
50
  <span onClick={(e) => { if (!onPick) return; e.stopPropagation(); onPick() }}>{label || '(root)'}</span>
47
- <small>{count}</small>
51
+ {/* folded, its one slot rolls the frames up (spec 25): a question first, else a blue count */}
52
+ {fold.asks ? <Bubble n={fold.asks} /> : <small className={fold.fresh ? 'mk-fresh' : undefined}>{count}</small>}
48
53
  </button>
49
54
  )}
50
55
  {open && children}
@@ -328,6 +333,7 @@ function ThemeMenu() {
328
333
  export function App() {
329
334
  // B0.1: per-field selectors, NOT `useStore()` (which subscribes to the whole store and
330
335
  // re-rendered the entire shell on every setScale tick during a pan/zoom).
336
+ useSeenOnScreen()
331
337
  const manifest = useStore((s) => s.manifest)
332
338
  const nodes = useStore((s) => s.nodes)
333
339
  const panelOpen = useStore((s) => s.panelOpen)
@@ -441,6 +447,7 @@ export function App() {
441
447
  if (s.play) s.setPlay(null)
442
448
  const keys = linkTargets(h, s.nodes)
443
449
  useStore.setState({ selection: keys })
450
+ s.markSeen(keys.map((k) => s.nodes.find((n) => n.key === k)?.frame).filter((f): f is string => !!f)) // a link opened is a look
444
451
  if (!keys.length && h.f?.length) void revealFrame(h.f[0]) // not on this board - where it lives
445
452
  else setTimeout(() => (keys.length ? canvasCtl.fitNodes(keys) : canvasCtl.fitAll()), 60)
446
453
  }
@@ -512,11 +519,16 @@ export function App() {
512
519
  import.meta.hot.on('sh:scenes', (m: any) => useStore.getState().setScenes(m?.scenes))
513
520
  // Live Jam presence: the daemon broadcasts the set of frames Marver is editing.
514
521
  // Camera-safe by construction - this only toggles a glow class, never moves the view.
515
- import.meta.hot.on('sh:jam-activity', (m: any) => useStore.getState().setWorkingFrom(m))
522
+ import.meta.hot.on('sh:jam-activity', (m: any) => { useStore.getState().setWorkingFrom(m); void useStore.getState().syncMarks() })
516
523
  // then ask for what is lit now - a broadcast sent before this listener existed is gone - and again
517
524
  // after the dev server reconnects
518
525
  void useStore.getState().syncWorking()
519
526
  import.meta.hot.on('vite:ws:connect', () => void useStore.getState().syncWorking())
527
+ // sidebar marks (spec 25): a frame changed on disk, or an agent's work started or ended
528
+ void useStore.getState().syncMarks()
529
+ import.meta.hot.on('vite:ws:connect', () => void useStore.getState().syncMarks())
530
+ import.meta.hot.on('sh:marks', () => void useStore.getState().syncMarks())
531
+ import.meta.hot.on('sh:boards', () => void useStore.getState().syncMarks()) // a board's frames changed: its roll-up too
520
532
  // Live Jam reply delivery: the daemon just wrote to a board's log - fetch it NOW instead of
521
533
  // waiting out the 30s comment poll, so the reply + notification land within a second.
522
534
  import.meta.hot.on('sh:jam-comment', (m: any) => { if (typeof m?.board === 'string') useComments.getState().poke(m.board) })
@@ -686,6 +698,15 @@ export function App() {
686
698
  }
687
699
  if (e.key === 'C' && e.shiftKey) { const c = commentsStore(); c.setShow(!c.show) }
688
700
  // sticky notes (spec 18): any note visible -> hide all; none -> show all
701
+ // U: the next frame that needs you, else the next new one (spec 25)
702
+ if (e.key === 'u' && !e.shiftKey && !PUBLISHED) {
703
+ const live = s.nodes.filter((n) => !n.missing).sort((a, b) => a.y - b.y || a.x - b.x)
704
+ const from = s.selection.length ? s.nodes.find((n) => n.key === s.selection[s.selection.length - 1])?.frame ?? null : null
705
+ const id = nextToLook(s.marks, asksNow(), [...new Set(live.map((n) => n.frame))], from)
706
+ const n = id ? live.find((x) => x.frame === id) : null
707
+ if (n) { s.select(n.key); canvasCtl.fitNode(n.key) } else toast('nothing new on this board')
708
+ return
709
+ }
689
710
  if (e.key === 'n' && !e.shiftKey) { const visible = document.querySelectorAll('.sh-notes:not(.off)').length > 0; useNotes.getState().toggleAll(visible); toast(visible ? 'notes hidden' : 'notes shown'); return }
690
711
  // Shift+L = laser comment: the laser-sharp lighting on the element a comment tags
691
712
  // (pick hover, compose lock, open-thread highlight). Pins and cards stay - this
@@ -812,6 +833,7 @@ export function App() {
812
833
  <div className="hd" style={{ marginTop: 10 }}>Scenes</div>
813
834
  {scenes.map((sc) => (
814
835
  <SceneGroup key={sc.name} name={sc.name} label={sceneLabel(sc.name)} count={sc.frames}
836
+ ids={frames.filter((f) => f.scene === sc.name).map((f) => f.id)}
815
837
  held={frames.some((f) => f.scene === sc.name && selFrames.has(f.id))}
816
838
  renaming={sceneNaming === sc.name}
817
839
  onRename={(raw) => {
@@ -828,7 +850,8 @@ export function App() {
828
850
  onClick: () => copyToClipboard(sc.name
829
851
  ? `board: ${useStore.getState().board} · scene: ${sc.name} (design/scenes/${sc.name}/)`
830
852
  : `board: ${useStore.getState().board} · scene: (root)`, 'path copied'),
831
- }, ...(!PUBLISHED && sc.name ? [{ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setSceneNaming(sc.name) }] : [])])}
853
+ }, ...(!PUBLISHED && sc.name ? [{ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setSceneNaming(sc.name) }] : []),
854
+ ...(!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => useStore.getState().markSeen(frames.filter((f) => f.scene === sc.name).map((f) => f.id), true) }] : [])])}
832
855
  onPick={() => {
833
856
  const keys = nodes.filter((n) => frames.some((f) => f.scene === sc.name && f.id === n.frame) && !n.missing).map((n) => n.key)
834
857
  if (!keys.length) return
@@ -896,10 +919,10 @@ export function App() {
896
919
  const on = !!n && selection.includes(n.key)
897
920
  const nm = m.title ?? cap((m.id.split('/').pop() ?? '').replace(/^[a-z]-/, '').replace(/-/g, ' '))
898
921
  rows.push(
899
- <div key={m.id} className={`sub vrow${on ? ' on' : ''}`} onClick={(e) => go(m.id, e.shiftKey)}
922
+ <MarkedRow key={m.id} frame={m.id} className={`sub vrow${on ? ' on' : ''}`} onClick={(e) => go(m.id, e.shiftKey)}
900
923
  onContextMenu={(e) => cm.open(e, frameMenu(m))}>
901
924
  <span className={`chip${on ? ' on' : ''}`}>{(m.variant ?? '?').toUpperCase()}</span><span className="nm">{nm}</span>
902
- </div>,
925
+ </MarkedRow>,
903
926
  )
904
927
  }
905
928
  continue
@@ -908,7 +931,7 @@ export function App() {
908
931
  const n = nodeFor(f.id)
909
932
  const on = !!n && selection.includes(n.key)
910
933
  rows.push(
911
- <div key={f.id} className={`sub${on ? ' on' : ''}`} onClick={(e) => go(f.id, e.shiftKey)} onContextMenu={(e) => cm.open(e, frameMenu(f))} title={f.intent}>
934
+ <MarkedRow key={f.id} frame={f.id} className={`sub${on ? ' on' : ''}`} onClick={(e) => go(f.id, e.shiftKey)} onContextMenu={(e) => cm.open(e, frameMenu(f))} title={f.intent}>
912
935
  {/* every frame leads with an icon: the slide badge first (a deck
913
936
  frame is a deck frame whatever it imports), intent glyph for
914
937
  content frames, the plain rectangle for UI frames */}
@@ -917,8 +940,8 @@ export function App() {
917
940
  : f.intent
918
941
  ? <IntentGlyph intent={f.intent} size={13} className="iicon" aria-label={f.intent} />
919
942
  : <FrameRectIcon size={13} className="iicon" />}
920
- {cap(f.id.split('/').slice(1).join('/') || f.id)}
921
- </div>,
943
+ <span className="nm">{cap(f.id.split('/').slice(1).join('/') || f.id)}</span>
944
+ </MarkedRow>,
922
945
  )
923
946
  }
924
947
  return rows
@@ -969,7 +992,7 @@ export function App() {
969
992
 
970
993
  {CONFIG.setup
971
994
  ? <div className="sh-banner">no app detected - designs would be built from nothing. See design/instructions/setup.md, then restart</div>
972
- : CONFIG.noTheme && <div className="sh-banner">no theme configured - frames render unstyled. Create design/theme.css importing your app's stylesheet (or set theme in design/config.ts)</div>}
995
+ : CONFIG.noTheme && !contentOnly(manifest?.frames ?? []) && <div className="sh-banner">no theme configured - frames render unstyled. Create design/theme.css importing your app's stylesheet (or set theme in design/config.ts)</div>}
973
996
  <UpdatePill />
974
997
 
975
998
  <JamToasts toasts={toasts} />
@@ -1052,13 +1075,15 @@ function JamToast({ id, note, badge, inert }: { id: number; note: import('./stor
1052
1075
  <div className="sh-jam-txt">
1053
1076
  {human
1054
1077
  ? <b className="sh-jam-frame"><span className="t">{note.author!.name ?? 'Someone'}</span> <span className="v">{note.kind === 'mention' ? 'mentioned you' : 'replied'}</span></b>
1055
- : <b className="sh-jam-frame"><span className="t">{note.frameTitle ?? note.board}</span></b>}
1078
+ : note.stack?.length
1079
+ ? <b className="sh-jam-frame"><span className="t">{boardLabel(note.board)}</span> <span className="v">· {note.stack.length + 1} replies</span></b>
1080
+ : <b className="sh-jam-frame"><span className="t">{note.frameTitle ?? note.board}</span></b>}
1056
1081
  <span className="sh-jam-prev">{note.preview}</span>
1057
1082
  </div>
1058
1083
  {badge != null
1059
1084
  ? <span className="sh-jam-badge">+{badge}</span>
1060
1085
  : !inert && <>
1061
- <button className="sh-jam-view" onClick={() => void viewNote(note, dismiss)}>View</button>
1086
+ <button className="sh-jam-view" onClick={() => void viewNote(note, () => useStore.getState().advanceToast(id))}>View</button>
1062
1087
  <button className="sh-jam-x" aria-label="Dismiss" onClick={dismiss}><XIcon size={13} /></button>
1063
1088
  </>}
1064
1089
  </div>
@@ -5,9 +5,11 @@ import { StatusPicker } from './StatusPicker.tsx'
5
5
  import type { StatusWord } from '../../shared/board-types.ts'
6
6
  import { PHASE_LABEL, STATUS_LABEL } from '../../shared/status.ts'
7
7
  import { canvasCtl } from './canvas/Canvas.tsx'
8
+ import { rollup } from '../../shared/marks.ts'
9
+ import { Bubble, useAsks } from './marks-ui.tsx'
8
10
  import { Tip } from './Tip.tsx'
9
11
  import { copyToClipboard, type MenuItem, type MenuOpener } from './ContextMenu.tsx'
10
- import { ArrowLineUpIcon, CardsIcon, CardsThreeIcon, FolderIcon, FolderMinusIcon, FolderOpenIcon, FolderPlusIcon, PencilSimpleIcon, SignpostIcon } from './icons.tsx'
12
+ import { ArrowLineUpIcon, CardsIcon, CheckIcon, CardsThreeIcon, FolderIcon, FolderMinusIcon, FolderOpenIcon, FolderPlusIcon, PencilSimpleIcon, SignpostIcon } from './icons.tsx'
11
13
  import {
12
14
  applyDrop, boardsIn, createFolder, deleteFolder, depthOf, folderEntries, folderIn, folderOf, foldersIn, holdsFolders, humanize, INDENT, isOwnSlot, labelOf, listIn, moveBoard, moveFolderToRoot, newFolderSlot, parentOf, readTitle,
13
15
  resolveDrop, retitleFolder, rootIndex, slugFor,
@@ -53,7 +55,12 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
53
55
  const board = useStore((s) => s.board)
54
56
  const working = useStore((s) => s.workingBoards) // boards an agent is working on right now
55
57
  const titles = useStore((s) => s.boardTitles) // board slug → title, off the last tree read
56
- const meta = useStore((s) => s.boardMeta) // board slug → type and status (spec 20)
58
+ const meta = useStore((s) => s.boardMeta)
59
+ // sidebar marks (spec 25): a board you are not on, or a closed folder, rolls up its frames
60
+ const marks = useStore((s) => s.marks)
61
+ const asks = useAsks()
62
+ const framesOf = (boards: string[]) => boards.flatMap((b) => marks?.boards[b] ?? [])
63
+ const seeAll = (boards: string[]): MenuItem[] => (!PUBLISHED ? [{ label: 'Mark all as seen', icon: <CheckIcon size={15} />, onClick: () => useStore.getState().markSeen(framesOf(boards), true) }] : []) // board slug → type and status (spec 20)
57
64
  const label = (n: string) => labelOf(n, titles[n]) // a board's label; a folder's is labelOf(name, item.title)
58
65
  const [tree, setTree] = useState<TreeItem[]>([])
59
66
  const [naming, setNaming] = useState<Naming | null>(null)
@@ -329,7 +336,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
329
336
  refresh() // a clear: what the evidence says now
330
337
  }
331
338
  const boardMenu = (n: string, parent: string | null): MenuItem[] => {
332
- const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`board: ${n}`, 'path copied') }]
339
+ const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`board: ${n}`, 'path copied') }, ...seeAll([n])]
333
340
  if (PUBLISHED || n === 'all-scenes') return items
334
341
  // a feature or project board: its status first, as Linear puts it - the picker opens in place
335
342
  const m = useStore.getState().boardMeta[n]
@@ -352,7 +359,7 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
352
359
  const folderMenu = (f: string, boards: string[], parent: string | null): MenuItem[] => {
353
360
  const items: MenuItem[] = [{ label: 'Copy path', icon: <SignpostIcon size={15} />, onClick: () => copyToClipboard(`folder: ${f}${parent ? ` (in ${parent})` : ''} (boards: ${boards.join(', ') || 'none'})`, 'path copied') }]
354
361
  if (PUBLISHED) return items
355
- items.push({ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setNaming({ kind: 'folder', name: f }) })
362
+ items.push({ label: 'Rename', icon: <PencilSimpleIcon size={15} />, onClick: () => setNaming({ kind: 'folder', name: f }) }, ...seeAll(boards))
356
363
  // two levels: a top-level folder can hold folders; a sub-folder can leave its parent
357
364
  if (!parent) items.push({ label: 'New folder inside', icon: <FolderPlusIcon size={15} />, onClick: () => newFolderAt(listIn(treeRef.current, f)?.length ?? 0, undefined, f) })
358
365
  else items.push({ label: 'Move to top level', icon: <ArrowLineUpIcon size={15} />, onClick: () => mutate((t) => {
@@ -444,9 +451,11 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
444
451
  )
445
452
  const canDrag = !PUBLISHED && n !== 'all-scenes'
446
453
  const item: Drag = { kind: 'board', name: n }
454
+ // the board you are on shows nothing: its rows below speak for themselves
455
+ const r = n === board ? { asks: 0, fresh: 0 } : rollup(marks, asks, framesOf([n]))
447
456
  return (
448
457
  <button key={`b:${n}`} data-board-row data-board={n} data-folder={parent ?? undefined} data-depth={depth} data-reorderable={canDrag || undefined}
449
- className={`it board${indent(depth)}${n === board ? ' cur' : ''}${dragging ? ' dragging' : ''}${s.cls}`} style={s.style}
458
+ className={`it board${indent(depth)}${n === board ? ' cur' : ''}${r.asks ? ' mk-ask' : r.fresh ? ' mk-new' : ''}${dragging ? ' dragging' : ''}${s.cls}`} style={s.style}
450
459
  // draggable rows switch on the pointer tap (onPointerUp), so their trailing mouse
451
460
  // click (detail >= 1) must be ignored to avoid a double switch; keyboard clicks
452
461
  // (detail === 0) and non-draggable rows (all-scenes, published) switch here as normal
@@ -461,7 +470,14 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
461
470
  <span>{label(n)}</span>
462
471
  {/* the status for a screen reader, part of the board button's own name: the glyph is the eye's */}
463
472
  {meta[n]?.status && <span className="sh-sr" data-status-text>{`, ${statusTip(meta[n]).replace(/\n/g, '; ')}`}</span>}
464
- {meta[n]?.status && (
473
+ {meta[n]?.error && (
474
+ <Tip side="right" label={<div className="sh-tip-lines"><b>Not valid JSON - fix the file</b><small>{`design/boards/${n}.json: ${meta[n].error}`}</small></div>}>
475
+ <i className="st st-error" data-board-error aria-label={`not valid JSON: ${meta[n].error}`}>!</i>
476
+ </Tip>
477
+ )}
478
+ {/* one slot: a question for you takes it until answered, then the status comes back */}
479
+ {r.asks > 0 && <i className="st"><Bubble n={r.asks} /></i>}
480
+ {meta[n]?.status && !r.asks && (
465
481
  <Tip side="right" label={<StatusTipLabel m={meta[n]} />}>
466
482
  <i className="st" data-status={meta[n].status!.status} aria-hidden="true"><StatusIcon status={meta[n].status!.status} fill={meta[n].status!.fill} /></i>
467
483
  </Tip>
@@ -513,7 +529,11 @@ export function BoardList({ onMenu }: { onMenu: MenuOpener }) {
513
529
  {/* a closed folder carries the live signal of the boards it hides */}
514
530
  <LiveIcon live={!open && boards.some((b) => working.includes(b))}>{open ? <FolderOpenIcon size={14} /> : <FolderIcon size={14} />}</LiveIcon>
515
531
  <span>{labelOf(f, it.title)}</span>
516
- <small>{boards.length}</small>
532
+ {(() => {
533
+ // a closed folder's one slot rolls up what it hides: a question first, else a blue count
534
+ const r = open ? { asks: 0, fresh: 0 } : rollup(marks, asks, framesOf(boards))
535
+ return r.asks ? <Bubble n={r.asks} /> : <small className={r.fresh ? 'mk-fresh' : undefined}>{boards.length}</small>
536
+ })()}
517
537
  </button>,
518
538
  )
519
539
  }
@@ -15,6 +15,7 @@ import { useStore, BOARD_POLICY, BRANDING, CONFIG, PUBLISHED, SOURCE_REVEALED, b
15
15
  import { deckOrder } from './play-order.ts'
16
16
  import { useComments } from './comments-store.ts'
17
17
  import { isNoteAnchor } from './notes.ts'
18
+ import { stageShown } from './marks-ui.tsx'
18
19
  import { ROUTE, slideSize } from '../const.ts'
19
20
  import { poweredByUrl } from '../../shared/utm.ts'
20
21
  import { canvasCtl } from './canvas/ctl.ts'
@@ -464,6 +465,7 @@ function PlayInner() {
464
465
  postStage({ type: 'sh:laser', on: s.laser })
465
466
  postStage({ type: 'sh:pick', on: commentsStore().commentMode, quiet: !commentsStore().showAnchor })
466
467
  setStageReady((n) => n + 1) // a reload wiped the frame's lock; let PlayComments re-drive it
468
+ stageShown() // spec 25: what the stage shows now counts toward seen
467
469
  } else if (data.type === 'sh:stage-at') {
468
470
  const p = s.play
469
471
  if (p && typeof data.at === 'string') s.setPlay({ ...p, at: data.at })
@@ -231,6 +231,8 @@ export function Canvas() {
231
231
  const keys = linkTargets(bootHash, useStore.getState().nodes)
232
232
  if (keys.length) {
233
233
  useStore.setState({ selection: keys })
234
+ const st = useStore.getState() // a link opened is a look (marks not in yet: their first load acknowledges it)
235
+ st.markSeen(keys.map((k) => st.nodes.find((n) => n.key === k)?.frame).filter((f): f is string => !!f))
234
236
  canvasCtl.fitNodes(keys)
235
237
  } else {
236
238
  canvasCtl.fitAll()
@@ -12,6 +12,7 @@ import { canAutoReload, shouldArmReadyWatch } from './ready-watch.ts'
12
12
  import { Stickies, type NoteSpec } from './Sticky.tsx'
13
13
  import { noteId, sceneNoteHost } from '../notes.ts'
14
14
  import { slideSize, stageFit } from '../../const.ts'
15
+ import { FrameSlot, toneOf, useFrameMark } from '../marks-ui.tsx'
15
16
 
16
17
  export const HEADER = 28
17
18
  const SNAP = 12
@@ -64,6 +65,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
64
65
  const selected = useStore((s) => s.selection.includes(node.key))
65
66
  const interact = useStore((s) => s.interact === node.key)
66
67
  const working = useStore((s) => s.working.includes(node.frame)) // Live Jam: Marver is editing this frame
68
+ const mark = useFrameMark(node.frame) // spec 25: new, or a question for you
67
69
  // sticky notes (spec 18): the scene's note when this node is the scene's first on the board
68
70
  // (reading order), then the frame's own. Text is compared by value - a note edit re-renders
69
71
  // only its column; a pan never re-renders any node (no position subscription here).
@@ -272,6 +274,7 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
272
274
  // shift-click toggles multi-selection instead of dragging (Figma convention)
273
275
  if (e.shiftKey && mode === 'move') { select(node.key, true); return }
274
276
  if (!(selected && useStore.getState().selection.length > 1)) select(node.key)
277
+ else useStore.getState().markSeen([node.frame]) // a click inside a group selection still looks at this one
275
278
  const el = e.currentTarget as HTMLElement
276
279
  const world = document.getElementById('sh-world')!
277
280
  // Law G-5: measured scale, never stored zoom state. #sh-world is 1px wide by design,
@@ -391,13 +394,15 @@ export const FrameNode = memo(function FrameNode({ node }: { node: Node }) {
391
394
  <span>{variantName}</span>
392
395
  </div>
393
396
  )}
394
- <div className="sh-node-head sh-no-pan" onPointerDown={(e) => drag(e, 'move')} title={frame.file}>
397
+ <div className={`sh-node-head sh-no-pan${toneOf(mark)}`} onPointerDown={(e) => drag(e, 'move')} title={frame.file}>
395
398
  {/* the chrome badge: slide first, else the content intent glyph */}
396
399
  {frame.slide
397
400
  ? <SlideFrameIcon size={12} className="iicon sh-no-pan" role="img" aria-hidden={false} aria-label="slide" />
398
401
  : frame.intent && <IntentGlyph intent={frame.intent} size={12} className="iicon sh-no-pan" aria-label={frame.intent} />}
399
402
  <span className="id sh-no-pan">{frame.title ?? frame.id}</span>
400
403
  <span className="dim sh-no-pan">{Math.round(node.w)} · {node.theme}</span>
404
+ {/* the sidebar's marks on the frame itself (spec 25): no outline, no glow - the glow is an agent working */}
405
+ <FrameSlot m={mark} />
401
406
  </div>
402
407
 
403
408
  <div className="sh-node-body" style={{ height: node.h }}>
@@ -125,6 +125,8 @@ export const useComments = create<CommentsState>((set, get) => {
125
125
  threadId, board: t?.board ?? e.board ?? get().board ?? '', ts: e.ts,
126
126
  preview: (e.body ?? '').replace(/\s+/g, ' ').slice(0, 90),
127
127
  frame: t?.frame, frameTitle: entry?.title ?? t?.frame, intent: entry?.intent,
128
+ // a reply folds into the board's round; a new note, or a reply that asks (ends in "?"), stands alone
129
+ round: e.type === 'reply' && !/\?\s*$/.test(e.body ?? ''),
128
130
  })
129
131
  }
130
132
  })
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Sidebar marks in the shell (spec 25, variant B - one slot). Colour on a row's icon and title
3
+ * carries the state (blue new, orange needs you); the row's one right-hand slot holds what matters
4
+ * most: a question's numbered bubble, then the row's own count or status, then a frame's dot.
5
+ */
6
+ import { useEffect, type HTMLAttributes, type ReactNode } from 'react'
7
+ import { create } from 'zustand'
8
+ import { useStore, PUBLISHED } from './store.ts'
9
+ import { useComments } from './comments-store.ts'
10
+ import { frameMark, isNew, questions, type Ask, type FrameMark } from '../../shared/marks.ts'
11
+
12
+ /** Every frame's mark, derived ONCE per change of marks, threads or manifest. Rows and headers read
13
+ * one string each, so a change re-renders only what it changes - never the whole shell. */
14
+ interface View { q: Map<string, Ask>; frame: Record<string, string>; fresh: Record<string, true> }
15
+ const useMarkView = create<View>(() => ({ q: new Map(), frame: {}, fresh: {} }))
16
+ const derive = () => {
17
+ const { marks, manifest } = useStore.getState()
18
+ // a published canvas shows no marks at all: no seen state there, and its threads are not yours
19
+ const q = PUBLISHED ? new Map<string, Ask>() : questions(useComments.getState().threads)
20
+ const frame: Record<string, string> = {}, fresh: Record<string, true> = {}
21
+ for (const f of manifest?.frames ?? []) {
22
+ const m = frameMark(marks, q, f.id)
23
+ if (m) frame[f.id] = m.kind === 'new' ? 'new' : `${m.kind}:${m.n}`
24
+ if (isNew(marks, f.id)) fresh[f.id] = true
25
+ }
26
+ useMarkView.setState({ q, frame, fresh })
27
+ }
28
+ useStore.subscribe((s, p) => { if (s.marks !== p.marks || s.manifest !== p.manifest) derive() })
29
+ useComments.subscribe((s, p) => { if (s.threads !== p.threads) derive() })
30
+
31
+ /** The playNav at which the focus/play stage last finished loading (Play reports it); -1 while none
32
+ * has. An applied Update reloads the stage: the change is on screen once that reload lands. */
33
+ let stageNav = -1
34
+ export const stageShown = () => { stageNav = useStore.getState().playNav }
35
+ useStore.subscribe((s, p) => { if (!s.play && p.play) stageNav = -1 })
36
+
37
+ export const asksNow = (): Map<string, Ask> => useMarkView.getState().q
38
+ /** Open Marver questions per frame - for the board list, a light component that rolls up per board. */
39
+ export const useAsks = (): Map<string, Ask> => useMarkView((s) => s.q)
40
+
41
+ const parse = (k: string): FrameMark => {
42
+ if (!k) return null
43
+ if (k === 'new') return { kind: 'new' }
44
+ const [kind, n] = k.split(':')
45
+ return { kind: kind as 'ask' | 'answered', n: Number(n) }
46
+ }
47
+ export const useFrameMark = (id: string): FrameMark => parse(useMarkView((s) => s.frame[id] ?? ''))
48
+
49
+ /** A row standing for many frames: open questions and new frames among `ids`, as one primitive -
50
+ * the row re-renders only when the pair changes. */
51
+ export function useRollup(ids: readonly string[]): { asks: number; fresh: number } {
52
+ const k = useMarkView((s) => {
53
+ let asks = 0, fresh = 0
54
+ for (const id of new Set(ids)) { const f = s.frame[id]; if (f?.startsWith('ask:')) asks += Number(f.slice(4)); if (s.fresh[id]) fresh++ }
55
+ return `${asks}:${fresh}`
56
+ })
57
+ const [asks, fresh] = k.split(':').map(Number)
58
+ return { asks, fresh }
59
+ }
60
+
61
+ /** The row's tone class: blue for new, orange for a question (answered or not). */
62
+ export const toneOf = (m: FrameMark): string => (!m ? '' : m.kind === 'new' ? ' mk-new' : ' mk-ask')
63
+
64
+ export const Bubble = ({ n, hollow }: { n: number; hollow?: boolean }) => (
65
+ <i className={`mk-bubble${hollow ? ' hollow' : ''}`} data-mark={hollow ? 'answered' : 'ask'}
66
+ aria-label={hollow ? `${n} answered, waiting on the agent` : `${n} question${n > 1 ? 's' : ''} for you`}>{n}</i>
67
+ )
68
+
69
+ /** A frame row's slot: the bubble, or the blue dot. */
70
+ export function FrameSlot({ m }: { m: FrameMark }) {
71
+ if (!m) return null
72
+ if (m.kind === 'new') return <i className="mk-slot"><i className="mk-dot" data-mark="new" aria-label="new" /></i>
73
+ return <i className="mk-slot"><Bubble n={m.n} hollow={m.kind === 'answered'} /></i>
74
+ }
75
+
76
+ /** A sidebar frame row that wears its frame's mark: the tone on the row, the slot at its end. */
77
+ export function MarkedRow({ frame, className, children, ...rest }: { frame: string; className: string; children: ReactNode } & HTMLAttributes<HTMLDivElement>) {
78
+ const m = useFrameMark(frame)
79
+ return <div className={className + toneOf(m)} {...rest}>{children}<FrameSlot m={m} /></div>
80
+ }
81
+
82
+ /** Looking at a frame counts as seeing it (spec 25): any part of it in the window for two seconds,
83
+ * at a readable zoom (scale 0.5 or more), showing the change - a frame still loading, or holding a
84
+ * deferred update, is not showing it yet. In focus or play the frame on stage fills the window, once
85
+ * an update it holds is applied and the stage has reloaded with it. Polls once a second, and only frames that are new. */
86
+ export function useSeenOnScreen() {
87
+ useEffect(() => {
88
+ if (PUBLISHED) return
89
+ const since = new Map<string, number>() // "key@changed" -> when it came into view
90
+ const tick = () => {
91
+ const s = useStore.getState(), m = s.marks
92
+ const now = Date.now()
93
+ const shown = new Map<string, string>() // clock key -> frame; a newer change restarts the clock
94
+ if (m && !document.hidden && s.play) {
95
+ const f = s.nodes.find((n) => n.key === s.play!.at)?.frame ?? s.play.at
96
+ if (!s.playUpdateRevision && stageNav === s.playNav && isNew(m, f)) shown.set(`play:${f}@${m.changed[f] ?? 0}`, f)
97
+ } else if (m && !document.hidden && s.scale >= 0.5) {
98
+ // in view: some of it inside the window and not all of that under the open sidebar
99
+ const P = document.querySelector('.sh-panel:not(.closed)')?.getBoundingClientRect()
100
+ const W = window.innerWidth, H = window.innerHeight
101
+ for (const n of s.nodes) {
102
+ if (n.status !== 'ready' || s.pendingFrameRevisions[n.frame] || !isNew(m, n.frame)) continue
103
+ const r = document.querySelector<HTMLElement>(`.sh-node[data-node="${CSS.escape(n.key)}"]`)?.getBoundingClientRect()
104
+ if (!r) continue
105
+ const x0 = Math.max(r.left, 0), x1 = Math.min(r.right, W), y0 = Math.max(r.top, 0), y1 = Math.min(r.bottom, H)
106
+ if (x0 >= x1 || y0 >= y1) continue
107
+ if (P && x0 >= P.left && x1 <= P.right && y0 >= P.top && y1 <= P.bottom) continue
108
+ shown.set(`${n.key}@${m.changed[n.frame] ?? 0}`, n.frame)
109
+ }
110
+ }
111
+ for (const k of [...since.keys()]) if (!shown.has(k)) since.delete(k)
112
+ const due: string[] = []
113
+ for (const [k, f] of shown) { const t = since.get(k) ?? now; since.set(k, t); if (now - t >= 2000) due.push(f) }
114
+ if (due.length) s.markSeen(due, true)
115
+ }
116
+ const id = setInterval(tick, 1000)
117
+ return () => clearInterval(id)
118
+ }, [])
119
+ }