@1agh/maude 2.0.1 → 2.0.3

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 (42) hide show
  1. package/apps/studio/access/filters.ts +24 -2
  2. package/apps/studio/access/frame.ts +38 -0
  3. package/apps/studio/access/request.ts +81 -2
  4. package/apps/studio/asset-placeholder.tsx +157 -62
  5. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  6. package/apps/studio/client/app.jsx +3 -0
  7. package/apps/studio/client/hooks/use-palette-and-panels.jsx +2 -0
  8. package/apps/studio/client/styles/_index.css +2 -0
  9. package/apps/studio/client/v2/assets/asset-state-lane.js +170 -5
  10. package/apps/studio/client/v2/assets/ds-library-view.jsx +263 -0
  11. package/apps/studio/client/v2/assets/ds-library.css +123 -0
  12. package/apps/studio/client/v2/assets/ds-library.js +175 -0
  13. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  14. package/apps/studio/client/v2/export/native-save.js +44 -0
  15. package/apps/studio/client/v2/left-panel/assets-panel.jsx +60 -1
  16. package/apps/studio/dist/client.bundle.js +524 -523
  17. package/apps/studio/dist/comment-mount.js +2 -2
  18. package/apps/studio/dist/styles.css +1 -1
  19. package/apps/studio/ds-assets.ts +407 -0
  20. package/apps/studio/edit-ops/image-fit.ts +19 -2
  21. package/apps/studio/edit-ops/types.ts +5 -0
  22. package/apps/studio/editing/asset-drag.ts +8 -2
  23. package/apps/studio/editing/ds-asset-ref.ts +66 -0
  24. package/apps/studio/http.ts +17 -2
  25. package/apps/studio/materialize-client.ts +11 -0
  26. package/apps/studio/routes/asset-state.ts +12 -0
  27. package/apps/studio/routes/ds-assets.ts +78 -0
  28. package/apps/studio/routes/edit.ts +1 -0
  29. package/apps/studio/routes/index.ts +4 -0
  30. package/apps/studio/sync/accepted-link.ts +28 -6
  31. package/apps/studio/sync/asset-push.ts +8 -1
  32. package/apps/studio/sync/asset-state.ts +27 -2
  33. package/apps/studio/sync/availability.ts +5 -0
  34. package/apps/studio/sync/create-collision.ts +96 -19
  35. package/apps/studio/sync/file-plane.ts +36 -7
  36. package/apps/studio/sync/index.ts +10 -2
  37. package/apps/studio/sync/lfs-pointer.ts +137 -0
  38. package/apps/studio/sync/project-config-push.ts +8 -1
  39. package/apps/studio/sync/transaction-client.ts +54 -11
  40. package/apps/studio/sync/writer-registry.ts +2 -0
  41. package/apps/studio/whats-new.json +9 -0
  42. package/package.json +8 -8
@@ -52,6 +52,7 @@ import type { ServerWebSocket } from 'bun';
52
52
  import { canvasSlugFromRel } from '../canvas-slug.ts';
53
53
  import type { Context } from '../context.ts';
54
54
  import type { ProjectIndexSnapshot, SearchResult } from '../index/types.ts';
55
+ import { lastMaterializable, listMaterializable } from '../materialize-client.ts';
55
56
  import {
56
57
  type Closure,
57
58
  type ClosureCache,
@@ -61,7 +62,7 @@ import {
61
62
  projectClosureConfig,
62
63
  } from './closure.ts';
63
64
  import { closureConfigFor, knownCanvasesFor } from './known-canvases.ts';
64
- import { currentAccess, diskProjectReader, toDesignRel } from './request.ts';
65
+ import { currentAccess, diskProjectReader, toDesignRel, withJournalMedia } from './request.ts';
65
66
  import { type Access, sees } from './scope.ts';
66
67
 
67
68
  // ===========================================================================
@@ -580,6 +581,12 @@ export interface ProjectVisibility {
580
581
  * the names to what its reader sees (`filterIndexData`). Memoized per tree generation.
581
582
  */
582
583
  canvasImports(canvases: readonly string[]): ReadonlyMap<string, string[]>;
584
+ /**
585
+ * 2.0.2 — resolves once the closure's listing holds a materializing cell's journal media (the
586
+ * first `listMaterializable` answer; later ones refresh in the background). Immediate off a
587
+ * cell. The access gate awaits it before judging a session with grants.
588
+ */
589
+ ready?(): Promise<void>;
583
590
  }
584
591
 
585
592
  const sources = new WeakMap<object, ProjectVisibility>();
@@ -602,7 +609,21 @@ export function projectVisibility(
602
609
  generation++;
603
610
  });
