@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,203 @@
1
+ // client/v2/shell/project-account-card.jsx — 2.0.5 W4: THIS project's account, opened from the avatar
2
+ // (your own face in the Share cluster) and from the account chip.
3
+ //
4
+ // PRESENTATIONAL. The words and the paths come from project-account-model.js; the host
5
+ // (share-cluster-host.jsx) runs them. Every button runs a registry action through `run(id)` or the
6
+ // kind's existing sign-out path through `onSignOut(path)` — and a row is drawn only where its path
7
+ // exists (a browser tab gets the facts and no button). Sign out asks first (CONTRACT §4).
8
+
9
+ import { useEffect, useRef, useState } from 'react';
10
+ import { onCanvasPointer } from './canvas-pointer.js';
11
+
12
+ /**
13
+ * The popover the card sits in, under the Share cluster's start. Esc, a press outside and a press in the
14
+ * canvas close it; a press on an opener (`data-account-opener` — your face, the account chip) is the
15
+ * opener's own toggle, so it is not an outside press.
16
+ */
17
+ export function ProjectAccountPopover({ open, onClose, children }) {
18
+ const wrap = useRef(null);
19
+ useEffect(() => {
20
+ if (!open) return undefined;
21
+ const onDown = (e) => {
22
+ const t = e.target;
23
+ if (wrap.current?.contains(t)) return;
24
+ if (t?.closest?.('[data-account-opener]')) return;
25
+ onClose();
26
+ };
27
+ const onKey = (e) => {
28
+ if (e.key === 'Escape') onClose();
29
+ };
30
+ document.addEventListener('pointerdown', onDown, true);
31
+ document.addEventListener('keydown', onKey);
32
+ const off = onCanvasPointer(() => onClose());
33
+ return () => {
34
+ document.removeEventListener('pointerdown', onDown, true);
35
+ document.removeEventListener('keydown', onKey);
36
+ off();
37
+ };
38
+ }, [open, onClose]);
39
+ if (!open) return null;
40
+ return (
41
+ <div className="sh-acct-card sh-pa-pop" role="dialog" aria-label="Account" ref={wrap}>
42
+ {children}
43
+ </div>
44
+ );
45
+ }
46
+
47
+ function Line({ k, testid, children }) {
48
+ if (!children) return null;
49
+ return (
50
+ <div className="sh-pa-line">
51
+ <span className="sh-pa-k">{k}</span>
52
+ <span className="sh-pa-v" data-testid={testid}>
53
+ {children}
54
+ </span>
55
+ </div>
56
+ );
57
+ }
58
+
59
+ /**
60
+ * @param account projectAccount()
61
+ * @param run (id) => void — the shell's runner (account.switch, account.github-signin)
62
+ * @param onSignOut (path) => Promise — 'cloud-signout' | 'hub-detach' | 'github-signout'
63
+ * @param onSwitch (spec) => void — a Switch with a `path` (W4b 'hub-switch'), not a registry id
64
+ * @param onClose () => void
65
+ */
66
+ export function ProjectAccountCard({ account, run, onSignOut, onSwitch, onClose }) {
67
+ const [asking, setAsking] = useState(null); // the signOut spec being confirmed
68
+ const [busy, setBusy] = useState(false);
69
+ if (!account) return null;
70
+ const gh = account.github;
71
+ const ghOut = gh?.canSignOut
72
+ ? {
73
+ path: 'github-signout',
74
+ label: `Sign out of GitHub (@${gh.login})…`,
75
+ confirm: {
76
+ title: `Sign out of @${gh.login}?`,
77
+ body: 'Every project on it is signed out of GitHub. Your work stays on this Mac.',
78
+ primary: 'Sign out',
79
+ cancel: 'Cancel',
80
+ },
81
+ }
82
+ : null;
83
+
84
+ const confirm = async () => {
85
+ const spec = asking;
86
+ setBusy(true);
87
+ try {
88
+ await onSignOut?.(spec.path);
89
+ } finally {
90
+ setBusy(false);
91
+ setAsking(null);
92
+ onClose?.();
93
+ }
94
+ };
95
+ const go = (id) => {
96
+ onClose?.();
97
+ run?.(id);
98
+ };
99
+
100
+ return (
101
+ <div className="sh-pa" data-testid="project-account">
102
+ <p className="sh-pa-h">This project’s account</p>
103
+ <Line k="Signed in with" testid="project-account-kind">
104
+ {account.kindLabel}
105
+ </Line>
106
+ <Line k="Account" testid="project-account-who">
107
+ {account.who}
108
+ </Line>
109
+ <Line k={account.kind === 'team' ? 'Server' : 'Project'} testid="project-account-where">
110
+ {account.where}
111
+ </Line>
112
+ <Line k="Profile on this Mac" testid="project-account-profile">
113
+ {account.profileLabel}
114
+ </Line>
115
+ {gh?.login && account.kind !== 'github' ? (
116
+ <Line k="GitHub" testid="project-account-github">
117
+ @{gh.login}
118
+ </Line>
119
+ ) : null}
120
+ {gh?.note ? (
121
+ <p className="sh-pa-note" data-testid="project-account-github-note">
122
+ {gh.note}
123
+ </p>
124
+ ) : null}
125
+
126
+ {asking ? (
127
+ <div className="sh-acct-ask" role="alertdialog" data-testid="project-account-confirm">
128
+ <strong>{asking.confirm.title}</strong>
129
+ <span>{asking.confirm.body}</span>
130
+ <span className="sh-acct-btns">
131
+ <button
132
+ type="button"
133
+ className="btn btn--sm"
134
+ data-testid="project-account-signout-cancel"
135
+ onClick={() => setAsking(null)}
136
+ >
137
+ {asking.confirm.cancel}
138
+ </button>
139
+ <button
140
+ type="button"
141
+ className="btn btn--sm btn--danger"
142
+ data-testid="project-account-signout-confirm"
143
+ disabled={busy}
144
+ onClick={confirm}
145
+ >
146
+ {asking.confirm.primary}
147
+ </button>
148
+ </span>
149
+ </div>
150
+ ) : (
151
+ <>
152
+ {account.switch || gh?.canSignIn || account.signOut || ghOut ? (
153
+ <hr className="sh-acct-sep" />
154
+ ) : null}
155
+ {account.switch ? (
156
+ <button
157
+ type="button"
158
+ className="sh-acct-act"
159
+ data-testid="project-account-switch"
160
+ onClick={() => {
161
+ if (!account.switch.path) return go(account.switch.id);
162
+ onClose?.();
163
+ onSwitch?.(account.switch);
164
+ }}
165
+ >
166
+ {account.switch.label}
167
+ </button>
168
+ ) : null}
169
+ {gh?.canSignIn ? (
170
+ <button
171
+ type="button"
172
+ className="sh-acct-act"
173
+ data-testid="project-account-github-signin"
174
+ onClick={() => go('account.github-signin')}
175
+ >
176
+ Sign in with GitHub…
177
+ </button>
178
+ ) : null}
179
+ {account.signOut ? (
180
+ <button
181
+ type="button"
182
+ className="sh-acct-act"
183
+ data-testid="project-account-signout"
184
+ onClick={() => setAsking(account.signOut)}
185
+ >
186
+ {account.signOut.label}
187
+ </button>
188
+ ) : null}
189
+ {ghOut ? (
190
+ <button
191
+ type="button"
192
+ className="sh-acct-act"
193
+ data-testid="project-account-github-signout"
194
+ onClick={() => setAsking(ghOut)}
195
+ >
196
+ {ghOut.label}
197
+ </button>
198
+ ) : null}
199
+ </>
200
+ )}
201
+ </div>
202
+ );
203
+ }
@@ -0,0 +1,182 @@
1
+ // client/v2/shell/project-account-model.js — 2.0.5 W4: which account THIS project uses, and how.
2
+ //
3
+ // PURE: what the avatar's card says and which existing path each of its buttons runs. Michal's rule
4
+ // after 2.0.4 — every button does something, nothing fails — so a row exists only where its path does:
5
+ //
6
+ // kind team server · Maude Cloud · GitHub · nothing (this Mac only)
7
+ // profile `/_config.profile` — the account slot this project is bound to (V2-3.1; the server
8
+ // learns it from env only, MAUDE_PROFILE_ID / _LABEL)
9
+ // where the team server's host, or the cloud project's name
10
+ // who the signed-in login / e-mail, only where the page already holds it (the hub's recorded
11
+ // account from `/_api/connections/hub`, the cloud e-mail from `/_api/cloud/status`, the
12
+ // GitHub login from `/_api/github/identity`, a cloud tab's `cfg.cloud.user.email`)
13
+ //
14
+ // Sign out, per kind — each the path its Settings › Connections row already runs, never a new one:
15
+ // cloud-signout POST /_api/cloud/signout — clears this project's PROFILE cloud credential (V2-3.8)
16
+ // hub-detach POST /_api/cloud/detach — Settings' team-server "Sign out": the link + its sign-in
17
+ // github-signout the shell's `github_sign_out` — the calling project's profile keychain slot
18
+ // Switch, per kind — through the bind-on-sign-in rule (decision v2-3.8-bind-on-sign-in):
19
+ // cloud `account.switch` → `cloud_sign_in_prepare` (a fresh profile bound to this project)
20
+ // github `account.github-signin` → `github_sign_in` (settle_sign_in rebinds on another login)
21
+ // team server W4b: `hub-switch` → `team_sign_in_prepare` (this project moves to a fresh profile
22
+ // of its own when its profile is shared — the shell restarts it, the page reloads,
23
+ // the person signs in there) → `/_api/hub-signin/start` + the server's own page.
24
+ // A browser tab on this Mac has no shell: it says what is known and offers no button. A cloud tab's
25
+ // account is the hub's browser session: `account.switch` ends it (the v1 menubar's Sign out).
26
+
27
+ import { ACTIONS_BY_ID } from '../../../actions/index.ts';
28
+ import { isCloudHub } from '../settings/connections-model.js';
29
+
30
+ // host, plus the port when it is not the scheme's default (URL.host drops 443/80) — as the Home card says it
31
+ const hostOf = (url) => {
32
+ try {
33
+ return new URL(String(url)).host.toLowerCase();
34
+ } catch {
35
+ return '';
36
+ }
37
+ };
38
+ const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
39
+ const labelOf = (id) => ACTIONS_BY_ID.get(id)?.label ?? '';
40
+
41
+ export const KIND_LABELS = Object.freeze({
42
+ team: 'Team server',
43
+ cloud: 'Maude Cloud',
44
+ github: 'GitHub',
45
+ local: 'This Mac only',
46
+ });
47
+
48
+ export const GITHUB_NEEDS_APP = 'Signing in with GitHub needs the Maude desktop app.';
49
+
50
+ /**
51
+ * @param in.native the desktop app (a Tauri shell)
52
+ * @param in.cloudTab `cfg.cloud` of a cloud tab, else null
53
+ * @param in.profile `/_config.profile` { id, label? }
54
+ * @param in.project this project's name
55
+ * @param in.linkedHub { url, credentialed } from `/_api/cloud/status`
56
+ * @param in.hubAccount the hub sign-in's recorded account (`/_api/connections/hub` `account`)
57
+ * @param in.cloudUrl the Maude Cloud address this Mac signs in against
58
+ * @param in.cloudConnected this profile holds a Maude Cloud sign-in
59
+ * @param in.cloudEmail its e-mail
60
+ * @param in.github { state: 'loading'|'in'|'out', login }
61
+ */
62
+ export function projectAccount(input = {}) {
63
+ const {
64
+ native = false,
65
+ cloudTab = null,
66
+ profile = null,
67
+ project = null,
68
+ linkedHub = null,
69
+ hubAccount = null,
70
+ cloudUrl = '',
71
+ cloudConnected = false,
72
+ cloudEmail = null,
73
+ github = null,
74
+ } = input;
75
+ const profileLabel = str(profile?.label) || str(profile?.id) || (native ? 'default' : null);
76
+
77
+ if (cloudTab) {
78
+ // A browser on a cell: a hub with a dashboard is Maude Cloud, one that serves a single project is a
79
+ // team's own server. No Mac, no keychain, no GitHub.
80
+ const email = str(cloudTab.user?.email);
81
+ return {
82
+ kind: cloudTab.dashboardUrl ? 'cloud' : 'team',
83
+ kindLabel: KIND_LABELS[cloudTab.dashboardUrl ? 'cloud' : 'team'],
84
+ profileLabel: null,
85
+ where: str(cloudTab.projectName) || str(project),
86
+ who: email,
87
+ signOut: null,
88
+ // the registry hides account.switch in a cloud tab without a user (app.jsx); so does the card
89
+ switch: email ? { id: 'account.switch', label: labelOf('account.switch') } : null,
90
+ github: null,
91
+ };
92
+ }
93
+
94
+ const hubUrl = str(linkedHub?.url);
95
+ const cloudHub = hubUrl ? isCloudHub(hubUrl, cloudUrl) : false;
96
+ const ghIn = github?.state === 'in';
97
+ const ghLogin = ghIn ? str(github?.login) : null;
98
+ let kind = 'local';
99
+ if (hubUrl && !cloudHub) kind = 'team';
100
+ else if (cloudConnected || (hubUrl && cloudHub)) kind = 'cloud';
101
+ else if (ghIn) kind = 'github';
102
+
103
+ const who =
104
+ kind === 'team'
105
+ ? str(hubAccount)
106
+ : kind === 'cloud'
107
+ ? str(cloudEmail)
108
+ : kind === 'github' && ghLogin
109
+ ? `@${ghLogin}`
110
+ : null;
111
+ const where = kind === 'team' ? hostOf(hubUrl) || hubUrl : kind === 'cloud' ? str(project) : null;
112
+
113
+ let signOut = null;
114
+ let sw = null;
115
+ if (native) {
116
+ if (kind === 'cloud' && cloudConnected) {
117
+ const name = who || profileLabel;
118
+ // The account card's words (account-card-model.js), unchanged: one confirm on every surface.
119
+ signOut = {
120
+ path: 'cloud-signout',
121
+ label: `Sign out of ${name}…`,
122
+ confirm: {
123
+ title: `Sign out of ${name}?`,
124
+ body: 'Every project on it is signed out. Your work stays on this Mac.',
125
+ primary: 'Sign out',
126
+ cancel: 'Cancel',
127
+ },
128
+ };
129
+ sw = { id: 'account.switch', label: labelOf('account.switch') };
130
+ } else if (kind === 'team') {
131
+ const host = where || 'this server';
132
+ // 2.0.5 W4b — Switch through `team_sign_in_prepare`: a project on a profile other projects
133
+ // share first moves to its own (the shell restarts it); then the team server's own page.
134
+ sw = {
135
+ path: 'hub-switch',
136
+ url: hubUrl,
137
+ label: linkedHub?.credentialed ? 'Sign in as someone else…' : `Sign in to ${host}…`,
138
+ };
139
+ if (linkedHub?.credentialed)
140
+ signOut = {
141
+ path: 'hub-detach',
142
+ label: `Sign out of ${host}…`,
143
+ confirm: {
144
+ title: `Sign out of ${host}?`,
145
+ body: 'This folder stops syncing with it. Your work stays on this Mac.',
146
+ primary: 'Sign out',
147
+ cancel: 'Cancel',
148
+ },
149
+ };
150
+ } else if (kind === 'github' && ghLogin) {
151
+ signOut = {
152
+ path: 'github-signout',
153
+ label: `Sign out of @${ghLogin}…`,
154
+ confirm: {
155
+ title: `Sign out of @${ghLogin}?`,
156
+ body: 'Every project on it is signed out of GitHub. Your work stays on this Mac.',
157
+ primary: 'Sign out',
158
+ cancel: 'Cancel',
159
+ },
160
+ };
161
+ sw = { id: 'account.github-signin', label: 'Sign in as another GitHub account…' };
162
+ }
163
+ }
164
+
165
+ return {
166
+ kind,
167
+ kindLabel: KIND_LABELS[kind],
168
+ profileLabel,
169
+ where,
170
+ who,
171
+ signOut,
172
+ switch: sw,
173
+ // The GitHub line: sign in where the app can, sign out where it is the second account of the card.
174
+ github: native
175
+ ? {
176
+ login: ghLogin,
177
+ canSignIn: !ghIn && github?.state !== 'loading',
178
+ canSignOut: ghIn && kind !== 'github',
179
+ }
180
+ : { login: null, canSignIn: false, canSignOut: false, note: GITHUB_NEEDS_APP },
181
+ };
182
+ }
@@ -53,13 +53,66 @@ import { normalizeOpenPath } from '../../share-link.js';
53
53
  import { useAccount } from './use-account.js';
