@1agh/maude 2.0.8 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/README.md +2 -1
  2. package/apps/hub/src/project-transactions/kernel.mjs +13 -7
  3. package/apps/studio/access/closure.ts +86 -10
  4. package/apps/studio/access/filters.ts +18 -1
  5. package/apps/studio/access/request.ts +8 -0
  6. package/apps/studio/acp/design-write-verb.ts +12 -2
  7. package/apps/studio/acp/env.ts +7 -2
  8. package/apps/studio/acp/index.ts +15 -4
  9. package/apps/studio/acp/login-state.ts +22 -5
  10. package/apps/studio/acp/may-scope.ts +38 -1
  11. package/apps/studio/acp/plugin-bootstrap.ts +13 -1
  12. package/apps/studio/acp/probe.ts +11 -4
  13. package/apps/studio/actions/agents.ts +110 -28
  14. package/apps/studio/actions/canvas-keys.ts +4 -2
  15. package/apps/studio/actions/ctx.ts +3 -0
  16. package/apps/studio/actions/defs/annotation.ts +84 -2
  17. package/apps/studio/actions/defs/app.ts +28 -1
  18. package/apps/studio/actions/defs/edit.ts +13 -0
  19. package/apps/studio/actions/defs/export.ts +12 -0
  20. package/apps/studio/actions/defs/sync.ts +18 -0
  21. package/apps/studio/actions/defs/video.ts +9 -0
  22. package/apps/studio/actions/documents.ts +6 -1
  23. package/apps/studio/actions/keymap.gen.ts +147 -9
  24. package/apps/studio/actions/menu.ts +5 -1
  25. package/apps/studio/actions/types.ts +4 -2
  26. package/apps/studio/actions/verbs.ts +9 -0
  27. package/apps/studio/actions.manifest.json +300 -45
  28. package/apps/studio/actions.parity.json +19 -1
  29. package/apps/studio/ai/save-hold.ts +2 -1
  30. package/apps/studio/ai/write-claim-scope.ts +7 -1
  31. package/apps/studio/ai/write-claim.ts +154 -3
  32. package/apps/studio/annotations/ai-read.ts +42 -6
  33. package/apps/studio/annotations/ai-write.ts +145 -2
  34. package/apps/studio/annotations/board-ops.ts +34 -3
  35. package/apps/studio/annotations/checklist-ops.ts +374 -0
  36. package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
  37. package/apps/studio/annotations/elements/sticky.model.ts +54 -2
  38. package/apps/studio/annotations/ops.ts +30 -0
  39. package/apps/studio/annotations/registry.ts +9 -1
  40. package/apps/studio/annotations/templates.ts +4 -2
  41. package/apps/studio/annotations/text-steps.ts +114 -10
  42. package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
  43. package/apps/studio/annotations/ui/checklist.tsx +429 -0
  44. package/apps/studio/annotations/ui/element-node.tsx +48 -2
  45. package/apps/studio/annotations/ui/template-place.ts +11 -1
  46. package/apps/studio/annotations/v1-adapter.ts +22 -3
  47. package/apps/studio/annotations-context-toolbar.tsx +12 -0
  48. package/apps/studio/annotations-layer.tsx +442 -49
  49. package/apps/studio/annotations-model.ts +4 -2
  50. package/apps/studio/api.ts +148 -21
  51. package/apps/studio/artboard-live-gate.tsx +54 -17
  52. package/apps/studio/artboard-still-persist.ts +166 -0
  53. package/apps/studio/artboard-still-raster.ts +6 -2
  54. package/apps/studio/artboard-still.ts +390 -20
  55. package/apps/studio/asset-added.ts +154 -0
  56. package/apps/studio/asset-details.ts +46 -3
  57. package/apps/studio/asset-origins.ts +5 -3
  58. package/apps/studio/asset-trash.ts +6 -1
  59. package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
  60. package/apps/studio/bin/_annotate-post.mjs +14 -5
  61. package/apps/studio/bin/_audio-search.mjs +8 -2
  62. package/apps/studio/bin/_curl-local.mjs +7 -4
  63. package/apps/studio/bin/_desktop-locate.sh +145 -0
  64. package/apps/studio/bin/_ds-check-live.mjs +2 -1
  65. package/apps/studio/bin/_exports.mjs +38 -2
  66. package/apps/studio/bin/_history.mjs +79 -8
  67. package/apps/studio/bin/_import-asset.mjs +14 -9
  68. package/apps/studio/bin/_import-figma.mjs +510 -98
  69. package/apps/studio/bin/_index-cli.mjs +10 -21
  70. package/apps/studio/bin/_ingest-footage.mjs +24 -6
  71. package/apps/studio/bin/_media-probe.mjs +232 -0
  72. package/apps/studio/bin/_perf-probe-open.mjs +6 -0
  73. package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
  74. package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
  75. package/apps/studio/bin/_perf-probe.mjs +8 -3
  76. package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
  77. package/apps/studio/bin/_perf-sweep.mjs +240 -0
  78. package/apps/studio/bin/_record-shot.sh +33 -8
  79. package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
  80. package/apps/studio/bin/_studio-verb.mjs +8 -3
  81. package/apps/studio/bin/_thumb-route.mjs +21 -0
  82. package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
  83. package/apps/studio/bin/_transcribe.mjs +22 -6
  84. package/apps/studio/bin/_unsynced-refs.mjs +22 -0
  85. package/apps/studio/bin/_url-guard.mjs +120 -5
  86. package/apps/studio/bin/_url-guard.sh +29 -7
  87. package/apps/studio/bin/_video-limits.mjs +104 -0
  88. package/apps/studio/bin/_video-playwright.mjs +119 -19
  89. package/apps/studio/bin/_video-proxy.mjs +130 -0
  90. package/apps/studio/bin/_write-claim.mjs +38 -16
  91. package/apps/studio/bin/annotate.mjs +12 -2
  92. package/apps/studio/bin/canvas-rects.sh +19 -4
  93. package/apps/studio/bin/chat-open.sh +7 -1
  94. package/apps/studio/bin/draw-proof.sh +6 -2
  95. package/apps/studio/bin/generate.sh +32 -10
  96. package/apps/studio/bin/handoff.sh +2 -2
  97. package/apps/studio/bin/perf.sh +96 -15
  98. package/apps/studio/bin/photo-adjust.sh +6 -3
  99. package/apps/studio/bin/photo-bg-remove.sh +2 -2
  100. package/apps/studio/bin/prep.sh +21 -4
  101. package/apps/studio/bin/read-annotations.mjs +3 -0
  102. package/apps/studio/bin/runtime-health.sh +27 -1
  103. package/apps/studio/bin/screenshot.sh +152 -12
  104. package/apps/studio/bin/server-up.sh +64 -6
  105. package/apps/studio/bin/smoke.sh +43 -8
  106. package/apps/studio/bin/to-lottie.sh +3 -2
  107. package/apps/studio/bin/video-proxy.sh +27 -0
  108. package/apps/studio/bin/visual-sanity.sh +3 -1
  109. package/apps/studio/bridge/dgn-protocol.ts +157 -1
  110. package/apps/studio/bridge/mode-shows.ts +8 -6
  111. package/apps/studio/bridge/still-webp.ts +233 -0
  112. package/apps/studio/build.ts +18 -0
  113. package/apps/studio/canvas-build.ts +93 -11
  114. package/apps/studio/canvas-comment-mount.tsx +53 -8
  115. package/apps/studio/canvas-edit.ts +34 -1
  116. package/apps/studio/canvas-lib-module.ts +210 -0
  117. package/apps/studio/canvas-lib.tsx +3 -12
  118. package/apps/studio/canvas-pipeline.ts +111 -5
  119. package/apps/studio/canvas-shell.tsx +8 -11
  120. package/apps/studio/canvas-theme-pill.tsx +5 -3
  121. package/apps/studio/check/index.ts +12 -5
  122. package/apps/studio/check/video.ts +18 -2
  123. package/apps/studio/client/app.jsx +65 -7
  124. package/apps/studio/client/clipboard-relay.ts +193 -16
  125. package/apps/studio/client/comments-overlay.css +18 -0
  126. package/apps/studio/client/export-center.jsx +30 -0
  127. package/apps/studio/client/generate-dialog.jsx +49 -4
  128. package/apps/studio/client/github.js +7 -0
  129. package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
  130. package/apps/studio/client/home/HomeConnection.jsx +111 -0
  131. package/apps/studio/client/home/home-accounts-model.js +110 -1
  132. package/apps/studio/client/home/home-api.js +9 -2
  133. package/apps/studio/client/home/home-app.jsx +126 -13
  134. package/apps/studio/client/home/home-model.js +69 -1
  135. package/apps/studio/client/home/home-where-model.js +105 -0
  136. package/apps/studio/client/home/home.css +239 -1
  137. package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
  138. package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
  139. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  140. package/apps/studio/client/panels/DiffView.jsx +7 -1
  141. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  142. package/apps/studio/client/panels/chat-context.js +2 -0
  143. package/apps/studio/client/panels/slash-commands.gen.js +13 -13
  144. package/apps/studio/client/selection-scope.js +16 -9
  145. package/apps/studio/client/share-link.js +12 -0
  146. package/apps/studio/client/shell/viewport.jsx +11 -1
  147. package/apps/studio/client/shell-events.js +8 -0
  148. package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
  149. package/apps/studio/client/styles/_index.css +4 -0
  150. package/apps/studio/client/v2/ai/Feed.jsx +1 -1
  151. package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
  152. package/apps/studio/client/v2/ai/activity-line.js +54 -1
  153. package/apps/studio/client/v2/ai/ai-offer.js +21 -1
  154. package/apps/studio/client/v2/ai/run-model.js +3 -1
  155. package/apps/studio/client/v2/annotations/vote-store.js +28 -4
  156. package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
  157. package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
  158. package/apps/studio/client/v2/assets/details-model.js +1 -1
  159. package/apps/studio/client/v2/assets/details.jsx +5 -0
  160. package/apps/studio/client/v2/assets/tile-drag.js +11 -7
  161. package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
  162. package/apps/studio/client/v2/create/duplicate-done.js +6 -2
  163. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  164. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  165. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  166. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  167. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
  168. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
  169. package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
  170. package/apps/studio/client/v2/ds/review.css +1 -1
  171. package/apps/studio/client/v2/export/exports-model.js +7 -0
  172. package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
  173. package/apps/studio/client/v2/export/job-row.jsx +32 -2
  174. package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
  175. package/apps/studio/client/v2/history/compare-view.jsx +1 -0
  176. package/apps/studio/client/v2/inspector/css-write.js +6 -1
  177. package/apps/studio/client/v2/inspector/frame.jsx +28 -4
  178. package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
  179. package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
  180. package/apps/studio/client/v2/inspector/model.js +21 -0
  181. package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
  182. package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
  183. package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
  184. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  185. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  186. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  187. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  188. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  189. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  190. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  191. package/apps/studio/client/v2/preview/link-follow.js +4 -2
  192. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
  193. package/apps/studio/client/v2/search/help-model.js +2 -0
  194. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  195. package/apps/studio/client/v2/settings/account.jsx +4 -2
  196. package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
  197. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  198. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  199. package/apps/studio/client/v2/settings/general-section.jsx +155 -24
  200. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  201. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  202. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  203. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  204. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  205. package/apps/studio/client/v2/settings/settings-model.js +100 -31
  206. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  207. package/apps/studio/client/v2/settings/settings.css +374 -64
  208. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  209. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  210. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  211. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  212. package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
  213. package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
  214. package/apps/studio/client/v2/shell/api-session.js +126 -0
  215. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  216. package/apps/studio/client/v2/shell/floating-panels.css +31 -1
  217. package/apps/studio/client/v2/shell/image-pick.js +61 -8
  218. package/apps/studio/client/v2/shell/menu-aim.js +43 -0
  219. package/apps/studio/client/v2/shell/menu-runner.js +25 -7
  220. package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
  221. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  222. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  223. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  224. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  225. package/apps/studio/client/v2/shell/project-account.css +237 -0
  226. package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
  227. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  228. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  229. package/apps/studio/client/v2/shell/shell-parity.json +71 -36
  230. package/apps/studio/client/v2/shell/still-bridge.js +194 -0
  231. package/apps/studio/client/v2/shell/still-store.js +319 -0
  232. package/apps/studio/client/v2/shell/use-account.js +2 -0
  233. package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
  234. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  235. package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
  236. package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
  237. package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
  238. package/apps/studio/clip-ops.ts +126 -8
  239. package/apps/studio/cloud/endpoints.ts +29 -4
  240. package/apps/studio/collab/ai-activity.ts +10 -8
  241. package/apps/studio/collab/awareness-bridge.ts +34 -9
  242. package/apps/studio/collab/index.ts +3 -0
  243. package/apps/studio/collab/registry.ts +41 -10
  244. package/apps/studio/comment-reattach.ts +149 -0
  245. package/apps/studio/comments/mine-stamp.ts +15 -7
  246. package/apps/studio/comments/ops.ts +52 -8
  247. package/apps/studio/comments-overlay.tsx +146 -9
  248. package/apps/studio/dist/client.bundle.js +892 -885
  249. package/apps/studio/dist/comment-mount.js +2 -2
  250. package/apps/studio/dist/styles.css +1 -1
  251. package/apps/studio/dom-selection.ts +87 -18
  252. package/apps/studio/ds/board/directions.css +8 -0
  253. package/apps/studio/ds/board/outline.tsx +16 -0
  254. package/apps/studio/ds/canvas-check.ts +6 -0
  255. package/apps/studio/edit-ops/clip/reframe.ts +19 -3
  256. package/apps/studio/edit-ops/clip-carry.ts +602 -0
  257. package/apps/studio/edit-ops/clipboard.ts +318 -23
  258. package/apps/studio/edit-ops/dispatch.ts +20 -2
  259. package/apps/studio/edit-ops/scope-names.ts +249 -40
  260. package/apps/studio/edit-ops/slot-defaults.ts +3 -0
  261. package/apps/studio/edit-ops/types.ts +6 -0
  262. package/apps/studio/editing/align-bar.tsx +33 -9
  263. package/apps/studio/editing/artboard-actions.ts +5 -0
  264. package/apps/studio/editing/artboard-menu.tsx +6 -2
  265. package/apps/studio/editing/click-to-type.ts +1 -1
  266. package/apps/studio/editing/clip-words.ts +48 -0
  267. package/apps/studio/editing/clipboard.ts +21 -6
  268. package/apps/studio/editing/declared-background.ts +25 -0
  269. package/apps/studio/editing/index.tsx +3 -0
  270. package/apps/studio/editing/object-keys.ts +4 -4
  271. package/apps/studio/editing/object-menu.tsx +13 -3
  272. package/apps/studio/editing/pen/points.tsx +61 -0
  273. package/apps/studio/editing/text-in-place.tsx +11 -0
  274. package/apps/studio/editing/video-frame-handle.tsx +425 -0
  275. package/apps/studio/exporters/capture-prepass.ts +374 -0
  276. package/apps/studio/exporters/degraded.ts +148 -0
  277. package/apps/studio/exporters/hub-render-door.ts +28 -2
  278. package/apps/studio/exporters/index.ts +3 -1
  279. package/apps/studio/exporters/job-budget.ts +93 -0
  280. package/apps/studio/exporters/jobs.ts +215 -28
  281. package/apps/studio/exporters/parity-check.ts +254 -0
  282. package/apps/studio/exporters/remote.ts +209 -15
  283. package/apps/studio/exporters/svg-inline.ts +87 -0
  284. package/apps/studio/exporters/video-render-lib.ts +88 -26
  285. package/apps/studio/exporters/video.ts +29 -6
  286. package/apps/studio/figma/assets.ts +58 -43
  287. package/apps/studio/figma/codegen-fonts.ts +100 -0
  288. package/apps/studio/figma/fig-decode.ts +390 -25
  289. package/apps/studio/figma/fig-kiwi.ts +18 -4
  290. package/apps/studio/figma/fig-vector.ts +59 -3
  291. package/apps/studio/figma/sanitize.ts +2 -0
  292. package/apps/studio/figma/style-map.ts +293 -48
  293. package/apps/studio/figma/to-artboard.ts +455 -69
  294. package/apps/studio/figma/to-strokes.ts +44 -11
  295. package/apps/studio/figma/types.ts +13 -0
  296. package/apps/studio/footage/schema.ts +3 -3
  297. package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
  298. package/apps/studio/generation/adapters/groq.ts +8 -1
  299. package/apps/studio/generation/spend.ts +312 -0
  300. package/apps/studio/generation/types.ts +12 -0
  301. package/apps/studio/handoff/run.ts +1 -1
  302. package/apps/studio/handoff/targets.ts +2 -2
  303. package/apps/studio/handoff/write-scopes.ts +1 -1
  304. package/apps/studio/history/describe-annotations.ts +4 -0
  305. package/apps/studio/home/accounts.ts +30 -11
  306. package/apps/studio/home/cloud.ts +6 -1
  307. package/apps/studio/home/create-local.ts +32 -3
  308. package/apps/studio/home/hub-health.ts +76 -0
  309. package/apps/studio/home/routes.ts +15 -4
  310. package/apps/studio/http.ts +438 -86
  311. package/apps/studio/imported-module-ids.ts +91 -0
  312. package/apps/studio/inspect.ts +2 -0
  313. package/apps/studio/migrate/hub.ts +8 -1
  314. package/apps/studio/notifications.tsx +47 -5
  315. package/apps/studio/paths.ts +10 -1
  316. package/apps/studio/port.ts +3 -2
  317. package/apps/studio/preview/preview-camera.tsx +15 -382
  318. package/apps/studio/readiness.ts +10 -1
  319. package/apps/studio/release-build.ts +51 -0
  320. package/apps/studio/routes/agent.ts +188 -9
  321. package/apps/studio/routes/ai.ts +43 -11
  322. package/apps/studio/routes/annotations.ts +27 -1
  323. package/apps/studio/routes/assets.ts +18 -1
  324. package/apps/studio/routes/canvas-origin.ts +12 -9
  325. package/apps/studio/routes/cloud-move.ts +15 -0
  326. package/apps/studio/routes/edit.ts +3 -0
  327. package/apps/studio/routes/export.ts +51 -0
  328. package/apps/studio/routes/generate.ts +42 -12
  329. package/apps/studio/routes/hub-link-folder.ts +334 -0
  330. package/apps/studio/routes/hub-signin.ts +78 -1
  331. package/apps/studio/routes/index.ts +9 -1
  332. package/apps/studio/routes/shell.ts +217 -5
  333. package/apps/studio/routes/sync.ts +136 -8
  334. package/apps/studio/routes/votes.ts +2 -1
  335. package/apps/studio/schema/annotations.v2.schema.json +143 -1
  336. package/apps/studio/schema/beats.v1.schema.json +1 -1
  337. package/apps/studio/schema/edl.v1.schema.json +1 -1
  338. package/apps/studio/schema/formats.ts +3 -3
  339. package/apps/studio/schema/transcript.v1.schema.json +1 -1
  340. package/apps/studio/server.ts +142 -43
  341. package/apps/studio/shell/api-key.ts +503 -0
  342. package/apps/studio/shell/attest.ts +59 -0
  343. package/apps/studio/shell/capture-url.ts +20 -0
  344. package/apps/studio/shell/cli-yield.ts +276 -0
  345. package/apps/studio/shell/clip-transfer.ts +302 -0
  346. package/apps/studio/shell/key-file.ts +108 -0
  347. package/apps/studio/shell/server-json.ts +75 -0
  348. package/apps/studio/shell/worktree.ts +19 -0
  349. package/apps/studio/spoof-chars.ts +9 -0
  350. package/apps/studio/studio-page-host.ts +1 -1
  351. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  352. package/apps/studio/sync/accepted-link.ts +76 -29
  353. package/apps/studio/sync/action-stage.ts +575 -44
  354. package/apps/studio/sync/adopt-held.ts +85 -0
  355. package/apps/studio/sync/ctl-heal.ts +58 -0
  356. package/apps/studio/sync/file-ledger.ts +38 -4
  357. package/apps/studio/sync/file-membership.ts +16 -1
  358. package/apps/studio/sync/file-plane.ts +289 -22
  359. package/apps/studio/sync/held-deletes.ts +86 -5
  360. package/apps/studio/sync/hub-link.ts +8 -0
  361. package/apps/studio/sync/index.ts +196 -12
  362. package/apps/studio/sync/journal-client.ts +50 -4
  363. package/apps/studio/sync/link-consent.ts +22 -75
  364. package/apps/studio/sync/link-survey.ts +252 -0
  365. package/apps/studio/sync/local-kernel.ts +296 -8
  366. package/apps/studio/sync/projection.ts +22 -3
  367. package/apps/studio/sync/seed-progress.ts +12 -0
  368. package/apps/studio/sync/source-recovery.ts +59 -3
  369. package/apps/studio/sync/status.ts +19 -2
  370. package/apps/studio/sync/unsynced-refs.ts +397 -0
  371. package/apps/studio/sync/writer-registry.ts +20 -0
  372. package/apps/studio/thumbs/service.ts +4 -1
  373. package/apps/studio/tool-palette.tsx +23 -0
  374. package/apps/studio/ui-prefs.ts +40 -0
  375. package/apps/studio/use-agent-presence.tsx +2 -2
  376. package/apps/studio/use-canvas-keys.ts +6 -1
  377. package/apps/studio/video/format-ids.ts +2 -2
  378. package/apps/studio/video/inject.ts +31 -0
  379. package/apps/studio/video/media-risk.ts +58 -0
  380. package/apps/studio/video/object-fit.ts +137 -0
  381. package/apps/studio/video/provider-transcript.ts +141 -0
  382. package/apps/studio/whats-new.json +137 -0
  383. package/apps/studio/workspace-mode.ts +1 -0
  384. package/apps/studio/ws.ts +5 -0
  385. package/cli/commands/design.mjs +119 -8
  386. package/cli/lib/bash-guard.mjs +366 -6
  387. package/cli/lib/confine-read.mjs +1 -0
  388. package/cli/lib/design-help.gen.mjs +3 -2
  389. package/cli/lib/design-hook.mjs +387 -81
  390. package/cli/lib/design-link.mjs +16 -1
  391. package/cli/lib/design-open.mjs +49 -3
  392. package/cli/lib/desktop-locate.mjs +770 -0
  393. package/cli/lib/handoff.mjs +1 -1
  394. package/cli/lib/hook-state.mjs +291 -0
  395. package/cli/lib/pkg-root.mjs +65 -13
  396. package/cli/lib/studio-locate.mjs +59 -16
  397. package/package.json +15 -8
  398. package/plugins/design/templates/_shell.html +13 -0
  399. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  400. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  401. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -78,10 +78,16 @@ export const STILL_MAX_DECODING = 4;
