@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
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// client/v2/onboarding/HubSheet.jsx — "Connect to your own hub" (02 ob-adv-sheets, S6.9). The sheet S11.14's
|
|
2
2
|
// Settings › Connections mounts as "Add a team server…" (G0-D/D12), so it is a view: it owns its fields and
|
|
3
|
-
// calls back; what Test connection and
|
|
3
|
+
// calls back; what Test connection and Sign in DO is the caller's (Home: `/_home/hub/{test,signin/*,prepare}`).
|
|
4
4
|
//
|
|
5
|
-
// <HubSheet onTest={(url) => {ok, version?, error?}}
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// <HubSheet onTest={(url) => {ok, version?, error?}}
|
|
6
|
+
// onSignIn={({url, invite, onWaiting}) => {ok, error?, cancelled?}}
|
|
7
|
+
// onAbortSignIn={() => void} onCancel />
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
9
|
+
// Issue #204 (decision maude/v2-michal-team-server-signin-via-hub-page): the app owns NO login method for a
|
|
10
|
+
// team server. There is no email or password field here: Sign in opens the hub's OWN sign-in page in the
|
|
11
|
+
// browser (with an invite, the hub's own invite page), the sheet waits (`onWaiting` → "Finish signing in in
|
|
12
|
+
// your browser.", Cancel = `onAbortSignIn`) and the caller opens the project once the browser came back.
|
|
13
|
+
// The invite key is a bearer secret: a masked field, read once on Sign in and emptied at once; an error
|
|
14
|
+
// line is the server's own words, never an echo.
|
|
14
15
|
|
|
15
16
|
import { useEffect, useRef, useState } from 'react';
|
|
16
17
|
|
|
@@ -31,18 +32,17 @@ export function hubOfInviteLink(raw) {
|
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* @param {{ onTest: (url: string) => Promise<{ok: boolean, version?: string|null, error?: string}>,
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* onSignIn: (v: {url: string, invite: string, onWaiting: () => void}) =>
|
|
36
|
+
* Promise<{ok: boolean, error?: string, cancelled?: boolean}>,
|
|
37
|
+
* onAbortSignIn?: () => void,
|
|
36
38
|
* onCancel: () => void, initialUrl?: string }} props
|
|
37
39
|
*/
|
|
38
|
-
export function HubSheet({ onTest,
|
|
40
|
+
export function HubSheet({ onTest, onSignIn, onAbortSignIn, onCancel, initialUrl = '' }) {
|
|
39
41
|
const [url, setUrl] = useState(initialUrl);
|
|
40
|
-
const [mode, setMode] = useState('password'); // 'password' | 'invite'
|
|
41
|
-
const [email, setEmail] = useState('');
|
|
42
|
-
const [password, setPassword] = useState('');
|
|
43
42
|
const [invite, setInvite] = useState('');
|
|
44
43
|
const [test, setTest] = useState({ phase: 'idle', version: null, error: null });
|
|
45
44
|
const [busy, setBusy] = useState(false);
|
|
45
|
+
const [waiting, setWaiting] = useState(false);
|
|
46
46
|
const [error, setError] = useState(null);
|
|
47
47
|
const alive = useRef(true);
|
|
48
48
|
const seq = useRef(0); // an answer for an address that has since changed is dropped
|
|
@@ -70,41 +70,46 @@ export function HubSheet({ onTest, onConnect, onJoin, onCancel, initialUrl = ''
|
|
|
70
70
|
);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
// read once, empty the fields now — the password (and an invite key) never outlives this call in the page
|
|
76
|
-
const creds = email.trim() || password ? { email: email.trim(), password } : null;
|
|
73
|
+
const signIn = async () => {
|
|
74
|
+
// read once, empty the field now — an invite key never outlives this call in the page
|
|
77
75
|
const key = invite.trim();
|
|
78
|
-
setPassword('');
|
|
79
76
|
setInvite('');
|
|
80
77
|
setError(null);
|
|
81
78
|
setBusy(true);
|
|
82
79
|
let r;
|
|
83
80
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
r = await onSignIn({
|
|
82
|
+
url: url.trim(),
|
|
83
|
+
invite: key,
|
|
84
|
+
onWaiting: () => {
|
|
85
|
+
if (alive.current) setWaiting(true);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
87
88
|
} catch {
|
|
88
89
|
r = { ok: false, error: W.unreachable };
|
|
89
90
|
}
|
|
90
91
|
if (!alive.current) return;
|
|
91
92
|
setBusy(false);
|
|
92
|
-
|
|
93
|
+
setWaiting(false);
|
|
94
|
+
if (!r?.ok && !r?.cancelled) setError(r?.error || W.unreachable);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const abort = () => {
|
|
98
|
+
setWaiting(false);
|
|
99
|
+
onAbortSignIn?.();
|
|
93
100
|
};
|
|
94
101
|
|
|
95
102
|
return (
|
|
96
|
-
<AdvModal onCancel={onCancel}>
|
|
103
|
+
<AdvModal onCancel={waiting ? abort : onCancel}>
|
|
97
104
|
<AdvSheet
|
|
98
105
|
id="hub"
|
|
99
106
|
title={W.title}
|
|
100
107
|
verb={W.verb}
|
|
101
108
|
busyVerb={W.busy}
|
|
102
109
|
busy={busy}
|
|
103
|
-
canSubmit={
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
onSubmit={connect}
|
|
107
|
-
onCancel={onCancel}
|
|
110
|
+
canSubmit={!!url.trim() && !busy}
|
|
111
|
+
onSubmit={signIn}
|
|
112
|
+
onCancel={waiting ? abort : onCancel}
|
|
108
113
|
>
|
|
109
114
|
<span className="ob-field">
|
|
110
115
|
<label className="ob-field-label" htmlFor="onb-hub-url">
|
|
@@ -122,6 +127,7 @@ export function HubSheet({ onTest, onConnect, onJoin, onCancel, initialUrl = ''
|
|
|
122
127
|
placeholder="https://"
|
|
123
128
|
// biome-ignore lint/a11y/noAutofocus: the sheet opens for this one field
|
|
124
129
|
autoFocus
|
|
130
|
+
disabled={busy}
|
|
125
131
|
value={url}
|
|
126
132
|
onChange={(e) => {
|
|
127
133
|
seq.current += 1;
|
|
@@ -133,7 +139,7 @@ export function HubSheet({ onTest, onConnect, onJoin, onCancel, initialUrl = ''
|
|
|
133
139
|
type="button"
|
|
134
140
|
className="btn btn--sm"
|
|
135
141
|
data-testid="onb-hub-test"
|
|
136
|
-
disabled={!url.trim() || test.phase === 'busy'}
|
|
142
|
+
disabled={!url.trim() || test.phase === 'busy' || busy}
|
|
137
143
|
onClick={runTest}
|
|
138
144
|
>
|
|
139
145
|
{W.test}
|
|
@@ -160,41 +166,20 @@ export function HubSheet({ onTest, onConnect, onJoin, onCancel, initialUrl = ''
|
|
|
160
166
|
) : null}
|
|
161
167
|
</span>
|
|
162
168
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
className="ob-seg-b"
|
|
168
|
-
aria-pressed={inviteMode ? 'false' : 'true'}
|
|
169
|
-
data-testid="onb-hub-mode-password"
|
|
170
|
-
onClick={() => setMode('password')}
|
|
171
|
-
>
|
|
172
|
-
{W.modePassword}
|
|
173
|
-
</button>
|
|
174
|
-
<button
|
|
175
|
-
type="button"
|
|
176
|
-
className="ob-seg-b"
|
|
177
|
-
aria-pressed={inviteMode ? 'true' : 'false'}
|
|
178
|
-
aria-disabled={onJoin ? undefined : 'true'}
|
|
179
|
-
data-testid="onb-hub-mode-invite"
|
|
180
|
-
onClick={() => {
|
|
181
|
-
if (onJoin) setMode('invite');
|
|
182
|
-
}}
|
|
183
|
-
>
|
|
184
|
-
{W.modeInvite}
|
|
185
|
-
</button>
|
|
186
|
-
</span>
|
|
187
|
-
|
|
188
|
-
{inviteMode ? (
|
|
169
|
+
<span className="ob-field">
|
|
170
|
+
<label className="ob-field-label" htmlFor="onb-hub-invite">
|
|
171
|
+
{W.inviteLabel}
|
|
172
|
+
</label>
|
|
189
173
|
<input
|
|
174
|
+
id="onb-hub-invite"
|
|
190
175
|
className="ob-input"
|
|
191
176
|
data-testid="onb-hub-invite"
|
|
192
|
-
// a bearer secret
|
|
177
|
+
// a bearer secret: masked, never drawn back
|
|
193
178
|
type="password"
|
|
194
179
|
autoComplete="off"
|
|
195
180
|
spellCheck={false}
|
|
196
|
-
|
|
197
|
-
|
|
181
|
+
placeholder={W.invitePlaceholder}
|
|
182
|
+
disabled={busy}
|
|
198
183
|
value={invite}
|
|
199
184
|
onChange={(e) => {
|
|
200
185
|
const v = e.target.value;
|
|
@@ -208,30 +193,13 @@ export function HubSheet({ onTest, onConnect, onJoin, onCancel, initialUrl = ''
|
|
|
208
193
|
}
|
|
209
194
|
}}
|
|
210
195
|
/>
|
|
211
|
-
) : null}
|
|
212
|
-
|
|
213
|
-
<span className="ob-row2">
|
|
214
|
-
<input
|
|
215
|
-
className="ob-input"
|
|
216
|
-
data-testid="onb-hub-email"
|
|
217
|
-
type="email"
|
|
218
|
-
autoComplete="off"
|
|
219
|
-
aria-label="Email"
|
|
220
|
-
placeholder="you@alligators.cz"
|
|
221
|
-
value={email}
|
|
222
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
223
|
-
/>
|
|
224
|
-
<input
|
|
225
|
-
className="ob-input"
|
|
226
|
-
data-testid="onb-hub-password"
|
|
227
|
-
type="password"
|
|
228
|
-
autoComplete="off"
|
|
229
|
-
aria-label="Password"
|
|
230
|
-
placeholder="Password"
|
|
231
|
-
value={password}
|
|
232
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
233
|
-
/>
|
|
234
196
|
</span>
|
|
197
|
+
|
|
198
|
+
{waiting ? (
|
|
199
|
+
<p className="ob-ok" role="status" data-testid="onb-hub-waiting">
|
|
200
|
+
<Sw state="busy">{W.waiting}</Sw>
|
|
201
|
+
</p>
|
|
202
|
+
) : null}
|
|
235
203
|
{error ? (
|
|
236
204
|
<p className="ai-conn-err" role="alert" data-testid="onb-hub-error">
|
|
237
205
|
{error}
|
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
// main button ("Connect to your own hub" → Connect). Advanced language (addresses, commands, keys) is allowed
|
|
4
4
|
// here and only here (the canvas's note 15).
|
|
5
5
|
|
|
6
|
+
// Issue #204: one Sign in — the hub's own page in the browser; no email or password field in the app.
|
|
6
7
|
export const HUB_WORDS = {
|
|
7
|
-
title: '
|
|
8
|
-
verb: '
|
|
9
|
-
busy: '
|
|
8
|
+
title: 'Sign in to your own hub',
|
|
9
|
+
verb: 'Sign in',
|
|
10
|
+
busy: 'Signing in…',
|
|
10
11
|
addressLabel: 'Hub address',
|
|
11
12
|
test: 'Test connection',
|
|
12
13
|
testing: 'Testing…',
|
|
13
14
|
reachable: (version) => (version ? `Reachable — hub ${version}` : 'Reachable'),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
inviteLabel: 'Invite link or key (if you have one)',
|
|
16
|
+
invitePlaceholder: 'Invite link or key',
|
|
17
|
+
waiting: 'Finish signing in in your browser.',
|
|
18
|
+
refused: 'That address can’t be opened. Check the hub address.',
|
|
19
|
+
noBrowser: 'The browser didn’t open. Try again.',
|
|
20
|
+
fine: 'Sign in opens the hub’s own sign-in page in your browser. Maude Cloud stays signed in too.',
|
|
17
21
|
unreachable: "Couldn't reach that hub. Check the address, or whether it's online.",
|
|
18
22
|
};
|
|
19
23
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// row in declared order, so the declared order IS the canvas order.
|
|
10
10
|
|
|
11
11
|
import { canvasOrder } from '../../../present/order.ts';
|
|
12
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
12
13
|
|
|
13
14
|
const finite = (n) => typeof n === 'number' && Number.isFinite(n);
|
|
14
15
|
const text = (v) => (typeof v === 'string' && v.trim() ? v : null);
|
|
@@ -74,7 +75,7 @@ export function indexRowFor(snapshot, path) {
|
|
|
74
75
|
export async function loadOrderNotesArtboards(path, fetchImpl = (...a) => fetch(...a)) {
|
|
75
76
|
const json = async (url) => {
|
|
76
77
|
try {
|
|
77
|
-
const r = await
|
|
78
|
+
const r = await fetchIfServed(url, { cache: 'no-store' }, fetchImpl);
|
|
78
79
|
return r.ok ? await r.json() : null;
|
|
79
80
|
} catch {
|
|
80
81
|
return null;
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
// "Recently opened" order read. The list is "known empty" only when the server ANSWERED with an `opened`
|
|
10
10
|
// object — an offline server or an old build is "don't know", and ⌘K then shows the short list as before.
|
|
11
11
|
|
|
12
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
13
|
+
|
|
12
14
|
/** Recent rows on screen. */
|
|
13
15
|
export const RECENT_CAP = 5;
|
|
14
16
|
|
|
@@ -31,7 +33,7 @@ export async function fetchRecents({ signal, fetchImpl = globalThis.fetch } = {}
|
|
|
31
33
|
const none = { known: false, opened: {} };
|
|
32
34
|
if (!fetchImpl) return none;
|
|
33
35
|
try {
|
|
34
|
-
const r = await
|
|
36
|
+
const r = await fetchIfServed('/_api/pins', { signal, cache: 'no-store' }, fetchImpl);
|
|
35
37
|
if (!r.ok) return none;
|
|
36
38
|
const raw = await r.json();
|
|
37
39
|
if (!raw || typeof raw.opened !== 'object' || raw.opened === null || Array.isArray(raw.opened))
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// the dash in "New artboard — A4" would be a word nothing contains.
|
|
6
6
|
|
|
7
7
|
import { sanitizeQuery } from './search-model.js';
|
|
8
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @param fetchImpl (url, { signal }) => Promise<Response> — injected so tests need no network
|
|
@@ -14,10 +15,11 @@ export async function searchIndex(query, { signal, fetchImpl = globalThis.fetch
|
|
|
14
15
|
const q = sanitizeQuery(query);
|
|
15
16
|
if (!q || !fetchImpl) return null;
|
|
16
17
|
try {
|
|
17
|
-
const r = await
|
|
18
|
-
|
|
19
|
-
cache: 'no-store',
|
|
20
|
-
|
|
18
|
+
const r = await fetchIfServed(
|
|
19
|
+
`/_api/index?q=${encodeURIComponent(q)}`,
|
|
20
|
+
{ signal, cache: 'no-store' },
|
|
21
|
+
fetchImpl
|
|
22
|
+
);
|
|
21
23
|
if (!r.ok) return null;
|
|
22
24
|
const data = await r.json();
|
|
23
25
|
return Array.isArray(data?.rows) ? data : null;
|
|
@@ -60,7 +60,7 @@ export function hubRow({ linkedHub, cloudUrl, project, lastSyncAt, now = Date.no
|
|
|
60
60
|
return {
|
|
61
61
|
linked: false,
|
|
62
62
|
title: 'Your team’s own server',
|
|
63
|
-
status: 'Sign in
|
|
63
|
+
status: 'Sign in on the server’s own page.',
|
|
64
64
|
tone: '',
|
|
65
65
|
action: 'add',
|
|
66
66
|
};
|
|
@@ -310,6 +310,7 @@ export function createMenuHandlers(d) {
|
|
|
310
310
|
// S8.12 — the picked tile's Place / Show details (the key and the tile menu run the same two functions)
|
|
311
311
|
'assets.place': () => runAssetsAction('assets.place'),
|
|
312
312
|
'assets.details': () => runAssetsAction('assets.details'),
|
|
313
|
+
'assets.spotlight': () => runAssetsAction('assets.spotlight'),
|
|
313
314
|
'assets.trash': () => runAssetsAction('assets.trash'),
|
|
314
315
|
'assets.rename': () => runAssetsAction('assets.rename'),
|
|
315
316
|
// S8.16 — Assets › Generate: the ask lives in the Assets tab, so the tab is shown first
|
|
@@ -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
|
|
|
@@ -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
|
+
}
|
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
presenterAvailable,
|
|
60
60
|
usePresenterDisplays,
|
|
61
61
|
} from '../present/presenter-store.js';
|
|
62
|
+
import { servedFetch } from './served-routes.js';
|
|
62
63
|
|
|
63
64
|
const subscribeOnline = (fn) => {
|
|
64
65
|
window.addEventListener('online', fn);
|
|
@@ -83,7 +84,7 @@ function useOutboxPending(enabled, nudge) {
|
|
|
83
84
|
let live = true;
|
|
84
85
|
const read = () => {
|
|
85
86
|
if (document.visibilityState === 'hidden') return;
|
|
86
|
-
|
|
87
|
+
servedFetch('/_api/outbox')
|
|
87
88
|
.then((r) => (r.ok ? r.json() : null))
|
|
88
89
|
.then((v) => {
|
|
89
90
|
if (live) setPending(outboxPending(v));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// client/v2/shell/shell-activity.js — 2.0.4 (task O): the shell window's one activity clock, for its server polls.
|
|
2
|
+
//
|
|
3
|
+
// The canvas's clock (editing/page-activity.ts) turns idle after 3 s and counts node changes as use; the shell
|
|
4
|
+
// re-renders on its own (relative times, live rows), so here only input, messages from the canvas, resize, focus
|
|
5
|
+
// and visibility count, and "unused" starts after a minute. `pacedInterval(fn, ms, shellActivity())` keeps the pace
|
|
6
|
+
// while the window is used, slows while it is only looked at, and stops while it is hidden.
|
|
7
|
+
|
|
8
|
+
import { createPageActivity, domActivityEnv } from '../../../editing/page-activity.ts';
|
|
9
|
+
|
|
10
|
+
export const SHELL_IDLE_AFTER_MS = 60_000;
|
|
11
|
+
|
|
12
|
+
let one = null;
|
|
13
|
+
|
|
14
|
+
/** The shell's activity clock (made on first use; null outside a browser). */
|
|
15
|
+
export function shellActivity() {
|
|
16
|
+
if (one || typeof window === 'undefined' || typeof document === 'undefined') return one;
|
|
17
|
+
one = createPageActivity(domActivityEnv(window, { nodes: false }), SHELL_IDLE_AFTER_MS);
|
|
18
|
+
return one;
|
|
19
|
+
}
|
|
@@ -82,8 +82,11 @@ export function useOccludedInsets({ bodyRef, iframesRef, presenting, layoutKey }
|
|
|
82
82
|
pump.seed(win);
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
+
// 2.0.4: a finished ladder leaves the set — its cancel holds `win`, and a kept one kept every canvas
|
|
86
|
+
// ever opened in memory (the webview's per-switch leak, occlusion-insets.js)
|
|
85
87
|
const cancel = seedOnLadder(pump, win, {
|
|
86
88
|
alive: () => frames().some((f) => f.contentWindow === win),
|
|
89
|
+
onDone: () => cancels.delete(cancel),
|
|
87
90
|
});
|
|
88
91
|
cancels.add(cancel);
|
|
89
92
|
};
|
|
@@ -26,6 +26,7 @@ import { useOfflineFoot } from './offline-foot.jsx';
|
|
|
26
26
|
import { useOutboxWords } from './row-words.js';
|
|
27
27
|
import { conflictCard, conflictsFor, whenWords } from './sync-states-model.js';
|
|
28
28
|
import { reasonProps } from '../access/disabled-reason.js';
|
|
29
|
+
import { servedFetch } from '../shell/served-routes.js';
|
|
29
30
|
|
|
30
31
|
/** The shell opens the card from anywhere (the toast's Show, the mark, ⌘K-less row actions). */
|
|
31
32
|
export const OPEN_EVENT = 'maude:sync-conflicts-open';
|
|
@@ -42,7 +43,11 @@ export const PICK = Object.freeze({
|
|
|
42
43
|
|
|
43
44
|
export async function readConflicts(fetchImpl = fetch) {
|
|
44
45
|
try {
|
|
45
|
-
const r = await
|
|
46
|
+
const r = await servedFetch(
|
|
47
|
+
'/_api/sync/conflicts',
|
|
48
|
+
{ headers: { accept: 'application/json' } },
|
|
49
|
+
fetchImpl
|
|
50
|
+
);
|
|
46
51
|
if (!r.ok) return null;
|
|
47
52
|
const j = await r.json();
|
|
48
53
|
return Array.isArray(j?.conflicts) ? j.conflicts : null;
|
|
@@ -258,7 +263,7 @@ export function SyncStatesHost() {
|
|
|
258
263
|
let live = true;
|
|
259
264
|
const read = () => {
|
|
260
265
|
if (document.visibilityState === 'hidden') return;
|
|
261
|
-
|
|
266
|
+
servedFetch('/_api/outbox')
|
|
262
267
|
.then((r) => (r.ok ? r.json() : null))
|
|
263
268
|
.then((v) => live && setOutboxView(v))
|
|
264
269
|
.catch(() => {});
|
|
@@ -26,6 +26,7 @@ import { notifyUndo } from '../../../notifications.tsx';
|
|
|
26
26
|
import { getRunsStore } from '../ai/runs-store.js';
|
|
27
27
|
import { actorName, ownRunWorkingOn } from '../ai/runs-model.js';
|
|
28
28
|
import { historyRows, nextRedo, nextUndo } from './projection.js';
|
|
29
|
+
import { fetchIfServed } from '../shell/served-routes.js';
|
|
29
30
|
|
|
30
31
|
export const UNDO_STACK_ROUTE = '/_api/project/undo-stack';
|
|
31
32
|
export const UNDO_ROUTE = '/_api/project/undo';
|
|
@@ -50,7 +51,8 @@ const isObj = (v) => !!v && typeof v === 'object';
|
|
|
50
51
|
const str = (v) => (typeof v === 'string' ? v : null);
|
|
51
52
|
|
|
52
53
|
async function defaultRequest(method, url, body) {
|
|
53
|
-
|
|
54
|
+
// #204 R — a workspace cell has no personal undo: its stack is not asked
|
|
55
|
+
const r = await fetchIfServed(url, {
|
|
54
56
|
method,
|
|
55
57
|
...(body !== undefined
|
|
56
58
|
? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }
|
|
@@ -247,7 +247,7 @@ export function createCloudEndpoints(ctx: Ctx) {
|
|
|
247
247
|
);
|
|
248
248
|
/** The last plan read, for THIS token only (a new sign-in never sees the old account's plan). */
|
|
249
249
|
let planRead: { token: string; at: number; plan: CloudPlan | null } | null = null;
|
|
250
|
-
|
|
250
|
+
const api = {
|
|
251
251
|
/**
|
|
252
252
|
* Signed in? Who? And WHICH folder is asking? Cheap — reads two files,
|
|
253
253
|
* never the network.
|
|
@@ -730,6 +730,28 @@ export function createCloudEndpoints(ctx: Ctx) {
|
|
|
730
730
|
},
|
|
731
731
|
};
|
|
732
732
|
|
|
733
|
+
// #166 (2.0.4) — the attach lane is single-flight. Two calls that arrive together (a Connect
|
|
734
|
+
// pressed twice before the first answer, a Move to cloud racing a Connect) each ran their own
|
|
735
|
+
// /projects/open + the cell's /auth/login ~5 ms apart and minted two hub sessions for one
|
|
736
|
+
// person. A concurrent repeat now shares the call already running and gets its answer; a call
|
|
737
|
+
// after it settled runs again (a retry after a refusal must still reach the cell).
|
|
738
|
+
const inFlight = new Map<string, Promise<CloudEndpointResult>>();
|
|
739
|
+
const once = (key: string, run: () => Promise<CloudEndpointResult>) => {
|
|
740
|
+
const held = inFlight.get(key);
|
|
741
|
+
if (held) return held;
|
|
742
|
+
const p = run().finally(() => {
|
|
743
|
+
if (inFlight.get(key) === p) inFlight.delete(key);
|
|
744
|
+
});
|
|
745
|
+
inFlight.set(key, p);
|
|
746
|
+
return p;
|
|
747
|
+
};
|
|
748
|
+
const { attach, openManaged, attachStored } = api;
|
|
749
|
+
api.attach = (projectId: string) => once(`attach:${String(projectId)}`, () => attach(projectId));
|
|
750
|
+
api.openManaged = (projectId: string) =>
|
|
751
|
+
once(`open:${String(projectId)}`, () => openManaged(projectId));
|
|
752
|
+
api.attachStored = (hubUrl: string) => once(`link:${String(hubUrl)}`, () => attachStored(hubUrl));
|
|
753
|
+
return api;
|
|
754
|
+
|
|
733
755
|
/**
|
|
734
756
|
* The workspace this folder already answers to, if any. Address only.
|
|
735
757
|
*
|