54
54
  import { useCanvasModeLane } from './use-canvas-mode-lane.js';
55
55
  import { usePanelLayout } from './use-panel-layout.js';
56
- import { isNativeApp } from '../../github.js';
56
+ import { invoke as shellInvoke, isNativeApp, openTeamServerSignIn } from '../../github.js';
57
57
  import {
58
58
  chosenDisplay,
59
59
  presenterAvailable,
60
60
  usePresenterDisplays,
61
61
  } from '../present/presenter-store.js';
62
62
  import { servedFetch } from './served-routes.js';
63
+ import { CLOUD_CHANGED_EVENT } from '../../panels/CloudBar.jsx';
64
+ import { GitHubSignInSheet, useGitHubSignInHost } from './github-signin-host.jsx';
65
+ import { ProjectAccountCard, ProjectAccountPopover } from './project-account-card.jsx';
66
+ import { projectAccount } from './project-account-model.js';
67
+ import { runTeamSwitch } from './team-switch.js';
68
+
69
+ /** 2.0.5 W4 — the team server sign-in's recorded account (`GET /_api/connections/hub`, Settings' own read). */
70
+ function useHubAccount(enabled, url) {
71
+ const [account, setAccount] = useState(null);
72
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `url` re-reads when the folder's link moves
73
+ useEffect(() => {
74
+ if (!enabled) {
75
+ setAccount(null);
76
+ return undefined;
77
+ }
78
+ let live = true;
79
+ fetch('/_api/connections/hub')
80
+ .then((r) => (r.ok ? r.json() : null))
81
+ .then((j) => {
82
+ if (live) setAccount(typeof j?.hub?.account === 'string' ? j.hub.account : null);
83
+ })
84
+ .catch(() => {});
85
+ return () => {
86
+ live = false;
87
+ };
88
+ }, [enabled, url]);
89
+ return account;
90
+ }
91
+
92
+ /** Settings' team-server "Sign out": POST /_api/cloud/detach — the link and its sign-in, this profile only. */
93
+ async function detachHub(host) {
94
+ try {
95
+ const r = await fetch('/_api/cloud/detach', { method: 'POST' });
96
+ const j = await r.json().catch(() => ({}));
97
+ if (!r.ok || !j?.ok) throw new Error(j?.error || String(r.status));
98
+ window.dispatchEvent(
99
+ new CustomEvent(CLOUD_CHANGED_EVENT, { detail: { from: 'account-card' } })
100
+ );
101
+ shellToast(`Signed out of ${host || 'the team server'}. Your work stays on this Mac.`, true);
102
+ } catch {
103
+ shellToast('Could not sign out. Nothing changed — try again.');
104
+ }
105
+ }
106
+
107
+ /** `{ ok, status, json }` of a same-origin JSON call (team-switch.js's `api`). */
108
+ async function jsonFetch(path, init) {
109
+ try {
110
+ const r = await fetch(path, init);
111
+ return { ok: r.ok, status: r.status, json: await r.json().catch(() => null) };
112
+ } catch {
113
+ return { ok: false, status: 0, json: null };
114
+ }
115
+ }
63
116
 
