@songsid/agend 2.4.0-alpha.4 → 2.4.0-beta.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 (109) hide show
  1. package/dist/agent-whats-new.js +1 -1
  2. package/dist/agent-whats-new.js.map +1 -1
  3. package/dist/auth-api.js +1 -0
  4. package/dist/auth-api.js.map +1 -1
  5. package/dist/build-provenance.json +1 -1
  6. package/dist/daemon.js +2 -1
  7. package/dist/daemon.js.map +1 -1
  8. package/dist/delivery-consumed-watch.d.ts +2 -0
  9. package/dist/delivery-consumed-watch.js +1 -1
  10. package/dist/delivery-consumed-watch.js.map +1 -1
  11. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +8 -2
  12. package/dist/general-knowledge/skills/hub/SKILL.md +53 -16
  13. package/dist/hub/catalog.d.ts +1 -1
  14. package/dist/hub/catalog.js +34 -10
  15. package/dist/hub/catalog.js.map +1 -1
  16. package/dist/hub/compose/server.d.ts +1 -0
  17. package/dist/hub/compose/server.js +6 -0
  18. package/dist/hub/compose/server.js.map +1 -1
  19. package/dist/hub/grant-access.js +23 -3
  20. package/dist/hub/grant-access.js.map +1 -1
  21. package/dist/hub/grant-search.js +13 -1
  22. package/dist/hub/grant-search.js.map +1 -1
  23. package/dist/hub/group-policy/impact-inventory.js +18 -2
  24. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  25. package/dist/hub/http/compose.js +76 -5
  26. package/dist/hub/http/compose.js.map +1 -1
  27. package/dist/hub/http/deps.d.ts +2 -0
  28. package/dist/hub/http/schema.js +2 -0
  29. package/dist/hub/http/schema.js.map +1 -1
  30. package/dist/hub/join/store.d.ts +5 -0
  31. package/dist/hub/join/store.js +12 -2
  32. package/dist/hub/join/store.js.map +1 -1
  33. package/dist/hub/person-prefs.d.ts +22 -0
  34. package/dist/hub/person-prefs.js +34 -0
  35. package/dist/hub/person-prefs.js.map +1 -0
  36. package/dist/hub/rooms/service.js +1 -1
  37. package/dist/hub/rooms/service.js.map +1 -1
  38. package/dist/hub/settings-member-address-decision.js +3 -1
  39. package/dist/hub/settings-member-address-decision.js.map +1 -1
  40. package/dist/hub/settings-member-address-http.js +3 -2
  41. package/dist/hub/settings-member-address-http.js.map +1 -1
  42. package/dist/hub/settings-member-address-policy.d.ts +3 -2
  43. package/dist/hub/settings-member-address-policy.js +3 -1
  44. package/dist/hub/settings-member-address-policy.js.map +1 -1
  45. package/dist/hub/settings-web-address-decision.js +3 -1
  46. package/dist/hub/settings-web-address-decision.js.map +1 -1
  47. package/dist/hub/settings-web-address-http.js +3 -2
  48. package/dist/hub/settings-web-address-http.js.map +1 -1
  49. package/dist/hub/settings-web-address-policy.d.ts +3 -2
  50. package/dist/hub/settings-web-address-policy.js +3 -1
  51. package/dist/hub/settings-web-address-policy.js.map +1 -1
  52. package/dist/hub/teams/grant-schema.d.ts +2 -0
  53. package/dist/hub/teams/grant-schema.js +13 -0
  54. package/dist/hub/teams/grant-schema.js.map +1 -0
  55. package/dist/hub/teams/index.d.ts +7 -0
  56. package/dist/hub/teams/index.js +273 -0
  57. package/dist/hub/teams/index.js.map +1 -0
  58. package/dist/hub/teams/store.d.ts +34 -0
  59. package/dist/hub/teams/store.js +57 -0
  60. package/dist/hub/teams/store.js.map +1 -0
  61. package/dist/hub/teams/types.d.ts +58 -1
  62. package/dist/hub/types.d.ts +3 -0
  63. package/dist/hub-pilot-trust-settings.d.ts +1 -1
  64. package/dist/hub-pilot-trust-settings.js +2 -2
  65. package/dist/hub-pilot-trust-settings.js.map +1 -1
  66. package/dist/locale.js +2 -0
  67. package/dist/locale.js.map +1 -1
  68. package/dist/transcript-needles.d.ts +4 -2
  69. package/dist/transcript-needles.js +35 -4
  70. package/dist/transcript-needles.js.map +1 -1
  71. package/dist/ui/hub-client.js +18 -5
  72. package/dist/ui/hub-grant-picker.js +14 -5
  73. package/dist/ui/hub-group-strings.js +3 -3
  74. package/dist/ui/hub-room-composer.js +12 -2
  75. package/dist/ui/hub-room-favorites.js +63 -5
  76. package/dist/ui/hub-room-strings.js +2 -0
  77. package/dist/ui/hub-room-thread.js +39 -13
  78. package/dist/ui/hub-strings.js +2 -0
  79. package/dist/ui/hub-teams-strings.js +34 -0
  80. package/dist/ui/hub-teams.js +169 -0
  81. package/dist/ui/panel-hub.js +34 -16
  82. package/dist/ui/settings-hub-member-address.js +21 -6
  83. package/dist/ui/settings-hub-section.js +2 -2
  84. package/dist/ui/settings-hub-web-address.js +21 -5
  85. package/dist/ui/settings-layout.js +5 -1
  86. package/dist/ui/shared/app-shell.js +40 -6
  87. package/dist/ui/shared/app.css +3 -0
  88. package/dist/ui/shared/chat-thread.js +2 -1
  89. package/dist/ui/shared/hub-chat.css +5 -0
  90. package/dist/ui/shared/hub-signin.css +2 -0
  91. package/dist/ui/shared/hub-teams.css +31 -0
  92. package/dist/ui/shared/page-head.js +3 -2
  93. package/dist/ui/shared/usage-dialog.js +2 -1
  94. package/dist/ui/shared/view-strings.js +2 -0
  95. package/dist/usage/agent-output.js +1 -0
  96. package/dist/usage/agent-output.js.map +1 -1
  97. package/dist/usage/i18n-keys.d.ts +1 -1
  98. package/dist/usage/i18n-keys.js +1 -1
  99. package/dist/usage/i18n-keys.js.map +1 -1
  100. package/dist/usage/i18n.d.ts +1 -1
  101. package/dist/usage/i18n.js +2 -1
  102. package/dist/usage/i18n.js.map +1 -1
  103. package/dist/usage/providers.d.ts +4 -1
  104. package/dist/usage/providers.js +25 -10
  105. package/dist/usage/providers.js.map +1 -1
  106. package/dist/usage/usage-api.d.ts +1 -1
  107. package/dist/usage/usage-api.js +4 -4
  108. package/dist/usage/usage-api.js.map +1 -1
  109. package/package.json +1 -1
