@1agh/maude 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/apps/studio/access/request.ts +1 -0
  2. package/apps/studio/actions/agents.ts +45 -42
  3. package/apps/studio/actions/defs/app.ts +28 -1
  4. package/apps/studio/actions/defs/sync.ts +4 -0
  5. package/apps/studio/actions/verbs.ts +49 -0
  6. package/apps/studio/actions.manifest.json +162 -20
  7. package/apps/studio/actions.parity.json +13 -1
  8. package/apps/studio/ai/create-claim.ts +1 -1
  9. package/apps/studio/bin/_asset-file.mjs +117 -0
  10. package/apps/studio/bin/_canvas-file.mjs +146 -0
  11. package/apps/studio/bin/_curl-local.mjs +7 -4
  12. package/apps/studio/bin/_footage.mjs +123 -0
  13. package/apps/studio/bin/_pdf-playwright.mjs +14 -0
  14. package/apps/studio/bin/_png-playwright.mjs +15 -1
  15. package/apps/studio/bin/_pw-launch.mjs +98 -0
  16. package/apps/studio/bin/_retry-save.mjs +49 -0
  17. package/apps/studio/bin/_sync.mjs +145 -2
  18. package/apps/studio/bin/asset-rename.sh +12 -0
  19. package/apps/studio/bin/asset-trash.sh +12 -0
  20. package/apps/studio/bin/canvas-move.sh +12 -0
  21. package/apps/studio/bin/canvas-new.sh +12 -0
  22. package/apps/studio/bin/footage.sh +12 -0
  23. package/apps/studio/bin/generate.sh +7 -0
  24. package/apps/studio/bin/retry-save.sh +13 -0
  25. package/apps/studio/bridge/canvas-mode-store.ts +11 -2
  26. package/apps/studio/bridge/dgn-protocol.ts +8 -3
  27. package/apps/studio/bridge/occlusion.ts +45 -0
  28. package/apps/studio/canvas-theme-pill.tsx +169 -26
  29. package/apps/studio/client/app.jsx +16 -4
  30. package/apps/studio/client/export-center.jsx +32 -3
  31. package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
  32. package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
  33. package/apps/studio/client/home/HomeConnection.jsx +112 -0
  34. package/apps/studio/client/home/ProjectRows.jsx +514 -0
  35. package/apps/studio/client/home/home-accounts-model.js +234 -76
  36. package/apps/studio/client/home/home-api.js +10 -2
  37. package/apps/studio/client/home/home-app.jsx +151 -394
  38. package/apps/studio/client/home/home-icons.jsx +8 -0
  39. package/apps/studio/client/home/home-model.js +149 -1
  40. package/apps/studio/client/home/home-where-model.js +105 -0
  41. package/apps/studio/client/home/home.css +621 -53
  42. package/apps/studio/client/home/use-account-fix.js +123 -0
  43. package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
  44. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  45. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  46. package/apps/studio/client/share-link.js +12 -0
  47. package/apps/studio/client/styles/_index.css +4 -0
  48. package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
  49. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  50. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  51. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  52. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  53. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
  54. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
  55. package/apps/studio/client/v2/export/done-toast.jsx +2 -5
  56. package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
  57. package/apps/studio/client/v2/export/export.css +9 -0
  58. package/apps/studio/client/v2/export/exports-model.js +16 -3
  59. package/apps/studio/client/v2/export/file-rows.jsx +81 -5
  60. package/apps/studio/client/v2/export/native-save.js +33 -0
  61. package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
  62. package/apps/studio/client/v2/export/sections/print.jsx +37 -20
  63. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  64. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  65. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  66. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  67. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  68. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  69. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  70. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  71. package/apps/studio/client/v2/settings/account.jsx +4 -2
  72. package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
  73. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  74. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  75. package/apps/studio/client/v2/settings/general-section.jsx +138 -43
  76. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  77. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  78. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  79. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  80. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  81. package/apps/studio/client/v2/settings/settings-model.js +91 -31
  82. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  83. package/apps/studio/client/v2/settings/settings.css +374 -64
  84. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  85. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  86. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  87. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  88. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  89. package/apps/studio/client/v2/shell/menu-runner.js +7 -2
  90. package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
  91. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  92. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  93. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  94. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  95. package/apps/studio/client/v2/shell/project-account.css +237 -0
  96. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  97. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  98. package/apps/studio/client/v2/shell/shell-parity.json +40 -26
  99. package/apps/studio/client/v2/shell/use-account.js +2 -0
  100. package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
  101. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  102. package/apps/studio/cloud/endpoints.ts +29 -4
  103. package/apps/studio/collab/room.ts +21 -7
  104. package/apps/studio/dist/client.bundle.js +886 -886
  105. package/apps/studio/dist/comment-mount.js +2 -2
  106. package/apps/studio/dist/styles.css +1 -1
  107. package/apps/studio/exporters/ghostscript.ts +78 -1
  108. package/apps/studio/exporters/pdf-fonts.ts +31 -4
  109. package/apps/studio/generation/jobs.ts +6 -0
  110. package/apps/studio/home/accounts.ts +30 -11
  111. package/apps/studio/home/cloud.ts +6 -1
  112. package/apps/studio/home/hub-health.ts +76 -0
  113. package/apps/studio/home/routes.ts +9 -3
  114. package/apps/studio/http.ts +14 -2
  115. package/apps/studio/migrate/hub.ts +8 -1
  116. package/apps/studio/routes/agent.ts +6 -2
  117. package/apps/studio/routes/hub-link-folder.ts +334 -0
  118. package/apps/studio/routes/hub-signin.ts +78 -1
  119. package/apps/studio/routes/index.ts +4 -0
  120. package/apps/studio/routes/project-undo.ts +10 -0
  121. package/apps/studio/routes/sync.ts +22 -4
  122. package/apps/studio/server.ts +25 -0
  123. package/apps/studio/shell/api-key.ts +11 -0
  124. package/apps/studio/shell/cli-yield.ts +48 -11
  125. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  126. package/apps/studio/sync/action-stage.ts +18 -1
  127. package/apps/studio/sync/ctl-heal.ts +58 -0
  128. package/apps/studio/sync/file-ledger.ts +38 -4
  129. package/apps/studio/sync/file-plane.ts +226 -19
  130. package/apps/studio/sync/held-deletes.ts +86 -5
  131. package/apps/studio/sync/hub-link.ts +8 -0
  132. package/apps/studio/sync/index.ts +68 -4
  133. package/apps/studio/sync/link-consent.ts +22 -75
  134. package/apps/studio/sync/link-survey.ts +252 -0
  135. package/apps/studio/sync/local-kernel.ts +16 -1
  136. package/apps/studio/sync/seed-progress.ts +12 -0
  137. package/apps/studio/sync/source-recovery.ts +18 -2
  138. package/apps/studio/sync/status.ts +11 -1
  139. package/apps/studio/sync/writer-registry.ts +5 -0
  140. package/apps/studio/whats-new.json +36 -0
  141. package/cli/commands/design.mjs +74 -16
  142. package/cli/lib/bash-guard.mjs +23 -4
  143. package/cli/lib/confine-read.mjs +2 -0
  144. package/cli/lib/design-help.gen.mjs +15 -2
  145. package/cli/lib/design-hook.mjs +1 -1
  146. package/cli/lib/desktop-locate.mjs +36 -8
  147. package/cli/lib/studio-locate.mjs +8 -2
  148. package/cli/lib/sub-verbs.mjs +13 -1
  149. package/package.json +9 -8
  150. package/apps/studio/client/home/HomeAccounts.jsx +0 -262
  151. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  152. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  153. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -0,0 +1,730 @@
