@1agh/maude 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/access/request.ts +1 -0
- package/apps/studio/actions/agents.ts +45 -42
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/sync.ts +4 -0
- package/apps/studio/actions/verbs.ts +49 -0
- package/apps/studio/actions.manifest.json +162 -20
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/ai/create-claim.ts +1 -1
- package/apps/studio/bin/_asset-file.mjs +117 -0
- package/apps/studio/bin/_canvas-file.mjs +146 -0
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/bin/_footage.mjs +123 -0
- package/apps/studio/bin/_pdf-playwright.mjs +14 -0
- package/apps/studio/bin/_png-playwright.mjs +15 -1
- package/apps/studio/bin/_pw-launch.mjs +98 -0
- package/apps/studio/bin/_retry-save.mjs +49 -0
- package/apps/studio/bin/_sync.mjs +145 -2
- package/apps/studio/bin/asset-rename.sh +12 -0
- package/apps/studio/bin/asset-trash.sh +12 -0
- package/apps/studio/bin/canvas-move.sh +12 -0
- package/apps/studio/bin/canvas-new.sh +12 -0
- package/apps/studio/bin/footage.sh +12 -0
- package/apps/studio/bin/generate.sh +7 -0
- package/apps/studio/bin/retry-save.sh +13 -0
- package/apps/studio/bridge/canvas-mode-store.ts +11 -2
- package/apps/studio/bridge/dgn-protocol.ts +8 -3
- package/apps/studio/bridge/occlusion.ts +45 -0
- package/apps/studio/canvas-theme-pill.tsx +169 -26
- package/apps/studio/client/app.jsx +16 -4
- package/apps/studio/client/export-center.jsx +32 -3
- package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
- package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
- package/apps/studio/client/home/HomeConnection.jsx +112 -0
- package/apps/studio/client/home/ProjectRows.jsx +514 -0
- package/apps/studio/client/home/home-accounts-model.js +234 -76
- package/apps/studio/client/home/home-api.js +10 -2
- package/apps/studio/client/home/home-app.jsx +151 -394
- package/apps/studio/client/home/home-icons.jsx +8 -0
- package/apps/studio/client/home/home-model.js +149 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +621 -53
- package/apps/studio/client/home/use-account-fix.js +123 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
- package/apps/studio/client/v2/export/done-toast.jsx +2 -5
- package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
- package/apps/studio/client/v2/export/export.css +9 -0
- package/apps/studio/client/v2/export/exports-model.js +16 -3
- package/apps/studio/client/v2/export/file-rows.jsx +81 -5
- package/apps/studio/client/v2/export/native-save.js +33 -0
- package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
- package/apps/studio/client/v2/export/sections/print.jsx +37 -20
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +138 -43
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +91 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/menu-runner.js +7 -2
- package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +40 -26
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/collab/room.ts +21 -7
- package/apps/studio/dist/client.bundle.js +886 -886
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/ghostscript.ts +78 -1
- package/apps/studio/exporters/pdf-fonts.ts +31 -4
- package/apps/studio/generation/jobs.ts +6 -0
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +9 -3
- package/apps/studio/http.ts +14 -2
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/routes/agent.ts +6 -2
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/project-undo.ts +10 -0
- package/apps/studio/routes/sync.ts +22 -4
- package/apps/studio/server.ts +25 -0
- package/apps/studio/shell/api-key.ts +11 -0
- package/apps/studio/shell/cli-yield.ts +48 -11
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/action-stage.ts +18 -1
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-plane.ts +226 -19
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +68 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +16 -1
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +18 -2
- package/apps/studio/sync/status.ts +11 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/whats-new.json +36 -0
- package/cli/commands/design.mjs +74 -16
- package/cli/lib/bash-guard.mjs +23 -4
- package/cli/lib/confine-read.mjs +2 -0
- package/cli/lib/design-help.gen.mjs +15 -2
- package/cli/lib/design-hook.mjs +1 -1
- package/cli/lib/desktop-locate.mjs +36 -8
- package/cli/lib/studio-locate.mjs +8 -2
- package/cli/lib/sub-verbs.mjs +13 -1
- package/package.json +9 -8
- package/apps/studio/client/home/HomeAccounts.jsx +0 -262
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -67,6 +67,14 @@ const GLYPHS = {
|
|
|
67
67
|
<path d="M5.5 8.25l1.75 1.75 3.25-3.75" />
|
|
68
68
|
</>
|
|
69
69
|
),
|
|
70
|
+
// 2.1.2 HB1 — the accounts chip and an account line's "…"
|
|
71
|
+
people: (
|
|
72
|
+
<>
|
|
73
|
+
<circle cx="6" cy="5.5" r="2.25" />
|
|
74
|
+
<path d="M2 13c0-2.2 1.8-3.75 4-3.75s4 1.55 4 3.75M10.5 3.6a2.25 2.25 0 010 4.1M12 9.6c1.2.5 2 1.7 2 3.4" />
|
|
75
|
+
</>
|
|
76
|
+
),
|
|
77
|
+
more: <path d="M3.5 8h.01M8 8h.01M12.5 8h.01" />,
|
|
70
78
|
};
|
|
71
79
|
|
|
72
80
|
export function HIcon({ name, size = 16 }) {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { localIdentityMatches } from '../share-link.js';
|
|
16
16
|
import { accountTone } from '../shell/account-tone.js';
|
|
17
17
|
import { pathTestIdSlug } from '../shell/util.js';
|
|
18
|
+
import { cloudRowWhere, cloudState, connBadge, serverState, whereOf } from './home-where-model.js';
|
|
18
19
|
|
|
19
20
|
/** `canvas-row-<slug>`'s rule, so Home rows and tree rows name a canvas the same way. */
|
|
20
21
|
export const rowSlug = (rel) => pathTestIdSlug(rel);
|
|
@@ -186,6 +187,7 @@ export function buildHomeModel({
|
|
|
186
187
|
clouds = null,
|
|
187
188
|
filterPid = null,
|
|
188
189
|
hubAccounts = null,
|
|
190
|
+
hubStates = null,
|
|
189
191
|
cloudUrl = null,
|
|
190
192
|
}) {
|
|
191
193
|
const indexed = new Map();
|
|
@@ -236,6 +238,14 @@ export function buildHomeModel({
|
|
|
236
238
|
if (normHubUrl(url) && typeof who === 'string' && who) m.set(normHubUrl(url), who);
|
|
237
239
|
accountsOn.set(id, m);
|
|
238
240
|
}
|
|
241
|
+
// 2.1.1 — per profile, whether each saved team sign-in still works (`/_home/accounts` `state`)
|
|
242
|
+
const statesOn = new Map();
|
|
243
|
+
for (const [id, byHub] of Object.entries(hubStates ?? {})) {
|
|
244
|
+
const m = new Map();
|
|
245
|
+
for (const [url, st] of Object.entries(byHub ?? {}))
|
|
246
|
+
if (normHubUrl(url) && typeof st === 'string') m.set(normHubUrl(url), st);
|
|
247
|
+
statesOn.set(id, m);
|
|
248
|
+
}
|
|
239
249
|
const allLocal = registry.map((p) => {
|
|
240
250
|
const ix = indexed.get(p.pid);
|
|
241
251
|
const gone = ix?.state === 'gone';
|
|
@@ -279,6 +289,11 @@ export function buildHomeModel({
|
|
|
279
289
|
copies: [],
|
|
280
290
|
folder: (p.root || '').split('/').filter(Boolean).pop() ?? '',
|
|
281
291
|
cover: firstCover(ix),
|
|
292
|
+
// 2.1.2 — the row's quiet time: the registry's last open, else the newest canvas opened
|
|
293
|
+
lastOpenedAt:
|
|
294
|
+
typeof p.lastOpenedAt === 'number' && p.lastOpenedAt > 0
|
|
295
|
+
? p.lastOpenedAt
|
|
296
|
+
: newestOpened(ix),
|
|
282
297
|
};
|
|
283
298
|
});
|
|
284
299
|
allLocal.sort((a, b) => {
|
|
@@ -286,7 +301,34 @@ export function buildHomeModel({
|
|
|
286
301
|
const ib = mru.has(b.pid) ? mru.get(b.pid) : Number.POSITIVE_INFINITY;
|
|
287
302
|
return ia - ib || a.name.localeCompare(b.name);
|
|
288
303
|
});
|
|
289
|
-
const
|
|
304
|
+
const listingFor = (id) => (clouds ?? []).find((c) => c?.profile === id) ?? null;
|
|
305
|
+
// 2.1.1 (artboard 14) — where the row lives and how it connects, after the folded copies settled
|
|
306
|
+
const placed = (r) => {
|
|
307
|
+
const kind = r.connection?.kind;
|
|
308
|
+
const state =
|
|
309
|
+
kind === 'local'
|
|
310
|
+
? 'local'
|
|
311
|
+
: kind === 'cloud'
|
|
312
|
+
? cloudState(listingFor(r.profile))
|
|
313
|
+
: kind === 'team'
|
|
314
|
+
? serverState(
|
|
315
|
+
hubStates ? (statesOn.get(r.profile) ?? new Map()) : null,
|
|
316
|
+
r.boundHub || r.hub
|
|
317
|
+
)
|
|
318
|
+
: null;
|
|
319
|
+
return {
|
|
320
|
+
...r,
|
|
321
|
+
where: whereOf(r),
|
|
322
|
+
conn: connBadge(state, {
|
|
323
|
+
kind,
|
|
324
|
+
profile: { id: r.profile },
|
|
325
|
+
email: r.connection?.account ?? null,
|
|
326
|
+
}),
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
const localRows = attachWorktrees(collapseDuplicates(allLocal, cloudUrl), shell?.worktrees).map(
|
|
330
|
+
(r) => (r.status === 'gone' ? r : placed(r))
|
|
331
|
+
);
|
|
290
332
|
|
|
291
333
|
// one profile's copy never hides another profile's cloud row
|
|
292
334
|
const bound = new Set(
|
|
@@ -308,6 +350,8 @@ export function buildHomeModel({
|
|
|
308
350
|
ownerName: cp.ownerName ?? null,
|
|
309
351
|
role: cp.role ?? null,
|
|
310
352
|
url: cp.url ?? null,
|
|
353
|
+
where: cloudRowWhere(listing.account?.email || emailOf(listing.profile)),
|
|
354
|
+
conn: null,
|
|
311
355
|
status: 'cloud',
|
|
312
356
|
updatedAt: cp.updatedAt ?? null,
|
|
313
357
|
});
|
|
@@ -352,15 +396,80 @@ export function buildHomeModel({
|
|
|
352
396
|
.sort((a, b) => (a.r === b.r ? a.i - b.i : a.r - b.r))
|
|
353
397
|
.map((x) => x.g);
|
|
354
398
|
|
|
399
|
+
// 2.1.2 (artboards 15/16/19) — the page's one list: live rows by last use, then the Maude Cloud
|
|
400
|
+
// projects not on this Mac, then the folders that moved. A row says where it lives in one word and
|
|
401
|
+
// a state only when it isn't fine; an account's face only when this Mac has two Maude Cloud accounts.
|
|
402
|
+
const cloudAccounts = new Set(
|
|
403
|
+
(clouds ?? [])
|
|
404
|
+
.filter((c) => c?.signedIn && typeof c.profile === 'string')
|
|
405
|
+
.map((c) => c.account?.email || c.profile)
|
|
406
|
+
);
|
|
407
|
+
const faces = cloudAccounts.size >= 2;
|
|
408
|
+
const slim = (r) => ({ ...r, lives: livesOf(r, faces), flag: flagOf(r) });
|
|
409
|
+
const projects = [
|
|
410
|
+
...localRows.filter((r) => r.status !== 'gone').map(slim),
|
|
411
|
+
...cloudRows.map(slim),
|
|
412
|
+
...localRows.filter((r) => r.status === 'gone').map((r) => ({ ...r, lives: null, flag: null })),
|
|
413
|
+
];
|
|
414
|
+
|
|
415
|
+
// 2.1.2 — Pinned joined Recent canvases: the pinned cards first (newest pin), then the opened ones
|
|
416
|
+
const inFilter = (r) => !filterPid || r.pid === filterPid;
|
|
417
|
+
const cards = [
|
|
418
|
+
...pinned.filter(inFilter),
|
|
419
|
+
...opened.filter((r) => r.pinnedAt == null && inFilter(r)),
|
|
420
|
+
];
|
|
421
|
+
|
|
355
422
|
return {
|
|
356
423
|
pinned,
|
|
357
424
|
recent,
|
|
425
|
+
cards,
|
|
358
426
|
recentProjects,
|
|
359
427
|
groups: ranked,
|
|
428
|
+
projects,
|
|
360
429
|
projectCount: localRows.length + cloudRows.length,
|
|
361
430
|
};
|
|
362
431
|
}
|
|
363
432
|
|
|
433
|
+
/** The newest `openedAt` among a project's canvases (the index), or null. */
|
|
434
|
+
function newestOpened(ix) {
|
|
435
|
+
let at = null;
|
|
436
|
+
for (const c of ix?.canvases ?? [])
|
|
437
|
+
if (typeof c?.openedAt === 'number' && (at == null || c.openedAt > at)) at = c.openedAt;
|
|
438
|
+
return at;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* 2.1.2 — where a row lives, in one word: "Maude Cloud" (CONTRACT: the name, never the address),
|
|
443
|
+
* your server's host, "Your folder" or "Kept by Maude". `face` = the Maude Cloud account's face, only
|
|
444
|
+
* when `faces` (this Mac has two Maude Cloud accounts).
|
|
445
|
+
*/
|
|
446
|
+
export function livesOf(row, faces = false) {
|
|
447
|
+
const w = row.where;
|
|
448
|
+
if (!w) return null;
|
|
449
|
+
if (w.kind === 'cloud') {
|
|
450
|
+
const email = row.connection?.account || (w.label !== 'Maude Cloud' ? w.label : null);
|
|
451
|
+
return {
|
|
452
|
+
kind: 'cloud',
|
|
453
|
+
word: 'Maude Cloud',
|
|
454
|
+
face: faces ? accountFace({ id: row.profile, label: email || '', email: email || '' }) : null,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
return { kind: w.kind, word: w.label, face: null };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* 2.1.2 — a row's state, only when it isn't fine: Needs you · a broken sign-in · AI working · (a
|
|
462
|
+
* Maude Cloud project) Not on this Mac yet. Resting, Offline and an unreachable server say nothing on
|
|
463
|
+
* a row (the top of the page raises what needs action).
|
|
464
|
+
*/
|
|
465
|
+
export function flagOf(row) {
|
|
466
|
+
if (row.kind === 'cloud') return { kind: 'away', word: 'Not on this Mac yet' };
|
|
467
|
+
if (row.ai?.awaiting > 0) return { kind: 'needs', word: 'Needs you' };
|
|
468
|
+
if (row.conn?.tone === 'bad') return { kind: 'signin', word: row.conn.word };
|
|
469
|
+
if (row.ai?.running > 0) return { kind: 'ai', word: 'AI working' };
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
|
|
364
473
|
/**
|
|
365
474
|
* #206 T6.3g (contract 206 §5 "Home and Recent") — the worktree folders this Mac opened as tabs
|
|
366
475
|
* (`shell_state.worktrees`, newest first) go under their main project's row as `worktrees`, never as
|
|
@@ -445,6 +554,45 @@ function collapseDuplicates(rows, cloudUrl) {
|
|
|
445
554
|
if (!primary) byReal.set(key, r);
|
|
446
555
|
else fold(primary, r, 'folder', r.folder || r.name);
|
|
447
556
|
}
|
|
557
|
+
|
|
558
|
+
// (c) 2.1.2 (H1 #3) — a managed copy whose folder is gone is not a row of its own while its project
|
|
559
|
+
// is still here: a live copy of the same project (profile + hub + project id) hides it; else the ONE
|
|
560
|
+
// live folder of that profile linking the hub does, when every copy on that hub is of one project
|
|
561
|
+
// (a folder's linkedHub names no project id, so a hub with copies of two projects cannot be told).
|
|
562
|
+
// Hidden only — the registry keeps it (Remove from list is the person's click, never ours).
|
|
563
|
+
for (const c of out) {
|
|
564
|
+
if (!c.copyOf || live(c) || drop.has(c.pid)) continue;
|
|
565
|
+
const mine = (x) => x.profile === c.profile && x.boundHub === c.boundHub;
|
|
566
|
+
const twin = out.find(
|
|
567
|
+
(x) => x !== c && live(x) && !drop.has(x.pid) && mine(x) && x.copyOf === c.copyOf
|
|
568
|
+
);
|
|
569
|
+
if (twin) {
|
|
570
|
+
drop.add(c.pid);
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const ids = new Set(out.filter((x) => x.copyOf && mine(x)).map((x) => x.copyOf));
|
|
574
|
+
if (ids.size !== 1) continue;
|
|
575
|
+
const folders = out.filter(
|
|
576
|
+
(x) =>
|
|
577
|
+
!x.copyOf && live(x) && !drop.has(x.pid) && x.profile === c.profile && x.hub === c.boundHub
|
|
578
|
+
);
|
|
579
|
+
if (folders.length === 1) drop.add(c.pid);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// (d) one orphan row per project: gone copies of one project id show once, carrying every pid
|
|
583
|
+
const orphans = new Map();
|
|
584
|
+
for (const r of out) {
|
|
585
|
+
if (live(r) || drop.has(r.pid)) continue;
|
|
586
|
+
r.pids = [r.pid];
|
|
587
|
+
if (!r.copyOf) continue;
|
|
588
|
+
const key = `${r.profile} ${r.boundHub} ${r.copyOf}`;
|
|
589
|
+
const first = orphans.get(key);
|
|
590
|
+
if (!first) orphans.set(key, r);
|
|
591
|
+
else {
|
|
592
|
+
first.pids.push(r.pid);
|
|
593
|
+
drop.add(r.pid);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
448
596
|
return out.filter((r) => !drop.has(r.pid));
|
|
449
597
|
}
|
|
450
598
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// client/home/home-where-model.js — 2.1.1 B4 (artboard 14): where a project row lives and whether it
|
|
2
|
+
// connects. PURE; `home-model.js` calls these while it builds a row.
|
|
3
|
+
//
|
|
4
|
+
// A project is always in exactly one of the places the design names — your folder, kept by Maude, on
|
|
5
|
+
// Maude Cloud, on your server — and a synced one also has an account:
|
|
6
|
+
// where.kind 'cloud' the project is on a Maude Cloud account → label = the account's e-mail
|
|
7
|
+
// 'server' it is on a server of your own → label = the server's host
|
|
8
|
+
// 'folder' only on this Mac, in a folder you chose → label "Your folder"
|
|
9
|
+
// 'kept' only on this Mac, a copy Maude keeps → label "Kept by Maude"
|
|
10
|
+
// where.path the folder, `~`-shortened — only for a folder the person chose (a copy Maude keeps has
|
|
11
|
+
// no path to manage)
|
|
12
|
+
// "On an account" comes from the shell's own binding (`connectionOf`, home-model.js), never from the
|
|
13
|
+
// project's self-claimed `linkedHub` alone; the words are the project window's (project-account-model).
|
|
14
|
+
|
|
15
|
+
import { accountFace } from './home-model.js';
|
|
16
|
+
|
|
17
|
+
/** The project window's connection words — one set, so the top bar and Home never disagree. */
|
|
18
|
+
export const CONN_WORDS = Object.freeze({
|
|
19
|
+
ok: 'Connected',
|
|
20
|
+
syncing: 'Syncing',
|
|
21
|
+
offline: 'Offline',
|
|
22
|
+
missing: 'Sign-in missing',
|
|
23
|
+
rejected: 'Sign-in stopped working',
|
|
24
|
+
unreachable: 'Server unreachable',
|
|
25
|
+
local: 'Only on this Mac',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** How the badge reads: `ok` (green) · `bad` (a sign-in the person can fix) · `warn` · `off` (grey). */
|
|
29
|
+
export const CONN_TONE = {
|
|
30
|
+
ok: 'ok',
|
|
31
|
+
syncing: 'busy',
|
|
32
|
+
offline: 'off',
|
|
33
|
+
missing: 'bad',
|
|
34
|
+
rejected: 'bad',
|
|
35
|
+
unreachable: 'warn',
|
|
36
|
+
local: 'off',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A path with the home folder as `~`. Home does not know the home folder; `/Users/<n>` and `/home/<n>` are. */
|
|
40
|
+
export function tildePath(root, home = null) {
|
|
41
|
+
const p = String(root || '');
|
|
42
|
+
if (!p) return '';
|
|
43
|
+
if (home && (p === home || p.startsWith(`${home}/`))) return `~${p.slice(home.length)}`;
|
|
44
|
+
const m = p.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);
|
|
45
|
+
return m ? `~${m[1] ?? ''}` : p;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The app's own copy of a project lives under its data folder's `projects/` (managed.rs `managed_root`). */
|
|
49
|
+
const APP_PROJECTS = /\/com\.maude\.app\/projects\//;
|
|
50
|
+
|
|
51
|
+
export const isKeptByMaude = ({ root, copyOf }) => !!copyOf || APP_PROJECTS.test(`${root || ''}/`);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {{ root?: string, copyOf?: string|null,
|
|
55
|
+
* connection?: { kind: string, host?: string|null, account?: string|null } }} row
|
|
56
|
+
* @returns {{ kind: 'cloud'|'server'|'folder'|'kept', label: string, path: string|null }}
|
|
57
|
+
*/
|
|
58
|
+
export function whereOf(row) {
|
|
59
|
+
const c = row.connection;
|
|
60
|
+
const kept = isKeptByMaude(row);
|
|
61
|
+
const path = kept ? null : tildePath(row.root) || null;
|
|
62
|
+
if (c?.kind === 'cloud') return { kind: 'cloud', label: c.account || 'Maude Cloud', path };
|
|
63
|
+
if (c?.kind === 'team') return { kind: 'server', label: c.host || 'Your server', path };
|
|
64
|
+
return kept
|
|
65
|
+
? { kind: 'kept', label: 'Kept by Maude', path: null }
|
|
66
|
+
: { kind: 'folder', label: 'Your folder', path };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A Maude Cloud project that is not on this Mac yet: it is on that profile's account. */
|
|
70
|
+
export const cloudRowWhere = (email) => ({
|
|
71
|
+
kind: 'cloud',
|
|
72
|
+
label: email || 'Maude Cloud',
|
|
73
|
+
path: null,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** Maude Cloud: how the account's listing reads. null = not answered yet (nothing is guessed). */
|
|
77
|
+
export function cloudState(listing) {
|
|
78
|
+
if (!listing) return null;
|
|
79
|
+
if (listing.signedIn) return listing.offline ? 'offline' : 'ok';
|
|
80
|
+
return listing.rejected ? 'rejected' : 'missing';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A team server from `/_home/accounts`: `byHub` = { normUrl: state } of the profile's saved sign-ins,
|
|
85
|
+
* `null` while that has not answered. A server with no saved sign-in at all is "missing".
|
|
86
|
+
*/
|
|
87
|
+
export function serverState(byHub, url) {
|
|
88
|
+
if (!byHub) return null;
|
|
89
|
+
const st = byHub.get(url);
|
|
90
|
+
if (st === undefined) return 'missing';
|
|
91
|
+
return st === 'rejected' ? 'rejected' : st === 'unreachable' ? 'unreachable' : 'ok';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The badge: the state's word + tone, worn on the account's face. null = no state to show. */
|
|
95
|
+
export function connBadge(state, { kind, profile, email }) {
|
|
96
|
+
if (!state) return null;
|
|
97
|
+
const face =
|
|
98
|
+
kind === 'cloud'
|
|
99
|
+
? {
|
|
100
|
+
kind: 'cloud',
|
|
101
|
+
...accountFace({ id: profile?.id, label: email || profile?.label, email }),
|
|
102
|
+
}
|
|
103
|
+
: { kind: kind === 'team' ? 'server' : 'local' };
|
|
104
|
+
return { state, word: CONN_WORDS[state], tone: CONN_TONE[state], face };
|
|
105
|
+
}
|