@1agh/maude 2.0.3 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -0,0 +1,262 @@
1
+ // client/home/HomeAccounts.jsx — 2.0.5 W4b: Home's avatar and the card it opens.
2
+ //
3
+ // Every profile on this Mac by its label, with the accounts it is signed in with (Maude Cloud,
4
+ // team servers, GitHub): Sign out per account where Home has a path (asks first), Sign in with
5
+ // GitHub for a profile without it, and add / switch at the foot. What each row means and why a
6
+ // row has no button: home-accounts-model.js. The card fetches the team-server sign-ins when it
7
+ // opens (`GET /_home/accounts`) and after every sign-out.
8
+
9
+ import { useCallback, useEffect, useRef, useState } from 'react';
10
+
11
+ import { cloudSignOut, getAccounts, hubSignOut, shellInvoke, shellListen } from './home-api.js';
12
+ import { homeAccounts } from './home-accounts-model.js';
13
+ import { githubSignIn } from '../v2/onboarding/github-home.js';
14
+
15
+ const KIND_TITLE = { cloud: 'Maude Cloud', team: 'Team server', github: 'GitHub' };
16
+
17
+ /** The team-server sign-ins of `ids`, re-read when `open` turns on or `gen` moves. */
18
+ function useHubProfiles(ids, open, gen) {
19
+ const [hubProfiles, setHubProfiles] = useState([]);
20
+ const key = ids.join(',');
21
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for `ids`; `gen` re-reads
22
+ useEffect(() => {
23
+ if (!open || !key) return undefined;
24
+ let live = true;
25
+ getAccounts(key.split(',')).then((r) => {
26
+ if (live && r.ok && Array.isArray(r.json?.profiles)) setHubProfiles(r.json.profiles);
27
+ });
28
+ return () => {
29
+ live = false;
30
+ };
31
+ }, [open, key, gen]);
32
+ return hubProfiles;
33
+ }
34
+
35
+ /**
36
+ * @param shell / clouds / native — Home's data
37
+ * @param onAddCloud () => void Home's Maude Cloud sign-in (a fresh profile when one is signed in)
38
+ * @param onAddTeam () => void the Advanced › team server sheet
39
+ * @param onChanged () => Promise reload Home's data after a sign-out / sign-in
40
+ */
41
+ export function HomeAccounts({ shell, clouds, native, onAddCloud, onAddTeam, onChanged }) {
42
+ const [open, setOpen] = useState(false);
43
+ const [gen, setGen] = useState(0);
44
+ const [asking, setAsking] = useState(null);
45
+ const [busy, setBusy] = useState(false);
46
+ const [error, setError] = useState(null);
47
+ const [ghCode, setGhCode] = useState(null);
48
+ const wrap = useRef(null);
49
+ const ids = (shell?.profiles ?? []).map((p) => p?.id).filter((id) => typeof id === 'string');
50
+ const hubProfiles = useHubProfiles(ids, open, gen);
51
+ const model = homeAccounts({ native, shell, clouds, hubProfiles });
52
+
53
+ const close = useCallback(() => {
54
+ setOpen(false);
55
+ setAsking(null);
56
+ setError(null);
57
+ }, []);
58
+ useEffect(() => {
59
+ if (!open) return undefined;
60
+ const onKey = (e) => e.key === 'Escape' && close();
61
+ const onDown = (e) => wrap.current && !wrap.current.contains(e.target) && close();
62
+ window.addEventListener('keydown', onKey);
63
+ window.addEventListener('pointerdown', onDown);
64
+ return () => {
65
+ window.removeEventListener('keydown', onKey);
66
+ window.removeEventListener('pointerdown', onDown);
67
+ };
68
+ }, [open, close]);
69
+ // the GitHub device code arrives as a shell message while a sign-in from this card runs
70
+ useEffect(() => {
71
+ if (!open || !native) return undefined;
72
+ let off = () => {};
73
+ shellListen('github://device-code', (p) => setGhCode(p?.user_code ?? null)).then((u) => {
74
+ off = u;
75
+ });
76
+ return () => off();
77
+ }, [open, native]);
78
+
79
+ if (!model.face) return null;
80
+
81
+ const signOut = async () => {
82
+ const spec = asking;
83
+ setBusy(true);
84
+ setError(null);
85
+ const r =
86
+ spec.path === 'cloud-signout'
87
+ ? await cloudSignOut(spec.profile)
88
+ : await hubSignOut(spec.profile, spec.url);
89
+ setBusy(false);
90
+ setAsking(null);
91
+ if (!r.ok || !r.json?.ok) {
92
+ setError(r.json?.error || 'Couldn’t sign out. Nothing changed — try again.');
93
+ return;
94
+ }
95
+ setGen((g) => g + 1);
96
+ await onChanged?.();
97
+ };
98
+ const ghSignIn = async (profile) => {
99
+ setError(null);
100
+ setBusy(true);
101
+ try {
102
+ await githubSignIn(profile, shellInvoke);
103
+ await onChanged?.();
104
+ } catch (e) {
105
+ setError(typeof e === 'string' ? e : 'GitHub sign-in didn’t finish. Try again.');
106
+ } finally {
107
+ setGhCode(null);
108
+ setBusy(false);
109
+ }
110
+ };
111
+
112
+ return (
113
+ <span className="home-top-acct" ref={wrap}>
114
+ <button
115
+ type="button"
116
+ className="home-top-acct-btn"
117
+ data-testid="home-top-face"
118
+ aria-label={model.face.title}
119
+ title={model.face.title}
120
+ aria-haspopup="dialog"
121
+ aria-expanded={open}
122
+ onClick={() => (open ? close() : setOpen(true))}
123
+ >
124
+ <span
125
+ className={`home-face home-face--md home-face--${model.face.tone}`}
126
+ aria-hidden="true"
127
+ >
128
+ {model.face.initial}
129
+ </span>
130
+ </button>
131
+ {open ? (
132
+ <div
133
+ className="home-accts"
134
+ role="dialog"
135
+ aria-label="Accounts on this Mac"
136
+ data-testid="home-accounts"
137
+ >
138
+ <p className="home-accts-h">Accounts on this Mac</p>
139
+ {model.profiles.map((p) => (
140
+ <section
141
+ key={p.id}
142
+ className="home-accts-p"
143
+ data-testid={`home-accounts-profile-${p.id}`}
144
+ >
145
+ <h3 className="home-accts-ph">
146
+ <span className={`home-acctf home-acctf--${p.face.tone}`} aria-hidden="true">
147
+ {p.face.initial}
148
+ </span>
149
+ {p.label}
150
+ </h3>
151
+ {p.accounts.length ? (
152
+ <ul className="home-accts-list">
153
+ {p.accounts.map((a) => (
154
+ <li
155
+ key={a.key}
156
+ className="home-accts-row"
157
+ data-testid={`home-account-${p.id}-${a.kind}`}
158
+ >
159
+ <span className="home-accts-t">
160
+ <strong>
161
+ {a.kind === 'team'
162
+ ? `${KIND_TITLE.team} · ${a.host}`
163
+ : KIND_TITLE[a.kind]}
164
+ </strong>
165
+ {a.who ? <span>{a.who}</span> : null}
166
+ </span>
167
+ {a.signOut ? (
168
+ <button
169
+ type="button"
170
+ className="btn btn--ghost btn--sm"
171
+ data-testid={`home-account-signout-${p.id}-${a.kind}`}
172
+ onClick={() => setAsking(a.signOut)}
173
+ disabled={busy}
174
+ >
175
+ Sign out…
176
+ </button>
177
+ ) : null}
178
+ </li>
179
+ ))}
180
+ </ul>
181
+ ) : (
182
+ <p className="home-accts-none">Not signed in to anything yet.</p>
183
+ )}
184
+ {p.githubSignIn ? (
185
+ <button
186
+ type="button"
187
+ className="home-accts-act"
188
+ data-testid={`home-account-github-signin-${p.id}`}
189
+ onClick={() => ghSignIn(p.id)}
190
+ disabled={busy}
191
+ >
192
+ Sign in with GitHub…
193
+ </button>
194
+ ) : null}
195
+ </section>
196
+ ))}
197
+ {ghCode ? (
198
+ <p className="home-accts-note" data-testid="home-accounts-github-code">
199
+ Enter <strong>{ghCode}</strong> on the GitHub page that opened.
200
+ </p>
201
+ ) : null}
202
+ {error ? (
203
+ <p className="home-accts-note" role="alert" data-testid="home-accounts-error">
204
+ {error}
205
+ </p>
206
+ ) : null}
207
+ {asking ? (
208
+ <div className="home-accts-ask" role="alertdialog" data-testid="home-accounts-confirm">
209
+ <strong>{asking.confirm.title}</strong>
210
+ <span>{asking.confirm.body}</span>
211
+ <span className="home-accts-btns">
212
+ <button
213
+ type="button"
214
+ className="btn btn--sm"
215
+ data-testid="home-accounts-signout-cancel"
216
+ onClick={() => setAsking(null)}
217
+ >
218
+ {asking.confirm.cancel}
219
+ </button>
220
+ <button
221
+ type="button"
222
+ className="btn btn--sm btn--danger"
223
+ data-testid="home-accounts-signout-confirm"
224
+ disabled={busy}
225
+ onClick={signOut}
226
+ >
227
+ {asking.confirm.primary}
228
+ </button>
229
+ </span>
230
+ </div>
231
+ ) : null}
232
+ {model.add ? (
233
+ <div className="home-accts-foot">
234
+ <button
235
+ type="button"
236
+ className="home-accts-act"
237
+ data-testid="home-accounts-add-cloud"
238
+ onClick={() => {
239
+ close();
240
+ onAddCloud?.();
241
+ }}
242
+ >
243
+ {model.add.cloud}
244
+ </button>
245
+ <button
246
+ type="button"
247
+ className="home-accts-act"
248
+ data-testid="home-accounts-add-team"
249
+ onClick={() => {
250
+ close();
251
+ onAddTeam?.();
252
+ }}
253
+ >
254
+ {model.add.team}
255
+ </button>
256
+ </div>
257
+ ) : null}
258
+ </div>
259
+ ) : null}
260
+ </span>
261
+ );
262
+ }
@@ -10,7 +10,8 @@ import { accountFace, rowSlug, sharedAside } from './home-model.js';
10
10
  import { HIcon, ProjectSquare } from './home-icons.jsx';
