@1agh/maude 2.0.4 → 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/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/actions/agents.ts +5 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions.manifest.json +13 -1
- package/apps/studio/actions.parity.json +7 -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 +42 -0
- 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/_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 +89 -12
- 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/canvas-lib.tsx +131 -12
- package/apps/studio/client/canvas-url.js +13 -0
- 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 +6 -0
- 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-project-data.jsx +2 -0
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +36 -8
- 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/Composer.jsx +27 -10
- 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/code-bus.js +5 -0
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- 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 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- 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 +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- 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 +11 -0
- 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/share-cluster-host.jsx +137 -10
- 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/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/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 +1232 -1232
- 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/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +14 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/server.ts +8 -10
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +40 -9
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/index.ts +308 -150
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +12 -1
- package/apps/studio/sync/status.ts +3 -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/whats-new.json +72 -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/package.json +8 -8
|
@@ -342,7 +342,13 @@ export function DsReviewHost({
|
|
|
342
342
|
<DsSwitchHost cfg={cfg} activePath={activePath} toast={toast} fetchImpl={fetchImpl} />
|
|
343
343
|
{/* S10.15b — "Bring <system> up to the schema?": the amber dot, the row's menu and the switch's level-11 refusal */}
|
|
344
344
|
<DsUpgradeHost cfg={cfg} toast={toast} fetchImpl={fetchImpl} />
|
|
345
|
-
<DsOffSystemHost
|
|
345
|
+
<DsOffSystemHost
|
|
346
|
+
cfg={cfg}
|
|
347
|
+
activePath={activePath}
|
|
348
|
+
toast={toast}
|
|
349
|
+
frameFor={frameFor}
|
|
350
|
+
fetchImpl={fetchImpl}
|
|
351
|
+
/>
|
|
346
352
|
{/* S10.16b — "Make a design system": the three-input sheet, the filling sections, the ready card */}
|
|
347
353
|
<DsMakeHost
|
|
348
354
|
cfg={cfg}
|
|
@@ -12,19 +12,20 @@
|
|
|
12
12
|
//
|
|
13
13
|
// Every write is the server's to refuse (Can edit on the whole project, rule 12): a refusal comes back as a code
|
|
14
14
|
// and becomes the person's words. The system comes from the canvas the person has open, never from a message.
|
|
15
|
-
// The studio does not push `ds:outside` to the page yet, so
|
|
16
|
-
//
|
|
15
|
+
// The studio does not push `ds:outside` to the page yet, so this is the ONE design-system read on a clock
|
|
16
|
+
// (ds-refresh.js, 2.0.5): once a minute while the window is looked at and the canvas has drawn, plus on a write,
|
|
17
|
+
// a redraw and a return to the window. A file edited outside Maude has no other event.
|
|
17
18
|
|
|
18
19
|
import { useEffect, useRef } from 'react';
|
|
19
|
-
import { pacedInterval } from '../../../editing/page-activity.ts';
|
|
20
|
-
import { shellActivity } from '../shell/shell-activity.js';
|
|
21
20
|
import { contrastLine } from './contrast.js';
|
|
22
21
|
import { fetchBoard } from './token-write.js';
|
|
22
|
+
import { DS_STATE_CHANGED } from './door-write.js';
|
|
23
|
+
import { DS_SLOW_POLL_MS, dsRefresh } from './ds-refresh.js';
|
|
23
24
|
import { getTruth, setTruth, setTruthActions } from './truth-store.js';
|
|
24
25
|
import { headValueName, ownSystemOf, refusalWords, TRUTH_WORDS, truthOf } from './truth-model.js';
|
|
25
26
|
import { bodyOf } from './update-available.jsx';
|
|
26
27
|
|
|
27
|
-
export const TRUTH_POLL_MS =
|
|
28
|
+
export const TRUTH_POLL_MS = DS_SLOW_POLL_MS;
|
|
28
29
|
const JSON_HEADERS = { 'content-type': 'application/json' };
|
|
29
30
|
|
|
30
31
|
async function call(fetchImpl, method, url, body) {
|
|
@@ -152,6 +153,7 @@ export function DsTruthHost({
|
|
|
152
153
|
}
|
|
153
154
|
let dead = false;
|
|
154
155
|
let seq = 0;
|
|
156
|
+
let refresh = async () => {};
|
|
155
157
|
|
|
156
158
|
const tell = (marks) => {
|
|
157
159
|
const frame = live.current.frameFor?.() ?? null;
|
|
@@ -160,10 +162,9 @@ export function DsTruthHost({
|
|
|
160
162
|
postDsMarks(frame, marks, origin);
|
|
161
163
|
};
|
|
162
164
|
|
|
163
|
-
const
|
|
164
|
-
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;
|
|
165
|
+
const read = async (fetchImpl) => {
|
|
165
166
|
const n = ++seq;
|
|
166
|
-
const got = await loadTruth(ds,
|
|
167
|
+
const got = await loadTruth(ds, fetchImpl);
|
|
167
168
|
if (dead || n !== seq) return;
|
|
168
169
|
setTruth(got ? { ...got, busy: false, note: null } : null);
|
|
169
170
|
tell(got ? got.truth.marks : { outside: [], conflicts: [] });
|
|
@@ -176,6 +177,8 @@ export function DsTruthHost({
|
|
|
176
177
|
if (dead) return;
|
|
177
178
|
if (r.ok) {
|
|
178
179
|
say(done());
|
|
180
|
+
// the other hosts (the system's files, the make state) read again too
|
|
181
|
+
window.dispatchEvent(new Event(DS_STATE_CHANGED));
|
|
179
182
|
await refresh();
|
|
180
183
|
} else {
|
|
181
184
|
setTruth((t) => (t ? { ...t, busy: false, note: r.message } : t));
|
|
@@ -213,13 +216,9 @@ export function DsTruthHost({
|
|
|
213
216
|
),
|
|
214
217
|
});
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const onVisible = () => {
|
|
220
|
-
if (document.visibilityState === 'visible') refresh();
|
|
221
|
-
};
|
|
222
|
-
document.addEventListener('visibilitychange', onVisible);
|
|
219
|
+
// 2.0.5: once, then on a write, a redraw or a return to the window; one slow clock for outside edits
|
|
220
|
+
const reads = dsRefresh(read, { fetchImpl: f, slowMs: pollMs });
|
|
221
|
+
refresh = reads.now;
|
|
223
222
|
// a canvas that reloaded forgot its marks: when it says it has loaded, tell it again
|
|
224
223
|
const onLoaded = (e) => {
|
|
225
224
|
const frame = live.current.frameFor?.() ?? null;
|
|
@@ -230,8 +229,7 @@ export function DsTruthHost({
|
|
|
230
229
|
window.addEventListener('message', onLoaded);
|
|
231
230
|
return () => {
|
|
232
231
|
dead = true;
|
|
233
|
-
|
|
234
|
-
document.removeEventListener('visibilitychange', onVisible);
|
|
232
|
+
reads.stop();
|
|
235
233
|
window.removeEventListener('message', onLoaded);
|
|
236
234
|
setTruthActions(null);
|
|
237
235
|
setTruth(null);
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
14
14
|
import { getPaletteEnv } from '../search/search-env.js';
|
|
15
15
|
import { canvasesIn } from './switch-host.jsx';
|
|
16
|
+
import { dsRefresh } from './ds-refresh.js';
|
|
16
17
|
import { onDsUpgradeRequest } from './upgrade-bus.js';
|
|
17
18
|
import {
|
|
18
19
|
appliedWords,
|
|
@@ -24,8 +25,15 @@ import {
|
|
|
24
25
|
import { DsUpgradeSheet } from './upgrade-sheet.jsx';
|
|
25
26
|
|
|
26
27
|
const JSON_HEADERS = { 'content-type': 'application/json' };
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 2.0.5 (#205): the sheet asks again when something it shows may have moved — the window is looked at, the shell
|
|
30
|
+
* wrote a system, the AI run registry moved (`maude:ai-runs`), an action landed (`maude:project-action`) — and
|
|
31
|
+
* after a failed read (5 s doubling to 5 min). The ONE clock left is `TICK_MS`, only while the AI or the check is
|
|
32
|
+
* working with the sheet open: a proof's progress ("2 of 6 canvases checked") has no push. A settled sheet reads
|
|
33
|
+
* on events only.
|
|
34
|
+
*/
|
|
35
|
+
export const TICK_MS = 5000;
|
|
36
|
+
export const UPGRADE_EVENTS = ['maude:ai-runs', 'maude:project-action'];
|
|
29
37
|
/** A request the AI was sent off with is remembered this long, so closing and reopening does not ask twice. */
|
|
30
38
|
const ASKED_MS = 30 * 60 * 1000;
|
|
31
39
|
const askedAt = new Map();
|
|
@@ -80,9 +88,9 @@ export async function cancelUpgrade(ds, stage, fetchImpl = globalThis.fetch) {
|
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
|
-
* @param {{ cfg: any, toast?: (m: string) => void, fetchImpl?: typeof fetch,
|
|
91
|
+
* @param {{ cfg: any, toast?: (m: string) => void, fetchImpl?: typeof fetch, tickMs?: number }} props
|
|
84
92
|
*/
|
|
85
|
-
export function DsUpgradeHost({ cfg, toast, fetchImpl,
|
|
93
|
+
export function DsUpgradeHost({ cfg, toast, fetchImpl, tickMs = TICK_MS }) {
|
|
86
94
|
const [sheet, setSheet] = useState(null);
|
|
87
95
|
const live = useRef({ cfg, toast, fetchImpl, sheet: null });
|
|
88
96
|
live.current = { cfg, toast, fetchImpl, sheet };
|
|
@@ -111,10 +119,10 @@ export function DsUpgradeHost({ cfg, toast, fetchImpl, pollMs = POLL_MS }) {
|
|
|
111
119
|
);
|
|
112
120
|
|
|
113
121
|
// biome-ignore lint/correctness/useExhaustiveDependencies: `f` reads the live ref
|
|
114
|
-
const refresh = useCallback(async () => {
|
|
122
|
+
const refresh = useCallback(async (fx) => {
|
|
115
123
|
const s = live.current.sheet;
|
|
116
124
|
if (!s) return;
|
|
117
|
-
const r = await loadUpgradeStatus(s.ds, s.label, f());
|
|
125
|
+
const r = await loadUpgradeStatus(s.ds, s.label, typeof fx === 'function' ? fx : f());
|
|
118
126
|
// the sheet may have been closed (or reopened on another system) while the answer was on its way
|
|
119
127
|
if (r.ok && live.current.sheet?.ds === s.ds)
|
|
120
128
|
setSheet((cur) => (cur && cur.ds === s.ds ? { ...cur, status: r.status } : cur));
|
|
@@ -133,13 +141,21 @@ export function DsUpgradeHost({ cfg, toast, fetchImpl, pollMs = POLL_MS }) {
|
|
|
133
141
|
})
|
|
134
142
|
: null;
|
|
135
143
|
|
|
136
|
-
// while the AI or the check works
|
|
144
|
+
// while the AI or the check works the sheet follows events, with one slow tick for the proof's progress; a
|
|
145
|
+
// settled sheet (ask, review, converted) hears nothing between events
|
|
137
146
|
const busyView = view?.kind === 'working' || view?.kind === 'proving';
|
|
147
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `f` reads the live ref
|
|
138
148
|
useEffect(() => {
|
|
139
149
|
if (!busyView) return undefined;
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
const r = dsRefresh((fx) => refresh(fx), {
|
|
151
|
+
fetchImpl: () => live.current.fetchImpl ?? globalThis.fetch,
|
|
152
|
+
events: UPGRADE_EVENTS,
|
|
153
|
+
slowMs: tickMs,
|
|
154
|
+
skipFirst: true,
|
|
155
|
+
paused: () => false,
|
|
156
|
+
});
|
|
157
|
+
return () => r.stop();
|
|
158
|
+
}, [busyView, refresh, tickMs]);
|
|
143
159
|
|
|
144
160
|
const close = useCallback(() => setSheet(null), []);
|
|
145
161
|
|
|
@@ -52,7 +52,13 @@ export function useBranchActions({
|
|
|
52
52
|
const [downloading, setDownloading] = useState(false);
|
|
53
53
|
const [folding, setFolding] = useState('');
|
|
54
54
|
const [busy, setBusy] = useState(false);
|
|
55
|
-
const [err,
|
|
55
|
+
const [err, setErrText] = useState('');
|
|
56
|
+
// 2.0.5 W4 — the error asks for a GitHub sign-in (a 401 / authRequired): the sheet draws the button
|
|
57
|
+
const [errAuth, setErrAuth] = useState(false);
|
|
58
|
+
const setErr = useCallback((text, auth = false) => {
|
|
59
|
+
setErrText(text);
|
|
60
|
+
setErrAuth(!!text && auth);
|
|
61
|
+
}, []);
|
|
56
62
|
const [refreshing, setRefreshing] = useState(false);
|
|
57
63
|
const [fetchedAt, setFetchedAt] = useState(0);
|
|
58
64
|
const [chatGuard, setChatGuard] = useState(null); // { count, verb, action }
|
|
@@ -136,10 +142,10 @@ export function useBranchActions({
|
|
|
136
142
|
await reloadBranches();
|
|
137
143
|
} else if (r.timedOut || r.json?.timedOut) {
|
|
138
144
|
setErr(W.errFetchTimeout);
|
|
145
|
+
} else if (r.status === 401 || r.json?.authRequired) {
|
|
146
|
+
setErr(W.errFetchAuth, true);
|
|
139
147
|
} else {
|
|
140
|
-
setErr(
|
|
141
|
-
r.status === 401 || r.json?.authRequired ? W.errFetchAuth : r.json?.error || W.errFetch
|
|
142
|
-
);
|
|
148
|
+
setErr(r.json?.error || W.errFetch);
|
|
143
149
|
}
|
|
144
150
|
setRefreshing(false);
|
|
145
151
|
}
|
|
@@ -168,11 +174,8 @@ export function useBranchActions({
|
|
|
168
174
|
reload(); // added directly (no remote)
|
|
169
175
|
return;
|
|
170
176
|
}
|
|
171
|
-
setErr(
|
|
172
|
-
|
|
173
|
-
? `Sign in with GitHub to add “${branch}” to ${shared}.`
|
|
174
|
-
: j?.error || W.errAdd
|
|
175
|
-
);
|
|
177
|
+
if (r.status === 401) setErr(`Sign in with GitHub to add “${branch}” to ${shared}.`, true);
|
|
178
|
+
else setErr(j?.error || W.errAdd);
|
|
176
179
|
setFolding('');
|
|
177
180
|
}
|
|
178
181
|
|
|
@@ -196,6 +199,7 @@ export function useBranchActions({
|
|
|
196
199
|
folding,
|
|
197
200
|
busy,
|
|
198
201
|
err,
|
|
202
|
+
errAuth,
|
|
199
203
|
setErr,
|
|
200
204
|
refreshing,
|
|
201
205
|
fetchedAt,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
26
26
|
import { useOnline } from '../empty/use-empty-canvas.js';
|
|
27
|
-
import { MENU_ACTION_EVENT } from '../shell/menu-runner.js';
|
|
27
|
+
import { MENU_ACTION_EVENT, menuRunner } from '../shell/menu-runner.js';
|
|
28
28
|
import { useBranchActions } from './branch-actions.js';
|
|
29
29
|
import { COMPARE_PICTURES_WORDS as CW } from './compare-words.js';
|
|
30
30
|
import { loadBranches, loadSourceAt } from './git-io.js';
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
BranchDialog,
|
|
52
52
|
ChangedList,
|
|
53
53
|
CopyButton,
|
|
54
|
+
GitHubSignInButton,
|
|
54
55
|
GitRow,
|
|
55
56
|
GitSub,
|
|
56
57
|
GuardDialog,
|
|
@@ -138,6 +139,8 @@ function GitBody({ canvas, version, versionRow, role, canView, git, fetchImpl })
|
|
|
138
139
|
const cloudHistory = git.historySource === 'cloud';
|
|
139
140
|
const [branches, setBranches] = useState([]);
|
|
140
141
|
const [banner, setBanner] = useState(null);
|
|
142
|
+
// 2.0.5 W4 — every "Sign in with GitHub to …" line starts the one sign-in (`account.github-signin`)
|
|
143
|
+
const signInGitHub = useCallback(() => menuRunner.run('account.github-signin'), []);
|
|
141
144
|
const [busy, setBusy] = useState(null);
|
|
142
145
|
const [dialog, setDialog] = useState(null); // 'save' | 'branch' | 'add'
|
|
143
146
|
const [resumeDismissed, setResumeDismissed] = useState(false);
|
|
@@ -263,6 +266,7 @@ function GitBody({ canvas, version, versionRow, role, canView, git, fetchImpl })
|
|
|
263
266
|
busy={busy}
|
|
264
267
|
onGetLatest={getLatest}
|
|
265
268
|
onDismiss={() => setBanner(null)}
|
|
269
|
+
onSignIn={signInGitHub}
|
|
266
270
|
/>
|
|
267
271
|
|
|
268
272
|
{surface.mode === 'cloud' || surface.mode === 'cloud-saving' ? versions : null}
|
|
@@ -334,6 +338,9 @@ function GitBody({ canvas, version, versionRow, role, canView, git, fetchImpl })
|
|
|
334
338
|
{actions.err}
|
|
335
339
|
</p>
|
|
336
340
|
) : null}
|
|
341
|
+
{actions.err && actions.errAuth && !dialog ? (
|
|
342
|
+
<GitHubSignInButton onSignIn={signInGitHub} />
|
|
343
|
+
) : null}
|
|
337
344
|
|
|
338
345
|
{versionRow ? (
|
|
339
346
|
<>
|
|
@@ -496,7 +496,9 @@ export function versionRows(entries, nowMs = Date.now()) {
|
|
|
496
496
|
*/
|
|
497
497
|
export function outcomeBanner(kind, res, ok) {
|
|
498
498
|
if (res?.ok) return ok ?? null;
|
|
499
|
-
|
|
499
|
+
// 2.0.5 W4 — the sign-in line carries its button (`account.github-signin`), never only words
|
|
500
|
+
if (res?.authRequired)
|
|
501
|
+
return { variant: 'info', text: res.error || GIT_WORDS.signIn, signIn: true };
|
|
500
502
|
if (res?.conflict)
|
|
501
503
|
return kind === 'getLatest'
|
|
502
504
|
? {
|
|
@@ -91,8 +91,22 @@ function TriCheck({ state, onChange, ariaLabel }) {
|
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/** 2.0.5 W4 — "Sign in with GitHub to …" is a button: the registry's `account.github-signin`. */
|
|
95
|
+
export function GitHubSignInButton({ onSignIn }) {
|
|
96
|
+
return (
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
className="btn btn--sm"
|
|
100
|
+
data-testid="git-signin-github"
|
|
101
|
+
onClick={() => onSignIn()}
|
|
102
|
+
>
|
|
103
|
+
Sign in with GitHub…
|
|
104
|
+
</button>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
94
108
|
/** A banner under the fold's head: a result, a warning, or an offer (Get latest after a publish conflict). */
|
|
95
|
-
export function Banner({ banner, busy, onGetLatest, onDismiss }) {
|
|
109
|
+
export function Banner({ banner, busy, onGetLatest, onDismiss, onSignIn }) {
|
|
96
110
|
if (!banner) return null;
|
|
97
111
|
return (
|
|
98
112
|
<div
|
|
@@ -114,6 +128,7 @@ export function Banner({ banner, busy, onGetLatest, onDismiss }) {
|
|
|
114
128
|
{W.getLatest}
|
|
115
129
|
</button>
|
|
116
130
|
) : null}
|
|
131
|
+
{banner.signIn && onSignIn ? <GitHubSignInButton onSignIn={onSignIn} /> : null}
|
|
117
132
|
</span>
|
|
118
133
|
<button type="button" className="vh-git-x" aria-label={W.dismiss} onClick={onDismiss}>
|
|
119
134
|
<StIcon name="x" size={12} />
|
|
@@ -79,12 +79,35 @@ function toneStyle(name, you = false) {
|
|
|
79
79
|
return { '--face-tone': toneVar(you ? YOU_TONE : toneFor(name)) };
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** 2.0.5 W4 — your own face is the avatar: a button that opens THIS project's account (the host's card). */
|
|
83
|
+
function YouFace({ face, onYou, youOpen }) {
|
|
84
|
+
return (
|
|
85
|
+
<li className="sh-face-li">
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
className="sh-face is-you"
|
|
89
|
+
style={toneStyle(face.name, true)}
|
|
90
|
+
title={`${face.name} · Account`}
|
|
91
|
+
aria-label={`${face.name} — this project's account`}
|
|
92
|
+
aria-haspopup="dialog"
|
|
93
|
+
aria-expanded={youOpen ? 'true' : 'false'}
|
|
94
|
+
data-testid="share-cluster-face-you"
|
|
95
|
+
data-account-opener="true"
|
|
96
|
+
onClick={() => onYou()}
|
|
97
|
+
>
|
|
98
|
+
{face.initials}
|
|
99
|
+
</button>
|
|
100
|
+
</li>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
82
104
|
/** The pre-S9.23 strip: a peer's face IS the Follow control. */
|
|
83
|
-
function LegacyFaces({ faces, onFollow }) {
|
|
105
|
+
function LegacyFaces({ faces, onFollow, onYou, youOpen }) {
|
|
84
106
|
return (
|
|
85
107
|
<ul className="sh-faces" aria-label="People here" data-testid="share-cluster-faces">
|
|
86
108
|
{faces.map((f) => {
|
|
87
109
|
const key = `${f.you ? 'you' : f.agent ? 'agent' : `peer-${f.clientID}`}:${f.name}`;
|
|
110
|
+
if (f.you && onYou) return <YouFace key={key} face={f} onYou={onYou} youOpen={youOpen} />;
|
|
88
111
|
if (isPeer(f) && onFollow) {
|
|
89
112
|
const label = f.following
|
|
90
113
|
? `Stop following ${firstName(f.name)}`
|
|
@@ -261,7 +284,7 @@ function PeopleList({ peers, presence, close, now, onPick }) {
|
|
|
261
284
|
);
|
|
262
285
|
}
|
|
263
286
|
|
|
264
|
-
export function PresenceFaces({ faces, onFollow, presence = null }) {
|
|
287
|
+
export function PresenceFaces({ faces, onFollow, presence = null, onYou = null, youOpen = false }) {
|
|
265
288
|
const [open, setOpen] = useState(null); // { kind: 'face', clientID } | { kind: 'list' } | null
|
|
266
289
|
const hostRef = useRef(null);
|
|
267
290
|
const openerRef = useRef(null);
|
|
@@ -273,7 +296,8 @@ export function PresenceFaces({ faces, onFollow, presence = null }) {
|
|
|
273
296
|
() => openerRef.current?.focus()
|
|
274
297
|
);
|
|
275
298
|
if (!faces?.length) return null;
|
|
276
|
-
if (!presence)
|
|
299
|
+
if (!presence)
|
|
300
|
+
return <LegacyFaces faces={faces} onFollow={onFollow} onYou={onYou} youOpen={youOpen} />;
|
|
277
301
|
|
|
278
302
|
const lead = faces.filter((f) => !isPeer(f));
|
|
279
303
|
const peers = faces.filter(isPeer);
|
|
@@ -284,17 +308,21 @@ export function PresenceFaces({ faces, onFollow, presence = null }) {
|
|
|
284
308
|
return (
|
|
285
309
|
<span className="sh-faces-host" ref={hostRef}>
|
|
286
310
|
<ul className="sh-faces" aria-label="People here" data-testid="share-cluster-faces">
|
|
287
|
-
{lead.map((f) =>
|
|
288
|
-
|
|
289
|
-
key={
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
311
|
+
{lead.map((f) =>
|
|
312
|
+
f.you && onYou ? (
|
|
313
|
+
<YouFace key={`you:${f.name}`} face={f} onYou={onYou} youOpen={youOpen} />
|
|
314
|
+
) : (
|
|
315
|
+
<li
|
|
316
|
+
key={f.you ? `you:${f.name}` : `agent:${f.name}`}
|
|
317
|
+
className={`sh-face${f.agent ? ' is-agent' : ''}${f.you ? ' is-you' : ''}`}
|
|
318
|
+
style={f.you ? toneStyle(f.name, true) : undefined}
|
|
319
|
+
title={f.name}
|
|
320
|
+
aria-label={f.name}
|
|
321
|
+
>
|
|
322
|
+
{f.agent ? <SparkGlyph size={12} /> : f.initials}
|
|
323
|
+
</li>
|
|
324
|
+
)
|
|
325
|
+
)}
|
|
298
326
|
{shown.map((f) => {
|
|
299
327
|
const idle = typeof f.idleSince === 'number' && f.idleSince > 0;
|
|
300
328
|
const label = `${f.name} — ${whereOf(f, { labelOf: presence.labelOf, roleOf: presence.roleOf, now })}`;
|
|
@@ -29,7 +29,7 @@ function Face({ initial, tone, size = 'md' }) {
|
|
|
29
29
|
* @param onSwitch () => void — the shell's `account.switch`
|
|
30
30
|
* @param onSignOut () => Promise — the existing sign-out path
|
|
31
31
|
*/
|
|
32
|
-
export function AccountChip({ chip, card, onSwitch, onSignOut }) {
|
|
32
|
+
export function AccountChip({ chip, card, onSwitch, onSignOut, onOpen = null, opened = false }) {
|
|
33
33
|
const [open, setOpen] = useState(false);
|
|
34
34
|
const [asking, setAsking] = useState(false);
|
|
35
35
|
const [busy, setBusy] = useState(false);
|
|
@@ -74,14 +74,20 @@ export function AccountChip({ chip, card, onSwitch, onSignOut }) {
|
|
|
74
74
|
<button
|
|
75
75
|
ref={btn}
|
|
76
76
|
type="button"
|
|
77
|
-
className={`sh-acct-chip${open ? ' is-on' : ''}`}
|
|
77
|
+
className={`sh-acct-chip${open || opened ? ' is-on' : ''}`}
|
|
78
78
|
data-testid="share-cluster-account"
|
|
79
79
|
data-account={chip.id}
|
|
80
|
+
// 2.0.5 W4 — with `onOpen` the chip opens the project's account card (project-account-card.jsx)
|
|
81
|
+
data-account-opener={onOpen ? 'true' : undefined}
|
|
80
82
|
aria-haspopup="dialog"
|
|
81
|
-
aria-expanded={open ? 'true' : 'false'}
|
|
83
|
+
aria-expanded={open || opened ? 'true' : 'false'}
|
|
82
84
|
aria-label={`Account: ${chip.title}`}
|
|
83
85
|
title={chip.title}
|
|
84
|
-
onClick={() =>
|
|
86
|
+
onClick={() => {
|
|
87
|
+
if (onOpen) onOpen();
|
|
88
|
+
else if (open) close(false);
|
|
89
|
+
else setOpen(true);
|
|
90
|
+
}}
|
|
85
91
|
>
|
|
86
92
|
<Face initial={chip.initial} tone={chip.tone} />
|
|
87
93
|
<span className="sh-acct-name">{chip.label}</span>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// client/v2/shell/canvas-crash-guard.js — 2.0.5: a canvas that crashes the page is not reopened in a loop.
|
|
2
|
+
//
|
|
3
|
+
// When a heavy canvas makes WebKit kill the page's WebContent process, the desktop shell reloads the tab
|
|
4
|
+
// (apps/desktop/src-tauri/src/web_process.rs) and the shell reopened the same canvas — which crashed it
|
|
5
|
+
// again, over and over. No JavaScript runs at the crash, so the guard works backwards: while a canvas is
|
|
6
|
+
// open the shell keeps a "live" mark in localStorage and clears it on a clean `pagehide`. A page that boots
|
|
7
|
+
// and finds the mark still there died with that canvas open. `CRASH_LIMIT` such deaths of the same canvas
|
|
8
|
+
// within `CRASH_WINDOW_MS` and the viewport stops opening it: the tab shows "This canvas is too heavy to
|
|
9
|
+
// show all at once" with the lighter way in (only the artboards near the viewport mounted,
|
|
10
|
+
// `?artboard-live=light`). Pure over a Storage-like object so it is testable without a browser.
|
|
11
|
+
|
|
12
|
+
export const CRASH_LIMIT = 2;
|
|
13
|
+
export const CRASH_WINDOW_MS = 10 * 60 * 1000;
|
|
14
|
+
/** A chosen lighter mode is kept this long for that canvas (it survives the next crash reload). */
|
|
15
|
+
export const LIGHT_KEEP_MS = 24 * 60 * 60 * 1000;
|
|
16
|
+
export const CRASH_KEY = 'maude.canvas-crash.v1';
|
|
17
|
+
|
|
18
|
+
function empty() {
|
|
19
|
+
return { live: null, crashes: {}, light: {} };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function read(storage) {
|
|
23
|
+
try {
|
|
24
|
+
const raw = storage?.getItem(CRASH_KEY);
|
|
25
|
+
if (!raw) return empty();
|
|
26
|
+
const s = JSON.parse(raw);
|
|
27
|
+
if (!s || typeof s !== 'object') return empty();
|
|
28
|
+
return {
|
|
29
|
+
live: typeof s.live === 'string' ? s.live : null,
|
|
30
|
+
crashes: s.crashes && typeof s.crashes === 'object' ? s.crashes : {},
|
|
31
|
+
light: s.light && typeof s.light === 'object' ? s.light : {},
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return empty();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {{ getItem(k: string): string | null, setItem(k: string, v: string): void } | null} storage
|
|
40
|
+
* @param {() => number} [now]
|
|
41
|
+
*/
|
|
42
|
+
export function createCrashGuard(storage, now = Date.now) {
|
|
43
|
+
const s = read(storage);
|
|
44
|
+
const save = () => {
|
|
45
|
+
try {
|
|
46
|
+
storage?.setItem(CRASH_KEY, JSON.stringify(s));
|
|
47
|
+
} catch {
|
|
48
|
+
/* private mode / quota — the guard just forgets */
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const prune = () => {
|
|
52
|
+
const t = now();
|
|
53
|
+
for (const [p, list] of Object.entries(s.crashes)) {
|
|
54
|
+
const kept = Array.isArray(list)
|
|
55
|
+
? list.filter((x) => typeof x === 'number' && t - x < CRASH_WINDOW_MS)
|
|
56
|
+
: [];
|
|
57
|
+
if (kept.length) s.crashes[p] = kept;
|
|
58
|
+
else delete s.crashes[p];
|
|
59
|
+
}
|
|
60
|
+
for (const [p, at] of Object.entries(s.light)) {
|
|
61
|
+
if (typeof at !== 'number' || t - at >= LIGHT_KEEP_MS) delete s.light[p];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// Boot: a mark left behind is a page that died with that canvas open.
|
|
65
|
+
if (s.live) {
|
|
66
|
+
const list = s.crashes[s.live] || [];
|
|
67
|
+
list.push(now());
|
|
68
|
+
s.crashes[s.live] = list;
|
|
69
|
+
s.live = null;
|
|
70
|
+
}
|
|
71
|
+
prune();
|
|
72
|
+
save();
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
/** The open canvas (null when none is framed). Called whenever the active frame changes. */
|
|
76
|
+
noteOpen(path) {
|
|
77
|
+
const next = typeof path === 'string' && path ? path : null;
|
|
78
|
+
if (s.live === next) return;
|
|
79
|
+
s.live = next;
|
|
80
|
+
save();
|
|
81
|
+
},
|
|
82
|
+
/** A clean unload (`pagehide`): whatever was open did not crash the page. */
|
|
83
|
+
noteClean() {
|
|
84
|
+
if (s.live === null) return;
|
|
85
|
+
s.live = null;
|
|
86
|
+
save();
|
|
87
|
+
},
|
|
88
|
+
crashCount(path) {
|
|
89
|
+
prune();
|
|
90
|
+
return (s.crashes[path] || []).length;
|
|
91
|
+
},
|
|
92
|
+
/** Too heavy: it crashed the page `CRASH_LIMIT` times recently and no lighter mode was chosen. */
|
|
93
|
+
tooHeavy(path) {
|
|
94
|
+
if (!path) return false;
|
|
95
|
+
prune();
|
|
96
|
+
return (s.crashes[path] || []).length >= CRASH_LIMIT && !(path in s.light);
|
|
97
|
+
},
|
|
98
|
+
isLight(path) {
|
|
99
|
+
prune();
|
|
100
|
+
return !!path && path in s.light;
|
|
101
|
+
},
|
|
102
|
+
/** "Show visible artboards only". */
|
|
103
|
+
chooseLight(path) {
|
|
104
|
+
s.light[path] = now();
|
|
105
|
+
save();
|
|
106
|
+
},
|
|
107
|
+
/** "Show everything": forget the crashes and the lighter mode for this canvas. */
|
|
108
|
+
forgive(path) {
|
|
109
|
+
delete s.crashes[path];
|
|
110
|
+
delete s.light[path];
|
|
111
|
+
save();
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let shared = null;
|
|
117
|
+
const subs = new Set();
|
|
118
|
+
|
|
119
|
+
/** The page's one guard, on localStorage, cleared on a clean pagehide. */
|
|
120
|
+
export function crashGuard() {
|
|
121
|
+
if (shared) return shared;
|
|
122
|
+
const storage = typeof localStorage === 'undefined' ? null : localStorage;
|
|
123
|
+
const g = createCrashGuard(storage);
|
|
124
|
+
const wrap = (fn) => (path) => {
|
|
125
|
+
fn(path);
|
|
126
|
+
for (const cb of subs) cb();
|
|
127
|
+
};
|
|
128
|
+
shared = { ...g, chooseLight: wrap(g.chooseLight), forgive: wrap(g.forgive) };
|
|
129
|
+
if (typeof window !== 'undefined') window.addEventListener('pagehide', () => g.noteClean());
|
|
130
|
+
return shared;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Re-render on a choice made on the card. */
|
|
134
|
+
export function subscribeCrashGuard(cb) {
|
|
135
|
+
subs.add(cb);
|
|
136
|
+
return () => subs.delete(cb);
|
|
137
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// client/v2/shell/github-signin-host.jsx — 2.0.5 W4: where `account.github-signin` runs.
|
|
2
|
+
//
|
|
3
|
+
// The one GitHub sign-in of a project tab: the shell's device flow (`github_sign_in`, oauth.rs — the
|
|
4
|
+
// calling project's profile, bind-on-sign-in for another account on a shared one), through the SAME hook
|
|
5
|
+
// Settings › Connections uses (useGitHubConnection), and the same code sheet (GitHubDeviceDialog). The
|
|
6
|
+
// menu runner hands the action here over MENU_ACTION_EVENT, the way IdentityBar hears project.new, so the
|
|
7
|
+
// avatar's card, ⌘K, the Versions sheet's "Sign in with GitHub to publish" lines and New project… all
|
|
8
|
+
// start this one flow. Mounted by share-cluster-host.jsx, which every project tab draws.
|
|
9
|
+
|
|
10
|
+
import { useEffect, useRef } from 'react';
|
|
11
|
+
import { GitHubDeviceDialog } from '../../panels/IdentityBar.jsx';
|
|
12
|
+
import { shellToast } from '../../shell/util.js';
|
|
13
|
+
import { useGitHubConnection } from '../settings/use-connections.js';
|
|
14
|
+
import { MENU_ACTION_EVENT } from './menu-runner.js';
|
|
15
|
+
|
|
16
|
+
export function useGitHubSignInHost() {
|
|
17
|
+
const gh = useGitHubConnection();
|
|
18
|
+
const ref = useRef(gh);
|
|
19
|
+
ref.current = gh;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const on = (e) => {
|
|
22
|
+
if (e.detail?.id !== 'account.github-signin') return;
|
|
23
|
+
const g = ref.current;
|
|
24
|
+
if (!g.native || g.signing) return;
|
|
25
|
+
g.signIn();
|
|
26
|
+
};
|
|
27
|
+
window.addEventListener(MENU_ACTION_EVENT, on);
|
|
28
|
+
return () => window.removeEventListener(MENU_ACTION_EVENT, on);
|
|
29
|
+
}, []);
|
|
30
|
+
// A failed flow says so once (the hook keeps the sentence for Settings' row too).
|
|
31
|
+
const lastErr = useRef('');
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (gh.error && gh.error !== lastErr.current) shellToast(gh.error);
|
|
34
|
+
lastErr.current = gh.error;
|
|
35
|
+
}, [gh.error]);
|
|
36
|
+
return gh;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The device-code sheet while a sign-in started here waits for the browser. */
|
|
40
|
+
export function GitHubSignInSheet({ gh }) {
|
|
41
|
+
return gh?.device ? <GitHubDeviceDialog device={gh.device} onClose={gh.closeDevice} /> : null;
|
|
42
|
+
}
|
|
@@ -274,6 +274,17 @@ export function createMenuHandlers(d) {
|
|
|
274
274
|
'handoff.open': () => d.setExportDialog({ mode: 'handoff' }),
|
|
275
275
|
'canvas.close': () => d.onCloseCanvas(),
|
|
276
276
|
'account.switch': () => d.onSwitchAccount(),
|
|
277
|
+
// 2.0.5 W4 — the GitHub device flow is the mounted host's (github-signin-host.jsx: its code sheet
|
|
278
|
+
// and state); it hears this the way IdentityBar hears project.new. A browser tab has no keychain.
|
|
279
|
+
'account.github-signin': () => {
|
|
280
|
+
if (!d.native) {
|
|
281
|
+
d.toast('Signing in with GitHub needs the Maude desktop app.');
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
window.dispatchEvent(
|
|
285
|
+
new CustomEvent(MENU_ACTION_EVENT, { detail: { id: 'account.github-signin' } })
|
|
286
|
+
);
|
|
287
|
+
},
|
|
277
288
|
// ── Edit ── (select / properties ride the canvas lane; artboards the shell's)
|
|
278
289
|
// S2.20 — Undo / Redo run the ⌘Z projection over the op log (since p8-v1-drop the canvas keeps no
|
|
279
290
|
// stack to fall back to). Undo history… opens the popover.
|