@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.
- package/README.md +6 -5
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/filters.ts +12 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- 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 +10 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/view.ts +12 -0
- package/apps/studio/actions.manifest.json +25 -1
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-layer.tsx +0 -12
- package/apps/studio/api.ts +73 -24
- package/apps/studio/artboard-live-gate.tsx +267 -0
- package/apps/studio/artboard-live.ts +336 -0
- package/apps/studio/artboard-webgl.ts +668 -0
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_png-playwright.mjs +10 -1
- package/apps/studio/bin/_pw-launch.mjs +14 -0
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +11 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- 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-lib.tsx +131 -12
- 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/canvas-url.js +13 -0
- package/apps/studio/client/github.js +23 -3
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +36 -19
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
- package/apps/studio/client/hooks/use-project-data.jsx +2 -0
- 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 +49 -57
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- 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/caps-cache.js +46 -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 +45 -8
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/tree/tree.jsx +48 -21
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- 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-imports-card.jsx +15 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
- 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-bus.js +5 -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 +11 -23
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -12
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- 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/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +21 -5
- package/apps/studio/client/v2/history/git-parts.jsx +76 -43
- 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/presence/faces.jsx +42 -14
- 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/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +12 -0
- package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- 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 +139 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-activity.js +19 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- 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/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/config-reload-wire.ts +53 -0
- package/apps/studio/dist/client.bundle.js +1098 -1102
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/specimen.tsx +12 -1
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +7 -3
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +4 -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/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/hub.ts +77 -175
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +66 -8
- package/apps/studio/http.ts +131 -68
- 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/ds-convert.ts +18 -0
- 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 +19 -1
- package/apps/studio/server.ts +19 -10
- package/apps/studio/sync/accepted-cold-start.ts +54 -16
- package/apps/studio/sync/accepted-link.ts +9 -4
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +74 -0
- package/apps/studio/sync/file-ledger.ts +35 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +483 -86
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-browser-signin.ts +377 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hub-text-undo.ts +30 -10
- package/apps/studio/sync/index.ts +381 -161
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +121 -14
- 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 +58 -3
- package/apps/studio/sync/status.ts +3 -1
- 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/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/video-comp.tsx +23 -0
- package/apps/studio/video-links-overlay.tsx +3 -2
- package/apps/studio/whats-new.json +126 -0
- package/cli/lib/bash-guard.mjs +13 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/cli/lib/workspace-plan.mjs +14 -0
- package/package.json +8 -8
|
@@ -45,19 +45,31 @@ export function measureShellInsets(frameEl, root, { presenting = false } = {}) {
|
|
|
45
45
|
* evaluated and installed the insets listener — a single seed on `loaded` is usually dropped (measured
|
|
46
46
|
* in V2-4.1: the first Fit of a freshly opened canvas ignored the left panel). The same ladder
|
|
47
47
|
* `ui-open.js` / the halo restore use covers the gap: each rung is a fresh seed (newer seq, same value),
|
|
48
|
-
* stopped as soon as the window is gone. Returns a cancel function.
|
|
48
|
+
* stopped as soon as the window is gone. Returns a cancel function. `onDone` runs once, after the last rung or on
|
|
49
|
+
* cancel — 2.0.4: the caller must let go of the cancel then, since it holds the canvas window (a kept cancel kept
|
|
50
|
+
* every canvas ever opened alive, ~14 MB each).
|
|
49
51
|
*/
|
|
50
52
|
export const SEED_LADDER_MS = [0, 50, 450, 1200];
|
|
51
|
-
export function seedOnLadder(pump, to, { alive = () => true, setTimer, clearTimer } = {}) {
|
|
53
|
+
export function seedOnLadder(pump, to, { alive = () => true, setTimer, clearTimer, onDone } = {}) {
|
|
52
54
|
const set = setTimer ?? ((fn, ms) => setTimeout(fn, ms));
|
|
53
55
|
const clear = clearTimer ?? ((h) => clearTimeout(h));
|
|
56
|
+
let left = SEED_LADDER_MS.length;
|
|
57
|
+
let finished = false;
|
|
58
|
+
const finish = () => {
|
|
59
|
+
if (finished) return;
|
|
60
|
+
finished = true;
|
|
61
|
+
onDone?.();
|
|
62
|
+
};
|
|
54
63
|
const handles = SEED_LADDER_MS.map((ms) =>
|
|
55
64
|
set(() => {
|
|
56
65
|
if (alive()) pump.seed(to);
|
|
66
|
+
left -= 1;
|
|
67
|
+
if (left === 0) finish();
|
|
57
68
|
}, ms)
|
|
58
69
|
);
|
|
59
70
|
return () => {
|
|
60
71
|
for (const h of handles) clear(h);
|
|
72
|
+
finish();
|
|
61
73
|
};
|
|
62
74
|
}
|
|
63
75
|
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// client/v2/shell/project-account-card.jsx — 2.0.5 W4: THIS project's account, opened from the avatar
|
|
2
|
+
// (your own face in the Share cluster) and from the account chip.
|
|
3
|
+
//
|
|
4
|
+
// PRESENTATIONAL. The words and the paths come from project-account-model.js; the host
|
|
5
|
+
// (share-cluster-host.jsx) runs them. Every button runs a registry action through `run(id)` or the
|
|
6
|
+
// kind's existing sign-out path through `onSignOut(path)` — and a row is drawn only where its path
|
|
7
|
+
// exists (a browser tab gets the facts and no button). Sign out asks first (CONTRACT §4).
|
|
8
|
+
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { onCanvasPointer } from './canvas-pointer.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The popover the card sits in, under the Share cluster's start. Esc, a press outside and a press in the
|
|
14
|
+
* canvas close it; a press on an opener (`data-account-opener` — your face, the account chip) is the
|
|
15
|
+
* opener's own toggle, so it is not an outside press.
|
|
16
|
+
*/
|
|
17
|
+
export function ProjectAccountPopover({ open, onClose, children }) {
|
|
18
|
+
const wrap = useRef(null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!open) return undefined;
|
|
21
|
+
const onDown = (e) => {
|
|
22
|
+
const t = e.target;
|
|
23
|
+
if (wrap.current?.contains(t)) return;
|
|
24
|
+
if (t?.closest?.('[data-account-opener]')) return;
|
|
25
|
+
onClose();
|
|
26
|
+
};
|
|
27
|
+
const onKey = (e) => {
|
|
28
|
+
if (e.key === 'Escape') onClose();
|
|
29
|
+
};
|
|
30
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
31
|
+
document.addEventListener('keydown', onKey);
|
|
32
|
+
const off = onCanvasPointer(() => onClose());
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
35
|
+
document.removeEventListener('keydown', onKey);
|
|
36
|
+
off();
|
|
37
|
+
};
|
|
38
|
+
}, [open, onClose]);
|
|
39
|
+
if (!open) return null;
|
|
40
|
+
return (
|
|
41
|
+
<div className="sh-acct-card sh-pa-pop" role="dialog" aria-label="Account" ref={wrap}>
|
|
42
|
+
{children}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function Line({ k, testid, children }) {
|
|
48
|
+
if (!children) return null;
|
|
49
|
+
return (
|
|
50
|
+
<div className="sh-pa-line">
|
|
51
|
+
<span className="sh-pa-k">{k}</span>
|
|
52
|
+
<span className="sh-pa-v" data-testid={testid}>
|
|
53
|
+
{children}
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param account projectAccount()
|
|
61
|
+
* @param run (id) => void — the shell's runner (account.switch, account.github-signin)
|
|
62
|
+
* @param onSignOut (path) => Promise — 'cloud-signout' | 'hub-detach' | 'github-signout'
|
|
63
|
+
* @param onSwitch (spec) => void — a Switch with a `path` (W4b 'hub-switch'), not a registry id
|
|
64
|
+
* @param onClose () => void
|
|
65
|
+
*/
|
|
66
|
+
export function ProjectAccountCard({ account, run, onSignOut, onSwitch, onClose }) {
|
|
67
|
+
const [asking, setAsking] = useState(null); // the signOut spec being confirmed
|
|
68
|
+
const [busy, setBusy] = useState(false);
|
|
69
|
+
if (!account) return null;
|
|
70
|
+
const gh = account.github;
|
|
71
|
+
const ghOut = gh?.canSignOut
|
|
72
|
+
? {
|
|
73
|
+
path: 'github-signout',
|
|
74
|
+
label: `Sign out of GitHub (@${gh.login})…`,
|
|
75
|
+
confirm: {
|
|
76
|
+
title: `Sign out of @${gh.login}?`,
|
|
77
|
+
body: 'Every project on it is signed out of GitHub. Your work stays on this Mac.',
|
|
78
|
+
primary: 'Sign out',
|
|
79
|
+
cancel: 'Cancel',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
: null;
|
|
83
|
+
|
|
84
|
+
const confirm = async () => {
|
|
85
|
+
const spec = asking;
|
|
86
|
+
setBusy(true);
|
|
87
|
+
try {
|
|
88
|
+
await onSignOut?.(spec.path);
|
|
89
|
+
} finally {
|
|
90
|
+
setBusy(false);
|
|
91
|
+
setAsking(null);
|
|
92
|
+
onClose?.();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const go = (id) => {
|
|
96
|
+
onClose?.();
|
|
97
|
+
run?.(id);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div className="sh-pa" data-testid="project-account">
|
|
102
|
+
<p className="sh-pa-h">This project’s account</p>
|
|
103
|
+
<Line k="Signed in with" testid="project-account-kind">
|
|
104
|
+
{account.kindLabel}
|
|
105
|
+
</Line>
|
|
106
|
+
<Line k="Account" testid="project-account-who">
|
|
107
|
+
{account.who}
|
|
108
|
+
</Line>
|
|
109
|
+
<Line k={account.kind === 'team' ? 'Server' : 'Project'} testid="project-account-where">
|
|
110
|
+
{account.where}
|
|
111
|
+
</Line>
|
|
112
|
+
<Line k="Profile on this Mac" testid="project-account-profile">
|
|
113
|
+
{account.profileLabel}
|
|
114
|
+
</Line>
|
|
115
|
+
{gh?.login && account.kind !== 'github' ? (
|
|
116
|
+
<Line k="GitHub" testid="project-account-github">
|
|
117
|
+
@{gh.login}
|
|
118
|
+
</Line>
|
|
119
|
+
) : null}
|
|
120
|
+
{gh?.note ? (
|
|
121
|
+
<p className="sh-pa-note" data-testid="project-account-github-note">
|
|
122
|
+
{gh.note}
|
|
123
|
+
</p>
|
|
124
|
+
) : null}
|
|
125
|
+
|
|
126
|
+
{asking ? (
|
|
127
|
+
<div className="sh-acct-ask" role="alertdialog" data-testid="project-account-confirm">
|
|
128
|
+
<strong>{asking.confirm.title}</strong>
|
|
129
|
+
<span>{asking.confirm.body}</span>
|
|
130
|
+
<span className="sh-acct-btns">
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
className="btn btn--sm"
|
|
134
|
+
data-testid="project-account-signout-cancel"
|
|
135
|
+
onClick={() => setAsking(null)}
|
|
136
|
+
>
|
|
137
|
+
{asking.confirm.cancel}
|
|
138
|
+
</button>
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
className="btn btn--sm btn--danger"
|
|
142
|
+
data-testid="project-account-signout-confirm"
|
|
143
|
+
disabled={busy}
|
|
144
|
+
onClick={confirm}
|
|
145
|
+
>
|
|
146
|
+
{asking.confirm.primary}
|
|
147
|
+
</button>
|
|
148
|
+
</span>
|
|
149
|
+
</div>
|
|
150
|
+
) : (
|
|
151
|
+
<>
|
|
152
|
+
{account.switch || gh?.canSignIn || account.signOut || ghOut ? (
|
|
153
|
+
<hr className="sh-acct-sep" />
|
|
154
|
+
) : null}
|
|
155
|
+
{account.switch ? (
|
|
156
|
+
<button
|
|
157
|
+
type="button"
|
|
158
|
+
className="sh-acct-act"
|
|
159
|
+
data-testid="project-account-switch"
|
|
160
|
+
onClick={() => {
|
|
161
|
+
if (!account.switch.path) return go(account.switch.id);
|
|
162
|
+
onClose?.();
|
|
163
|
+
onSwitch?.(account.switch);
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
{account.switch.label}
|
|
167
|
+
</button>
|
|
168
|
+
) : null}
|
|
169
|
+
{gh?.canSignIn ? (
|
|
170
|
+
<button
|
|
171
|
+
type="button"
|
|
172
|
+
className="sh-acct-act"
|
|
173
|
+
data-testid="project-account-github-signin"
|
|
174
|
+
onClick={() => go('account.github-signin')}
|
|
175
|
+
>
|
|
176
|
+
Sign in with GitHub…
|
|
177
|
+
</button>
|
|
178
|
+
) : null}
|
|
179
|
+
{account.signOut ? (
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
className="sh-acct-act"
|
|
183
|
+
data-testid="project-account-signout"
|
|
184
|
+
onClick={() => setAsking(account.signOut)}
|
|
185
|
+
>
|
|
186
|
+
{account.signOut.label}
|
|
187
|
+
</button>
|
|
188
|
+
) : null}
|
|
189
|
+
{ghOut ? (
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
className="sh-acct-act"
|
|
193
|
+
data-testid="project-account-github-signout"
|
|
194
|
+
onClick={() => setAsking(ghOut)}
|
|
195
|
+
>
|
|
196
|
+
{ghOut.label}
|
|
197
|
+
</button>
|
|
198
|
+
) : null}
|
|
199
|
+
</>
|
|
200
|
+
)}
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// client/v2/shell/project-account-model.js — 2.0.5 W4: which account THIS project uses, and how.
|
|
2
|
+
//
|
|
3
|
+
// PURE: what the avatar's card says and which existing path each of its buttons runs. Michal's rule
|
|
4
|
+
// after 2.0.4 — every button does something, nothing fails — so a row exists only where its path does:
|
|
5
|
+
//
|
|
6
|
+
// kind team server · Maude Cloud · GitHub · nothing (this Mac only)
|
|
7
|
+
// profile `/_config.profile` — the account slot this project is bound to (V2-3.1; the server
|
|
8
|
+
// learns it from env only, MAUDE_PROFILE_ID / _LABEL)
|
|
9
|
+
// where the team server's host, or the cloud project's name
|
|
10
|
+
// who the signed-in login / e-mail, only where the page already holds it (the hub's recorded
|
|
11
|
+
// account from `/_api/connections/hub`, the cloud e-mail from `/_api/cloud/status`, the
|
|
12
|
+
// GitHub login from `/_api/github/identity`, a cloud tab's `cfg.cloud.user.email`)
|
|
13
|
+
//
|
|
14
|
+
// Sign out, per kind — each the path its Settings › Connections row already runs, never a new one:
|
|
15
|
+
// cloud-signout POST /_api/cloud/signout — clears this project's PROFILE cloud credential (V2-3.8)
|
|
16
|
+
// hub-detach POST /_api/cloud/detach — Settings' team-server "Sign out": the link + its sign-in
|
|
17
|
+
// github-signout the shell's `github_sign_out` — the calling project's profile keychain slot
|
|
18
|
+
// Switch, per kind — through the bind-on-sign-in rule (decision v2-3.8-bind-on-sign-in):
|
|
19
|
+
// cloud `account.switch` → `cloud_sign_in_prepare` (a fresh profile bound to this project)
|
|
20
|
+
// github `account.github-signin` → `github_sign_in` (settle_sign_in rebinds on another login)
|
|
21
|
+
// team server W4b: `hub-switch` → `team_sign_in_prepare` (this project moves to a fresh profile
|
|
22
|
+
// of its own when its profile is shared — the shell restarts it, the page reloads,
|
|
23
|
+
// the person signs in there) → `/_api/hub-signin/start` + the server's own page.
|
|
24
|
+
// A browser tab on this Mac has no shell: it says what is known and offers no button. A cloud tab's
|
|
25
|
+
// account is the hub's browser session: `account.switch` ends it (the v1 menubar's Sign out).
|
|
26
|
+
|
|
27
|
+
import { ACTIONS_BY_ID } from '../../../actions/index.ts';
|
|
28
|
+
import { isCloudHub } from '../settings/connections-model.js';
|
|
29
|
+
|
|
30
|
+
// host, plus the port when it is not the scheme's default (URL.host drops 443/80) — as the Home card says it
|
|
31
|
+
const hostOf = (url) => {
|
|
32
|
+
try {
|
|
33
|
+
return new URL(String(url)).host.toLowerCase();
|
|
34
|
+
} catch {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
39
|
+
const labelOf = (id) => ACTIONS_BY_ID.get(id)?.label ?? '';
|
|
40
|
+
|
|
41
|
+
export const KIND_LABELS = Object.freeze({
|
|
42
|
+
team: 'Team server',
|
|
43
|
+
cloud: 'Maude Cloud',
|
|
44
|
+
github: 'GitHub',
|
|
45
|
+
local: 'This Mac only',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const GITHUB_NEEDS_APP = 'Signing in with GitHub needs the Maude desktop app.';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param in.native the desktop app (a Tauri shell)
|
|
52
|
+
* @param in.cloudTab `cfg.cloud` of a cloud tab, else null
|
|
53
|
+
* @param in.profile `/_config.profile` { id, label? }
|
|
54
|
+
* @param in.project this project's name
|
|
55
|
+
* @param in.linkedHub { url, credentialed } from `/_api/cloud/status`
|
|
56
|
+
* @param in.hubAccount the hub sign-in's recorded account (`/_api/connections/hub` `account`)
|
|
57
|
+
* @param in.cloudUrl the Maude Cloud address this Mac signs in against
|
|
58
|
+
* @param in.cloudConnected this profile holds a Maude Cloud sign-in
|
|
59
|
+
* @param in.cloudEmail its e-mail
|
|
60
|
+
* @param in.github { state: 'loading'|'in'|'out', login }
|
|
61
|
+
*/
|
|
62
|
+
export function projectAccount(input = {}) {
|
|
63
|
+
const {
|
|
64
|
+
native = false,
|
|
65
|
+
cloudTab = null,
|
|
66
|
+
profile = null,
|
|
67
|
+
project = null,
|
|
68
|
+
linkedHub = null,
|
|
69
|
+
hubAccount = null,
|
|
70
|
+
cloudUrl = '',
|
|
71
|
+
cloudConnected = false,
|
|
72
|
+
cloudEmail = null,
|
|
73
|
+
github = null,
|
|
74
|
+
} = input;
|
|
75
|
+
const profileLabel = str(profile?.label) || str(profile?.id) || (native ? 'default' : null);
|
|
76
|
+
|
|
77
|
+
if (cloudTab) {
|
|
78
|
+
// A browser on a cell: a hub with a dashboard is Maude Cloud, one that serves a single project is a
|
|
79
|
+
// team's own server. No Mac, no keychain, no GitHub.
|
|
80
|
+
const email = str(cloudTab.user?.email);
|
|
81
|
+
return {
|
|
82
|
+
kind: cloudTab.dashboardUrl ? 'cloud' : 'team',
|
|
83
|
+
kindLabel: KIND_LABELS[cloudTab.dashboardUrl ? 'cloud' : 'team'],
|
|
84
|
+
profileLabel: null,
|
|
85
|
+
where: str(cloudTab.projectName) || str(project),
|
|
86
|
+
who: email,
|
|
87
|
+
signOut: null,
|
|
88
|
+
// the registry hides account.switch in a cloud tab without a user (app.jsx); so does the card
|
|
89
|
+
switch: email ? { id: 'account.switch', label: labelOf('account.switch') } : null,
|
|
90
|
+
github: null,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const hubUrl = str(linkedHub?.url);
|
|
95
|
+
const cloudHub = hubUrl ? isCloudHub(hubUrl, cloudUrl) : false;
|
|
96
|
+
const ghIn = github?.state === 'in';
|
|
97
|
+
const ghLogin = ghIn ? str(github?.login) : null;
|
|
98
|
+
let kind = 'local';
|
|
99
|
+
if (hubUrl && !cloudHub) kind = 'team';
|
|
100
|
+
else if (cloudConnected || (hubUrl && cloudHub)) kind = 'cloud';
|
|
101
|
+
else if (ghIn) kind = 'github';
|
|
102
|
+
|
|
103
|
+
const who =
|
|
104
|
+
kind === 'team'
|
|
105
|
+
? str(hubAccount)
|
|
106
|
+
: kind === 'cloud'
|
|
107
|
+
? str(cloudEmail)
|
|
108
|
+
: kind === 'github' && ghLogin
|
|
109
|
+
? `@${ghLogin}`
|
|
110
|
+
: null;
|
|
111
|
+
const where = kind === 'team' ? hostOf(hubUrl) || hubUrl : kind === 'cloud' ? str(project) : null;
|
|
112
|
+
|
|
113
|
+
let signOut = null;
|
|
114
|
+
let sw = null;
|
|
115
|
+
if (native) {
|
|
116
|
+
if (kind === 'cloud' && cloudConnected) {
|
|
117
|
+
const name = who || profileLabel;
|
|
118
|
+
// The account card's words (account-card-model.js), unchanged: one confirm on every surface.
|
|
119
|
+
signOut = {
|
|
120
|
+
path: 'cloud-signout',
|
|
121
|
+
label: `Sign out of ${name}…`,
|
|
122
|
+
confirm: {
|
|
123
|
+
title: `Sign out of ${name}?`,
|
|
124
|
+
body: 'Every project on it is signed out. Your work stays on this Mac.',
|
|
125
|
+
primary: 'Sign out',
|
|
126
|
+
cancel: 'Cancel',
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
sw = { id: 'account.switch', label: labelOf('account.switch') };
|
|
130
|
+
} else if (kind === 'team') {
|
|
131
|
+
const host = where || 'this server';
|
|
132
|
+
// 2.0.5 W4b — Switch through `team_sign_in_prepare`: a project on a profile other projects
|
|
133
|
+
// share first moves to its own (the shell restarts it); then the team server's own page.
|
|
134
|
+
sw = {
|
|
135
|
+
path: 'hub-switch',
|
|
136
|
+
url: hubUrl,
|
|
137
|
+
label: linkedHub?.credentialed ? 'Sign in as someone else…' : `Sign in to ${host}…`,
|
|
138
|
+
};
|
|
139
|
+
if (linkedHub?.credentialed)
|
|
140
|
+
signOut = {
|
|
141
|
+
path: 'hub-detach',
|
|
142
|
+
label: `Sign out of ${host}…`,
|
|
143
|
+
confirm: {
|
|
144
|
+
title: `Sign out of ${host}?`,
|
|
145
|
+
body: 'This folder stops syncing with it. Your work stays on this Mac.',
|
|
146
|
+
primary: 'Sign out',
|
|
147
|
+
cancel: 'Cancel',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
} else if (kind === 'github' && ghLogin) {
|
|
151
|
+
signOut = {
|
|
152
|
+
path: 'github-signout',
|
|
153
|
+
label: `Sign out of @${ghLogin}…`,
|
|
154
|
+
confirm: {
|
|
155
|
+
title: `Sign out of @${ghLogin}?`,
|
|
156
|
+
body: 'Every project on it is signed out of GitHub. Your work stays on this Mac.',
|
|
157
|
+
primary: 'Sign out',
|
|
158
|
+
cancel: 'Cancel',
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
sw = { id: 'account.github-signin', label: 'Sign in as another GitHub account…' };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
kind,
|
|
167
|
+
kindLabel: KIND_LABELS[kind],
|
|
168
|
+
profileLabel,
|
|
169
|
+
where,
|
|
170
|
+
who,
|
|
171
|
+
signOut,
|
|
172
|
+
switch: sw,
|
|
173
|
+
// The GitHub line: sign in where the app can, sign out where it is the second account of the card.
|
|
174
|
+
github: native
|
|
175
|
+
? {
|
|
176
|
+
login: ghLogin,
|
|
177
|
+
canSignIn: !ghIn && github?.state !== 'loading',
|
|
178
|
+
canSignOut: ghIn && kind !== 'github',
|
|
179
|
+
}
|
|
180
|
+
: { login: null, canSignIn: false, canSignOut: false, note: GITHUB_NEEDS_APP },
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { useEffect, useState, useSyncExternalStore } from 'react';
|
|
12
12
|
|
|
13
13
|
import { onCrashed } from './native-doors.js';
|
|
14
|
+
import { servedFetch } from './served-routes.js';
|
|
14
15
|
|
|
15
16
|
const EMPTY = Object.freeze({ full: false, held: 0, since: null });
|
|
16
17
|
const POLL_MS = 8000;
|
|
@@ -36,7 +37,7 @@ function set(next) {
|
|
|
36
37
|
export async function refreshDisk(fetchImpl = globalThis.fetch) {
|
|
37
38
|
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return disk;
|
|
38
39
|
try {
|
|
39
|
-
const r = await
|
|
40
|
+
const r = await servedFetch('/_api/diagnostics/disk', undefined, fetchImpl);
|
|
40
41
|
if (r.ok) set(await r.json());
|
|
41
42
|
} catch {
|
|
42
43
|
/* the studio is restarting: keep what we knew */
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// client/v2/shell/served-routes.js — #204: the shell asks only what this server serves.
|
|
2
|
+
//
|
|
3
|
+
// In a workspace cell (`/_config.cloud` present — DDR-193 / DDR-209) the hub's door refuses the
|
|
4
|
+
// desktop-only routes (apps/hub/src/studio-manifest.mjs REFUSED → 404, "a cell should look like it
|
|
5
|
+
// never had the feature") or the studio prunes them (workspace-mode.ts FORBIDDEN_ROUTE_PREFIXES).
|
|
6
|
+
// The shell polled them anyway, every few seconds, forever: 318 requests in a few minutes against
|
|
7
|
+
// design.studyfi.com, every one a 404. Two rules:
|
|
8
|
+
//
|
|
9
|
+
// 1. A cell is told by `/_config` (the `cloud` block, the one cloud-only input the client takes):
|
|
10
|
+
// the routes in CELL_UNSERVED are not asked at all.
|
|
11
|
+
// 2. Anywhere, a 404 from a POLLED route means "not here": that route is not asked again on this
|
|
12
|
+
// page. A 404 cannot get better by asking every 8 s; a reload asks again.
|
|
13
|
+
//
|
|
14
|
+
// Task R adds the ONE-SHOT callers (a panel's mount, a tab's open — `fetchIfServed`: rule 1 only,
|
|
15
|
+
// since a one-shot 404 can be about the canvas it named) and the start-up race: the pollers mount
|
|
16
|
+
// before `/_config` answers, so at boot the shell says a config is coming (`expectServedFrom`) and the
|
|
17
|
+
// first asks wait for it — bounded — instead of going out blind.
|
|
18
|
+
//
|
|
19
|
+
// `test/served-routes.test.ts` holds CELL_UNSERVED to the hub manifest: every entry is refused there.
|
|
20
|
+
|
|
21
|
+
/** Routes a workspace cell never serves (the exact path, or a prefix when the entry ends in `/`). */
|
|
22
|
+
export const CELL_UNSERVED = Object.freeze([
|
|
23
|
+
'/_api/outbox', // the outbox carries personal text and a cell is multi-user (C27)
|
|
24
|
+
'/_api/sync/conflicts', // the conflict record lives on a Mac; a cell IS the copy
|
|
25
|
+
'/_api/diagnostics/', // the process logs (V2-2.9) — pruned by the studio itself
|
|
26
|
+
'/_api/ai/runs', // AI runs are this Mac's; a cell runs no agent (DDR-123)
|
|
27
|
+
// task R — asked once per load or per open, not polled
|
|
28
|
+
'/_api/index', // the project index has no per-canvas `sees` filter yet (V2-2.17)
|
|
29
|
+
'/_api/thumbs/want', // cells render no pictures (V2-1.17 R7)
|
|
30
|
+
'/_api/pins', // one member's pins would become everyone's
|
|
31
|
+
'/_api/sync/trash', // the per-Mac quarantine list; a cell's checkout is the operator's
|
|
32
|
+
'/_api/project/undo-stack', // personal undo is this Mac's
|
|
33
|
+
'/_api/asset-state', // the per-Mac asset ledger
|
|
34
|
+
'/_api/votes', // board votes are the hub's (S9.13)
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
/** How long a first ask waits for `/_config` before it goes out anyway. */
|
|
38
|
+
export const CONFIG_WAIT_MS = 4000;
|
|
39
|
+
|
|
40
|
+
let cell = false;
|
|
41
|
+
const gone = new Set();
|
|
42
|
+
/** While the shell's `/_config` is on its way: what the first asks wait on. */
|
|
43
|
+
let pending = null;
|
|
44
|
+
let settle = null;
|
|
45
|
+
|
|
46
|
+
const pathOf = (url) => {
|
|
47
|
+
const s = String(url || '');
|
|
48
|
+
const q = s.search(/[?#]/);
|
|
49
|
+
return q === -1 ? s : s.slice(0, q);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** The shell is about to read `/_config` (boot): asks made before it answers wait for it, bounded. */
|
|
53
|
+
export function expectServedFrom(waitMs = CONFIG_WAIT_MS) {
|
|
54
|
+
if (pending) return;
|
|
55
|
+
let timer = null;
|
|
56
|
+
pending = new Promise((resolve) => {
|
|
57
|
+
settle = resolve;
|
|
58
|
+
timer = setTimeout(resolve, waitMs);
|
|
59
|
+
}).then(() => {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
pending = null;
|
|
62
|
+
settle = null;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `/_config` arrived: is this a workspace cell? */
|
|
67
|
+
export function setServedFrom(cfg) {
|
|
68
|
+
cell = !!(cfg && typeof cfg === 'object' && cfg.cloud);
|
|
69
|
+
settle?.();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Should the shell ask this route at all? */
|
|
73
|
+
export function served(url) {
|
|
74
|
+
const path = pathOf(url);
|
|
75
|
+
if (gone.has(path)) return false;
|
|
76
|
+
if (cell && CELL_UNSERVED.some((p) => path === p || (p.endsWith('/') && path.startsWith(p))))
|
|
77
|
+
return false;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** What the route answered. A 404 means it is not here: it is not polled again on this page. */
|
|
82
|
+
export function noteServed(url, status) {
|
|
83
|
+
if (status === 404) gone.add(pathOf(url));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The answer an unserved route gets without a request: a 404, like the server's own. */
|
|
87
|
+
const UNSERVED = Object.freeze({
|
|
88
|
+
ok: false,
|
|
89
|
+
status: 404,
|
|
90
|
+
json: async () => null,
|
|
91
|
+
text: async () => '',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/** `fetch` for a POLLED route: unserved routes are not asked, and a 404 is remembered. */
|
|
95
|
+
export async function servedFetch(url, init, fetchImpl = globalThis.fetch) {
|
|
96
|
+
if (pending) await pending;
|
|
97
|
+
if (!served(url)) return UNSERVED;
|
|
98
|
+
const res = await fetchImpl(url, init);
|
|
99
|
+
noteServed(url, res?.status);
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `fetch` for a ONE-SHOT route (a mount, an open): not asked when this server withholds it. The answer
|
|
105
|
+
* is not remembered — a one-shot 404 can be about the canvas it named rather than the route.
|
|
106
|
+
*/
|
|
107
|
+
export async function fetchIfServed(url, init, fetchImpl = globalThis.fetch) {
|
|
108
|
+
if (pending) await pending;
|
|
109
|
+
if (!served(url)) return UNSERVED;
|
|
110
|
+
return fetchImpl(url, init);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Tests only. */
|
|
114
|
+
export function resetServed() {
|
|
115
|
+
settle?.();
|
|
116
|
+
cell = false;
|
|
117
|
+
gone.clear();
|
|
118
|
+
pending = null;
|
|
119
|
+
settle = null;
|
|
120
|
+
}
|