@1agh/maude 2.0.3 → 2.0.4
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/README.md +6 -5
- package/apps/studio/access/request.ts +0 -1
- package/apps/studio/acp/adapter-stderr.ts +43 -13
- package/apps/studio/acp/background-tasks.ts +155 -0
- package/apps/studio/acp/bridge.ts +44 -5
- package/apps/studio/acp/connected-fact.ts +15 -4
- package/apps/studio/acp/index.ts +14 -5
- package/apps/studio/actions/agents.ts +5 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -1
- package/apps/studio/api.ts +31 -24
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
- package/apps/studio/boot-progress.ts +31 -0
- package/apps/studio/canvas-build-sandbox.ts +275 -42
- package/apps/studio/canvas-build-worker.ts +10 -0
- package/apps/studio/canvas-create.ts +24 -0
- package/apps/studio/canvas-module-cache.ts +93 -0
- package/apps/studio/canvas-source/errors.ts +39 -0
- package/apps/studio/canvas-source/waiting.ts +290 -0
- package/apps/studio/client/actions/shell-key-handlers.js +5 -0
- package/apps/studio/client/app.jsx +19 -9
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/home-api.js +30 -19
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
- package/apps/studio/client/hooks/use-tabs.jsx +64 -35
- package/apps/studio/client/index-loader.ts +23 -3
- package/apps/studio/client/panels/ChatPanel.jsx +22 -37
- package/apps/studio/client/panels/DiffView.jsx +314 -248
- package/apps/studio/client/panels/TeamProjects.jsx +119 -69
- package/apps/studio/client/panels/acp-runtime.js +25 -0
- package/apps/studio/client/panels/chat-finish.js +66 -0
- package/apps/studio/client/shell/frame-cap.js +53 -0
- package/apps/studio/client/shell/viewport.jsx +9 -0
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
- package/apps/studio/client/v2/ai/ai-run.css +87 -3
- package/apps/studio/client/v2/ai/background-model.js +113 -0
- package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
- package/apps/studio/client/v2/ai/run-api.js +7 -3
- package/apps/studio/client/v2/ai/runs-store.js +2 -1
- package/apps/studio/client/v2/annotations/vote-store.js +11 -5
- package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
- package/apps/studio/client/v2/assets/assets-bus.js +10 -8
- package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
- package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
- package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
- package/apps/studio/client/v2/assets/spotlight.css +153 -0
- package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
- package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
- package/apps/studio/client/v2/assets/tile.jsx +3 -0
- package/apps/studio/client/v2/assets/use-assets.js +2 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
- package/apps/studio/client/v2/canvases/covers.js +11 -5
- package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
- package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
- package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
- package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
- package/apps/studio/client/v2/canvases/use-pins.js +2 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
- package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
- package/apps/studio/client/v2/code/code.css +67 -0
- package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
- package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
- package/apps/studio/client/v2/create/name-dialog.css +10 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
- package/apps/studio/client/v2/ds/make-host.jsx +5 -2
- package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
- package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
- package/apps/studio/client/v2/empty/arriving.jsx +29 -12
- package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
- package/apps/studio/client/v2/empty/not-local.jsx +31 -1
- package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
- package/apps/studio/client/v2/export/last-finished.js +2 -1
- package/apps/studio/client/v2/history/git-model.js +18 -4
- package/apps/studio/client/v2/history/git-parts.jsx +60 -42
- package/apps/studio/client/v2/history/history.css +6 -0
- package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
- package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
- package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
- package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
- package/apps/studio/client/v2/search/search-recent.js +3 -1
- package/apps/studio/client/v2/search/search-remote.js +6 -4
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/shell/menu-runner.js +1 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/recovery-store.js +2 -1
- package/apps/studio/client/v2/shell/served-routes.js +120 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
- package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
- package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
- package/apps/studio/cloud/endpoints.ts +23 -1
- package/apps/studio/dist/client.bundle.js +977 -981
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/minimap-context.tsx +3 -3
- package/apps/studio/editing/page-activity.ts +251 -0
- package/apps/studio/editing/rotate-handle.tsx +9 -5
- package/apps/studio/editing/sticky-name.tsx +4 -4
- package/apps/studio/history/restore-artboard-action.ts +40 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/routes.ts +47 -8
- package/apps/studio/http.ts +117 -66
- package/apps/studio/index-flight.ts +40 -0
- package/apps/studio/managed-projects.ts +52 -24
- package/apps/studio/migrate/hub.ts +7 -1
- package/apps/studio/routes/canvas-source.ts +44 -2
- package/apps/studio/routes/history.ts +28 -5
- package/apps/studio/routes/hub-signin.ts +115 -0
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/table.ts +7 -0
- package/apps/studio/routes/trash.ts +3 -0
- package/apps/studio/server.ts +11 -0
- package/apps/studio/sync/accepted-cold-start.ts +26 -3
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-plane.ts +443 -77
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +73 -11
- package/apps/studio/sync/projection.ts +44 -2
- package/apps/studio/sync/pull-pacer.ts +160 -0
- package/apps/studio/sync/pull-priority.ts +119 -0
- package/apps/studio/sync/seed-progress.ts +47 -3
- package/apps/studio/sync/transaction-client.ts +71 -6
- package/apps/studio/sync/workspace-signin.ts +6 -256
- package/apps/studio/sync/writer-registry.ts +5 -1
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +54 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// POST /_api/project/restore { path, at | revision } → { ok, status, actionId? } · 409 (moved from http.ts)
|
|
5
5
|
// { path, at, artboard? | element? } · { path, at: '@last-good' }
|
|
6
6
|
// → { ok, actionId, line, sharedKept?, why? } · 409 { reason, line? } (S1.13)
|
|
7
|
+
// every restore: 409 { reason: unsaved-change|still-saving, line } when this
|
|
8
|
+
// disk has a change the project lacks (F14, settleBeforeRestore)
|
|
7
9
|
// GET /_api/project/versions ?path&before&limit&filter → { ok, now, rows, next?, source, offline? }
|
|
8
10
|
// GET /_api/project/changes ?path&from&to → { ok, changes, detail, blame }
|
|
9
11
|
// GET /_api/project/source ?path&at&lane → { ok, source } (raw source: `export`)
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
readSide,
|
|
37
39
|
refusalStatus,
|
|
38
40
|
restoreArtboardAt,
|
|
41
|
+
settleBeforeRestore,
|
|
39
42
|
} from '../history/restore-artboard-action.ts';
|
|
40
43
|
import { type ObjectKey, parseObjectKey, restoreObject } from '../history/restore-object.ts';
|
|
41
44
|
import { formatTime } from '../history/titles.ts';
|
|
@@ -90,6 +93,8 @@ type Outcome = {
|
|
|
90
93
|
|
|
91
94
|
/** The runtime methods these routes read — all optional (an older home has none). */
|
|
92
95
|
export interface HistoryRuntime extends VersionsRuntime {
|
|
96
|
+
/** F14 — this disk's change goes up before a restore reads the newest version (sync/index.ts). */
|
|
97
|
+
settleSource?(repoRel: string, ms?: number): Promise<'settled' | 'held' | 'pending' | null>;
|
|
93
98
|
/** S1.13 — `o.lanes`: one artboard / object / kept-aside body as ONE `restore` action. */
|
|
94
99
|
acceptedRestore?(repoRel: string, revision: number, o?: RestoreOptions): Promise<Outcome | null>;
|
|
95
100
|
/** S1.13 — the annotations lane, and `{ aside: true }` (a kept-aside body at exactly `revision`). */
|
|
@@ -301,6 +306,17 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
|
|
|
301
306
|
return json(200, { ok: true, actionId: r.actionId, line: label, ...extra });
|
|
302
307
|
}
|
|
303
308
|
|
|
309
|
+
/**
|
|
310
|
+
* F14 (2.0.4, #166) — every restore here reads (or lands on) the canvas's NEWEST version, but the
|
|
311
|
+
* person sees THIS disk: its change the project has not taken yet goes up first. A held change
|
|
312
|
+
* answers 409 `unsaved-change`, one still unanswered `still-saving`, each with its line; null:
|
|
313
|
+
* settled (or a home without the seam), go on.
|
|
314
|
+
*/
|
|
315
|
+
async function unsettled(rt: HistoryRuntime, t: Target): Promise<Response | null> {
|
|
316
|
+
const s = await settleBeforeRestore(rt, t.repoRel);
|
|
317
|
+
return s.ok ? null : json(s.status, { ok: false, reason: s.reason, line: s.line });
|
|
318
|
+
}
|
|
319
|
+
|
|
304
320
|
/** `at` names a version nobody kept → that body back over Now (§5.8 last row), else null. */
|
|
305
321
|
async function restoreAside(at: unknown, t: Target): Promise<Response | null> {
|
|
306
322
|
const ref = parseRef(at);
|
|
@@ -309,6 +325,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
|
|
|
309
325
|
if (!rt?.acceptedHistory || !rt.acceptedVersion) return null;
|
|
310
326
|
const row = await rowAt(rt, t.repoRel, ref.rev).catch(() => null);
|
|
311
327
|
if (row?.kind !== 'aside') return null;
|
|
328
|
+
const refused = await unsettled(rt, t);
|
|
329
|
+
if (refused) return refused;
|
|
312
330
|
const newest = await revisionOf(rt, 'now', t).catch(() => null);
|
|
313
331
|
for (const lane of ASIDE_ORDER) {
|
|
314
332
|
const body = await rt
|
|
@@ -338,6 +356,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
|
|
|
338
356
|
if (b.at === LAST_GOOD) {
|
|
339
357
|
if (b.artboard !== undefined || b.element !== undefined)
|
|
340
358
|
return json(400, { ok: false, reason: '@last-good restores the whole canvas' });
|
|
359
|
+
const refused = await unsettled(rt, t);
|
|
360
|
+
if (refused) return refused;
|
|
341
361
|
const lg = await findLastGood({
|
|
342
362
|
runtime: rt,
|
|
343
363
|
designRoot: deps.designRoot ?? null,
|
|
@@ -366,6 +386,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
|
|
|
366
386
|
ok: false,
|
|
367
387
|
reason: 'element must be <artboard>/<id> or an annotation id',
|
|
368
388
|
});
|
|
389
|
+
const refused = await unsettled(rt, t);
|
|
390
|
+
if (refused) return refused;
|
|
369
391
|
const newest = await revisionOf(rt, 'now', t).catch(() => undefined);
|
|
370
392
|
if (newest === undefined) return json(503, { ok: false, reason: 'unreachable' });
|
|
371
393
|
const row = await rowAt(rt, t.repoRel, ref.rev).catch(() => null);
|
|
@@ -497,12 +519,13 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
|
|
|
497
519
|
// "Restored 5 Oct, 18:40", §5.8): the row in Version history and the toast read it. The v1 body
|
|
498
520
|
// (`revision`) gets it too — the panel's own "Restore this version" sends that body, and without a
|
|
499
521
|
// label the row read "Restore Smoke to version 4" (P8 B1: an internal revision number, never shown).
|
|
522
|
+
const rt = runtime();
|
|
523
|
+
if (rt?.acceptedRestore) {
|
|
524
|
+
const refused = await unsettled(rt, t);
|
|
525
|
+
if (refused) return refused;
|
|
526
|
+
}
|
|
500
527
|
const label = await restoreLabel(t, revision);
|
|
501
|
-
const r = await
|
|
502
|
-
t.repoRel,
|
|
503
|
-
revision,
|
|
504
|
-
...(label ? [{ label }] : [])
|
|
505
|
-
);
|
|
528
|
+
const r = await rt?.acceptedRestore?.(t.repoRel, revision, ...(label ? [{ label }] : []));
|
|
506
529
|
// The v1 answer shape is kept: `maude design history restore` reads it.
|
|
507
530
|
if (!r) return json(200, { ok: false, reason: 'legacy' });
|
|
508
531
|
if (r.status === 'accepted' && r.actionId && !r.queued)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Sign in to a team server in the browser — issue #204 (sync/hub-browser-signin.ts has the flow).
|
|
2
|
+
//
|
|
3
|
+
// POST /_api/hub-signin/start { url } → { ok, id, signInUrl, expiresIn } | { ok:false, error }
|
|
4
|
+
// POST /_api/hub-signin/poll { id } → { ok, pending } | { ok, url, user } | { ok:false, error }
|
|
5
|
+
// POST /_api/hub-signin/cancel { id } → { ok }
|
|
6
|
+
// GET /_api/hub-signin/return ?state&code | ?state&error (the browser's hop back from the hub)
|
|
7
|
+
//
|
|
8
|
+
// MAIN ORIGIN ONLY: these mint and store a team-server credential, which the untrusted canvas
|
|
9
|
+
// origin (DDR-054) must never reach. `guardTableRoute` applies the CSRF + DNS-rebind gates to all
|
|
10
|
+
// four — the return route is the ONE table spec a cross-site page may reach, and only as a
|
|
11
|
+
// top-level navigation (`crossSiteNavigation`): it is where the hub's page sends the browser, so
|
|
12
|
+
// a navigation from the hub's origin is its whole job. What protects it is what protects any
|
|
13
|
+
// OAuth redirect endpoint: it acts only on a `state` this process minted, once, and the code is
|
|
14
|
+
// worthless without the verifier that never left this process.
|
|
15
|
+
//
|
|
16
|
+
// A cell never serves these (apps/hub/src/studio-manifest.mjs: REFUSED) — a cell holds no team
|
|
17
|
+
// server credential of its own.
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
createHubBrowserSignIn,
|
|
21
|
+
type HubBrowserSignIn,
|
|
22
|
+
returnPage,
|
|
23
|
+
} from '../sync/hub-browser-signin.ts';
|
|
24
|
+
import type { RouteSpec } from './table.ts';
|
|
25
|
+
|
|
26
|
+
export interface HubSigninRouteDeps {
|
|
27
|
+
/** The flow; a test passes one with a fake hub. */
|
|
28
|
+
signIn?: HubBrowserSignIn;
|
|
29
|
+
/** The team server this project syncs with — a renewed sign-in for it cycles sync. */
|
|
30
|
+
linkedHubUrl?: () => string | null | undefined;
|
|
31
|
+
restartSync?: () => Promise<unknown> | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function body(req: Request): Promise<Record<string, unknown>> {
|
|
35
|
+
try {
|
|
36
|
+
const text = await req.text();
|
|
37
|
+
if (text.length > 4096) return {};
|
|
38
|
+
const j = JSON.parse(text || '{}');
|
|
39
|
+
return j && typeof j === 'object' ? (j as Record<string, unknown>) : {};
|
|
40
|
+
} catch {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const json = (payload: unknown, status = 200) =>
|
|
46
|
+
Response.json(payload, { status, headers: { 'Cache-Control': 'no-store' } });
|
|
47
|
+
|
|
48
|
+
const sameServer = (a: string | null | undefined, b: string) => {
|
|
49
|
+
try {
|
|
50
|
+
return !!a && new URL(a).origin === new URL(b).origin;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function createHubSigninRoutes(deps: HubSigninRouteDeps = {}): RouteSpec[] {
|
|
57
|
+
const signIn =
|
|
58
|
+
deps.signIn ??
|
|
59
|
+
createHubBrowserSignIn({
|
|
60
|
+
// SIGN IN AGAIN: a new credential for the team server this project already syncs with. The
|
|
61
|
+
// running sync still holds the one the server refused — cycle it onto the one just stored
|
|
62
|
+
// (the move the retired email/password sign-in used to make).
|
|
63
|
+
onSignedIn: async (url) => {
|
|
64
|
+
if (sameServer(deps.linkedHubUrl?.(), url)) await deps.restartSync?.();
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
method: 'POST',
|
|
70
|
+
path: '/_api/hub-signin/start',
|
|
71
|
+
origin: 'main',
|
|
72
|
+
readOnly: 'allowed',
|
|
73
|
+
async handle(req) {
|
|
74
|
+
const b = await body(req);
|
|
75
|
+
const r = await signIn.start(b.url, new URL(req.url).origin);
|
|
76
|
+
return r.ok
|
|
77
|
+
? json(r)
|
|
78
|
+
: json(
|
|
79
|
+
{ ok: false, error: r.error, ...(r.reason ? { reason: r.reason } : {}) },
|
|
80
|
+
r.status
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
method: 'POST',
|
|
86
|
+
path: '/_api/hub-signin/poll',
|
|
87
|
+
origin: 'main',
|
|
88
|
+
readOnly: 'allowed',
|
|
89
|
+
async handle(req) {
|
|
90
|
+
return json(signIn.poll((await body(req)).id));
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
method: 'POST',
|
|
95
|
+
path: '/_api/hub-signin/cancel',
|
|
96
|
+
origin: 'main',
|
|
97
|
+
readOnly: 'allowed',
|
|
98
|
+
async handle(req) {
|
|
99
|
+
signIn.cancel((await body(req)).id);
|
|
100
|
+
return json({ ok: true });
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
method: 'GET',
|
|
105
|
+
// A literal (the route scrapers read `path:` strings) — HUB_SIGNIN_RETURN_PATH, asserted by the test.
|
|
106
|
+
path: '/_api/hub-signin/return',
|
|
107
|
+
origin: 'main',
|
|
108
|
+
readOnly: 'allowed',
|
|
109
|
+
crossSiteNavigation: true,
|
|
110
|
+
async handle(req) {
|
|
111
|
+
return returnPage(await signIn.onReturn(new URL(req.url).searchParams));
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
}
|
|
@@ -45,6 +45,7 @@ import { createGenerateRoutes, type GenerateRouteDeps } from './generate.ts';
|
|
|
45
45
|
import { createHandoffRoutes, type HandoffRouteDeps } from './handoff.ts';
|
|
46
46
|
import { createHelpGuidesRoutes, type HelpGuidesDeps } from './help-guides.ts';
|
|
47
47
|
import { createHistoryRoutes, type HistoryRouteDeps } from './history.ts';
|
|
48
|
+
import { createHubSigninRoutes, type HubSigninRouteDeps } from './hub-signin.ts';
|
|
48
49
|
import { createImportLinkRoutes, type ImportLinkRouteDeps } from './import-link.ts';
|
|
49
50
|
import { createKindRoutes } from './kinds.ts';
|
|
50
51
|
import { createLinksRoutes, type LinksRouteDeps } from './links.ts';
|
|
@@ -140,6 +141,8 @@ export interface RouteDeps {
|
|
|
140
141
|
cloudPlan?: CloudPlanDeps;
|
|
141
142
|
/** S11.14 — `GET /_api/connections/hub` (main origin): the linked team server's Advanced details */
|
|
142
143
|
connections?: ConnectionsRouteDeps;
|
|
144
|
+
/** Issue #204 — `/_api/hub-signin/*` (main origin): sign in to a team server on its own page */
|
|
145
|
+
hubSignin?: HubSigninRouteDeps;
|
|
143
146
|
/** S8.19 — `GET /_api/asset-state` (main origin): disk + upload queue + hub presence */
|
|
144
147
|
assetState?: AssetStateRouteDeps;
|
|
145
148
|
/** S8.13 — `POST /_api/assets/trash` (main origin, Can edit on the project): assets + sidecars to `_trash/`;
|
|
@@ -266,6 +269,7 @@ export function allSpecs(deps: RouteDeps): RouteSpec[] {
|
|
|
266
269
|
...(deps.cloudPlan ? createCloudPlanRoutes(deps.cloudPlan) : []),
|
|
267
270
|
...(deps.helpGuides ? createHelpGuidesRoutes(deps.helpGuides) : []),
|
|
268
271
|
...(deps.connections ? createConnectionsRoutes(deps.connections) : []),
|
|
272
|
+
...createHubSigninRoutes(deps.hubSignin ?? {}),
|
|
269
273
|
...createAssetStateRoutes(deps.assetState ?? { service: () => null }),
|
|
270
274
|
...(deps.assetTrash ? createAssetTrashRoutes(deps.assetTrash) : []),
|
|
271
275
|
// P8 round 7 — POST /_api/assets/rename (routes/asset-rename.ts): the same deps and verdict as Move to trash
|
|
@@ -41,6 +41,13 @@ export interface RouteSpec {
|
|
|
41
41
|
* GATES stay exactly the same; only the words differ.
|
|
42
42
|
*/
|
|
43
43
|
refuse?(reason: 'cross-origin' | 'untrusted-host'): Response;
|
|
44
|
+
/**
|
|
45
|
+
* Issue #204 — a GET a cross-site page may reach, as a TOP-LEVEL NAVIGATION only
|
|
46
|
+
* (`Sec-Fetch-Mode: navigate` + `Sec-Fetch-Dest: document`): the loopback return a team
|
|
47
|
+
* server's sign-in page sends the browser to. A cross-site fetch, image or frame is still
|
|
48
|
+
* refused, and so is a rebound Host. The handler must act only on state it minted itself.
|
|
49
|
+
*/
|
|
50
|
+
crossSiteNavigation?: true;
|
|
44
51
|
handle(req: Request, params: Record<string, string>): Response | Promise<Response>;
|
|
45
52
|
}
|
|
46
53
|
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
// what to draw; the clear route refuses an editor with 403 whatever the client drew.
|
|
21
21
|
|
|
22
22
|
import type { Access } from '../access/scope.ts';
|
|
23
|
+
import { SETTLE_REFUSAL_LINES } from '../history/restore-artboard-action.ts';
|
|
23
24
|
import {
|
|
24
25
|
ARTBOARD_ID,
|
|
25
26
|
ARTBOARD_NOT_YET_LINE,
|
|
@@ -88,6 +89,8 @@ const refused = (code: string | undefined, extra: Record<string, unknown> = {})
|
|
|
88
89
|
ok: false,
|
|
89
90
|
reason: r.reason,
|
|
90
91
|
...(r.reason === 'needs-hub-update' ? { line: NEEDS_HUB_UPDATE_LINE } : {}),
|
|
92
|
+
// F14 — a restore over this disk's unsaved change says why (the card shows the line)
|
|
93
|
+
...(SETTLE_REFUSAL_LINES[r.reason] ? { line: SETTLE_REFUSAL_LINES[r.reason] } : {}),
|
|
91
94
|
...extra,
|
|
92
95
|
});
|
|
93
96
|
};
|
package/apps/studio/server.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { saveHold, withSaveRequest } from './ai/save-hold.ts';
|
|
|
40
40
|
import { migrateAnnotationsV2 } from './annotations/migrate-boot.ts';
|
|
41
41
|
import { runContext, runTagOf, stageRunAnnotations } from './annotations/run-tag.ts';
|
|
42
42
|
import { ASSET_MAX_VIDEO_BYTES, createApi } from './api.ts';
|
|
43
|
+
import { bootFinished, bootStep } from './boot-progress.ts';
|
|
43
44
|
import { bootSelfHeal } from './boot-self-heal.ts';
|
|
44
45
|
import { isSandboxArmed } from './canvas-build-sandbox.ts';
|
|
45
46
|
import { createCanvasListWatch } from './canvas-list-watch.ts';
|
|
@@ -102,10 +103,12 @@ if (process.argv.includes('--home')) {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
const ctx = createContext();
|
|
106
|
+
bootStep('context');
|
|
105
107
|
|
|
106
108
|
// V2-2.9 (T23) — persist the per-source diagnostics (server · sync · ai · export) under
|
|
107
109
|
// ~/.maude/logs (or $MAUDE_LOG_DIR), scrubbed, 7 days. Local only: nothing is sent anywhere.
|
|
108
110
|
await initDiagnostics({ repoRoot: ctx.paths.repoRoot });
|
|
111
|
+
bootStep('diagnostics');
|
|
109
112
|
|
|
110
113
|
// DDR-064 — the collab room's Y.Doc is THE doc per canvas, everywhere. Since p8-v1-drop there is no
|
|
111
114
|
// opt-out: `MAUDE_SHARED_DOC=0` (the rollback onto the two-doc + disk-reconcile path) is gone. Set on
|
|
@@ -244,7 +247,9 @@ const inspects = createInspectRegistry(ctx, (file) => api.loadCommentsForFile(fi
|
|
|
244
247
|
inspectHandle = inspects;
|
|
245
248
|
// The shared instance is the desktop's, and a cell's fallback for anything that
|
|
246
249
|
// arrives without a vouched session.
|
|
250
|
+
bootStep('api');
|
|
247
251
|
await inspects.for('').load();
|
|
252
|
+
bootStep('inspect');
|
|
248
253
|
|
|
249
254
|
// Semantic structural notifications include remote sync operations as well as
|
|
250
255
|
// API actions. Keep every session's agent/inspector context on the live path.
|
|
@@ -305,6 +310,7 @@ const runRegistry = createRunRegistry({
|
|
|
305
310
|
}),
|
|
306
311
|
});
|
|
307
312
|
await runRegistry.boot();
|
|
313
|
+
bootStep('runs');
|
|
308
314
|
// S5.15 — every accepted action reaches the shell as `project:action`, not only a run's publish and the
|
|
309
315
|
// undo routes': a person's edit (yours, or a teammate's arriving from the hub) clears "Made by AI".
|
|
310
316
|
const actionFeed = createActionFeed({
|
|
@@ -389,6 +395,7 @@ const ws = createWs(
|
|
|
389
395
|
const exportJobs = createExportJobQueue(ctx.bus, ctx.paths.designRoot, { runs: () => runRegistry });
|
|
390
396
|
// feature-ai-media-generation (DDR-16x) — background AI-media generation queue.
|
|
391
397
|
const generateJobs = createGenerationJobQueue(ctx.bus, ctx.paths.designRoot);
|
|
398
|
+
bootStep('sockets');
|
|
392
399
|
const http = createHttp(ctx, api, inspects, aiActivity, exportJobs, generateJobs, {
|
|
393
400
|
shellCount: () => ws.shellCount(),
|
|
394
401
|
runs: runRegistry,
|
|
@@ -412,7 +419,9 @@ if (!isWorkspaceMode()) {
|
|
|
412
419
|
});
|
|
413
420
|
ctx.bus.on('config-updated', narrowSockets);
|
|
414
421
|
}
|
|
422
|
+
bootStep('http');
|
|
415
423
|
const fsWatch = createFsWatch(ctx);
|
|
424
|
+
bootStep('watcher');
|
|
416
425
|
|
|
417
426
|
// Port: --port arg > $PORT > $MDCC_DEV_PORT > $MAUDE_PORT_BASE > 47399 (e2e) > 46399 (the desktop app) > 4399 — port.ts.
|
|
418
427
|
// When the port wasn't explicitly chosen and the default is busy (another
|
|
@@ -942,6 +951,7 @@ function startCanvasServer(
|
|
|
942
951
|
});
|
|
943
952
|
}
|
|
944
953
|
|
|
954
|
+
bootStep('routes');
|
|
945
955
|
let server: BunServer;
|
|
946
956
|
{
|
|
947
957
|
const r = bindFirst(PORT_CANDIDATES, (p) => listenLoopback((h, port) => startServer(port, h), p));
|
|
@@ -1060,6 +1070,7 @@ const captureServer =
|
|
|
1060
1070
|
if (captureServer) ctx.captureOrigin = `http://localhost:${captureServer.port}`;
|
|
1061
1071
|
|
|
1062
1072
|
const startedAt = new Date().toISOString();
|
|
1073
|
+
bootFinished();
|
|
1063
1074
|
await Bun.write(
|
|
1064
1075
|
ctx.paths.serverInfoFile,
|
|
1065
1076
|
JSON.stringify(
|
|
@@ -53,7 +53,7 @@ import type { CommentLedger } from './comment-ledger.ts';
|
|
|
53
53
|
import { hashBytes } from './echo-guard.ts';
|
|
54
54
|
import type { SyncJournal } from './journal.ts';
|
|
55
55
|
import type { DocProjection, ProjectionPaths, ProposalLane } from './projection.ts';
|
|
56
|
-
import { readRecoveryBody, saveRecoveryBody } from './source-recovery.ts';
|
|
56
|
+
import { readRecoveryBody, readRecoveryCandidate, saveRecoveryBody } from './source-recovery.ts';
|
|
57
57
|
import { sourceError } from './source-validation.ts';
|
|
58
58
|
|
|
59
59
|
export type LaneDecision = 'agreed' | 'materialize' | 'propose' | 'hold';
|
|
@@ -107,6 +107,17 @@ export function commentsOwedToProject(
|
|
|
107
107
|
return owed.length > 0 ? JSON.stringify([...acceptedList, ...owed]) : null;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/** An unresolved refused draft of this source is on record (unreadable counts: fail closed). */
|
|
111
|
+
function openConflict(historyDir: string | undefined, file: string): boolean {
|
|
112
|
+
if (!historyDir) return false;
|
|
113
|
+
try {
|
|
114
|
+
const c = readRecoveryCandidate(historyDir, file);
|
|
115
|
+
return c !== null && !c.resolved;
|
|
116
|
+
} catch {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
/**
|
|
111
122
|
* Pure decision for the source lanes. `knownBase` is the last value disk and
|
|
112
123
|
* the accepted replica agreed on (recovery slot), `baseHash` the journal's
|
|
@@ -214,7 +225,9 @@ export async function acceptedColdStart(
|
|
|
214
225
|
// What the project now holds IS the local file: the next save is based
|
|
215
226
|
// on it, even if it lands before the publication reaches this replica.
|
|
216
227
|
const base = r.html ?? localHtml;
|
|
217
|
-
|
|
228
|
+
// Persisted (v2-204): the creator has a base on record like any peer that received it, so
|
|
229
|
+
// an offline edit after a restart is proposed against it instead of held as a conflict.
|
|
230
|
+
i.projection.adoptBase(base, { remember: true });
|
|
218
231
|
// S6.13b — saved again on top of that create while it waited (offline,
|
|
219
232
|
// or a previous run): the disk is an edit of it, proposed as one.
|
|
220
233
|
if (base !== localHtml && !sourceError(i.paths.html, localHtml)) {
|
|
@@ -251,8 +264,18 @@ export async function acceptedColdStart(
|
|
|
251
264
|
(i.historyDir ? readRecoveryBody(i.historyDir, i.paths.html, 'base') : null),
|
|
252
265
|
baseHash: i.journal?.get(i.slug)?.bodyHash ?? null,
|
|
253
266
|
});
|
|
267
|
+
// "The project once accepted exactly these bytes" proves an OLDER accepted state (a checkout
|
|
268
|
+
// restored from a backup — every cloud cell wake) only when this Mac is not holding a refused
|
|
269
|
+
// save: the hub answers by content hash, across every document and revision, and a refused
|
|
270
|
+
// candidate is very often bytes the project took somewhere (the same artboards trashed on a
|
|
271
|
+
// twin canvas, a trash a restore undid). An open conflict episode on disk (its first refused
|
|
272
|
+
// draft, unresolved) keeps the hold — the person sees it again after a restart instead of
|
|
273
|
+
// losing it in silence (F15, v2-204).
|
|
254
274
|
const older =
|
|
255
|
-
d.decision === 'hold' &&
|
|
275
|
+
d.decision === 'hold' &&
|
|
276
|
+
localHtml !== null &&
|
|
277
|
+
!openConflict(i.historyDir, i.paths.html) &&
|
|
278
|
+
(await i.wasAccepted?.(localHtml)) === true;
|
|
256
279
|
verdicts.push({
|
|
257
280
|
lane: 'html',
|
|
258
281
|
...(older ? { decision: 'materialize' as const } : d),
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
createTransactionClient,
|
|
39
39
|
type Operation,
|
|
40
40
|
type ProposalResult,
|
|
41
|
+
type ReadLimits,
|
|
41
42
|
type Reservation,
|
|
42
43
|
type TransactionClient,
|
|
43
44
|
type TransactionClientOptions,
|
|
@@ -767,14 +768,18 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
|
|
|
767
768
|
* p8-hub-undo-collision — a lane body the hub holds, by hash (null: not served / unreachable).
|
|
768
769
|
* The blob read is gated by the hub exactly like the history rows that name the hash.
|
|
769
770
|
*/
|
|
770
|
-
async blob(hash: string): Promise<string | null> {
|
|
771
|
+
async blob(hash: string, lim: ReadLimits = {}): Promise<string | null> {
|
|
771
772
|
if (!/^[0-9a-f]{64}$/.test(hash)) return null;
|
|
772
|
-
const b = (await client.read(`blobs/${hash}`, {})) as { body?: unknown };
|
|
773
|
+
const b = (await client.read(`blobs/${hash}`, {}, lim)) as { body?: unknown };
|
|
773
774
|
return typeof b?.body === 'string' ? b.body : null;
|
|
774
775
|
},
|
|
775
776
|
/** p8-hub-undo-collision — a doc's lane at the hub's newest revision (what an undo merges onto). */
|
|
776
|
-
async laneHead(
|
|
777
|
-
|
|
777
|
+
async laneHead(
|
|
778
|
+
doc: string,
|
|
779
|
+
lane: LaneProposal['lane'],
|
|
780
|
+
lim: ReadLimits = {}
|
|
781
|
+
): Promise<string | null> {
|
|
782
|
+
const r = (await client.read('lane', { doc, lane, rev: Number.MAX_SAFE_INTEGER }, lim)) as {
|
|
778
783
|
body?: unknown;
|
|
779
784
|
};
|
|
780
785
|
return typeof r?.body === 'string' ? r.body : null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// sync/code-module-consent.ts — may this hub DELIVER code modules (`.ts`/`.js`) to this checkout?
|
|
2
|
+
//
|
|
3
|
+
// DDR-054: a code module lands outside the sandboxed canvas origin — the agent and every
|
|
4
|
+
// `maude design *` helper read it — so only a hub this machine vouches for may move one. Three
|
|
5
|
+
// ways a hub is vouched for, and nothing a hub can say about itself is one of them:
|
|
6
|
+
//
|
|
7
|
+
// 1. `cell` — this process is a cell's own paired child: the hub and the checkout are one
|
|
8
|
+
// trust domain, there is no remote party.
|
|
9
|
+
// 2. `recorded` — `codeModulesAllowed: true` in the profile's hubs.json, written only by the
|
|
10
|
+
// person at `maude design link` (cli/lib/design-link.mjs `askCodeModuleConsent`)
|
|
11
|
+
// and carried across every re-save by `saveHubCredential` — a sign-in response
|
|
12
|
+
// can change the stored role, never this.
|
|
13
|
+
// 3. `cloud` — 2.0.4, Michal's decision ("automaticky pro Maude Cloud"): a Maude Cloud project
|
|
14
|
+
// the desktop app ITSELF opened from Home. The cloud's file door takes code-module
|
|
15
|
+
// uploads only from the project's OWNER role (DDR-217), so what arrives is the
|
|
16
|
+
// owner's own code; asking every member to say yes to it left a second Mac with
|
|
17
|
+
// 12 helpers `stuck` and the canvases importing them undrawable.
|
|
18
|
+
//
|
|
19
|
+
// Why (3) is computed here, per boot, and NOT recorded into hubs.json:
|
|
20
|
+
// - both inputs are out of a repo's and a hub's reach: `MAUDE_APP_BOUND_HUB` is set by the Rust
|
|
21
|
+
// shell from the app's own registry (a committed `linkedHub` never is — sync/link-consent.ts),
|
|
22
|
+
// and the cell zone is compiled in (`CELL_ZONE`, the same constant as Rust `windows.rs`), never
|
|
23
|
+
// read from config or from `MAUDE_CLOUD_URL` — a self-hosted control plane is not Maude Cloud;
|
|
24
|
+
// - a record would outlive its reason: a folder later re-linked to another hub, or a copy opened
|
|
25
|
+
// outside the app, would inherit a `true` nobody gave. Computing it can't be planted or go stale.
|
|
26
|
+
// - there is no per-hub consent row in Settings › Connections to keep in step with.
|
|
27
|
+
//
|
|
28
|
+
// An explicit recorded `false` still wins: a person who said no on this Mac keeps their no.
|
|
29
|
+
|
|
30
|
+
import { CELL_ZONE, cellDoorUrl } from '../client/v2/cloud/browser-door.js';
|
|
31
|
+
import { normHub } from './link-consent.ts';
|
|
32
|
+
|
|
33
|
+
export type CodeModuleConsentHow = 'cell' | 'recorded' | 'cloud';
|
|
34
|
+
|
|
35
|
+
export interface CodeModuleConsentInput {
|
|
36
|
+
/** this process is a paired cell child (sync/cell-pairing.ts) */
|
|
37
|
+
cellPairing: boolean;
|
|
38
|
+
/** the linked hub the runtime is about to dial (already past link consent) */
|
|
39
|
+
hubUrl: string;
|
|
40
|
+
/** the profile's stored hub record — only its local `codeModulesAllowed` is read */
|
|
41
|
+
storedRecord?: { codeModulesAllowed?: boolean } | null;
|
|
42
|
+
env?: Record<string, string | undefined>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Is `url` the front door of a Maude Cloud project cell? https, no port, no userinfo, no path, one
|
|
47
|
+
* cell label under the compiled-in zone (never `canvas`, `view-*`, `canvas-*` — `cellDoorUrl`).
|
|
48
|
+
*/
|
|
49
|
+
export function isMaudeCloudCell(url: unknown): boolean {
|
|
50
|
+
const hub = normHub(url);
|
|
51
|
+
if (!hub) return false;
|
|
52
|
+
let origin: string;
|
|
53
|
+
try {
|
|
54
|
+
const u = new URL(hub);
|
|
55
|
+
if (u.search || u.hash || (u.pathname !== '/' && u.pathname !== '')) return false;
|
|
56
|
+
origin = u.origin;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (!origin.endsWith(`.${CELL_ZONE}`)) return false;
|
|
61
|
+
return cellDoorUrl(`${origin}/`) === `${origin}/`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Why this hub may deliver code modules here, or null when it may not. */
|
|
65
|
+
export function codeModuleConsent(o: CodeModuleConsentInput): CodeModuleConsentHow | null {
|
|
66
|
+
if (o.cellPairing) return 'cell';
|
|
67
|
+
const recorded = o.storedRecord?.codeModulesAllowed;
|
|
68
|
+
if (recorded === true) return 'recorded';
|
|
69
|
+
if (recorded === false) return null;
|
|
70
|
+
const env = o.env ?? process.env;
|
|
71
|
+
const hub = normHub(o.hubUrl);
|
|
72
|
+
if (hub && normHub(env.MAUDE_APP_BOUND_HUB) === hub && isMaudeCloudCell(hub)) return 'cloud';
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
@@ -313,6 +313,16 @@ export interface FileLedger {
|
|
|
313
313
|
outboxHas(hash: string): boolean;
|
|
314
314
|
|
|
315
315
|
flush(): void;
|
|
316
|
+
/**
|
|
317
|
+
* Hold the debounced write until the returned release is called (issue #204).
|
|
318
|
+
*
|
|
319
|
+
* A pass that lands thousands of files used to rewrite this file — 2.3 MB of JSON on a 5 000-file
|
|
320
|
+
* project, stringified twice per write — once a second for the whole pass, because every landing
|
|
321
|
+
* re-armed the 1 s debounce. While held, changes stay in memory and the caller decides when to
|
|
322
|
+
* write: every N landings and at the end of the pass, through `flush()`, which always writes.
|
|
323
|
+
* Holds nest; the last release re-arms the debounce if anything changed meanwhile.
|
|
324
|
+
*/
|
|
325
|
+
deferFlush(): () => void;
|
|
316
326
|
stop(): void;
|
|
317
327
|
/** Where this ledger persists. Tests and the panel read it. */
|
|
318
328
|
file(): string;
|
|
@@ -343,6 +353,8 @@ export interface FileLedgerOptions {
|
|
|
343
353
|
now?: () => number;
|
|
344
354
|
flushMs?: number;
|
|
345
355
|
log?: Pick<Console, 'warn'>;
|
|
356
|
+
/** Called after every write that reached the disk — the tests count them. */
|
|
357
|
+
onPersist?: () => void;
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
@@ -439,7 +451,15 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
439
451
|
return out;
|
|
440
452
|
}
|
|
441
453
|
|
|
454
|
+
/** Open `deferFlush` holds, and whether something changed while one was open. */
|
|
455
|
+
let holds = 0;
|
|
456
|
+
let dirtyWhileHeld = false;
|
|
457
|
+
|
|
442
458
|
function schedule(): void {
|
|
459
|
+
if (holds > 0) {
|
|
460
|
+
dirtyWhileHeld = true;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
443
463
|
if (timer !== null) return;
|
|
444
464
|
timer = setTimeout(() => {
|
|
445
465
|
timer = null;
|
|
@@ -464,6 +484,8 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
464
484
|
data.updatedAt = now();
|
|
465
485
|
atomicWrite(file, `${JSON.stringify(data, null, 2)}\n`);
|
|
466
486
|
lastPersisted = body;
|
|
487
|
+
dirtyWhileHeld = false;
|
|
488
|
+
opts.onPersist?.();
|
|
467
489
|
} catch (err) {
|
|
468
490
|
// Never throws into the sync hot path. A ledger we cannot persist costs
|
|
469
491
|
// a re-anchor next boot, which is noise rather than loss.
|
|
@@ -711,6 +733,19 @@ export function createFileLedger(opts: FileLedgerOptions): FileLedger {
|
|
|
711
733
|
}
|
|
712
734
|
persist();
|
|
713
735
|
},
|
|
736
|
+
deferFlush() {
|
|
737
|
+
holds += 1;
|
|
738
|
+
let released = false;
|
|
739
|
+
return () => {
|
|
740
|
+
if (released) return;
|
|
741
|
+
released = true;
|
|
742
|
+
holds -= 1;
|
|
743
|
+
if (holds === 0 && dirtyWhileHeld) {
|
|
744
|
+
dirtyWhileHeld = false;
|
|
745
|
+
schedule();
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
},
|
|
714
749
|
stop() {
|
|
715
750
|
if (timer !== null) {
|
|
716
751
|
clearTimeout(timer);
|