@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
@@ -102,6 +102,10 @@ export interface JamNote {
102
102
  frame?: string; frameTitle?: string; intent?: string
103
103
  kind?: 'mention' | 'reply' // absent = the agent pill
104
104
  author?: { name?: string; avatar?: string; id?: string; email?: string }
105
+ /** an agent REPLY (not a new question): a board's replies fold into one notice per round (spec 25) */
106
+ round?: boolean
107
+ /** the earlier replies of the round, under this one - View walks through them */
108
+ stack?: JamNote[]
105
109
  }
106
110
  export interface Toast { id: number; text: string; jam?: JamNote }
107
111
 
@@ -150,6 +154,7 @@ import { canAutoReload } from './canvas/ready-watch.ts'
150
154
  import { buildTree, flatten, labelOf, toWire, TREE_PROTOCOL, type TreeItem } from '../../shared/board-tree.ts'
151
155
  import type { BoardType, StatusWord } from '../../shared/board-types.ts'
152
156
  import type { Phase, Status } from '../../shared/status.ts'
157
+ import { isNew, type Marks } from '../../shared/marks.ts'
153
158
 
154
159
  /** The CAS tokens a tree write echoes: the sha256 of every board file as last seen, and of
155
160
  * the folder registry (null = there was no file). */
@@ -164,6 +169,8 @@ export interface BoardMeta {
164
169
  status?: { status: Status; row?: number; fill?: Phase; reason?: string; evidence?: string[] }
165
170
  /** what a person may set it to from the sidebar (dev only) - shared/board-types settableStatuses */
166
171
  settable?: StatusWord[]
172
+ /** the board file is not valid JSON: the parser's words, line and column (#6) */
173
+ error?: string
167
174
  }
168
175
 
169
176
  /** The sidebar tree: root boards and folders in rank order, each folder's boards and
@@ -173,7 +180,7 @@ export interface BoardMeta {
173
180
  export async function fetchBoardTree(): Promise<TreeSnapshot> {
174
181
  if (DATA) return { tree: DATA.tree ?? DATA.names.filter((n) => n !== 'all-scenes').map((n) => ({ kind: 'board', name: n })), base: { boards: {}, folders: null }, titles: DATA.titles ?? {}, meta: DATA.meta ?? {} }
175
182
  const [boards, reg] = await Promise.all([
176
- fetch(`${ROUTE}/api/boards`).then((r) => r.json()) as Promise<{ name: string; sha256: string; order?: number; folder?: string; title?: string; type?: BoardType; status?: BoardMeta['status'] | null; settable?: StatusWord[] }[]>,
183
+ fetch(`${ROUTE}/api/boards`).then((r) => r.json()) as Promise<{ name: string; sha256: string; order?: number; folder?: string; title?: string; type?: BoardType; status?: BoardMeta['status'] | null; settable?: StatusWord[]; error?: string }[]>,
177
184
  fetch(`${ROUTE}/api/folders`).then(async (r) => {
178
185
  const j = await r.json() as { folders?: { name: string; order?: number; parent?: string; title?: string }[]; sha256?: string | null; error?: string }
179
186
  if (!r.ok) throw new Error(j?.error ?? `folders ${r.status}`)
@@ -184,7 +191,7 @@ export async function fetchBoardTree(): Promise<TreeSnapshot> {
184
191
  tree: buildTree(boards, reg.folders ?? []),
185
192
  base: { boards: Object.fromEntries(boards.map((b) => [b.name, b.sha256])), folders: reg.sha256 ?? null },
186
193
  titles: Object.fromEntries(boards.flatMap((b) => (b.title ? [[b.name, b.title]] : []))),
187
- meta: Object.fromEntries(boards.map((b) => [b.name, { ...(b.type && b.type !== 'plain' ? { type: b.type } : {}), ...(b.status ? { status: b.status } : {}), ...(b.settable?.length ? { settable: b.settable } : {}) }])),
194
+ meta: Object.fromEntries(boards.map((b) => [b.name, { ...(b.type && b.type !== 'plain' ? { type: b.type } : {}), ...(b.status ? { status: b.status } : {}), ...(b.settable?.length ? { settable: b.settable } : {}), ...(b.error ? { error: b.error } : {}) }])),
188
195
  }
189
196
  }
190
197
  /** A tree read's types and statuses, kept under the same latest-wins rule as its titles. */
