@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.
Files changed (129) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/filters.ts +12 -5
  3. package/apps/studio/access/known-canvases.ts +24 -1
  4. package/apps/studio/access/refused-inputs.ts +89 -0
  5. package/apps/studio/actions/agents.ts +5 -0
  6. package/apps/studio/actions/defs/app.ts +12 -0
  7. package/apps/studio/actions.manifest.json +13 -1
  8. package/apps/studio/actions.parity.json +7 -1
  9. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  10. package/apps/studio/annotations/ui/lod.tsx +1 -1
  11. package/apps/studio/annotations/ui/text-style.ts +1 -1
  12. package/apps/studio/annotations-layer.tsx +0 -12
  13. package/apps/studio/api.ts +42 -0
  14. package/apps/studio/artboard-live-gate.tsx +267 -0
  15. package/apps/studio/artboard-live.ts +336 -0
  16. package/apps/studio/artboard-webgl.ts +668 -0
  17. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  18. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  19. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  20. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  21. package/apps/studio/bin/_ds-check.mjs +4 -1
  22. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  23. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  24. package/apps/studio/bin/_import-asset.mjs +2 -1
  25. package/apps/studio/bin/_perf-probe.mjs +2 -1
  26. package/apps/studio/bin/_studio-verb.mjs +24 -3
  27. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  28. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  29. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  30. package/apps/studio/bin/ds-check.sh +5 -1
  31. package/apps/studio/bin/perf.sh +11 -1
  32. package/apps/studio/bin/server-up.sh +7 -2
  33. package/apps/studio/bin/smoke.sh +19 -0
  34. package/apps/studio/canvas-lib.tsx +131 -12
  35. package/apps/studio/client/canvas-url.js +13 -0
  36. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  37. package/apps/studio/client/home/Shelves.jsx +4 -3
  38. package/apps/studio/client/home/home-accounts-model.js +121 -0
  39. package/apps/studio/client/home/home-api.js +6 -0
  40. package/apps/studio/client/home/home-app.jsx +141 -40
  41. package/apps/studio/client/home/home-model.js +172 -6
  42. package/apps/studio/client/home/home.css +169 -5
  43. package/apps/studio/client/home/shell-mode.js +8 -1
  44. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  45. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  46. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  47. package/apps/studio/client/panels/caps-cache.js +46 -0
  48. package/apps/studio/client/shell/viewport.jsx +36 -8
  49. package/apps/studio/client/v2/access/access-client.js +2 -0
  50. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  51. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  52. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  53. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  54. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  55. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  56. package/apps/studio/client/v2/code/code-bus.js +5 -0
  57. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  58. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  59. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  60. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  61. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  62. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  63. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  64. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  65. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  66. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  67. package/apps/studio/client/v2/history/git-model.js +3 -1
  68. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  69. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  70. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  71. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  72. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  73. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  74. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  75. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  76. package/apps/studio/client/v2/shell/share-cluster-host.jsx +137 -10
  77. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  78. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  79. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  80. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  81. package/apps/studio/client/v2/shell/use-account.js +8 -1
  82. package/apps/studio/collab/persistence.ts +9 -1
  83. package/apps/studio/collab/registry.ts +32 -0
  84. package/apps/studio/collab/room.ts +8 -0
  85. package/apps/studio/config-reload-wire.ts +53 -0
  86. package/apps/studio/dist/client.bundle.js +1232 -1232
  87. package/apps/studio/dist/styles.css +1 -1
  88. package/apps/studio/ds/board/specimen.tsx +12 -1
  89. package/apps/studio/ds/canvas-cli.ts +58 -2
  90. package/apps/studio/ds/check.ts +26 -1
  91. package/apps/studio/ds/cli.ts +7 -3
  92. package/apps/studio/ds/convert.ts +34 -6
  93. package/apps/studio/ds/ds-verb.ts +13 -0
  94. package/apps/studio/ds/post-build.ts +38 -0
  95. package/apps/studio/ds/upgrade-apply.ts +27 -5
  96. package/apps/studio/ds/upgrade-cli.ts +22 -2
  97. package/apps/studio/ds/upgrade-prove.ts +198 -15
  98. package/apps/studio/ds/upgrade-stage.ts +4 -1
  99. package/apps/studio/history/trash.ts +6 -0
  100. package/apps/studio/home/accounts.ts +87 -0
  101. package/apps/studio/home/index-reader.ts +24 -2
  102. package/apps/studio/home/routes.ts +19 -0
  103. package/apps/studio/http.ts +14 -2
  104. package/apps/studio/routes/ds-convert.ts +18 -0
  105. package/apps/studio/routes/trash.ts +16 -1
  106. package/apps/studio/server.ts +8 -10
  107. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  108. package/apps/studio/sync/asset-push.ts +146 -23
  109. package/apps/studio/sync/asset-state.ts +3 -2
  110. package/apps/studio/sync/file-membership.ts +28 -3
  111. package/apps/studio/sync/file-plane.ts +40 -9
  112. package/apps/studio/sync/file-pull.ts +304 -33
  113. package/apps/studio/sync/hub-link.ts +1 -2
  114. package/apps/studio/sync/index.ts +308 -150
  115. package/apps/studio/sync/journal-client.ts +94 -5
  116. package/apps/studio/sync/pending-deletes.ts +100 -0
  117. package/apps/studio/sync/projection.ts +77 -12
  118. package/apps/studio/sync/seed-progress.ts +12 -1
  119. package/apps/studio/sync/status.ts +3 -1
  120. package/apps/studio/thumbs/service.ts +12 -2
  121. package/apps/studio/thumbs/validate.ts +7 -0
  122. package/apps/studio/ui-prefs-migrate.ts +4 -0
  123. package/apps/studio/video-comp.tsx +23 -0
  124. package/apps/studio/whats-new.json +72 -0
  125. package/cli/lib/bash-guard.mjs +13 -1
  126. package/cli/lib/design-help.gen.mjs +1 -1
  127. package/cli/lib/design-hook.mjs +20 -0
  128. package/cli/lib/studio-locate.mjs +35 -10
  129. package/package.json +8 -8