604
611
  const cache: ClosureCache = createClosureCache();
605
- const reader = diskProjectReader(ctx.paths.designRoot, () => String(generation));
612
+ // 2.0.2 — on a materializing cell the checkout holds no media (DDR-243): the journal's inert
613
+ // media joins the listing, so a design system's logos and photos are in its canvases' closure.
614
+ const reader = withJournalMedia(
615
+ diskProjectReader(ctx.paths.designRoot, () => String(generation)),
616
+ lastMaterializable
617
+ );
618
+ const ready = async (): Promise<void> => {
619
+ // Stale-while-revalidate: only the FIRST listing is waited for, so a hub that hangs costs one
620
+ // request its hop timeout, not every request every TTL.
621
+ if (lastMaterializable() !== null) {
622
+ void listMaterializable();
623
+ return;
624
+ }
625
+ await listMaterializable();
626
+ };
606
627
  // p8-c4b — plus the canvases the authority knows of (a stored grant), re-read per call.
607
628
  const config = () =>
608
629
  closureConfigFor(ctx) ?? projectClosureConfig(reader, knownCanvasesFor(undefined));
@@ -625,6 +646,7 @@ export function projectVisibility(
625
646
  visibilityFor,
626
647
  current: () => visibilityFor(currentAccess()),
627
648
  canvasImports,
649
+ ready,
628
650
  });
629
651
  sources.set(ctx, src);
630
652
  return src;
@@ -217,6 +217,44 @@ export function narrowToFrame(base: Access, canvases: readonly string[] | null):
217
217
  return Object.freeze({ ...narrowed, unnarrowed: base.unnarrowed ?? base });
218
218
  }
219
219
 
220
+ /**
221
+ * Project media a frame may read: pictures, video, audio and fonts — inert bytes the canvas CSP
222
+ * never runs. The same set as the file plane's inert media (sync/file-membership.ts), by extension
223
+ * only: the shape there refuses names like `Team photo (2).jpg` that a design root does hold.
224
+ */
225
+ const PROJECT_MEDIA_EXT_RE =
226
+ /\.(png|jpe?g|webp|gif|avif|svg|ico|mp4|webm|mov|m4v|mp3|wav|m4a|aac|ogg|woff2?|ttf|otf)$/i;
227
+
228
+ /** A designRoot-relative path that names project media: no runtime state, no dot or empty segment. */
229
+ export function isProjectMediaRel(rel: string): boolean {
230
+ if (!rel || rel.startsWith('/') || rel.includes('\\')) return false;
231
+ const segs = rel.split('/');
232
+ if (segs.some((s) => s === '' || s.startsWith('.'))) return false;
233
+ // Runtime state is first-segment `_*` (DDR-115) — never project media.
234
+ if ((segs[0] as string).startsWith('_')) return false;
235
+ return PROJECT_MEDIA_EXT_RE.test(rel);
236
+ }
237
+
238
+ /**
239
+ * Decision `maude/v2-202-project-role-frames-read-project-media` (Michal, 2026-11-03): a frame
240
+ * whose OPENER holds a project read role (`unnarrowed`, the access before `narrowToFrame`) may GET
241
+ * any project media, anywhere in the design root — so a canvas that builds a picture path in code
242
+ * (G3 leaves it out of the closure) or places another system's picture still draws it for the
243
+ * people who can read that picture on the main origin anyway. Reads only, media only: source, CSS,
244
+ * JSON, sidecars and other canvases stay behind the closure. A canvas-only opener (a share of one
245
+ * canvas) gets nothing here — its frame keeps the strict closure.
246
+ *
247
+ * Residual risk, accepted: code planted in a canvas by an editor of a single-canvas share can load
248
+ * other canvases' pictures when an owner or member opens that canvas.
249
+ */
250
+ export function frameReadsProjectMedia(access: Access, rel: string, method: string): boolean {
251
+ if (method !== 'GET' && method !== 'HEAD') return false;
252
+ const opener = access.unnarrowed;
253
+ if (!access.canvasOnly || !opener || opener.role === null) return false;
254
+ if (!opener.can('read', null)) return false;
255
+ return isProjectMediaRel(rel);
256
+ }
257
+
220
258
  // ---------------------------------------------------------------------------