@@ -399,12 +406,26 @@ function defaultSize(frame: FrameEntry) {
399
406
  }
400
407
 
401
408
  let resizedInGesture = false
409
+ // sidebar marks: the fetch in flight, and acknowledgements the server has not confirmed yet
410
+ let marksSeq = 0
411
+ let marksTimer: ReturnType<typeof setTimeout> | undefined
412
+ const pendingSeen: Record<string, number> = {}
413
+ /** frames looked at before the first marks arrived (a link, a click, focus) - acknowledged when they land */
414
+ const lookedEarly = new Set<string>()
415
+ /** Why a board's last load failed, from the server (a parse error names its line) - for its toast. */
416
+ const loadErrors = new Map<string, string>()
417
+ const whyNot = (name: string) => { const e = loadErrors.get(name); return e ? ` - ${e}` : '' }
402
418
 
403
419
  /** sceneRows is the legacy shorthand for a plain rows layout. */
404
420
  const effectiveLayout = (layout: BoardLayout | null, sceneRows: string[][] | null): BoardLayout | undefined =>
405
421
  layout ?? (sceneRows?.length ? { rows: sceneRows.map((r) => [...r]) } : undefined)
406
422
 
423
+ /** Every scene of the project, empty phase scenes included - a layout naming one is no typo (#18).
424
+ * A published bundle carries the empty scenes its recipes name, so it lays out as dev does. */
425
+ const knownScenes = (m: Manifest | null): ReadonlySet<string> => new Set(m?.scenes.map((s) => s.name))
426
+
407
427
  const layoutWarn = (msg: string) => {
428
+ if (PUBLISHED) return // a viewer cannot fix a recipe - the owner sees it in dev (#18: empty phase scenes)
408
429
  console.warn('[marver layout]', msg)
409
430
  try { useStore.getState().toast(`layout: ${msg}`) } catch { /* store not ready during boot */ }
410
431
  }