@@ -0,0 +1,121 @@
1
+ // client/home/home-accounts-model.js — 2.0.5 W4b: what Home's avatar lists. PURE.
2
+ //
3
+ // Every profile on this Mac by its label (`shell_state.profiles`), each with the accounts it is
4
+ // signed in with:
5
+ // cloud the profile's Maude Cloud listing says signed in → its e-mail; Sign out =
6
+ // POST /_home/cloud/signout {profile} (that profile's cloud.json only)
7
+ // team each team server in that profile's hubs.json (`GET /_home/accounts`) → host + the
8
+ // account it vouched for; Sign out = POST /_home/hub/signout {profile, url}
9
+ // github the login last signed in on the profile (profiles.json). Home has no GitHub sign-out
10
+ // path of its own — it lives in the project's account card — so no button here
11
+ // (Michal's rule: no dead buttons). A profile without a login offers "Sign in with GitHub…"
12
+ // (the existing `home_github_sign_in`).
13
+ // Add / switch: "Add a Maude Cloud account…" is Home's own sign-in, which never re-signs a profile
14
+ // that holds a credential (`home_cloud_sign_in_prepare` makes a fresh one — that IS the switch);
15
+ // "Connect to a team server…" is the Advanced › hub sheet. A browser has no shell: facts only.
16
+
17
+ import { accountFace } from './home-model.js';
18
+
19
+ const hostOf = (url) => {
20
+ try {
21
+ return new URL(String(url)).host;
22
+ } catch {
23
+ return String(url || '');
24
+ }
25
+ };
26
+ const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
27
+
28
+ function signOutSpec(path, name, extra) {
29
+ return {
30
+ path,
31
+ ...extra,
32
+ label: `Sign out of ${name}…`,
33
+ confirm: {
34
+ title: `Sign out of ${name}?`,
35
+ body:
36
+ path === 'hub-signout'
37
+ ? 'Projects on this account stop syncing with it. Your work stays on this Mac.'
38
+ : 'Every project on this account is signed out. Your work stays on this Mac.',
39
+ primary: 'Sign out',
40
+ cancel: 'Cancel',
41
+ },
42
+ };
43
+ }
44
+
45
+ /**
46
+ * @param in.native the desktop app
47
+ * @param in.shell `shell_state` (profiles: [{ id, label, email?, github? }])
48
+ * @param in.clouds one `GET /_home/cloud` answer per profile
49
+ * @param in.hubProfiles `GET /_home/accounts` `profiles`
50
+ */
51
+ export function homeAccounts({ native = false, shell = null, clouds = null, hubProfiles = null }) {
52
+ const known = (shell?.profiles ?? []).filter((p) => p && typeof p.id === 'string');
53
+ const ids = [
54
+ ...known.map((p) => p.id),
55
+ ...(clouds ?? [])
56
+ .filter((c) => c?.signedIn && typeof c.profile === 'string')
57
+ .map((c) => c.profile),
58
+ ].filter((id, i, all) => all.indexOf(id) === i);
59
+
60
+ const profiles = ids.map((id) => {
61
+ const p = known.find((x) => x.id === id) ?? null;
62
+ const label = str(p?.label) || (id === 'default' ? 'Default' : id);
63
+ const cloud = (clouds ?? []).find((c) => c?.profile === id) ?? null;
64
+ const accounts = [];
65
+ if (cloud?.signedIn) {
66
+ const email = str(cloud.account?.email) || str(p?.email);
67
+ accounts.push({
68
+ kind: 'cloud',
69
+ key: 'cloud',
70
+ title: 'Maude Cloud',
71
+ host: null,
72
+ who: email,
73
+ signOut: native
74
+ ? signOutSpec('cloud-signout', email || 'Maude Cloud', { profile: id })
75
+ : null,
76
+ });
77
+ }
78
+ for (const h of (hubProfiles ?? []).find((x) => x?.id === id)?.hubs ?? []) {
79
+ if (!h || typeof h.url !== 'string') continue;
80
+ const host = hostOf(h.url);
81
+ accounts.push({
82
+ kind: 'team',
83
+ key: `team:${h.url}`,
84
+ title: 'Team server',
85
+ host,
86
+ who: str(h.account),
87
+ signOut: native ? signOutSpec('hub-signout', host, { profile: id, url: h.url }) : null,
88
+ });
89
+ }
90
+ const gh = str(p?.github);
91
+ if (gh)
92
+ accounts.push({
93
+ kind: 'github',
94
+ key: 'github',
95
+ title: 'GitHub',
96
+ host: null,
97
+ who: `@${gh.replace(/^@/, '')}`,
98
+ signOut: null,
99
+ });
100
+ return {
101
+ id,
102
+ label,
103
+ face: accountFace({ id, label, email: accounts[0]?.who?.replace(/^@/, '') || '' }),
104
+ accounts,
105
+ githubSignIn: native && !gh,
106
+ };
107
+ });
108
+
109
+ const first = profiles.find((p) => p.accounts.length) ?? profiles[0] ?? null;
110
+ const face = first
111
+ ? {
112
+ ...first.face,
113
+ title: [first.label, first.accounts[0]?.who].filter(Boolean).join(' · ') || 'Your accounts',
114
+ }
115
+ : null;
116
+ return {
117
+ profiles,
118
+ face,
119
+ add: native ? { cloud: 'Add a Maude Cloud account…', team: 'Connect to a team server…' } : null,
120
+ };
121
+ }
@@ -89,6 +89,12 @@ export const getIndex = (pids, running = []) =>
89
89
  homeFetch(`/_home/index?pids=${pidParam(pids)}&running=${pidParam(running)}`);