@@ -0,0 +1,169 @@
1
+ /** Teams share one roster editor between Administration and the lead's My teams page. */
2
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
+ import { Icon } from "/assets/ui-icons.js";
4
+ import { navigate } from "/assets/app-nav.js";
5
+ import { ht } from "./hub-teams-strings.js";
6
+
7
+ const changes = new Set();
8
+ const changed = () => { for (const fn of changes) fn(); };
9
+ // Only a fallback for older/fixture servers without isLead; real sessions omit person.
10
+ const personId = person => typeof person === "string" ? person : person?.realm && person?.objectId ? `${person.realm}/${person.objectId}` : person?.id || "";
11
+ const leads = (row, me) => row.isLead === true || row.isLead === undefined && !!me && row.lead === me;
12
+ const errorText = (out, writing = false) => out?.status === 429 ? ht("busy") : out?.status === 401 || out?.status === 403 ? ht("denied") : ht(writing ? "saveFailed" : "failed");
13
+ const date = value => new Date(value).toLocaleDateString();
14
+ const cssLoads = new WeakMap();
15
+ /** No new editor controls draw before their fresh feature stylesheet has loaded. */
16
+ export function linkHubTeamsCss(doc = typeof document === "undefined" ? null : document) {
17
+ if (!doc?.head) return Promise.resolve(false);
18
+ if (cssLoads.has(doc)) return cssLoads.get(doc);
19
+ const promise = new Promise(resolve => {
20
+ const link = doc.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-teams.css");
21
+ link.setAttribute("data-hub-teams-css", "1");
22
+ link.addEventListener("load", () => resolve(true), { once: true });
23
+ link.addEventListener("error", () => { link.remove(); cssLoads.delete(doc); resolve(false); }, { once: true });
24
+ doc.head.appendChild(link);
25
+ });
26
+ cssLoads.set(doc, promise); return promise;
27
+ }
28
+ function useStyle() {
29
+ const [ready, setReady] = useState(null), [retry, setRetry] = useState(0);
30
+ useEffect(() => { let live = true; linkHubTeamsCss().then(value => { if (live) setReady(value); }); return () => { live = false; }; }, [retry]);
31
+ return [ready, () => { setReady(null); setRetry(n => n + 1); }];
32
+ }
33
+ function StyleWait({ ready, retry }) {
34
+ return html`<p role="status">${ht(ready === false ? "styleFailed" : "styleLoading")}</p>${ready === false ? html`<button type="button" class="btn" onClick=${retry}>${ht("retry")}</button>` : null}`;
35
+ }
36
+ function useTeams(client) {
37
+ const [rows, setRows] = useState(null), [error, setError] = useState(null), [revision, setRevision] = useState(0), epoch = useRef(0);
38
+ useEffect(() => {
39
+ let live = true; const mine = ++epoch.current;
40
+ Promise.resolve().then(() => client.teams()).then(out => { if (!live || mine !== epoch.current) return;
41
+ if (out.ok) { setRows(Array.isArray(out.teams) ? out.teams : []); setError(null); } else setError(errorText(out));
42
+ }, () => { if (live && mine === epoch.current) setError(ht("failed")); });
43
+ const end = client.onSignedOut?.(() => { epoch.current++; setRows([]); setError(ht("denied")); });
44
+ const refresh = () => setRevision(n => n + 1); changes.add(refresh);
45
+ return () => { live = false; epoch.current++; changes.delete(refresh); end?.(); };
46
+ }, [client, revision]);
47
+ return { rows, error, refresh: () => setRevision(n => n + 1) };
48
+ }
49
+ export function HubTeamsEntry() {
50
+ const [ready, retry] = useStyle();
51
+ return html`<section class="card hub-teams"><h3>${ht("title")}</h3><p class="note">${ht("lead")}</p>
52
+ ${ready ? html`<a class="btn hub-team-button" href="/ui/hub/admin?view=teams" onClick=${e => { if (!e.metaKey && !e.ctrlKey) { e.preventDefault(); navigate("/ui/hub/admin?view=teams"); } }}>${ht("manage")}</a>` : html`<${StyleWait} ready=${ready} retry=${retry} />`}</section>`;
53
+ }
54
+ export function HubMyTeamsEntry({ client, person, active, onPick }) {
55
+ const { rows } = useTeams(client), me = personId(person);
56
+ if (!rows?.some(row => leads(row, me))) return null;
57
+ const href = "/ui/hub?view=teams";
58
+ return html`<a class=${`side-row${active ? " active" : ""}`} href=${href} aria-current=${active ? "page" : undefined}
59
+ onClick=${e => { if (e.metaKey || e.ctrlKey) return; e.preventDefault(); onPick?.(); navigate(href); }}><${Icon} name="user" /><span class="grow">${ht("mine")}</span></a>`;
60
+ }
61
+
62
+ /** Feedback is cancellable and never applies a result from a previous query or team. */
63
+ export function TeamSuggestions({ client, kind = "person", teamId, disabled, onPick }) {
64
+ const [query, setQuery] = useState(""), [answer, setAnswer] = useState(null), [busy, setBusy] = useState(false), epoch = useRef(0), controller = useRef(null);
65
+ useEffect(() => { epoch.current++; controller.current?.abort(); setAnswer(null); setBusy(false);
66
+ return () => { epoch.current++; controller.current?.abort(); }; }, [client, kind, teamId]);
67
+ const search = async () => {
68
+ const q = query.trim(); if (disabled || q.length < 2 || q.length > 64) return;
69
+ const mine = ++epoch.current; controller.current?.abort(); const current = controller.current = new AbortController(); setBusy(true); setAnswer(null);
70
+ let out; try { out = await client.teamSuggestions(kind, q, teamId, current.signal); } catch { out = { ok: false }; }
71
+ if (mine !== epoch.current || current.signal.aborted) return;
72
+ setBusy(false); setAnswer(out);
73
+ };
74
+ const hits = answer?.ok && Array.isArray(answer.candidates) ? answer.candidates.slice(0, 20).filter(row => row.kind === kind) : [];
75
+ return html`<div class="hub-team-search">
76
+ <div class="hub-team-search-line"><label class="field grow"><span>${ht(kind === "group" ? "department" : "members")}</span><input type="search" maxlength="64" autocomplete="off" spellcheck=${false}
77
+ placeholder=${ht(kind === "group" ? "departmentQuery" : "personQuery")} value=${query} disabled=${disabled}
78
+ onInput=${e => { epoch.current++; controller.current?.abort(); setQuery(e.target.value); setAnswer(null); setBusy(false); }}
79
+ onKeyDown=${e => { if (e.key === "Enter") { e.preventDefault(); void search(); } }} /></label>
80
+ <button type="button" class="btn hub-team-button" disabled=${disabled || busy || query.trim().length < 2 || query.trim().length > 64} onClick=${search}>${ht("search")}</button></div>
81
+ <p class="note" role="status">${busy ? ht("searching") : !answer ? ht(kind === "group" ? "groupHint" : "searchHint") : !answer.ok ? answer.status === 429 ? ht("busy") : ht("searchFailed") : hits.length ? "" : ht("noMatches")}</p>
82
+ ${hits.length ? html`<ul class="hub-team-hits">${hits.map(row => html`<li key=${row.id}><span class="grow"><strong>${row.name}</strong>${row.login ? html`<small class="note"> · ${row.login}</small>` : null}</span>
83
+ <button type="button" class="btn hub-team-button" disabled=${disabled} aria-label=${ht("choose", row.name)} onClick=${() => { epoch.current++; controller.current?.abort(); onPick(row); setQuery(""); setAnswer(null); }}>${ht("pick")}</button></li>`)}</ul>` : null}
84
+ </div>`;
85
+ }
86
+ const draftFrom = team => ({ name: team?.name || "", department: team?.department || "", departmentName: team?.departmentName || "", lead: team?.lead || "",
87
+ members: (team?.memberInfo || (team?.members || []).map(id => ({ id, name: id }))).map(row => ({ ...row })) });
88
+ const editableImage = draft => JSON.stringify([draft.name.trim(), draft.department, draft.lead, draft.members.map(row => row.id).sort()]);
89
+ function TeamEditor({ client, id, mode, onSaved, onBack }) {
90
+ const [view, setView] = useState(null), [draft, setDraft] = useState(draftFrom(null)), [error, setError] = useState(null), [busy, setBusy] = useState(false), [picker, setPicker] = useState(id ? null : "department"), [deleting, setDeleting] = useState(false), [reload, setReload] = useState(0), [saved, setSaved] = useState(false);
91
+ const epoch = useRef(0), writing = useRef(false), admin = mode === "admin";
92
+ useEffect(() => {
93
+ let live = true; const mine = ++epoch.current;
94
+ if (id) Promise.resolve().then(() => client.team(id)).then(out => {
95
+ if (!live || mine !== epoch.current) return;
96
+ if (out.ok && out.team) { setView(out.team); setDraft(draftFrom(out.team)); setError(null); setPicker(null); }
97
+ else setError(errorText(out));
98
+ }, () => { if (live && mine === epoch.current) setError(ht("failed")); });
99
+ const end = client.onSignedOut?.(() => { epoch.current++; setView(null); setError(ht("denied")); });
100
+ return () => { live = false; epoch.current++; end?.(); };
101
+ }, [client, id, reload]);
102
+ const allowed = !id || view?.canManage === true;
103
+ const dirty = editableImage(draft) !== editableImage(draftFrom(view));
104
+ const save = async e => {
105
+ e?.preventDefault?.(); if (writing.current || !allowed || !draft.lead || !draft.department || !draft.name.trim()) return;
106
+ writing.current = true; setBusy(true); setError(null); setSaved(false); const mine = ++epoch.current;
107
+ const members = [...new Set([...draft.members.map(row => row.id), draft.lead])];
108
+ const value = admin ? { name: draft.name.trim(), department: draft.department, lead: draft.lead, members } : { members };
109
+ let out; try { out = id ? await client.updateTeam(id, { ...value, revision: view.revision }) : await client.createTeam(value); } catch { out = { ok: false }; }
110
+ if (mine !== epoch.current) return;
111
+ writing.current = false; setBusy(false);
112
+ if (out.ok && out.team) {
113
+ // Writes may return only the stored Team. Keep known display metadata until
114
+ // the fenced detail read supplies current names, permissions and status.
115
+ const detailed = Array.isArray(out.team.memberInfo);
116
+ const next = detailed ? out.team : { ...view, ...out.team, departmentName: draft.departmentName,
117
+ memberInfo: out.team.members.map(id => draft.members.find(row => row.id === id) || { id, name: id }) };
118
+ setView(next); setDraft(draftFrom(next)); setSaved(true); setPicker(null); changed(); onSaved(out.team);
119
+ if (id && !detailed) setReload(n => n + 1);
120
+ }
121
+ else setError(errorText(out, true));
122
+ };
123
+ const remove = async () => {
124
+ if (writing.current || !admin || !id) return;
125
+ writing.current = true; setBusy(true); setError(null); const mine = ++epoch.current;
126
+ let out; try { out = await client.deleteTeam(id); } catch { out = { ok: false }; }
127
+ if (mine !== epoch.current) return; writing.current = false; setBusy(false);
128
+ if (out.ok) { changed(); onBack(); } else setError(errorText(out, true));
129
+ };
130
+ const pick = row => {
131
+ setSaved(false);
132
+ if (picker === "department") setDraft(old => ({ ...old, department: row.id, departmentName: row.name }));
133
+ else setDraft(old => ({ ...old, ...(picker === "lead" ? { lead: row.id } : {}), members: old.members.some(member => member.id === row.id) ? old.members : [...old.members, row] }));
134
+ setPicker(null);
135
+ };
136
+ return html`<section class="card hub-team-editor"><div class="hub-team-head"><h3>${ht(id ? "edit" : "create", view?.name || draft.name)}</h3><button type="button" class="btn hub-team-button" disabled=${busy} onClick=${onBack}>${ht("back")}</button></div>
137
+ ${error ? html`<p class="err" role="alert">${error}</p><button type="button" class="btn hub-team-button" disabled=${busy} onClick=${() => setReload(n => n + 1)}>${ht("refresh")}</button>` : null}
138
+ ${id && !view ? html`<p role="status">${ht("loading")}</p>` : html`<form class="form" onSubmit=${save}>
139
+ ${admin ? html`<label class="field"><span>${ht("name")}</span><input data-team-name maxlength="100" required value=${draft.name} disabled=${busy || !allowed} onInput=${e => { setDraft(old => ({ ...old, name: e.target.value })); setSaved(false); }} /></label>` : null}
140
+ <div class="hub-team-head"><p class="note">${ht("departmentLine", draft.departmentName || ht("chooseDepartment"))}</p>${admin ? html`<button type="button" class="btn hub-team-button" disabled=${busy || !allowed} onClick=${() => setPicker("department")}>${ht("change")}</button>` : null}</div>
141
+ ${view?.leadEligible === false ? html`<p class="warn" role="status">${ht("disabledLead")}</p>` : null}
142
+ ${admin ? html`<div class="hub-team-head"><p>${ht("leadPerson")}: <strong>${draft.members.find(row => row.id === draft.lead)?.name || ht("chooseLead")}</strong></p><button type="button" class="btn hub-team-button" disabled=${busy || !allowed} onClick=${() => setPicker("lead")}>${ht("chooseLead")}</button></div>` : null}
143
+ ${picker ? html`<div class="hub-team-picker"><${TeamSuggestions} key=${picker} client=${client} kind=${picker === "department" ? "group" : "person"} teamId=${id || undefined} disabled=${busy || !allowed} onPick=${pick} /><button type="button" class="btn hub-team-button" onClick=${() => setPicker(null)}>${ht("cancel")}</button></div>` : null}
144
+ <div class="hub-team-head"><h4>${ht("members")} · ${draft.members.length}</h4><button type="button" class="btn hub-team-button" disabled=${busy || !allowed || draft.members.length >= 200} onClick=${() => setPicker("member")}>${ht("add")}</button></div>
145
+ <p class="note">${ht("limit")} ${ht("leadRequired")}</p>
146
+ <div class="hub-team-table-wrap"><table class="hub-team-table"><thead><tr><th>${ht("members")}</th><th>${ht("role")}</th><th>${ht("signedIn")}</th><th>${ht("agents")}</th><th><span class="sr-only">${ht("remove")}</span></th></tr></thead><tbody>
147
+ ${draft.members.map(row => html`<tr key=${row.id}><td><strong>${row.name}</strong>${row.login ? html`<small class="note hub-team-detail">${row.login}</small>` : null}${row.department ? html`<small class="note hub-team-detail">${row.department}</small>` : null}</td><td data-label=${ht("role")}>${ht(row.id === draft.lead ? "roleLead" : "roleMember")}</td>
148
+ <td data-label=${ht("signedIn")}>${row.signedIn === true ? ht("yes") : row.signedIn === false ? ht("notYet") : ht("unobserved")}</td><td data-label=${ht("agents")}>${row.agents?.length ? row.agents.map(agent => agent.name).join(", ") : ht("none")}</td><td><button type="button" class="btn hub-team-button" disabled=${busy || !allowed || row.id === draft.lead || row.id === view?.lead} aria-label=${`${ht("remove")} ${row.name}`} onClick=${() => { setDraft(old => ({ ...old, members: old.members.filter(member => member.id !== row.id) })); setSaved(false); }}>${ht("remove")}</button></td></tr>`)}
149
+ </tbody></table></div>
150
+ <div class="hub-team-actions"><button type="submit" class="btn btn-primary hub-team-button" disabled=${busy || !allowed || !draft.name.trim() || !draft.department || !draft.lead}>${ht(busy ? "saving" : "save")}</button>${dirty || saved ? html`<span role="status">${ht(dirty ? "unsaved" : "saved")}</span>` : null}
151
+ ${admin && id ? html`<button type="button" class="btn btn-danger hub-team-button" disabled=${busy || !allowed} onClick=${() => setDeleting(true)}>${ht("delete")}</button>` : null}</div>
152
+ </form>`}
153
+ ${deleting ? html`<div class="hub-team-delete" role="region" aria-label=${ht("deleteTitle", view.name)}><h4>${ht("deleteTitle", view.name)}</h4><p>${ht("deleteLead")}</p>
154
+ ${view.impact?.grants?.length || view.impact?.roomCreator ? html`<ul>${view.impact.grants.map(grant => html`<li>${ht("grantExpiry", grant.name, date(grant.expiresAt))}</li>`)}${view.impact.roomCreator ? html`<li>${ht("creators")}</li>` : null}</ul>` : html`<p class="note">${ht("noImpact")}</p>`}
155
+ <div class="hub-team-actions"><button type="button" class="btn hub-team-button" disabled=${busy} onClick=${() => setDeleting(false)}>${ht("cancel")}</button><button type="button" class="btn btn-danger hub-team-button" disabled=${busy} onClick=${remove}>${ht("delete")}</button></div></div>` : null}
156
+ </section>`;
157
+ }
158
+ export function HubTeamsPage({ client, mode = "lead", person }) {
159
+ const [ready, retry] = useStyle(), { rows, error, refresh } = useTeams(client), [selected, setSelected] = useState(null), me = personId(person);
160
+ const shown = (rows || []).filter(row => mode === "admin" || leads(row, me));
161
+ return html`<div class="hub-teams"><p class="s-page-lead hub-page-lead">${ht(mode === "admin" ? "pageLead" : "myLead")}</p>
162
+ ${!ready ? html`<${StyleWait} ready=${ready} retry=${retry} />` : html`<div class="s-section-layout">
163
+ ${selected !== null ? html`<${TeamEditor} key=${selected} client=${client} id=${selected || null} mode=${mode} onBack=${() => { setSelected(null); refresh(); }} onSaved=${team => { setSelected(team.id); refresh(); }} />`
164
+ : html`<section class="card"><div class="hub-team-head"><h3>${ht(mode === "admin" ? "title" : "mine")}</h3>${mode === "admin" ? html`<button type="button" class="btn btn-primary hub-team-button" onClick=${() => setSelected("")}>${ht("create")}</button>` : null}</div>
165
+ ${error ? html`<p class="err" role="alert">${error}</p><button type="button" class="btn hub-team-button" onClick=${refresh}>${ht("retry")}</button>` : null}
166
+ ${rows === null ? html`<p role="status">${ht("loading")}</p>` : shown.length ? html`<ul class="hub-team-list">${shown.map(row => html`<li key=${row.id}><span class="grow"><strong>${row.name}</strong><small class="note hub-team-detail">${ht("departmentLine", row.departmentName)} · ${ht("count", row.members.length)}</small></span><button type="button" class="btn hub-team-button" aria-label=${ht("edit", row.name)} onClick=${() => setSelected(row.id)}>${ht("manage")}</button></li>`)}</ul>` : html`<p class="note">${ht(mode === "admin" ? "empty" : "noMine")}</p>`}
167
+ </section>`}
168
+ </div>`}</div>`;
169
+ }
@@ -35,10 +35,12 @@ import { compareGroups, hubClient } from "./hub-client.js";
35
35
  import { hw, linkHubCss } from "./hub-strings.js";