@@ -508,6 +529,8 @@ interface State {
508
529
  toast(text: string): void
509
530
  jamToast(note: JamNote): void
510
531
  dismissToast(id: number): void
532
+ /** View on a notice: a round's notice moves to its next reply, any other one goes. */
533
+ advanceToast(id: number): void
511
534
  clearJamToasts(): void
512
535
  /** Frames Marver is editing right now (Live Jam presence) - drives the working glow. */
513
536
  working: string[]
@@ -519,6 +542,12 @@ interface State {
519
542
  setWorkingFrom(m: unknown): void
520
543
  /** Fetch what is lit now (dev only) - the snapshot behind the broadcasts. */
521
544
  syncWorking(): Promise<void>
545
+ /** Sidebar marks (spec 25): what changed since you looked - null on a published canvas. */
546
+ marks: Marks | null
547
+ syncMarks(): Promise<void>
548
+ /** You looked at these frames: clear their "new", here and on disk - skipping one still holding a
549
+ * deferred update, unless `shown` (the dwell and the play stage know what is on screen; Mark all as seen) */
550
+ markSeen(frameIds: readonly string[], shown?: boolean): void
522
551
  /** Boards showing a working frame - their sidebar icon shimmers while an agent works. */
523
552
  workingBoards: string[]
524
553
  /** The place in the server's order of the activity last applied - an older answer is dropped. */
@@ -673,6 +702,7 @@ export const useStore = create<State>((set, get) => {
673
702
  * keeps whatever board is currently mounted. */
674
703
  const loadBoardState = async (boardName: string): Promise<Partial<State> | null> => {
675
704
  clearNoteHeights() // heights are per column drawn; a key shared by two board files carries none across
705
+ loadErrors.delete(boardName)
676
706
  try {
677
707
  let raw: any
678
708
  const saved = loadSavedHeights() // in parallel with the manifest; every size below reads it
@@ -711,7 +741,7 @@ export const useStore = create<State>((set, get) => {
711
741
  loaded = body?.board == null ? 'fresh' : body // board:null = not materialized yet
712
742
  }
713
743
  else if (res.status === 404) loaded = 'fresh' // older servers still 404 fresh boards
714
- else loaded = null // anything else must not commit an empty canvas
744
+ else { loadErrors.set(boardName, (await res.json().catch(() => null))?.error ?? ''); loaded = null } // anything else must not commit an empty canvas - and says why (#6)
715
745
  }
716
746
  if (loaded === null) return null
717
747
  if (loaded !== 'fresh') {
@@ -848,7 +878,7 @@ export const useStore = create<State>((set, get) => {
848
878
  // a board with a recipe re-applies it (spec 18 - room is the layout's job)
849
879
  const cramped = !!boardHash && !needTidy && !!(layout || sceneRows?.length || boardAuto) && notesCramped(nodes, manifest)
850
880
  if ((!boardHash || needTidy || cramped) && nodes.length) {
851
- const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn)
881
+ const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
852
882
  for (const pl of placedAll) { const n = nodes.find((x) => x.key === pl.key)!; n.x = pl.x; n.y = pl.y }
853
883
  laidOut = sizeRecord(nodes)
854
884
  }
@@ -858,7 +888,7 @@ export const useStore = create<State>((set, get) => {
858
888
  // surface recipe problems at load (dry-run): materialized boards otherwise
859
889
  // never run tidy, so a broken agent-authored layout would fail silently
860
890
  if (layout && boardHash && !needTidy && !cramped && nodes.length) {
861
- tidy(tidyInput(nodes, manifest), layout, layoutWarn)
891
+ tidy(tidyInput(nodes, manifest), layout, layoutWarn, knownScenes(manifest))
862
892
  }
863
893
  return { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }
864
894
  } catch { return null }
@@ -876,7 +906,7 @@ export const useStore = create<State>((set, get) => {
876
906
  const revAtStart = editRev, scenesAtStart = scenesRev
877
907
  const next = await loadBoardState(boardName)
878
908
  if (seq !== loadSeq) return false // a newer load superseded this one
879
- if (!next) { get().toast(`board "${boardName}" failed to load`); return false }
909
+ if (!next) { get().toast(`board "${boardName}" failed to load${whyNot(boardName)}`); return false }
880
910
  // the user kept editing while we fetched - their newer state wins over the reload
881
911
  if (get().board !== boardName || editRev !== revAtStart || (mayCommit && !mayCommit())) return false
882
912
  const live = get().manifest // a WS manifest update may have landed mid-fetch
@@ -909,7 +939,7 @@ export const useStore = create<State>((set, get) => {
909
939
  // there is never an empty intermediate state and nothing to roll back
910
940
  const next = await loadBoardState(name)
911
941
  if (mySwitch !== switchSeq) return
912
- if (!next) { get().toast(`could not load "${name}" - staying on ${get().board}`); return }
942
+ if (!next) { get().toast(`could not load "${name}"${whyNot(name)} - staying on ${get().board}`); return }
913
943
  // edits may have landed on the still-mounted old board during the target load
914
944
  for (let i = 0; i < 5 && get().dirty && ok; i++) { clearTimeout(saveTimer); ok = await get().save() }
915
945
  if (mySwitch !== switchSeq) return
@@ -1337,6 +1367,8 @@ export const useStore = create<State>((set, get) => {
1337
1367
  : [key]
1338
1368
  return { selection, interact: s.interact && selection.includes(s.interact) ? s.interact : null }
1339
1369
  })
1370
+ // selecting a frame is looking at it, every time - even one already selected (spec 25)
1371
+ if (key != null) { const f = get().nodes.find((n) => n.key === key)?.frame; if (f) get().markSeen([f]) }
1340
1372
  },
1341
1373
  // scoped device sizing: only the selected frames change; null restores their defaults.
1342
1374
  // Always followed by a tidy - a preset change must never scramble the layout.
@@ -1373,6 +1405,8 @@ export const useStore = create<State>((set, get) => {
1373
1405
  const valid = keys.filter((k) => s.nodes.some((n) => n.key === k))
1374
1406
  return { selection: valid, interact: s.interact && valid.includes(s.interact) ? s.interact : null }
1375
1407
  })
1408
+ // a frame link, a scene's name: the frames brought in front of you are looked at (⌘A is selectAll - not a look)
1409
+ const st = get(); st.markSeen(st.selection.map((k) => st.nodes.find((n) => n.key === k)?.frame).filter((f): f is string => !!f))
1376
1410
  },
1377
1411
  // interact is a ONE-frame mode: entering it collapses any multi-selection to the
1378
1412
  // interacted frame (a 4-frame selection double-clicked otherwise leaves all four
@@ -1512,7 +1546,7 @@ export const useStore = create<State>((set, get) => {
1512
1546
  },
1513
1547
  runTidy() {
1514
1548
  const { nodes, manifest, sceneRows, layout } = get()
1515
- const placed = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn)
1549
+ const placed = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
1516
1550
  set((s) => ({
1517
1551
  nodes: s.nodes.map((n) => {
1518
1552
  const p = placed.find((x) => x.key === n.key)
@@ -1533,9 +1567,30 @@ export const useStore = create<State>((set, get) => {
1533
1567
  jamToast(note) {
1534
1568
  const id = ++toastSeq
1535
1569
  const text = note.kind === 'mention' ? 'You were mentioned' : note.kind === 'reply' ? 'New reply' : 'Marver replied'
1536
- set((s) => ({ toasts: [...s.toasts.filter((t) => t.jam?.threadId !== note.threadId), { id, text, jam: note }].slice(-8) }))
1570
+ set((s) => {
1571
+ // one notice per board per round: an agent reply folds into that board's open notice (spec 25)
1572
+ // a round ends after ten quiet minutes: a later reply opens a fresh notice
1573
+ const prev = note.round ? s.toasts.find((t) => t.jam?.round && t.jam.board === note.board && note.ts - t.jam.ts < 600_000) : undefined
1574
+ const jam = prev ? { ...note, stack: [...(prev.jam!.stack ?? []), { ...prev.jam!, stack: undefined }].filter((n) => n.threadId !== note.threadId) } : note
1575
+ // a notice whose top reply is this thread steps down to the replies under it, never loses them
1576
+ const others = s.toasts.flatMap((t) => {
1577
+ if (t === prev) return []
1578
+ const rest = (t.jam?.stack ?? []).filter((n) => n.threadId !== note.threadId)
1579
+ if (t.jam?.threadId !== note.threadId) return [t.jam?.stack ? { ...t, jam: { ...t.jam, stack: rest } } : t]
1580
+ return rest.length ? [{ ...t, jam: { ...rest[rest.length - 1], stack: rest.slice(0, -1) } }] : []
1581
+ })
1582
+ return { toasts: [...others, { id, text, jam }].slice(-8) }
1583
+ })
1537
1584
  },
1538
1585
  dismissToast(id) { set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })) },
1586
+ advanceToast(id) {
1587
+ // a merged round notice steps to its next reply; any other notice goes
1588
+ set((s) => ({ toasts: s.toasts.flatMap((t) => {
1589
+ if (t.id !== id) return [t]
1590
+ const rest = t.jam?.stack ?? []
1591
+ return rest.length ? [{ ...t, jam: { ...rest[rest.length - 1], stack: rest.slice(0, -1) } }] : []
1592
+ }) }))
1593
+ },
1539
1594
  clearJamToasts() { set((s) => ({ toasts: s.toasts.filter((t) => !t.jam) })) },
1540
1595
  setWorkingFrom(m) {
1541
1596
  const strings = (v: unknown) => (Array.isArray(v) ? v.filter((x: unknown): x is string => typeof x === 'string') : [])
@@ -1546,6 +1601,45 @@ export const useStore = create<State>((set, get) => {
1546
1601
  if (seq !== undefined) set({ workingSeq: seq })
1547
1602
  get().setWorking(strings(o.frames), strings(o.boards))
1548
1603
  },
1604
+ marks: null,
1605
+ // one fetch per burst (activity, board edits, file changes), and only the newest answer lands;
1606
+ // acknowledgements still in flight are kept over any answer that predates them
1607
+ async syncMarks() {
1608
+ if (PUBLISHED) return
1609
+ clearTimeout(marksTimer)
1610
+ await new Promise<void>((done) => { marksTimer = setTimeout(done, 200) })
1611
+ const seq = ++marksSeq
1612
+ try {
1613
+ for (let i = 0; i < 2; i++) { // the first ask may prime the CSRF cookie (as syncWorking)
1614
+ const r = await fetch(`${ROUTE}/api/marks`, { headers: { 'x-mv-c': csrf() } })
1615
+ if (seq !== marksSeq) return
1616
+ if (r.ok) {
1617
+ const m = await r.json() as Marks
1618
+ if (seq !== marksSeq) return
1619
+ const seen = { ...m.seen }
1620
+ for (const [id, at] of Object.entries(pendingSeen)) seen[id] = Math.max(seen[id] ?? 0, at)
1621
+ set({ marks: { ...m, seen } })
1622
+ if (lookedEarly.size) { const early = [...lookedEarly]; lookedEarly.clear(); get().markSeen(early) }
1623
+ return
1624
+ }
1625
+ if (r.status !== 403) return
1626
+ }
1627
+ } catch { /* the next broadcast heals it */ }
1628
+ },
1629
+ markSeen(frameIds, shown) {
1630
+ const m = get().marks, held = get().pendingFrameRevisions
1631
+ if (!m) { if (!PUBLISHED) for (const id of frameIds) lookedEarly.add(id); return }
1632
+ const fresh = frameIds.filter((id) => isNew(m, id) && (shown || !held[id]))
1633
+ if (!m || !fresh.length) return
1634
+ // you saw the change the page shows - its stamp, never a clock: an edit landing after this is new
1635
+ const seen = Object.fromEntries(fresh.map((id) => [id, m.changed[id] ?? 0]))
1636
+ Object.assign(pendingSeen, seen)
1637
+ set({ marks: { ...m, seen: { ...m.seen, ...seen } } })
1638
+ void postOwner('marks/seen', { frames: seen })
1639
+ // kept once confirmed too (stamps only ever rise): an answer that left before this one cannot undo it
1640
+ .then((r) => { if (!r.ok) throw new Error(String(r.status)) })
1641
+ .catch(() => { for (const [id, at] of Object.entries(seen)) if (pendingSeen[id] === at) delete pendingSeen[id]; void get().syncMarks() })
1642
+ },
1549
1643
  async syncWorking() {
1550
1644
  if (PUBLISHED) return
1551
1645
  try {
@@ -1672,5 +1766,12 @@ export const useStore = create<State>((set, get) => {
1672
1766
  }
1673
1767
  })
1674
1768
 
1769
+ // a frame opened in focus or play is looked at (spec 25); selecting one is handled in select()
1770
+ useStore.subscribe((s, prev) => {
1771
+ // a frame opened in focus or play is in front of you too - stepping within play while an edit is
1772
+ // held behind Update shows the old version, so that waits for the dwell after Update
1773
+ if (s.play?.at && s.play.at !== prev.play?.at && (!prev.play || !s.playUpdateRevision)) { const f = s.nodes.find((n) => n.key === s.play!.at)?.frame ?? s.play.at; s.markSeen([f], true) }
1774
+ })
1775
+
1675
1776
  // dev-only inspection hook for tests/debugging (never installed in published builds)
1676
1777
  if (import.meta.env.DEV) (window as unknown as { __mvStore: unknown }).__mvStore = useStore
@@ -12,6 +12,7 @@
12
12
  --glass-ink: #18181b;
13
13
  --glass-ink-2: rgba(24, 24, 27, .66);
14
14
  --glass-ink-3: rgba(24, 24, 27, .4);
15
+ --mk-ask: #f08a00; --mk-new: #0077e6;
15
16
  --glass-hover: rgba(24, 24, 27, .06);
16
17
  --glass-accent: #0077e6;
17
18
  --glass-accent-bg: rgba(0, 136, 255, .13);
@@ -52,6 +53,7 @@
52
53
  --glass-ink: #f5f5f7;
53
54
  --glass-ink-2: rgba(245, 245, 247, .64);
54
55
  --glass-ink-3: rgba(245, 245, 247, .4);
56
+ --mk-ask: #ff9f0a; --mk-new: #5cb3ff;
55
57
  --glass-hover: rgba(255, 255, 255, .1);
56
58
  --glass-accent: #5cb3ff;
57
59
  --glass-accent-bg: rgba(0, 136, 255, .28);
@@ -472,6 +474,7 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
472
474
  /* spec 20: a feature or project board's status ring sits at the row's end, in its own colours -
473
475
  never the accent of the current row - with its evidence in the tooltip */
474
476
  .sh-panel .it.board .st { flex: none; display: inline-flex; margin-left: auto; font-style: normal }
477
+ .sh-panel .it.board .st-error { width: 14px; height: 14px; border-radius: 7px; justify-content: center; align-items: center; font: 700 10px/1 system-ui; color: #fff; background: #ff3b30 }
475
478
  /* the settled statuses' fills, one value per theme: done is the content palette's green (Apple's
476
479
  systemGreen); archived is Apple's brown - its increased-contrast value on light, its default on
477
480
  dark, where the increased-contrast one turns peach - so it reads as the same brown box in both */
@@ -1397,3 +1400,23 @@ body.sh-commenting .sh-sticky-body { cursor: crosshair }
1397
1400
  research/notes/diagprobe5.ts */
1398
1401
  text-rendering: geometricPrecision }
1399
1402
  .sh-sticky-diagram svg text, .sh-sticky-diagram svg tspan { text-rendering: geometricPrecision }
1403
+
1404
+ /* sidebar marks (spec 25, variant B - one slot): colour on the icon and title carries the state,
1405
+ blue new, orange needs you; the row's one right-hand slot holds the bubble or the dot. Their own
1406
+ tokens: the accent turns purple in interact mode, a mark never does */
1407
+ .sh-panel .sub .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
1408
+ .mk-slot { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 16px; margin-left: 6px; font-style: normal }
1409
+ .sh-node-head .mk-slot { margin-left: 0 }
1410
+ .mk-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mk-new); flex: none }
1411
+ .mk-bubble { flex: none; min-width: 16px; height: 15px; padding: 0 4px; border-radius: 8px 8px 8px 2px;
1412
+ background: var(--mk-ask); color: #fff; font: 700 10px/15px -apple-system, system-ui, sans-serif; font-style: normal;
1413
+ text-align: center; font-variant-numeric: tabular-nums }
1414
+ .mk-bubble.hollow { background: transparent; color: var(--mk-ask); box-shadow: inset 0 0 0 1.5px var(--mk-ask) }
1415
+ .sh-panel .sub.mk-new, .sh-panel .sub.mk-new .nm { color: var(--mk-new); font-weight: 600 }
1416
+ .sh-panel .sub.mk-new .iicon, .sh-panel .sub.mk-new .chip { color: var(--mk-new); opacity: 1 }
1417
+ .sh-panel .sub.mk-ask .iicon, .sh-panel .sub.mk-ask .chip { color: var(--mk-ask); opacity: 1 }
1418
+ .sh-panel .it.board.mk-new { color: var(--mk-new) }
1419
+ .sh-panel .it.board.mk-new > .sh-live-ic svg, .sh-panel .it.board.mk-new > svg { color: var(--mk-new) }
1420
+ .sh-panel .it.board.mk-ask > .sh-live-ic svg, .sh-panel .it.board.mk-ask > svg { color: var(--mk-ask) }
1421
+ .sh-panel .it small.mk-fresh { color: var(--mk-new); font-weight: 700 }
1422
+ .sh-node-head.mk-new .id { color: var(--mk-new) }
@@ -21,6 +21,19 @@ export interface BoardLayout extends Flow { scenes?: Record<string, Flow> }
21
21
  export type Warn = (msg: string) => void
22
22
 
23
23
  const isSpace = (x: unknown): x is Space => !!x && typeof x === 'object' && !Array.isArray(x)
24
+ /** Drop the items `isGone` names, each with the spacer that led into it (or, at the start, the
25
+ * one that followed it) - what is left reads as if the item was never there. */
26
+ function dropGone<T>(items: T[], isGone: (x: T) => boolean): T[] {
27
+ const out: T[] = []
28
+ let skip = false
29
+ for (const it of items) {
30
+ if (isGone(it)) { if (isSpace(out[out.length - 1])) out.pop(); else if (!out.length) skip = true; continue }
31
+ if (skip && isSpace(it)) { skip = false; continue }
32
+ skip = false
33
+ out.push(it)
34
+ }
35
+ return out
36
+ }
24
37
  const units = (s: Space, warn: Warn): number =>
25
38
  Number.isInteger(s.space) && s.space > 0 ? s.space : (warn(`invalid space ${JSON.stringify(s.space)} - using 1`), 1)
26
39
 
@@ -268,7 +281,9 @@ function layoutScene(scene: string, members: TidyNode[], flow: Flow | undefined,
268
281
  * array is never reordered (iframe law G-1). Two passes: each scene lays out its
269
282
  * frames (recipe or default lane), then the board flow places the scene boxes.
270
283
  */
271
- export function tidy(nodes: TidyNode[], layout?: BoardLayout, warn: Warn = () => {}): Placed[] {
284
+ /** `known`: every scene of the project. A layout naming a known scene with no node on this board
285
+ * (an empty phase scene, frames not pinned here) skips it quietly; only an unknown name warns (#18). */
286
+ export function tidy(nodes: TidyNode[], layout?: BoardLayout, warn: Warn = () => {}, known?: ReadonlySet<string>): Placed[] {
272
287
  const scenes = [...new Set(nodes.map((n) => n.scene))]
273
288
 
274
289
  // pass 1: per-scene relative layouts + bounding boxes
@@ -300,7 +315,23 @@ export function tidy(nodes: TidyNode[], layout?: BoardLayout, warn: Warn = () =>
300
315
  // PLAIN tidy (default trailing lanes), never a silent pick
301
316
  let boardFlow: Flow
302
317
  if (layout && layout.rows && layout.columns) { warn('layout has rows AND columns - ignoring it (plain tidy)'); boardFlow = { rows: [] } }
303
- else if (layout && (layout.rows || layout.columns)) boardFlow = { rows: layout.rows, columns: layout.columns }
318
+ else if (layout && (layout.rows || layout.columns)) {
319
+ // #18: a known scene with nothing on this board (an empty phase scene) leaves the recipe
320
+ // with the spacer that went with it, so the rest lays out as if it was never named - quietly
321
+ const gone = (a: unknown) => typeof a === 'string' && !!known?.has(a) && !sceneBoxes.has(a)
322
+ const prune = (flow?: Array<Lane | Space>) => {
323
+ if (!flow || !known) return flow
324
+ const emptied = new Set<unknown>()
325
+ const lanes = flow.map((e) => {
326
+ if (!Array.isArray(e) || !e.some(gone)) return e
327
+ const kept = dropGone(e, gone)
328
+ if (kept.every(isSpace)) emptied.add(kept)
329
+ return kept
330
+ })
331
+ return dropGone(lanes, (e) => emptied.has(e))
332
+ }
333
+ boardFlow = { rows: prune(layout.rows), columns: prune(layout.columns) }
334
+ }
304
335
  else boardFlow = { rows: [] } // default: every scene its own trailing lane (alphabetical)
305
336
 
306
337
  const listed = new Set<string>()
@@ -315,7 +346,7 @@ export function tidy(nodes: TidyNode[], layout?: BoardLayout, warn: Warn = () =>
315
346
  boardFlow,
316
347
  (atom) => {
317
348
  const b = sceneBoxes.get(atom)
318
- if (!b) warn(`unknown scene "${atom}" in layout - skipped`)
349
+ if (!b && !known?.has(atom)) warn(`unknown scene "${atom}" in layout - skipped`)
319
350
  return b ?? null
320
351
  },
321
352
  trailing,
@@ -0,0 +1,3 @@
1
+ /** A canvas made of content frames alone (Doc, Md, Diagram ship their own styling) needs no theme -
2
+ * only an app frame does (#4). Empty counts as not content-only: the warning still helps there. */
3
+ export const contentOnly = (frames: readonly { intent?: string }[]): boolean => frames.length > 0 && frames.every((f) => !!f.intent)
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Sidebar marks (spec 25 "what is new, what needs you", variant B - one slot). Pure: the shell and
3
+ * the tests read the same rules.
4
+ *
5
+ * Two signals. NEW: a frame changed since you looked (blue). NEEDS YOU: an open Marver question on
6
+ * a frame (orange). A row keeps ONE slot at its right edge; what fills it, first match wins: a
7
+ * question (the bubble with how many), then the row's own count or status, then a frame's dot.
8
+ */
9
+ import type { Thread } from './events.ts'
10
+
11
+ /** What the dev server says: when each frame last changed, when you last looked, and the line
12
+ * before which everything counts as seen (the day marks first ran). */
13
+ export interface Marks {
14
+ changed: Record<string, number>
15
+ seen: Record<string, number>
16
+ baseline: number
17
+ /** each board's frames - a board you are not on rolls up over these */
18
+ boards: Record<string, string[]>
19
+ }
20
+
21
+ export const isNew = (m: Marks | null, id: string): boolean =>
22
+ !!m && (m.changed[id] ?? 0) > Math.max(m.seen[id] ?? 0, m.baseline)
23
+
24
+ /** A question's state is read from its thread - nobody sets it. Open with Marver's word last:
25
+ * needs you. Open with yours last, after Marver spoke: answered, waiting on the agent. */
26
+ export type Ask = { ask: number; answered: number }
27
+ export function questions(threads: readonly Thread[]): Map<string, Ask> {
28
+ const out = new Map<string, Ask>()
29
+ for (const t of threads) {
30
+ if (t.resolved || !t.frame) continue
31
+ const last = t.replies.length ? t.replies[t.replies.length - 1] : t
32
+ const marver = !!t.agent || t.replies.some((r) => r.agent)
33
+ if (!marver) continue
34
+ const q = out.get(t.frame) ?? { ask: 0, answered: 0 }
35
+ if (last.agent) q.ask++
36
+ else q.answered++
37
+ out.set(t.frame, q)
38
+ }
39
+ return out
40
+ }
41
+
42
+ /** A single frame's mark. */
43
+ export type FrameMark = { kind: 'ask' | 'answered'; n: number } | { kind: 'new' } | null
44
+ export function frameMark(m: Marks | null, q: Map<string, Ask>, id: string): FrameMark {
45
+ const a = q.get(id)
46
+ if (a?.ask) return { kind: 'ask', n: a.ask }
47
+ if (a?.answered) return { kind: 'answered', n: a.answered }
48
+ return isNew(m, id) ? { kind: 'new' } : null
49
+ }
50
+
51
+ /** A row that stands for many frames (a board you are not on, a folder, a folded scene). */
52
+ export function rollup(m: Marks | null, q: Map<string, Ask>, ids: Iterable<string>): { asks: number; fresh: number } {
53
+ let asks = 0, fresh = 0
54
+ for (const id of new Set(ids)) { asks += q.get(id)?.ask ?? 0; if (isNew(m, id)) fresh++ }
55
+ return { asks, fresh }
56
+ }
57
+
58
+ /** `U`: the next frame that needs you, else the next new one - after `from` in reading order,
59
+ * wrapping. `order` is the board's frames top-to-bottom, left-to-right. */
60
+ export function nextToLook(m: Marks | null, q: Map<string, Ask>, order: readonly string[], from: string | null): string | null {
61
+ const i = from ? order.indexOf(from) : -1
62
+ const ring = [...order.slice(i + 1), ...order.slice(0, i + 1)]
63
+ // an answered frame waits on the agent, not on you: U skips it even when it is also new
64
+ return ring.find((id) => (q.get(id)?.ask ?? 0) > 0) ?? ring.find((id) => isNew(m, id) && !q.get(id)?.answered) ?? null
65
+ }