90
90
  export const getCloud = (profile) =>
91
91
  homeFetch(`/_home/cloud?profile=${encodeURIComponent(profile)}`);
92
+ /** 2.0.5 W4b — each profile's team-server sign-ins: `{ ok, profiles: [{ id, hubs: [{url, account}] }] }`. */
93
+ export const getAccounts = (profiles) =>
94
+ homeFetch(`/_home/accounts?profiles=${pidParam(profiles)}`);
95
+ /** 2.0.5 W4b — sign ONE profile out of one team server / of Maude Cloud. */
96
+ export const hubSignOut = (profile, url) => post('/_home/hub/signout', { profile, url });
97
+ export const cloudSignOut = (profile) => post('/_home/cloud/signout', { profile });
92
98
  export const search = (q, pids) =>
93
99
  homeFetch(`/_home/search?q=${encodeURIComponent(q)}&pids=${pidParam(pids)}`);
94
100
  export const getRecentSearches = () => homeFetch('/_home/recent-searches');
@@ -15,7 +15,9 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
15
15
  import {
16
16
  createLocal,
17
17
  createLocalFromPrompt,
18
+ getAccounts,
18
19
  getCloud,
20
+ getConfig,
19
21
  getIndex,
20
22
  getFirstRunSeen,
21
23
  getRecentSearches,
@@ -40,6 +42,7 @@ import {
40
42
  takePendingDeepLink,
41
43
  thumbObjectUrl,
42
44
  } from './home-api.js';
45
+ import { homeBootConfig } from './shell-mode.js';
43
46
  import { parseMaudeLink } from '../share-link.js';
44
47
  import { browserDoorOf } from '../v2/cloud/browser-door.js';
45
48
  import { AdvancedSheets } from '../v2/onboarding/AdvancedSheets.jsx';
@@ -56,6 +59,7 @@ import { HOME_MENU, homeMenuCtx, homeMenuState } from './home-menu.js';
56
59
  import { InviteSheet } from './InviteSheet.jsx';
57
60
  import { INVITE_WORDS, joinPendingAndOpen, useInviteFlow } from './invite-flow.js';
58
61
  import { HIcon, HMark, HSpark, ProjectSquare } from './home-icons.jsx';
62
+ import { HomeAccounts } from './HomeAccounts.jsx';
59
63
  import {
60
64
  accountFace,
61
65
  buildHomeModel,
@@ -117,6 +121,17 @@ function browserPids() {
117
121
  }
118
122
  }
119
123
 
124
+ /** `/_config.cloudOrigin` when it is an http(s) origin, else null. */
125
+ function cloudOriginOf(cfg) {
126
+ const o = cfg?.cloudOrigin;
127
+ return typeof o === 'string' && /^https?:\/\/[^/]+$/i.test(o) ? o : null;
128
+ }
129
+
130
+ /** Who each profile is signed in as (id · e-mail · GitHub login): changes on a sign-in or sign-out. */
131
+ function profileSignature(s) {
132
+ return (s?.profiles ?? []).map((p) => [p?.id, p?.email, p?.github].join('|')).join(',');
133
+ }
134
+
120
135
  // ── data ─────────────────────────────────────────────────────────────────────────────────────
121
136
  function useHomeData() {
122
137
  const [shell, setShell] = useState(null);
@@ -172,6 +187,11 @@ function useHomeData() {
172
187
  }
173
188
  }, [native]);