221
259
  // The request's frame (set by the canvas / capture listener, read by `accessOf`).
222
260
 
@@ -24,9 +24,11 @@
24
24
  import { AsyncLocalStorage } from 'node:async_hooks';
25
25
  import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
26
26
  import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
27
+ import { classifyProjectFile } from '../sync/file-membership.ts';
27
28
  import type { Closure, ProjectReader } from './closure.ts';
28
29
  // S9.12 — the revert-guard seam (a call-time read, so the import cycle with filters.ts is inert).
29
30
  import { aclCheckOn } from './filters.ts';
31
+ import { frameReadsProjectMedia } from './frame.ts';
30
32
  import type { Capability, ProjectRole } from './roles.ts';
31
33
  import { FLOOR_ROLE, can as roleCan } from './roles.ts';
32
34
  import {
@@ -438,8 +440,30 @@ export async function canvasScopeRefusal(req: Request, g: GateInput): Promise<Re
438
440
  if (!g.access.canvasOnly || !aclCheckOn('canvasScopeRefusal')) return null;
439
441
  const target = await gateTarget(req, g);
440
442
  if (target === undefined) return null;
441
- if (target === null || !seesTarget(g, target, req.method)) return notInScopeResponse();
442
- return null;
443
+ if (target === null) return notInScopeResponse();
444
+ if (seesTarget(g, target, req.method)) return null;
445
+ // 2.0.2 (decision maude/v2-202-project-role-frames-read-project-media) — the static lane's own
446
+ // path (never a `?file=` naming it for an API) may be project media a project-role opener's frame
447
+ // reads; `frameReadsProjectMedia` holds it to GET/HEAD and media, and never a canvas-only opener.
448
+ if (
449
+ staticPathTarget(req, g.designRel) === target &&
450
+ frameReadsProjectMedia(g.access, target, req.method)
451
+ )
452
+ return null;
453
+ return notInScopeResponse();
454
+ }
455
+
456
+ /** The designRoot file a request's PATH names when no target key in its query names another. */
457
+ function staticPathTarget(req: Request, designRel: string): string | null {
458
+ let url: URL;
459
+ try {
460
+ url = new URL(req.url);
461
+ } catch {
462
+ return null;
463
+ }
464
+ if (TARGET_KEYS.some((k) => url.searchParams.has(k))) return null;
465
+ const base = `/${designRel.replace(/^\/+|\/+$/g, '')}/`;
466
+ return url.pathname.startsWith(base) ? toDesignRel(url.pathname, designRel) : null;
443
467
  }
444
468
 
445
469
  export type LocalGate =
@@ -635,3 +659,58 @@ export function diskProjectReader(
635
659
  },
636
660
  };
637
661
  }
662
+
663
+ /**
664
+ * 2.0.2 — `disk` plus a materializing cell's journal media (`media()`, materialize-client.ts
665
+ * `lastMaterializable`). On a cell the disk is a cache (DDR-243): inert media lives in the bucket
666
+ * and is served from a hub-owned cache OUTSIDE the design root, so it never appears at its checkout
667
+ * path. A closure over the disk alone therefore never held a design system's logos or photos, and
668
+ * the path-first gate refused a canvas frame its own system's media (alligators, 2.0.1).
669
+ *
670
+ * The hub is semi-trusted (DDR-054), so its listing only ADDS names the closure's own rules then
671
+ * judge — and only inert-media names (`classifyProjectFile(rel, {})`, the check the static lane's
672
+ * fill makes): never a module, a stylesheet, config or runtime state, never a dot name. `text()` of
673
+ * one is the disk's (null when absent); serving one still goes through `materializeMissing`.
674
+ * `head()` carries a version that moves when the listing does, so cached closures are recomputed.
675
+ */
676
+ export function withJournalMedia(
677
+ disk: ProjectReader,
678
+ media: () => readonly string[] | null
679
+ ): ProjectReader {
680
+ let seen: readonly string[] | null = null;
681
+ let version = 0;
682
+ let extra: ReadonlySet<string> = new Set();
683
+ const sync = () => {
684
+ const rels = media();
685
+ if (rels === seen) return;
686
+ seen = rels;
687
+ const next = new Set<string>();
688
+ for (const rel of rels ?? []) {
689
+ if (rel.split('/').some((s) => s.startsWith('.'))) continue;
690
+ if (classifyProjectFile(rel, {}) !== 'inert-media') continue;
691
+ next.add(rel);
692
+ }
693
+ if (next.size === extra.size && [...next].every((r) => extra.has(r))) return;
694
+ extra = next;
695
+ version++;
696
+ };
697
+ return {
698
+ head: () => {
699
+ sync();
700
+ return `${disk.head()}+m${version}`;
701
+ },
702
+ text: (rel) => disk.text(rel),
703
+ listTruncated: disk.listTruncated ? () => disk.listTruncated?.() === true : undefined,
704
+ present: disk.present ? (rel) => disk.present?.(rel) === true || extra.has(rel) : undefined,
705
+ unlisted: disk.unlisted ? () => disk.unlisted?.() ?? [] : undefined,
706
+ *list() {
707
+ sync();
708
+ const listed = new Set<string>();
709
+ for (const f of disk.list()) {
710
+ listed.add(f);
711
+ yield f;
712
+ }
713
+ for (const f of extra) if (!listed.has(f)) yield f;
714
+ },
715
+ };
716
+ }
@@ -12,6 +12,12 @@
12
12
  //
