@1agh/maude 2.0.3 → 2.0.6

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 (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -28,6 +28,7 @@ import { execFileSync } from 'node:child_process';
28
28
  import { appendFileSync, mkdirSync } from 'node:fs';
29
29
  import { dirname } from 'node:path';
30
30
 
31
+ import { resolveAgentBrowserBin } from './_agent-browser-bin.mjs';
31
32
  import {
32
33
  buildRow,
33
34
  emptyViewportRefusal,
@@ -39,7 +40,7 @@ import {
39
40
  renderReport,
40
41
  } from './_perf-shared.mjs';
41
42
 
42
- const AB = process.env.MAUDE_AGENT_BROWSER || 'agent-browser';
43
+ const AB = resolveAgentBrowserBin();
43
44
 
44
45
  // agent-browser is a SHARED singleton by default: a concurrent session running
45
46
  // its own smoke sweep will navigate the same tab out from under a measurement
@@ -7,7 +7,12 @@
7
7
 
8
8
  import { mkdirSync } from 'node:fs';
9
9
  import { dirname, join } from 'node:path';
10
- import { launchChromium, newShellContext, safeArtboardFilename } from './_pw-launch.mjs';
10
+ import {
11
+ afterPaint,
12
+ launchChromium,
13
+ newShellContext,
14
+ safeArtboardFilename,
15
+ } from './_pw-launch.mjs';
11
16
  import { layoutRegion, parseRegionArg } from './_region.mjs';
12
17
 
13
18
  const args = Object.fromEntries(
@@ -201,6 +206,8 @@ try {
201
206
  const vp = page.viewportSize();
202
207
  const clipX = Math.min(Math.max(0, Math.floor(finalRect.x)), Math.max(0, vp.width - 1));
203
208
  const clipY = Math.min(Math.max(0, Math.floor(finalRect.y)), Math.max(0, vp.height - 1));
209
+ // Shoot a frame painted at this size and position, never the previous surface (afterPaint).
210
+ await afterPaint(page);
204
211
  await page.screenshot({
205
212
  ...shotOpts,
206
213
  path: target,
@@ -232,6 +239,8 @@ try {
232
239
  const box = await layoutRegion(page, region);
233
240
  assertOutputSizeOk(box.width, box.height);
234
241
  await page.setViewportSize({ width: Math.max(1, box.width), height: Math.max(1, box.height) });
242
+ // Shoot a frame painted at this size and position, never the previous surface (afterPaint).
243
+ await afterPaint(page);
235
244
  await page.screenshot({
236
245
  ...shotOpts,
237
246
  path: out,
@@ -153,6 +153,20 @@ export function safeArtboardFilename(id, index, ext) {
153
153
  return `${safe}.${ext}`;
154
154
  }
155
155
 
156
+ // fix/204-capture-parity — wait until the page has produced a frame AFTER its last layout change
157
+ // (a viewport resize, the world plane moved to the origin) before a raster shot. Taken at once,
158
+ // headless Chromium can hand `page.screenshot` the compositor's previous surface: stale raster
159
+ // tiles of the 1440×900 page repeated across the small viewport. Nothing on an idle canvas page
160
+ // requests a frame by itself, so the shot must. The first callback runs before the frame that
161
+ // carries the change, the second after it was produced. `_ds-prove-playwright.mjs` and
162
+ // `_tile-draw.mjs` already wait the same way.
163
+ export async function afterPaint(page) {
164
+ await page.evaluate(
165
+ () =>
166
+ new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())))
167
+ );
168
+ }
169
+
156
170
  // Shared by every raster-capture export shim (_png/_pdf-playwright.mjs) that
157
171
  // scales its render surface by `deviceScaleFactor` (feature-2-print-artboards
158
172
  // T4's DPI support). The requested pixel output is only knowable once the
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { randomBytes } from 'node:crypto';
12
12
  import { isAbsolute, relative, resolve, sep } from 'node:path';
13
- import { DESIGN_REL, findProjectRoot, locateStudio } from '../../../cli/lib/studio-locate.mjs';
13
+ import { DESIGN_REL, findProjectRoot, probeStudio } from '../../../cli/lib/studio-locate.mjs';
14
14
 
15
15
  export { DESIGN_REL };
16
16
 
@@ -66,8 +66,23 @@ export function canvasRepoRel(root, canvas) {
66
66
  return `${DESIGN_REL}/${rel.split(sep).join('/')}`;
67
67
  }
68
68
 
69
+ /** How long `/_health` gets, and how often it is asked, before a live studio counts as busy. */
70
+ export const HEALTH_TIMEOUT_MS = 3000;
71
+ export const HEALTH_ATTEMPTS = 3;
72
+
69
73
  /** The studio serving `root`, or null. */
70
- export const studioFor = (root) => locateStudio(root, { timeoutMs: 1500 });
74
+ export const studioFor = async (root) => (await studioState(root)).studio ?? null;
75
+
76
+ /** `{ studio }` | `{ state: 'none' | 'busy' }` (#13: a studio under load is not "not running"). */
77
+ export const studioState = (root, env = process.env) =>
78
+ probeStudio(root, {
79
+ timeoutMs:
80
+ Number(env.MAUDE_HEALTH_TIMEOUT_MS) > 0
81
+ ? Number(env.MAUDE_HEALTH_TIMEOUT_MS)
82
+ : HEALTH_TIMEOUT_MS,
83
+ attempts: HEALTH_ATTEMPTS,
84
+ retryDelayMs: 500,
85
+ });
71
86
 
72
87
  /**
73
88
  * p8-a1-claims — a write names the chat this shell is (`MAUDE_CHAT_ID`, set per chat by the ACP spawn):
@@ -209,7 +224,13 @@ export async function connect(name, rootFlag) {
209
224
  );
210
225
  return { exit: 2 };
211
226
  }
212
- const studio = await studioFor(root);
227
+ const { studio, state } = await studioState(root);
228
+ if (!studio && state === 'busy') {
229
+ process.stderr.write(
230
+ `maude design ${name}: the Maude studio for this project is busy — it is running but did not answer in time. Wait a moment and try again.\n`
231
+ );
232
+ return { exit: 3 };
233
+ }
213
234
  if (!studio) {
214
235
  process.stderr.write(
215
236
  `maude design ${name}: no Maude studio is running for this project. Open it in Maude (or \`maude design serve\`) and try again.\n`
@@ -0,0 +1,70 @@
1
+ // _thumb-blank.mjs — "is this cover a blank card?" for the thumbnail renderer (2.0.5 W5).
2
+ //
3
+ // A cover that is one flat colour (an empty viewport, a canvas that drew nothing, the page's own
4
+ // background) is worse than no cover: Home would cache it as a fresh hit and never look again.
5
+ // The renderer asks this of every JPEG it is about to hand back; the server treats `blank: true` as
6
+ // a retryable miss (thumbs/service.ts), so Home keeps its placeholder instead.
7
+ //
8
+ // The check runs on a BLANK page (`about:blank`) — never on the canvas page, whose code is untrusted
9
+ // (DDR-054) — by decoding the JPEG in the browser (the shim has no image library), shrinking it to
10
+ // 64 px wide and counting how much of it is the single most common colour (4 bits per channel, so
11
+ // JPEG noise on a flat area still counts as flat). It is "blank" only when that colour is white or the
12
+ // canvas's own background (what an unpainted viewport shows): a design that is one deliberate colour
13
+ // (a dark hero, a brand-colour poster) is a cover.
14
+
15
+ /** more than this share of one colour = blank. A text-only slice of a white page stays well under. */
16
+ export const BLANK_SHARE = 0.99;
17
+
18
+ /** Runs in the page: base64 JPEG → { share of the most common colour (0..1), its rgb }, or null when it cannot decode. */
19
+ export async function dominantShare(b64) {
20
+ try {
21
+ const bin = atob(b64);
22
+ const u8 = new Uint8Array(bin.length);
23
+ for (let i = 0; i < bin.length; i++) u8[i] = bin.charCodeAt(i);
24
+ const bmp = await createImageBitmap(new Blob([u8], { type: 'image/jpeg' }));
25
+ const w = Math.min(64, bmp.width);
26
+ const h = Math.max(1, Math.round((w * bmp.height) / bmp.width));
27
+ const c = new OffscreenCanvas(w, h);
28
+ const g = c.getContext('2d', { willReadFrequently: true });
29
+ g.drawImage(bmp, 0, 0, w, h);
30
+ const px = g.getImageData(0, 0, w, h).data;
31
+ const counts = new Map();
32
+ let top = 0;
33
+ let topKey = 0;
34
+ for (let i = 0; i < px.length; i += 4) {
35
+ const k = ((px[i] >> 4) << 8) | ((px[i + 1] >> 4) << 4) | (px[i + 2] >> 4);
36
+ const n = (counts.get(k) ?? 0) + 1;
37
+ counts.set(k, n);
38
+ if (n > top) {
39
+ top = n;
40
+ topKey = k;
41
+ }
42
+ }
43
+ // the bucket's centre
44
+ const rgb = [(topKey >> 8) & 15, (topKey >> 4) & 15, topKey & 15].map((v) => v * 16 + 8);
45
+ return { share: top / (w * h), rgb };
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+
51
+ const NEAR = 24;
52
+ const near = (a, b) => a.every((v, i) => Math.abs(v - b[i]) <= NEAR);
53
+
54
+ /**
55
+ * `page` must be on about:blank; `bg` = the canvas page's background colour as [r, g, b] (or null).
56
+ * true = blank, false = has content, null = could not tell (kept).
57
+ */
58
+ export async function isBlankCover(page, b64, bg = null) {
59
+ const r = await page.evaluate(dominantShare, b64).catch(() => null);
60
+ if (!r || typeof r.share !== 'number') return null;
61
+ if (r.share <= BLANK_SHARE) return false;
62
+ return near(r.rgb, [255, 255, 255]) || (Array.isArray(bg) && near(r.rgb, bg));
63
+ }
64
+
65
+ /** "rgb(22, 24, 29)" / "rgba(…)" → [22, 24, 29]; a transparent or unparsable value → null. */
66
+ export function parseRgb(css) {
67
+ const m = /^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(String(css));
68
+ if (!m || (m[4] !== undefined && Number(m[4]) === 0)) return null;
69
+ return [Number(m[1]), Number(m[2]), Number(m[3])];
70
+ }
@@ -0,0 +1,35 @@
1
+ // _thumb-cover.mjs — which artboard is a canvas's cover (C31, W5). Pure: the thumbnail renderer
2
+ // (`_thumbs-playwright.mjs`) imports it, and the tests import it without starting a browser.
3
+
4
+ /** An artboard worth being a cover: not a sliver (a header strip, a divider) — a cover is shown at ~16:10. */
5
+ export const MIN_COVER_SIDE = 80;
6
+ export const MAX_COVER_ASPECT = 5;
7
+ export const coverWorthy = (r) =>
8
+ (r.w ?? 0) >= MIN_COVER_SIDE &&
9
+ (r.h ?? 0) >= MIN_COVER_SIDE &&
10
+ Math.max(r.w / r.h, r.h / r.w) <= MAX_COVER_ASPECT;
11
+
12
+ /** The first of `rects` row by row, left to right. */
13
+ export function topLeft(rects) {
14
+ if (!rects.length) return null;
15
+ const minY = Math.min(...rects.map((r) => r.y));
16
+ const minH = Math.min(...rects.map((r) => r.h ?? 0).filter((h) => h > 0), 1);
17
+ const top = rects.filter((r) => r.y < minY + minH / 2);
18
+ return top.sort((a, b) => a.x - b.x)[0]?.id ?? rects[0].id;
19
+ }
20
+
21
+ /**
22
+ * C31: the first artboard in "Order and notes…" when set (that always wins), else the top-left one among
23
+ * those worth a cover (W5: a 480 x 42 header slice or a 3320 x 200 strip is not one — the phone below it
24
+ * is). null when none is: the caller then shows the board, or falls back to `pickAny`.
25
+ */
26
+ export function pickCover(rects, order) {
27
+ if (Array.isArray(order)) for (const id of order) if (rects.some((r) => r.id === id)) return id;
28
+ return topLeft(rects.filter(coverWorthy));
29
+ }
30
+
31
+ /** No artboard is worth a cover and there is no board: the biggest one beats a blank card. */
32
+ export function pickAny(rects) {
33
+ const big = [...rects].sort((a, b) => (b.w ?? 0) * (b.h ?? 0) - (a.w ?? 0) * (a.h ?? 0))[0];
34
+ return big?.id ?? null;
35
+ }
@@ -31,7 +31,9 @@
31
31
 
32
32
  import { createInterface } from 'node:readline';
33
33
 
34
- import { launchChromium } from './_pw-launch.mjs';
34
+ import { afterPaint, launchChromium } from './_pw-launch.mjs';
35
+ import { isBlankCover, parseRgb } from './_thumb-blank.mjs';
36
+ import { pickAny, pickCover } from './_thumb-cover.mjs';
35
37
  import { drawTile } from './_tile-draw.mjs';
36
38
 
37
39
  const MAX_PAGES = 4;
@@ -269,27 +271,80 @@ async function harvest(page) {
269
271
  return rows;
270
272
  }
271
273
 
272
- /** C31: the first artboard in "Order and notes…" when set, else row by row, left to right. */
273
- function pickCover(rects, order) {
274
- if (Array.isArray(order)) for (const id of order) if (rects.some((r) => r.id === id)) return id;
275
- if (!rects.length) return null;
276
- const minY = Math.min(...rects.map((r) => r.y));
277
- const minH = Math.min(...rects.map((r) => r.h ?? 0).filter((h) => h > 0), 1);
278
- const top = rects.filter((r) => r.y < minY + minH / 2);
279
- return top.sort((a, b) => a.x - b.x)[0]?.id ?? rects[0].id;
280
- }
281
-
282
274
  async function shoot(page, job, index, target, runtime, left) {
283
275
  const t0 = performance.now();
284
276
  const px = Math.max(16, Math.min(2048, Math.trunc(Number(target.px) || 480)));
285
277
  let id = target.artboard == null ? null : String(target.artboard);
286
278
  const domIds = runtime.map((a) => a.id);
279
+ // W5: a cover with no artboard worth showing is the BOARD (the annotation layer, which lives in the
280
+ // world beside the artboards, not in `#canvas-root`'s flow) — or, with no board, the biggest artboard
281
+ let board = false;
287
282
  if (id === null && domIds.length) id = pickCover(runtime, job.coverOrder);
288
283
  else if (id !== null && !domIds.includes(id)) return { target: index, missing: true };
284
+ if (id === null && target.artboard == null) {
285
+ board = await page.evaluate(
286
+ () => document.querySelector('[data-mdcc-annotations] .dc-annot-el') !== null
287
+ );
288
+ if (!board && domIds.length) id = pickAny(runtime);
289
+ }
289
290
 
290
291
  const box = await page.evaluate(
291
- ([abId, size]) => {
292
+ ([abId, size, boardMode]) => {
292
293
  const world = document.querySelector('.dc-world');
294
+ if (boardMode && world) {
295
+ // The bounds of everything drawn in the world, in WORLD units: the annotation layer's elements
296
+ // are absolutely placed with inline left/top and carry their size on the geometry svg (their own
297
+ // boxes measure 0 x 0); artboards are real boxes. No transform is read, so the pan/zoom the page
298
+ // happens to be in does not matter.
299
+ let x0 = Number.POSITIVE_INFINITY;
300
+ let y0 = Number.POSITIVE_INFINITY;
301
+ let x1 = Number.NEGATIVE_INFINITY;
302
+ let y1 = Number.NEGATIVE_INFINITY;
303
+ const add = (x, y, w, h) => {
304
+ if (![x, y, w, h].every(Number.isFinite)) return;
305
+ x0 = Math.min(x0, x);
306
+ y0 = Math.min(y0, y);
307
+ x1 = Math.max(x1, x + Math.max(1, w));
308
+ y1 = Math.max(y1, y + Math.max(1, h));
309
+ };
310
+ // `?hide-chrome=1` hides the annotation layer (an export must not carry it, capture-chrome.ts); a
311
+ // board cover IS that layer, so this one capture puts it back (an inline !important beats the sheet's)
312
+ for (const scene of world.querySelectorAll('[data-mdcc-annotations]'))
313
+ scene.style.setProperty('display', 'block', 'important');
314
+ const px = (v) => Number.parseFloat(v);
315
+ for (const el of world.querySelectorAll('.dc-annot-el')) {
316
+ const vb = el.querySelector(':scope > svg.dc-annot-geo')?.viewBox?.baseVal;
317
+ if (vb && vb.width > 0 && vb.height > 0) add(vb.x, vb.y, vb.width, vb.height);
318
+ else
319
+ add(
320
+ px(el.style.left),
321
+ px(el.style.top),
322
+ px(el.style.width) || 160,
323
+ px(el.style.height) || 40
324
+ );
325
+ }
326
+ for (const el of world.querySelectorAll('[data-dc-screen]'))
327
+ add(el.offsetLeft, el.offsetTop, el.offsetWidth, el.offsetHeight);
328
+ if (!(x1 > x0 && y1 > y0)) return null;
329
+ const bw = x1 - x0;
330
+ const bh = y1 - y0;
331
+ const z = Math.min(1, size / bw);
332
+ world.style.zoom = '1';
333
+ world.style.transformOrigin = '0 0';
334
+ world.style.transform = 'none';
335
+ const o = world.getBoundingClientRect(); // where the world's origin sits in the page
336
+ world.style.transform = `translate(${-x0 * z}px, ${-y0 * z}px) scale(${z})`;
337
+ window.scrollTo(0, 0);
338
+ const cw = Math.min(bw * z, size);
339
+ // a cover is 1 : 0.5 .. 1 : 0.625 — a short, wide board gets some of the canvas below it, a tall
340
+ // one its top (the clip is cut from the board's own top-left corner)
341
+ return {
342
+ x: o.left,
343
+ y: o.top,
344
+ w: cw,
345
+ h: Math.max(cw * 0.5, Math.min(bh * z, (cw * 10) / 16)),
346
+ };
347
+ }
293
348
  if (abId !== null) {
294
349
  const abs = [...document.querySelectorAll('[data-dc-screen]')];
295
350
  const ab = abs.find((a) => a.getAttribute('data-dc-screen') === abId);
@@ -320,7 +375,7 @@ async function shoot(page, job, index, target, runtime, left) {
320
375
  const cw = Math.min(b.width, size);
321
376
  return { x: b.left, y: b.top, w: cw, h: Math.min(b.height, (cw * 10) / 16) };
322
377
  },
323
- [id, px]
378
+ [id, px, board]
324
379
  );
325
380
  if (!box) return { target: index, missing: id !== null };
326
381
 
@@ -369,6 +424,9 @@ async function shoot(page, job, index, target, runtime, left) {
369
424
  if (seek !== true) partial = true;
370
425
  }
371
426
  assertOrigin(page, job);
427
+ // 2.0.4: the viewport was just resized — wait for a painted frame, or headless Chromium can hand back
428
+ // the previous one (the PNG shim's parity flake, decision v2-204-capture-waits-painted-frame).
429
+ await afterPaint(page);
372
430
  const jpeg = await page.screenshot({
373
431
  type: 'jpeg',
374
432
  quality: 80,
@@ -500,6 +558,26 @@ async function render(msg) {
500
558
  const shots = [];
501
559
  for (const [i, t] of targets.entries()) shots.push(await shoot(page, job, i, t, runtime, left));
502
560
  lap('shoot');
561
+ // W5: a flat-colour picture is a miss, not a cover — checked on a blank page, never on the canvas's
562
+ const pics = shots.filter((sh) => typeof sh.jpeg === 'string');
563
+ if (pics.length) {
564
+ // the colour an unpainted viewport shows: the canvas host's own background (read, then left behind)
565
+ const bg = parseRgb(
566
+ await bounded(
567
+ page.evaluate(() => {
568
+ for (const el of [document.querySelector('.dc-canvas'), document.body]) {
569
+ const c = el ? getComputedStyle(el).backgroundColor : '';
570
+ if (c && c !== 'rgba(0, 0, 0, 0)') return c;
571
+ }
572
+ return '';
573
+ }),
574
+ 1000
575
+ )
576
+ );
577
+ await page.goto('about:blank').catch(() => {});
578
+ for (const sh of pics) if ((await isBlankCover(page, sh.jpeg, bg)) === true) sh.blank = true;
579
+ }
580
+ lap('blank');
503
581
  return {
504
582
  phases,
505
583
  ok: true,
@@ -666,6 +744,8 @@ async function handle(msg) {
666
744
  try {
667
745
  send({ id, ...(await (msg.op === 'tile' ? tile(msg) : render(msg))) });
668
746
  } catch (e) {
747
+ if (process.env.MAUDE_THUMBS_DEBUG)
748
+ process.stderr.write(`render failed: ${String(e?.stack ?? e)}\n`);
669
749
  const code =
670
750
  e?.code === 'origin' || e?.code === 'canvas-failed'
671
751
  ? e.code
@@ -14,6 +14,10 @@
14
14
  # ds-check.sh --hook --canvas <file> # PostToolUse mode: always exit 0, hook JSON
15
15
  # ds-check.sh --root <project> # default: $CLAUDE_PROJECT_DIR, else the current directory
16
16
  #
17
+ # The canvas modes also ask the project's running studio (127.0.0.1 only) which canvases it refused after
18
+ # their build — a canvas that uses a file another canvas owns — and print why; with no studio they say so
19
+ # and print the import-walk reasons only. `--json` carries `studio` (true/false) and `refusedInputs`.
20
+ #
17
21
  # Structure only — presence, per-theme presence, value TYPE, name/type collisions. Values,
18
22
  # ordering and aesthetics are never judged (A14, DDR-043); they surface as notes.
19
23
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -24,7 +28,7 @@ if ! command -v bun >/dev/null 2>&1; then
24
28
  fi
25
29
 
26
30
  case "$1" in
27
- --help|-h) sed -n '2,18p' "$0" | sed 's/^# \?//'; exit 0 ;;
31
+ --help|-h) sed -n '2,21p' "$0" | sed 's/^# \?//'; exit 0 ;;
28
32
  esac
29
33
 
30
34
  exec bun run "$SCRIPT_DIR/_ds-check.mjs" "$@"
@@ -18,7 +18,7 @@
18
18
  # [--pan N] [--zoom N] [--timeout S] [--repeat N]
19
19
  # [--engine chromium|safari] [--studio] [--fit-all]
20
20
  # [--window WxH] [--frame today|pinned|full|WxH] [--compare-frame <same>]
21
- # [--variant <tag>] [--inject-css <css>]
21
+ # [--variant <tag>] [--inject-css <css>] [--query <k=v&…>]
22
22
  # [--history <path>] [--json]
23
23
  #
24
24
  # --engine safari measures WebKit through safaridriver (one-time
@@ -50,6 +50,8 @@
50
50
  # difference. Refuses (exit 1) when the two geometries showed a
51
51
  # different number of artboards on screen — not the same content.
52
52
  # --variant A label for an A/B arm; keys the history row with the canvas.
53
+ # --query Extra canvas-page parameters for an A/B arm on the bare page (not --studio), e.g.
54
+ # `artboard-live=off` vs `artboard-live=sleep` (2.0.5 heavy canvases). Letters, digits, `=&_-` only.
53
55
  # --inject-css CSS injected into the canvas document before each pass, to
54
56
  # test a rendering hypothesis against the same build.
55
57
  #
@@ -110,6 +112,7 @@ while [ $# -gt 0 ]; do
110
112
  --compare-frame) COMPARE_FRAME="$2"; shift 2 ;;
111
113
  --variant) VARIANT="$2"; shift 2 ;;
112
114
  --inject-css) INJECT_CSS="$2"; shift 2 ;;
115
+ --query) QUERY="$2"; shift 2 ;;
113
116
  --help|-h)
114
117
  sed -n '2,/^[^#]/p' "$0" | sed '$d' | sed -E 's/^# ?//'
115
118
  exit 0
@@ -227,6 +230,13 @@ esac
227
230
  # or `%` would otherwise truncate or rewrite the query string.
228
231
  REL_ENC=$("$JS_RUNTIME" -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$REL_FULL")
229
232
  URL="http://localhost:${PORT}/_canvas-shell.html?canvas=${REL_ENC}"
233
+ if [ -n "${QUERY:-}" ]; then
234
+ case "$QUERY" in
235
+ *[!A-Za-z0-9=\&_-]*) echo "perf.sh: --query takes letters, digits and = & _ - only" >&2; exit 2 ;;
236
+ esac
237
+ [ "$STUDIO" = "1" ] && { echo "perf.sh: --query applies to the bare canvas page, not --studio" >&2; exit 2; }
238
+ URL="${URL}&${QUERY}"
239
+ fi
230
240
  . "$SCRIPT_DIR/_url-guard.sh" && maude_url_guard "$URL" || exit 2 # V2-8.9 B2 — http(s) to this Mac only
231
241
 
232
242
  # ---------- history path ----------
@@ -89,8 +89,13 @@ fi
89
89
  if [ -n "$SERVER_BIN" ]; then
90
90
  _sbase="$(basename "$SERVER_BIN")"
91
91
  _sparent="$(basename "$(dirname "$SERVER_BIN")")"
92
- case "$_sbase:$_sparent" in
93
- maude:maude-* | maude.exe:maude-*) : ;;
92
+ # fix/ds-convert-hooks-cli #13 — or the desktop app's own bundled server, which the sidecar
93
+ # hands every helper (sidecar.rs, DDR-166 T0b): <Name>.app/Contents/MacOS/maude-server.
94
+ _sapp="$(basename "$(dirname "$(dirname "$(dirname "$SERVER_BIN")")")")"
95
+ _scontents="$(basename "$(dirname "$(dirname "$SERVER_BIN")")")"
96
+ case "$_sbase:$_sparent:$_scontents:$_sapp" in
97
+ maude:maude-*:*:* | maude.exe:maude-*:*:*) : ;;
98
+ maude-server:MacOS:Contents:*.app) : ;;
94
99
  *)
95
100
  echo "server-up.sh: ignoring dev-server binary outside the expected maude-<slug>/ layout ($SERVER_BIN) — falling back to source" >&2
96
101
  SERVER_BIN=""
@@ -538,6 +538,25 @@ while IFS= read -r CANVAS; do
538
538
  printf '%s\t%s\t%s\t%s\n' "$STATUS" "$REL" "$SHOT" "$DETAIL"
539
539
  done <<< "$CANVASES"
540
540
 
541
+ # ---------- why a canvas is refused (2.0.5 #205) ----------
542
+ # A canvas that imports another canvas, or whose built module inlined a file another canvas owns, renders
543
+ # nothing in its frame. The server knows why (`/_index-data` canvasImportsCanvases + canvasRefusedInputs);
544
+ # say it here in the shell card's words, so the report is not a bare "error".
545
+ REASONS=""
546
+ if command -v bun >/dev/null 2>&1; then
547
+ REASONS=$(curl -fsS -m 5 "http://localhost:$PORT/_index-data" 2>/dev/null \
548
+ | bun "$(dirname "$0")/_canvas-reasons.mjs" 2>/dev/null)
549
+ fi
550
+ if [ -n "$REASONS" ]; then
551
+ printf '%s\n' "$REASONS" >&2
552
+ {
553
+ echo
554
+ echo "## Refused canvases"
555
+ echo
556
+ printf '%s\n' "$REASONS" | sed 's/^/- /'
557
+ } >> "$MD"
558
+ fi
559
+
541
560
  TOTAL_FAIL=$((FAILED + LINT_FAILED))
542
561
  {
543
562
  echo
@@ -0,0 +1,31 @@
1
+ // apps/studio/boot-progress.ts — #204: the boot tells its supervisor it is still moving.
2
+ //
3
+ // A cell's hub supervises this process (apps/hub/src/studio-child.mjs) and used to SIGKILL it when
4
+ // `/_health` had not answered within a fixed 60 s. A large workspace on a small cell boots slower
5
+ // than that, so the child was killed mid-boot and started over — twice — before it came up. The
6
+ // supervisor now kills only a child that has gone QUIET: each `[boot] <step>` line here moves its
7
+ // deadline (BOOT_PROGRESS_RE there), and a hard ceiling still ends one that never gets there.
8
+ //
9
+ // Printed only where something reads it: a workspace cell, or an explicit MAUDE_BOOT_PROGRESS=1.
10
+ // One line per boot step (a handful), none after the server listens.
11
+
12
+ const enabled = (env: NodeJS.ProcessEnv = process.env): boolean =>
13
+ env.MAUDE_WORKSPACE_MODE === '1' || env.MAUDE_BOOT_PROGRESS === '1';
14
+
15
+ let finished = false;
16
+
17
+ /** One boot step done. `label` is a fixed word from server.ts — never a path or tenant text. */
18
+ export function bootStep(label: string, out: (line: string) => void = console.log): void {
19
+ if (finished || !enabled()) return;
20
+ out(`[boot] ${label} +${Math.round(performance.now())}ms`);
21
+ }
22
+
23
+ /** The server listens: from here `/_health` is the signal, and nothing more is printed. */
24
+ export function bootFinished(out: (line: string) => void = console.log): void {
25
+ bootStep('listening', out);
26
+ finished = true;
27
+ }
28
+
29
+ // The first line, printed as this module is evaluated — the import graph has loaded by now, which
30
+ // on a cold cell is the longest single step of the boot.
31
+ bootStep('modules');