11
11
  import { reasonProps } from '../v2/access/disabled-reason.js';
12
12
 
13
- /** Three ghost cards: the shelf's shape before there is anything on it. */
13
+ /** Three ghost cards: the shelf's shape before there is anything on it. Flat and dashed on purpose —
14
+ * they must never read as thumbnails that failed to load (no tilt, no fill). */
14
15
  export function GhostCards({ n = 3 }) {
15
16
  return (
16
17
  <span className="home-ghosts" aria-hidden="true">
@@ -202,10 +203,10 @@ export function SharedWithYou({
202
203
  ))}
203
204
  </div>
204
205
  ) : (
205
- <div className="home-shelf-row" data-testid="home-shared-empty">
206
- <GhostCards n={3} />
206
+ <div className="home-shelf-row home-shelf-row--lone" data-testid="home-shared-empty">
207
207
  <Empty
208
208
  align="left"
209
+ glyph="people"
209
210
  copyId="es-home-shared.shared-none"
210
211
  next="When someone shares a project with you, it shows up here."
211
212
  />
@@ -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');
@@ -130,27 +136,38 @@ export const signInOpenBrowser = (userCode, state) =>
130
136
  shellInvoke('home_cloud_sign_in_open', { userCode, state });
131
137
  /** After the Home server stored the credential: Rust records the account → the profile it landed in. */
132
138
  export const signInDone = (profile) => shellInvoke('home_cloud_signed_in', { profile });
133
- // S6.9 — the Advanced sheets' routes (S6.6). Nothing here keeps or logs what it carries: the hub
134
- // password is posted once, in the body, and the answer never contains it.
139
+ // S6.9 — the Advanced sheets' routes (S6.6). Issue #204 K2: Home takes no team-server password —
140
+ // Sign in (and an invite) opens the hub's own page in the browser, and Home's server waits for the
141
+ // browser to come back (home/hub.ts). Nothing here keeps or logs what it carries.
135
142
  /** "Test connection": one tokenless GET /health on the server → `{ok, reachable, url, version}`. */
136
143
  export const hubTest = (url) => post('/_home/hub/test', { url });
137
- /** "Connect": `creds` ({email, password}) signs in; without it, a hub this Mac already holds a sign-in for. */
138
- export const hubPrepare = (profile, url, creds) =>
139
- post('/_home/hub/prepare', {
140
- profile,
141
- url,
142
- ...(creds ? { email: creds.email, password: creds.password } : {}),
143
- });
144
- /** S6.11b — "Invite link or key": redeem a hub invite (the hub's POST /join) → the same answer as
145
- * `hubPrepare`. The invite key, email and password ride this one POST body, never a URL or a log. */
146
- export const hubJoin = (profile, url, invite) =>
147
- post('/_home/hub/join', {
148
- profile,
149
- url,
150
- token: invite?.token,
151
- email: invite?.email,
152
- password: invite?.password,
153
- });
144
+ /** The project on a team server THIS profile is signed in to → the managed copy to open. */
145
+ export const hubPrepare = (profile, url) => post('/_home/hub/prepare', { profile, url });
146
+ /** #204 K2 — a sign-in (with `invite`, an invite accept) on the hub's own page →
147
+ * `{ok, id, signInUrl}` | `{ok:false, error, reason?}` (`reason: 'needs-update'` for a hub < 2.0.4). */
148
+ export const hubSignInStart = (profile, url, invite) =>
149
+ post('/_home/hub/signin/start', { profile, url, ...(invite ? { invite } : {}) });
150
+ /** → `{ok, pending}` | `{ok, url, user}` | `{ok:false, error}`. */
151
+ export const hubSignInPoll = (id) => post('/_home/hub/signin/poll', { id });
152
+ export const hubSignInCancel = (id) => post('/_home/hub/signin/cancel', { id });
153
+ /**
154
+ * Open the hub's page `hubSignInStart` answered. In the app Rust opens exactly that page shape, back
155
+ * to the Home origin only (external_link.rs `open_team_server_signin`); in a plain browser it is a
156
+ * new tab. Resolves 'ok' | 'refused' | 'failed'.
157
+ */
158
+ export function openTeamServerSignIn(url) {
159
+ if (inShell())
160
+ return shellInvoke('open_team_server_signin', { url }).then(
161
+ () => 'ok',
162
+ (e) => (/Refusing/i.test(String(e)) ? 'refused' : 'failed')
163
+ );
164
+ try {
165
+ window.open(url, '_blank', 'noopener');
166
+ return Promise.resolve('ok');
167
+ } catch {
168
+ return Promise.resolve('failed');
169
+ }
170
+ }
154
171
  /** Claude readiness →`{available, claudeInstalled, reason, install:{phase,ok?,reason?}, signinInFlight}`. */
155
172
  export const aiStatus = () => homeFetch('/_home/ai/status');
156
173
  /** step: 'install' | 'signin' | 'cancel'. */