@1agh/maude 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/api.ts +76 -13
- package/apps/studio/client/app.jsx +63 -14
- package/apps/studio/client/panels/file-preview.jsx +93 -6
- package/apps/studio/client/styles/3-shell-maude.css +54 -2
- package/apps/studio/dist/client.bundle.js +744 -744
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/materialize-client.ts +75 -0
- package/apps/studio/sync/index.ts +38 -7
- package/apps/studio/whats-new.json +9 -0
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +132 -0
|
@@ -100,3 +100,78 @@ export function isCacheBlob(cacheDir: string, p: string): boolean {
|
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
/** How long one listing is reused. The tree reloads on every file event and
|
|
105
|
+
* every reconnect; the journal answer only changes when media is added or
|
|
106
|
+
* removed, which reaches the tree through those same events a moment later. */
|
|
107
|
+
const LIST_TTL_MS = 15_000;
|
|
108
|
+
let listCache: { at: number; base: string; rels: string[] } | null = null;
|
|
109
|
+
let listInflight: Promise<string[] | null> | null = null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Every inert-media path the hub can serve although this checkout may not
|
|
113
|
+
* hold it — designRoot-relative, `/`-separated. `null` when this is not a
|
|
114
|
+
* materializing cell (desktop, self-hosted hub) or the hub did not answer:
|
|
115
|
+
* the caller then lists the checkout alone, exactly as before.
|
|
116
|
+
*
|
|
117
|
+
* Paths only, and only as file-tree ROWS: serving any of them still goes
|
|
118
|
+
* through `materializeMissing`, which checks the hub's answer itself.
|
|
119
|
+
*/
|
|
120
|
+
export async function listMaterializable({
|
|
121
|
+
env = process.env,
|
|
122
|
+
fetchImpl = fetch,
|
|
123
|
+
now = Date.now,
|
|
124
|
+
}: {
|
|
125
|
+
env?: NodeJS.ProcessEnv;
|
|
126
|
+
fetchImpl?: typeof fetch;
|
|
127
|
+
now?: () => number;
|
|
128
|
+
} = {}): Promise<string[] | null> {
|
|
129
|
+
if (env.MAUDE_CELL_MATERIALIZE !== '1') return null;
|
|
130
|
+
const base = env.MAUDE_MATERIALIZE_URL;
|
|
131
|
+
const token = env.MAUDE_MATERIALIZE_TOKEN;
|
|
132
|
+
if (!base || !token) return null;
|
|
133
|
+
let url: URL;
|
|
134
|
+
try {
|
|
135
|
+
url = new URL('/_materialize', base);
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (url.protocol !== 'http:' || !LOOPBACK_HOSTS.has(url.hostname)) return null;
|
|
140
|
+
url.searchParams.set('list', '1');
|
|
141
|
+
if (listCache && listCache.base === base && now() - listCache.at < LIST_TTL_MS)
|
|
142
|
+
return listCache.rels;
|
|
143
|
+
if (listInflight) return listInflight;
|
|
144
|
+
listInflight = (async () => {
|
|
145
|
+
try {
|
|
146
|
+
const res = await fetchImpl(url, {
|
|
147
|
+
headers: { authorization: `Bearer ${token}` },
|
|
148
|
+
signal: AbortSignal.timeout(HOP_TIMEOUT_MS),
|
|
149
|
+
});
|
|
150
|
+
if (!res.ok) return listCache?.rels ?? null;
|
|
151
|
+
const body = (await res.json()) as { rels?: unknown };
|
|
152
|
+
const rels = Array.isArray(body?.rels)
|
|
153
|
+
? body.rels.filter(
|
|
154
|
+
(r): r is string =>
|
|
155
|
+
typeof r === 'string' &&
|
|
156
|
+
r.length > 0 &&
|
|
157
|
+
r.length < 1024 &&
|
|
158
|
+
!r.startsWith('/') &&
|
|
159
|
+
!r.split('/').some((seg) => seg === '' || seg === '.' || seg === '..')
|
|
160
|
+
)
|
|
161
|
+
: [];
|
|
162
|
+
listCache = { at: now(), base, rels };
|
|
163
|
+
return rels;
|
|
164
|
+
} catch {
|
|
165
|
+
return listCache?.rels ?? null;
|
|
166
|
+
} finally {
|
|
167
|
+
listInflight = null;
|
|
168
|
+
}
|
|
169
|
+
})();
|
|
170
|
+
return listInflight;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Test seam — forget the cached listing. */
|
|
174
|
+
export function resetMaterializableListCache(): void {
|
|
175
|
+
listCache = null;
|
|
176
|
+
listInflight = null;
|
|
177
|
+
}
|
|
@@ -260,6 +260,39 @@ export const DISCOVERY_DEBOUNCE_MS = 400;
|
|
|
260
260
|
*/
|
|
261
261
|
export const REMOTE_POLL_MS = 20_000;
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Does this studio run the FILE plane (Plane B) against its linked hub?
|
|
265
|
+
*
|
|
266
|
+
* NEVER inside a cell. The child shares the checkout with the hub it pairs
|
|
267
|
+
* with, so there is nothing to carry: the hub journals what the child writes
|
|
268
|
+
* (createCellWriteNudge + the walk), and it serves what the child is missing.
|
|
269
|
+
* This used to be left to an invariant — "every manifest entry is hash-equal
|
|
270
|
+
* by construction, so the pass skips itself" — which the cell materializer
|
|
271
|
+
* (DDR-243) ended: the disk is a cache, the bucket holds media the disk does
|
|
272
|
+
* not. A paired child then saw thousands of files "this peer is missing",
|
|
273
|
+
* pulled 200 a pass through its own hub onto the very disk the materializer
|
|
274
|
+
* keeps budgeted (most failing), and re-decided the whole set every 20 s — a
|
|
275
|
+
* multi-second event-loop stall on every poll that showed up as a file tree
|
|
276
|
+
* stuck at 0/0 and canvases slow to open (2026-10-02, alligators).
|
|
277
|
+
*
|
|
278
|
+
* Elsewhere `linkedHub.syncFiles: false` is the per-project opt-out and stays
|
|
279
|
+
* the documented rollback: a config key, not a terminal command (DDR-177).
|
|
280
|
+
*/
|
|
281
|
+
export function fileSyncEnabled({
|
|
282
|
+
linkedHub,
|
|
283
|
+
cellPairing,
|
|
284
|
+
env = process.env,
|
|
285
|
+
}: {
|
|
286
|
+
linkedHub: { syncFiles?: boolean };
|
|
287
|
+
cellPairing: boolean;
|
|
288
|
+
env?: NodeJS.ProcessEnv;
|
|
289
|
+
}): boolean {
|
|
290
|
+
if (cellPairing) return false;
|
|
291
|
+
return (
|
|
292
|
+
linkedHub.syncFiles !== false && (env.MAUDE_SYNC_FILES !== '0' || linkedHub.syncFiles === true)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
263
296
|
/** Floor between two serve-log seed-progress lines. Long enough not to become
|
|
264
297
|
* the next thing that buries the log. */
|
|
265
298
|
export const SEED_PROGRESS_LOG_MS = 15_000;
|
|
@@ -864,9 +897,7 @@ export function createSyncRuntime(
|
|
|
864
897
|
//
|
|
865
898
|
// `linkedHub.syncFiles: false` is the per-project opt-out and stays the
|
|
866
899
|
// documented rollback: a config key, not a terminal command (DDR-177).
|
|
867
|
-
const syncFilesOn =
|
|
868
|
-
linkedHub.syncFiles !== false &&
|
|
869
|
-
(process.env.MAUDE_SYNC_FILES !== '0' || linkedHub.syncFiles === true);
|
|
900
|
+
const syncFilesOn = fileSyncEnabled({ linkedHub, cellPairing: !!cellPairing });
|
|
870
901
|
// The gate for `code-module` entries — genuinely local state, at last.
|
|
871
902
|
//
|
|
872
903
|
// This used to read `storedRecord?.role === 'owner'`, described in the
|
|
@@ -4518,10 +4549,10 @@ export function createSyncRuntime(
|
|
|
4518
4549
|
* canvas that arrived this tick has its design system resolved in the
|
|
4519
4550
|
* same tick. Flag-gated; a no-op when off.
|
|
4520
4551
|
*
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
4523
|
-
*
|
|
4524
|
-
*
|
|
4552
|
+
* Never runs on a cell — `fileSyncEnabled()` turns the plane off there.
|
|
4553
|
+
* It used to rely on "the hub shares the checkout, so every entry is
|
|
4554
|
+
* hash-equal and the pass skips itself"; the materializer (DDR-243) made
|
|
4555
|
+
* the disk a cache and broke that invariant (see `fileSyncEnabled`).
|
|
4525
4556
|
*/
|
|
4526
4557
|
const pullFilesOnce = async (): Promise<void> => {
|
|
4527
4558
|
if (stopped || !syncFilesOn) return;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./whats-new.schema.json",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"id": "cloud-loading-states-and-faster-tree",
|
|
6
|
+
"version": "1.6.5",
|
|
7
|
+
"date": "2026-10-02",
|
|
8
|
+
"kind": "improvement",
|
|
9
|
+
"title": "Clear loading states in cloud projects",
|
|
10
|
+
"summary": "Opening a canvas now shows a loading screen until it is fully drawn, instead of a white page with stray comment pins. Photos in the file tree show a spinner and fetch themselves when the cloud is still bringing them in, fonts that loaded late repair themselves without a reload, and the file tree of a large cloud project lists every photo and no longer stalls.",
|
|
11
|
+
"surface": "design-ui"
|
|
12
|
+
},
|
|
4
13
|
{
|
|
5
14
|
"id": "cloud-projects-bigger-than-the-disk",
|
|
6
15
|
"version": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agh/maude",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Marketplace of Claude Code plugins by Michal Dovrtěl: `design` (canvas-first design iteration) + `flow` (generic agentic workflow loop with .ai second brain). Ships the `maude` CLI (with `mdcc` legacy alias) to scaffold workspace, run the design dev server, and manage configs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"test:e2e:desktop:parity:cloud": "pnpm --filter @maude/desktop-e2e e2e:parity:cloud"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@1agh/maude-darwin-arm64": "1.6.
|
|
62
|
-
"@1agh/maude-darwin-x64": "1.6.
|
|
63
|
-
"@1agh/maude-linux-arm64": "1.6.
|
|
64
|
-
"@1agh/maude-linux-arm64-musl": "1.6.
|
|
65
|
-
"@1agh/maude-linux-x64": "1.6.
|
|
66
|
-
"@1agh/maude-linux-x64-musl": "1.6.
|
|
67
|
-
"@1agh/maude-win32-x64": "1.6.
|
|
61
|
+
"@1agh/maude-darwin-arm64": "1.6.5",
|
|
62
|
+
"@1agh/maude-darwin-x64": "1.6.5",
|
|
63
|
+
"@1agh/maude-linux-arm64": "1.6.5",
|
|
64
|
+
"@1agh/maude-linux-arm64-musl": "1.6.5",
|
|
65
|
+
"@1agh/maude-linux-x64": "1.6.5",
|
|
66
|
+
"@1agh/maude-linux-x64-musl": "1.6.5",
|
|
67
|
+
"@1agh/maude-win32-x64": "1.6.5"
|
|
68
68
|
},
|
|
69
69
|
"files": [
|
|
70
70
|
"cli",
|
|
@@ -343,6 +343,12 @@
|
|
|
343
343
|
const el = document.getElementById('canvas-mount-error');
|
|
344
344
|
if (el) el.textContent = msg;
|
|
345
345
|
console.error('[canvas-shell]', msg);
|
|
346
|
+
// The studio keeps its loading screen up until the canvas reports
|
|
347
|
+
// rendered OR failed — tell it, so it drops the screen and this error
|
|
348
|
+
// is what the user reads instead of a spinner that never ends.
|
|
349
|
+
try {
|
|
350
|
+
window.parent.postMessage({ dgn: 'canvas-failed', file: designRel + '/' + (canvasRel || '') }, '*');
|
|
351
|
+
} catch (e) { /* parent gone */ }
|
|
346
352
|
}
|
|
347
353
|
|
|
348
354
|
// Spike finding M8 — a failed dynamic import throws a bare
|
|
@@ -670,6 +676,93 @@
|
|
|
670
676
|
}
|
|
671
677
|
connectHmr();
|
|
672
678
|
|
|
679
|
+
// HEAL WEBFONTS THAT FAILED ON A COLD CLOUD CACHE.
|
|
680
|
+
//
|
|
681
|
+
// On a cell the disk is a cache: the first request for a font the cell
|
|
682
|
+
// has not fetched yet makes the hub pull it from storage, and while that
|
|
683
|
+
// runs the static route answers 503 (retry shortly). An <img> is
|
|
684
|
+
// re-pointed when its bytes arrive (the asset-arrived handler above), but
|
|
685
|
+
// a CSS `@font-face` that failed stays failed for the life of the
|
|
686
|
+
// document — the canvas renders in a fallback serif until a reload, and
|
|
687
|
+
// which fonts lose the race differs every time ("the fonts are flaky").
|
|
688
|
+
//
|
|
689
|
+
// There is no way to re-run a CSS-connected FontFace, so a failed one is
|
|
690
|
+
// REPLACED: the same descriptors, read back from the stylesheet's own
|
|
691
|
+
// `@font-face` rule, with a cache-busting query on each url so the browser
|
|
692
|
+
// asks again. A face added through `document.fonts` is matched after the
|
|
693
|
+
// stylesheet's, so once it loads the text re-renders in it.
|
|
694
|
+
const fontHeal = { attempts: new Map(), timer: 0 };
|
|
695
|
+
const FONT_RETRY_DELAYS_MS = [1500, 3000, 5000, 8000, 12000, 20000];
|
|
696
|
+
const unquote = (s) => String(s || '').trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
697
|
+
function* fontFaceRules(rules) {
|
|
698
|
+
for (const rule of rules || []) {
|
|
699
|
+
if (typeof CSSFontFaceRule !== 'undefined' && rule instanceof CSSFontFaceRule) yield rule;
|
|
700
|
+
else if (rule.cssRules) yield* fontFaceRules(rule.cssRules);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function faceKey(family, weight, style, range) {
|
|
704
|
+
return [unquote(family), weight || '', style || '', range || ''].join('|');
|
|
705
|
+
}
|
|
706
|
+
function healFailedFonts() {
|
|
707
|
+
fontHeal.timer = 0;
|
|
708
|
+
if (!document.fonts) return;
|
|
709
|
+
const failed = new Set();
|
|
710
|
+
for (const f of document.fonts) {
|
|
711
|
+
if (f.status === 'error') failed.add(faceKey(f.family, f.weight, f.style, f.unicodeRange));
|
|
712
|
+
}
|
|
713
|
+
if (!failed.size) return;
|
|
714
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
715
|
+
let rules;
|
|
716
|
+
try { rules = sheet.cssRules; } catch (e) { continue; }
|
|
717
|
+
for (const rule of fontFaceRules(rules)) {
|
|
718
|
+
const st = rule.style;
|
|
719
|
+
const family = st.getPropertyValue('font-family');
|
|
720
|
+
const src = st.getPropertyValue('src');
|
|
721
|
+
if (!family || !src) continue;
|
|
722
|
+
const descriptors = {
|
|
723
|
+
weight: st.getPropertyValue('font-weight') || undefined,
|
|
724
|
+
style: st.getPropertyValue('font-style') || undefined,
|
|
725
|
+
stretch: st.getPropertyValue('font-stretch') || undefined,
|
|
726
|
+
unicodeRange: st.getPropertyValue('unicode-range') || undefined,
|
|
727
|
+
display: st.getPropertyValue('font-display') || undefined,
|
|
728
|
+
};
|
|
729
|
+
for (const k of Object.keys(descriptors)) if (!descriptors[k]) delete descriptors[k];
|
|
730
|
+
let probe;
|
|
731
|
+
try { probe = new FontFace(unquote(family), 'local("maude-probe")', descriptors); } catch (e) { continue; }
|
|
732
|
+
const key = faceKey(probe.family, probe.weight, probe.style, probe.unicodeRange);
|
|
733
|
+
if (!failed.has(key)) continue;
|
|
734
|
+
const n = (fontHeal.attempts.get(key) || 0) + 1;
|
|
735
|
+
if (n > FONT_RETRY_DELAYS_MS.length) continue;
|
|
736
|
+
fontHeal.attempts.set(key, n);
|
|
737
|
+
const base = sheet.href || document.baseURI;
|
|
738
|
+
const busted = src.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g, (whole, q, raw) => {
|
|
739
|
+
if (/^data:/i.test(raw)) return whole;
|
|
740
|
+
try {
|
|
741
|
+
const u = new URL(raw, base);
|
|
742
|
+
u.searchParams.set('font-retry', String(n));
|
|
743
|
+
return 'url("' + u.href.replace(/"/g, '%22') + '")';
|
|
744
|
+
} catch (e) { return whole; }
|
|
745
|
+
});
|
|
746
|
+
let face;
|
|
747
|
+
try { face = new FontFace(unquote(family), busted, descriptors); } catch (e) { continue; }
|
|
748
|
+
face.load().then(
|
|
749
|
+
() => {
|
|
750
|
+
document.fonts.add(face);
|
|
751
|
+
failed.delete(key);
|
|
752
|
+
},
|
|
753
|
+
() => scheduleFontHeal(FONT_RETRY_DELAYS_MS[n] || 0)
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function scheduleFontHeal(delay) {
|
|
759
|
+
if (!delay || fontHeal.timer) return;
|
|
760
|
+
fontHeal.timer = setTimeout(healFailedFonts, delay);
|
|
761
|
+
}
|
|
762
|
+
if (document.fonts && document.fonts.addEventListener) {
|
|
763
|
+
document.fonts.addEventListener('loadingerror', () => scheduleFontHeal(FONT_RETRY_DELAYS_MS[0]));
|
|
764
|
+
}
|
|
765
|
+
|
|
673
766
|
// NO TOP-LEVEL AWAIT IN THIS MODULE.
|
|
674
767
|
//
|
|
675
768
|
// The boot below used to `await` at the top level, which made this the
|
|
@@ -743,6 +836,45 @@
|
|
|
743
836
|
file: designRel + '/' + canvasRel,
|
|
744
837
|
commentsEnabled,
|
|
745
838
|
});
|
|
839
|
+
// The studio's loading screen stays up until this arrives — `loaded`
|
|
840
|
+
// (inspect.ts) only proves the shell document ran, which on a cold
|
|
841
|
+
// cloud canvas is seconds before anything is drawn, so dropping the
|
|
842
|
+
// screen there showed a white pane with bare comment pins. Wait for
|
|
843
|
+
// React to commit the canvas and for its fonts, so it does not appear
|
|
844
|
+
// in a fallback face and then jump. Capped: a font that never
|
|
845
|
+
// arrives must not hold the screen forever.
|
|
846
|
+
//
|
|
847
|
+
// NOT requestAnimationFrame: while the studio's opaque loading screen
|
|
848
|
+
// covers this cross-origin frame, Chrome throttles its frames, so a
|
|
849
|
+
// rAF-gated signal only ever arrived via the cap — the cover was
|
|
850
|
+
// waiting on itself. Timers and a forced layout run regardless.
|
|
851
|
+
let renderedSent = false;
|
|
852
|
+
const announceRendered = () => {
|
|
853
|
+
if (renderedSent) return;
|
|
854
|
+
renderedSent = true;
|
|
855
|
+
try {
|
|
856
|
+
window.parent.postMessage({ dgn: 'canvas-rendered', file: designRel + '/' + canvasRel }, '*');
|
|
857
|
+
} catch (e) { /* parent gone */ }
|
|
858
|
+
};
|
|
859
|
+
setTimeout(announceRendered, 8000);
|
|
860
|
+
const committed = new Promise((resolve) => {
|
|
861
|
+
const started = Date.now();
|
|
862
|
+
const tick = () => {
|
|
863
|
+
if ((rootEl && rootEl.children.length > 0) || Date.now() - started > 4000) resolve();
|
|
864
|
+
else setTimeout(tick, 40);
|
|
865
|
+
};
|
|
866
|
+
tick();
|
|
867
|
+
});
|
|
868
|
+
committed
|
|
869
|
+
.then(() => {
|
|
870
|
+
// Lay the canvas out now so the browser knows which fonts it
|
|
871
|
+
// uses and starts them — `fonts.ready` only waits on loads that
|
|
872
|
+
// have begun.
|
|
873
|
+
try { if (rootEl) rootEl.getBoundingClientRect(); void document.body.offsetHeight; } catch (e) {}
|
|
874
|
+
const fontsReady = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve();
|
|
875
|
+
return Promise.race([fontsReady, new Promise((r) => setTimeout(r, 3000))]);
|
|
876
|
+
})
|
|
877
|
+
.then(announceRendered, announceRendered);
|
|
746
878
|
// T2 (9.1-A) diagnostic — tell the parent the canvas mounted + how many
|
|
747
879
|
// root children it rendered. Lets the shell (and tooling) confirm a
|
|
748
880
|
// cross-origin canvas actually rendered, which a parent-page screenshot
|