78
78
  /** Kept for callers: drawings are paced by the frame budget now, not by a gap. */
79
79
  export const STILL_TAKE_GAP_MS = 50;
80
80
  /**
81
- * The stills kept in memory, in bytes of bitmap (w × h × 4). Past it the least recently used still that is not
82
- * standing in right now is dropped (an artboard released far away shows its own-colour placeholder again).
81
+ * The DECODED tier (#212): the stills kept as bitmaps, in bytes (w × h × 4). Past it the least recently used still
82
+ * that is not standing in right now leaves THIS tier only — its encoded copy stays, so it comes back as a still.
83
+ * Stills are 400 px wide at most now (0.35–1.4 MB each), so 48 MB holds ~35–140 of them.
83
84
  */
84
- export const STILL_CACHE_MAX_BYTES = 96 * 1024 * 1024;
85
+ export const STILL_CACHE_MAX_BYTES = 48 * 1024 * 1024;
86
+ /**
87
+ * The ENCODED tier (#212): every still as a WebP blob (~20–60 kB), never evicted by the decoded LRU. Only this cap
88
+ * drops one (oldest first) — 88 artboards are under 5 MB, so it is a safety net, not a working limit.
89
+ */
90
+ export const STILL_ENCODED_MAX_BYTES = 64 * 1024 * 1024;
85
91
  /** The attribute the article carries while its stand-in shows (`cover` | `still` | `paint` | `reveal`). */
