@songsid/agend 2.3.5-alpha.7 → 2.3.5-alpha.8
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/dist/accounts-view.d.ts +17 -0
- package/dist/accounts-view.js +33 -6
- package/dist/accounts-view.js.map +1 -1
- package/dist/apply-job.d.ts +5 -0
- package/dist/apply-job.js +10 -3
- package/dist/apply-job.js.map +1 -1
- package/dist/auth-api.d.ts +1 -1
- package/dist/auth-api.js +4 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/config-validator.js +2 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/fleet-manager.d.ts +25 -2
- package/dist/fleet-manager.js +158 -23
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/steering/core-rules.md +1 -1
- package/dist/hub/catalog.d.ts +1 -1
- package/dist/hub/catalog.js +151 -33
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.js +2 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +6 -0
- package/dist/hub/compose/member.js +9 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +7 -0
- package/dist/hub/compose/server.js +47 -6
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/group-policy/admin-api.d.ts +30 -0
- package/dist/hub/group-policy/admin-api.js +83 -0
- package/dist/hub/group-policy/admin-api.js.map +1 -0
- package/dist/hub/group-policy/admin-control.d.ts +34 -0
- package/dist/hub/group-policy/admin-control.js +258 -0
- package/dist/hub/group-policy/admin-control.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +9 -1
- package/dist/hub/group-policy/admin-dto.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +17 -0
- package/dist/hub/group-policy/admin-facts.js +33 -0
- package/dist/hub/group-policy/admin-facts.js.map +1 -0
- package/dist/hub/group-policy/admin-impact.d.ts +51 -0
- package/dist/hub/group-policy/admin-impact.js +88 -0
- package/dist/hub/group-policy/admin-impact.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +17 -0
- package/dist/hub/group-policy/authorization.js +123 -1
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
- package/dist/hub/group-policy/impact-inventory.js +75 -0
- package/dist/hub/group-policy/impact-inventory.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +13 -1
- package/dist/hub/group-policy/resources.js +92 -23
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.d.ts +11 -0
- package/dist/hub/group-policy/store.js +57 -2
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/group-policy/welcome.d.ts +36 -0
- package/dist/hub/group-policy/welcome.js +55 -0
- package/dist/hub/group-policy/welcome.js.map +1 -0
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +128 -6
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +7 -0
- package/dist/hub/member/pairing-api.d.ts +2 -0
- package/dist/hub/member/pairing-api.js +1 -0
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/pairing-notices.d.ts +18 -0
- package/dist/hub/member/pairing-notices.js +58 -0
- package/dist/hub/member/pairing-notices.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +47 -0
- package/dist/hub/pairing-notices.js +241 -0
- package/dist/hub/pairing-notices.js.map +1 -0
- package/dist/hub/pairing.d.ts +33 -1
- package/dist/hub/pairing.js +315 -15
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +32 -0
- package/dist/hub/protocol.js +6 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/runtime.d.ts +4 -1
- package/dist/hub/runtime.js +11 -0
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.js +4 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/store.d.ts +10 -1
- package/dist/hub/store.js +7 -4
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +13 -2
- package/dist/locale.js +22 -16
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +9 -1
- package/dist/login-controller.js +20 -1
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +4 -2
- package/dist/login-flows.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.js +1 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/quickstart-api.js +2 -2
- package/dist/quickstart-api.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +5 -1
- package/dist/reply-buttons-controller.js +8 -4
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +6 -2
- package/dist/reply-buttons.js +7 -3
- package/dist/reply-buttons.js.map +1 -1
- package/dist/settings-api.d.ts +2 -1
- package/dist/settings-api.js +4 -3
- package/dist/settings-api.js.map +1 -1
- package/dist/signin-keepalive.d.ts +2 -0
- package/dist/signin-keepalive.js +30 -2
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/ui/accounts-keepalive.js +10 -5
- package/dist/ui/accounts-manage.js +29 -11
- package/dist/ui/accounts-view.js +75 -28
- package/dist/ui/backend-signin.js +10 -1
- package/dist/ui/hub-client.js +43 -3
- package/dist/ui/hub-group-policy.js +170 -0
- package/dist/ui/hub-group-strings.js +97 -0
- package/dist/ui/hub-owner-strings.js +4 -4
- package/dist/ui/hub-pairing-progress-strings.js +15 -0
- package/dist/ui/hub-quick-pairing.js +202 -0
- package/dist/ui/hub-quick-strings.js +43 -0
- package/dist/ui/hub-read-strings.js +7 -0
- package/dist/ui/hub-welcome.js +99 -0
- package/dist/ui/panel-hub.js +47 -10
- package/dist/ui/panel-settings.js +7 -4
- package/dist/ui/settings-apply.js +12 -5
- package/dist/ui/settings-devices.js +2 -2
- package/dist/ui/settings-dialogs.js +3 -1
- package/dist/ui/settings-hub-membership.js +18 -4
- package/dist/ui/settings-hub-section.js +26 -1
- package/dist/ui/settings-hub.js +52 -11
- package/dist/ui/settings-restart-strings.js +17 -0
- package/dist/ui/settings-strings.js +6 -4
- package/dist/ui/shared/accounts-keepalive.css +11 -6
- package/dist/ui/shared/accounts.css +68 -18
- package/dist/ui/shared/app-i18n.js +3 -0
- package/dist/ui/shared/app-shell.js +18 -8
- package/dist/ui/shared/hub-groups.css +26 -0
- package/dist/ui/shared/hub.css +1 -0
- package/dist/ui/shared/setup-host-text.js +4 -1
- package/dist/ui/shared/signin.js +3 -1
- package/dist/ui/shared/usage-dialog.js +3 -72
- package/dist/ui/shared/usage-meter.js +84 -0
- package/dist/ui/shared/web-authorize.js +4 -4
- package/dist/update-marker.d.ts +2 -0
- package/dist/update-marker.js.map +1 -1
- package/dist/web-api.d.ts +5 -1
- package/dist/web-api.js +25 -5
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +16 -2
- package/dist/web-backend-login.js +14 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-notices.d.ts +9 -0
- package/dist/web-notices.js +19 -0
- package/dist/web-notices.js.map +1 -1
- package/dist/web-terminal.d.ts +7 -0
- package/dist/web-terminal.js +14 -2
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
2
|
+
import { ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
3
|
+
import { compareGroups, hubClient, safeWebOrigin } from "./hub-client.js";
|
|
4
|
+
import { hq } from "./hub-quick-strings.js";
|
|
5
|
+
import { hr } from "./hub-read-strings.js";
|
|
6
|
+
import { linkHubOwnerCss } from "./hub-owner-strings.js";
|
|
7
|
+
|
|
8
|
+
const reason = (r) => hq(r.code === "expired" ? "expired" : r.code === "conflict" ? "conflict" : r.code === "backpressure" ? "limit"
|
|
9
|
+
: r.code === "denied" || r.code === "revoked" ? "denied" : r.code === "unavailable" || r.code === "unreachable" ? "unavailable" : "failed");
|
|
10
|
+
const time = (at) => new Date(at).toLocaleString();
|
|
11
|
+
|
|
12
|
+
/** The page controls its own attempt only. The separate fleet-local proof is never performed by this component. */
|
|
13
|
+
export function QuickPairingGuide({ allowed = false, publishAllowed = false, onConnected = () => {} }) {
|
|
14
|
+
const c = hubClient(), live = useRef(true), generation = useRef(0), reported = useRef(null);
|
|
15
|
+
const [attempt, setAttempt] = useState(null), [loading, setLoading] = useState(true), [busy, setBusy] = useState(false);
|
|
16
|
+
const [label, setLabel] = useState(""), [error, setError] = useState(null), [mismatch, setMismatch] = useState(false), [stopped, setStopped] = useState(false);
|
|
17
|
+
const [copied, setCopied] = useState(null), [full, setFull] = useState(false);
|
|
18
|
+
const load = async (id = null) => {
|
|
19
|
+
const captured = generation.current, r = await c.quickPairing(id);
|
|
20
|
+
if (!live.current || captured !== generation.current) return;
|
|
21
|
+
setLoading(false);
|
|
22
|
+
if (!r.ok) { if (r.code === "expired") { generation.current++; setAttempt(null); } setError(reason(r)); return; }
|
|
23
|
+
setError(null); setAttempt(old => r.attempt ? { ...(old?.id === r.attempt.id ? old : {}), ...r.attempt, memberOrigin: r.memberOrigin } : null);
|
|
24
|
+
};
|
|
25
|
+
useEffect(() => { linkHubOwnerCss(); live.current = true; void load(); return () => { live.current = false; generation.current++; }; }, []);
|
|
26
|
+
useEffect(() => { if (attempt?.connected && reported.current !== attempt.id) { reported.current = attempt.id; onConnected(); } }, [attempt?.connected, attempt?.id]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!attempt?.id || attempt.connected || mismatch || stopped) return;
|
|
29
|
+
let pending = false;
|
|
30
|
+
const timer = setInterval(() => { if (!document.hidden && !pending) { pending = true; void load(attempt.id).finally(() => { pending = false; }); } }, 2000);
|
|
31
|
+
return () => clearInterval(timer);
|
|
32
|
+
}, [attempt?.id, attempt?.connected, mismatch, stopped]);
|
|
33
|
+
const create = async (event) => {
|
|
34
|
+
event.preventDefault(); if (busy || !allowed || !label.trim()) return;
|
|
35
|
+
const captured = ++generation.current; setBusy(true); setError(null); setMismatch(false); setStopped(false);
|
|
36
|
+
const r = await c.createQuickPairing(label.trim());
|
|
37
|
+
if (!live.current || captured !== generation.current) return;
|
|
38
|
+
setBusy(false);
|
|
39
|
+
if (!r.ok) { setError(reason(r)); return; }
|
|
40
|
+
setAttempt({ id: r.pairingId, code: r.code, expiresAt: r.expiresAt, memberOrigin: r.memberOrigin, state: "offered", connected: false });
|
|
41
|
+
};
|
|
42
|
+
const stop = async (different = false) => {
|
|
43
|
+
if (busy || !attempt?.id) return;
|
|
44
|
+
if (different) setMismatch(true);
|
|
45
|
+
const id = attempt.id, captured = ++generation.current; setBusy(true); setError(null);
|
|
46
|
+
const r = await c.stopQuickPairing(id);
|
|
47
|
+
if (!live.current || captured !== generation.current) return;
|
|
48
|
+
setBusy(false);
|
|
49
|
+
if (!r.ok) { setError(reason(r)); return; }
|
|
50
|
+
setStopped(true); setAttempt(null);
|
|
51
|
+
};
|
|
52
|
+
const match = async () => {
|
|
53
|
+
if (busy || mismatch || !attempt?.fingerprint) return;
|
|
54
|
+
const id = attempt.id, fp = attempt.fingerprint, captured = generation.current; setBusy(true); setError(null);
|
|
55
|
+
const r = await c.confirmPairing(id, fp);
|
|
56
|
+
if (!live.current || captured !== generation.current) return;
|
|
57
|
+
setBusy(false); if (!r.ok) { setError(reason(r)); return; }
|
|
58
|
+
await load(id);
|
|
59
|
+
};
|
|
60
|
+
const copy = async (key, value) => { try { await navigator.clipboard.writeText(value); if (live.current) setCopied(key); } catch { /* text remains selectable */ } };
|
|
61
|
+
// The Hub cannot observe the fleet-local button. Only its later claim proves that step completed; accepting
|
|
62
|
+
// the code or confirming on the Hub alone does not. Connected still requires the pinned ready link below.
|
|
63
|
+
if (loading) return html`<${Skeleton} variant="rows" lines=${2} />`;
|
|
64
|
+
if (!allowed && !attempt && !error) return null;
|
|
65
|
+
return html`<div data-quick-pairing="guide">
|
|
66
|
+
${error ? html`<${ErrorState} message=${error} onRetry=${() => load(attempt?.id)} />` : null}
|
|
67
|
+
${mismatch ? html`<p class="err" role="alert">${stopped ? hq("mismatchStop") : hq("compare")}</p>` : null}
|
|
68
|
+
${stopped ? html`<p class="note" role="status">${hq("stopped")}</p>` : null}
|
|
69
|
+
${!attempt ? allowed ? html`<form onSubmit=${create}><label for="quickFleetLabel">${hq("label")}</label>
|
|
70
|
+
<input id="quickFleetLabel" value=${label} maxLength="120" required placeholder=${hq("labelExample")} onInput=${e => setLabel(e.target.value)} />
|
|
71
|
+
<p class="note">${hq("labelHint")} ${hq("privacy")}</p><div class="field-row"><button type="submit" class="btn btn-primary" disabled=${busy || !label.trim()}>${hq(stopped ? "again" : "start")}</button></div></form>` : null
|
|
72
|
+
: attempt.connected ? html`<p class="note" role="status"><b>${hq("connected")}</b></p><h4>${hq("publish")}</h4><p class="note">${hq(publishAllowed ? "publishHint" : "publishNo")}</p>
|
|
73
|
+
${allowed ? html`<div class="field-row"><button type="button" class="btn" onClick=${() => { generation.current++; setAttempt(null); }}>${hq("another")}</button></div>` : null}`
|
|
74
|
+
: html`<ol class="hub-steps"><li class=${attempt.state === "claimed" ? "done" : "now"}><div class="hub-step-body"><h4>${hq("localTitle")}</h4><p class="note">${hq("local")}</p>
|
|
75
|
+
<span class="note">${hq("address")}</span><code class="hub-fp-full">${attempt.memberOrigin}</code>
|
|
76
|
+
${attempt.code ? html`<span class="note">${hq("code")}</span><code class="hub-fp-groups">${attempt.code}</code><button type="button" class="btn btn-sm" onClick=${() => copy("code", attempt.code)}>${hq(copied === "code" ? "copied" : "copy")}</button>` : html`<p class="note">${hq(attempt.state === "claimed" ? "claim" : "waiting")}</p>`}
|
|
77
|
+
<p class="note">${hq("expires", time(attempt.expiresAt))}</p></div></li>
|
|
78
|
+
<li class=${attempt.fingerprint ? "now" : ""}><div class="hub-step-body"><h4>${hq("compareTitle")}</h4><p class="note">${hq("compare")}</p>
|
|
79
|
+
${attempt.fingerprint ? html`<code class="hub-fp-groups">${compareGroups(attempt.fingerprint)}</code>
|
|
80
|
+
<button type="button" class="btn btn-sm btn-link" aria-expanded=${full} onClick=${() => setFull(!full)}>${full ? "SHA-256 −" : "SHA-256 +"}</button>
|
|
81
|
+
${full ? html`<code class="hub-fp-full">${attempt.fingerprint}</code>` : null}
|
|
82
|
+
${attempt.ownerConfirmed ? html`<p class="note" role="status">${hq("claim")}</p>` : html`<div class="field-row"><button type="button" class="btn btn-primary" disabled=${busy || mismatch} onClick=${match}>${hq("match")}</button>
|
|
83
|
+
<button type="button" class="btn" disabled=${busy} onClick=${() => stop(true)}>${hq("mismatch")}</button></div>`}` : null}
|
|
84
|
+
</div></li></ol>`}
|
|
85
|
+
${attempt && !attempt.connected ? html`<div class="field-row"><button type="button" class="btn" disabled=${busy} onClick=${() => stop(false)}>${hq("stop")}</button></div>` : null}
|
|
86
|
+
</div>`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function Notice({ notice, admin = false, memberOrigin = null, after = () => {} }) {
|
|
90
|
+
const [busy, setBusy] = useState(false), [error, setError] = useState(false);
|
|
91
|
+
const live = useRef(true); useEffect(() => () => { live.current = false; }, []);
|
|
92
|
+
const revoke = async () => {
|
|
93
|
+
if (busy || notice.revoked) return;
|
|
94
|
+
setBusy(true); setError(false); const c = hubClient();
|
|
95
|
+
const r = await (admin ? c.revokeFleet(notice.fleetId) : c.revokeOwnFleet(notice.fleetId, notice.generation));
|
|
96
|
+
if (!live.current) return;
|
|
97
|
+
setBusy(false); if (!r.ok) setError(true); else after();
|
|
98
|
+
};
|
|
99
|
+
let href = null;
|
|
100
|
+
if (memberOrigin) { try { const origin = new URL(memberOrigin); if (origin.protocol === "https:") href = `${origin.origin}/ui/hub?securityNotice=${encodeURIComponent(notice.id)}`; } catch { /* no link */ } }
|
|
101
|
+
return html`<div data-pairing-notice=${notice.id}><p><b>${hq("notice", notice.label)}</b></p><p class="note">${hq("approved")} ${time(notice.at)}</p>
|
|
102
|
+
<p class="note">${hq("fleetId")} <code class="hub-fp-full">${notice.fleetId}</code></p>
|
|
103
|
+
<p class="note">${hq("revokeHint")}</p>
|
|
104
|
+
${notice.revoked ? html`<span class="tag">${hq("revoked")}</span>` : href ? html`<a class="btn" target="_blank" rel="noopener noreferrer" href=${href}>${hq("review")}</a>`
|
|
105
|
+
: html`<div class="field-row"><button type="button" class="btn btn-danger" disabled=${busy} onClick=${revoke}>${hq("revoke")}</button></div>`}
|
|
106
|
+
${error ? html`<p class="err" role="alert">${hq("revokeFailed")}</p>` : null}</div>`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Narrowing remains available when current connect permission is denied or unknown. */
|
|
110
|
+
export function OwnedFleetRevoke({ fleet, onRevoked }) {
|
|
111
|
+
const [busy, setBusy] = useState(false), [error, setError] = useState(false);
|
|
112
|
+
const live = useRef(true); useEffect(() => () => { live.current = false; }, []);
|
|
113
|
+
if (!Number.isSafeInteger(fleet.generation) || fleet.status === "revoked") return null;
|
|
114
|
+
const revoke = async () => {
|
|
115
|
+
if (busy) return; setBusy(true); setError(false);
|
|
116
|
+
const r = await hubClient().revokeOwnFleet(fleet.id, fleet.generation);
|
|
117
|
+
if (!live.current) return;
|
|
118
|
+
setBusy(false); if (r.ok) onRevoked(); else setError(true);
|
|
119
|
+
};
|
|
120
|
+
return html`<button type="button" class="btn btn-sm btn-danger" disabled=${busy} onClick=${revoke}>${hq("revoke")}</button>
|
|
121
|
+
${error ? html`<small class="err" role="alert">${hq("revokeFailed")}</small>` : null}`;
|
|
122
|
+
}
|
|
123
|
+
export function PairingNotices({ admin = false, memberNotices = null, memberOrigin = null }) {
|
|
124
|
+
const c = hubClient(), live = useRef(true), epoch = useRef(0), acked = useRef(new Set());
|
|
125
|
+
const [noticeError, setNoticeError] = useState(null);
|
|
126
|
+
const [notices, setNotices] = useState(memberNotices || []);
|
|
127
|
+
const [historyOpen, setHistoryOpen] = useState(false), [historyCount, setHistoryCount] = useState(99);
|
|
128
|
+
const load = async () => {
|
|
129
|
+
const mine = epoch.current;
|
|
130
|
+
let r; try { r = await c.pairingNotices(); } catch { r = { ok: false, code: "unreachable" }; }
|
|
131
|
+
if (live.current && mine === epoch.current) {
|
|
132
|
+
if (r.ok) { setNotices(r.notices || []); setNoticeError(null); }
|
|
133
|
+
else { setNotices([]); setNoticeError(r.code === "backpressure" ? "busy" : "noticesUnavailable"); }
|
|
134
|
+
}
|
|
135
|
+
return r;
|
|
136
|
+
};
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
live.current = true; const mine = ++epoch.current;
|
|
139
|
+
const current = () => live.current && mine === epoch.current;
|
|
140
|
+
if (memberNotices) { setNotices(memberNotices); setNoticeError(null); return () => { live.current = false; epoch.current++; }; }
|
|
141
|
+
let off = () => {}, timer = null, reading = false;
|
|
142
|
+
const later = (fn, r = {}) => {
|
|
143
|
+
const seconds = Number(r.retryAfter); clearTimeout(timer);
|
|
144
|
+
timer = setTimeout(() => { if (current()) void fn(); },
|
|
145
|
+
(Number.isFinite(seconds) && seconds > 0 ? Math.max(1, Math.min(300, seconds)) : 10) * 1000);
|
|
146
|
+
};
|
|
147
|
+
const recover = async () => {
|
|
148
|
+
if (!current() || reading) return;
|
|
149
|
+
off(); reading = true;
|
|
150
|
+
const r = await load(); reading = false;
|
|
151
|
+
if (!current()) return;
|
|
152
|
+
if (r.ok) { setNoticeError("noticesRetry"); later(subscribe); }
|
|
153
|
+
else later(recover, r);
|
|
154
|
+
};
|
|
155
|
+
const subscribe = () => {
|
|
156
|
+
if (!current()) return;
|
|
157
|
+
off(); off = c.subscribePairingNotices(rows => { if (current()) { setNotices(rows); setNoticeError(null); } },
|
|
158
|
+
() => { if (current()) { setNoticeError("noticesRetry"); void recover(); } });
|
|
159
|
+
};
|
|
160
|
+
if (c.pairingNoticeSnapshotV1 === true) subscribe();
|
|
161
|
+
else void load().then(r => { if (current()) { if (r.ok) subscribe(); else later(recover, r); } });
|
|
162
|
+
return () => { live.current = false; epoch.current++; clearTimeout(timer); off(); };
|
|
163
|
+
}, [memberNotices]);
|
|
164
|
+
const requested = new URLSearchParams(location.search).get("securityNotice"), target = notices.find(n => n.id === requested) || notices[0];
|
|
165
|
+
const older = notices.filter(n => n !== target);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (memberNotices || !target) return;
|
|
168
|
+
let cancelled = false;
|
|
169
|
+
// A collapsed history is not shown. Bound rendering and ACK fan-out even at the 1024-record retention cap.
|
|
170
|
+
void (async () => { for (const n of [target, ...(historyOpen ? older.slice(0, historyCount) : [])]) {
|
|
171
|
+
if (cancelled || !live.current) return;
|
|
172
|
+
if (acked.current.has(n.id)) continue;
|
|
173
|
+
acked.current.add(n.id);
|
|
174
|
+
try { if (!(await c.acknowledgePairingNotice(n.id)).ok) acked.current.delete(n.id); }
|
|
175
|
+
catch { acked.current.delete(n.id); }
|
|
176
|
+
} })();
|
|
177
|
+
return () => { cancelled = true; };
|
|
178
|
+
}, [notices, memberNotices, historyOpen, historyCount]);
|
|
179
|
+
if (!target && !noticeError) return null;
|
|
180
|
+
const status = noticeError ? html`<p class="note" role="status" data-notices="retrying">${hr(noticeError)}</p>` : null;
|
|
181
|
+
if (!target) return html`<aside class="card hub-security-notices" aria-label=${hq("notices")}><h3>${hq("notices")}</h3>${status}</aside>`;
|
|
182
|
+
return html`<aside class="card hub-security-notices" aria-label=${hq("notices")}><h3>${hq("notices")}</h3>${status}
|
|
183
|
+
<${Notice} key=${target.id} notice=${target} admin=${admin} memberOrigin=${memberOrigin} after=${load} />
|
|
184
|
+
${older.length ? html`<details onToggle=${e => setHistoryOpen(e.currentTarget.open)}><summary>${hq("previous")} (${older.length})</summary>
|
|
185
|
+
${older.slice(0, historyCount).map(n => html`<${Notice} key=${n.id} notice=${n} admin=${admin} memberOrigin=${memberOrigin} after=${load} />`)}
|
|
186
|
+
${historyCount < older.length ? html`<button type="button" class="btn btn-sm" onClick=${() => setHistoryCount(n => n + 100)}>${hq("more")}</button>` : null}</details>` : null}
|
|
187
|
+
</aside>`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Same private, visible-only member poll as the switcher; no notice payload enters the fleet-wide SSE/guest stream. */
|
|
191
|
+
export function MemberPairingNotices() {
|
|
192
|
+
const c = hubClient(), [pairing, setPairing] = useState(null), [rows, setRows] = useState([]);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (!c.member || typeof c.pairingNotices !== "function") return;
|
|
195
|
+
let live = true;
|
|
196
|
+
const update = p => { if (live) { setPairing(p); setRows(c.pairingNotices()); } };
|
|
197
|
+
void c.pairing().then(update, () => {});
|
|
198
|
+
const off = c.subscribe(update); return () => { live = false; off(); };
|
|
199
|
+
}, []);
|
|
200
|
+
const origin = safeWebOrigin(pairing);
|
|
201
|
+
return origin && rows.length ? html`<${PairingNotices} memberNotices=${rows} memberOrigin=${origin} />` : null;
|
|
202
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Separate words so a cached earlier hub-strings module cannot expose raw keys.
|
|
2
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
3
|
+
register("hubQuick", {
|
|
4
|
+
en: {
|
|
5
|
+
start: "Connect my fleet", label: "Fleet name", labelHint: "A name you and your Hub admin will recognise.",
|
|
6
|
+
labelExample: "For example, my laptop", privacy: "Connect only a fleet you control. Your other Hub sessions, connected fleets and Hub admin will be notified.",
|
|
7
|
+
localTitle: "Confirm on your fleet", local: "On your fleet's web page, open Settings → Hub. Turn on Allow this fleet to connect to a Hub, then paste this address into the Hub address field and enter the one-time code. Confirm the local prompt there.",
|
|
8
|
+
remoteSteps: "Finish the fingerprint check on the Hub too.", ownerStep: "On the Hub, compare this fingerprint and confirm your pairing.", policyStep: "The Hub checks its group policy, or waits for its administrator's approval.",
|
|
9
|
+
address: "Hub address", code: "One-time code", copy: "Copy", copied: "Copied", expires: "Expires {0}",
|
|
10
|
+
compareTitle: "Compare the fingerprints", compare: "On your fleet, open Settings → Hub → Waiting for approval. Compare its fingerprint with this one. Confirm locally on your fleet too.",
|
|
11
|
+
match: "They match", mismatch: "They differ", mismatchStop: "The fingerprints differ. Pairing is stopped; no connection was approved. Start again only after checking the address.",
|
|
12
|
+
stop: "Stop pairing", stopped: "Pairing stopped", again: "Start again", waiting: "Waiting for your fleet's code and local confirmation…",
|
|
13
|
+
another: "Connect another fleet",
|
|
14
|
+
claim: "Waiting for your fleet's pinned connection…", connected: "Connected", publish: "Share agents on your fleet", publishHint: "On your fleet, open Settings → Hub → Shared agents. Choose only the agents you want to share and confirm there. Nothing is shared automatically.",
|
|
15
|
+
publishNo: "Your fleet is connected. Sharing new agents is not included in your current permissions; contact your Hub admin.",
|
|
16
|
+
expired: "This attempt expired or was replaced. It cannot connect a fleet. Start again.", unavailable: "Permissions or the connection can't be checked right now. Retry; this page can't confirm whether pairing finished.",
|
|
17
|
+
denied: "Connecting a fleet is not available to you. Contact your Hub admin.", conflict: "An administrator's pairing code is already waiting for you. Use that code, or ask the admin for help.",
|
|
18
|
+
limit: "Your fleet or pairing limit is reached. Stop an unused attempt or revoke a fleet you no longer use, then try again.", retry: "Retry", failed: "This action could not finish. Retry.",
|
|
19
|
+
notices: "Fleet security notices", notice: "A new fleet was connected: {0}", approved: "Approved by your Hub's group policy.",
|
|
20
|
+
revoke: "Revoke this fleet", revoked: "Revoked", revokeHint: "Stops this fleet's Hub access. Your other fleets and local agent work stay in place.",
|
|
21
|
+
review: "Review and revoke on the Hub", previous: "Earlier notices", more: "Show older notices", fleetId: "Fleet ID", revokeFailed: "The fleet could not be revoked. Sign in again if your session ended, then retry.",
|
|
22
|
+
},
|
|
23
|
+
"zh-TW": {
|
|
24
|
+
start: "連接我的 Fleet", label: "Fleet 名稱", labelHint: "取一個你和 Hub 管理員都認得的名字。", labelExample: "例如:我的筆電",
|
|
25
|
+
privacy: "只連接你能控制的 Fleet。你的其他 Hub 登入工作階段、已連接的 Fleet 和 Hub 管理員都會收到通知。",
|
|
26
|
+
localTitle: "在你的 Fleet 確認", local: "在你的 Fleet 網頁開啟「設定 → Hub」,開啟「允許這個 Fleet 連線至 Hub」,將以下位址貼到「Hub 位址」欄位,再輸入一次性代碼,並在當地確認提示。",
|
|
27
|
+
remoteSteps: "也要在 Hub 完成指紋比對。", ownerStep: "在 Hub 比對這個指紋,並確認你的配對。", policyStep: "Hub 會檢查群組規則,或等待管理員核准。",
|
|
28
|
+
address: "Hub 位址", code: "一次性代碼", copy: "複製", copied: "已複製", expires: "有效至 {0}",
|
|
29
|
+
compareTitle: "比對指紋", compare: "在你的 Fleet 開啟「設定 → Hub → 等待核准」,將當地指紋與下方逐一比對,也要在你的 Fleet 確認。",
|
|
30
|
+
match: "指紋相符", mismatch: "指紋不同", mismatchStop: "指紋不同,已停止配對,沒有核准連線。請先檢查位址,再重新開始。",
|
|
31
|
+
stop: "停止配對", stopped: "已停止配對", again: "重新開始", waiting: "等待你的 Fleet 使用代碼並在當地確認…", claim: "等待你的 Fleet 建立已固定憑證的連線…",
|
|
32
|
+
another: "連接另一個 Fleet",
|
|
33
|
+
connected: "已連接", publish: "在你的 Fleet 分享 Agent", publishHint: "在你的 Fleet 開啟「設定 → Hub → 已分享的 Agent」,選擇你要分享的 Agent 並在當地確認。不會自動分享任何 Agent。",
|
|
34
|
+
publishNo: "Fleet 已連接,但你目前的權限不包含分享新的 Agent。請聯絡 Hub 管理員。",
|
|
35
|
+
expired: "這次配對已過期或被取代,無法再連接 Fleet。請重新開始。", unavailable: "目前無法確認權限或連線。請重試;此頁無法確認配對是否已完成。",
|
|
36
|
+
denied: "你目前無法連接 Fleet。請聯絡 Hub 管理員。", conflict: "管理員已為你建立配對代碼。請使用該代碼,或請管理員協助。",
|
|
37
|
+
limit: "已達 Fleet 或配對數量上限。請停止未使用的配對,或撤銷不再使用的 Fleet,再重試。", retry: "重試", failed: "這次操作未能完成,請重試。",
|
|
38
|
+
notices: "Fleet 安全通知", notice: "已連接新的 Fleet:{0}", approved: "由 Hub 群組規則核准。", revoke: "撤銷此 Fleet", revoked: "已撤銷",
|
|
39
|
+
revokeHint: "停止這個 Fleet 的 Hub 存取。你的其他 Fleet 和當地 Agent 工作不受影響。", review: "在 Hub 查看並撤銷", previous: "較早的通知", more: "顯示更早的通知", fleetId: "Fleet ID",
|
|
40
|
+
revokeFailed: "無法撤銷此 Fleet。如果登入已結束,請重新登入後再重試。",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
export const hq = (key, ...args) => t(`hubQuick.${key}`, ...args);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Read recovery copy is loaded with its consumers, including tabs retaining older group strings.
|
|
2
|
+
import { register, t } from "/assets/app-i18n.js";
|
|
3
|
+
register("hubRead", {
|
|
4
|
+
en: { noticesRetry: "Live security notices are reconnecting. Retrying shortly…", noticesUnavailable: "Security notices can't be checked right now. Retrying shortly…", busy: "The Hub is busy. Retrying shortly…", catalogUnavailable: "Shared agents can't be checked right now. Retry." },
|
|
5
|
+
"zh-TW": { noticesRetry: "安全通知連線中斷,稍後會自動重試…", noticesUnavailable: "目前無法讀取安全通知,稍後會自動重試…", busy: "Hub 忙碌中,稍後會自動重試…", catalogUnavailable: "目前無法確認已分享的 Agent,請重試。" },
|
|
6
|
+
});
|
|
7
|
+
export const hr = (key) => t(`hubRead.${key}`);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// #3298 S-89: the signed-in welcome on a Hub with group permissions — two large entries, "Chat with an agent" and "Connect your
|
|
2
|
+
// fleet", shaped by what this person may do now (no actions / ask only / full). It is a DISPLAY of the server's welcome
|
|
3
|
+
// projection (GET /hub/v1/me/welcome): it grants nothing, and every chat, pairing or sharing action asks the server again.
|
|
4
|
+
// An answer the directory couldn't give is "can't be checked right now" with Retry, never a cached yes. Shared components:
|
|
5
|
+
// PageHead, card, btn, tag, note, Skeleton/ErrorState; the two cards sit in .hub-welcome (hub.css: a two-up grid, one column
|
|
6
|
+
// on a phone).
|
|
7
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
8
|
+
import { PageHead } from "/assets/page-head.js";
|
|
9
|
+
import { ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
10
|
+
import { navigate } from "/assets/app-nav.js";
|
|
11
|
+
import { hubClient, hubName } from "./hub-client.js";
|
|
12
|
+
import { hg } from "./hub-group-strings.js";
|
|
13
|
+
import { hr } from "./hub-read-strings.js";
|
|
14
|
+
import { OwnedFleetRevoke, QuickPairingGuide } from "./hub-quick-pairing.js";
|
|
15
|
+
|
|
16
|
+
const FLEET_STATUS = { active: "fleetActive", suspended: "fleetPaused", revoked: "fleetRevoked", unknown: "fleetUnknown" };
|
|
17
|
+
|
|
18
|
+
/** Why an entry is unavailable, in the person's words. */
|
|
19
|
+
export function reasonText(entry, fallback) {
|
|
20
|
+
if (!entry) return hg(fallback);
|
|
21
|
+
if (entry.state === "unknown") return hg("unknown");
|
|
22
|
+
const r = entry.reason;
|
|
23
|
+
return hg(r === "person-denied" ? "deniedPerson" : r === "ineligible" ? "ineligible" : r === "suspended" ? "suspended" : fallback);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `onChats` opens the chat list (the caller's own navigation). `askable` is how many agents are shared with this person
|
|
28
|
+
* (the catalog's own count), so a new owner with nothing shared reads "No agents have been shared with you yet".
|
|
29
|
+
*/
|
|
30
|
+
export function HubWelcome({ name, quick = false, onChats = () => navigate("/ui/hub?chats=1") }) {
|
|
31
|
+
const c = hubClient();
|
|
32
|
+
const [w, setW] = useState(null), [askable, setAskable] = useState(null), [error, setError] = useState(null);
|
|
33
|
+
const live = useRef(true), generation = useRef(0), retry = useRef(null);
|
|
34
|
+
const load = async () => {
|
|
35
|
+
if (!live.current) return;
|
|
36
|
+
clearTimeout(retry.current); retry.current = null;
|
|
37
|
+
const mine = ++generation.current;
|
|
38
|
+
const current = () => live.current && mine === generation.current;
|
|
39
|
+
const failed = (r, reason = "unknown") => {
|
|
40
|
+
if (!current()) return;
|
|
41
|
+
setError(r.code === "backpressure" ? "busy" : reason);
|
|
42
|
+
if (r.code === "backpressure") {
|
|
43
|
+
const seconds = Number(r.retryAfter);
|
|
44
|
+
retry.current = setTimeout(() => { if (current()) void load(); },
|
|
45
|
+
(Number.isFinite(seconds) && seconds > 0 ? Math.max(1, Math.min(300, seconds)) : 10) * 1000);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
setError(null); setW(null); setAskable(null);
|
|
49
|
+
try {
|
|
50
|
+
const [r, cat] = await Promise.all([c.welcome(), typeof c.catalog === "function" ? c.catalog() : Promise.resolve(null)]);
|
|
51
|
+
if (!current()) return;
|
|
52
|
+
if (!r.ok) { failed(r); return; }
|
|
53
|
+
if (cat && !cat.ok && (r.mode === "legacy" || r.chat?.state === "allow")) { failed(cat, "catalogUnavailable"); return; }
|
|
54
|
+
setW(r); setAskable(cat && Array.isArray(cat.askable) ? cat.askable.length : null);
|
|
55
|
+
} catch { failed({ code: "unreachable" }); }
|
|
56
|
+
};
|
|
57
|
+
useEffect(() => { live.current = true; void load(); return () => {
|
|
58
|
+
live.current = false; generation.current++; clearTimeout(retry.current);
|
|
59
|
+
}; }, []);
|
|
60
|
+
const refresh = async () => { const r = await c.welcome(); if (live.current && r.ok) setW(r); };
|
|
61
|
+
const head = html`<${PageHead} title=${hg("welcomeTitle", name || "")} scope=${hubName() || "Hub"} lead=${hg("welcomeLead")} />`;
|
|
62
|
+
if (error) return html`<div class="col hub-welcome-page">${head}${error === "busy"
|
|
63
|
+
? html`<p class="note" role="status" data-welcome="busy">${hr("busy")}</p>`
|
|
64
|
+
: html`<${ErrorState} message=${error === "catalogUnavailable" ? hr(error) : hg(error)} onRetry=${load} />`}</div>`;
|
|
65
|
+
if (!w) return html`<div class="col hub-welcome-page">${head}<div class="hub-welcome"><section class="card"><${Skeleton} variant="rows" lines=${3} /></section><section class="card"><${Skeleton} variant="rows" lines=${3} /></section></div></div>`;
|
|
66
|
+
const legacy = w.mode === "legacy";
|
|
67
|
+
const chat = w.chat || {}, connect = w.connect || {};
|
|
68
|
+
const chatOk = legacy || chat.state === "allow", connectOk = !legacy && connect.state === "allow";
|
|
69
|
+
const fleets = Array.isArray(connect.fleets) ? connect.fleets : [], max = Number(connect.maxFleets) || 0;
|
|
70
|
+
const quickOn = quick && c.quickPairingV1;
|
|
71
|
+
const used = fleets.filter((f) => f.status !== "revoked").length;
|
|
72
|
+
const atLimit = connectOk && max > 0 && used >= max;
|
|
73
|
+
const noActions = !legacy && chat.state !== "allow" && connect.state !== "allow" && chat.state !== "unknown" && connect.state !== "unknown";
|
|
74
|
+
const unknown = !legacy && (chat.state === "unknown" || connect.state === "unknown");
|
|
75
|
+
return html`<div class="col hub-welcome-page">${head}
|
|
76
|
+
${noActions ? html`<p class="note" role="status" data-welcome="no-actions">${hg("noActions")} ${hg("contactAdmin")}</p>` : null}
|
|
77
|
+
${unknown ? html`<p class="note" role="status" data-welcome="unknown">${hg("unknown")} <button type="button" class="btn btn-sm" onClick=${load}>${hg("retry")}</button></p>` : null}
|
|
78
|
+
<div class="hub-welcome">
|
|
79
|
+
<section class=${`card hub-welcome-card${chatOk ? "" : " is-off"}`} data-entry="chat" aria-disabled=${chatOk ? "false" : "true"}>
|
|
80
|
+
<h3>${hg("chatTitle")}</h3><p class="note">${hg("chatHint")}</p>
|
|
81
|
+
${chatOk ? html`${askable === 0 ? html`<p class="note" data-welcome="nothing-shared">${hg("chatNone")}</p>` : null}
|
|
82
|
+
<div class="hub-welcome-actions"><button type="button" class="btn btn-primary" onClick=${onChats}>${hg("chatGo")}</button></div>`
|
|
83
|
+
: html`<p class="note">${reasonText(chat, "contactAdmin")}</p>`}
|
|
84
|
+
</section>
|
|
85
|
+
<section class=${`card hub-welcome-card${connectOk ? "" : " is-off"}`} data-entry="connect" aria-disabled=${connectOk ? "false" : "true"}>
|
|
86
|
+
<h3>${hg("connectTitle")}</h3><p class="note">${hg("connectHint")}</p>
|
|
87
|
+
${connectOk && max > 0 ? html`<p class="note" data-welcome="fleets">${hg("connectFleets", used, max)}</p>` : null}
|
|
88
|
+
${fleets.length ? html`<ul class="hub-welcome-fleets">${fleets.map((f) => html`<li key=${f.id}><span class="hub-fp-full">${f.label || f.id}</span> <span class=${`tag${f.status === "active" ? " ok" : f.status === "suspended" || f.status === "unknown" ? " warn" : ""}`} data-fleet-status=${f.status}>${hg(FLEET_STATUS[f.status] || "fleetUnknown")}</span>
|
|
89
|
+
${quickOn ? html`<${OwnedFleetRevoke} fleet=${f} onRevoked=${load} />` : null}</li>`)}</ul>` : null}
|
|
90
|
+
${legacy ? html`<p class="note">${hg("connectManual")}</p>`
|
|
91
|
+
: !connectOk ? html`<p class="note">${chat.state === "allow" && connect.reason === "no-group" ? hg("connectNotIncluded") : reasonText(connect, "contactAdmin")}</p>`
|
|
92
|
+
: atLimit ? html`<p class="note" data-welcome="limit">${hg("connectLimit")}</p>`
|
|
93
|
+
: !quick || !c.quickPairingV1 ? html`<p class="note">${hg("connectManual")}</p>` : null}
|
|
94
|
+
${quickOn ? html`<${QuickPairingGuide} allowed=${connectOk && !atLimit} publishAllowed=${w.publish?.state === "allow"} onConnected=${refresh} />` : null}
|
|
95
|
+
</section>
|
|
96
|
+
</div>
|
|
97
|
+
${!legacy && w.publish && w.publish.state !== "allow" && connectOk ? html`<p class="note" data-welcome="publish">${hg("publishNot")}</p>` : null}
|
|
98
|
+
</div>`;
|
|
99
|
+
}
|
package/dist/ui/panel-hub.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
// (who, the revision shown, the directory), and a conflict reloads the list instead of guessing.
|
|
8
8
|
import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
|
|
9
9
|
import { PanelHeader, closeDrawer, setTitle } from "/assets/app-shell.js";
|
|
10
|
-
import { lang, t } from "/assets/app-i18n.js";
|
|
10
|
+
import { lang, register, t } from "/assets/app-i18n.js";
|
|
11
11
|
import { createStore, useStore } from "/assets/app-store.js";
|
|
12
12
|
import { navigate, navStore } from "/assets/app-nav.js";
|
|
13
13
|
import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
|
|
14
14
|
import { Icon } from "/assets/ui-icons.js";
|
|
15
15
|
import { confirmDialog } from "/assets/ui-confirm.js";
|
|
16
16
|
import { Dialog } from "/assets/ui-dialog.js";
|
|
17
|
+
import { PairingNotices } from "./hub-quick-pairing.js";
|
|
17
18
|
import { Menu } from "/assets/ui-menu.js";
|
|
18
19
|
import { toast } from "/assets/ui-toast.js";
|
|
19
20
|
// #3226 B: the chat is the fleet chat's own drawing (PR A's shared modules), in the fleet chat's words.
|
|
@@ -32,6 +33,21 @@ import { QuotaBanner, QuotaCard, QuotaChip, QuotaVisibilityRow } from "./hub-quo
|
|
|
32
33
|
import { PageHead } from "/assets/page-head.js";
|
|
33
34
|
import { bindRoomFeedback, bootHubPreview, downloadHtml, draftWithLine, panelOpenFor, roomPanelKey, roomPanelOpts, setHubPreviewOptIn } from "./hub-preview.js";
|
|
34
35
|
import { PendingFiles, hf, pageCarriesFiles, roomTakesFiles, uploadChosen } from "./hub-attachments.js";
|
|
36
|
+
// #3298 S-89 (experimental): the group permissions editor and the signed-in welcome are their own LAZY modules, loaded only
|
|
37
|
+
// when the Hub's session says "group-policy-v1" and this tab's client has the calls — a Hub without them never serves or loads them.
|
|
38
|
+
// The one group-permissions sentence this module draws itself (shown when the lazy modules are NOT loaded: this Hub lacks them).
|
|
39
|
+
register("hubGroupsNote", {
|
|
40
|
+
en: { unavailable: "Group permissions aren't available on this Hub yet. Update the Hub, then try again." },
|
|
41
|
+
"zh-TW": { unavailable: "這個 Hub 還沒有群組權限。請更新 Hub 後再試。" },
|
|
42
|
+
});
|
|
43
|
+
const groupPolicyOn = (session, client) => !!session && Array.isArray(session.features) && session.features.includes("group-policy-v1")
|
|
44
|
+
&& !!client && client.groupPolicyV1 === true;
|
|
45
|
+
function LazyGroups({ pick, props }) {
|
|
46
|
+
const [C, setC] = useState(null), [failed, setFailed] = useState(false);
|
|
47
|
+
useEffect(() => { let live = true; Promise.all([import("./hub-welcome.js"), import("./hub-group-policy.js"), import("./hub-group-strings.js")])
|
|
48
|
+
.then(([w, p, g]) => { if (live) setC(() => pick({ ...w, ...p, ...g })); }, () => { if (live) setFailed(true); }); return () => { live = false; }; }, []);
|
|
49
|
+
return failed ? null : C ? html`<${C} ...${props} />` : html`<${Skeleton} variant="rows" lines=${3} />`;
|
|
50
|
+
}
|
|
35
51
|
|
|
36
52
|
const TITLES = { ask: "askTitle", exposures: "exposuresTitle", admin: "adminTitle" };
|
|
37
53
|
/** P1 room polling: at most once per ten seconds, one request at a time, paused while the page is hidden (hub.md §5). */
|
|
@@ -86,13 +102,14 @@ export function HubPanel({ route }) {
|
|
|
86
102
|
// Signed out: the sign-in page alone (no panel header, no chat chrome).
|
|
87
103
|
if (s === null) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-signin"><${HubSignIn} /></div>`;
|
|
88
104
|
if (s) body = tab === "ask" ? html`<${HubChats} />` : tab === "exposures" ? html`<${HubMine} />` : html`<${HubAdmin} admin=${!!s.admin} />`;
|
|
105
|
+
const notices = s?.features?.includes("quick-pairing-v1") && hubClient().quickPairingV1 ? html`<${PairingNotices} admin=${!!s.admin} />` : null;
|
|
89
106
|
// The chats draw their own header (the room's); the other pages keep the panel's.
|
|
90
|
-
if (s !== null && tab === "ask") return html`<div data-effect-panel="hub" class="panel p-hub p-hub-ask"><div data-trust="panel-content" class="panel-body hub-chat-body">${body}</div></div>`;
|
|
107
|
+
if (s !== null && tab === "ask") return html`<div data-effect-panel="hub" class="panel p-hub p-hub-ask"><div data-trust="panel-content" class="panel-body hub-chat-body">${notices}${body}</div></div>`;
|
|
91
108
|
// #3226 C: My shared agents and Administration are Settings-like pages (their own PageHead under the panel's header).
|
|
92
109
|
const pageTitle = tab === "exposures" ? hc("mine") : tab === "admin" ? hc("admin") : hw(TITLES[tab]);
|
|
93
110
|
return html`<div data-effect-panel="hub" class=${`panel p-hub p-hub-${tab}`}>
|
|
94
111
|
<${PanelHeader} title=${s ? pageTitle : hw(TITLES[tab])} />
|
|
95
|
-
<div data-trust="panel-content" class=${`panel-body ${s ? "hub-page-body" : "hub-body"}`}>${body}</div>
|
|
112
|
+
<div data-trust="panel-content" class=${`panel-body ${s ? "hub-page-body" : "hub-body"}`}>${notices}${body}</div>
|
|
96
113
|
</div>`;
|
|
97
114
|
}
|
|
98
115
|
|
|
@@ -196,7 +213,10 @@ function useRead(read) {
|
|
|
196
213
|
export const ROOMS_MS = 30_000;
|
|
197
214
|
export function refreshRooms() {
|
|
198
215
|
return roomsReading ??= hubClient().rooms().then((r) => {
|
|
199
|
-
|
|
216
|
+
// With group permissions on, a person whose groups don't include chatting is refused the list: that is their access, shown
|
|
217
|
+
// by the welcome, not a failure (Cairn #3372) — the list stays empty and quiet. Every chat action still asks the server.
|
|
218
|
+
if (!r.ok && (r.code === "denied" || r.code === "revoked") && groupPolicyOn(session, hubClient())) roomsStore.set({ loaded: true, rooms: [], error: null, denied: true });
|
|
219
|
+
else roomsStore.set(r.ok ? { loaded: true, rooms: r.rooms || [], error: null } : { ...roomsStore.get(), loaded: true, error: errText(r) });
|
|
200
220
|
}, () => roomsStore.set({ ...roomsStore.get(), loaded: true, error: hw("errFailed") })).finally(() => { roomsReading = null; });
|
|
201
221
|
}
|
|
202
222
|
/** Keeps the list fresh while something shows it (every ROOMS_MS, paused while the page is hidden). */
|
|
@@ -244,7 +264,7 @@ export function HubNav({ onPick } = {}) {
|
|
|
244
264
|
<div class="hub-sec">${hc("chats")}</div>
|
|
245
265
|
${rs.error ? html`<${ErrorState} message=${rs.error} onRetry=${refreshRooms} />` : null}
|
|
246
266
|
${!rs.loaded ? html`<${Skeleton} variant="rows" lines=${4} />` : null}
|
|
247
|
-
${rs.loaded && !rs.error && !rs.rooms.length ? html`<p class="note hub-list-empty">${hc("noChatsHint")}</p>` : null}
|
|
267
|
+
${rs.loaded && !rs.error && !rs.denied && !rs.rooms.length ? html`<p class="note hub-list-empty">${hc("noChatsHint")}</p>` : null}
|
|
248
268
|
${rs.rooms.length && !shown.length ? html`<p class="note hub-list-empty">${hc("noMatch")}</p>` : null}
|
|
249
269
|
<ul class="hub-rooms" role="list">${shown.map((r) => html`<li key=${r.id}>
|
|
250
270
|
<a class=${`hub-room-row${current === r.id ? " active" : ""}${r.state === "closed" ? " closed" : ""}`} href=${roomPath(r.id)} aria-current=${current === r.id ? "page" : undefined} onClick=${(e) => pick(e, r)}>
|
|
@@ -295,17 +315,21 @@ function NewChatDialog({ onClose }) {
|
|
|
295
315
|
function HubChats() {
|
|
296
316
|
useStore(navStore); // ?room= changes without a new route
|
|
297
317
|
const rs = useRooms();
|
|
318
|
+
const s = useSession();
|
|
319
|
+
const [picking, setPicking] = useState(false);
|
|
298
320
|
useEffect(() => { linkHubChatCss(); }, []);
|
|
299
321
|
const id = roomParam();
|
|
300
322
|
const room = id ? rs.rooms.find((r) => r.id === id) || (rs.loaded ? { id, exposureName: "", ownerName: "", features: [] } : null) : null;
|
|
301
323
|
if (id && room) return html`<${HubRoomView} key=${id} room=${room} />`;
|
|
302
324
|
if (id) return html`<${HubRoomLoading} error=${rs.error} />`;
|
|
303
325
|
return html`<${PanelHeader} title=${hc("chats")} />
|
|
304
|
-
<div class
|
|
326
|
+
<div class=${`hub-home${groupPolicyOn(s, hubClient()) ? " has-welcome" : ""}`}>
|
|
305
327
|
<div class="hub-home-list"><${HubNav} /></div>
|
|
306
|
-
|
|
328
|
+
${groupPolicyOn(s, hubClient()) ? html`<div class="hub-home-pick hub-home-welcome"><${LazyGroups} pick=${(m) => m.HubWelcome} props=${{ name: s.displayName, quick: s.features.includes("quick-pairing-v1"), onChats: () => setPicking(true) }} /></div>`
|
|
329
|
+
: html`<div class="hub-home-pick center">${!rs.loaded ? html`<${Skeleton} variant="rows" lines=${4} />` : rs.error && !rs.rooms.length ? html`<${ErrorState} message=${rs.error} onRetry=${refreshRooms} />` : !rs.rooms.length
|
|
307
330
|
? html`<${Empty} icon="chat" title=${hc("noChats")} hint=${hc("noChatsHint")} />`
|
|
308
|
-
: html`<${Empty} icon="chat" title=${hc("choose")} hint=${hc("chooseHint")} />`}</div
|
|
331
|
+
: html`<${Empty} icon="chat" title=${hc("choose")} hint=${hc("chooseHint")} />`}</div>`}
|
|
332
|
+
${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}
|
|
309
333
|
</div>`;
|
|
310
334
|
}
|
|
311
335
|
|
|
@@ -684,10 +708,22 @@ function AllowDialog({ x, act, onClose }) {
|
|
|
684
708
|
|
|
685
709
|
// ── Administration ──
|
|
686
710
|
function HubAdmin({ admin }) {
|
|
711
|
+
useStore(navStore); // ?view= changes without a new route
|
|
712
|
+
const s = useSession();
|
|
687
713
|
if (!admin) return html`<div class="center hub-empty"><${Empty} icon="key" title=${hw("adminOnly")} hint=${hw("adminOnlyHint")} /></div>`;
|
|
688
|
-
return html`<${
|
|
714
|
+
if (groupPolicyOn(s, hubClient()) && adminView() === "groups") return html`<${LazyGroups} pick=${(m) => m.HubGroupPolicyPage} props=${{}} />`;
|
|
715
|
+
// Reached from a fleet's Settings link on a Hub (or a tab) without group permissions: say so instead of a silent admin page.
|
|
716
|
+
const unavailable = adminView() === "groups" && !groupPolicyOn(s, hubClient());
|
|
717
|
+
return html`${unavailable ? html`<p class="note" role="status" data-groups="unavailable">${t("hubGroupsNote.unavailable")}</p>` : null}
|
|
718
|
+
<${HubAdminPage} groups=${groupPolicyOn(s, hubClient())} />`;
|
|
719
|
+
}
|
|
720
|
+
/** #3298 S-89: Administration's sub-page (?view=groups: Group permissions), from the page's own address. */
|
|
721
|
+
function adminView() { try { return new URLSearchParams(location.search).get("view") || ""; } catch { return ""; } }
|
|
722
|
+
/** #3298 S-89: the prominent entry to Group permissions at the top of Administration (discovery without docs). */
|
|
723
|
+
function GroupPermissionsEntry() {
|
|
724
|
+
return html`<${LazyGroups} pick=${(m) => m.GroupPermissionsCard} props=${{}} />`;
|
|
689
725
|
}
|
|
690
|
-
function HubAdminPage() {
|
|
726
|
+
function HubAdminPage({ groups = false } = {}) {
|
|
691
727
|
const [view, reload] = useRead(() => hubClient().adminOverview());
|
|
692
728
|
const [login, setLogin] = useState("");
|
|
693
729
|
const [offer, setOffer] = useState(null);
|
|
@@ -721,6 +757,7 @@ function HubAdminPage() {
|
|
|
721
757
|
const fleets = view.fleets || [], pairings = view.pairings || [];
|
|
722
758
|
return html`<div class="col hub-owner hub-admin"><${PageHead} title=${hc("admin")} scope=${ho("scopeHub")} lead=${ho("adminLead")} />
|
|
723
759
|
<div class="s-section-layout">
|
|
760
|
+
${groups ? html`<${GroupPermissionsEntry} />` : null}
|
|
724
761
|
${view.error ? html`<${ErrorState} message=${view.error} onRetry=${reload} />` : null}
|
|
725
762
|
${msg ? html`<p class="err" role="alert">${msg}</p>` : null}
|
|
726
763
|
<section class="card"><h3>${ho("pairSteps")}</h3>
|
|
@@ -27,6 +27,7 @@ import { toast } from "/assets/ui-toast.js";
|
|
|
27
27
|
import { GroupMark, groupLabel, groupOf as navGroupOf, modelText } from "/assets/instance-nav.js";
|
|
28
28
|
import "./settings-strings.js";
|
|
29
29
|
import "./settings-shared-strings.js"; // see settings-shared.js: the words Shared agent settings added, which an older settings-strings.js in an open tab lacks
|
|
30
|
+
import "./settings-restart-strings.js"; // S-92: the restart words for a fleet with no chat connection (a file of its own: an open tab may hold an old settings-strings.js)
|
|
30
31
|
import "./settings-access-strings.js"; // the words Access & security added (settings.webLoginQr…): an older settings-strings.js from a tab that visited Fleet first lacks them (#3061)
|
|
31
32
|
import { api, attach, confirmedWrite, newKey } from "./settings-confirm.js";
|
|
32
33
|
import { dismissOperation, operationActive, restartFleet, startOperation, takeLeftover } from "./settings-apply.js";
|
|
@@ -420,7 +421,7 @@ export function SettingsPanel({ route, navKey }) {
|
|
|
420
421
|
: section === "web-dashboard" ? html`<${WebSection} key=${formKey} ctx=${ctx} staged=${staged} part="dashboard" /><${AppearanceSection} ...${you} part="dashboard" />`
|
|
421
422
|
: section === "access" ? html`<${WebSection} key=${formKey} ctx=${ctx} staged=${staged} part="access" />`
|
|
422
423
|
// alpha.6 feedback (#2): the Hub cards have their own section (they were under Access & security, unfound by search).
|
|
423
|
-
: section === "hub" ? html`<${HubSection} overPublicLink=${typeof document !== "undefined" && document.body?.dataset?.publicLink === "1"} hubHost=${!!ctx.fleet.hub?.hubId} />`
|
|
424
|
+
: section === "hub" ? html`<${HubSection} overPublicLink=${typeof document !== "undefined" && document.body?.dataset?.publicLink === "1"} hubHost=${!!ctx.fleet.hub?.hubId} hubOrigin=${ctx.fleet.hub?.webOrigin} />`
|
|
424
425
|
: html`<${AdvancedSettings} ctx=${ctx} staged=${staged} formKey=${formKey} draftEpoch=${draftEpoch} />`;
|
|
425
426
|
// #2347 §6: the setting a search result opened — brought into view once its section is drawn (its data may still be
|
|
426
427
|
// on its way), focused, and flashed for 2 s.
|
|
@@ -1402,7 +1403,7 @@ function WebSection({ ctx, staged, part = "all" }) {
|
|
|
1402
1403
|
</section>`)}
|
|
1403
1404
|
${!overPublicLink ? html`<${WebAuthorityCard} ctx=${ctx} staged=${staged} />` : null}
|
|
1404
1405
|
${/* A tab whose shell is from before Settings → Hub (its app-route.js has no "hub"): the Hub cards stay here. */ ""}
|
|
1405
|
-
${!SETTINGS_SECTIONS.includes("hub") ? html`<${HubSection} overPublicLink=${overPublicLink} hubHost=${!!ctx.fleet.hub?.hubId} />` : null}
|
|
1406
|
+
${!SETTINGS_SECTIONS.includes("hub") ? html`<${HubSection} overPublicLink=${overPublicLink} hubHost=${!!ctx.fleet.hub?.hubId} hubOrigin=${ctx.fleet.hub?.webOrigin} />` : null}
|
|
1406
1407
|
<details class="drawer s-terminal-disclosure"><summary>${tn("webTerminalTitle")}</summary><div class="drawer-body">${lock(html`<section class="card s-access-terminal"><h3>${tn("webTerminalTitle")}</h3>
|
|
1407
1408
|
<p class="note">${tn("webTerminalHint")}</p>
|
|
1408
1409
|
<label class=${fc("check", "termOn")}><input id="webTerminalEnabled" type="checkbox" checked=${f.termOn} onChange=${(e) => set("termOn")(e.target.checked)} /><span>${tn("webTerminalEnabled")}</span><${Impact} schema=${schema} field="web_terminal.enabled" /></label>
|
|
@@ -1574,17 +1575,19 @@ function OperationCard({ op, schema }) {
|
|
|
1574
1575
|
const needsRestart = rows.some((r) => r.status === "restart-required");
|
|
1575
1576
|
const failedRows = rows.some((r) => r.status === "failed");
|
|
1576
1577
|
const mismatch = schema && schema.fleet_signature_mismatch;
|
|
1578
|
+
// S-92: a fleet with no chat connection — its restart is recorded in the dashboard's Notices, not a chat channel.
|
|
1579
|
+
const webOnly = useStore(appStore).connections === 0;
|
|
1577
1580
|
const title = op.phase === "failed" ? tn("applyPartial") : fleetRestarting ? tn("restartFleetTitle") : busy ? tn("applying")
|
|
1578
1581
|
: failedRows ? tn("applyPartial") : needsRestart ? tn("applyRestartNeeded") : tn("applyDone");
|
|
1579
1582
|
const note = op.phase === "failed" ? (op.error === "busy" ? tn("applyBusy") : op.error ? tn("applyStepFailed", applyErrorText(op.error)) : "")
|
|
1580
1583
|
: fleetRestarting ? tn("restartFleetWaiting") : op.lostJob ? tn("applyLostJob")
|
|
1581
1584
|
: job && job.overdue ? tn("applyStillWorking", Math.round((job.elapsed_ms || 0) / 1000))
|
|
1582
|
-
: mismatch && needsRestart ? tn("signatureMismatch", mismatch.join(", ")) : needsRestart ? tn("applyRestartHint") : "";
|
|
1585
|
+
: mismatch && needsRestart ? tn("signatureMismatch", mismatch.join(", ")) : needsRestart ? tn(webOnly ? "applyRestartHintWebOnly" : "applyRestartHint") : "";
|
|
1583
1586
|
const lease = useLease("operation-card");
|
|
1584
1587
|
const restart = async () => {
|
|
1585
1588
|
// The yes is for the job this card shows: it restarts AgEnD for that job only, and only while the card stands.
|
|
1586
1589
|
const forJob = { opId: op.id, jobId: op.job && op.job.id };
|
|
1587
|
-
if (!(await ask(tn("restartFleetConfirm"), { title: tn("restartFleetButton"), confirmLabel: tn("restartFleetButton"), danger: true }))) return;
|
|
1590
|
+
if (!(await ask(tn(webOnly ? "restartFleetConfirmWebOnly" : "restartFleetConfirm"), { title: tn("restartFleetButton"), confirmLabel: tn("restartFleetButton"), danger: true }))) return;
|
|
1588
1591
|
if (!lease.current()) return;
|
|
1589
1592
|
setRestarting(true);
|
|
1590
1593
|
const res = await restartFleet(forJob);
|
|
@@ -213,12 +213,16 @@ async function watch(o, id) {
|
|
|
213
213
|
* A full AgEnD restart for a job that needs one: its own confirmation (the caller's), its own key, one at a time. The
|
|
214
214
|
* job's fleet row moves to "running" on the server; that job is watched again.
|
|
215
215
|
*/
|
|
216
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* POST /api/settings/restart-fleet for `jobId`, with its own key: { ok, status, body } (a lost answer: status 0). `jobId`
|
|
218
|
+
* null (S-92): the pending changes' own restart, when no Settings job carries it (a hand edit) — the server makes one.
|
|
219
|
+
* The confirmation is this request's value; the person only clicks (and answers the restart's own dialog).
|
|
220
|
+
*/
|
|
217
221
|
async function postRestart(jobId) {
|
|
218
222
|
const key = newKey("restart");
|
|
219
223
|
try {
|
|
220
224
|
return await api("/api/settings/restart-fleet", { method: "POST", headers: { "Idempotency-Key": key },
|
|
221
|
-
body: JSON.stringify({ job_id: jobId, confirm: "restart-agend", idempotency_key: key }) });
|
|
225
|
+
body: JSON.stringify({ ...(jobId ? { job_id: jobId } : { pending: true }), confirm: "restart-agend", idempotency_key: key }) });
|
|
222
226
|
} catch { return { ok: false, status: 0, body: null }; }
|
|
223
227
|
}
|
|
224
228
|
|
|
@@ -247,11 +251,14 @@ export async function restartFleet(forJob) {
|
|
|
247
251
|
* become the operation, so its card and line follow the restart as they follow any other (a refusal leaves the banner
|
|
248
252
|
* as it was). The caller asked first.
|
|
249
253
|
*/
|
|
250
|
-
export async function restartPendingChanges(
|
|
254
|
+
export async function restartPendingChanges(asked) {
|
|
251
255
|
if (operationActive()) return { ok: false, busy: true };
|
|
252
|
-
if (op && op.job && op.job.id ===
|
|
253
|
-
const res = await postRestart(
|
|
256
|
+
if (asked && op && op.job && op.job.id === asked) return restartFleet({ opId: op.id, jobId: asked });
|
|
257
|
+
const res = await postRestart(asked || null);
|
|
254
258
|
if (!res.ok || operationActive()) return res;
|
|
259
|
+
// The job that carries it: the one asked for, or (S-92) the one the server made for it.
|
|
260
|
+
const jobId = asked || (res.body && typeof res.body.job_id === "string" ? res.body.job_id : null);
|
|
261
|
+
if (!jobId) return res;
|
|
255
262
|
toast(t("settings.restartFleetStarted"));
|
|
256
263
|
let fresh = null;
|
|
257
264
|
try { fresh = await api(`/api/settings/apply/${encodeURIComponent(jobId)}`); } catch { fresh = null; }
|
|
@@ -45,7 +45,7 @@ register("devices", {
|
|
|
45
45
|
signOutOwnerOnly: "Only a device whose owner is verified can sign out another device.",
|
|
46
46
|
signOutTitle: "Sign out this device?", signOutLead: "{0} will have to sign in again.", signOutGo: "Sign out",
|
|
47
47
|
signedOut: "{0} was signed out.", alreadyGone: "That device is already signed out.",
|
|
48
|
-
notSaved: "Signed out for now, but the change could not be saved: a restart may bring the session back.
|
|
48
|
+
notSaved: "Signed out for now, but the change could not be saved: a restart may bring the session back. This page cannot repair session storage.",
|
|
49
49
|
authorityOff: "Web authorization is off, so no device is the owner: none can add a device or sign another one out.",
|
|
50
50
|
},
|
|
51
51
|
"zh-TW": {
|
|
@@ -71,7 +71,7 @@ register("devices", {
|
|
|
71
71
|
signOutOwnerOnly: "只有已驗證擁有者的裝置才能登出其他裝置。",
|
|
72
72
|
signOutTitle: "登出這台裝置?", signOutLead: "{0} 需要重新登入。", signOutGo: "登出",
|
|
73
73
|
signedOut: "已登出 {0}。", alreadyGone: "這台裝置已經登出了。",
|
|
74
|
-
notSaved: "
|
|
74
|
+
notSaved: "暫時登出了,但變更沒能儲存:重新啟動後這個工作階段可能會回來。這個頁面無法修復工作階段的儲存問題。",
|
|
75
75
|
authorityOff: "網頁授權已關閉,所以沒有任何裝置是擁有者:不能新增裝置,也不能登出其他裝置。",
|
|
76
76
|
},
|
|
77
77
|
});
|