174
189
 
190
+ // 2.0.5 — counts the moments the team-server accounts may have changed (a reload after a sign-in or
191
+ // sign-out, an index change, a profile change); the rows read /_home/accounts again on every tick
192
+ const [accountsEpoch, setAccountsEpoch] = useState(0);
193
+ const bumpAccounts = useCallback(() => setAccountsEpoch((e) => e + 1), []);
194
+
175
195
  const loadAll = useCallback(async () => {
176
196
  const s = await readShell();
177
197
  shellRef.current = s;
@@ -179,7 +199,8 @@ function useHomeData() {
179
199
  const ok = await fetchIndexFor(s, null);
180
200
  setStatus(ok ? 'ready' : 'offline');
181
201
  fetchClouds(s);
182
- }, [readShell, fetchIndexFor, fetchClouds]);
202
+ bumpAccounts();
203
+ }, [readShell, fetchIndexFor, fetchClouds, bumpAccounts]);
183
204
 
184
205
  // step 5 — re-run 1–2 for the pids whose place changed (or that are new)
185
206
  const onShellState = useCallback(
@@ -199,8 +220,10 @@ function useHomeData() {
199
220
  if (changed.length) fetchIndexFor(s, changed);
200
221
  const profiles = (s.profiles ?? []).map((p) => p.id).join();
201
222
  if (profiles !== (prev?.profiles ?? []).map((p) => p.id).join()) fetchClouds(s);
223
+ // a profile signed in or out keeps its id but changes its e-mail / GitHub login
224
+ if (profileSignature(s) !== profileSignature(prev)) bumpAccounts();
202
225
  },
203
- [readShell, fetchIndexFor, fetchClouds]
226
+ [readShell, fetchIndexFor, fetchClouds, bumpAccounts]
204
227
  );
205
228
 
206
229
  useEffect(() => {
@@ -213,6 +236,7 @@ function useHomeData() {
213
236
  shellListen('index://changed', (p) => {
214
237
  const pids = Array.isArray(p?.pids) ? p.pids : null;
215
238
  fetchIndexFor(shellRef.current, pids);
239
+ bumpAccounts();
216
240
  }).then((off) => (alive ? offs.push(off) : off()));
217
241
  const onVisible = () => {
218
242
  if (document.visibilityState === 'visible') loadAll();
@@ -223,7 +247,7 @@ function useHomeData() {
223
247
  for (const off of offs) off();
224
248
  document.removeEventListener('visibilitychange', onVisible);
225
249
  };
226
- }, [loadAll, onShellState, fetchIndexFor]);
250
+ }, [loadAll, onShellState, fetchIndexFor, bumpAccounts]);
227
251
 
228
252
  const patchPin = useCallback((pid, rel, pinnedAt) => {
229
253
  setIndex((prev) => {
@@ -238,7 +262,17 @@ function useHomeData() {
238
262
  });
239
263
  }, []);
240
264
 
241
- return { native, shell, index, clouds, cloudsReady, status, reload: loadAll, patchPin };
265
+ return {
266
+ native,
267
+ shell,
268
+ index,
269
+ clouds,
270
+ cloudsReady,
271
+ status,
272
+ accountsEpoch,
273
+ reload: loadAll,
274
+ patchPin,
275
+ };
242
276
  }
243
277
 
244
278
  // ── maude:// links (V2-3.5) ───────────────────────────────────────────────────────────────────