1
+ // client/v2/settings/this-project-card.jsx — 2.1.1 T6: Settings › General › This project (canvas 17 · 08 · 09).
2
+ //
3
+ // General's first card, open by default: where this project lives, which account it uses, whether it
4
+ // connects — with Change… and Switch… beside them — and, when a sign-in broke, the one fix in its header
5
+ // (visible while the card is closed). A project only on this Mac offers its two ways out: Put on Maude
6
+ // Cloud… and Link your server…. The model is this-project-model.js.
7
+ //
8
+ // Sync details (the card's own fold, remembered per Mac) holds what used to be Advanced › This project
9
+ // (the sync switches and who keeps .design/, project-sync-settings.jsx) and what used to be Connections ›
10
+ // Maude Cloud and › Your team's own server: the account, the cloud projects on this Mac (Connect /
11
+ // Disconnect, D11), the server's address and masked token with Replace…, its Sign out. Same hooks, same
12
+ // routes (use-connections.js) — only the home moved: Connections is about the person, this card is
13
+ // about this project.
14
+ //
15
+ // Switch… runs `account.switch` (the avatar's account list, T4); Link your server… sends
16
+ // `account.link-server`'s event (T5's one dialog takes it; nothing taking it opens today's team-server
17
+ // form here); Sign in again for a server opens that form on the server's address, for Maude Cloud the
18
+ // device sign-in. Moving a project between your folder and a copy Maude keeps has no backend yet —
19
+ // Change… draws only what works (Show in Finder).
20
+
21
+ import { useEffect, useRef, useState } from 'react';
22
+
23
+ import { isNativeApp } from '../../github.js';
24
+ import {
25
+ CloudDeviceDialog,
26
+ isLinkedProjectRow,
27
+ openExternal,
28
+ shareViewUrl,
29
+ } from '../../panels/CloudBar.jsx';
30
+ import { TeamProjectsDialog } from '../../panels/TeamProjects.jsx';
31
+ import { StIcon } from '../../shell/icons.jsx';
32
+ import { getPaletteEnv } from '../search/search-env.js';
33
+ import { useFold } from '../fold/use-fold.js';
34
+ import { requestShareFocus } from '../share/share-model.js';
35
+ import { menuRunner } from '../shell/menu-runner.js';
36
+ import { nativeDoors } from '../shell/native-doors.js';
37
+ import { LINK_SERVER_EVENT } from '../shell/project-account-bus.js';
38
+ import { AccountBlock } from './account.jsx';
39
+ import { ConnField } from './connection-row.jsx';
40
+ import { cloudRow, maskedToken } from './connections-model.js';
41
+ import ProjectSyncSettings from './project-sync-settings.jsx';
42
+ import { CardRow, SettingsCard, StatusLine } from './settings-card.jsx';
43
+ import { PROJECT_FOLD } from './settings-model.js';
44
+ import { thisProjectModel } from './this-project-model.js';
45
+ import { useCloudConnection, useHubDetails } from './use-connections.js';
46
+
47
+ const btn = 'btn btn--sm';
48
+
49
+ function useOnline() {
50
+ const [on, setOn] = useState(() =>
51
+ typeof navigator === 'undefined' ? true : navigator.onLine !== false
52
+ );
53
+ useEffect(() => {
54
+ const up = () => setOn(true);
55
+ const down = () => setOn(false);
56
+ window.addEventListener('online', up);
57
+ window.addEventListener('offline', down);
58
+ return () => {
59
+ window.removeEventListener('online', up);
60
+ window.removeEventListener('offline', down);
61
+ };
62
+ }, []);
63
+ return on;
64
+ }
65
+
66
+ /** The project's square: its first letter (canvas 17 `Sq`). */
67
+ function ProjectSquare({ name }) {
68
+ const ch =
69
+ String(name || '?')
70
+ .trim()
71
+ .charAt(0)
72
+ .toUpperCase() || '?';
73
+ return <span className="v2s-sq">{ch}</span>;
74
+ }
75
+
76
+ /** The account's face: an initial, or a laptop for no account (canvas 17 `Face`). */
77
+ function Face({ account }) {
78
+ if (account.kind === 'local')
79
+ return (
80
+ <span className="v2s-face v2s-face--mac" aria-hidden="true">
81
+ <StIcon name="laptop" size={12} />
82
+ </span>
83
+ );
84
+ const ch = String(account.label || '?')
85
+ .charAt(0)
86
+ .toUpperCase();
87
+ return (
88
+ <span className="v2s-face" aria-hidden="true">
89
+ {ch}
90
+ </span>
91
+ );
92
+ }
93
+
94
+ /** Lives in: the place chip (canvas 17 `PlaceChip`). */
95
+ function PlaceChip({ place }) {
96
+ const icon = place.kind === 'folder' ? 'folder' : place.kind === 'server' ? 'box' : 'cloud';
97
+ return (
98
+ <span className="v2s-place" data-testid="settings-project-place" data-place={place.kind}>
99
+ <StIcon name={icon} size={12} />
100
+ <span>{place.label}</span>
101
+ {place.path ? <span className="v2s-place-path">{place.path}</span> : null}
102
+ </span>
103
+ );
104
+ }
105
+
106
+ /** Change… — where the project lives, and what this Mac can do about it today. */
107
+ function ChangeMenu({ m, onShowInFinder }) {
108
+ const [open, setOpen] = useState(false);
109
+ const btnRef = useRef(null);
110
+ const menuRef = useRef(null);
111
+ useEffect(() => {
112
+ if (!open) return undefined;
113
+ menuRef.current?.querySelector('[role^="menuitem"]:not([aria-disabled="true"])')?.focus();
114
+ const away = (e) => {
115
+ if (!menuRef.current?.contains(e.target) && !btnRef.current?.contains(e.target))
116
+ setOpen(false);
117
+ };
118
+ document.addEventListener('mousedown', away);
119
+ return () => document.removeEventListener('mousedown', away);
120
+ }, [open]);
121
+ const close = () => {
122
+ setOpen(false);
123
+ btnRef.current?.focus();
124
+ };
125
+ const shown = m.changeOptions.filter((o) => o.available);
126
+ const places = shown.filter((o) => o.id !== 'finder');
127
+ const finder = shown.find((o) => o.id === 'finder');
128
+ return (
129
+ <span className="v2s-menu-host">
130
+ <button
131
+ ref={btnRef}
132
+ type="button"
133
+ className={btn}
134
+ aria-haspopup="menu"
135
+ aria-expanded={open}
136
+ onClick={() => setOpen((v) => !v)}
137
+ data-testid="settings-project-change"
138
+ >
139
+ Change…
140
+ </button>
141
+ {open ? (
142
+ <div
143
+ ref={menuRef}
144
+ className="v2s-menu"
145
+ role="menu"
146
+ aria-label={`Where ${m.name} lives`}
147
+ data-testid="settings-project-change-menu"
148
+ onKeyDown={(e) => {
149
+ if (e.key === 'Escape') {
150
+ e.preventDefault();
151
+ e.stopPropagation();
152
+ close();
153
+ }
154
+ }}
155
+ >
156
+ <p className="v2s-menu-h">Where {m.name} lives</p>
157
+ {places.map((o) => (
158
+ <div
159
+ key={o.id}
160
+ // the place it lives now — information, not a choice (moving between places has no
161
+ // backend yet), so it is not a menu item a person could try to pick
162
+ role="presentation"
163
+ aria-current={o.current ? 'true' : undefined}
164
+ className="v2s-menu-i"
165
+ data-testid={`settings-project-place-${o.id}`}
166
+ >
167
+ <span className="v2s-menu-ck">
168
+ {o.current ? <StIcon name="check" size={12} /> : null}
169
+ </span>
170
+ <span>{o.label}</span>
171
+ {o.detail ? <span className="v2s-menu-d">{o.detail}</span> : null}
172
+ </div>
173
+ ))}
174
+ {finder ? (
175
+ <>
176
+ <span className="v2s-menu-sep" />
177
+ <button
178
+ type="button"
179
+ role="menuitem"
180
+ className="v2s-menu-i"
181
+ onClick={() => {
182
+ close();
183
+ onShowInFinder();
184
+ }}
185
+ data-testid="settings-project-finder"
186
+ >
187
+ <span className="v2s-menu-ck">
188
+ <StIcon name="folder" size={12} />
189
+ </span>
190
+ <span>Show in Finder</span>
191
+ </button>
192
+ </>
193
+ ) : null}
194
+ </div>
195
+ ) : null}
196
+ </span>
197
+ );
198
+ }
199
+
200
+ function CloudProjects({ c }) {
201
+ const { projects, local, cloudUrl, busy } = c;
202
+ if (projects === null)
203
+ return (
204
+ <div className="v2s-conn-li" aria-disabled="true">
205
+ Loading projects…
206
+ </div>
207
+ );
208
+ if (projects.length === 0)
209
+ return (
210
+ <div className="v2s-conn-li" aria-disabled="true">
211
+ No projects yet — start one on the dashboard.
212
+ </div>
213
+ );
214
+ return projects.map((p) => {
215
+ const name = p.name || p.id;
216
+ // Viewer dignity (Phase 17 T4): no dead Connect that would 403 at the workspace — viewing has a
217
+ // first-class home in the browser, and the label says why.
218
+ if (p.role === 'viewer')
219
+ return (
220
+ <div className="v2s-conn-li" key={p.id}>
221
+ <button
222
+ type="button"
223
+ className="btn btn--ghost btn--sm"
224
+ onClick={() => openExternal(shareViewUrl(p.url, p.id))}
225
+ title="Viewing works in the browser. Editing in the app needs the member role — ask whoever runs the project."
226
+ data-testid={`cloud-project-${p.id}`}
227
+ >
228
+ {`View ${name} in the browser`}
229
+ </button>
230
+ </div>
231
+ );
232
+ const linked = isLinkedProjectRow({
233
+ projectUrl: p.url,
234
+ linkedHubUrl: local.linkedHub?.url,
235
+ linkedHubCredentialed: local.linkedHub?.credentialed,
236
+ cloudUrl,
237
+ });
238
+ return linked ? (
239
+ <div className="v2s-conn-li is-connected" key={p.id} data-testid={`cloud-project-${p.id}`}>
240
+ <span>{name}</span>
241
+ <span className="v2s-conn-s v2s-conn-s--ok">Connected</span>
242
+ <button
243
+ type="button"
244
+ className="btn btn--ghost btn--sm"
245
+ disabled={busy === 'disconnect'}
246
+ onClick={c.disconnect}
247
+ aria-label={`Disconnect this folder from ${name}`}
248
+ data-testid={`cloud-disconnect-${p.id}`}
249
+ >
250
+ {busy === 'disconnect' ? 'Disconnecting…' : 'Disconnect'}
251
+ </button>
252
+ </div>
253
+ ) : (
254
+ <div className="v2s-conn-li" key={p.id}>
255
+ <span>{name}</span>
256
+ <button
257
+ type="button"
258
+ className="btn btn--ghost btn--sm"
259
+ disabled={busy === p.id}
260
+ onClick={() => c.connect(p.id)}
261
+ title={`Connect this folder to ${name}`}
262
+ data-testid={`cloud-project-${p.id}`}
263
+ >
264
+ {busy === p.id ? 'Connecting…' : `Connect ${name}`}
265
+ </button>
266
+ </div>
267
+ );
268
+ });
269
+ }
270
+
271
+ /** Replace… — a password field, sent once through `POST /_api/hub/link`, then cleared. */
272
+ function ReplaceToken({ hub }) {
273
+ const [open, setOpen] = useState(false);
274
+ const [value, setValue] = useState('');
275
+ if (!open)
276
+ return (
277
+ <button
278
+ type="button"
279
+ className="btn btn--ghost btn--sm"
280
+ onClick={() => setOpen(true)}
281
+ data-testid="settings-hub-token-replace"
282
+ >
283
+ Replace…
284
+ </button>
285
+ );
286
+ const done = async () => {
287
+ const ok = await hub.replace(value);
288
+ setValue('');
289
+ if (ok) setOpen(false);
290
+ };
291
+ return (
292
+ <span className="v2s-conn-replace">
293
+ <input
294
+ className="input"
295
+ type="password"
296
+ autoComplete="off"
297
+ spellCheck={false}
298
+ value={value}
299
+ placeholder="Paste the new token"
300
+ aria-label="New access token"
301
+ onChange={(e) => setValue(e.target.value)}
302
+ onKeyDown={(e) => {
303
+ if (e.key === 'Enter') done();
304
+ if (e.key === 'Escape') {
305
+ e.preventDefault();
306
+ setValue('');
307
+ setOpen(false);
308
+ }
309
+ }}
310
+ data-testid="settings-hub-token-input"
311
+ />
312
+ <button
313
+ type="button"
314
+ className={btn}
315
+ disabled={hub.busy || !value.trim()}
316
+ onClick={done}
317
+ data-testid="settings-hub-token-save"
318
+ >
319
+ {hub.busy ? 'Saving…' : 'Replace'}
320
+ </button>
321
+ <button
322
+ type="button"
323
+ className="btn btn--ghost btn--sm"
324
+ onClick={() => {
325
+ setValue('');
326
+ setOpen(false);
327
+ }}
328
+ >
329
+ Cancel
330
+ </button>
331
+ </span>
332
+ );
333
+ }
334
+
335
+ /** The linked server's address + masked token — never more than its last four characters. */
336
+ function HubFields({ url, hub, replace, credentialed }) {
337
+ const d = hub.details;
338
+ // Until the details answer, the link's own corroboration says whether a token is stored at all.
339
+ const stored = d ? d.credentialed : !!credentialed;
340
+ return (
341
+ <div data-testid="settings-hub-address">
342
+ <ConnField k="Address" mono copy={url}>
343
+ {url}
344
+ </ConnField>
345
+ <ConnField k="Access token" mono testid="settings-hub-token">
346
+ <span className="v2s-conn-inline">
347
+ {stored ? maskedToken(d?.tokenLast4) : 'None saved for this folder'}
348
+ {replace && stored ? <ReplaceToken hub={hub} /> : null}
349
+ </span>
350
+ </ConnField>
351
+ {typeof d?.account === 'string' && d.account ? (
352
+ <ConnField k="Signed in as" mono testid="settings-hub-account">
353
+ {d.account}
354
+ </ConnField>
355
+ ) : null}
356
+ {d?.version ? (
357
+ <ConnField k="Hub version" mono testid="settings-hub-version">
358
+ {d.version}
359
+ </ConnField>
360
+ ) : null}
361
+ {hub.error ? (
362
+ <p className="v2s-conn-err" role="alert">
363
+ {hub.error}
364
+ </p>
365
+ ) : null}
366
+ </div>
367
+ );
368
+ }
369
+
370
+ /** Run a registry action through the one runner, when the shell can; false when it cannot. */
371
+ function runAction(id, params) {
372
+ if (!menuRunner.canRun(id)) return false;
373
+ return menuRunner.run(id, params);
374
+ }
375
+
376
+ export default function ThisProjectCard({
377
+ open,
378
+ onToggle,
379
+ focus,
380
+ syncStatus,
381
+ onLinkedHub,
382
+ onLocalProject,
383
+ onCloseSheet,
384
+ }) {
385
+ const cloud = useCloudConnection({ onLinkedHub, onLocalProject, syncStatus });
386
+ const online = useOnline();
387
+ // 2.1.1 T8 — an address this Mac never confirmed is the repo's text: no details are asked about it
388
+ const linkedUrl =
389
+ cloud.local.linkedHub?.confirmed === false ? null : (cloud.local.linkedHub?.url ?? null);
390
+ const hub = useHubDetails(linkedUrl);
391
+ const [, setFold] = useFold(PROJECT_FOLD);
392
+ const [teamOpen, setTeamOpen] = useState(false);
393
+ const [signInAt, setSignInAt] = useState(null);
394
+ const native = isNativeApp();
395
+
396
+ // ⌘K found a row of this card: nearly all of them sit under Sync details, so the fold opens too (it
397
+ // stays open, like any fold opened by hand).
398
+ const focusN = focus?.n ?? 0;
399
+ // biome-ignore lint/correctness/useExhaustiveDependencies: a new ask (`n`) opens it again
400
+ useEffect(() => {
401
+ if (focus?.card === 'this-project') setFold(true);
402
+ }, [focusN]);
403
+
404
+ const m = thisProjectModel({
405
+ status: {
406
+ connected: cloud.state === 'in',
407
+ email: cloud.email,
408
+ url: cloud.cloudUrl,
409
+ project: cloud.local.project,
410
+ linkedHub: cloud.local.linkedHub,
411
+ place: cloud.local.place,
412
+ },
413
+ syncStatus,
414
+ hubAccount: hub.details?.account ?? null,
415
+ online,
416
+ native,
417
+ });
418
+ const cr = cloudRow({ state: cloud.state, email: cloud.email });
419
+
420
+ const signInAgain = () => {
421
+ if (m.linkKind === 'cloud') {
422
+ cloud.startSignIn();
423
+ return;
424
+ }
425
+ // the one Link your server dialog (2.1.1 T5) on the server's address; today's form when nothing takes it
426
+ const ev = new CustomEvent(LINK_SERVER_EVENT, {
427
+ detail: { intent: 'sign-in', url: m.hubUrl ?? '' },
428
+ cancelable: true,
429
+ });
430
+ window.dispatchEvent(ev);
431
+ if (ev.defaultPrevented) onCloseSheet?.();
432
+ else setSignInAt(m.hubUrl ?? '');
433
+ };
434
+ const linkServer = () => {
435
+ // `account.link-server`'s event (shell/project-account-bus.js): 2.1.1 T5's one dialog takes it; when
436
+ // nothing does, today's team-server form opens here, in the sheet
437
+ const ev = new CustomEvent(LINK_SERVER_EVENT, { detail: { intent: 'link' }, cancelable: true });
438
+ window.dispatchEvent(ev);
439
+ if (ev.defaultPrevented) onCloseSheet?.();
440
+ else setTeamOpen(true);
441
+ };
442
+ // 2.1.1 T8 — Review… on an address the repo names opens the Share sheet's Connect row, where the
443
+ // person says whether it is theirs (the one consent step). Nothing is signed in from here.
444
+ const reviewLink = () => {
445
+ onCloseSheet?.();
446
+ requestShareFocus('connect');
447
+ runAction('share.open');
448
+ };
449
+ const canMove = menuRunner.canRun('share.move-to-cloud');
450
+ const canSwitch = menuRunner.canRun('account.switch');
451
+ const showInFinder = () => {
452
+ const rel = getPaletteEnv()?.designRel || '.design';
453
+ nativeDoors()
454
+ .revealPath(rel)
455
+ .catch(() => {});
456
+ };
457
+
458
+ const fix = m.fixLabel ? (
459
+ <button
460
+ type="button"
461
+ className="btn btn--sm btn--primary"
462
+ onClick={signInAgain}
463
+ data-testid="settings-project-sign-in-again"
464
+ >
465
+ {m.fixLabel}
466
+ </button>
467
+ ) : null;
468
+
469
+ if (cloud.state === 'loading') return null;
470
+
471
+ return (
472
+ <>
473
+ <SettingsCard
474
+ id="this-project"
475
+ testid="settings-this-project"
476
+ label="This project"
477
+ iconNode={<ProjectSquare name={m.name} />}
478
+ title="This project"
479
+ titleExtra={m.name}
480
+ desc={m.desc}
481
+ summary={m.statusWord}
482
+ sw={m.sw}
483
+ bad={m.bad}
484
+ // the fix never hides inside a closed card (09): open, it is the callout's button instead
485
+ action={m.bad && !open ? fix : undefined}
486
+ open={open}
487
+ onToggle={onToggle}
488
+ reveal={focus?.card === 'this-project'}
489
+ fold={{
490
+ panel: PROJECT_FOLD,
491
+ label: 'Sync details',
492
+ hint: m.local ? 'Maude Cloud · cloud projects' : 'Project files · trash · first link',
493
+ testid: 'settings-sync-details',
494
+ body: (
495
+ <div className="v2s-sync-details">
496
+ <ProjectSyncSettings cloud={null} />
497
+
498
+ <section className="v2s-sub" aria-label="Maude Cloud" data-testid="settings-cloud">
499
+ <h4 className="v2s-sub-t">Maude Cloud</h4>
500
+ <div
501
+ className="v2s-sub-r"
502
+ data-testid={cloud.state === 'in' ? 'cloud-account' : undefined}
503
+ >
504
+ <StatusLine
505
+ sw={cr.tone === 'ok' ? 'ok' : 'off'}
506
+ testid="settings-conn-cloud-status"
507
+ >
508
+ {cr.status}
509
+ </StatusLine>
510
+ {cr.action === 'sign-out' ? (
511
+ <button
512
+ type="button"
513
+ className={btn}
514
+ disabled={cloud.busy === 'signout'}
515
+ onClick={cloud.signOut}
516
+ data-testid="cloud-sign-out"
517
+ >
518
+ Sign out
519
+ </button>
520
+ ) : cr.action === 'sign-in' ? (
521
+ <button
522
+ type="button"
523
+ className={btn}
524
+ onClick={cloud.startSignIn}
525
+ data-testid="cloud-signin"
526
+ >
527
+ Sign in
528
+ </button>
529
+ ) : null}
530
+ </div>
531
+ {/* `cloud-bar`: the account's own words — the projects, the Connect outcome, an error. */}
532
+ <div className="v2s-conn-body" data-testid="cloud-bar">
533
+ {cloud.state === 'in' ? (
534
+ <div className="v2s-conn-list">
535
+ <p className="v2s-conn-h">Cloud projects on this Mac</p>
536
+ <div data-testid="settings-cloud-projects">
537
+ <CloudProjects c={cloud} />
538
+ </div>
539
+ {cloud.note ? (
540
+ <p
541
+ className="v2s-hint"
542
+ role="status"
543
+ aria-live="polite"
544
+ data-testid="cloud-connect-note"
545
+ >
546
+ {cloud.note.text}
547
+ </p>
548
+ ) : null}
549
+ </div>
550
+ ) : null}
551
+ {cloud.error ? (
552
+ <p className="v2s-conn-err" role="alert">
553
+ {cloud.error}
554
+ </p>
555
+ ) : null}
556
+ </div>
557
+ {cloud.cloudUrl ? (
558
+ <ConnField k="Address" mono copy={cloud.cloudUrl}>
559
+ {cloud.cloudUrl}
560
+ </ConnField>
561
+ ) : null}
562
+ {linkedUrl && m.linkKind === 'cloud' ? (
563
+ <HubFields
564
+ url={linkedUrl}
565
+ hub={hub}
566
+ credentialed={cloud.local.linkedHub?.credentialed}
567
+ />
568
+ ) : null}
569
+ <AccountBlock cloud={null} />
570
+ </section>
571
+
572
+ {m.linkKind === 'server' ? (
573
+ <section
574
+ className="v2s-sub"
575
+ aria-label="Your server"
576
+ data-testid="settings-conn-hub"
577
+ >
578
+ <h4 className="v2s-sub-t">Your server · {m.host}</h4>
579
+ <div className="v2s-sub-r">
580
+ <StatusLine sw={m.sw} testid="settings-conn-hub-status">
581
+ {m.statusWord}
582
+ </StatusLine>
583
+ <button
584
+ type="button"
585
+ className={btn}
586
+ disabled={cloud.busy === 'disconnect'}
587
+ onClick={cloud.disconnect}
588
+ data-testid="settings-hub-sign-out"
589
+ >
590
+ Sign out
591
+ </button>
592
+ </div>
593
+ <HubFields
594
+ url={linkedUrl}
595
+ hub={hub}
596
+ replace
597
+ credentialed={cloud.local.linkedHub?.credentialed}
598
+ />
599
+ </section>
600
+ ) : null}
601
+ {!m.local ? (
602
+ <button
603
+ type="button"
604
+ className="btn btn--ghost btn--sm v2s-conn-more"
605
+ onClick={linkServer}
606
+ data-testid="settings-team-server-add"
607
+ >
608
+ Link another server…
609
+ </button>
610
+ ) : null}
611
+ </div>
612
+ ),
613
+ }}
614
+ >
615
+ <CardRow
616
+ k="Lives in"
617
+ action={m.canChange ? <ChangeMenu m={m} onShowInFinder={showInFinder} /> : null}
618
+ >
619
+ <PlaceChip place={m.place} />
620
+ </CardRow>
621
+ <CardRow
622
+ k="Account"
623
+ testid="settings-project-account"
624
+ action={
625
+ canSwitch ? (
626
+ <button
627
+ type="button"
628
+ className="btn btn--ghost btn--sm"
629
+ onClick={() => {
630
+ onCloseSheet?.();
631
+ runAction('account.switch');
632
+ }}
633
+ data-testid="settings-project-switch"
634
+ >
635
+ Switch…
636
+ </button>
637
+ ) : null
638
+ }
639
+ >
640
+ <span className="v2s-inline">
641
+ <Face account={m.account} />
642
+ {m.account.label}
643
+ </span>
644
+ </CardRow>
645
+ <CardRow k="Connection">
646
+ <StatusLine sw={m.sw} testid="settings-project-connection">
647
+ {m.statusWord}
648
+ </StatusLine>
649
+ </CardRow>
650
+ {m.callout ? (
651
+ <div className="v2s-callout" role="alert" data-testid="settings-project-callout">
652
+ <span className="v2s-callout-ic" aria-hidden="true">
653
+ <StIcon name="link" size={14} />
654
+ </span>
655
+ <span className="v2s-callout-t">
656
+ <strong>{m.callout.title}</strong>
657
+ <span>{m.callout.line}</span>
658
+ </span>
659
+ {fix}
660
+ </div>
661
+ ) : null}
662
+ {m.unconfirmed ? (
663
+ <div className="v2s-acts" data-testid="settings-project-unconfirmed">
664
+ <span className="v2s-hint">{m.unconfirmed.line}</span>
665
+ <button
666
+ type="button"
667
+ className={btn}
668
+ onClick={reviewLink}
669
+ data-testid="settings-project-review-link"
670
+ >
671
+ {m.unconfirmed.label}
672
+ </button>
673
+ </div>
674
+ ) : null}
675
+ {m.local ? (
676
+ <div className="v2s-acts" data-testid="settings-project-local-acts">
677
+ {canMove ? (
678
+ <button
679
+ type="button"
680
+ className={btn}
681
+ onClick={() => {
682
+ onCloseSheet?.();
683
+ runAction('share.move-to-cloud');
684
+ }}
685
+ data-testid="settings-project-put-on-cloud"
686
+ >
687
+ <StIcon name="cloud" size={12} />
688
+ Put on Maude Cloud…
689
+ </button>
690
+ ) : null}
691
+ <button
692
+ type="button"
693
+ className={btn}
694
+ onClick={linkServer}
695
+ data-testid="settings-team-server-add"
696
+ >
697
+ <StIcon name="box" size={12} />
698
+ Link your server…
699
+ </button>
700
+ </div>
701
+ ) : null}
702
+ </SettingsCard>
703
+
704
+ {teamOpen ? (
705
+ <TeamProjectsDialog
706
+ serverOnly
707
+ title="Link your server"
708
+ onClose={() => setTeamOpen(false)}
709
+ />
710
+ ) : null}
711
+ {signInAt !== null ? (
712
+ <TeamProjectsDialog
713
+ serverOnly
714
+ title="Sign in again"
715
+ initialServer={signInAt}
716
+ onClose={() => setSignInAt(null)}
717
+ />
718
+ ) : null}
719
+ {cloud.device ? (
720
+ <CloudDeviceDialog
721
+ device={cloud.device}
722
+ cloudUrl={cloud.cloudUrl}
723
+ openFailed={cloud.openFailed}
724
+ onOpenResult={(s) => cloud.setOpenFailed(s === 'ok' ? '' : s)}
725
+ onCancel={cloud.cancelSignIn}
726
+ />
727
+ ) : null}
728
+ </>
729
+ );
730
+ }