86
92
  export const STILL_ATTR = 'data-dc-still';
87
93
  /**
@@ -188,24 +194,119 @@ export function contentSignature(body: {
188
194
  return `${(h >>> 0).toString(36)}:${s.length}:${body.offsetWidth}x${body.offsetHeight}`;
189
195
  }
190
196
 
191
- /** One kept still: its bitmap, the signature it was drawn from, its size in bytes, and when it was last used. */
197
+ /**
198
+ * One kept still. `el` is the decoded bitmap (null once the decoded tier let go of it); `blob` the encoded copy
199
+ * (null until it is encoded, or when no encoder exists); `bytes` the decoded size, remembered across a restore.
200
+ */
192
201
  export interface CachedStill {
193
- el: HTMLElement;
202
+ el: HTMLElement | null;
203
+ blob: Blob | null;
194
204
  sig: string;
195
205
  bytes: number;
196
206
  used: number;
207
+ /** the order its blob was stored in (the encoded tier drops the smallest first) */
208
+ order: number;
209
+ /** its encode is queued or running: the decoded tier does not drop it before it has a copy to restore from */
210
+ encoding: boolean;
211
+ url: string | null;
212
+ }
213
+
214
+ export interface StillCacheOptions {
215
+ /** the encoded tier's byte cap */
216
+ encodedMax?: number;
217
+ /** a decoded still → its encoded copy (null: none) */
218
+ encode?: (el: HTMLElement) => Promise<Blob | null>;
219
+ /** an encoded copy → a decoded still, not yet in the document (null: it cannot) */
220
+ decode?: (blob: Blob) => Promise<HTMLElement | null>;
221
+ objectUrl?: { make(blob: Blob): string; revoke(url: string): void };
197
222
  }
