@marver-design/marver 0.22.1 → 0.23.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.
- package/CHANGELOG.md +117 -0
- package/README.md +14 -10
- package/dist/agent-BsieQGTD.mjs +99 -0
- package/dist/{bake-CvY8QR3L.mjs → bake-DQtnDB8-.mjs} +1 -1
- package/dist/{board-status-CWGHIdo_.mjs → board-status-BZSzc9Hp.mjs} +69 -610
- package/dist/boards-BRLnoTC3.mjs +620 -0
- package/dist/{boards-BwKI0qWd.mjs → boards-Dv-Ipd8G.mjs} +13 -5
- package/dist/{build-B1kavcpc.mjs → build-_ndp_dXn.mjs} +18 -10
- package/dist/cli.mjs +20 -11
- package/dist/{comments-ClVgfQib.mjs → comments-BlqyZh3D.mjs} +71 -9
- package/dist/{config-DJxMRVD8.mjs → config-BUKprFAp.mjs} +5 -97
- package/dist/{context-D4t59wDi.mjs → context-CdkNiKdJ.mjs} +3 -2
- package/dist/{daemon-PmNqoOAk.mjs → daemon-BvMPdQ3k.mjs} +78 -19
- package/dist/{dev-Cf4wLGe2.mjs → dev-Cf-4eqaC.mjs} +50 -10
- package/dist/{init-C_K-cjBQ.mjs → init-hfZV7TwY.mjs} +10 -4
- package/dist/{ledger-Bu0BjqIe.mjs → ledger-BNXW14Xw.mjs} +1 -6
- package/dist/link-BodAbIQz.mjs +132 -0
- package/dist/{manifest-CcdWx7ud.mjs → manifest-TpfDWldB.mjs} +56 -6
- package/dist/{plugin-C5u07Yhv.mjs → plugin-DoXql0ZZ.mjs} +400 -48
- package/dist/{poster-BduzQBYz.mjs → poster-XBmUvQiL.mjs} +1 -1
- package/dist/{profile-BjAPAJSb.mjs → profile-CrZohD6g.mjs} +1 -1
- package/dist/{publish-bakes-b0jUwvM_.mjs → publish-bakes-KKTHWqq3.mjs} +2 -2
- package/dist/{share--bdSc4G5.mjs → share-BD-wcDQq.mjs} +1 -1
- package/dist/{shot-BAR8hmU9.mjs → shot-DOD8v6fJ.mjs} +2 -2
- package/dist/{shot-BFEuYbaz.mjs → shot-Dh6fV1Lm.mjs} +1 -1
- package/dist/{sync-BZaCWqK-.mjs → sync-DoA1vf4u.mjs} +15 -1
- package/dist/{work-0YopuMt9.mjs → work-ClFFq0Qh.mjs} +9 -3
- package/dist/{work-CLrmY-vQ.mjs → work-ayuL_9Kk.mjs} +72 -1
- package/docs/boards-and-folders.md +60 -7
- package/docs/context.md +10 -2
- package/docs/live-jam.md +11 -0
- package/docs/sticky-notes.md +1 -1
- package/package.json +1 -1
- package/src/client/content/diagram.tsx +7 -1
- package/src/client/content/img-lod.ts +12 -2
- package/src/client/content/index.tsx +73 -6
- package/src/client/content/md.ts +3 -2
- package/src/client/frame-host/inspect.js +23 -0
- package/src/client/shell/App.tsx +21 -10
- package/src/client/shell/BoardList.tsx +26 -6
- package/src/client/shell/LockedApp.tsx +2 -2
- package/src/client/shell/Play.tsx +5 -1
- package/src/client/shell/StatusPicker.tsx +12 -5
- package/src/client/shell/Tip.tsx +25 -5
- package/src/client/shell/board-icons.tsx +15 -1
- package/src/client/shell/canvas/Canvas.tsx +42 -6
- package/src/client/shell/canvas/anchor.ts +41 -0
- package/src/client/shell/canvas/ctl.ts +6 -0
- package/src/client/shell/comments-store.ts +8 -5
- package/src/client/shell/goto.ts +52 -3
- package/src/client/shell/hash.ts +24 -3
- package/src/client/shell/store.ts +261 -36
- package/src/client/shell/styles.css +20 -2
- package/src/client/shell/tidy.ts +34 -3
- package/src/shared/board-types.ts +10 -6
- package/src/shared/frames.ts +3 -0
- package/src/shared/status.ts +17 -8
- package/templates/AGENTS-embedded.md +43 -8
- package/templates/AGENTS-studio.md +43 -8
- package/templates/instructions/boards.md +13 -3
- package/templates/instructions/context.md +6 -2
- package/templates/instructions/iterate.md +29 -16
- package/templates/instructions/jam.md +9 -2
- package/templates/instructions/reference/deck-layouts.md +2 -1
- package/templates/instructions/reference/deck-story.md +2 -1
|
@@ -3,6 +3,7 @@ import { ROUTE, slideSize } from '../const.ts'
|
|
|
3
3
|
import { tidy, parseLayout, type BoardLayout, type TidyNode } from './tidy.ts'
|
|
4
4
|
import { clearNoteHeights, noteHeight, noteReserve, notesCramped, setNoteHeight } from './notes.ts'
|
|
5
5
|
import { stableNodeKey } from './keys.ts'
|
|
6
|
+
import { canvasCtl } from './canvas/ctl.ts'
|
|
6
7
|
// @ts-expect-error virtual module provided by the plugin
|
|
7
8
|
import shConfig from 'virtual:sh-config'
|
|
8
9
|
// @ts-expect-error virtual module: null in dev; a published build inlines manifest+boards
|
|
@@ -25,6 +26,8 @@ const DATA: {
|
|
|
25
26
|
policy?: { boards: Record<string, { type?: string; open?: string; lock?: boolean }>; reveal?: { structure?: boolean; source?: boolean }; lockedShell?: boolean }
|
|
26
27
|
/** the generation of the glass textures this build shipped (publish-bakes.ts); absent = none */
|
|
27
28
|
bakes?: number
|
|
29
|
+
/** content-frame heights, `scene/frame@width` -> px (design/boards/_sizes.json, published frames only) */
|
|
30
|
+
sizes?: Record<string, number>
|
|
28
31
|
} | null = shData
|
|
29
32
|
|
|
30
33
|
/** The published textures' generation, or 0: the static index this build shipped is at /__mv/bakes/<gen>/index.json. */
|
|
@@ -161,6 +164,8 @@ export interface BoardMeta {
|
|
|
161
164
|
status?: { status: Status; row?: number; fill?: Phase; reason?: string; evidence?: string[] }
|
|
162
165
|
/** what a person may set it to from the sidebar (dev only) - shared/board-types settableStatuses */
|
|
163
166
|
settable?: StatusWord[]
|
|
167
|
+
/** the board file is not valid JSON: the parser's words, line and column (#6) */
|
|
168
|
+
error?: string
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
/** The sidebar tree: root boards and folders in rank order, each folder's boards and
|
|
@@ -170,7 +175,7 @@ export interface BoardMeta {
|
|
|
170
175
|
export async function fetchBoardTree(): Promise<TreeSnapshot> {
|
|
171
176
|
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 ?? {} }
|
|
172
177
|
const [boards, reg] = await Promise.all([
|
|
173
|
-
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[] }[]>,
|
|
178
|
+
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 }[]>,
|
|
174
179
|
fetch(`${ROUTE}/api/folders`).then(async (r) => {
|
|
175
180
|
const j = await r.json() as { folders?: { name: string; order?: number; parent?: string; title?: string }[]; sha256?: string | null; error?: string }
|
|
176
181
|
if (!r.ok) throw new Error(j?.error ?? `folders ${r.status}`)
|
|
@@ -181,7 +186,7 @@ export async function fetchBoardTree(): Promise<TreeSnapshot> {
|
|
|
181
186
|
tree: buildTree(boards, reg.folders ?? []),
|
|
182
187
|
base: { boards: Object.fromEntries(boards.map((b) => [b.name, b.sha256])), folders: reg.sha256 ?? null },
|
|
183
188
|
titles: Object.fromEntries(boards.flatMap((b) => (b.title ? [[b.name, b.title]] : []))),
|
|
184
|
-
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 } : {}) }])),
|
|
189
|
+
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 } : {}) }])),
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
192
|
/** A tree read's types and statuses, kept under the same latest-wins rule as its titles. */
|
|
@@ -210,6 +215,11 @@ export const HAS_ALL_SCENES = !DATA || DATA.names.includes('all-scenes')
|
|
|
210
215
|
/** Display name for a board: its title when one is set (subscribe to `boardTitles` to
|
|
211
216
|
* re-render on change), else the Title-Cased slug ('all-scenes' reads "All Scenes"). */
|
|
212
217
|
export const boardLabel = (n: string) => labelOf(n, useStore.getState().boardTitles[n])
|
|
218
|
+
/** The canvas's name, as the sidebar heads it: the project's (share.name, else the repo folder). */
|
|
219
|
+
export const CANVAS_NAME = CONFIG.projectName ? humanize(CONFIG.projectName) : 'Marver'
|
|
220
|
+
/** The browser tab: the board, then the canvas - "Start here - Acme Studio" - so a row of canvas tabs
|
|
221
|
+
* says which project each one is (it said "- Marver" on all of them). */
|
|
222
|
+
export const tabTitle = (board: string | null | undefined): string => (board ? `${boardLabel(board)} - ${CANVAS_NAME}` : CANVAS_NAME)
|
|
213
223
|
/** Display name for a scene: the title in its brief's front matter, else the Title-Cased directory. */
|
|
214
224
|
export const sceneLabel = (n: string) => labelOf(n, useStore.getState().manifest?.scenes.find((s) => s.name === n)?.title)
|
|
215
225
|
|
|
@@ -276,34 +286,135 @@ const manifestKey = (m: Manifest) => JSON.stringify(m.frames) // any change co
|
|
|
276
286
|
let scenesRev = 0 // bumps per sh:scenes, so a load that straddled one keeps the live labels
|
|
277
287
|
let liveScenes: Manifest['scenes'] | null = null // the last sh:scenes payload - applied late when it beat the first manifest
|
|
278
288
|
|
|
279
|
-
/** Latest measured content heights, keyed frameId@width.
|
|
280
|
-
* auto sizes
|
|
289
|
+
/** Latest measured content heights, keyed frameId@width - this session's live truth. Board files
|
|
290
|
+
* never carry auto sizes; the committed cache below does. */
|
|
281
291
|
const measuredHeights = new Map<string, number>()
|
|
282
292
|
|
|
293
|
+
/** Committed content heights (design/boards/_sizes.json - src/server/sizes.ts), keyed frameId@width:
|
|
294
|
+
* a content frame's height BEFORE it measures, so a board opens at its final geometry instead of
|
|
295
|
+
* growing from a guess and re-flowing row after row. Read at every board load in dev (the API: an
|
|
296
|
+
* agent may have edited frames since), once from the bundle on a published canvas. A stale entry
|
|
297
|
+
* is still the best first guess - the live measurement corrects it, and the dev shell writes the
|
|
298
|
+
* correction back. */
|
|
299
|
+
const savedHeights = new Map<string, number>()
|
|
300
|
+
/** The frames that measure (render a Doc), as the dev server read their sources at the last load -
|
|
301
|
+
* only theirs is a height to trust: a Doc turned bare Md keeps the size its board gives it, even
|
|
302
|
+
* in a page that measured it as a Doc earlier. null = no such list (a published bundle ships only
|
|
303
|
+
* measuring frames' heights). */
|
|
304
|
+
let measuring: Set<string> | null = null
|
|
305
|
+
let publishedLoaded = false
|
|
306
|
+
async function loadSavedHeights(): Promise<void> {
|
|
307
|
+
if (DATA) {
|
|
308
|
+
if (publishedLoaded) return
|
|
309
|
+
publishedLoaded = true
|
|
310
|
+
for (const [k, v] of Object.entries(DATA.sizes ?? {})) if (typeof v === 'number' && Number.isFinite(v) && v > 0) savedHeights.set(k, Math.round(v))
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
const r = await fetch(`${ROUTE}/api/sizes`)
|
|
315
|
+
if (!r.ok) return
|
|
316
|
+
const body = (await r.json()) as { heights?: Record<string, unknown>; measuring?: unknown }
|
|
317
|
+
savedHeights.clear()
|
|
318
|
+
for (const [k, v] of Object.entries(body.heights ?? {})) if (typeof v === 'number' && Number.isFinite(v) && v > 0) savedHeights.set(k, Math.round(v))
|
|
319
|
+
measuring = Array.isArray(body.measuring) ? new Set(body.measuring.filter((x): x is string => typeof x === 'string')) : null
|
|
320
|
+
} catch { /* no cache: placeholders, as before */ }
|
|
321
|
+
}
|
|
322
|
+
const measures = (frameId: string) => !measuring || measuring.has(frameId)
|
|
323
|
+
|
|
324
|
+
// settled heights that differ from the committed ones, written back in batches (dev only). One
|
|
325
|
+
// write in flight at a time; a height that changes while its write is in flight queues behind it,
|
|
326
|
+
// so the LAST settled height is the one the file ends with
|
|
327
|
+
const pendingHeights = new Map<string, number>()
|
|
328
|
+
const inflightHeights = new Map<string, number>()
|
|
329
|
+
let heightsTimer: ReturnType<typeof setTimeout> | undefined
|
|
330
|
+
let flushing = false
|
|
331
|
+
const persistHeight = (key: string, h: number) => {
|
|
332
|
+
if (DATA) return
|
|
333
|
+
if (!inflightHeights.has(key) && savedHeights.get(key) === h) { pendingHeights.delete(key); return }
|
|
334
|
+
pendingHeights.set(key, h)
|
|
335
|
+
if (!flushing) heightsTimer ??= setTimeout(flushHeights, 1500) // a throttle, not a debounce: a board settling in waves still writes
|
|
336
|
+
}
|
|
337
|
+
async function flushHeights() {
|
|
338
|
+
heightsTimer = undefined
|
|
339
|
+
if (flushing || !pendingHeights.size) return
|
|
340
|
+
flushing = true
|
|
341
|
+
const batch = Object.fromEntries([...pendingHeights].slice(0, 500))
|
|
342
|
+
for (const [k, v] of Object.entries(batch)) { pendingHeights.delete(k); inflightHeights.set(k, v) }
|
|
343
|
+
let answered = false
|
|
344
|
+
try {
|
|
345
|
+
const r = await postOwner('sizes', { heights: batch })
|
|
346
|
+
if (r.ok) {
|
|
347
|
+
const accepted = new Set(((await r.json()) as { accepted?: string[] }).accepted ?? [])
|
|
348
|
+
for (const k of Object.keys(batch)) if (accepted.has(k)) savedHeights.set(k, batch[k])
|
|
349
|
+
answered = true
|
|
350
|
+
}
|
|
351
|
+
} catch { /* lost: below */ }
|
|
352
|
+
// no answer = the write may or may not have landed: what the file holds is unknown, so nothing is
|
|
353
|
+
// deduplicated against it - a correction queued meanwhile still goes, the next report still writes
|
|
354
|
+
if (!answered) for (const k of Object.keys(batch)) savedHeights.delete(k)
|
|
355
|
+
for (const k of Object.keys(batch)) inflightHeights.delete(k)
|
|
356
|
+
// a height that settled while the write was in flight: still owed only if it differs from what landed
|
|
357
|
+
for (const [k, v] of pendingHeights) if (savedHeights.get(k) === v) pendingHeights.delete(k)
|
|
358
|
+
flushing = false
|
|
359
|
+
if (pendingHeights.size) heightsTimer ??= setTimeout(flushHeights, 1500)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const hasKnownHeight = (frameId: string, w: number) => measures(frameId) && (measuredHeights.has(`${frameId}@${w}`) || savedHeights.has(`${frameId}@${w}`))
|
|
363
|
+
|
|
364
|
+
/** The Doc sizes a layout was computed around: each auto content node whose height is known, by key,
|
|
365
|
+
* as "WxH" (one line per node in the board file). A composed board saves it with its positions
|
|
366
|
+
* (`laidOut`); a load where a node it names now has another size knows its rows were laid out
|
|
367
|
+
* around other sizes - grown, shrunk, or gone from document to wide. A drag changes no size, and a
|
|
368
|
+
* node added or removed is no size change of the others. */
|
|
369
|
+
export type LaidOut = Record<string, string>
|
|
370
|
+
const sizeOf = (n: Node) => `${Math.round(n.w)}x${Math.round(n.h)}`
|
|
371
|
+
function sizeRecord(nodes: readonly Node[]): LaidOut {
|
|
372
|
+
const out: LaidOut = {}
|
|
373
|
+
for (const n of nodes) if (n.sizeMode === 'auto' && hasKnownHeight(n.frame, Math.round(n.w))) out[n.key] = sizeOf(n)
|
|
374
|
+
return out
|
|
375
|
+
}
|
|
376
|
+
const readLaidOut = (v: unknown): LaidOut | null => {
|
|
377
|
+
if (!v || typeof v !== 'object' || Array.isArray(v)) return null
|
|
378
|
+
const out: LaidOut = {}
|
|
379
|
+
for (const [k, wh] of Object.entries(v)) if (typeof wh === 'string' && /^\d+x\d+$/.test(wh)) out[k] = wh
|
|
380
|
+
return out
|
|
381
|
+
}
|
|
382
|
+
|
|
283
383
|
function defaultSize(frame: FrameEntry) {
|
|
284
384
|
// the precedence chain (spec 09 slice 1): slide stage → authored
|
|
285
385
|
// viewport → content sizing → default (one helper, shared with shot) -
|
|
286
386
|
// a slide's stage is its declared viewport, else 1280×720
|
|
287
387
|
const sl = slideSize(frame, CONFIG.viewports)
|
|
288
388
|
if (sl) return { w: sl.width, h: sl.height }
|
|
289
|
-
// content frames: own width from Doc layout
|
|
290
|
-
// measurement at that width,
|
|
291
|
-
//
|
|
292
|
-
if (frame.contentWidth
|
|
293
|
-
const
|
|
294
|
-
|
|
389
|
+
// content frames: own width from Doc layout (meta.viewport, when declared, wins - the existing
|
|
390
|
+
// precedence); height from this session's measurement at that width, else the committed one,
|
|
391
|
+
// else a placeholder until sh:measure lands
|
|
392
|
+
if (frame.contentWidth) {
|
|
393
|
+
const vp = CONFIG.viewports[frame.viewport ?? '']
|
|
394
|
+
const w = vp?.width ?? frame.contentWidth
|
|
395
|
+
const key = `${frame.id}@${w}`
|
|
396
|
+
const known = measures(frame.id) ? measuredHeights.get(key) ?? savedHeights.get(key) : undefined
|
|
397
|
+
return { w, h: known ?? vp?.height ?? Math.round(w * 0.75) }
|
|
295
398
|
}
|
|
296
399
|
const vp = CONFIG.viewports[frame.viewport ?? ''] ?? CONFIG.viewports.mobile ?? { width: 390, height: 844 }
|
|
297
400
|
return { w: vp.width, h: vp.height }
|
|
298
401
|
}
|
|
299
402
|
|
|
300
403
|
let resizedInGesture = false
|
|
404
|
+
/** Why a board's last load failed, from the server (a parse error names its line) - for its toast. */
|
|
405
|
+
const loadErrors = new Map<string, string>()
|
|
406
|
+
const whyNot = (name: string) => { const e = loadErrors.get(name); return e ? ` - ${e}` : '' }
|
|
301
407
|
|
|
302
408
|
/** sceneRows is the legacy shorthand for a plain rows layout. */
|
|
303
409
|
const effectiveLayout = (layout: BoardLayout | null, sceneRows: string[][] | null): BoardLayout | undefined =>
|
|
304
410
|
layout ?? (sceneRows?.length ? { rows: sceneRows.map((r) => [...r]) } : undefined)
|
|
305
411
|
|
|
412
|
+
/** Every scene of the project, empty phase scenes included - a layout naming one is no typo (#18).
|
|
413
|
+
* A published bundle carries the empty scenes its recipes name, so it lays out as dev does. */
|
|
414
|
+
const knownScenes = (m: Manifest | null): ReadonlySet<string> => new Set(m?.scenes.map((s) => s.name))
|
|
415
|
+
|
|
306
416
|
const layoutWarn = (msg: string) => {
|
|
417
|
+
if (PUBLISHED) return // a viewer cannot fix a recipe - the owner sees it in dev (#18: empty phase scenes)
|
|
307
418
|
console.warn('[marver layout]', msg)
|
|
308
419
|
try { useStore.getState().toast(`layout: ${msg}`) } catch { /* store not ready during boot */ }
|
|
309
420
|
}
|
|
@@ -329,6 +440,8 @@ interface State {
|
|
|
329
440
|
layout: BoardLayout | null // lane-flow recipe, parsed; wins over sceneRows when both exist
|
|
330
441
|
layoutRaw: unknown // the author's layout VERBATIM - save round-trips this, never the parse
|
|
331
442
|
baseLayout: Record<string, { x: number; y: number; w?: number; h?: number }> | null // snapshot taken on entering a device view; Default restores it exactly (auto content entries carry positions only - their sizes are measured)
|
|
443
|
+
laidOut: LaidOut | null // a composed board's record of the Doc heights its positions were laid out around (sizeRecord)
|
|
444
|
+
baseLaidOut: LaidOut | null // the free-form layout's laidOut, kept with baseLayout while a device view is up; Default restores both
|
|
332
445
|
panelOpen: boolean
|
|
333
446
|
scale: number
|
|
334
447
|
toasts: Toast[]
|
|
@@ -353,7 +466,9 @@ interface State {
|
|
|
353
466
|
frameFor(node: Node): FrameEntry | undefined
|
|
354
467
|
moveNode(key: string, x: number, y: number): void
|
|
355
468
|
resizeNode(key: string, w: number, h: number): void
|
|
356
|
-
|
|
469
|
+
/** `settled`: the Doc's fonts, images and diagrams are done (content/index.tsx). false = provisional
|
|
470
|
+
* (an image still loading) - it may grow a frame, never shrink it under a known height. */
|
|
471
|
+
measureNode(key: string, frameId: string, ownWidth: number, measuredWidth: number, height: number, settled?: boolean): void
|
|
357
472
|
/** A node's sticky column was drawn (or grew, or went): its extent from the node's top, world px. */
|
|
358
473
|
noteMeasured(key: string, height: number): void
|
|
359
474
|
setStatus(key: string, status: Node['status'], error?: string): void
|
|
@@ -409,7 +524,15 @@ interface State {
|
|
|
409
524
|
/** When each working frame's job started (ms epoch) - phases the animations so parallel
|
|
410
525
|
* frames never pulse in sync. */
|
|
411
526
|
workingSince: Record<string, number>
|
|
412
|
-
setWorking(frames: string[]): void
|
|
527
|
+
setWorking(frames: string[], boards?: string[]): void
|
|
528
|
+
/** setWorking from a wire payload (`{ frames, boards }`), strings only. */
|
|
529
|
+
setWorkingFrom(m: unknown): void
|
|
530
|
+
/** Fetch what is lit now (dev only) - the snapshot behind the broadcasts. */
|
|
531
|
+
syncWorking(): Promise<void>
|
|
532
|
+
/** Boards showing a working frame - their sidebar icon shimmers while an agent works. */
|
|
533
|
+
workingBoards: string[]
|
|
534
|
+
/** The place in the server's order of the activity last applied - an older answer is dropped. */
|
|
535
|
+
workingSeq: number
|
|
413
536
|
spawn(frameId: string): Node | null
|
|
414
537
|
save(): Promise<boolean>
|
|
415
538
|
}
|
|
@@ -447,12 +570,19 @@ export const useStore = create<State>((set, get) => {
|
|
|
447
570
|
// The captured board name is the generation guard - a debounce surviving a board
|
|
448
571
|
// switch fires into a name check and dies, never touching the new board.
|
|
449
572
|
// `onlyIf` (a note asking for room) is re-judged when the timer fires - a drag or a restore
|
|
450
|
-
// in the meantime may have settled it - and never downgrades an unconditional reflow pending
|
|
573
|
+
// in the meantime may have settled it - and never downgrades an unconditional reflow pending;
|
|
574
|
+
// two conditions pending are EITHER one (a later ask never drops an earlier one).
|
|
451
575
|
let reflowTimer: ReturnType<typeof setTimeout> | undefined
|
|
452
576
|
let reflowCheck: (() => boolean) | null = null
|
|
453
|
-
|
|
577
|
+
/** A board load (boot, switch) starts its own reflow story: whatever was pending - an
|
|
578
|
+
* unconditional reflow from the board that was up - must never carry over and tidy this one. */
|
|
579
|
+
const cancelReflow = () => { clearTimeout(reflowTimer); reflowTimer = undefined; reflowCheck = null }
|
|
580
|
+
/** How long a content reflow waits for a camera in flight - past it, the rows move anyway. */
|
|
581
|
+
const REFLOW_CAMERA_WAIT = 1500
|
|
582
|
+
const scheduleReflow = (onlyIf?: () => boolean, delay = 400, cameraSince?: number) => {
|
|
454
583
|
const boardAt = get().board
|
|
455
|
-
|
|
584
|
+
const prev = reflowTimer !== undefined ? reflowCheck : undefined // undefined: nothing pending
|
|
585
|
+
reflowCheck = prev === null || !onlyIf ? null : prev ? () => prev() || onlyIf() : onlyIf
|
|
456
586
|
clearTimeout(reflowTimer)
|
|
457
587
|
reflowTimer = setTimeout(() => {
|
|
458
588
|
reflowTimer = undefined
|
|
@@ -460,10 +590,18 @@ export const useStore = create<State>((set, get) => {
|
|
|
460
590
|
reflowCheck = null
|
|
461
591
|
const s = get()
|
|
462
592
|
if (s.board !== boardAt) return
|
|
463
|
-
|
|
593
|
+
// defer, never drop - retries after the drag
|
|
594
|
+
if (s.gesture) { scheduleReflow(check ?? undefined); return }
|
|
595
|
+
// and after a camera flight: a link's fit lands first, then the rows move around the frames it
|
|
596
|
+
// showed (holdView keeps them where the fit put them). Looked at often, so the reflow follows the
|
|
597
|
+
// landing closely - and never waited on past REFLOW_CAMERA_WAIT: a camera that keeps moving (fit
|
|
598
|
+
// after fit) does not hold the rows apart forever
|
|
599
|
+
const since = cameraSince ?? Date.now()
|
|
600
|
+
if (canvasCtl.cameraBusy() && Date.now() - since < REFLOW_CAMERA_WAIT) { scheduleReflow(check ?? undefined, 60, since); return }
|
|
464
601
|
if (check && !check()) return
|
|
465
|
-
|
|
466
|
-
|
|
602
|
+
// content moved the rows, not the human: hold what they are looking at still (Canvas.tsx)
|
|
603
|
+
if (composed(s)) { canvasCtl.holdView(); s.runTidy() }
|
|
604
|
+
}, delay)
|
|
467
605
|
}
|
|
468
606
|
/** Boards whose layout the shell owns: a recipe, scene rows, or the auto board. Room for a
|
|
469
607
|
* note is made here; a board the human placed by hand is never moved (spec 18, 0.19.1). */
|
|
@@ -472,6 +610,32 @@ export const useStore = create<State>((set, get) => {
|
|
|
472
610
|
/** A note may have landed with no room (a frame note via the manifest, a scene note via
|
|
473
611
|
* sh:scenes, either merged late by boot/switch): a composed board re-applies its layout. */
|
|
474
612
|
const roomForNotes = () => { if (composed(get()) && cramped()) scheduleReflow(cramped) }
|
|
613
|
+
/** A composed board's saved positions were laid out around the heights of the session that saved
|
|
614
|
+
* them. A committed height that changed since (the doc grew or shrank while another board was
|
|
615
|
+
* open) opens at its new size over - or far above - the row below, and no measurement will re-flow
|
|
616
|
+
* it: it already equals the committed one. So once the board is up, the recipe re-runs if the
|
|
617
|
+
* known heights differ from the ones its positions were laid out around (`laidOut`). A frame the
|
|
618
|
+
* human dragged, at heights that did not change, stays where they put it. */
|
|
619
|
+
const layoutStale = () => {
|
|
620
|
+
const { nodes, laidOut } = get()
|
|
621
|
+
const record = laidOut ?? {}
|
|
622
|
+
const known = (n: Node) => n.sizeMode === 'auto' && hasKnownHeight(n.frame, Math.round(n.w))
|
|
623
|
+
const has = (n: Node) => Object.prototype.hasOwnProperty.call(record, n.key)
|
|
624
|
+
// a node the layout recorded, at another size now
|
|
625
|
+
if (nodes.some((n) => known(n) && has(n) && sizeOf(n) !== record[n.key])) return true
|
|
626
|
+
// a node it never recorded (an agent's board, an older save, a Doc that had not measured yet):
|
|
627
|
+
// an overlap is the one thing a size change does that a hand never meant
|
|
628
|
+
const box = (n: Node) => ({ l: n.x, t: n.y, r: n.x + n.w, b: n.y + n.h + HEADER })
|
|
629
|
+
return nodes.some((a) => {
|
|
630
|
+
if (!known(a) || has(a)) return false
|
|
631
|
+
const A = box(a)
|
|
632
|
+
return nodes.some((b) => { if (b === a) return false; const B = box(b); return A.l < B.r - 1 && B.l < A.r - 1 && A.t < B.b - 1 && B.t < A.b - 1 })
|
|
633
|
+
})
|
|
634
|
+
}
|
|
635
|
+
const recheckLayout = () => {
|
|
636
|
+
const s = get()
|
|
637
|
+
if (composed(s) && s.nodes.some((n) => n.sizeMode === 'auto' && hasKnownHeight(n.frame, Math.round(n.w)))) scheduleReflow(layoutStale)
|
|
638
|
+
}
|
|
475
639
|
|
|
476
640
|
/** Theme resolution ladder: user pin > the frame's declared meta.theme > viewTheme. */
|
|
477
641
|
const resolveTheme = (frame?: FrameEntry, user?: string) => user ?? frame?.theme ?? get().viewTheme
|
|
@@ -519,14 +683,17 @@ export const useStore = create<State>((set, get) => {
|
|
|
519
683
|
* keeps whatever board is currently mounted. */
|
|
520
684
|
const loadBoardState = async (boardName: string): Promise<Partial<State> | null> => {
|
|
521
685
|
clearNoteHeights() // heights are per column drawn; a key shared by two board files carries none across
|
|
686
|
+
loadErrors.delete(boardName)
|
|
522
687
|
try {
|
|
523
688
|
let raw: any
|
|
689
|
+
const saved = loadSavedHeights() // in parallel with the manifest; every size below reads it
|
|
524
690
|
if (DATA) raw = DATA.manifest
|
|
525
691
|
else {
|
|
526
692
|
const mRes = await fetch('/design/manifest.json')
|
|
527
693
|
if (!mRes.ok) return null
|
|
528
694
|
raw = await mRes.json().catch(() => undefined)
|
|
529
695
|
}
|
|
696
|
+
await saved
|
|
530
697
|
if (raw === undefined || raw === null || typeof raw !== 'object') return null
|
|
531
698
|
bumpManifestRev() // fresh manifest → fresh iframe URLs
|
|
532
699
|
const manifest: Manifest = {
|
|
@@ -542,6 +709,8 @@ export const useStore = create<State>((set, get) => {
|
|
|
542
709
|
let layout: BoardLayout | null = null
|
|
543
710
|
let layoutRaw: unknown = undefined
|
|
544
711
|
let baseLayout: State['baseLayout'] = null
|
|
712
|
+
let laidOut: LaidOut | null = null
|
|
713
|
+
let baseLaidOut: LaidOut | null = null
|
|
545
714
|
let needTidy = false
|
|
546
715
|
// published build: boards come from the inlined data; absent = fresh (the 404 path)
|
|
547
716
|
let loaded: { board: any; sha256: string } | 'fresh' | null
|
|
@@ -553,7 +722,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
553
722
|
loaded = body?.board == null ? 'fresh' : body // board:null = not materialized yet
|
|
554
723
|
}
|
|
555
724
|
else if (res.status === 404) loaded = 'fresh' // older servers still 404 fresh boards
|
|
556
|
-
else loaded = null
|
|
725
|
+
else { loadErrors.set(boardName, (await res.json().catch(() => null))?.error ?? ''); loaded = null } // anything else must not commit an empty canvas - and says why (#6)
|
|
557
726
|
}
|
|
558
727
|
if (loaded === null) return null
|
|
559
728
|
if (loaded !== 'fresh') {
|
|
@@ -585,11 +754,16 @@ export const useStore = create<State>((set, get) => {
|
|
|
585
754
|
const sizeMode = f?.contentWidth
|
|
586
755
|
? { sizeMode: (n.sizeMode === 'manual' || n.sizeMode === 'device' ? n.sizeMode : 'auto') as Node['sizeMode'] }
|
|
587
756
|
: {}
|
|
757
|
+
// an AUTO content node whose height is KNOWN (measured, or committed - sizes.ts) opens at
|
|
758
|
+
// it: a w/h in the file is a guess (an agent wrote the node) or a pre-auto leftover the
|
|
759
|
+
// first measurement overrides anyway - opening at it only to jump is the swim. Unknown
|
|
760
|
+
// (a frame that never measures: no Doc) keeps the file's size, as before
|
|
761
|
+
const own = sizeMode.sizeMode === 'auto' && !!f && hasKnownHeight(f.id, d.w)
|
|
588
762
|
return {
|
|
589
763
|
key,
|
|
590
764
|
frame: n.frame,
|
|
591
765
|
x: typeof n.x === 'number' ? n.x : 0, y: typeof n.y === 'number' ? n.y : 0,
|
|
592
|
-
w: typeof n.w === 'number' ? n.w : d.w, h: typeof n.h === 'number' ? n.h : d.h,
|
|
766
|
+
w: !own && typeof n.w === 'number' ? n.w : d.w, h: !own && typeof n.h === 'number' ? n.h : d.h,
|
|
593
767
|
...(!f && typeof n.w !== 'number' && typeof n.h !== 'number' ? { sizeFallback: true } : {}),
|
|
594
768
|
...sizeMode,
|
|
595
769
|
// pins persist as their own field (exact round-trip). Legacy boards stored a
|
|
@@ -619,6 +793,8 @@ export const useStore = create<State>((set, get) => {
|
|
|
619
793
|
layout = parseLayout(board?.layout, layoutWarn)
|
|
620
794
|
if (layout && sceneRows) layoutWarn('board has layout AND sceneRows - layout wins')
|
|
621
795
|
if (board?.baseLayout && typeof board.baseLayout === 'object') baseLayout = board.baseLayout
|
|
796
|
+
laidOut = readLaidOut(board?.laidOut)
|
|
797
|
+
baseLaidOut = readLaidOut(board?.baseLaidOut)
|
|
622
798
|
}
|
|
623
799
|
// auto-managed goes both ways (friction log #15): an auto board gains new frames
|
|
624
800
|
// AND sheds deleted ones. Tombstone cards are a curated-board concept.
|
|
@@ -683,8 +859,9 @@ export const useStore = create<State>((set, get) => {
|
|
|
683
859
|
// a board with a recipe re-applies it (spec 18 - room is the layout's job)
|
|
684
860
|
const cramped = !!boardHash && !needTidy && !!(layout || sceneRows?.length || boardAuto) && notesCramped(nodes, manifest)
|
|
685
861
|
if ((!boardHash || needTidy || cramped) && nodes.length) {
|
|
686
|
-
const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn)
|
|
862
|
+
const placedAll = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
|
|
687
863
|
for (const pl of placedAll) { const n = nodes.find((x) => x.key === pl.key)!; n.x = pl.x; n.y = pl.y }
|
|
864
|
+
laidOut = sizeRecord(nodes)
|
|
688
865
|
}
|
|
689
866
|
// dirty matches disk by construction - except when load-time pruning changed the
|
|
690
867
|
// node set (or a cramped note re-ran the recipe); callers see dirty:true and
|
|
@@ -692,16 +869,16 @@ export const useStore = create<State>((set, get) => {
|
|
|
692
869
|
// surface recipe problems at load (dry-run): materialized boards otherwise
|
|
693
870
|
// never run tidy, so a broken agent-authored layout would fail silently
|
|
694
871
|
if (layout && boardHash && !needTidy && !cramped && nodes.length) {
|
|
695
|
-
tidy(tidyInput(nodes, manifest), layout, layoutWarn)
|
|
872
|
+
tidy(tidyInput(nodes, manifest), layout, layoutWarn, knownScenes(manifest))
|
|
696
873
|
}
|
|
697
|
-
return { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, selection: [], dirty: prunedAtLoad || cramped }
|
|
874
|
+
return { manifest, nodes, boardHash, boardAuto, deviceView, sceneRows, layout, layoutRaw, baseLayout, laidOut, baseLaidOut, selection: [], dirty: prunedAtLoad || cramped }
|
|
698
875
|
} catch { return null }
|
|
699
876
|
}
|
|
700
877
|
|
|
701
878
|
return {
|
|
702
879
|
manifest: null, nodes: [], selection: [], interact: null, viewTheme: initialViewTheme(), play: null, gesture: false, laser: false,
|
|
703
|
-
board: DATA?.default ?? 'all-scenes', boardAuto: (DATA?.default ?? 'all-scenes') === 'all-scenes', deviceView: null, sceneRows: null, layout: null, layoutRaw: undefined, baseLayout: null,
|
|
704
|
-
panelOpen: true, scale: 1, toasts: [], working: [], workingSince: {}, boardHash: null, dirty: false, boardTitles: DATA?.titles ?? {}, boardMeta: DATA?.meta ?? {},
|
|
880
|
+
board: DATA?.default ?? 'all-scenes', boardAuto: (DATA?.default ?? 'all-scenes') === 'all-scenes', deviceView: null, sceneRows: null, layout: null, layoutRaw: undefined, baseLayout: null, laidOut: null, baseLaidOut: null,
|
|
881
|
+
panelOpen: true, scale: 1, toasts: [], working: [], workingSince: {}, workingBoards: [], workingSeq: -1, boardHash: null, dirty: false, boardTitles: DATA?.titles ?? {}, boardMeta: DATA?.meta ?? {},
|
|
705
882
|
pendingFrameRevisions: {}, externalLeases: {}, playUpdateRevision: null, playNav: 0, pathPulse: 0, imagePulse: 0, imageBusy: false,
|
|
706
883
|
|
|
707
884
|
async boot(mayCommit) {
|
|
@@ -710,15 +887,17 @@ export const useStore = create<State>((set, get) => {
|
|
|
710
887
|
const revAtStart = editRev, scenesAtStart = scenesRev
|
|
711
888
|
const next = await loadBoardState(boardName)
|
|
712
889
|
if (seq !== loadSeq) return false // a newer load superseded this one
|
|
713
|
-
if (!next) { get().toast(`board "${boardName}" failed to load`); return false }
|
|
890
|
+
if (!next) { get().toast(`board "${boardName}" failed to load${whyNot(boardName)}`); return false }
|
|
714
891
|
// the user kept editing while we fetched - their newer state wins over the reload
|
|
715
892
|
if (get().board !== boardName || editRev !== revAtStart || (mayCommit && !mayCommit())) return false
|
|
716
893
|
const live = get().manifest // a WS manifest update may have landed mid-fetch
|
|
717
894
|
set(next)
|
|
895
|
+
cancelReflow()
|
|
718
896
|
if (next.dirty) scheduleSave() // load-time prune must reach the disk
|
|
719
897
|
if (live && manifestKey(live) !== manifestKey(next.manifest as Manifest)) get().applyManifest(live)
|
|
720
898
|
else if (scenesRev !== scenesAtStart && liveScenes) set({ manifest: { ...get().manifest!, scenes: liveScenes } }) // an sh:scenes that landed mid-fetch outranks the file we read
|
|
721
899
|
roomForNotes() // whichever way the notes arrived, they get their room
|
|
900
|
+
recheckLayout() // and a height committed since the board was laid out, its rows
|
|
722
901
|
return true
|
|
723
902
|
},
|
|
724
903
|
|
|
@@ -741,7 +920,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
741
920
|
// there is never an empty intermediate state and nothing to roll back
|
|
742
921
|
const next = await loadBoardState(name)
|
|
743
922
|
if (mySwitch !== switchSeq) return
|
|
744
|
-
if (!next) { get().toast(`could not load "${name}" - staying on ${get().board}`); return }
|
|
923
|
+
if (!next) { get().toast(`could not load "${name}"${whyNot(name)} - staying on ${get().board}`); return }
|
|
745
924
|
// edits may have landed on the still-mounted old board during the target load
|
|
746
925
|
for (let i = 0; i < 5 && get().dirty && ok; i++) { clearTimeout(saveTimer); ok = await get().save() }
|
|
747
926
|
if (mySwitch !== switchSeq) return
|
|
@@ -750,10 +929,12 @@ export const useStore = create<State>((set, get) => {
|
|
|
750
929
|
++loadSeq // invalidate any in-flight boot of the old board
|
|
751
930
|
const live = get().manifest // a WS manifest update may have landed mid-load
|
|
752
931
|
set({ board: name, interact: null, ...next })
|
|
932
|
+
cancelReflow()
|
|
753
933
|
if (next.dirty) scheduleSave() // load-time prune must reach the disk
|
|
754
934
|
if (live && manifestKey(live) !== manifestKey(next.manifest as Manifest)) get().applyManifest(live)
|
|
755
935
|
else if (scenesRev !== scenesAtStart && liveScenes) set({ manifest: { ...get().manifest!, scenes: liveScenes } })
|
|
756
936
|
roomForNotes()
|
|
937
|
+
recheckLayout()
|
|
757
938
|
},
|
|
758
939
|
|
|
759
940
|
renameBoard(name, title, baseHash) {
|
|
@@ -828,8 +1009,11 @@ export const useStore = create<State>((set, get) => {
|
|
|
828
1009
|
if (status) {
|
|
829
1010
|
const meta = { ...get().boardMeta }
|
|
830
1011
|
const cur = meta[name] ?? {}
|
|
831
|
-
const row = ({ archived: 1, paused: 2, blocked: 3, 'in-progress': 5, done: 6, todo: 8, backlog: 9 } as const)[status]
|
|
832
|
-
|
|
1012
|
+
const row = ({ archived: 1, paused: 2, blocked: 3, 'in-progress': 5, building: 5, done: 6, todo: 8, backlog: 9 } as const)[status]
|
|
1013
|
+
// with context/, In progress and Building were written into the open plan, not the board
|
|
1014
|
+
const inPlan = (status === 'building' || status === 'in-progress') && !(cur.settable ?? []).includes('todo')
|
|
1015
|
+
const evidence = inPlan ? ['context/plans/: stage written from the sidebar'] : [`design/boards/${name}.json: "status": "${status}"`]
|
|
1016
|
+
meta[name] = { ...cur, status: { status, row, ...(status === 'blocked' && reason ? { reason } : {}), evidence } }
|
|
833
1017
|
set({ boardMeta: meta })
|
|
834
1018
|
}
|
|
835
1019
|
return { ok: true }
|
|
@@ -1040,7 +1224,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
1040
1224
|
* clamped. A height only commits when it was measured at the width being applied;
|
|
1041
1225
|
* auto sizes are transient - applying one never dirties the board (positions from
|
|
1042
1226
|
* the follow-up reflow do, exactly like a human resize). */
|
|
1043
|
-
measureNode(key, frameId, ownWidth, measuredWidth, height) {
|
|
1227
|
+
measureNode(key, frameId, ownWidth, measuredWidth, height, settled) {
|
|
1044
1228
|
const s = get()
|
|
1045
1229
|
const node = s.nodes.find((n) => n.key === key)
|
|
1046
1230
|
// Only an explicit DEVICE viewport locks a content frame's height. 'auto' and 'manual' both
|
|
@@ -1053,13 +1237,22 @@ export const useStore = create<State>((set, get) => {
|
|
|
1053
1237
|
const f = s.manifest?.frames.find((x) => x.id === node.frame)
|
|
1054
1238
|
if (!f?.contentWidth) return // not a content frame - spoof-proofing
|
|
1055
1239
|
if (![ownWidth, measuredWidth, height].every((v) => Number.isFinite(v) && v > 0)) return
|
|
1240
|
+
// a Doc that reports IS one, whatever the last load's scan said (it arrived since): its heights
|
|
1241
|
+
// count until the next load re-reads the sources
|
|
1242
|
+
measuring?.add(f.id)
|
|
1056
1243
|
// Generous cap: a reference doc with many screenshots is legitimately very tall and must fit in
|
|
1057
1244
|
// FULL (this was 2.5x a viewport ~= 2700px, which clipped image-heavy docs). Still bounded so a
|
|
1058
1245
|
// broken measurement can't mint an infinite frame.
|
|
1059
1246
|
const maxH = 40000
|
|
1060
1247
|
const H = Math.min(maxH, Math.max(80, Math.round(height)))
|
|
1061
1248
|
const curW = Math.round(node.w)
|
|
1062
|
-
|
|
1249
|
+
const mKey = `${node.frame}@${Math.round(measuredWidth)}`
|
|
1250
|
+
// a PROVISIONAL height (an image off-screen still lazy-loading) may grow a frame but never
|
|
1251
|
+
// shrink it under a height already known for this width: that one is what the finished doc
|
|
1252
|
+
// measures, and shrinking now would only grow back when the image lands - the swim again
|
|
1253
|
+
const known = measuredHeights.get(mKey) ?? savedHeights.get(mKey)
|
|
1254
|
+
if (settled === false && known !== undefined && H < known) return
|
|
1255
|
+
measuredHeights.set(mKey, H)
|
|
1063
1256
|
// AUTO owns the width too - adopt the Doc's declared/own width. MANUAL keeps the human's width
|
|
1064
1257
|
// and only fits the height.
|
|
1065
1258
|
if (node.sizeMode !== 'manual') {
|
|
@@ -1075,6 +1268,9 @@ export const useStore = create<State>((set, get) => {
|
|
|
1075
1268
|
}
|
|
1076
1269
|
}
|
|
1077
1270
|
if (Math.round(measuredWidth) !== curW) return // height only true at the width it was measured at
|
|
1271
|
+
// a settled height at the frame's OWN width is the one the next load should open at (sizes.ts);
|
|
1272
|
+
// a human-owned width is the board file's business (manual sizes save there)
|
|
1273
|
+
if (settled === true && node.sizeMode !== 'manual') persistHeight(mKey, H)
|
|
1078
1274
|
if (Math.round(node.h) === H) return
|
|
1079
1275
|
set((st) => ({ nodes: st.nodes.map((n) => (n.key === key ? { ...n, h: H } : n)) }))
|
|
1080
1276
|
scheduleReflow()
|
|
@@ -1111,10 +1307,15 @@ export const useStore = create<State>((set, get) => {
|
|
|
1111
1307
|
const d = defaultSize(f) // frames added mid-device-view get their default
|
|
1112
1308
|
return { ...n, w: d.w, h: d.h }
|
|
1113
1309
|
})
|
|
1114
|
-
|
|
1310
|
+
// the snapshot's positions were laid out around the free-form heights: its laidOut goes and
|
|
1311
|
+
// comes back with it (null = not known - the next load falls back to the overlap check)
|
|
1312
|
+
const laid = name
|
|
1313
|
+
? { baseLaidOut: s.deviceView === null ? s.laidOut : s.baseLaidOut }
|
|
1314
|
+
: s.baseLayout ? { laidOut: s.baseLaidOut, baseLaidOut: null } : { baseLaidOut: null }
|
|
1315
|
+
return { deviceView: name, dirty: true, baseLayout, nodes, ...laid }
|
|
1115
1316
|
})
|
|
1116
1317
|
if (name) get().runTidy() // restore must NOT tidy - it would destroy positions
|
|
1117
|
-
else { scheduleSave(); roomForNotes() }
|
|
1318
|
+
else { scheduleSave(); roomForNotes(); recheckLayout() } // ...unless a note grew meanwhile, or a Doc changed size, under the restored rows
|
|
1118
1319
|
},
|
|
1119
1320
|
bumpRev(key) { set((s) => ({ nodes: s.nodes.map((n) => (n.key === key ? { ...n, rev: (n.rev ?? 0) + 1 } : n)) })) },
|
|
1120
1321
|
setThemeOn(key, theme) { set((s) => ({ nodes: s.nodes.map((n) => (n.key === key ? { ...n, themeOn: theme } : n)) })) },
|
|
@@ -1322,12 +1523,13 @@ export const useStore = create<State>((set, get) => {
|
|
|
1322
1523
|
},
|
|
1323
1524
|
runTidy() {
|
|
1324
1525
|
const { nodes, manifest, sceneRows, layout } = get()
|
|
1325
|
-
const placed = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn)
|
|
1526
|
+
const placed = tidy(tidyInput(nodes, manifest), effectiveLayout(layout, sceneRows), layoutWarn, knownScenes(manifest))
|
|
1326
1527
|
set((s) => ({
|
|
1327
1528
|
nodes: s.nodes.map((n) => {
|
|
1328
1529
|
const p = placed.find((x) => x.key === n.key)
|
|
1329
1530
|
return p ? { ...n, x: p.x, y: p.y } : n
|
|
1330
1531
|
}),
|
|
1532
|
+
laidOut: sizeRecord(nodes),
|
|
1331
1533
|
dirty: true,
|
|
1332
1534
|
}))
|
|
1333
1535
|
scheduleSave()
|
|
@@ -1346,13 +1548,34 @@ export const useStore = create<State>((set, get) => {
|
|
|
1346
1548
|
},
|
|
1347
1549
|
dismissToast(id) { set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })) },
|
|
1348
1550
|
clearJamToasts() { set((s) => ({ toasts: s.toasts.filter((t) => !t.jam) })) },
|
|
1349
|
-
|
|
1551
|
+
setWorkingFrom(m) {
|
|
1552
|
+
const strings = (v: unknown) => (Array.isArray(v) ? v.filter((x: unknown): x is string => typeof x === 'string') : [])
|
|
1553
|
+
const o = (m && typeof m === 'object' ? m : {}) as { frames?: unknown; boards?: unknown; seq?: unknown }
|
|
1554
|
+
// a snapshot that left before a newer broadcast arrived is the past: it never undoes it
|
|
1555
|
+
const seq = typeof o.seq === 'number' && Number.isFinite(o.seq) ? o.seq : undefined
|
|
1556
|
+
if (seq !== undefined && seq < get().workingSeq) return
|
|
1557
|
+
if (seq !== undefined) set({ workingSeq: seq })
|
|
1558
|
+
get().setWorking(strings(o.frames), strings(o.boards))
|
|
1559
|
+
},
|
|
1560
|
+
async syncWorking() {
|
|
1561
|
+
if (PUBLISHED) return
|
|
1562
|
+
try {
|
|
1563
|
+
// a fresh page may ask before its double-submit cookie exists: the refusal primes it (api.ts),
|
|
1564
|
+
// so one more try carries it
|
|
1565
|
+
for (let i = 0; i < 2; i++) {
|
|
1566
|
+
const r = await fetch(`${ROUTE}/api/work`, { headers: { 'x-mv-c': csrf() } })
|
|
1567
|
+
if (r.ok) return get().setWorkingFrom(await r.json())
|
|
1568
|
+
if (r.status !== 403) return
|
|
1569
|
+
}
|
|
1570
|
+
} catch { /* the next broadcast heals it */ }
|
|
1571
|
+
},
|
|
1572
|
+
setWorking(frames, boards = []) {
|
|
1350
1573
|
// preserve each frame's original start time; stamp now() only for newly-working frames -
|
|
1351
1574
|
// the start phases the working animations so parallel frames never pulse in sync
|
|
1352
1575
|
const prev = get().workingSince
|
|
1353
1576
|
const workingSince: Record<string, number> = {}
|
|
1354
1577
|
for (const f of frames) workingSince[f] = prev[f] ?? Date.now()
|
|
1355
|
-
set({ working: frames, workingSince })
|
|
1578
|
+
set({ working: frames, workingSince, workingBoards: frames.length ? boards : [] })
|
|
1356
1579
|
},
|
|
1357
1580
|
spawn(frameId) {
|
|
1358
1581
|
const { manifest, nodes, deviceView, baseLayout } = get()
|
|
@@ -1402,6 +1625,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
1402
1625
|
...(deviceView ? { deviceView } : {}),
|
|
1403
1626
|
...(get().sceneRows?.length ? { sceneRows: get().sceneRows } : {}),
|
|
1404
1627
|
...(get().layoutRaw !== undefined ? { layout: get().layoutRaw } : {}),
|
|
1628
|
+
...(get().laidOut && Object.keys(get().laidOut!).length && composed(get()) ? { laidOut: get().laidOut } : {}),
|
|
1405
1629
|
// baseLayout entries for auto content nodes keep POSITIONS only - their
|
|
1406
1630
|
// measured dimensions are transient and never reach the file
|
|
1407
1631
|
...(baseLayout ? {
|
|
@@ -1409,6 +1633,7 @@ export const useStore = create<State>((set, get) => {
|
|
|
1409
1633
|
const n = nodes.find((x) => x.key === k)
|
|
1410
1634
|
return n?.sizeMode === 'auto' ? [k, { x: b.x, y: b.y }] : [k, b]
|
|
1411
1635
|
})),
|
|
1636
|
+
...(get().baseLaidOut ? { baseLaidOut: get().baseLaidOut } : {}),
|
|
1412
1637
|
} : {}),
|
|
1413
1638
|
// only PINNED themes persist - inherited values follow viewTheme at load time.
|
|
1414
1639
|
// Content frames in AUTO save no dimensions: measured sizes are
|
|
@@ -472,11 +472,22 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
472
472
|
/* spec 20: a feature or project board's status ring sits at the row's end, in its own colours -
|
|
473
473
|
never the accent of the current row - with its evidence in the tooltip */
|
|
474
474
|
.sh-panel .it.board .st { flex: none; display: inline-flex; margin-left: auto; font-style: normal }
|
|
475
|
+
.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
476
|
/* the settled statuses' fills, one value per theme: done is the content palette's green (Apple's
|
|
476
477
|
systemGreen); archived is Apple's brown - its increased-contrast value on light, its default on
|
|
477
478
|
dark, where the increased-contrast one turns peach - so it reads as the same brown box in both */
|
|
478
|
-
.sh-app { --status-done: #34c759; --status-archived: #956d51 }
|
|
479
|
-
.sh-app.dark { --status-done: #30d158; --status-archived: #b78a66 }
|
|
479
|
+
.sh-app { --status-done: #34c759; --status-archived: #956d51; --status-building: #0088ff; --live-glint: #b3dbff }
|
|
480
|
+
.sh-app.dark { --status-done: #30d158; --status-archived: #b78a66; --status-building: #0088ff; --live-glint: #d6ecff }
|
|
481
|
+
/* the live signal (spec 20): an agent working on what a sidebar row holds - its icon accent blue, a
|
|
482
|
+
highlight sweeping across it. The glint is the icon again, masked to a band that travels left to right */
|
|
483
|
+
.sh-panel .it .sh-live-ic { position: relative; display: inline-flex; flex: none }
|
|
484
|
+
.sh-panel .it .sh-live-ic[data-live-icon] svg { color: var(--status-building) } /* Marver's blue, whatever the mode */
|
|
485
|
+
.sh-panel .it .sh-live-ic .glint { position: absolute; inset: 0; display: inline-flex; pointer-events: none;
|
|
486
|
+
-webkit-mask-image: linear-gradient(100deg, transparent 38%, #000 50%, transparent 62%); mask-image: linear-gradient(100deg, transparent 38%, #000 50%, transparent 62%);
|
|
487
|
+
-webkit-mask-size: 300% 100%; mask-size: 300% 100%; animation: sh-live-glint 1.8s ease-in-out infinite }
|
|
488
|
+
.sh-panel .it .sh-live-ic[data-live-icon] .glint svg { color: var(--live-glint) }
|
|
489
|
+
@keyframes sh-live-glint { from { -webkit-mask-position: 100% 0; mask-position: 100% 0 } to { -webkit-mask-position: 0 0; mask-position: 0 0 } }
|
|
490
|
+
@media (prefers-reduced-motion: reduce) { .sh-panel .it .sh-live-ic .glint { display: none } }
|
|
480
491
|
.sh-panel .it.board .st svg, .sh-panel .it.board.cur .st svg { color: inherit; margin: 0 }
|
|
481
492
|
/* drag-to-reorder: a grab cursor, the lifted row dims, and a 2px accent rule marks the
|
|
482
493
|
drop seam above or below the hovered row */
|
|
@@ -631,6 +642,13 @@ body.sh-space .sh-node { pointer-events: none } /* space-drag
|
|
|
631
642
|
/* top-of-screen chrome flips its tooltip below the trigger */
|
|
632
643
|
.sh-tip.below { transform: translate(-50%, 0); animation-name: sh-tip-pop-b }
|
|
633
644
|
@keyframes sh-tip-pop-b { from { opacity: 0; transform: translate(-50%, 0) scale(.95) } }
|
|
645
|
+
.sh-tip.right { transform: translate(0, -50%); animation-name: sh-tip-pop-r }
|
|
646
|
+
@keyframes sh-tip-pop-r { from { opacity: 0; transform: translate(0, -50%) scale(.95) } }
|
|
647
|
+
/* a status's tooltip: the status, then where it came from - each piece of evidence on its own line */
|
|
648
|
+
.sh-tip .sh-tip-lines { display: flex; flex-direction: column; gap: 2px; max-width: 420px; max-height: calc(100vh - 32px); overflow: hidden; white-space: normal }
|
|
649
|
+
/* read by a screen reader, never seen: what a glyph says to the eye */
|
|
650
|
+
.sh-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0 }
|
|
651
|
+
.sh-tip .sh-tip-lines small { opacity: .62; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere }
|
|
634
652
|
/* play chrome is fixed dark glass regardless of board theme - its tips pin the light bubble */
|
|
635
653
|
.sh-tip.inv { background: #f4f4f5; color: #18181b }
|
|
636
654
|
.sh-tip b { font-weight: 600 }
|