36
36
  import { hc, linkHubChatCss } from "./hub-chat-strings.js";
37
37
  import { HubRoomRows, readRoomList } from "./hub-room-list.js";
38
- import { useRoomStar } from "./hub-room-favorites.js";
38
+ import * as roomFavorites from "./hub-room-favorites.js";
39
+ const { useRoomStar } = roomFavorites;
39
40
  import { HubRoomPage } from "./hub-room-thread.js";
40
41
  import { hroom } from "./hub-room-strings.js";
41
42
  import { hr } from "./hub-read-strings.js";
43
+ import { ht } from "./hub-teams-strings.js";
42
44
  import { ho, linkHubOwnerCss } from "./hub-owner-strings.js";
43
45
  import { hg } from "./hub-grant-strings.js";
44
46
  import { createHubChatStore } from "./hub-chat-store.js";
@@ -53,8 +55,8 @@ register("hubAccess", {
53
55
  const ha = key => t(`hubAccess.${key}`);
54
56
  // Kept with the fresh renderer: retained owner dictionaries do not know this label.
55
57
  register("hubGrantStatus", {
56
- en: { grantNeverSignedIn: "Hasn't signed in to Hub yet", grantADGroup: "AD group", grantSubjects: "People and groups allowed: {0}" },
57
- "zh-TW": { grantNeverSignedIn: "還沒登入過 Hub", grantADGroup: "AD 群組", grantSubjects: "已允許的個人與群組:{0}" },
58
+ en: { grantNeverSignedIn: "Hasn't signed in to Hub yet", grantADGroup: "AD group", grantTeam: "Team", grantSubjects: "People, groups and teams allowed: {0}" },
59
+ "zh-TW": { grantNeverSignedIn: "還沒登入過 Hub", grantADGroup: "AD 群組", grantTeam: "團隊", grantSubjects: "已允許的個人、群組與團隊:{0}" },
58
60
  });
59
61
 
60
62
  // These words travel with the renderer; retained dictionaries need no new exports.
@@ -101,6 +103,7 @@ const sessionSubs = new Set();
101
103
  function setSession(next) {
102
104
  const was = session;
103
105
  session = next;
106
+ roomFavorites.configureHubFavorites?.(hubClient(), next);
104
107
  // #3226 B: the conversation list is this person's: cleared when no one is signed in, read again when someone is.
105
108
  if (!next) roomsStore.set({ loaded: false, rooms: [], error: null });
106
109
  else if (!was || was.login !== next.login) void refreshRooms();
@@ -140,8 +143,8 @@ export function HubPanel({ route }) {
140
143
  // The owner stylesheet holds the page column (.hub-owner, 860 px) every page with a column uses — Notices too (Argon #12).
141
144
  useEffect(() => { linkHubCss(); linkHubOwnerCss(); if (tab === "ask") linkHubChatCss(); }, [tab]);
142
145
  // Join takes precedence over other query views. Rooms and Group permissions otherwise name their own pages.
143
- const pageName = companyPage ? hj("title") : tab === "exposures" ? hc("mine") : tab === "admin" ? hc("admin") : view === "notices" ? hc("noticesTitle")
144
- : view === "invitations" ? hroom("invitationsTitle") : hc("chats");
146
+ const pageName = companyPage ? hj("title") : tab === "exposures" ? hc("mine") : tab === "admin" ? view === "teams" ? ht("title") : hc("admin") : view === "notices" ? hc("noticesTitle")
147
+ : view === "invitations" ? hroom("invitationsTitle") : view === "teams" ? ht("mine") : hc("chats");
145
148
  useEffect(() => { if (companyPage || !(tab === "ask" && roomParam()) && !(tab === "admin" && view === "groups")) setTitle(pageName); }, [tab, view, pageName, roomParam(), companyPage]);
146
149
  let body = tab === "ask" ? roomParam() ? html`<${HubRoomLoading} />`
147
150
  : html`<${PanelHeader} title=${hc("chats")} /><div class="hub-home"><${Skeleton} variant="rows" lines=${4} /></div>`
@@ -162,6 +165,9 @@ export function HubPanel({ route }) {
162
165
  if (s && tab === "ask" && view === "invitations" && roomsLive()) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-invitations">
163
166
  <${PanelHeader} title=${hroom("invitationsTitle")} /><div data-trust="panel-content" class="panel-body hub-page-body"><div class="col hub-owner">
164
167
  <${LazyRoomPart} load=${() => import("./hub-invitations.js")} name="InvitationsList" props=${{ client: hubClient(), heading: false }} /></div></div></div>`;
168
+ if (s && tab === "ask" && view === "teams" && teamsLive()) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-teams">
169
+ <${PanelHeader} title=${ht("mine")} /><div data-trust="panel-content" class="panel-body hub-page-body"><div class="col hub-owner">
170
+ <${LazyRoomPart} load=${() => import("./hub-teams.js")} name="HubTeamsPage" props=${{ client: hubClient(), mode: "lead", person: s.person }} /></div></div></div>`;
165
171
  // The chats draw their own header (the room's); the other pages keep the panel's.
166
172
  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>`;
167
173
  // #3226 C: My shared agents and Administration are Settings-like pages. The panel's header names the page once, its scope
@@ -255,6 +261,7 @@ function HubSignIn() {
255
261
  <div class="hub-signin-brand"><strong>${t("hubShell.brand")}</strong>${name ? html`<span>${name}</span>` : null}</div>
256
262
  <h1 id="hubSignInTitle">${hw("signInTitle")}</h1>
257
263
  ${company.requestId ? html`<${CompanyJoinLead} context=${company.view?.ok ? company.view : null} />` : html`<p class="hub-signin-lead">${hw("signInLead")}</p>`}
264
+ <p class="note hub-signin-preview">${hw("signInPreview")}</p>
258
265
  ${company.requestId && company.view === undefined ? html`<${Skeleton} variant="form" lines=${2} label=${hj("loading")} />` : company.requestId && company.view && !company.view.ok ? html`<${ErrorState} message=${joinError(company.view.code)} onRetry=${company.retry} />` : null}
259
266
  ${!company.requestId || company.view?.ok && company.view.state === "pending" ? html`<form class="hub-signin-form" onSubmit=${submit}>
260
267
  <label for="hubLogin">${hw("login")}</label>
@@ -317,6 +324,7 @@ const viewParam = () => { try { return new URLSearchParams(location.search).get(
317
324
  export const NOTICES_PATH = "/ui/hub?view=notices";
318
325
  /** M-3092: the owner's invitations (spec §8). */
319
326
  export const INVITATIONS_PATH = "/ui/hub?view=invitations";
327
+ export const MY_TEAMS_PATH = "/ui/hub?view=teams";
320
328
  const pairingNoticesOffered = (s) => !!s && Array.isArray(s.features) && s.features.includes("quick-pairing-v1") && !!hubClient().quickPairingV1;
321
329
  const noticesOffered = s => pairingNoticesOffered(s) || directoryNoticesOffered(s, hubClient());
322
330
  const initial = (name) => (String(name || "?").trim()[0] || "?").toUpperCase();
@@ -386,7 +394,7 @@ export function HubSide({ onPick } = {}) {
386
394
  if (!s) return null;
387
395
  const tab = route && route.panel === "hub" ? route.tab : "ask";
388
396
  const view = viewParam();
389
- const here = (key) => key === "notices" || key === "invitations" ? tab === "ask" && view === key : key === "ask" ? tab === "ask" && view !== "notices" && view !== "invitations" : tab === key;
397
+ const here = (key) => ["notices", "invitations", "teams"].includes(key) ? tab === "ask" && view === key : key === "ask" ? tab === "ask" && view !== "notices" && view !== "invitations" && view !== "teams" : tab === key;
390
398
  const go = (e, href) => { if (onPick) onPick(); if (e && (e.metaKey || e.ctrlKey)) return; e && e.preventDefault(); navigate(href); };
391
399
  const row = (key, href, icon, label) => html`<a class=${`side-row${here(key) ? " active" : ""}`} href=${href} aria-current=${here(key) ? "page" : undefined}
392
400
  onClick=${(e) => go(e, href)}><${Icon} name=${icon} /><span class="grow">${label}</span></a>`;
@@ -395,10 +403,11 @@ export function HubSide({ onPick } = {}) {
395
403
  return html`<nav data-trust="navigation" class="side-nav" aria-label=${t("app.menu")}>
396
404
  ${row("ask", "/ui/hub", "chat", hc("chats"))}
397
405
  ${row("exposures", "/ui/hub/exposures", "globe", hc("mine"))}
398
- ${s.admin ? row("admin", "/ui/hub/admin", "key", hc("admin")) : null}
399
- ${noticesOffered(s) ? row("notices", NOTICES_PATH, "bell", hc("notices")) : null}
406
+ ${teamsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-teams.js")} name="HubMyTeamsEntry" props=${{ client: hubClient(), person: s.person, active: here("teams"), onPick }} />` : null}
400
407
  ${roomsLive() && rs.invitations > 0 ? html`<a class=${`side-row${here("invitations") ? " active" : ""}`} href=${INVITATIONS_PATH} aria-current=${here("invitations") ? "page" : undefined}
401
408
  onClick=${(e) => go(e, INVITATIONS_PATH)}><${Icon} name="inbox" /><span class="grow">${hroom("invitationsTitle")}</span><span class="nav-count" title=${hroom("invitationsN", String(rs.invitations))}>${rs.invitations}</span></a>` : null}
409
+ ${s.admin ? row("admin", "/ui/hub/admin", "key", hc("admin")) : null}
410
+ ${noticesOffered(s) ? row("notices", NOTICES_PATH, "bell", hc("notices")) : null}
402
411
  <button type="button" class="side-row side-search" onClick=${openFilter} title=${`${hc("search")} (${searchShortcut()})`}
403
412
  aria-keyshortcuts=${isMacLike() ? "Meta+K" : "Control+K"}><${Icon} name="search" /><span class="grow">${hc("navSearch")}</span><kbd class="kbd-hint" aria-hidden="true">${searchShortcut()}</kbd></button>
404
413
  <button type="button" class="side-row side-new" onClick=${() => setPicking(true)}><${Icon} name="plus" /><span class="grow">${hc("newChat")}</span></button>
@@ -416,7 +425,7 @@ export function HubSide({ onPick } = {}) {
416
425
  * count, one-line empty states) — the sidebar's (HubSide) and, on a phone, the chats' home page's (with its own New chat
417
426
  * row and the filter always shown): one drawing, not two (Argon #9). `quietEmpty`: the page beside it already says "No chats yet".
418
427
  */
419
- function HubRoomList({ rs, q, setQ, filtering, setFiltering, filterRef, onPick, quietEmpty = false, onNew = null }) {
428
+ function HubRoomList({ rs, q, setQ, filtering, setFiltering, filterRef, onPick, quietEmpty = false, onNew = null, onNewRoom = null }) {
420
429
  const current = roomParam();
421
430
  const star = useRoomStar(rs.rooms, useSession()?.login); // S-145: favourites, as the Fleet sidebar's
422
431
  const go = (e, href) => { if (onPick) onPick(); if (e && (e.metaKey || e.ctrlKey)) return; e && e.preventDefault(); navigate(href); };
@@ -424,6 +433,8 @@ function HubRoomList({ rs, q, setQ, filtering, setFiltering, filterRef, onPick,
424
433
  const always = !!onNew; // the home page's list: its filter is always there (when there's a list to filter)
425
434
  return html`<div class="view-roster inst-nav hub-side-rooms"><div data-trust="navigation" class="side-section">
426
435
  ${onNew ? html`<button type="button" class="side-row side-new" onClick=${onNew}><${Icon} name="plus" /><span class="grow">${hc("newChat")}</span></button>` : null}
436
+ ${/* Lumen (spec §2): on the phone's list too, beside New chat — not only in the drawer. */ ""}
437
+ ${onNewRoom ? html`<button type="button" class="side-row side-new hub-new-room" onClick=${onNewRoom}><${Icon} name="room" /><span class="grow">${hroom("newRoomTitle")}</span></button>` : null}
427
438
  ${!rs.rooms.length ? html`<div class="inst-head"><h2 class="side-label">${hc("chats")}</h2></div>` : null}
428
439
  ${filtering || q || (always && rs.rooms.length) ? html`<label class="hub-side-filter"><${Icon} name="search" size=${14} /><input ref=${filterRef} type="search" placeholder=${hc("search")} aria-label=${hc("search")} value=${q}
429
440
  onInput=${(e) => setQ(e.target.value)} onKeyDown=${(e) => { if (e.key === "Escape") { setQ(""); setFiltering(false); } }} /></label>` : null}
@@ -438,10 +449,13 @@ function HubRoomList({ rs, q, setQ, filtering, setFiltering, filterRef, onPick,
438
449
  /** The phone's chats home: the same roster, with New chat at its head and the filter in place. */
439
450
  function HubHomeList() {
440
451
  const rs = useRooms();
441
- const [q, setQ] = useState(""), [filtering, setFiltering] = useState(false), [picking, setPicking] = useState(false);
452
+ const [q, setQ] = useState(""), [filtering, setFiltering] = useState(false), [picking, setPicking] = useState(false), [newRoom, setNewRoom] = useState(false);
442
453
  const filter = useRef(null);
443
- return html`<${HubRoomList} rs=${rs} q=${q} setQ=${setQ} filtering=${filtering} setFiltering=${setFiltering} filterRef=${filter} onNew=${() => setPicking(true)} />
444
- ${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}`;
454
+ return html`<${HubRoomList} rs=${rs} q=${q} setQ=${setQ} filtering=${filtering} setFiltering=${setFiltering} filterRef=${filter} onNew=${() => setPicking(true)}
455
+ onNewRoom=${roomsLive() && rs.me?.canCreateRooms ? () => setNewRoom(true) : null} />
456
+ ${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}
457
+ ${newRoom ? html`<${LazyRoomPart} load=${() => import("./hub-room-new.js")} name="NewRoomDialog" props=${{ client: hubClient(), assistant: !!rs.me?.assistant,
458
+ onClose: () => setNewRoom(false), onOpenRoom: (id) => { setNewRoom(false); void refreshRooms(); navigate(roomPath(id)); } }} />` : null}`;
445
459
  }
446
460
 
447
461
  /**
@@ -515,7 +529,8 @@ function HubChats() {
515
529
  const room = id ? (listed ? listed.legacy || listed : rs.loaded ? { id, exposureName: "", ownerName: "", features: [] } : null) : null;
516
530
  // A room of a Hub with rooms: the shared thread with the room's store, composer and members panel (hub-room-thread.js).
517
531
  if (id && listed && !listed.legacy) return html`<${HubRoomPage} key=${id} roomId=${id} listed=${listed} Thread=${HubThread} client=${hubClient()}
518
- rooms=${rs.rooms} openRoom=${(rid) => navigate(roomPath(rid))} />`;
532
+ rooms=${rs.rooms} openRoom=${(rid) => navigate(roomPath(rid))} goList=${() => navigate("/ui/hub")}
533
+ onLeft=${() => { void refreshRooms(); navigate("/ui/hub"); }} />`;
519
534
  if (id && room) return html`<${HubRoomView} key=${id} room=${room} />`;
520
535
  if (id) return html`<${HubRoomLoading} error=${rs.error} />`;
521
536
  return html`<${PanelHeader} title=${hc("chats")} />
@@ -787,7 +802,7 @@ const stateTag = (state) => state === "published" ? html`<span class="tag ok">${
787
802
  : state === "paused" ? html`<span class="tag warn">${t("hubSharing.paused")}</span>`
788
803
  : state === "frozen" ? html`<span class="tag warn">${ho("statePaused")}</span>` : html`<span class="tag">${ho("stateWithdrawn")}</span>`;
789
804
  const mayAsk = (n) => (n === 0 ? ho("mayAskNone") : n === 1 ? ho("mayAskOne") : ho("mayAsk", n));
790
- const grantSummary = (grants = []) => grants.some(g => g.subject?.kind === "group") ? t("hubGrantStatus.grantSubjects", grants.length) : mayAsk(grants.length);
805
+ const grantSummary = (grants = []) => grants.some(g => ["group", "team"].includes(g.subject?.kind)) ? t("hubGrantStatus.grantSubjects", grants.length) : mayAsk(grants.length);
791
806
  const agentParam = () => { try { const v = new URLSearchParams(location.search).get("agent"); return v && /^[a-f0-9-]{36}$/.test(v) ? v : null; } catch { return null; } };
792
807
 
793
808
  /**
@@ -887,7 +902,7 @@ function HubAgentPage({ x, act, msg }) {
887
902
  <section class="card"><div class="hub-card-head"><h3>${ho("whoMayAsk")}</h3>${shared ? html`<button type="button" class="btn btn-sm" onClick=${() => setAllowing(true)}><${Icon} name="plus" size=${14} />${ho("allow")}</button>` : null}</div>
888
903
  ${grants.length ? html`<div class="hub-rows">${grants.map((g) => html`<div key=${g.id} class="s-row hub-row">
889
904
  <${Avatar} name=${g.subjectName || g.subjectLogin} size="sm" />
890
- <span class="hub-row-text"><strong>${g.subjectName || g.subjectLogin}</strong><small class="note">${g.subjectLogin ? html`<code>${g.subjectLogin}</code> · ` : null}${ho("untilLeft", dateOnly(g.expiresAt), DAYS_LEFT(g.expiresAt))}</small>${g.subject?.kind === "group" ? html`<small class="tag">${t("hubGrantStatus.grantADGroup")}</small>` : g.subjectSignedIn === false ? html`<small class="tag warn">${t("hubGrantStatus.grantNeverSignedIn")}</small>` : null}</span>
905
+ <span class="hub-row-text"><strong>${g.subjectName || g.subjectLogin}</strong><small class="note">${g.subjectLogin ? html`<code>${g.subjectLogin}</code> · ` : null}${ho("untilLeft", dateOnly(g.expiresAt), DAYS_LEFT(g.expiresAt))}</small>${g.subject?.kind === "group" ? html`<small class="tag">${t("hubGrantStatus.grantADGroup")}</small>` : g.subject?.kind === "team" ? html`<small class="tag">${t("hubGrantStatus.grantTeam")}</small>` : g.subjectSignedIn === false ? html`<small class="tag warn">${t("hubGrantStatus.grantNeverSignedIn")}</small>` : null}</span>
891
906
  <${Menu} label=${ho("rowMenu", g.subjectName || g.subjectLogin)} items=${[{ key: "revoke", label: ho("revokeItem"), icon: "trash", danger: true, onSelect: () => revoke(g) }]} />
892
907
  </div>`)}</div>` : html`<p class="note">${roomCount > 0 ? hroom("agentNoOneToOne") : hw("noGrants")}</p>`}
893
908
  ${roomCount > 0 ? html`<p class="note hub-rooms-can-ask">${hroom("roomsCanAskIt")}</p>` : null}
@@ -958,6 +973,7 @@ function HubAdmin({ admin }) {
958
973
  const directory = s?.features?.includes("directory-editor-v1") && hubClient()?.directoryEditorV1 === true;
959
974
  if (directory && adminView() === "directory") return html`<${LazyDirectory} session=${s} />`;
960
975
  if (groupPolicyOn(s, hubClient()) && adminView() === "groups") return html`<${LazyGroups} pick=${(m) => m.HubGroupPolicyPage} props=${{}} />`;
976
+ if (teamsLive() && adminView() === "teams") return html`<div class="col hub-owner"><h2 class="sr-only">${ht("title")}</h2><${LazyRoomPart} load=${() => import("./hub-teams.js")} name="HubTeamsPage" props=${{ client: hubClient(), mode: "admin", person: s?.person }} /></div>`;
961
977
  // Reached from a fleet's Settings link on a Hub (or a tab) without group permissions: say so instead of a silent admin page.
962
978
  const unavailable = adminView() === "groups" && !groupPolicyOn(s, hubClient());
963
979
  return html`${unavailable ? html`<p class="note" role="status" data-groups="unavailable">${t("hubGroupsNote.unavailable")}</p>` : null}
@@ -978,6 +994,7 @@ function LazyRoomPart({ load, name, props = {} }) {
978
994
  useEffect(() => { let live = true; load().then((m) => { if (live && typeof m[name] === "function") setC(() => m[name]); }, () => {}); return () => { live = false; }; }, []);
979
995
  return C ? html`<${C} ...${props} />` : null;
980
996
  }
997
+ const teamsLive = () => { const c = hubClient(); return typeof c.teamsLive === "function" && c.teamsLive() === true; };
981
998
  const roomsLive = () => { const c = hubClient(); return typeof c.roomsLive === "function" && c.roomsLive() === true; };
982
999
  function LazyThisHub({ directory }) {
983
1000
  const [C, setC] = useState(null);
@@ -1040,7 +1057,8 @@ function HubAdminPage({ groups = false, companyJoin = false, directory = false }
1040
1057
  <div class="s-section-layout">
1041
1058
  ${groups && !accessEntry ? html`<${GroupPermissionsEntry} />` : null}
1042
1059
  ${companyJoin ? html`<${CompanyJoinAdminCard} entry=${accessEntry} groups=${groups} />` : null}
1043
- ${/* Lumen's order: Let colleagues join → Rooms → Room assistant → Connected fleets → pairing. */ ""}
1060
+ ${/* Lumen's order: Let colleagues join → Teams → Rooms → Room assistant → Connected fleets → pairing. */ ""}
1061
+ ${teamsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-teams.js")} name="HubTeamsEntry" props=${{ client: hubClient() }} />` : null}
1044
1062
  ${roomsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-admin-rooms.js")} name="AdminRooms" props=${{ client: hubClient() }} />` : null}
1045
1063
  ${assistantSession?.features?.includes("room-assistant-v1") && hubClient().assistantAdminV1 === true ? html`<${LazyAssistantAdmin} />` : null}
1046
1064
  ${view.error ? html`<${ErrorState} message=${view.error} onRetry=${reload} />` : null}
@@ -6,7 +6,7 @@
6
6
  // Own lazy module with its own words. Shared components: card, field, btn, note, err, s-web-ro, s-ui-disclosure, Skeleton.
7
7
  import { html, useEffect, useState } from "/assets/app-html.js";
8
8
  import { Skeleton, ErrorState } from "/assets/ui-states.js";
9
- import { register, t } from "/assets/app-i18n.js";
9
+ import { register, t, lang } from "/assets/app-i18n.js";
10
10
  import { api } from "./settings-confirm.js";
11
11
  import { typedOrigin, shownAddress, defaultListen } from "./settings-hub-web-address.js";
12
12
 
@@ -39,7 +39,9 @@ register("hubMemberAddress", {
39
39
  err_unchanged: "That is already the Fleet connection address.",
40
40
  err_stale: "Something changed meanwhile (a Fleet connected, left or was revoked). Check again.",
41
41
  err_expired: "That took too long. Check again.",
42
- err_busy: "Another change is still finishing, or a device is finishing its sign-in. Try again in a moment.",
42
+ err_busy: "Another settings change is still in progress. Try again in a moment.",
43
+ err_joining: "A colleague's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again after {0}.",
44
+ err_joining_no_time: "A colleague's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again in a few minutes.",
43
45
  err_denied: "Only this computer's own dashboard can change it. Reload this page and try again.",
44
46
  err_unavailable: "It can't be changed right now. Reload this page and try again.",
45
47
  err_recovery: "The change didn't finish. Reload this page to see the current address.",
@@ -73,7 +75,9 @@ register("hubMemberAddress", {
73
75
  err_unchanged: "這已經是目前的 Fleet 連接位址。",
74
76
  err_stale: "剛剛有變動(有 Fleet 連接、離開或被撤銷)。請再檢查一次。",
75
77
  err_expired: "等候太久了,請再檢查一次。",
76
- err_busy: "另一項變更還在完成中,或有裝置正在完成登入,請稍後再試。",
78
+ err_busy: "另一項設定變更還在進行,請稍候再試。",
79
+ err_joining: "有同仁的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請在 {0} 之後再試一次。",
80
+ err_joining_no_time: "有同仁的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請過幾分鐘再試一次。",
77
81
  err_denied: "只有這台電腦自己的儀表板可以變更。請重新載入這個頁面後再試。",
78
82
  err_unavailable: "目前無法變更。請重新載入這個頁面後再試。",
79
83
  err_recovery: "變更沒有完成。請重新載入這個頁面查看目前的位址。",
@@ -84,13 +88,24 @@ const copy = (key, ...a) => t(`hubMemberAddress.${key}`, ...a);
84
88
  const PREFIX = "/api/settings/hub/member-address";
85
89
  const ERR = new Set(["invalid", "port_conflict", "port_in_use", "certificate", "unchanged", "stale", "expired", "busy", "denied", "unavailable", "recovery"]);
86
90
  const errKey = (code) => `err_${ERR.has(code) ? code : "failed"}`;
91
+ const errorText = (r) => {
92
+ if (r.code !== "joining") return copy(errKey(r.code));
93
+ let time = "";
94
+ if (Number.isSafeInteger(r.retryAt) && r.retryAt > 0) {
95
+ try {
96
+ const at = new Date(Math.ceil(r.retryAt / 60_000) * 60_000);
97
+ if (!Number.isNaN(at.getTime())) time = new Intl.DateTimeFormat(lang(), { hour: "2-digit", minute: "2-digit" }).format(at);
98
+ } catch { /* Fall back to the no-time wording. */ }
99
+ }
100
+ return copy(time ? "err_joining" : "err_joining_no_time", time);
101
+ };
87
102
  const names = (fleets) => (fleets || []).map((f) => f.label || copy("unnamed")).join(copy("sep"));
88
103
 
89
104
  export function createMemberAddressClient() {
90
105
  const call = async (action, body) => {
91
106
  try {
92
107
  const r = await api(PREFIX + action, { credentials: "same-origin", cache: "no-store", ...(body === undefined ? {} : { method: "POST", body: JSON.stringify(body) }) });
93
- return r.ok && r.body?.ok ? r.body : { ok: false, code: r.body?.code || "unavailable" };
108
+ return r.ok && r.body?.ok ? r.body : { ok: false, code: r.body?.code || "unavailable", ...(Number.isSafeInteger(r.body?.retryAt) ? { retryAt: r.body.retryAt } : {}) };
94
109
  } catch { return { ok: false, code: "unavailable" }; }
95
110
  };
96
111
  return { read: () => call(""), prepare: (candidate) => call("/prepare", candidate), commit: (ref) => call("/commit", { ref }) };
@@ -139,7 +154,7 @@ export function HubMemberAddressSettings({ client: given = null } = {}) {
139
154
  setBusy(true); setError("");
140
155
  const r = await client.prepare({ origin, listen });
141
156
  setBusy(false);
142
- if (!r.ok) { setError(copy(errKey(r.code))); return; }
157
+ if (!r.ok) { setError(errorText(r)); return; }
143
158
  setProposal(r); setStep("confirm");
144
159
  };
145
160
  const confirm = async () => {
@@ -147,7 +162,7 @@ export function HubMemberAddressSettings({ client: given = null } = {}) {
147
162
  setBusy(true); setError("");
148
163
  const r = await client.commit(proposal.ref);
149
164
  setBusy(false);
150
- if (!r.ok) { setError(copy(errKey(r.code))); if (r.code === "expired" || r.code === "stale") { setProposal(null); setStep("edit"); } return; }
165
+ if (!r.ok) { setError(errorText(r)); if (r.code === "expired" || r.code === "stale" || r.code === "joining") { setProposal(null); setStep("edit"); } return; }
151
166
  setOutcome(r); setStep("show");
152
167
  // Connected now: only the Fleets that followed (the rest were disconnected and must reconnect).
153
168
  const gone = new Set((Array.isArray(r.reconnect) ? r.reconnect : []).map((f) => f.id));
@@ -8,13 +8,13 @@ register("settingsHubSection", {
8
8
  publicLink: "Hub settings are only on this fleet's own dashboard, not over the public link.",
9
9
  relatedTitle: "Hub", relatedHint: "Connect this fleet to a team Hub and choose which agents to share.",
10
10
  groupsTitle: "Group permissions", groupsHint: "Let members of chosen directory groups chat with agents, share agents or connect their fleet. Set on the Hub, signed in as its administrator.",
11
- groupsOpen: "Open on the Hub", experimental: "Experimental", setupLink: "Set up a Hub",
11
+ groupsOpen: "Open on the Hub", experimental: "Preview", setupLink: "Set up a Hub",
12
12
  },
13
13
  "zh-TW": {
14
14
  publicLink: "Hub 設定只在這個 Fleet 自己的儀表板上提供,公開連結上沒有。",
15
15
  relatedTitle: "Hub", relatedHint: "將這個 Fleet 連接到團隊 Hub,並選擇要分享的 Agent。",
16
16
  groupsTitle: "群組權限", groupsHint: "讓指定目錄群組的成員與 Agent 對話、分享 Agent 或連接自己的 Fleet。在 Hub 上以管理員身分登入後設定。",
17
- groupsOpen: "在 Hub 上開啟", experimental: "實驗性", setupLink: "設定 Hub",
17
+ groupsOpen: "在 Hub 上開啟", experimental: "預覽版", setupLink: "設定 Hub",
18
18
  },
19
19
  });
20
20
  export const hubSectionText = (key) => t(`settingsHubSection.${key}`);
@@ -35,7 +35,9 @@ register("hubWebAddress", {
35
35
  err_unchanged: "That is already the Hub's address.",
36
36
  err_stale: "The Hub's settings changed meanwhile. Check the address and try again.",
37
37
  err_expired: "That took too long. Check again.",
38
- err_busy: "Another change is still finishing, or a device is finishing its sign-in. Try again in a moment.",
38
+ err_busy: "Another settings change is still in progress. Try again in a moment.",
39
+ err_joining: "A colleague's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again after {0}.",
40
+ err_joining_no_time: "A colleague's Fleet is joining this Hub right now, so the Hub address can't be changed. Try again in a few minutes.",
39
41
  err_denied: "Only this computer's own dashboard can change the Hub's address. Reload this page and try again.",
40
42
  err_unavailable: "The Hub's address can't be changed right now. Reload this page and try again.",
41
43
  err_recovery: "The change didn't finish. Reload this page to see the Hub's current address.",
@@ -66,7 +68,9 @@ register("hubWebAddress", {
66
68
  err_unchanged: "這已經是 Hub 目前的位址。",
67
69
  err_stale: "Hub 的設定剛剛有變更。請確認位址後再試一次。",
68
70
  err_expired: "等候太久了,請再檢查一次。",
69
- err_busy: "另一項變更還在完成中,或有裝置正在完成登入,請稍後再試。",
71
+ err_busy: "另一項設定變更還在進行,請稍候再試。",
72
+ err_joining: "有同仁的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請在 {0} 之後再試一次。",
73
+ err_joining_no_time: "有同仁的 Fleet 正在加入這個 Hub,這段時間不能變更 Hub 位址。請過幾分鐘再試一次。",
70
74
  err_denied: "只有這台電腦自己的儀表板可以變更 Hub 的位址。請重新載入這個頁面後再試。",
71
75
  err_unavailable: "目前無法變更 Hub 的位址。請重新載入這個頁面後再試。",
72
76
  err_recovery: "變更沒有完成。請重新載入這個頁面查看 Hub 目前的位址。",
@@ -77,6 +81,18 @@ const copy = (key, ...a) => t(`hubWebAddress.${key}`, ...a);
77
81
  const PREFIX = "/api/settings/hub/web-address";
78
82
  const ERR = new Set(["invalid", "port_conflict", "port_in_use", "certificate", "unchanged", "stale", "expired", "busy", "denied", "unavailable", "recovery"]);
79
83
  const errKey = (code) => `err_${ERR.has(code) ? code : "failed"}`;
84
+ const errorText = (r) => {
85
+ if (r.code !== "joining") return copy(errKey(r.code));
86
+ let time = "";
87
+ if (Number.isSafeInteger(r.retryAt) && r.retryAt > 0) {
88
+ try {
89
+ // Round up: the displayed minute must not invite a retry before the exact deadline.
90
+ const at = new Date(Math.ceil(r.retryAt / 60_000) * 60_000);
91
+ if (!Number.isNaN(at.getTime())) time = new Intl.DateTimeFormat(lang(), { hour: "2-digit", minute: "2-digit" }).format(at);
92
+ } catch { /* The no-time wording also supports an older response or browser. */ }
93
+ }
94
+ return copy(time ? "err_joining" : "err_joining_no_time", time);
95
+ };
80
96
 
81
97
  /** What was typed, as the https origin the server is asked for ("hub.example.com" → "https://hub.example.com"); null if not one. */
82
98
  export function typedOrigin(text) {
@@ -105,7 +121,7 @@ export function createWebAddressClient() {
105
121
  const call = async (action, body) => {
106
122
  try {
107
123
  const r = await api(PREFIX + action, { credentials: "same-origin", cache: "no-store", ...(body === undefined ? {} : { method: "POST", body: JSON.stringify(body) }) });
108
- return r.ok && r.body?.ok ? r.body : { ok: false, code: r.body?.code || "unavailable" };
124
+ return r.ok && r.body?.ok ? r.body : { ok: false, code: r.body?.code || "unavailable", ...(Number.isSafeInteger(r.body?.retryAt) ? { retryAt: r.body.retryAt } : {}) };
109
125
  } catch { return { ok: false, code: "unavailable" }; }
110
126
  };
111
127
  return { read: () => call(""), prepare: (candidate) => call("/prepare", candidate), commit: (ref) => call("/commit", { ref }) };
@@ -160,7 +176,7 @@ export function HubWebAddressSettings({ client: given = null } = {}) {
160
176
  const certificate = mode === "import" ? { mode, certPem, keyPem } : { mode };
161
177
  const r = await client.prepare({ origin, listen, certificate });
162
178
  setBusy(false);
163
- if (!r.ok) { setError(copy(errKey(r.code))); return; }
179
+ if (!r.ok) { setError(errorText(r)); return; }
164
180
  setKeyPem(""); // sent once; never kept in the page
165
181
  setProposal(r); setStep("confirm");
166
182
  };
@@ -169,7 +185,7 @@ export function HubWebAddressSettings({ client: given = null } = {}) {
169
185
  setBusy(true); setError("");
170
186
  const r = await client.commit(proposal.ref);
171
187
  setBusy(false);
172
- if (!r.ok) { setError(copy(errKey(r.code))); if (r.code === "expired" || r.code === "stale") { setProposal(null); setStep("edit"); } return; }
188
+ if (!r.ok) { setError(errorText(r)); if (r.code === "expired" || r.code === "stale" || r.code === "joining") { setProposal(null); setStep("edit"); } return; }
173
189
  setOutcome(r); setProposal(null); setStep("done");
174
190
  setView((v) => ({ ...v, origin: r.origin || proposal.summary?.to, listen: proposal.summary?.listen || v.listen, certificate: proposal.certificate || v.certificate }));
175
191
  };
@@ -17,6 +17,7 @@ register("settingsLayout", {
17
17
  lead_access: "Manage sign-in, web authority, guests and sharing.",
18
18
  lead_advanced: "Inspect and edit fleet configuration, with effective values kept separate.",
19
19
  lead_hub: "Connect this fleet to a team Hub and choose which agents to share there.",
20
+ preview: "Preview", previewHub: "The Hub is a preview in this release. It stays off until you set one up or connect to one, and its screens and behaviour may still change.",
20
21
  lead_notifications: "Choose when account usage reminders are sent, and to whom.",
21
22
  editor: "Configuration editor", effective: "Effective settings (read only)",
22
23
  aiAccounts: "AI accounts and keys", aiAccountsHint: "Connected AI accounts and supported provider keys on the AgEnD host. Windows CLI status is shown under Runtime.",
@@ -33,6 +34,7 @@ register("settingsLayout", {
33
34
  lead_access: "管理登入、網頁授權、訪客與對外分享。",
34
35
  lead_advanced: "檢視與編輯 Fleet 設定,並區分目前生效的唯讀內容。",
35
36
  lead_hub: "將這個 Fleet 連接到團隊 Hub,並選擇要在那裡分享的 Agent。",
37
+ preview: "預覽版", previewHub: "Hub 在這個版本是預覽版。設定或連接之前不會啟用,畫面與行為之後可能還會變動。",
36
38
  lead_notifications: "設定帳號用量提醒的時機與傳送對象。",
37
39
  editor: "設定編輯器", effective: "生效設定(唯讀)",
38
40
  aiAccounts: "AI 帳號與金鑰", aiAccountsHint: "管理 AgEnD 主機上連接的 AI 帳號與支援的供應商金鑰;Windows CLI 狀態請到 Runtime 查看。",
@@ -94,7 +96,9 @@ register("settingsLayout", {
94
96
 
95
97
  export function SettingsPageHead({ section, children }) {
96
98
  const scope = section === "preferences" ? "account" : section === "look" ? "personal" : "fleet";
97
- return html`<${PageHead} title=${t(`settings.sec_${section}`)} scope=${layoutText(scope)} lead=${layoutText(`lead_${section}`)}>${children}</${PageHead}>`;
99
+ const hub = section === "hub"; // M-3108: the Hub is a preview in 2.4.0-beta.1
100
+ return html`<${PageHead} title=${t(`settings.sec_${section}`)} scope=${layoutText(scope)} lead=${layoutText(`lead_${section}`)}
101
+ tag=${hub ? layoutText("preview") : null} note=${hub ? layoutText("previewHub") : null}>${children}</${PageHead}>`;
98
102
  }
99
103
 
100
104
  // Settings search, validation links and legacy anchors reveal their owning tab before focusing a control.