@@ -399,6 +433,48 @@ export function HomeApp() {
399
433
  const askingRef = useRef(false);
400
434
  const [seen, setSeen] = useState(readSeen);
401
435
 
436
+ // 2.0.5 — the control plane this Home server talks to (`/_config.cloudOrigin`, from
437
+ // MAUDE_CLOUD_URL): it tells a Maude Cloud project from a team server. The client never names
438
+ // the vendor's address itself (cloud-shell-surfaces pin); until it is known no row guesses.
439
+ const [cloudUrl, setCloudUrl] = useState(() => cloudOriginOf(homeBootConfig()));
440
+ useEffect(() => {
441
+ if (cloudUrl) return undefined;
442
+ let live = true;
443
+ getConfig().then((r) => {
444
+ const origin = r.ok ? cloudOriginOf(r.json) : null;
445
+ if (live && origin) setCloudUrl(origin);
446
+ });
447
+ return () => {
448
+ live = false;
449
+ };
450
+ }, [cloudUrl]);
451
+
452
+ // 2.0.5 W4b — the account each profile's team servers vouched for, so a row can say
453
+ // "Team server · <host> · <account>" (public handles from /_home/accounts, never a token)
454
+ const [hubAccounts, setHubAccounts] = useState(null);
455
+ const profileKey = (data.shell?.profiles ?? [])
456
+ .map((p) => p?.id)
457
+ .filter(Boolean)
458
+ .join(',');
459
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `accountsEpoch` is the trigger — it ticks on every sign-in / sign-out / index change
460
+ useEffect(() => {
461
+ if (!profileKey) return undefined;
462
+ let live = true;
463
+ getAccounts(profileKey.split(',')).then((r) => {
464
+ if (!live || !r.ok || !Array.isArray(r.json?.profiles)) return;
465
+ setHubAccounts(
466
+ Object.fromEntries(
467
+ r.json.profiles.map((p) => [
468
+ p.id,
469
+ Object.fromEntries((p.hubs ?? []).map((h) => [h.url, h.account])),
470
+ ])
471
+ )
472
+ );
473
+ });
474
+ return () => {
475
+ live = false;
476
+ };
477
+ }, [profileKey, data.accountsEpoch]);
402
478
  const model = useMemo(
403
479
  () =>
404
480
  buildHomeModel({
@@ -406,21 +482,12 @@ export function HomeApp() {
406
482
  index: data.index ? { v: 1, projects: [...data.index.values()] } : null,
407
483
  clouds: data.clouds,
408
484
  filterPid: filterPid || null,
485
+ hubAccounts,
486
+ cloudUrl,
409
487
  }),
410
- [data.shell, data.index, data.clouds, filterPid]
488
+ [data.shell, data.index, data.clouds, filterPid, hubAccounts, cloudUrl]
411
489
  );
412
- // the signed-in account's face at the top right (02 ob-home-new: a circle, never the project's square)
413
- const face = useMemo(() => {
414
- const c = data.clouds.find((x) => x?.signedIn);
415
- if (!c) return null;
416
- const id = c.profile || 'default';
417
- const label = (data.shell?.profiles ?? []).find((p) => p.id === id)?.label || '';
418
- const email = c.account?.email || '';
419
- return {
420
- ...accountFace({ id, label, email }),
421
- title: [label, email].filter(Boolean).join(' · ') || 'Your account',
422
- };
423
- }, [data.clouds, data.shell]);
490
+ // 2.0.5 W4b — the face at the top right opens every account on this Mac (HomeAccounts.jsx)
424
491
  const searchPids = useMemo(
425
492
  () => (data.shell ? indexQuery(data.shell).pids : browserPids()),
426
493
  [data.shell]
@@ -895,22 +962,14 @@ export function HomeApp() {
895
962
  }}
896
963
  canOpen={data.native}
897
964
  />
898
- {face ? (
899
- <span
900
- className="home-top-acct"
901
- data-testid="home-top-face"
902
- role="img"
903
- aria-label={face.title}
904
- title={face.title}
905
- >
906
- <span
907
- className={`home-face home-face--md home-face--${face.tone}`}
908
- aria-hidden="true"
909
- >
910
- {face.initial}
911
- </span>
912
- </span>
913
- ) : null}
965
+ <HomeAccounts
966
+ shell={data.shell}
967
+ clouds={data.clouds}
968
+ native={data.native}
969
+ onAddCloud={() => signin.begin()}
970
+ onAddTeam={() => openSheet('hub')}
971
+ onChanged={data.reload}
972
+ />
914
973
  </div>
915
974
  </header>
916
975
 
@@ -1342,12 +1401,6 @@ const RECENT_CAP = 6;
1342
1401
 
1343
1402
  const STATE_WORD = {
1344
1403
  tab: 'in a tab',
1345
- mac: (
1346
- <>
1347
- <HIcon name="laptop" size={12} />
1348
- this Mac only
1349
- </>
1350
- ),
1351
1404
  cloud: (
1352
1405
  <>
1353
1406
  <HIcon name="cloud" size={12} />
@@ -1356,6 +1409,52 @@ const STATE_WORD = {
1356
1409
  ),
1357
1410
  };
1358
1411
 
1412
+ // 2.0.5 W4b — how a local project is connected and as whom: "Local · this Mac only",
1413
+ // "Maude Cloud · <account>", "Team server · <host> · <account>" (home-model `connectionOf`).
1414
+ const CONNECTION_ICON = { local: 'laptop', cloud: 'cloud', team: 'server' };
1415
+ function ConnectionWords({ row }) {
1416
+ const c = row.connection;
1417
+ if (!c?.words) return null;
1418
+ return (
1419
+ <span
1420
+ className="home-prow-conn"
1421
+ data-testid={`home-project-conn-${row.pid}`}
1422
+ data-kind={c.kind}
1423
+ >
1424
+ <HIcon name={CONNECTION_ICON[c.kind] ?? 'laptop'} size={12} />
1425
+ {c.words}
1426
+ </span>
1427
+ );
1428
+ }
1429
+
1430
+ // 2.0.5 W4b — the folders folded into this row (a managed cloud copy; another folder on the same
1431
+ // design root). Each still opens its own project.
1432
+ function RowCopies({ row, canOpen, onOpen }) {
1433
+ if (!row.copies?.length) return null;
1434
+ return (
1435
+ <span className="home-prow-copies">
1436
+ {row.copies.map((c) => (
1437
+ <button
1438
+ key={c.pid}
1439
+ type="button"
1440
+ className="chip home-prow-copy"
1441
+ data-testid={`home-project-copy-${c.pid}`}
1442
+ data-kind={c.kind}
1443
+ onClick={() => onOpen(c.pid)}
1444
+ disabled={!canOpen}
1445
+ {...reasonProps(!canOpen, 'homeBrowser')}
1446
+ title={c.root}
1447
+ aria-label={
1448
+ c.kind === 'folder' ? `Open ${c.label}` : `Open the ${c.label} of ${row.name}`
1449
+ }
1450
+ >
1451
+ {c.kind === 'folder' ? `also ${c.label}` : c.label}
1452
+ </button>
1453
+ ))}
1454
+ </span>
1455
+ );
1456
+ }
1457
+
1359
1458
  // A project tab's live state (shell_state `ai` + `place`), canvas 11's words: AI working (a spark
1360
1459
  // while it runs) · Needs you (it is waiting on a decision — the one that asks for you wins) ·
1361
1460
  // Resting (its server is stopped; the tab wakes it). A resting tab never has AI (rest policy).
@@ -1474,10 +1573,11 @@ function ProfileGroup({ group, showHeader, canOpen, onOpen, onRelink, onOpenClou
1474
1573
  {[
1475
1574
  r.canvasCount != null ? canvasCount(r.canvasCount) : null,
1476
1575
  STATE_WORD[r.status] ?? null,
1576
+ r.connection ? <ConnectionWords key="conn" row={r} /> : null,
1477
1577
  ]
1478
1578
  .filter(Boolean)
1479
1579
  .map((part, i) => (
1480
- // biome-ignore lint/suspicious/noArrayIndexKey: a fixed two-part line
1580
+ // biome-ignore lint/suspicious/noArrayIndexKey: a fixed three-part line
1481
1581
  <span key={i} className="home-prow-part">
1482
1582
  {i ? ' · ' : ''}
1483
1583
  {part}
@@ -1489,6 +1589,7 @@ function ProfileGroup({ group, showHeader, canOpen, onOpen, onRelink, onOpenClou
1489
1589
  <ProjectSquare id={r.pid} name={r.name} />
1490
1590
  </button>
1491
1591
  )}
1592
+ <RowCopies row={r} canOpen={canOpen} onOpen={onOpen} />
1492
1593
  </li>
1493
1594
  )
1494
1595
  )}
@@ -100,11 +100,94 @@ function canvasRow(pid, projectName, c) {
100
100
 
101
101
  const DEFAULT_PROFILE = { id: 'default', label: 'This Mac' };
102
102
 
103
+ const hostOfUrl = (url) => {
104
+ try {
105
+ return new URL(String(url)).hostname.toLowerCase();
106
+ } catch {
107
+ return '';
108
+ }
109
+ };
110
+
111
+ // What a row calls a hub: the host, plus the port when it is not the scheme's default (URL.host drops
112
+ // 443/80 itself) — the same words the account card and the project's account card use.
113
+ const hubLabelOf = (url) => {
114
+ try {
115
+ return new URL(String(url)).host.toLowerCase();
116
+ } catch {
117
+ return '';
118
+ }
119
+ };
120
+
121
+ /**
122
+ * A hub of Maude Cloud (the control plane's host or a cell under it) — connections-model's rule.
123
+ * `cloudUrl` is the control plane this Home server talks to (`/_config.cloudOrigin`, from
124
+ * `MAUDE_CLOUD_URL`); the client never names the vendor's address itself, so a self-hosted
125
+ * control plane is "Maude Cloud" here too. Not known yet ⇒ false (nothing is guessed).
126
+ */
127
+ export function isCloudHubUrl(hubUrl, cloudUrl) {
128
+ const host = hostOfUrl(hubUrl);
129
+ const cloud = cloudUrl ? hostOfUrl(cloudUrl) : '';
130
+ return !!host && !!cloud && (host === cloud || host.endsWith(`.${cloud}`));
131
+ }
132
+
133
+ /**
134
+ * 2.0.5 W4b — the project id of a managed copy, read from its folder: `managed.rs`
135
+ * `managed_key_for` names it `[<profile>@]<host>--<id>` under the app's data folder. null = the
136
+ * folder is not the copy of `boundHub` (a folder the person opened is never a copy).
137
+ */
138
+ export function copyProjectId(root, boundHub) {
139
+ if (!boundHub) return null;
140
+ const base =
141
+ String(root || '')
142
+ .split('/')
143
+ .filter(Boolean)
144
+ .pop() ?? '';
145
+ const key = base.includes('@') ? base.slice(base.indexOf('@') + 1) : base;
146
+ const prefix = managedKey(boundHub, '');
147
+ return key.length > prefix.length && key.startsWith(prefix) ? key.slice(prefix.length) : null;
148
+ }
149
+
150
+ /**
151
+ * 2.0.5 W4b (3) — how a project is connected and as whom, in one line: "Local · this Mac only",
152
+ * "Maude Cloud · <account>", "Team server · <host> · <account>". An account nobody recorded is
153
+ * left out, never guessed.
154
+ */
155
+ export function connectionOf({ hub, profileEmail = null, hubAccount = null, cloudUrl = null }) {
156
+ if (!hub) return { kind: 'local', host: null, account: null, words: 'Local · this Mac only' };
157
+ // the control plane is not known yet (Home's /_config has not answered): say nothing rather
158
+ // than call a Maude Cloud project a team server
159
+ if (!cloudUrl) return { kind: 'unknown', host: hubLabelOf(hub), account: null, words: null };
160
+ if (isCloudHubUrl(hub, cloudUrl)) {
161
+ const account = profileEmail || null;
162
+ return {
163
+ kind: 'cloud',
164
+ host: hubLabelOf(hub),
165
+ account,
166
+ words: ['Maude Cloud', account].filter(Boolean).join(' · '),
167
+ };
168
+ }
169
+ const host = hubLabelOf(hub);
170
+ const account = hubAccount || null;
171
+ return {
172
+ kind: 'team',
173
+ host,
174
+ account,
175
+ words: ['Team server', host, account].filter(Boolean).join(' · '),
176
+ };
177
+ }
178
+
103
179
  /**
104
180
  * @param {{ shell?: object|null, index?: object|null, clouds?: object[]|null,
105
181
  * filterPid?: string|null }} input
106
182
  */
107
- export function buildHomeModel({ shell = null, index = null, clouds = null, filterPid = null }) {
183
+ export function buildHomeModel({
184
+ shell = null,
185
+ index = null,
186
+ clouds = null,
187
+ filterPid = null,
188
+ hubAccounts = null,
189
+ cloudUrl = null,
190
+ }) {
108
191
  const indexed = new Map();
109
192
  for (const p of index?.projects ?? []) if (p && typeof p.pid === 'string') indexed.set(p.pid, p);
110
193
 
@@ -142,7 +225,18 @@ export function buildHomeModel({ shell = null, index = null, clouds = null, filt
142
225
 
143
226
  // ── projects by profile ──────────────────────────────────────────────────────────────────
144
227
  const mru = new Map((shell?.recent ?? []).map((pid, i) => [pid, i]));
145
- const localRows = registry.map((p) => {
228
+ const emailOf = (id) =>
229
+ (shell?.profiles ?? []).find((x) => x?.id === id)?.email ||
230
+ (clouds ?? []).find((c) => c?.profile === id)?.account?.email ||
231
+ null;
232
+ const accountsOn = new Map();
233
+ for (const [id, byHub] of Object.entries(hubAccounts ?? {})) {
234
+ const m = new Map();
235
+ for (const [url, who] of Object.entries(byHub ?? {}))
236
+ if (normHubUrl(url) && typeof who === 'string' && who) m.set(normHubUrl(url), who);
237
+ accountsOn.set(id, m);
238
+ }
239
+ const allLocal = registry.map((p) => {
146
240
  const ix = indexed.get(p.pid);
147
241
  const gone = ix?.state === 'gone';
148
242
  // `hub` (display + the 'mac' word) is the project's own linkedHub — a HINT it wrote itself.
@@ -153,11 +247,15 @@ export function buildHomeModel({ shell = null, index = null, clouds = null, filt
153
247
  // 'mac' = "this Mac only" — true only of a project with no hub; a linked one that is not in a
154
248
  // tab is plain 'closed' (no state word)
155
249
  const inTab = p.place === 'tab' || p.place === 'resting';
156
- const status = gone ? 'gone' : inTab ? 'tab' : hub ? 'closed' : 'mac';
250
+ // W4b: a managed copy whose own config lost its claim is still the app's copy of a hub — never
251
+ // "this Mac only"
252
+ const status = gone ? 'gone' : inTab ? 'tab' : hub || boundHub ? 'closed' : 'mac';
253
+ const profile = p.profile || DEFAULT_PROFILE.id;
254
+ const shown = boundHub || hub;
157
255
  return {
158
256
  kind: 'local',
159
257
  pid: p.pid,
160
- profile: p.profile || DEFAULT_PROFILE.id,
258
+ profile,
161
259
  name: ix?.project?.name || p.name || 'Untitled project',
162
260
  root: p.root || ix?.project?.root || '',
163
261
  status,
@@ -170,19 +268,29 @@ export function buildHomeModel({ shell = null, index = null, clouds = null, filt
170
268
  formatGate: p.formatGate ?? null,
171
269
  hub,
172
270
  boundHub,
271
+ copyOf: copyProjectId(p.root, boundHub),
272
+ designReal: !gone && typeof ix?.designReal === 'string' ? ix.designReal : null,
273
+ connection: connectionOf({
274
+ hub: shown,
275
+ profileEmail: emailOf(profile),
276
+ hubAccount: shown ? (accountsOn.get(profile)?.get(shown) ?? null) : null,
277
+ cloudUrl,
278
+ }),
279
+ copies: [],
173
280
  folder: (p.root || '').split('/').filter(Boolean).pop() ?? '',
174
281
  cover: firstCover(ix),
175
282
  };
176
283
  });
177
- localRows.sort((a, b) => {
284
+ allLocal.sort((a, b) => {
178
285
  const ia = mru.has(a.pid) ? mru.get(a.pid) : Number.POSITIVE_INFINITY;
179
286
  const ib = mru.has(b.pid) ? mru.get(b.pid) : Number.POSITIVE_INFINITY;
180
287
  return ia - ib || a.name.localeCompare(b.name);
181
288
  });
289
+ const localRows = collapseDuplicates(allLocal, cloudUrl);
182
290
 
183
291
  // one profile's copy never hides another profile's cloud row
184
292
  const bound = new Set(
185
- localRows.filter((r) => r.boundHub).map((r) => `${r.profile} ${r.boundHub}`)
293
+ allLocal.filter((r) => r.boundHub).map((r) => `${r.profile} ${r.boundHub}`)
186
294
  );
187
295
  const cloudRows = [];
188
296
  for (const listing of clouds ?? []) {
@@ -253,6 +361,64 @@ export function buildHomeModel({ shell = null, index = null, clouds = null, filt
253
361
  };
254
362
  }
255
363
 
364
+ /**
365
+ * 2.0.5 W4b (4) — one row per project. Identity, never the label:
366
+ * (a) a managed copy (profile + its bound hub + the project id in its folder name) folds into the
367
+ * ONE folder of the same profile that links that hub; the folder the person opened stays the
368
+ * row. Two copies on one hub, or two such folders, cannot be told apart: nothing folds.
369
+ * (b) rows whose design root is one realpath (a `.design` symlink) fold into the last opened.
370
+ * A folded row stays openable from its primary's `copies`. Rows arrive MRU-sorted; nothing is
371
+ * removed from the registry — this is only what Home draws.
372
+ */
373
+ function collapseDuplicates(rows, cloudUrl) {
374
+ const out = rows.map((r) => ({ ...r, copies: [] }));
375
+ const drop = new Set();
376
+ const live = (r) => r.status !== 'gone';
377
+ const fold = (primary, r, kind, label) => {
378
+ primary.copies.push({ pid: r.pid, kind, label, place: r.place, root: r.root, name: r.name });
379
+ if (primary.canvasCount == null && r.canvasCount != null) {
380
+ primary.canvasCount = r.canvasCount;
381
+ primary.byKind = r.byKind;
382
+ }
383
+ if (!primary.cover && r.cover) primary.cover = r.cover;
384
+ if (primary.status === 'mac' && r.status !== 'mac') primary.status = 'closed';
385
+ if (primary.connection?.kind === 'local' && r.connection?.kind !== 'local')
386
+ primary.connection = r.connection;
387
+ drop.add(r.pid);
388
+ };
389
+
390
+ // (a) a managed copy into the folder that links the same hub
391
+ for (const c of out) {
392
+ if (!c.copyOf || !live(c)) continue;
393
+ const sameHub = out.filter(
394
+ (x) => x.copyOf && x.profile === c.profile && x.boundHub === c.boundHub
395
+ );
396
+ if (sameHub.length !== 1) continue;
397
+ const folders = out.filter(
398
+ (x) =>
399
+ !x.copyOf && live(x) && !drop.has(x.pid) && x.profile === c.profile && x.hub === c.boundHub
400
+ );
401
+ if (folders.length !== 1) continue;
402
+ fold(
403
+ folders[0],
404
+ c,
405
+ 'cloud-copy',
406
+ !cloudUrl ? 'copy' : isCloudHubUrl(c.boundHub, cloudUrl) ? 'cloud copy' : 'server copy'
407
+ );
408
+ }
409
+
410
+ // (b) one design root, many folders: the last opened leads (rows are MRU-sorted)
411
+ const byReal = new Map();
412
+ for (const r of out) {
413
+ if (drop.has(r.pid) || !r.designReal || !live(r)) continue;
414
+ const key = `${r.profile} ${r.designReal}`;
415
+ const primary = byReal.get(key);
416
+ if (!primary) byReal.set(key, r);
417
+ else fold(primary, r, 'folder', r.folder || r.name);
418
+ }
419
+ return out.filter((r) => !drop.has(r.pid));
420
+ }
421
+
256
422
  // ── where the sentence lands (S6.4 — the chip under the question) ─────────────────────────────
257
423
 
258
424
  /** `https://alligators.cloud.maude.sh` → `alligators.cloud.maude.sh` (a hint's words; '' when none). */