64
117
  const subscribeOnline = (fn) => {
65
118
  window.addEventListener('online', fn);
@@ -249,7 +302,8 @@ export function ShellShareCluster() {
249
302
  // S1.22a — the account chip (desktop): which Mac account this project tab is bound to. A cloud tab's
250
303
  // account is the hub's, a browser tab has none: both get no chip.
251
304
  const native = isNativeApp();
252
- const acct = useAccount(native && !cfg?.cloud);
305
+ // 2.0.5 W4 — every non-cloud tab reads its account (a browser tab on this Mac shows the facts too)
306
+ const acct = useAccount(!cfg?.cloud);
253
307
  const projectName = cfg?.cloud?.projectName || project;
254
308
  const chip = useMemo(
255
309
  () =>
@@ -275,6 +329,61 @@ export function ShellShareCluster() {
275
329
  : null,
276
330
  [chip, projectName, cfg?.profile, acct.email, acct.accounts]
277
331
  );
332
+ // 2.0.5 W4 — the avatar (your face, or the chip) opens THIS project's account: kind, profile, hub or
333
+ // cloud project, the login; Sign out on the kind's existing path, Switch through bind-on-sign-in.
334
+ const gh = useGitHubSignInHost();
335
+ const [acctOpen, setAcctOpen] = useState(false);
336
+ const closeAcct = useCallback(() => setAcctOpen(false), []);
337
+ // the account's own read once it answered (it follows a sign-out), the shell's link until then
338
+ const linkHub = acct.linkedHub !== undefined ? acct.linkedHub : (cloudLinkedHub ?? null);
339
+ const hubAccount = useHubAccount(!cfg?.cloud && !!linkHub?.credentialed, linkHub?.url);
340
+ const projectAcct = useMemo(
341
+ () =>
342
+ projectAccount({
343
+ native,
344
+ cloudTab: cfg?.cloud ?? null,
345
+ profile: cfg?.profile,
346
+ project: projectName,
347
+ linkedHub: linkHub,
348
+ hubAccount,
349
+ cloudUrl: acct.cloudUrl,
350
+ cloudConnected: acct.connected,
351
+ cloudEmail: acct.email,
352
+ github: { state: gh.state, login: gh.login },
353
+ }),
354
+ [native, cfg?.cloud, cfg?.profile, projectName, linkHub, hubAccount, acct, gh.state, gh.login]
355
+ );
356
+ const signOutPath = useCallback(
357
+ async (path) => {
358
+ if (path === 'cloud-signout') return acct.signOut();
359
+ if (path === 'github-signout') return gh.signOut();
360
+ if (path === 'hub-detach') return detachHub(projectAcct.where);
361
+ },
362
+ [acct, gh, projectAcct.where]
363
+ );
364
+ // 2.0.5 W4b — Switch / Sign in for a team server: `team_sign_in_prepare` first (bind-on-sign-in for
365
+ // a hub), then the server's own page. Words come back as one toast.
366
+ const switchPath = useCallback(
367
+ async (spec) => {
368
+ if (spec?.path !== 'hub-switch') return;
369
+ const r = await runTeamSwitch({
370
+ url: spec.url,
371
+ native,
372
+ invoke: shellInvoke,
373
+ api: jsonFetch,
374
+ openPage: openTeamServerSignIn,
375
+ wait: (ms) => new Promise((res) => setTimeout(res, ms)),
376
+ });
377
+ if (r.cancelled) return;
378
+ if (r.message) shellToast(r.message, true);
379
+ else if (r.error) shellToast(r.error);
380
+ if (r.ok && !r.moved)
381
+ window.dispatchEvent(
382
+ new CustomEvent(CLOUD_CHANGED_EVENT, { detail: { from: 'account-card' } })
383
+ );
384
+ },
385
+ [native]
386
+ );
278
387
  // S9.23 — the faces' menu and people list: where people are, Follow / Go to / Bring everyone here.
279
388
  const presence = usePresenceHost({
280
389
  lane,
@@ -310,15 +419,32 @@ export function ShellShareCluster() {
310
419
  <ShareCluster
311
420
  cloud={!!cfg?.cloud}
312
421
  accountSlot={
313
- chip ? (
314
- <AccountChip
315
- chip={chip}
316
- card={card}
317
- onSwitch={() => menuRunner.run('account.switch')}
318
- onSignOut={acct.signOut}
319
- />
320
- ) : null
422
+ <>
423
+ <span className="sh-pa-anchor">
424
+ <ProjectAccountPopover open={acctOpen} onClose={closeAcct}>
425
+ <ProjectAccountCard
426
+ account={projectAcct}
427
+ run={(id) => menuRunner.run(id)}
428
+ onSignOut={signOutPath}
429
+ onSwitch={switchPath}
430
+ onClose={closeAcct}
431
+ />
432
+ </ProjectAccountPopover>
433
+ </span>
434
+ {chip ? (
435
+ <AccountChip
436
+ chip={chip}
437
+ card={card}
438
+ onSwitch={() => menuRunner.run('account.switch')}
439
+ onSignOut={acct.signOut}
440
+ onOpen={() => setAcctOpen((o) => !o)}
441
+ opened={acctOpen}
442
+ />
443
+ ) : null}
444
+ </>
321
445
  }
446
+ onAccount={() => setAcctOpen((o) => !o)}
447
+ accountOpen={acctOpen}
322
448
  faces={faces}
323
449
  onFollow={lane.follow}
324
450
  presence={presence}
@@ -387,6 +513,7 @@ export function ShellShareCluster() {
387
513
  run={(id) => menuRunner.run(id)}
388
514
  onOpenTab={openTrashed}
389
515
  />
516
+ <GitHubSignInSheet gh={gh} />
390
517
  </>
391
518
  );
392
519
  }
@@ -98,6 +98,21 @@
98
98
  overflow: hidden;
99
99
  text-overflow: ellipsis;
100
100
  }
101
+ /* 2.0.5 W4 — the word is a button (Diagnostics › Sync): no chrome until hover/focus */
102
+ .sh-saved--btn {
103
+ appearance: none;
104
+ border: 0;
105
+ background: transparent;
106
+ font: inherit;
107
+ font-size: var(--type-xs, 12px);
108
+ border-radius: var(--radius-md, 8px);
109
+ cursor: pointer;
110
+ }
111
+ .sh-saved--btn:hover,
112
+ .sh-saved--btn:focus-visible {
113
+ background: var(--accent-muted, var(--bg-3));
114
+ outline: none;
115
+ }
101
116
  .sh-saved--warn {
102
117
  color: var(--status-warn-text, var(--status-warn));
103
118
  }
@@ -438,6 +453,49 @@
438
453
  height: 32px;
439
454
  font-size: var(--type-sm, 13px);
440
455
  }
456
+ /* 2.0.5 W4 — this project's account (project-account-card.jsx), anchored at the cluster's start */
457
+ .sh-pa-anchor {
458
+ position: relative;
459
+ flex: none;
460
+ width: 0;
461
+ align-self: stretch;
462
+ }
463
+ .sh-pa {
464
+ display: flex;
465
+ flex-direction: column;
466
+ gap: 2px;
467
+ }
468
+ .sh-pa-h {
469
+ margin: 0;
470
+ padding: var(--space-1, 4px) var(--space-2, 8px);
471
+ font-size: var(--type-xs, 12px);
472
+ font-weight: var(--w-semibold, 600);
473
+ color: var(--fg-2);
474
+ }
475
+ .sh-pa-line {
476
+ display: flex;
477
+ justify-content: space-between;
478
+ gap: var(--space-3, 12px);
479
+ padding: 2px var(--space-2, 8px);
480
+ font-size: var(--type-xs, 12px);
481
+ }
482
+ .sh-pa-k {
483
+ color: var(--fg-2);
484
+ flex: none;
485
+ }
486
+ .sh-pa-v {
487
+ color: var(--fg-0);
488
+ min-width: 0;
489
+ overflow: hidden;
490
+ text-overflow: ellipsis;
491
+ white-space: nowrap;
492
+ }
493
+ .sh-pa-note {
494
+ margin: 0;
495
+ padding: 2px var(--space-2, 8px);
496
+ font-size: var(--type-xs, 12px);
497
+ color: var(--fg-2);
498
+ }
441
499
  .sh-acct-card {
442
500
  position: absolute;
443
501
  top: calc(100% + var(--space-2, 8px));