13
13
  // Anything uncertain is "Not here yet", never Missing. Outside a shell (an export capture, a
14
14
  // headless screenshot) nothing is ever sent, so nothing is ever drawn — exports carry no frames.
15
+ //
16
+ // 2.0.3 — a Git LFS placeholder (`lfs-pointer`: the file here is a pointer, not the picture) says so
17
+ // in plain words. Where the shell can repair it (`lfsActions`, the desktop app's AI chat) the frame
18
+ // adds "Fix with AI" and "Copy prompt"; both only NAME the rel (`asset-lfs-fix-request`,
19
+ // `asset-lfs-copy-request`) — the shell builds the prompt from its own answer and does the clipboard
20
+ // write (this iframe has no clipboard rights), then answers `asset-lfs-copied` for the "Copied" word.
15
21
 
16
22
  import { useEffect, useMemo, useRef, useState } from 'react';
17
23
  import { createPortal } from 'react-dom';
@@ -21,11 +27,16 @@ import { type AssetStateItem, acceptFromShell } from './bridge/dgn-protocol.ts';
21
27
 
22
28
  /** What a frame says. `null` = draw nothing (the picture is here, or still uploading from here). */
23
29
  export interface FrameWords {
24
- state: 'waiting' | 'missing';
30
+ state: 'waiting' | 'missing' | 'lfs-pointer';
25
31
  line: string;
26
32
  relink: boolean;
27
33
  }
28
34
 
35
+ /** 2.0.3 — the line a Git LFS placeholder wears. */
36
+ export const LFS_LINE = 'Not downloaded — Git LFS placeholder';
37
+ /** How long "Copy prompt" reads "Copied" after the shell said it copied. */
38
+ export const LFS_COPIED_MS = 1500;
39
+
29
40
  const KIND_WORD = { mac: 'Mac', pc: 'PC', linux: 'computer' } as const;
30
41
 
31
42
  /**
@@ -43,6 +54,7 @@ function possessive(name: string): string {
43
54
  /** The §5.5 words. A name only, never an address: "Jonas's device" when the kind is unknown. */
