@1agh/maude 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/access/request.ts +1 -0
- package/apps/studio/actions/agents.ts +27 -0
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/sync.ts +4 -0
- package/apps/studio/actions.manifest.json +60 -2
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/client/app.jsx +16 -4
- package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
- package/apps/studio/client/home/HomeConnection.jsx +111 -0
- package/apps/studio/client/home/home-accounts-model.js +110 -1
- package/apps/studio/client/home/home-api.js +6 -2
- package/apps/studio/client/home/home-app.jsx +74 -12
- package/apps/studio/client/home/home-model.js +40 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +233 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +138 -43
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +91 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/menu-runner.js +7 -2
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +40 -26
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/dist/client.bundle.js +834 -834
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +9 -3
- package/apps/studio/http.ts +8 -0
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/sync.ts +22 -4
- package/apps/studio/shell/api-key.ts +11 -0
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/action-stage.ts +18 -1
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-plane.ts +226 -19
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +68 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +16 -1
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +18 -2
- package/apps/studio/sync/status.ts +11 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/whats-new.json +18 -0
- package/cli/lib/bash-guard.mjs +19 -0
- package/cli/lib/design-help.gen.mjs +1 -1
- package/package.json +9 -8
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
// that holds a credential (`home_cloud_sign_in_prepare` makes a fresh one — that IS the switch);
|
|
15
15
|
// "Connect to a team server…" is the Advanced › hub sheet. A browser has no shell: facts only.
|
|
16
16
|
|
|
17
|
-
import { accountFace } from './home-model.js';
|
|
17
|
+
import { accountFace, normHubUrl } from './home-model.js';
|
|
18
|
+
import { CONN_WORDS, cloudState } from './home-where-model.js';
|
|
18
19
|
|
|
19
20
|
const hostOf = (url) => {
|
|
20
21
|
try {
|
|
@@ -119,3 +120,111 @@ export function homeAccounts({ native = false, shell = null, clouds = null, hubP
|
|
|
119
120
|
add: native ? { cloud: 'Add a Maude Cloud account…', team: 'Connect to a team server…' } : null,
|
|
120
121
|
};
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
const projectsWord = (n) => (n === 0 ? 'No projects' : `${n} ${n === 1 ? 'project' : 'projects'}`);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 2.1.1 B4 (artboard 14) — the accounts row on top of Home: one card per account the projects (or the
|
|
128
|
+
* sign-ins) name, with its state and, when the person can fix it in one click, the button.
|
|
129
|
+
* cloud a Maude Cloud account, by its e-mail. Listed when signed in, when its sign-in was refused,
|
|
130
|
+
* or when a project is on it but no sign-in is left ("Sign-in missing").
|
|
131
|
+
* server a server of your own, by its account (or host). Listed per saved sign-in, and for a server
|
|
132
|
+
* a project is on but no sign-in is saved for.
|
|
133
|
+
* "This Mac only" is not a card: nothing to connect, and the project rows already say it.
|
|
134
|
+
* `fix`: `{ path: 'cloud-signin', profile }` (Home's own Maude Cloud sign-in) or
|
|
135
|
+
* `{ path: 'hub-signin', profile, url }` (the team-server sign-in, address prefilled) — only for a
|
|
136
|
+
* sign-in that is missing or stopped working; a server that does not answer has nothing to fix here.
|
|
137
|
+
*
|
|
138
|
+
* @param in.shell `shell_state`
|
|
139
|
+
* @param in.clouds one `GET /_home/cloud` answer per profile
|
|
140
|
+
* @param in.hubProfiles `GET /_home/accounts` `profiles` (each hub with its `state`)
|
|
141
|
+
* @param in.groups `buildHomeModel().groups` (rows carry `where` / `connection`)
|
|
142
|
+
*/
|
|
143
|
+
export function homeAccountCards({ shell = null, clouds = null, hubProfiles = null, groups = [] }) {
|
|
144
|
+
const profiles = (shell?.profiles ?? []).filter((p) => p && typeof p.id === 'string');
|
|
145
|
+
const ids = [...profiles.map((p) => p.id), ...groups.map((g) => g.profile?.id)].filter(
|
|
146
|
+
(id, i, all) => typeof id === 'string' && all.indexOf(id) === i
|
|
147
|
+
);
|
|
148
|
+
const out = [];
|
|
149
|
+
for (const id of ids) {
|
|
150
|
+
const prof = profiles.find((p) => p.id === id) ?? null;
|
|
151
|
+
const rows = groups.find((g) => g.profile?.id === id)?.rows ?? [];
|
|
152
|
+
const listing = (clouds ?? []).find((c) => c?.profile === id) ?? null;
|
|
153
|
+
const email = str(listing?.account?.email) || str(prof?.email);
|
|
154
|
+
const onCloud = rows.filter((r) => r.where?.kind === 'cloud');
|
|
155
|
+
const cloudOwn = rows.some((r) => r.connection?.kind === 'cloud');
|
|
156
|
+
|
|
157
|
+
if (listing?.signedIn || listing?.rejected || cloudOwn) {
|
|
158
|
+
const state = cloudState(listing) ?? (cloudOwn ? 'missing' : null);
|
|
159
|
+
if (state)
|
|
160
|
+
out.push({
|
|
161
|
+
key: `cloud:${id}`,
|
|
162
|
+
kind: 'cloud',
|
|
163
|
+
profile: id,
|
|
164
|
+
url: null,
|
|
165
|
+
face: { kind: 'cloud', ...accountFace({ id, label: email || prof?.label, email }) },
|
|
166
|
+
title: email || 'Maude Cloud',
|
|
167
|
+
sub: `Maude Cloud · ${projectsWord(onCloud.length)}`,
|
|
168
|
+
state,
|
|
169
|
+
word: CONN_WORDS[state],
|
|
170
|
+
fix:
|
|
171
|
+
state === 'rejected' || state === 'missing'
|
|
172
|
+
? {
|
|
173
|
+
path: 'cloud-signin',
|
|
174
|
+
profile: id,
|
|
175
|
+
label: state === 'rejected' ? 'Sign in again' : 'Sign in',
|
|
176
|
+
}
|
|
177
|
+
: null,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const saved = (hubProfiles ?? []).find((x) => x?.id === id)?.hubs ?? [];
|
|
182
|
+
const servers = new Map();
|
|
183
|
+
for (const h of saved)
|
|
184
|
+
if (h && typeof h.url === 'string' && normHubUrl(h.url))
|
|
185
|
+
servers.set(normHubUrl(h.url), { url: h.url, account: str(h.account), state: h.state });
|
|
186
|
+
for (const r of rows) {
|
|
187
|
+
const url = r.connection?.kind === 'team' ? r.boundHub || r.hub : null;
|
|
188
|
+
if (url && !servers.has(url)) servers.set(url, { url, account: null, state: 'missing' });
|
|
189
|
+
}
|
|
190
|
+
for (const [norm, h] of servers) {
|
|
191
|
+
const state =
|
|
192
|
+
h.state === 'missing' || h.state === 'rejected' || h.state === 'unreachable'
|
|
193
|
+
? h.state
|
|
194
|
+
: 'ok';
|
|
195
|
+
const host = hostOf(h.url);
|
|
196
|
+
const n = rows.filter(
|
|
197
|
+
(r) => r.where?.kind === 'server' && (r.boundHub || r.hub) === norm
|
|
198
|
+
).length;
|
|
199
|
+
out.push({
|
|
200
|
+
key: `server:${id}:${norm}`,
|
|
201
|
+
kind: 'server',
|
|
202
|
+
profile: id,
|
|
203
|
+
url: h.url,
|
|
204
|
+
face: { kind: 'server' },
|
|
205
|
+
title: h.account || host,
|
|
206
|
+
sub: `${h.account ? host : 'Your server'} · ${projectsWord(n)}`,
|
|
207
|
+
state,
|
|
208
|
+
word: CONN_WORDS[state],
|
|
209
|
+
fix:
|
|
210
|
+
state === 'rejected' || state === 'missing'
|
|
211
|
+
? {
|
|
212
|
+
path: 'hub-signin',
|
|
213
|
+
profile: id,
|
|
214
|
+
url: h.url,
|
|
215
|
+
label: state === 'rejected' ? 'Sign in again' : 'Sign in',
|
|
216
|
+
}
|
|
217
|
+
: null,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The testid tail of a card: `<profile>-cloud` or `<profile>-<host>`. */
|
|
225
|
+
export const slugOf = (card) =>
|
|
226
|
+
card.kind === 'cloud'
|
|
227
|
+
? `${card.profile}-cloud`
|
|
228
|
+
: `${card.profile}-${hostOf(card.url)
|
|
229
|
+
.toLowerCase()
|
|
230
|
+
.replace(/[^a-z0-9]+/g, '-')}`;
|
|
@@ -130,8 +130,12 @@ export const cloudSignInStart = (profile) =>
|
|
|
130
130
|
export const cloudSignInPoll = (state) => post('/_home/cloud/signin/poll', { state });
|
|
131
131
|
export const cloudSignInCancel = (state) => post('/_home/cloud/signin/cancel', { state });
|
|
132
132
|
/** Rust picks (or makes) the profile the next sign-in may write → its id. A refusal rejects with words. */
|
|
133
|
-
export const signInPrepare = (forInvite) =>
|
|
134
|
-
shellInvoke('home_cloud_sign_in_prepare',
|
|
133
|
+
export const signInPrepare = (forInvite, profile) =>
|
|
134
|
+
shellInvoke('home_cloud_sign_in_prepare', {
|
|
135
|
+
...(forInvite ? { forInvite } : {}),
|
|
136
|
+
// 2.1.1: "Sign in again" on an account's card asks for THAT profile
|
|
137
|
+
...(profile ? { profile } : {}),
|
|
138
|
+
});
|
|
135
139
|
export const signInOpenBrowser = (userCode, state) =>
|
|
136
140
|
shellInvoke('home_cloud_sign_in_open', { userCode, state });
|
|
137
141
|
/** After the Home server stored the credential: Rust records the account → the profile it landed in. */
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
+
cloudSignOut,
|
|
16
17
|
createLocal,
|
|
17
18
|
createLocalFromPrompt,
|
|
18
19
|
getAccounts,
|
|
@@ -61,6 +62,9 @@ import { InviteSheet } from './InviteSheet.jsx';
|
|
|
61
62
|
import { INVITE_WORDS, joinPendingAndOpen, useInviteFlow } from './invite-flow.js';
|
|
62
63
|
import { HIcon, HMark, HSpark, ProjectSquare } from './home-icons.jsx';
|
|
63
64
|
import { HomeAccounts } from './HomeAccounts.jsx';
|
|
65
|
+
import { HomeAccountsRow } from './HomeAccountsRow.jsx';
|
|
66
|
+
import { AcctFace, StateWord, WhereChip } from './HomeConnection.jsx';
|
|
67
|
+
import { homeAccountCards } from './home-accounts-model.js';
|
|
64
68
|
import {
|
|
65
69
|
accountFace,
|
|
66
70
|
buildHomeModel,
|
|
@@ -453,6 +457,9 @@ export function HomeApp() {
|
|
|
453
457
|
// 2.0.5 W4b — the account each profile's team servers vouched for, so a row can say
|
|
454
458
|
// "Team server · <host> · <account>" (public handles from /_home/accounts, never a token)
|
|
455
459
|
const [hubAccounts, setHubAccounts] = useState(null);
|
|
460
|
+
// 2.1.1 — and whether each of those sign-ins still works (`state`), plus the raw answer for the accounts row
|
|
461
|
+
const [hubStates, setHubStates] = useState(null);
|
|
462
|
+
const [hubProfiles, setHubProfiles] = useState(null);
|
|
456
463
|
const profileKey = (data.shell?.profiles ?? [])
|
|
457
464
|
.map((p) => p?.id)
|
|
458
465
|
.filter(Boolean)
|
|
@@ -471,6 +478,15 @@ export function HomeApp() {
|
|
|
471
478
|
])
|
|
472
479
|
)
|
|
473
480
|
);
|
|
481
|
+
setHubStates(
|
|
482
|
+
Object.fromEntries(
|
|
483
|
+
r.json.profiles.map((p) => [
|
|
484
|
+
p.id,
|
|
485
|
+
Object.fromEntries((p.hubs ?? []).map((h) => [h.url, h.state])),
|
|
486
|
+
])
|
|
487
|
+
)
|
|
488
|
+
);
|
|
489
|
+
setHubProfiles(r.json.profiles);
|
|
474
490
|
});
|
|
475
491
|
return () => {
|
|
476
492
|
live = false;
|
|
@@ -484,9 +500,23 @@ export function HomeApp() {
|
|
|
484
500
|
clouds: data.clouds,
|
|
485
501
|
filterPid: filterPid || null,
|
|
486
502
|
hubAccounts,
|
|
503
|
+
hubStates,
|
|
487
504
|
cloudUrl,
|
|
488
505
|
}),
|
|
489
|
-
[data.shell, data.index, data.clouds, filterPid, hubAccounts, cloudUrl]
|
|
506
|
+
[data.shell, data.index, data.clouds, filterPid, hubAccounts, hubStates, cloudUrl]
|
|
507
|
+
);
|
|
508
|
+
// 2.1.1 (artboard 14) — the accounts row on top; an account whose sign-in stopped working is fixed
|
|
509
|
+
// from its own card. A Maude Cloud one drops the dead credential first so the sign-in may use that
|
|
510
|
+
// same profile again (Rust never re-signs a profile that still holds one).
|
|
511
|
+
const accountCards = useMemo(
|
|
512
|
+
() =>
|
|
513
|
+
homeAccountCards({
|
|
514
|
+
shell: data.shell,
|
|
515
|
+
clouds: data.clouds,
|
|
516
|
+
hubProfiles: hubProfiles ?? [],
|
|
517
|
+
groups: model.groups,
|
|
518
|
+
}),
|
|
519
|
+
[data.shell, data.clouds, hubProfiles, model.groups]
|
|
490
520
|
);
|
|
491
521
|
// 2.0.5 W4b — the face at the top right opens every account on this Mac (HomeAccounts.jsx)
|
|
492
522
|
const searchPids = useMemo(
|
|
@@ -1065,6 +1095,20 @@ export function HomeApp() {
|
|
|
1065
1095
|
</p>
|
|
1066
1096
|
) : null}
|
|
1067
1097
|
|
|
1098
|
+
{data.native && accountCards.length ? (
|
|
1099
|
+
<HomeAccountsRow
|
|
1100
|
+
cards={accountCards}
|
|
1101
|
+
native={data.native}
|
|
1102
|
+
onCloudSignIn={async (card) => {
|
|
1103
|
+
if (card.state === 'rejected') await cloudSignOut(card.profile);
|
|
1104
|
+
signin.begin({ profile: card.profile });
|
|
1105
|
+
}}
|
|
1106
|
+
onAddCloud={() => signin.begin()}
|
|
1107
|
+
onAddTeam={() => openSheet('hub')}
|
|
1108
|
+
onChanged={data.reload}
|
|
1109
|
+
/>
|
|
1110
|
+
) : null}
|
|
1111
|
+
|
|
1068
1112
|
{model.pinned.length ? (
|
|
1069
1113
|
<section className="home-sec" aria-labelledby="home-h-pinned">
|
|
1070
1114
|
<h2 className="home-h" id="home-h-pinned">
|
|
@@ -1424,20 +1468,34 @@ const STATE_WORD = {
|
|
|
1424
1468
|
),
|
|
1425
1469
|
};
|
|
1426
1470
|
|
|
1427
|
-
// 2.
|
|
1428
|
-
//
|
|
1429
|
-
|
|
1430
|
-
function
|
|
1431
|
-
|
|
1432
|
-
|
|
1471
|
+
// 2.1.1 (artboard 14) — a project row says where it lives (the account, or the place) and shows the
|
|
1472
|
+
// connection badge the project window shows: the account's face with the state on it, and its word.
|
|
1473
|
+
// `home-project-conn-<pid>` stays the connection cell (data-kind = local / cloud / team, data-state).
|
|
1474
|
+
function RowWhere({ row }) {
|
|
1475
|
+
if (!row.where) return null;
|
|
1476
|
+
return (
|
|
1477
|
+
<span className="home-prow-where">
|
|
1478
|
+
<WhereChip where={row.where} testid={`home-project-where-${row.pid}`} />
|
|
1479
|
+
</span>
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
function RowConn({ row }) {
|
|
1483
|
+
const c = row.conn;
|
|
1433
1484
|
return (
|
|
1434
1485
|
<span
|
|
1435
|
-
className="home-prow-
|
|
1486
|
+
className="home-prow-st"
|
|
1436
1487
|
data-testid={`home-project-conn-${row.pid}`}
|
|
1437
|
-
data-kind={
|
|
1488
|
+
data-kind={row.connection?.kind ?? undefined}
|
|
1489
|
+
data-state={c?.state ?? undefined}
|
|
1438
1490
|
>
|
|
1439
|
-
|
|
1440
|
-
|
|
1491
|
+
{c ? (
|
|
1492
|
+
<>
|
|
1493
|
+
<AcctFace face={c.face} state={c.state} size="sm" />
|
|
1494
|
+
<StateWord tone={c.tone} testid={`home-project-state-${row.pid}`}>
|
|
1495
|
+
{c.word}
|
|
1496
|
+
</StateWord>
|
|
1497
|
+
</>
|
|
1498
|
+
) : null}
|
|
1441
1499
|
</span>
|
|
1442
1500
|
);
|
|
1443
1501
|
}
|
|
@@ -1574,6 +1632,9 @@ function ProfileGroup({
|
|
|
1574
1632
|
{cloudRoleWord(r.role)} · {STATE_WORD.cloud}
|
|
1575
1633
|
</span>
|
|
1576
1634
|
</span>
|
|
1635
|
+
<span className="home-prow-where">
|
|
1636
|
+
<WhereChip where={r.where} testid={`home-project-where-${r.projectId}`} />
|
|
1637
|
+
</span>
|
|
1577
1638
|
<button
|
|
1578
1639
|
type="button"
|
|
1579
1640
|
className="btn btn--sm"
|
|
@@ -1623,7 +1684,6 @@ function ProfileGroup({
|
|
|
1623
1684
|
{[
|
|
1624
1685
|
r.canvasCount != null ? canvasCount(r.canvasCount) : null,
|
|
1625
1686
|
STATE_WORD[r.status] ?? null,
|
|
1626
|
-
r.connection ? <ConnectionWords key="conn" row={r} /> : null,
|
|
1627
1687
|
]
|
|
1628
1688
|
.filter(Boolean)
|
|
1629
1689
|
.map((part, i) => (
|
|
@@ -1635,6 +1695,8 @@ function ProfileGroup({
|
|
|
1635
1695
|
))}
|
|
1636
1696
|
</span>
|
|
1637
1697
|
</span>
|
|
1698
|
+
<RowWhere row={r} />
|
|
1699
|
+
<RowConn row={r} />
|
|
1638
1700
|
<RowLive row={r} />
|
|
1639
1701
|
<ProjectSquare id={r.pid} name={r.name} />
|
|
1640
1702
|
</button>
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { localIdentityMatches } from '../share-link.js';
|
|
16
16
|
import { accountTone } from '../shell/account-tone.js';
|
|
17
17
|
import { pathTestIdSlug } from '../shell/util.js';
|
|
18
|
+
import { cloudRowWhere, cloudState, connBadge, serverState, whereOf } from './home-where-model.js';
|
|
18
19
|
|
|
19
20
|
/** `canvas-row-<slug>`'s rule, so Home rows and tree rows name a canvas the same way. */
|
|
20
21
|
export const rowSlug = (rel) => pathTestIdSlug(rel);
|
|
@@ -186,6 +187,7 @@ export function buildHomeModel({
|
|
|
186
187
|
clouds = null,
|
|
187
188
|
filterPid = null,
|
|
188
189
|
hubAccounts = null,
|
|
190
|
+
hubStates = null,
|
|
189
191
|
cloudUrl = null,
|
|
190
192
|
}) {
|
|
191
193
|
const indexed = new Map();
|
|
@@ -236,6 +238,14 @@ export function buildHomeModel({
|
|
|
236
238
|
if (normHubUrl(url) && typeof who === 'string' && who) m.set(normHubUrl(url), who);
|
|
237
239
|
accountsOn.set(id, m);
|
|
238
240
|
}
|
|
241
|
+
// 2.1.1 — per profile, whether each saved team sign-in still works (`/_home/accounts` `state`)
|
|
242
|
+
const statesOn = new Map();
|
|
243
|
+
for (const [id, byHub] of Object.entries(hubStates ?? {})) {
|
|
244
|
+
const m = new Map();
|
|
245
|
+
for (const [url, st] of Object.entries(byHub ?? {}))
|
|
246
|
+
if (normHubUrl(url) && typeof st === 'string') m.set(normHubUrl(url), st);
|
|
247
|
+
statesOn.set(id, m);
|
|
248
|
+
}
|
|
239
249
|
const allLocal = registry.map((p) => {
|
|
240
250
|
const ix = indexed.get(p.pid);
|
|
241
251
|
const gone = ix?.state === 'gone';
|
|
@@ -286,7 +296,34 @@ export function buildHomeModel({
|
|
|
286
296
|
const ib = mru.has(b.pid) ? mru.get(b.pid) : Number.POSITIVE_INFINITY;
|
|
287
297
|
return ia - ib || a.name.localeCompare(b.name);
|
|
288
298
|
});
|
|
289
|
-
const
|
|
299
|
+
const listingFor = (id) => (clouds ?? []).find((c) => c?.profile === id) ?? null;
|
|
300
|
+
// 2.1.1 (artboard 14) — where the row lives and how it connects, after the folded copies settled
|
|
301
|
+
const placed = (r) => {
|
|
302
|
+
const kind = r.connection?.kind;
|
|
303
|
+
const state =
|
|
304
|
+
kind === 'local'
|
|
305
|
+
? 'local'
|
|
306
|
+
: kind === 'cloud'
|
|
307
|
+
? cloudState(listingFor(r.profile))
|
|
308
|
+
: kind === 'team'
|
|
309
|
+
? serverState(
|
|
310
|
+
hubStates ? (statesOn.get(r.profile) ?? new Map()) : null,
|
|
311
|
+
r.boundHub || r.hub
|
|
312
|
+
)
|
|
313
|
+
: null;
|
|
314
|
+
return {
|
|
315
|
+
...r,
|
|
316
|
+
where: whereOf(r),
|
|
317
|
+
conn: connBadge(state, {
|
|
318
|
+
kind,
|
|
319
|
+
profile: { id: r.profile },
|
|
320
|
+
email: r.connection?.account ?? null,
|
|
321
|
+
}),
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
const localRows = attachWorktrees(collapseDuplicates(allLocal, cloudUrl), shell?.worktrees).map(
|
|
325
|
+
(r) => (r.status === 'gone' ? r : placed(r))
|
|
326
|
+
);
|
|
290
327
|
|
|
291
328
|
// one profile's copy never hides another profile's cloud row
|
|
292
329
|
const bound = new Set(
|
|
@@ -308,6 +345,8 @@ export function buildHomeModel({
|
|
|
308
345
|
ownerName: cp.ownerName ?? null,
|
|
309
346
|
role: cp.role ?? null,
|
|
310
347
|
url: cp.url ?? null,
|
|
348
|
+
where: cloudRowWhere(listing.account?.email || emailOf(listing.profile)),
|
|
349
|
+
conn: null,
|
|
311
350
|
status: 'cloud',
|
|
312
351
|
updatedAt: cp.updatedAt ?? null,
|
|
313
352
|
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// client/home/home-where-model.js — 2.1.1 B4 (artboard 14): where a project row lives and whether it
|
|
2
|
+
// connects. PURE; `home-model.js` calls these while it builds a row.
|
|
3
|
+
//
|
|
4
|
+
// A project is always in exactly one of the places the design names — your folder, kept by Maude, on
|
|
5
|
+
// Maude Cloud, on your server — and a synced one also has an account:
|
|
6
|
+
// where.kind 'cloud' the project is on a Maude Cloud account → label = the account's e-mail
|
|
7
|
+
// 'server' it is on a server of your own → label = the server's host
|
|
8
|
+
// 'folder' only on this Mac, in a folder you chose → label "Your folder"
|
|
9
|
+
// 'kept' only on this Mac, a copy Maude keeps → label "Kept by Maude"
|
|
10
|
+
// where.path the folder, `~`-shortened — only for a folder the person chose (a copy Maude keeps has
|
|
11
|
+
// no path to manage)
|
|
12
|
+
// "On an account" comes from the shell's own binding (`connectionOf`, home-model.js), never from the
|
|
13
|
+
// project's self-claimed `linkedHub` alone; the words are the project window's (project-account-model).
|
|
14
|
+
|
|
15
|
+
import { accountFace } from './home-model.js';
|
|
16
|
+
|
|
17
|
+
/** The project window's connection words — one set, so the top bar and Home never disagree. */
|
|
18
|
+
export const CONN_WORDS = Object.freeze({
|
|
19
|
+
ok: 'Connected',
|
|
20
|
+
syncing: 'Syncing',
|
|
21
|
+
offline: 'Offline',
|
|
22
|
+
missing: 'Sign-in missing',
|
|
23
|
+
rejected: 'Sign-in stopped working',
|
|
24
|
+
unreachable: 'Server unreachable',
|
|
25
|
+
local: 'Only on this Mac',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** How the badge reads: `ok` (green) · `bad` (a sign-in the person can fix) · `warn` · `off` (grey). */
|
|
29
|
+
export const CONN_TONE = {
|
|
30
|
+
ok: 'ok',
|
|
31
|
+
syncing: 'busy',
|
|
32
|
+
offline: 'off',
|
|
33
|
+
missing: 'bad',
|
|
34
|
+
rejected: 'bad',
|
|
35
|
+
unreachable: 'warn',
|
|
36
|
+
local: 'off',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A path with the home folder as `~`. Home does not know the home folder; `/Users/<n>` and `/home/<n>` are. */
|
|
40
|
+
export function tildePath(root, home = null) {
|
|
41
|
+
const p = String(root || '');
|
|
42
|
+
if (!p) return '';
|
|
43
|
+
if (home && (p === home || p.startsWith(`${home}/`))) return `~${p.slice(home.length)}`;
|
|
44
|
+
const m = p.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);
|
|
45
|
+
return m ? `~${m[1] ?? ''}` : p;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The app's own copy of a project lives under its data folder's `projects/` (managed.rs `managed_root`). */
|
|
49
|
+
const APP_PROJECTS = /\/com\.maude\.app\/projects\//;
|
|
50
|
+
|
|
51
|
+
export const isKeptByMaude = ({ root, copyOf }) => !!copyOf || APP_PROJECTS.test(`${root || ''}/`);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {{ root?: string, copyOf?: string|null,
|
|
55
|
+
* connection?: { kind: string, host?: string|null, account?: string|null } }} row
|
|
56
|
+
* @returns {{ kind: 'cloud'|'server'|'folder'|'kept', label: string, path: string|null }}
|
|
57
|
+
*/
|
|
58
|
+
export function whereOf(row) {
|
|
59
|
+
const c = row.connection;
|
|
60
|
+
const kept = isKeptByMaude(row);
|
|
61
|
+
const path = kept ? null : tildePath(row.root) || null;
|
|
62
|
+
if (c?.kind === 'cloud') return { kind: 'cloud', label: c.account || 'Maude Cloud', path };
|
|
63
|
+
if (c?.kind === 'team') return { kind: 'server', label: c.host || 'Your server', path };
|
|
64
|
+
return kept
|
|
65
|
+
? { kind: 'kept', label: 'Kept by Maude', path: null }
|
|
66
|
+
: { kind: 'folder', label: 'Your folder', path };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A Maude Cloud project that is not on this Mac yet: it is on that profile's account. */
|
|
70
|
+
export const cloudRowWhere = (email) => ({
|
|
71
|
+
kind: 'cloud',
|
|
72
|
+
label: email || 'Maude Cloud',
|
|
73
|
+
path: null,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** Maude Cloud: how the account's listing reads. null = not answered yet (nothing is guessed). */
|
|
77
|
+
export function cloudState(listing) {
|
|
78
|
+
if (!listing) return null;
|
|
79
|
+
if (listing.signedIn) return listing.offline ? 'offline' : 'ok';
|
|
80
|
+
return listing.rejected ? 'rejected' : 'missing';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A team server from `/_home/accounts`: `byHub` = { normUrl: state } of the profile's saved sign-ins,
|
|
85
|
+
* `null` while that has not answered. A server with no saved sign-in at all is "missing".
|
|
86
|
+
*/
|
|
87
|
+
export function serverState(byHub, url) {
|
|
88
|
+
if (!byHub) return null;
|
|
89
|
+
const st = byHub.get(url);
|
|
90
|
+
if (st === undefined) return 'missing';
|
|
91
|
+
return st === 'rejected' ? 'rejected' : st === 'unreachable' ? 'unreachable' : 'ok';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The badge: the state's word + tone, worn on the account's face. null = no state to show. */
|
|
95
|
+
export function connBadge(state, { kind, profile, email }) {
|
|
96
|
+
if (!state) return null;
|
|
97
|
+
const face =
|
|
98
|
+
kind === 'cloud'
|
|
99
|
+
? {
|
|
100
|
+
kind: 'cloud',
|
|
101
|
+
...accountFace({ id: profile?.id, label: email || profile?.label, email }),
|
|
102
|
+
}
|
|
103
|
+
: { kind: kind === 'team' ? 'server' : 'local' };
|
|
104
|
+
return { state, word: CONN_WORDS[state], tone: CONN_TONE[state], face };
|
|
105
|
+
}
|