198
223
 
199
224
  /**
200
- * The stills of this canvas document, by artboard id — kept when an artboard's children are released, so it comes
201
- * back as its still rather than a placeholder, and across an edit's soft reload (the runtime lives on the document).
202
- * Bounded by `STILL_CACHE_MAX_BYTES`; what stands in right now (`inUse`) is never dropped.
225
+ * The default encoder: WebP at 0.8 off a canvas (a missing `toBlob`, or one that never answers, is "no copy").
226
+ * WebKit (Safari, the desktop app) has no WebP encoder and answers `image/png`: the blob keeps that type, and the
227
+ * persist lane checks and labels the bytes by what they are (bridge/still-webp.ts `checkStillImage`).
228
+ */
229
+ function defaultEncode(el: HTMLElement): Promise<Blob | null> {
230
+ const c = el as HTMLCanvasElement;
231
+ if (typeof c.toBlob !== 'function') return Promise.resolve(null);
232
+ return new Promise((res) => {
233
+ const t = setTimeout(() => res(null), 4000);
234
+ try {
235
+ c.toBlob(
236
+ (b) => {
237
+ clearTimeout(t);
238
+ res(b);
239
+ },
240
+ 'image/webp',
241
+ 0.8
242
+ );
243
+ } catch {
244
+ clearTimeout(t);
245
+ res(null);
246
+ }
247
+ });
248
+ }
249
+
250
+ /** The default decoder: the blob into a canvas the size of the picture. */
251
+ async function defaultDecode(blob: Blob): Promise<HTMLElement | null> {
252
+ if (typeof createImageBitmap !== 'function' || typeof document === 'undefined') return null;
253
+ try {
254
+ const bmp = await createImageBitmap(blob);
255
+ const c = document.createElement('canvas');
256
+ c.width = bmp.width;
257
+ c.height = bmp.height;
258
+ c.getContext('2d')?.drawImage(bmp, 0, 0);
259
+ bmp.close?.();
260
+ return c;
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
265
+
266
+ const defaultObjectUrl = {
267
+ make: (b: Blob) => URL.createObjectURL(b),
268
+ revoke: (u: string) => URL.revokeObjectURL(u),
269
+ };
270
+
271
+ /**
272
+ * The stills of this canvas document, by artboard id, in two tiers (#212) — kept when an artboard's children are
273
+ * released, so it comes back as its still rather than a placeholder, and across an edit's soft reload (the runtime
274
+ * lives on the document).
275
+ * - decoded: the bitmaps, an LRU bounded by `max` bytes; what stands in right now (`inUse`) is never dropped;
276
+ * - encoded: a WebP copy of each, made once the still exists, never touched by the decoded LRU (its own cap,
277
+ * oldest first). A still that leaves the decoded tier stays known (`peek` has it, `el` null) and `restore`
278
+ * decodes it again — so a still that was drawn never falls back to a blank.
279
+ * Without an encoder (a document that cannot make one) a still dropped from the decoded tier is gone, as before.
203
280
  */
204
281
  export class StillCache {
205
282
  private map = new Map<string, CachedStill>();
206
283
  private bytes = 0;
284
+ private encBytes = 0;
207
285
  private tick = 0;
208
- constructor(readonly max = STILL_CACHE_MAX_BYTES) {}
286
+ private order = 0;
287
+ private readonly encodedMax: number;
288
+ private readonly encode: (el: HTMLElement) => Promise<Blob | null>;
289
+ private readonly decode: (blob: Blob) => Promise<HTMLElement | null>;
290
+ private readonly objectUrl: NonNullable<StillCacheOptions['objectUrl']>;
291
+ private readonly customEncode: boolean;
292
+ private encQueue: string[] = [];
293
+ private encRunning = false;
294
+ private restoring = new Map<string, Promise<HTMLElement | null>>();
295
+ private evictListeners = new Set<(id: string) => void>();
296
+ /** #212 §5 — persisted stills not yet checked against their artboard (outside `map`: nothing shows them) */
297
+ private seeds = new Map<string, { blob: Blob; sig: string }>();
298
+ private seedBytes = 0;
299
+ private encodedListeners = new Set<(id: string, blob: Blob, sig: string) => void>();
300
+ constructor(
301
+ readonly max = STILL_CACHE_MAX_BYTES,
302
+ o: StillCacheOptions = {}
303
+ ) {
304
+ this.encodedMax = o.encodedMax ?? STILL_ENCODED_MAX_BYTES;
305
+ this.customEncode = !!o.encode;
306
+ this.encode = o.encode ?? defaultEncode;
307
+ this.decode = o.decode ?? defaultDecode;
308
+ this.objectUrl = o.objectUrl ?? defaultObjectUrl;
309
+ }
209
310
  get(id: string): CachedStill | undefined {
210
311
  const c = this.map.get(id);
211
312
  if (c) c.used = ++this.tick;
@@ -221,35 +322,235 @@ export class StillCache {
221
322
  bytes: number,
222
323
  inUse: (id: string) => boolean
223
324
  ): void {
325
+ this.dropSeed(id); // a fresh drawing wins over a persisted one
224
326
  const old = this.map.get(id);
225
327
  if (old) {
226
- this.bytes -= old.bytes;
227
- if (old.el !== el) old.el.remove();
328
+ if (old.el) this.bytes -= old.bytes;
329
+ if (old.el && old.el !== el) old.el.remove();
330
+ this.dropBlob(old);
228
331
  }
229
- this.map.set(id, { el, sig, bytes, used: ++this.tick });
332
+ // an element that cannot be encoded (no `toBlob`, no custom encoder) has nothing to wait for
333
+ const encoding = this.customEncode || typeof (el as HTMLCanvasElement).toBlob === 'function';
334
+ this.map.set(id, {
335
+ el,
336
+ blob: null,
337
+ sig,
338
+ bytes,
339
+ used: ++this.tick,
340
+ order: 0,
341
+ encoding,
342
+ url: null,
343
+ });
230
344
  this.bytes += bytes;
345
+ this.trim(id, inUse);
346
+ if (encoding) {
347
+ if (!this.encQueue.includes(id)) this.encQueue.push(id);
348
+ this.pumpEncode();
349
+ }
350
+ }
351
+ /** The decoded tier over its cap: the least recently used still that does not stand in leaves it. */
352
+ private trim(keep: string, inUse: (id: string) => boolean): void {
231
353
  if (this.bytes <= this.max) return;
232
354
  const victims = [...this.map.entries()]
233
- .filter(([k]) => k !== id && !inUse(k))
355
+ .filter(([k, v]) => k !== keep && v.el && !v.encoding && !inUse(k))
234
356
  .sort((a, b) => a[1].used - b[1].used);
235
357
  for (const [k, v] of victims) {
236
358
  if (this.bytes <= this.max) break;
237
- this.map.delete(k);
238
359
  this.bytes -= v.bytes;
239
- v.el.remove();
360
+ v.el?.remove();
361
+ v.el = null;
362
+ if (!v.blob) this.map.delete(k);
363
+ for (const fn of this.evictListeners) fn(k);
364
+ }
365
+ }
366
+ private pumpEncode(): void {
367
+ if (this.encRunning) return;
368
+ const id = this.encQueue.shift();
369
+ if (id === undefined) return;
370
+ const e = this.map.get(id);
371
+ const el = e?.el;
372
+ if (!e || !el) {
373
+ if (e) e.encoding = false;
374
+ this.pumpEncode();
375
+ return;
376
+ }
377
+ this.encRunning = true;
378
+ this.encode(el)
379
+ .catch(() => null)
380
+ .then((blob) => {
381
+ if (this.map.get(id) !== e) return;
382
+ e.encoding = false;
383
+ if (blob && blob.size > 0) {
384
+ this.dropBlob(e);
385
+ e.blob = blob;
386
+ e.order = ++this.order;
387
+ this.encBytes += blob.size;
388
+ this.trimEncoded(id);
389
+ // #212 §5 — a still this document drew of its current content: it may be kept across sessions
390
+ if (e.sig && this.map.get(id) === e)
391
+ for (const fn of this.encodedListeners) {
392
+ try {
393
+ fn(id, blob, e.sig);
394
+ } catch {}
395
+ }
396
+ }
397
+ })
398
+ .finally(() => {
399
+ this.encRunning = false;
400
+ // a gap between encodes: they must not stack up inside one frame
401
+ setTimeout(() => this.pumpEncode(), 0);
402
+ });
403
+ }
404
+ /** The encoded tier over its cap: the oldest copy goes (a still with no bitmap either is forgotten). */
405
+ private trimEncoded(keep: string): void {
406
+ if (this.encBytes <= this.encodedMax) return;
407
+ const victims = [...this.map.entries()]
408
+ .filter(([k, v]) => k !== keep && v.blob)
409
+ .sort((a, b) => a[1].order - b[1].order);
410
+ for (const [k, v] of victims) {
411
+ if (this.encBytes <= this.encodedMax) break;
412
+ this.dropBlob(v);
413
+ if (!v.el) this.map.delete(k);
414
+ }
415
+ }
416
+ private dropBlob(v: CachedStill): void {
417
+ if (v.blob) this.encBytes -= v.blob.size;
418
+ if (v.url) {
419
+ try {
420
+ this.objectUrl.revoke(v.url);
421
+ } catch {}
422
+ }
423
+ v.blob = null;
424
+ v.url = null;
425
+ }
426
+ /**
427
+ * The decoded still of `id`, decoding it from the encoded tier if the decoded tier let go of it (a second ask
428
+ * while it decodes shares the decode). Null when nothing can be restored (then the entry is forgotten).
429
+ */
430
+ restore(id: string, inUse: (id: string) => boolean = () => false): Promise<HTMLElement | null> {
431
+ const e = this.map.get(id);
432
+ if (!e) return Promise.resolve(null);
433
+ if (e.el) {
434
+ e.used = ++this.tick;
435
+ return Promise.resolve(e.el);
436
+ }
437
+ const going = this.restoring.get(id);
438
+ if (going) return going;
439
+ const blob = e.blob;
440
+ if (!blob) return Promise.resolve(null);
441
+ const p = this.decode(blob)
442
+ .catch(() => null)
443
+ .then((el) => {
444
+ this.restoring.delete(id);
445
+ if (this.map.get(id) !== e) return null;
446
+ if (e.el) return e.el;
447
+ if (!el) {
448
+ this.dropBlob(e);
449
+ this.map.delete(id);
450
+ return null;
451
+ }
452
+ e.el = el;
453
+ e.used = ++this.tick;
454
+ // a still adopted from a seed never had a decoded size: the bitmap's (canvas width × height × 4)
455
+ if (!e.bytes) e.bytes = elementBytes(el);
456
+ this.bytes += e.bytes;
457
+ this.trim(id, inUse);
458
+ return el;
459
+ });
460
+ this.restoring.set(id, p);
461
+ return p;
462
+ }
463
+ /** An object URL of the encoded copy (what a placeholder shows when the bitmap left the decoded tier). */
464
+ blobUrl(id: string): string | null {
465
+ const e = this.map.get(id);
466
+ if (!e?.blob) return null;
467
+ if (!e.url) {
468
+ try {
469
+ e.url = this.objectUrl.make(e.blob);
470
+ } catch {
471
+ return null;
472
+ }
240
473
  }
474
+ return e.url;
475
+ }
476
+ /** A bitmap left the decoded tier (the placeholder holding it shows the encoded copy instead). */
477
+ onEvict(fn: (id: string) => void): () => void {
478
+ this.evictListeners.add(fn);
479
+ return () => this.evictListeners.delete(fn);
241
480
  }
242
481
  /** The content changed under a kept still: it may still stand in (better than nothing), but is redrawn. */
243
482
  stale(id: string): void {
244
483
  const c = this.map.get(id);
245
484
  if (c) c.sig = '';
246
485
  }
247
- stats(): { n: number; bytes: number } {
248
- return { n: this.map.size, bytes: this.bytes };
486
+ stats(): { n: number; bytes: number; encoded: number; encodedBytes: number } {
487
+ let encoded = 0;
488
+ for (const v of this.map.values()) if (v.blob) encoded += 1;
489
+ return { n: this.map.size, bytes: this.bytes, encoded, encodedBytes: this.encBytes };
249
490
  }
250
491
  ids(): string[] {
251
492
  return [...this.map.keys()];
252
493
  }
494
+ /**
495
+ * #212 §5 — a persisted still of `id` (the shell's answer), with the content signature it was drawn from. Kept
496
+ * OUTSIDE the cache until `adopt` checks it against the artboard's own body: no placeholder, `hasStill` or warm-up
497
+ * sees a seed. Refused when the artboard already has a still, the signature is empty, or the seeds would pass the
498
+ * encoded tier's cap.
499
+ */
500
+ seed(id: string, blob: Blob, sig: string): boolean {
501
+ if (!sig || this.map.has(id) || !(blob?.size > 0)) return false;
502
+ this.dropSeed(id);
503
+ if (this.seedBytes + blob.size > this.encodedMax) return false;
504
+ this.seeds.set(id, { blob, sig });
505
+ this.seedBytes += blob.size;
506
+ return true;
507
+ }
508
+ hasSeed(id: string): boolean {
509
+ return this.seeds.has(id);
510
+ }
511
+ /**
512
+ * The seed of `id` becomes its kept still (encoded only; `restore` decodes it) iff it was drawn from the same
513
+ * content: `sig` = the artboard body's signature now. The seed is used up either way — a stale one is dropped.
514
+ */
515
+ adopt(id: string, sig: string): boolean {
516
+ const s = this.seeds.get(id);
517
+ if (!s) return false;
518
+ this.dropSeed(id);
519
+ if (!sig || s.sig !== sig || this.map.has(id)) return false;
520
+ this.map.set(id, {
521
+ el: null,
522
+ blob: s.blob,
523
+ sig,
524
+ bytes: 0,
525
+ used: ++this.tick,
526
+ order: ++this.order,
527
+ encoding: false,
528
+ url: null,
529
+ });
530
+ this.encBytes += s.blob.size;
531
+ this.trimEncoded(id);
532
+ return this.map.has(id);
533
+ }
534
+ private dropSeed(id: string): void {
535
+ const s = this.seeds.get(id);
536
+ if (!s) return;
537
+ this.seedBytes -= s.blob.size;
538
+ this.seeds.delete(id);
539
+ }
540
+ seedIds(): string[] {
541
+ return [...this.seeds.keys()];
542
+ }
543
+ /** #212 §5 — a still this document drew got its encoded copy (`sig` non-empty: drawn from the current content). */
544
+ onEncoded(fn: (id: string, blob: Blob, sig: string) => void): () => void {
545
+ this.encodedListeners.add(fn);
546
+ return () => this.encodedListeners.delete(fn);
547
+ }
548
+ }
549
+
550
+ /** The bytes a decoded still holds (a canvas: width × height × 4; anything else: 0). */
551
+ function elementBytes(el: HTMLElement): number {
552
+ const c = el as HTMLCanvasElement;
553
+ return typeof c.width === 'number' && typeof c.height === 'number' ? c.width * c.height * 4 : 0;
253
554
  }
254
555
 
255
556
  /** What the controller needs from one artboard's DOM (an adapter, so tests need no canvas). */
@@ -284,6 +585,8 @@ interface Entry {
284
585
  wasLive: boolean;
285
586
  /** its drawing in flight */
286
587
  job: Current | null;
588
+ /** its kept still is being decoded from the encoded tier */
589
+ restoring: boolean;
287
590
  }
288
591
 
289
592
  /** The drawing in flight (one at a time). */
@@ -504,16 +807,25 @@ export class StillController {
504
807
  observer: null,
505
808
  wasLive: false,
506
809
  job: null,
810
+ restoring: false,
507
811
  };
508
812
  e.observer = this.observe ? this.observe(target.body, (why) => this.markDirty(id, why)) : null;
509
813
  this.entries.set(id, e);
814
+ // #212 §5 — a persisted still (a seed) stands in only for the very content it was drawn from
815
+ if (this.cache.hasSeed(id)) this.cache.adopt(id, this.sigOf(target.body));
510
816
  // A fresh mount: it has painted nothing yet. Under the cut it starts as its kept still (or the cover) with the
511
817
  // body hidden before its first paint; over the cut it starts as a hand-over from that stand-in.
512
818
  const kept = this.cache.get(id);
513
- if (kept) this.putStill(e, kept.el);
819
+ if (kept?.el) this.putStill(e, kept.el);
514
820
  const small = this.small(e, this.zoom);
515
- if (small && !e.pinned && !e.eager) this.setView(e, kept ? 'still' : 'cover');
516
- else if (kept) this.handOver(e, true);
821
+ // #169 T8.1b (decision A): mid-zoom, a mount over the cut that has a kept still shows that still and is handed
822
+ // over at the settle (reconcileAll queues it) — a hand-over now would lay out and paint the body mid-zoom
823
+ const held = !!kept && this.zooming;
824
+ if ((small || held) && !e.pinned && !e.eager) {
825
+ this.setView(e, kept?.el ? 'still' : 'cover');
826
+ // a still the decoded tier let go of: decoded again from the encoded copy, never drawn again (#212)
827
+ if (kept && !kept.el) this.restoreFor(e);
828
+ } else if (kept?.el) this.handOver(e, true);
517
829
  else e.wasLive = true;
518
830
  this.schedulePump();
519
831
  return () => {
@@ -521,6 +833,28 @@ export class StillController {
521
833
  };
522
834
  }
523
835
 
836
+ /**
837
+ * #212 §5 — the persisted stills came in after their artboards mounted: each mounted artboard with no still on
838
+ * screen adopts its seed when the signatures match (a drawing in flight for it is dropped) and is restored from it.
839
+ */
840
+ adoptSeeds(): void {
841
+ for (const e of this.entries.values()) {
842
+ if (e.shown || !this.cache.hasSeed(e.id)) continue;
843
+ if (!this.cache.adopt(e.id, this.sigOf(e.target.body))) continue;
844
+ if (e.job) this.dropJob(e.job);
845
+ if (this.small(e, this.zoom) && !e.pinned && !e.eager) this.restoreFor(e);
846
+ }
847
+ this.schedulePump();
848
+ }
849
+
850
+ private sigOf(body: HTMLElement): string {
851
+ try {
852
+ return this.signature(body);
853
+ } catch {
854
+ return '';
855
+ }
856
+ }
857
+
524
858
  private unregister(id: string): void {
525
859
  const e = this.entries.get(id);
526
860
  if (!e) return;
@@ -605,6 +939,17 @@ export class StillController {
605
939
  this.schedulePump();
606
940
  }
607
941
 
942
+ /**
943
+ * #169 T8.1b (decision A) — may this artboard's first mount wait for the settle? While a zoom is in flight, one
944
+ * with a kept still keeps showing it (its placeholder holds that still), so its body mounts, lays out and paints
945
+ * only at the settle: still → live is a settle change, never a mid-zoom one. No still: never (a placeholder with
946
+ * nothing better is a block the user sees — v2-207-drop-undercut-midgesture-wait); a pure pan: never. The mount
947
+ * ring keeps the exemptions (the active artboard, a video one).
948
+ */
949
+ holdsForSettle(id: string): boolean {
950
+ return this.zooming && !!this.cache.peek(id);
951
+ }
952
+
608
953
  /** Is the zoom in flight (diagnostics)? */
609
954
  engaged(): boolean {
610
955
  return this.gestureZoom !== null;
@@ -978,6 +1323,10 @@ export class StillController {
978
1323
  if (sig && kept && kept.sig === sig) {
979
1324
  e.dirty = false;
980
1325
  this.takes.reused += 1;
1326
+ if (!kept.el) {
1327
+ this.restoreFor(e);
1328
+ return true;
1329
+ }
981
1330
  if (e.shown !== kept.el) this.putStill(e, kept.el);
982
1331
  this.afterTake(e);
983
1332
  for (const fn of this.stillListeners) fn(e.id, true);
@@ -1008,6 +1357,27 @@ export class StillController {
1008
1357
  return true;
1009
1358
  }
1010
1359
 
1360
+ /** Decode the entry's kept still from the encoded tier and stand it in (a failed decode: drawn again). */
1361
+ private restoreFor(e: Entry): void {
1362
+ if (e.restoring) return;
1363
+ e.restoring = true;
1364
+ void this.cache
1365
+ .restore(e.id, (k) => this.entries.has(k))
1366
+ .then((el) => {
1367
+ e.restoring = false;
1368
+ if (this.entries.get(e.id) !== e) return;
1369
+ if (!el) {
1370
+ e.dirty = true;
1371
+ e.readyAt = this.now();
1372
+ this.schedulePump();
1373
+ return;
1374
+ }
1375
+ if (!e.shown) this.putStill(e, el);
1376
+ this.afterTake(e);
1377
+ for (const fn of this.stillListeners) fn(e.id, true);
1378
+ });
1379
+ }
1380
+
1011
1381
  private finishJob(c: Current): void {
1012
1382
  const e = c.e;
1013
1383
  if (e.job === c) e.job = null;
@@ -0,0 +1,154 @@
1
+ // asset-added.ts — who brought an asset into the project, as every peer sees it (#172; contract
2
+ // client/v2/contracts/172-asset-origins.md).
3
+ //
4
+ // `assets/<name>.added.json` — `{ "format": "maude.added", "v": 1, "by": "Tereza", "at": "2026-11-08T09:12:00Z" }`
5
+ // (`<name>` = the asset's full file name, `d34bb59d.jpg`; records written before burndown F6 used the stem up to the
6
+ // first dot, `d34bb59d.added.json` — still read, see `legacyAddedRelOf`).
7
+ //
8
+ // Versioned project content: a companion sidecar of the asset (file plane `companion-text`, both classifier copies), so
9
+ // it syncs, moves to the Trash and renames with its asset. It holds a DISPLAY NAME only — never a path (that stays in
10
+ // the per-Mac `_canvas-state/asset-origins.json`), never an e-mail, never an account id. Write-once: the first person who
11
+ // brought the bytes in is the one who added them; the same bytes again are the same asset and keep the record.
12
+ //
13
+ // Peer-synced, so untrusted on read: small, the right format and version, a clean name — else absent. It is a CLAIM by
14
+ // someone who could write the project, not a proof (contract 172 § Trust).
15
+ //
16
+ // Leaf module (node:fs / node:path + the leaf asset-origins.ts; erasable TypeScript) — the CLI imports it under bun.
17
+
18
+ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
19
+ import path from 'node:path';
20
+ import { cleanOriginBy } from './asset-origins.ts';
21
+ import { assetKindOf } from './index/extractors/asset-usage.ts';
22
+
23
+ export const ADDED_SUFFIX = '.added.json';
24
+ export const ADDED_FORMAT = 'maude.added';
25
+ /** A record past this is not one we wrote. */
26
+ export const ADDED_MAX_BYTES = 4096;
27
+
28
+ export interface AssetAdded {
29
+ /** a display name ("Tereza") */
30
+ by: string;
31
+ /** ISO-8601 UTC, when the record has one */
32
+ at?: string;
33
+ }
34
+
35
+ const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
36
+
37
+ /** A flat file under assets/ (asset-details.ts DETAIL_ASSET_REL): no folder, no `..`, no leading dot. */
38
+ const ASSET_REL = /^assets\/([A-Za-z0-9_][A-Za-z0-9 ._-]*)$/;
39
+
40
+ const assetNameOf = (assetRel: unknown): string | null => {
41
+ if (typeof assetRel !== 'string') return null;
42
+ return ASSET_REL.exec(assetRel.replace(/^\.?\/+/, ''))?.[1] ?? null;
43
+ };
44
+
45
+ /**
46
+ * `assets/<name>` → `assets/<name>.added.json`, keyed by the FULL file name (burndown F6: `logo.png` and `logo.v2.svg`
47
+ * share the stem `logo`, so a stem key let one asset's record speak for the other). It rides trash and rename as a
48
+ * sidecar (asset-trash `sidecarsOf`, asset-rename's `<base>.` rule). Null for anything that is not a flat asset name.
49
+ */
50
+ export function addedRelOf(assetRel: unknown): string | null {
51
+ const name = assetNameOf(assetRel);
52
+ return name ? `assets/${name}${ADDED_SUFFIX}` : null;
53
+ }
54
+
55
+ /** The pre-F6 name `assets/<stem>.added.json` (stem = up to the first dot); read, never written. */
56
+ export function legacyAddedRelOf(assetRel: unknown): string | null {
57
+ const stem = assetNameOf(assetRel)?.split('.')[0] ?? '';
58
+ return stem ? `assets/${stem}${ADDED_SUFFIX}` : null;
59
+ }
60
+
61
+ /** Does another asset in `assets/` share `name`'s stem? Then a stem-keyed record cannot say whose it is. */
62
+ function stemShared(designRoot: string, name: string): boolean {
63
+ const stem = name.split('.')[0];
64
+ try {
65
+ return readdirSync(path.join(designRoot, 'assets')).some(
66
+ (n) => n !== name && n.split('.')[0] === stem && assetKindOf(n) !== null
67
+ );
68
+ } catch {
69
+ return false;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Where this asset's record is: the full-name file, else an older stem-keyed one that no other asset could claim.
75
+ * Null when there is none to read.
76
+ */
77
+ function recordFileOf(designRoot: string, assetRel: string): string | null {
78
+ const rel = addedRelOf(assetRel);
79
+ const name = assetNameOf(assetRel);
80
+ if (!rel || !name) return null;
81
+ const file = path.join(designRoot, ...rel.split('/'));
82
+ if (existsSync(file)) return file;
83
+ const legacy = legacyAddedRelOf(assetRel);
84
+ if (!legacy || legacy === rel || stemShared(designRoot, name)) return null;
85
+ const old = path.join(designRoot, ...legacy.split('/'));
86
+ return existsSync(old) ? old : null;
87
+ }
88
+
89
+ /**
90
+ * The name to write for a person: an e-mail becomes the words of its local part ("tereza.novak@…" → "Tereza Novak",
91
+ * the history `displayNameOf` rule), a machine actor (`local:…`, `operator`, `anon`) names nobody. Null when nothing
92
+ * fit to show is left.
93
+ */
94
+ export function addedByName(raw: unknown): string | null {
95
+ if (typeof raw !== 'string') return null;
96
+ let v = raw.trim();
97
+ if (!v || /^local:/.test(v) || v === 'operator' || v === 'anon') return null;
98
+ const at = v.indexOf('@');
99
+ if (at >= 0) {
100
+ v = v
101
+ .slice(0, at)
102
+ .split(/[._+-]+/)
103
+ .filter(Boolean)
104
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
105
+ .join(' ');
106
+ }
107
+ return cleanOriginBy(v.slice(0, 80));
108
+ }
109
+
110
+ /** The record beside `assets/<sha8>.<ext>`, or null (none, unreadable, or not one this version reads). */
111
+ export function readAssetAdded(designRoot: string, assetRel: string): AssetAdded | null {
112
+ const file = recordFileOf(designRoot, assetRel);
113
+ if (!file) return null;
114
+ try {
115
+ const st = statSync(file);
116
+ if (!st.isFile() || st.size > ADDED_MAX_BYTES) return null;
117
+ const j = JSON.parse(readFileSync(file, 'utf8')) as Record<string, unknown> | null;
118
+ if (!j || typeof j !== 'object' || Array.isArray(j)) return null;
119
+ if (j.format !== ADDED_FORMAT || j.v !== 1) return null;
120
+ const by = cleanOriginBy(j.by);
121
+ if (!by) return null;
122
+ return typeof j.at === 'string' && ISO.test(j.at) ? { by, at: j.at } : { by };
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Say that `who` brought `assets/<sha8>.<ext>` in. Write-once: an existing record (even one this version cannot read)
130
+ * is never replaced. Never throws — a record that cannot be kept is a missing line, not a failed import. Returns
131
+ * whether this call wrote the file.
132
+ */
133
+ export function recordAssetAdded(
134
+ designRoot: string,
135
+ assetRel: string,
136
+ who: unknown,
137
+ now: number = Date.now()
138
+ ): boolean {
139
+ const rel = addedRelOf(assetRel);
140
+ const by = addedByName(who);
141
+ if (!rel || !by) return false;
142
+ // Write-once across both names: an older stem-keyed record that is this asset's is the first person.
143
+ if (recordFileOf(designRoot, assetRel) !== null) return false;
144
+ const file = path.join(designRoot, ...rel.split('/'));
145
+ try {
146
+ const doc = { format: ADDED_FORMAT, v: 1, by, at: new Date(now).toISOString() };
147
+ // `wx`: an exclusive create IS the write-once rule (a record already there, or one racing in, wins). No temp file
148
+ // beside it: `assets/` is on the file plane and a stray temp name would be offered to peers.
149
+ writeFileSync(file, `${JSON.stringify(doc)}\n`, { flag: 'wx' });
150
+ return true;
151
+ } catch {
152
+ return false;
153
+ }
154
+ }