44
55
  export function frameWords(item: AssetStateItem | undefined): FrameWords | null {
45
56
  if (!item || item.state === 'here' || item.state === 'uploading') return null;
57
+ if (item.state === 'lfs-pointer') return { state: 'lfs-pointer', line: LFS_LINE, relink: false };
46
58
  if (item.state === 'missing') {
47
59
  return { state: 'missing', line: 'Missing — no device has it', relink: RELINK_LIVE };
48
60
  }
@@ -209,6 +221,10 @@ const CSS = `
209
221
  .dc-absent-btn { pointer-events: auto; margin-top: 2px; padding: 3px 10px; border: 0; border-radius: 6px; cursor: pointer;
210
222
  font: inherit; font-weight: 600; background: var(--dc-absent-accent); color: var(--dc-absent-accent-fg); }
211
223
  .dc-absent-btn:focus-visible { outline: 2px solid var(--dc-absent-accent); outline-offset: 2px; }
224
+ .dc-absent[data-state="lfs-pointer"] { background-image: repeating-linear-gradient(135deg, var(--dc-absent-stripe) 0 2px, transparent 2px 9px);
225
+ box-shadow: inset 0 0 0 1px var(--dc-absent-edge); }
226
+ .dc-absent-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
227
+ .dc-absent-btn--quiet { background: transparent; color: var(--dc-absent-ink); box-shadow: inset 0 0 0 1px var(--dc-absent-edge); }
212
228
  `;
213
229
 
214
230
  function ensureStyles(): void {
@@ -246,21 +262,48 @@ export function AssetPlaceholderLayer({
246
262
  const [items, setItems] = useState<ReadonlyMap<string, AssetStateItem>>(new Map());
247
263
  const [frames, setFrames] = useState<Frame[]>([]);
248
264
  const nodes = useRef(new Map<string, HTMLDivElement>());
265
+ // 2.0.3: the shell can repair an LFS placeholder (its AI chat exists); rel → what Copy prompt says now.
266
+ const [lfsActions, setLfsActions] = useState(false);
267
+ const [copied, setCopied] = useState<ReadonlyMap<string, 'copied' | 'failed'>>(new Map());
268
+ const copiedTimers = useRef(new Map<string, ReturnType<typeof setTimeout>>());
249
269
 
250
270
  useEffect(() => {
251
271
  if (typeof window === 'undefined') return;
272
+ const timers = copiedTimers.current;
252
273
  const onMessage = (e: MessageEvent) => {
253
274
  // Only the shell may say it (DDR-054); the table parses it (≤ 256 items, no e-mail names).
254
275
  if (e.source !== window.parent) return;
255
- if ((e.data as { dgn?: string } | null)?.dgn !== 'asset-state') return;
276
+ const dgn = (e.data as { dgn?: string } | null)?.dgn;
277
+ if (dgn !== 'asset-state' && dgn !== 'asset-lfs-copied') return;
256
278
  const m = acceptFromShell(e, window);
257
279
  if (m && m.dgn === 'asset-state') {
258
280
  ensureStyles();
259
281
  setItems(new Map(m.items.map((it) => [it.rel, it])));
282
+ setLfsActions(m.lfsActions === true);
283
+ } else if (m && m.dgn === 'asset-lfs-copied') {
284
+ const rel = m.rel;
285
+ setCopied((prev) => new Map(prev).set(rel, m.ok ? 'copied' : 'failed'));
286
+ const old = timers.get(rel);
287
+ if (old) clearTimeout(old);
288
+ timers.set(
289
+ rel,
290
+ setTimeout(() => {
291
+ timers.delete(rel);
292
+ setCopied((prev) => {
293
+ const next = new Map(prev);
294
+ next.delete(rel);
295
+ return next;
296
+ });
297
+ }, LFS_COPIED_MS)
298
+ );
260
299
  }
261
300
  };
262
301
  window.addEventListener('message', onMessage);
263
- return () => window.removeEventListener('message', onMessage);
302
+ return () => {
303
+ window.removeEventListener('message', onMessage);
304
+ for (const t of timers.values()) clearTimeout(t);
305
+ timers.clear();
306
+ };
264
307
  }, []);
265
308
 
266
309
  // Which elements need a frame: rescanned on news, and on every media load / error (capture
@@ -413,66 +456,118 @@ export function AssetPlaceholderLayer({
413
456
  {bars}
414
457
  {createPortal(
415
458
  <div className="dc-absent-layer" data-testid="asset-frames">
416
- {frames.map((f) => (
417
- // biome-ignore lint/a11y/useAriaPropsSupportedByRole: role is `group` or `img` (both take a name)
418
- <div
419
- key={f.key}
420
- ref={(el) => {
421
- if (el) nodes.current.set(f.key, el);
422
- else nodes.current.delete(f.key);
423
- }}
424
- className="dc-absent"
425
- data-testid="asset-frame"
426
- data-rel={f.rel}
427
- data-state={f.words.state}
428
- data-lost={f.lost ? '1' : undefined}
429
- // gate-b-a11y: `img` cannot hold the Relink… button (axe nested-interactive) — a labelled group can
430
- role={f.words.relink ? 'group' : 'img'}
431
- aria-label={
432
- f.lost && f.words.line === LOST_VIDEO_LINE
433
- ? `${f.words.line} · ${f.rel}`
434
- : `${f.lost ? f.rel : baseName(f.rel)} · ${f.words.line}`
435
- }
436
- >
437
- <span className="dc-absent-in">
438
- <svg
439
- className="dc-absent-ic"
440
- width="16"
441
- height="16"
442
- viewBox="0 0 16 16"
443
- fill="none"
444
- stroke="currentColor"
445
- strokeWidth="1.4"
446
- strokeLinecap="round"
447
- strokeLinejoin="round"
448
- aria-hidden="true"
449
- >
450
- <path d="M8 2.2 14.2 13H1.8z" />
451
- <path d="M8 6.4v3.2" />
452
- <circle cx="8" cy="11.3" r="0.4" fill="currentColor" />
453
- </svg>
454
- <span className="dc-absent-n">{f.lost ? f.rel : baseName(f.rel)}</span>
455
- <span className="dc-absent-d">{f.words.line}</span>
456
- {f.words.relink ? (
457
- <button
458
- type="button"
459
- className="dc-absent-btn"
460
- data-testid="asset-frame-relink"
461
- onClick={() => {
462
- // A literal `{ dgn }` so the bridge inventory sees this send site.
463
- try {
464
- window.parent.postMessage({ dgn: 'asset-relink-request', rel: f.rel }, '*');
465
- } catch {
466
- /* detached */
467
- }
468
- }}
459
+ {frames.map((f) => {
460
+ const lfs = f.words.state === 'lfs-pointer' && lfsActions && !f.lost;
461
+ const copyWord = copied.get(f.rel);
462
+ return (
463
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: role is `group` or `img` (both take a name)
464
+ <div
465
+ key={f.key}
466
+ ref={(el) => {
467
+ if (el) nodes.current.set(f.key, el);
468
+ else nodes.current.delete(f.key);
469
+ }}
470
+ className="dc-absent"
471
+ data-testid="asset-frame"
472
+ data-rel={f.rel}
473
+ data-state={f.words.state}
474
+ data-lost={f.lost ? '1' : undefined}
475
+ // gate-b-a11y: `img` cannot hold the Relink… button (axe nested-interactive) — a labelled group can
476
+ role={f.words.relink || lfs ? 'group' : 'img'}
477
+ aria-label={
478
+ f.lost && f.words.line === LOST_VIDEO_LINE
479
+ ? `${f.words.line} · ${f.rel}`
480
+ : `${f.lost ? f.rel : baseName(f.rel)} · ${f.words.line}`
481
+ }
482
+ >
483
+ <span className="dc-absent-in">
484
+ <svg
485
+ className="dc-absent-ic"
486
+ width="16"
487
+ height="16"
488
+ viewBox="0 0 16 16"
489
+ fill="none"
490
+ stroke="currentColor"
491
+ strokeWidth="1.4"
492
+ strokeLinecap="round"
493
+ strokeLinejoin="round"
494
+ aria-hidden="true"
469
495
  >
470
- Relink…
471
- </button>
472
- ) : null}
473
- </span>
474
- </div>
475
- ))}
496
+ <path d="M8 2.2 14.2 13H1.8z" />
497
+ <path d="M8 6.4v3.2" />
498
+ <circle cx="8" cy="11.3" r="0.4" fill="currentColor" />
499
+ </svg>
500
+ <span className="dc-absent-n">{f.lost ? f.rel : baseName(f.rel)}</span>
501
+ <span className="dc-absent-d">{f.words.line}</span>
502
+ {f.words.relink ? (
503
+ <button
504
+ type="button"
505
+ className="dc-absent-btn"
506
+ data-testid="asset-frame-relink"
507
+ onClick={() => {
508
+ // A literal `{ dgn }` so the bridge inventory sees this send site.
509
+ try {
510
+ window.parent.postMessage(
511
+ { dgn: 'asset-relink-request', rel: f.rel },
512
+ '*'
513
+ );
514
+ } catch {
515
+ /* detached */
516
+ }
517
+ }}
518
+ >
519
+ Relink…
520
+ </button>
521
+ ) : null}
522
+ {lfs ? (
523
+ <span className="dc-absent-row">
524
+ <button
525
+ type="button"
526
+ className="dc-absent-btn"
527
+ data-testid="asset-frame-lfs-fix"
528
+ onClick={() => {
529
+ // A literal `{ dgn }` so the bridge inventory sees this send site.
530
+ try {
531
+ window.parent.postMessage(
532
+ { dgn: 'asset-lfs-fix-request', rel: f.rel },
533
+ '*'
534
+ );
535
+ } catch {
536
+ /* detached */
537
+ }
538
+ }}
539
+ >
540
+ Fix with AI
541
+ </button>
542
+ <button
543
+ type="button"
544
+ className="dc-absent-btn dc-absent-btn--quiet"
545
+ data-testid="asset-frame-lfs-copy"
546
+ aria-live="polite"
547
+ onClick={() => {
548
+ // A literal `{ dgn }` so the bridge inventory sees this send site.
549
+ try {
550
+ window.parent.postMessage(
551
+ { dgn: 'asset-lfs-copy-request', rel: f.rel },
552
+ '*'
553
+ );
554
+ } catch {
555
+ /* detached */
556
+ }
557
+ }}
558
+ >
559
+ {copyWord === 'copied'
560
+ ? 'Copied'
561
+ : copyWord === 'failed'
562
+ ? 'Couldn’t copy'
563
+ : 'Copy prompt'}
564
+ </button>
565
+ </span>
566
+ ) : null}
567
+ </span>
568
+ </div>
569
+ );
570
+ })}
476
571
  </div>,
477
572
  document.body
478
573
  )}
@@ -439,12 +439,18 @@ export interface CanvasToShell {
439
439
  // S8.19 — the placeholder frame's Relink… (a Missing picture): the shell opens its relink sheet for
440
440
  // that rel. The canvas asks; the shell decides (the write is the shell's `asset.relink` edit op).
441
441
  'asset-relink-request': { rel: string };
442
+ // 2.0.3 — a Git LFS placeholder frame's two buttons (desktop only). The canvas only NAMES a rel; the
443
+ // shell checks it against its own asset-state answer (`lfs-pointer`) and builds the prompt itself.
444
+ 'asset-lfs-fix-request': { rel: string };
445
+ 'asset-lfs-copy-request': { rel: string };
442
446
  }
443
447
 
444
448
  /** S8.19 — one picture's state, as the shell tells the canvas (contract S8-S9-asset-presence §5.5). */
445
449
  export interface AssetStateItem {
446
450
  rel: string;
447
- state: 'here' | 'uploading' | 'waiting' | 'missing';
451
+ state: 'here' | 'uploading' | 'waiting' | 'missing' | 'lfs-pointer';
452
+ /** 2.0.3, `lfs-pointer` only: the real bytes are already in this repo's `.git/lfs/objects`. */
453
+ localObject?: boolean;
448
454
  /** A display name only — never an e-mail, never a device id. */
449
455
  who?: { name: string | null; kind: 'mac' | 'pc' | 'linux' | null; self: boolean };
450
456
  /** The hub already has the bytes; this Mac has not pulled them yet ("Syncing…"). */
@@ -747,7 +753,12 @@ export interface ShellToCanvas {
747
753
  // S8.19 — "Waiting for Jonas's Mac" vs Missing for the open canvas's media. State, not an event: the
748
754
  // shell sends the whole list on open, every 60 s while something waits, at reconnect and after a
749
755
  // sweep ends. ≤ 256 items; a name with an `@` is refused whole (the canvas never sees an e-mail).
750
- 'asset-state': { items: AssetStateItem[] };
756
+ // 2.0.3: `lfsActions` — this shell can repair a Git LFS placeholder (the desktop's AI chat), so its
757
+ // frame offers "Fix with AI" and "Copy prompt". Absent / false: the words only.
758
+ 'asset-state': { items: AssetStateItem[]; lfsActions?: boolean };
759
+ // 2.0.3 — the shell's answer to `asset-lfs-copy-request`: it wrote the prompt to the clipboard (`ok`)
760
+ // or could not. The frame's button reads "Copied" for a moment.
761
+ 'asset-lfs-copied': { rel: string; ok: boolean };
751
762
  // S8.16 — the pictures of the open canvas that have other takes (`assets/<sha8>.<ext>`): with one of them
752
763
  // selected, ← → are `take-step`, not a nudge. State, not an event: the whole set each time. ≤ 256 items,
753
764
  // each an asset path; a planted or oversized list is refused whole.
@@ -1188,7 +1199,8 @@ const assetWho = shape({
1188
1199
  });
1189
1200
  const assetStateItem = shape({
1190
1201
  rel: shortStr(512),
1191
- state: lit('here', 'uploading', 'waiting', 'missing'),
1202
+ state: lit('here', 'uploading', 'waiting', 'missing', 'lfs-pointer'),
1203
+ localObject: opt(bool),
1192
1204
  who: opt(assetWho),
1193
1205
  syncing: opt(bool),
1194
1206
  progress: opt(unit),
@@ -1939,6 +1951,18 @@ const c2s: C2S = {
1939
1951
  owner: 'client/v2/assets/asset-state-lane (S8.19)',
1940
1952
  parse: p({ rel: shortStr(512) }),
1941
1953
  },
1954
+ 'asset-lfs-fix-request': {
1955
+ gate: 'active',
1956
+ status: 'live',
1957
+ owner: 'client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)',
1958
+ parse: p({ rel: shortStr(512) }),
1959
+ },
1960
+ 'asset-lfs-copy-request': {
1961
+ gate: 'active',
1962
+ status: 'live',
1963
+ owner: 'client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)',
1964
+ parse: p({ rel: shortStr(512) }),
1965
+ },
1942
1966
  };
1943
1967
 
1944
1968
  const s2c: S2C = {
@@ -2565,7 +2589,13 @@ const s2c: S2C = {
2565
2589
  gate: 'parent',
2566
2590
  status: 'live',
2567
2591
  owner: 'canvas-lib asset placeholder frame (S8.19, L1)',
2568
- parse: p({ items: assetStateList }),
2592
+ parse: p({ items: assetStateList, lfsActions: opt(bool) }),
2593
+ },
2594
+ 'asset-lfs-copied': {
2595
+ gate: 'parent',
2596
+ status: 'live',
2597
+ owner: 'canvas-lib asset placeholder frame (2.0.3 LFS placeholder)',
2598
+ parse: p({ rel: shortStr(512), ok: bool }),
2569
2599
  },
2570
2600
  'gen-takes': {
2571
2601
  gate: 'parent',
@@ -3098,6 +3098,9 @@ function ShellTree() {
3098
3098
  const relink = useRelinkSheet({ canEdit: !viewerMode });
3099
3099
  useAssetStateLane({
3100
3100
  onRelink: relink.onRelink,
3101
+ // 2.0.3 — a Git LFS placeholder's Fix with AI / Copy prompt: where the error card offers Ask AI.
3102
+ askAiAvailable: isNativeApp() && !cfg?.readOnly,
3103
+ designRel: cfg?.designRel || cfg?.designRoot || '.design',
3101
3104
  syncStatus,
3102
3105
  wsConnected,
3103
3106
  canvasOrigin: () => cfg?.canvasOrigin || window.location.origin,
@@ -679,6 +679,8 @@ export function usePaletteAndPanels({
679
679
  isOffline={() => importsWaitHereFrom({ cfg, cloudLinkedHub, syncStatus, project })}
680
680
  // S8.21 — "Used in" in an asset's details opens that artboard
681
681
  onOpenCanvas={openCanvasAt}
682
+ // 2.0.2 — each design system's own library is a source of the tab
683
+ designSystems={cfg?.designSystems}
682
684
  />
683
685
  );
684
686
  // S1.14 — Version history (⌥⌘H): the dock id `changes` stays (testids, the dock strip, `history.open`).
@@ -172,6 +172,8 @@
172
172
  @import url("../v2/assets/takes.css");
173
173
  /* S8.20 — search in pictures: the offer, the sheet, "Seen in the picture" and its marks (client/v2/assets/). */
174
174
  @import url("../v2/assets/describe.css");
175
+ /* 2.0.2 - the Assets tab Library switch and a design system own library (client/v2/assets/ds-library-view.jsx). */
176
+ @import url("../v2/assets/ds-library.css");
175
177
  /* Phase 4 gate — the a11y contrast floor (WCAG 1.4.3), utilities layer: wins over shell + components. */
176
178
  @import url("../v2/shell/contrast.css");
177
179
  /* V2-3.3 — the Home page, scoped under `.maude-v2.home-root` (maude-v2 tokens only). */