@songsid/agend 2.4.0-beta.35 → 2.4.0-beta.37

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 (113) hide show
  1. package/dist/agent-whats-new.js +10 -0
  2. package/dist/agent-whats-new.js.map +1 -1
  3. package/dist/build-provenance.json +1 -1
  4. package/dist/cli-audited.js +8 -2
  5. package/dist/cli-audited.js.map +1 -1
  6. package/dist/fleet-manager.js +1 -1
  7. package/dist/fleet-manager.js.map +1 -1
  8. package/dist/general-knowledge/skills/hub/SKILL.md +32 -6
  9. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +2 -1
  10. package/dist/hub/client.js +22 -4
  11. package/dist/hub/client.js.map +1 -1
  12. package/dist/hub/compose/server.d.ts +2 -0
  13. package/dist/hub/compose/server.js +36 -2
  14. package/dist/hub/compose/server.js.map +1 -1
  15. package/dist/hub/directory/directory.d.ts +19 -1
  16. package/dist/hub/directory/directory.js +199 -10
  17. package/dist/hub/directory/directory.js.map +1 -1
  18. package/dist/hub/directory/people-index.d.ts +72 -0
  19. package/dist/hub/directory/people-index.js +265 -0
  20. package/dist/hub/directory/people-index.js.map +1 -0
  21. package/dist/hub/directory/types.d.ts +49 -0
  22. package/dist/hub/directory/types.js +1 -0
  23. package/dist/hub/directory/types.js.map +1 -1
  24. package/dist/hub/grant-search.js +38 -23
  25. package/dist/hub/grant-search.js.map +1 -1
  26. package/dist/hub/group-policy/admin-api.js +10 -1
  27. package/dist/hub/group-policy/admin-api.js.map +1 -1
  28. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  29. package/dist/hub/group-policy/admin-control.js +1 -1
  30. package/dist/hub/group-policy/admin-control.js.map +1 -1
  31. package/dist/hub/group-policy/admin-dto.d.ts +16 -14
  32. package/dist/hub/group-policy/admin-dto.js +5 -1
  33. package/dist/hub/group-policy/admin-dto.js.map +1 -1
  34. package/dist/hub/group-policy/admin-search.d.ts +2 -1
  35. package/dist/hub/group-policy/admin-search.js +45 -5
  36. package/dist/hub/group-policy/admin-search.js.map +1 -1
  37. package/dist/hub/group-policy/resources.d.ts +1 -1
  38. package/dist/hub/http/compose.js +68 -2
  39. package/dist/hub/http/compose.js.map +1 -1
  40. package/dist/hub/http/deps.d.ts +2 -0
  41. package/dist/hub/mcp/catalog.d.ts +0 -1
  42. package/dist/hub/mcp/catalog.js +2 -1
  43. package/dist/hub/mcp/catalog.js.map +1 -1
  44. package/dist/hub/mcp/http.js +6 -1
  45. package/dist/hub/mcp/http.js.map +1 -1
  46. package/dist/hub/mcp/policy.d.ts +9 -2
  47. package/dist/hub/mcp/policy.js +23 -1
  48. package/dist/hub/mcp/policy.js.map +1 -1
  49. package/dist/hub/people-query.d.ts +1 -0
  50. package/dist/hub/people-query.js +13 -0
  51. package/dist/hub/people-query.js.map +1 -0
  52. package/dist/hub/people-resolve.d.ts +34 -0
  53. package/dist/hub/people-resolve.js +38 -0
  54. package/dist/hub/people-resolve.js.map +1 -0
  55. package/dist/hub/protocol.d.ts +2 -0
  56. package/dist/hub/protocol.js +5 -2
  57. package/dist/hub/protocol.js.map +1 -1
  58. package/dist/hub/roles/admin-control.d.ts +0 -1
  59. package/dist/hub/roles/admin-control.js +29 -1
  60. package/dist/hub/roles/admin-control.js.map +1 -1
  61. package/dist/hub/roles/admin-types.d.ts +2 -0
  62. package/dist/hub/roles/allowed-list-control.d.ts +2 -0
  63. package/dist/hub/roles/allowed-list-control.js +17 -0
  64. package/dist/hub/roles/allowed-list-control.js.map +1 -1
  65. package/dist/hub/rooms/direct-view.js +2 -1
  66. package/dist/hub/rooms/direct-view.js.map +1 -1
  67. package/dist/hub/rooms/directory.d.ts +3 -0
  68. package/dist/hub/rooms/directory.js +38 -0
  69. package/dist/hub/rooms/directory.js.map +1 -1
  70. package/dist/hub/rooms/service.d.ts +7 -0
  71. package/dist/hub/rooms/service.js +17 -1
  72. package/dist/hub/rooms/service.js.map +1 -1
  73. package/dist/hub/runtime.js +15 -2
  74. package/dist/hub/runtime.js.map +1 -1
  75. package/dist/hub/server.d.ts +7 -0
  76. package/dist/hub/server.js +26 -4
  77. package/dist/hub/server.js.map +1 -1
  78. package/dist/hub/socket.d.ts +14 -0
  79. package/dist/hub/socket.js +19 -2
  80. package/dist/hub/socket.js.map +1 -1
  81. package/dist/hub/teams/index.js +35 -20
  82. package/dist/hub/teams/index.js.map +1 -1
  83. package/dist/hub/teams/types.d.ts +7 -1
  84. package/dist/locale.js +6 -4
  85. package/dist/locale.js.map +1 -1
  86. package/dist/runtime-cli-install.js +7 -3
  87. package/dist/runtime-cli-install.js.map +1 -1
  88. package/dist/ui/hub-admin-rooms.js +6 -4
  89. package/dist/ui/hub-ai-apps.js +2 -1
  90. package/dist/ui/hub-client.js +12 -0
  91. package/dist/ui/hub-grant-picker.js +42 -5
  92. package/dist/ui/hub-group-policy.js +3 -1
  93. package/dist/ui/hub-join-steps.js +3 -1
  94. package/dist/ui/hub-people-index.js +96 -0
  95. package/dist/ui/hub-people-paste.js +161 -0
  96. package/dist/ui/hub-people-query.js +8 -0
  97. package/dist/ui/hub-personal-agent.js +7 -2
  98. package/dist/ui/hub-role-forms.js +12 -3
  99. package/dist/ui/hub-room-new.js +12 -2
  100. package/dist/ui/hub-room-owner-requests.js +1 -1
  101. package/dist/ui/hub-room-settings.js +11 -4
  102. package/dist/ui/hub-room-thread.js +3 -3
  103. package/dist/ui/hub-subject-picker.js +16 -7
  104. package/dist/ui/hub-teams-strings.js +2 -2
  105. package/dist/ui/hub-teams.js +21 -5
  106. package/dist/ui/panel-hub.js +2 -0
  107. package/dist/ui/shared/app-update.js +19 -0
  108. package/dist/ui/shared/app.css +37 -0
  109. package/dist/ui/shared/update-card-ui.js +3 -3
  110. package/dist/update-card.d.ts +5 -1
  111. package/dist/update-card.js +8 -1
  112. package/dist/update-card.js.map +1 -1
  113. package/package.json +1 -1
@@ -0,0 +1,161 @@
1
+ /**
2
+ * M-3975: paste a list of people, anywhere people are added in the Hub. The user's ask: building a team meant adding
3
+ * people one by one. Lumen's UX pass shaped the review:
4
+ * - one box takes names, accounts or emails, separated by commas, semicolons, 、, tabs or new lines (full-width too);
5
+ * a mail client's "Name <a@b>" gives its address; spaces never split; duplicates fold;
6
+ * - each entry is resolved by the place's own route; only an exact account, email or whole name with one holder is
7
+ * ticked by itself; one partial match is shown unticked ("wang → Alex Wang"); several ask for a pick; none says so;
8
+ * - nothing is added until the one "Add N people" button; a line above it counts ready / need a choice / not found;
9
+ * rows that weren't added stay, and entries not found go back into the box;
10
+ * - at most 50 entries a time: the rest stay in the box, and the line says so.
11
+ * The place supplies `resolve`, how a row reads (`view`), its own "already" word, and `onAdd`; adding still goes through
12
+ * the place's existing route, which checks the directory again.
13
+ */
14
+ import { html, useRef, useState } from "/assets/app-html.js";
15
+ import { register, t } from "/assets/app-i18n.js";
16
+
17
+ register("hubPeoplePaste", {
18
+ en: {
19
+ open: "Paste a list", label: "Names, accounts or emails", hint: "Type or paste names, accounts or emails, separated by commas, semicolons or new lines.",
20
+ find: "Find these people", finding: "Looking them up…", cancel: "Cancel", back: "Edit the list",
21
+ tookFirst: "Took the first 50. {0} more were left in the box.",
22
+ ready: "{0} ready", choose: "{0} to choose", none: "{0} not found", already: "{0}: {1}", skipped: "Rows that aren't ticked or picked are skipped.",
23
+ add: "Add {0} people", add1: "Add 1 person",
24
+ possible: "1 possible match", many: "{0} people match. Pick one", notFound: "Not found", remove: "Remove this row ({0})", pick: "Pick {0}", inList: "Already in this list", refusedRow: "Couldn't be added.", notTried: "Not tried, because an earlier one was refused.", overLimit: "Over the limit of {0}.",
25
+ join: "Add {0} people", join1: "Add 1 person", addedNot: "Added {0}. Not added: {1}. They are back in the box to check.", addedAll: "Added {0}.", sep: ", ", gap: " ", saveToFinish: "Press Save to finish.",
26
+ off: "Pasting a list needs People search. An administrator can turn it on in Administration → People search.",
27
+ failed: "Couldn't look these up. Try again.", limited: "Too many lookups in a minute. Wait a moment, then try again.",
28
+ added: "Added {0}.", notAdded: "{0} not added:", alreadyDefault: "Already there", nothing: "Nothing to add", notAddedFirst: "Not added: {0} (back in the box).",
29
+ alreadyRoom: "Already in this room", alreadyTeam: "Already in this team", alreadyListed: "Already on the list",
30
+ },
31
+ "zh-TW": {
32
+ open: "貼上名單", label: "姓名、帳號或 Email", hint: "輸入或貼上姓名、帳號或 Email,以逗號、分號、頓號或換行分隔。",
33
+ find: "查詢這些人", finding: "查詢中…", cancel: "取消", back: "修改名單",
34
+ tookFirst: "先處理前 50 筆,其餘 {0} 筆留在輸入框。",
35
+ ready: "可新增 {0} 人", choose: "待選擇 {0} 筆", none: "找不到 {0} 筆", already: "{0}:{1} 人", skipped: "沒有勾選或選擇的不會新增。",
36
+ add: "新增 {0} 人", add1: "新增 1 人",
37
+ possible: "可能是這位", many: "有 {0} 人符合,請選一位", notFound: "找不到", remove: "移除這一列({0})", pick: "選擇 {0}", inList: "已在這份清單中", refusedRow: "無法加入。", notTried: "前一位被拒絕,所以沒有嘗試。", overLimit: "超過 {0} 人的上限。",
38
+ join: "加入 {0} 人", join1: "加入 1 人", addedNot: "已加入 {0} 人。沒有加入:{1}。已放回輸入框,請確認。", addedAll: "已加入 {0} 人。", sep: "、", gap: "", saveToFinish: "按「儲存」後才會生效。",
39
+ off: "貼上名單需要開啟「人員搜尋」。管理員可以在「管理」→「人員搜尋」開啟。",
40
+ failed: "無法查詢,請再試一次。", limited: "一分鐘內查詢太多次,請稍候再試。",
41
+ added: "已新增 {0} 人。", notAdded: "{0} 筆沒有新增:", alreadyDefault: "已在其中", nothing: "沒有可加入的人", notAddedFirst: "沒有加入:{0}(已放回輸入框)。",
42
+ alreadyRoom: "已在這個房間", alreadyTeam: "已在這個團隊", alreadyListed: "已在名單上",
43
+ },
44
+ });
45
+ const tp = (key, ...a) => t(`hubPeoplePaste.${key}`, ...a);
46
+ /** The paste box's words, for a place's own "already" label (alreadyRoom, alreadyTeam, alreadyListed). */
47
+ export const pasteText = tp;
48
+ export const PASTE_MAX = 50;
49
+
50
+ /** A pasted text → at most 50 entries (in order, duplicates folded) and what is left for the box. */
51
+ export function parsePeopleList(text) {
52
+ // A mail client's `"Lee, Dana" <dana@x>` is one entry, its address (Prism, #4652): address forms are taken first, so a
53
+ // comma inside the quoted name never splits off an unrelated lookup. A quoted name alone keeps its words together.
54
+ const source = String(text ?? "")
55
+ .replace(/(?:"[^"\r\n]*"|“[^”\r\n]*”|「[^」\r\n]*」|[^,,;;、\t\r\n<>"“”「」]*)\s*<([^<>\s]+@[^<>\s]+)>/gu, (_, addr) => addr)
56
+ .replace(/"([^"\r\n]*)"|“([^”\r\n]*)”|「([^」\r\n]*)」/gu, (_, a, b, c) => (a ?? b ?? c ?? "").replace(/[,,;;、\t]+/gu, " "));
57
+ const parts = source.split(/[,,;;、\t\r\n]+/u).map(s => s.trim()).filter(Boolean)
58
+ .map(s => s.replace(/^['‘’]+|['‘’]+$/gu, "").replace(/\s+/gu, " ").trim())
59
+ .filter(s => s && s.length <= 256);
60
+ const seen = new Set(), unique = [];
61
+ for (const p of parts) { const k = p.normalize("NFKC").toLowerCase(); if (!seen.has(k)) { seen.add(k); unique.push(p); } }
62
+ return { entries: unique.slice(0, PASTE_MAX), rest: unique.slice(PASTE_MAX) };
63
+ }
64
+
65
+ let sequence = 0;
66
+ /**
67
+ * Props: resolve(entries) → { resolved: [{ entry, match, candidates }] } | { resolved: null } (People search off) |
68
+ * { ok: false, status?, reason? }; view(raw) → { id, name, detail? }; already(raw) → a label or null; onAdd(raws) →
69
+ * { notAdded?: [{ id, reason }] } | void; disabled.
70
+ */
71
+ export function PeoplePaste({ resolve, view, already = () => null, onAdd, disabled = false, closable = true, addWord = "add", afterAdd = "" }) {
72
+ const [open, setOpen] = useState(false), [text, setText] = useState(""), [busy, setBusy] = useState(false), [off, setOff] = useState(false);
73
+ const [rows, setRows] = useState(null), [msg, setMsg] = useState(null), [note, setNote] = useState(""), [source, setSource] = useState("");
74
+ const id = useRef(`hubPaste${++sequence}`).current, asked = useRef(0);
75
+ // People search turned out to be off: the entry says so and doesn't open a box that can't work (Lumen, #4652).
76
+ if (off) return html`<div class="hub-paste"><button type="button" class="btn btn-link hub-paste-open" disabled=${true}>${tp("open")}</button><p class="note hub-paste-off" role="status">${tp("off")}</p></div>`;
77
+ if (!open) return html`<button type="button" class="btn btn-link hub-paste-open" disabled=${disabled} onClick=${() => setOpen(true)}>${tp("open")}</button>`;
78
+ const find = async () => {
79
+ const { entries, rest } = parsePeopleList(text);
80
+ if (!entries.length || busy) return;
81
+ const mine = ++asked.current; setBusy(true); setMsg(null); setNote(rest.length ? tp("tookFirst", rest.length) : "");
82
+ let out; try { out = await resolve(entries); } catch { out = { ok: false }; }
83
+ if (mine !== asked.current) return;
84
+ setBusy(false);
85
+ if (out && out.resolved === null) { setOff(true); setOpen(false); return; }
86
+ if (!out || !Array.isArray(out.resolved)) { setMsg({ err: true, text: out?.status === 429 || out?.reason === "limited" || out?.code === "backpressure" ? tp("limited") : tp("failed") }); return; }
87
+ setSource(text); setText(rest.join("\n"));
88
+ const seen = new Set();
89
+ setRows(out.resolved.map((r, i) => {
90
+ const candidates = (r.candidates || []).map(raw => ({ raw, ...view(raw) })).filter(c => c.id);
91
+ const first = candidates[0];
92
+ // Two entries that are the same person fold into the first; a person already in the place is greyed.
93
+ const dup = r.match === "exact" && first && seen.has(first.id);
94
+ if (r.match === "exact" && first) seen.add(first.id);
95
+ const flag = first && (r.match === "exact" || r.match === "possible") ? already(first.raw) : null, was = flag === true ? tp("alreadyDefault") : flag || null;
96
+ return { key: `${i}:${r.entry}`, entry: r.entry, match: dup ? "dup" : r.match, candidates, ticked: r.match === "exact" && !was ? first.id : null, already: was };
97
+ }).filter(r => r.match !== "dup"));
98
+ };
99
+ const set = (key, ticked) => setRows(list => list.map(r => r.key === key ? { ...r, ticked } : r));
100
+ const drop = (key) => setRows(list => { const next = list.filter(r => r.key !== key); return next.length ? next : null; });
101
+ const chosen = (rows || []).filter(r => !r.already && r.ticked);
102
+ const unique = [...new Map(chosen.map(r => [r.ticked, r.candidates.find(c => c.id === r.ticked)])).values()].filter(Boolean);
103
+ const count = (m) => (rows || []).filter(m).length;
104
+ const parts = rows ? [
105
+ [count(r => !r.already && r.ticked), "ready"], [count(r => !r.already && !r.ticked && r.match !== "none"), "choose"],
106
+ [count(r => r.match === "none"), "none"],
107
+ ].filter(([n]) => n > 0).map(([n, k]) => tp(k, n)) : [];
108
+ // People already in the place are counted with the place's own word ("Already in this team: 1"), never "added" (Lumen, #4652).
109
+ if (rows) for (const [word, n] of (rows || []).filter(r => r.already).reduce((m, r) => m.set(r.already, (m.get(r.already) || 0) + 1), new Map())) parts.push(tp("already", word, n));
110
+ const add = async () => {
111
+ if (!unique.length || busy) return;
112
+ setBusy(true); setMsg(null);
113
+ let out; try { out = await onAdd(unique.map(c => c.raw)); } catch { out = { notAdded: unique.map(c => ({ id: c.id, reason: tp("failed") })) }; }
114
+ setBusy(false);
115
+ const failed = new Map((out?.notAdded || []).map(f => [f.id, f.reason]));
116
+ const added = unique.length - failed.size;
117
+ // Everything not added (left unticked, not picked, not found, or refused by the place) goes back into the box, and
118
+ // one line says what happened (Lumen, #4652): the box is the way back to them.
119
+ const left = rows.filter(r => r.already ? false : r.ticked ? failed.has(r.ticked) : true).map(r => r.entry);
120
+ setRows(null); setText(prev => [...left, ...(prev ? [prev] : [])].join("\n"));
121
+ const refused = [...failed.values()][0];
122
+ // What needs action comes first (Lumen, #4652): who wasn't added (and why), then how many were, then what is left to do.
123
+ setMsg({ err: false, text: [left.length ? tp("notAddedFirst", left.join(tp("sep"))) : "", refused, tp("addedAll", added), afterAdd].filter(Boolean).join(tp("gap")) });
124
+ };
125
+ // The name, then its account and department on their own line: a wrapped line never starts with "·".
126
+ const line = (c) => html`<span class="hub-paste-name">${c.name}</span>${c.detail ? html`<small class="note hub-paste-detail">${c.detail}</small>` : null}`;
127
+ const label = (c) => `${c.name}${c.detail ? ` · ${c.detail}` : ""}`;
128
+ // A person already ticked in another row is not offered again in a pick-one group (Lumen, #4652).
129
+ const tickedBy = new Map((rows || []).filter(r => !r.already && r.ticked).map(r => [r.ticked, r.key]));
130
+ const remove = (r) => html`<button type="button" class="chip-btn" aria-label=${tp("remove", r.entry)} disabled=${busy} onClick=${() => drop(r.key)}>×</button>`;
131
+ return html`<div class="hub-paste" role="group" aria-labelledby=${`${id}Label`}>
132
+ ${!rows ? html`<label class="field" for=${id}><span id=${`${id}Label`}>${tp("label")}</span>
133
+ <textarea id=${id} class="hub-paste-text" rows="6" disabled=${disabled || busy} value=${text} onInput=${e => setText(e.target.value)} aria-describedby=${`${id}Hint`}></textarea></label>
134
+ <p id=${`${id}Hint`} class="note">${tp("hint")}</p>
135
+ ${note ? html`<p class="note" role="status">${note}</p>` : null}
136
+ <div class="row hub-paste-actions"><button type="button" class="btn btn-primary hub-paste-find" disabled=${disabled || busy || !parsePeopleList(text).entries.length} onClick=${find}>${busy ? tp("finding") : tp("find")}</button>
137
+ ${closable ? html`<button type="button" class="btn" disabled=${busy} onClick=${() => { asked.current++; setOpen(false); setText(""); setMsg(null); setNote(""); }}>${tp("cancel")}</button>` : null}</div>`
138
+ : html`<span id=${`${id}Label`} class="sr-only">${tp("label")}</span>
139
+ <ul class="hub-paste-rows" role="list">${rows.map(r => html`<li key=${r.key} class=${`hub-paste-row hub-paste-${r.already ? "already" : r.match}`}><div class="hub-paste-main">
140
+ ${r.already ? html`<span class="hub-paste-person"><span>${line(r.candidates[0])}</span><small class="note">${r.already}</small></span>`
141
+ : r.match === "exact" || r.match === "possible" ? html`<label class="check hub-paste-person"><input type="checkbox" checked=${r.ticked === r.candidates[0].id} disabled=${disabled || busy}
142
+ onChange=${e => set(r.key, e.target.checked ? r.candidates[0].id : null)} />
143
+ <span>${r.match === "possible" || r.entry.normalize("NFKC").toLowerCase() !== r.candidates[0].name.normalize("NFKC").toLowerCase() ? html`<span class="hub-paste-entry">${r.entry} → </span>` : null}${line(r.candidates[0])}
144
+ ${r.match === "possible" ? html`<small class="hub-paste-status hub-paste-detail">${tp("possible")}</small>` : null}</span></label>`
145
+ : r.match === "choose" ? html`<div class="hub-paste-pick" role="radiogroup" aria-labelledby=${`${id}-${r.key}-h`}><div class="hub-paste-pick-head"><span id=${`${id}-${r.key}-h`}><span class="hub-paste-entry">${r.entry}</span> · ${tp("many", r.candidates.length)}</span>${remove(r)}</div>
146
+ ${r.candidates.map(c => { const elsewhere = tickedBy.has(c.id) && tickedBy.get(c.id) !== r.key;
147
+ return html`<label class="check" key=${c.id}><input type="radio" name=${`${id}-${r.key}`} checked=${r.ticked === c.id} disabled=${disabled || busy || elsewhere}
148
+ aria-label=${tp("pick", label(c))} onChange=${() => set(r.key, c.id)} /><span>${line(c)}${elsewhere ? html`<small class="hub-paste-status hub-paste-detail">${tp("inList")}</small>` : null}</span></label>`; })}</div>`
149
+ : html`<span class="hub-paste-person"><span class="hub-paste-entry">${r.entry}</span> · <span class="hub-paste-status hub-paste-missing">${tp("notFound")}</span></span>`}
150
+ ${r.failure ? html`<small class="err">${r.failure}</small>` : null}</div>
151
+ ${!r.already && r.match !== "choose" ? remove(r) : null}
152
+ </li>`)}</ul>
153
+ ${note ? html`<p class="note" role="status">${note}</p>` : null}
154
+ <p class="note hub-paste-count" role="status">${parts.join(" · ")}</p>
155
+ ${rows.some(r => !r.already && !r.ticked && r.match !== "none") ? html`<p class="note">${tp("skipped")}</p>` : null}
156
+ <div class="row hub-paste-actions"><button type="button" class="btn btn-primary hub-paste-add" disabled=${disabled || busy || !unique.length} onClick=${add}>${!unique.length ? tp("nothing") : addWord === "join" ? unique.length === 1 ? tp("join1") : tp("join", unique.length) : unique.length === 1 ? tp("add1") : tp("add", unique.length)}</button>
157
+ <button type="button" class="btn" disabled=${busy} onClick=${() => { setRows(null); setMsg(null); setNote(""); setText(source); }}>${tp("back")}</button>
158
+ ${closable ? html`<button type="button" class="btn" disabled=${busy} onClick=${() => { asked.current++; setRows(null); setOpen(false); setText(""); setMsg(null); setNote(""); }}>${tp("cancel")}</button>` : null}</div>`}
159
+ ${msg ? html`<p class=${msg.err ? "err" : "s-info hub-paste-done"} role=${msg.err ? "alert" : "status"}>${msg.text}</p>` : null}
160
+ </div>`;
161
+ }
@@ -0,0 +1,8 @@
1
+ // M-3975: what a people search sends (the Hub checks the same rule, src/hub/people-query.ts): 1–64 characters, and two
2
+ // or more unless the text holds a CJK character, because a Chinese, Japanese or Korean surname alone is one character.
3
+ const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
4
+ export function searchablePeopleQuery(q) {
5
+ if (typeof q !== "string") return false;
6
+ const t = q.trim();
7
+ return t.length >= 1 && t.length <= 64 && !/[\u0000-\u001f\u007f]/.test(t) && (t.length >= 2 || CJK.test(t));
8
+ }
@@ -5,6 +5,8 @@ import {confirmDialog} from "/assets/ui-confirm.js";
5
5
  import {runtimeEnrollCommand} from "./runtime-commands.js";
6
6
  import {hp} from "./hub-personal-agent-strings.js";
7
7
  import { assetUrl } from "/assets/asset-url.js";
8
+ import { searchablePeopleQuery } from "./hub-people-query.js";
9
+ import { PeoplePaste, pasteText } from "./hub-people-paste.js";
8
10
  const refused=()=>({ok:false});
9
11
  const fields=agent=>({name:agent?.name??"",description:agent?.introBy?agent.intro:introPreview(agent?.description??""),cli:agent?.cli??"",model:agent?.model??"",ifRevision:agent?.revision??0,answerOnly:agent?.answerOnly===true});
10
12
  const policy=value=>({enabled:value.enabled===true,people:[...(value.people??[])],teams:[...(value.teams??[])]});
@@ -98,7 +100,7 @@ export function HubPersonalAgentAdmin({client,scope}){
98
100
  };
99
101
  useEffect(()=>{generation.current++;markBusy(false);setView(null);setForm(null);setError("");setSaved(false);setHits([]);void load();return()=>{generation.current++;};},[client,scope]);
100
102
  const edit=patch=>{setSaved(false);setForm(value=>({...value,...patch}));};
101
- const search=async()=>{if(query.trim().length<2||busy)return;const mine=generation.current,search=++searchSequence.current;let result;try{result=await client.teamSuggestions("person",query.trim());}catch{result=refused();}
103
+ const search=async()=>{if(!searchablePeopleQuery(query)||busy)return;const mine=generation.current,search=++searchSequence.current;let result;try{result=await client.teamSuggestions("person",query.trim());}catch{result=refused();}
102
104
  if(mine!==generation.current||search!==searchSequence.current)return;if(!result?.ok){setErrorKind("search");setError(hp("loadFailed"));return;}setError("");setHits(result.candidates??[]);
103
105
  };
104
106
  const pickPerson=row=>{if(!form.people.includes(row.id))edit({people:[...form.people,row.id]});setView(value=>({...value,peopleInfo:[...(value.peopleInfo??[]).filter(p=>p.id!==row.id),row]}));setHits([]);setQuery("");};
@@ -111,8 +113,11 @@ export function HubPersonalAgentAdmin({client,scope}){
111
113
  <p class="note">${hp("adminAlways")}</p><h4>${hp("allowed")}</h4>${!form.people.length&&!form.teams.length?html`<p class="note">${hp("onlyAdmin")}</p>`:null}
112
114
  ${form.people.map(id=>{const p=view.peopleInfo?.find(p=>p.id===id);return html`<div key=${id} class="s-row"><span class="hub-row-text"><strong>${p?.name||hp("unknownPerson")}</strong><small class="note">${p?.login||""}</small></span><button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${()=>edit({people:form.people.filter(p=>p!==id)})}>${hp("remove")}</button></div>`;})}
113
115
  ${form.teams.map(id=>html`<div key=${id} class="s-row"><span class="hub-row-text">${teams.find(t=>t.id===id)?.name||view.teamsInfo?.find(t=>t.id===id)?.name||hp("unknownTeam")}</span><button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${()=>edit({teams:form.teams.filter(t=>t!==id)})}>${hp("remove")}</button></div>`)}
114
- <label class="field"><span>${hp("search")}</span><input type="search" disabled=${busy} minlength="2" maxlength="64" value=${query} onInput=${e=>{searchSequence.current++;setQuery(e.target.value);setHits([]);}} /></label><button type="button" class="btn btn-sm" disabled=${busy||query.trim().length<2} onClick=${search}>${hp("find")}</button>
116
+ <label class="field"><span>${hp("search")}</span><input type="search" disabled=${busy} maxlength="64" value=${query} onInput=${e=>{searchSequence.current++;setQuery(e.target.value);setHits([]);}} /></label><button type="button" class="btn btn-sm" disabled=${busy||!searchablePeopleQuery(query)} onClick=${search}>${hp("find")}</button>
115
117
  ${hits.map(p=>html`<div key=${p.id} class="s-row"><span class="hub-row-text"><strong>${p.name}</strong><small class="note">${p.login||""}</small></span><button type="button" class="btn btn-sm" disabled=${busy} onClick=${()=>pickPerson(p)}>${hp("choose")}</button></div>`)}
118
+ ${typeof client.teamResolve==="function"?html`<${PeoplePaste} resolve=${entries=>client.teamResolve(entries)} disabled=${busy}
119
+ view=${c=>({id:c?.id||"",name:c?.name||"",detail:[c?.login,c?.department].filter(Boolean).join(" · ")})}
120
+ already=${c=>form.people.includes(c.id)} afterAdd=${pasteText("saveToFinish")} onAdd=${rows=>{const fresh=rows.filter(r=>!form.people.includes(r.id));edit({people:[...form.people,...fresh.map(r=>r.id)]});setView(value=>({...value,peopleInfo:[...(value.peopleInfo??[]).filter(p=>!fresh.some(r=>r.id===p.id)),...fresh]}));}} />`:null}
116
121
  <label class="field"><span>${hp("team")}</span><select disabled=${busy} value="" onChange=${e=>{if(e.target.value&&!form.teams.includes(e.target.value))edit({teams:[...form.teams,e.target.value]});}}><option value="">${hp("chooseTeam")}</option>${teams.filter(t=>!form.teams.includes(t.id)).map(t=>html`<option value=${t.id}>${t.name}</option>`)}</select></label>
117
122
  <div class="field-row"><button class="btn btn-sm btn-primary" disabled=${busy||!changed}>${hp("saveSettings")}</button>${changed||saved?html`<span class="note" role="status">${hp(changed?"unsaved":"savedSettings")}</span>`:null}</div></form>`:null}
118
123
  </section>`;
@@ -5,9 +5,10 @@ import {GroupSearch} from "./hub-group-search.js";
5
5
  import {hr} from "./hub-roles-strings.js";
6
6
  import {personKey,personName,roleName,roleDescription,permissionGroups,management,changeLines,reviewImpact,scopeName,valueLines} from "./hub-role-view.js";
7
7
  import { dateTimeText } from "/assets/clock-text.js";
8
+ import { pasteText } from "./hub-people-paste.js";
8
9
  const copy=value=>structuredClone(value);
9
10
  const dateValue=at=>at?new Date(at-new Date(at).getTimezoneOffset()*60000).toISOString().slice(0,16):"";
10
- export function RoleSearch({client,kind,onPick,disabled,id}){
11
+ export function RoleSearch({client,kind,onPick,disabled,id,multiple=false,already,room=50}){
11
12
  const candidates=useRef(new Map()),[revision,setRevision]=useState(0);
12
13
  const search=useMemo(()=>async(requested,q)=>{const out=await client.roleSearch(requested,q);if(!out.ok)return out;
13
14
  if(requested==="person")return {...out,people:out.candidates.map(row=>({person:row.key,displayName:row.name,login:row.login}))};
@@ -16,7 +17,14 @@ export function RoleSearch({client,kind,onPick,disabled,id}){
16
17
  return {...out,groups:out.candidates.map(row=>({objectId:row.key.objectId,cn:row.name,dn:row.dn}))};
17
18
  },[client]);
18
19
  const groups=useMemo(()=>({searchGroups:q=>search("group",q)}),[search]);
19
- return kind==="person"?html`<${PeopleSearch} key=${revision} search=${search} disabled=${disabled} id=${id} onPick=${row=>{onPick({kind:"person",key:row.person,name:row.displayName,login:row.login});setRevision(n=>n+1);}}/>`:html`<${GroupSearch} key=${revision} client=${groups} disabled=${disabled} id=${id} onPick=${row=>{const original=candidates.current.get(row.objectId);if(original){onPick(original);setRevision(n=>n+1);}}}/>`;
20
+ // M-3975: a pasted list (people only) when several may be picked; resolved by POST /hub/v1/roles/resolve.
21
+ const resolve=useMemo(()=>multiple&&typeof client.roleResolve==="function"?async entries=>{const out=await client.roleResolve(entries);
22
+ return Array.isArray(out?.resolved)?{...out,resolved:out.resolved.map(row=>({...row,candidates:row.candidates.map(c=>({person:c.key,displayName:c.name,login:c.login}))}))}:out;}:undefined,[client,multiple]);
23
+ return kind==="person"?html`<${PeopleSearch} key=${revision} search=${search} disabled=${disabled} id=${id} resolve=${resolve} already=${already}
24
+ onPickMany=${rows=>{// Only as many as the selection has room for (at most 50 in all); the rest come back as not added (Prism, #4652).
25
+ const fit=rows.slice(0,Math.max(0,room));for(const row of fit)onPick({kind:"person",key:row.person,name:row.displayName,login:row.login});
26
+ return {notAdded:rows.slice(fit.length).map(row=>({id:`${row.person.realm}/${row.person.objectId}`,reason:pasteText("overLimit",50)}))};}}
27
+ onPick=${row=>{onPick({kind:"person",key:row.person,name:row.displayName,login:row.login});setRevision(n=>n+1);}}/>`:html`<${GroupSearch} key=${revision} client=${groups} disabled=${disabled} id=${id} onPick=${row=>{const original=candidates.current.get(row.objectId);if(original){onPick(original);setRevision(n=>n+1);}}}/>`;
20
28
  }
21
29
  export function PermissionSections({permissions,onChange,disabled=false,readOnly=false,administrator=false}){
22
30
  const [small,setSmall]=useState(()=>typeof window!=="undefined"&&window.matchMedia?.("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)").matches);
@@ -92,7 +100,8 @@ export function AssignPanel({view,client,roleId:initialRole,assignment,checked,b
92
100
  <label class="field"><span>${hr("subject")}</span><select value=${kind} disabled=${busy} onChange=${e=>setKind(e.target.value)}><option value="person">${hr("people")}</option><option value="group" disabled=${adminRole}>${hr("groups")}</option></select></label>
93
101
  ${adminRole?html`<p class="s-info">${hr("personOnly")}</p>`:kind==="group"?html`<p class="s-info">${hr("groupCost")}</p>`:null}
94
102
  ${selected.length?html`<div class="chips hub-role-selected">${selected.map(s=>html`<span class="tag" key=${s.kind+personKey(s.key)}>${s.name}<button type="button" class="icon-btn" disabled=${busy} aria-label=${hr("removeSelection",s.name)} onClick=${()=>setSelected(old=>old.filter(row=>row!==s))}>×</button></span>`)}</div>`:null}
95
- <${RoleSearch} key=${kind} client=${client} kind=${kind} disabled=${busy||selected.length>=50} id="hubRoleSubject" onPick=${pick}/>
103
+ <${RoleSearch} key=${kind} client=${client} kind=${kind} disabled=${busy||selected.length>=50} id="hubRoleSubject" onPick=${pick} multiple=${!assignment} room=${50-selected.length}
104
+ already=${row=>selected.some(s=>s.kind==="person"&&personKey(s.key)===personKey(row.person))}/>
96
105
  ${teamRole&&!adminRole?html`<label class="field"><span>${hr("appliesTo")}</span><select value=${whole?"hub":"group"} disabled=${busy} onChange=${e=>setWhole(e.target.value==="hub")}><option value="group">${hr("scopeGroup")}</option><option value="hub" disabled=${!view.management.includes("hub.admin")}>${hr("wholeHub")}</option></select></label>${!whole?scope?html`<div class="s-row"><strong>${scope.name}</strong><button type="button" class="btn btn-sm" disabled=${busy} onClick=${()=>setScope(null)}>${hr("changeSubject")}</button></div>`:html`<${RoleSearch} client=${client} kind="group" id="hubRoleScope" disabled=${busy} onPick=${setScope}/>`:null}`:null}
97
106
  <details open=${!!assignment} class="hub-role-more"><summary>${hr("moreOptions")}</summary><div class="grid2"><label class="field"><span>${hr("start")}</span><input type="datetime-local" value=${start} disabled=${busy} onInput=${e=>setStart(e.target.value)}/></label><label class="field"><span>${hr("ends")}</span><input type="datetime-local" value=${end} disabled=${busy} onInput=${e=>setEnd(e.target.value)}/></label></div>
98
107
  ${role.permissions.includes("pair_fleet")?html`<label class="field"><span>${hr("limitPeople")} · ${hr("quota")}: ${role.defaultMaxFleets}</span><span class="hub-group-fleets"><input type="number" min="0" max="8" step="1" value=${limit} disabled=${busy} onInput=${e=>setLimit(e.target.value)}/></span></label>`:null}</details>
@@ -11,6 +11,7 @@ import { hubClient } from "./hub-client.js";
11
11
  import { hrq } from "./hub-room-owner-requests-strings.js";
12
12
  import { hroom } from "./hub-room-strings.js";
13
13
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
14
+ import { PeoplePaste, pasteText } from "./hub-people-paste.js";
14
15
 
15
16
  linkRoomsU2Css();
16
17
 
@@ -34,7 +35,7 @@ const keyOf = (item) => `${item.kind}:${item.id}`;
34
35
  * A picked AD group is read first (client.roomGroup): its tag shows its head count, and a group the directory cannot
35
36
  * read whole is not added — the other picks stay.
36
37
  */
37
- export function RoomPicker({ client, kinds, picked, onChange, placeholder, label, id, exclude = [], fixed = null, note = "", searchHelp = null } = {}) {
38
+ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label, id, exclude = [], fixed = null, note = "", searchHelp = null, alreadyLabel, paste = true } = {}) {
38
39
  const [q, setQ] = useState(""), [results, setResults] = useState(null), [failed, setFailed] = useState(false), [groupNote, setGroupNote] = useState("");
39
40
  const asked = useRef(0), timer = useRef(null), latest = useRef(picked), live = useRef(true);
40
41
  latest.current = picked;
@@ -83,6 +84,15 @@ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label
83
84
  <button type="button" role="option" class=${`hub-room-result${c.kind === "agent" ? " hub-room-result-agent" : ""}`} aria-label=${c.kind === "person" ? `${c.name}${c.detail ? `, ${c.detail}` : ""}` : c.kind === "agent" && !c.mine ? hrq("askOwnerLabel", c.owner?.name || "", c.name) : undefined} onClick=${() => { void pick(c); }}>${c.kind === "person" ? html`<span class="hub-room-person-label"><span class="hub-room-person-name" title=${c.name}>${c.name}</span>${c.detail ? html`<small class="note hub-room-person-detail" title=${c.detail}>${c.detail}</small>` : null}</span>` : c.kind === "agent" ? html`<span class="hub-room-agent-label"><span class="hub-room-agent-title">${c.name}${c.owner?.name ? html` <small class="note">${c.owner.name}</small>` : null}</span>${c.intro ? html`<small class="note hub-room-agent-intro" title=${c.intro}>${c.intro}</small>` : null}</span> ${!c.mine ? html`<span class="btn btn-sm hub-room-agent-action">${hrq("askOwner", c.owner?.name || "")}</span>` : null}` : pickLabel(c)}${c.kind !== "agent" && c.intro ? html` <small class="note">${c.intro}</small>` : null}</button></li>`)}</ul>`
84
85
  : html`<p class="note">${hn("noMatch")}</p>` : null}
85
86
  ${q.trim() ? searchHelp : null}
87
+ ${/* M-3975: a pasted list of people, resolved by POST /hub/v1/rooms/candidates; the picked people join the tags like a search pick. */ ""}
88
+ ${paste && kinds.includes("person") && typeof client.roomResolve === "function" ? html`<${PeoplePaste} resolve=${(entries) => client.roomResolve(entries)}
89
+ view=${(c) => ({ id: c?.id || "", name: c?.name || "", detail: c?.detail || "" })}
90
+ already=${(c) => taken.has(keyOf(c)) ? (alreadyLabel || true) : null} addWord="join"
91
+ onAdd=${async (rows) => {
92
+ // A place that writes at once (room settings, room creators) answers with what wasn't added; false means none was.
93
+ const have = new Set([...exclude, ...latest.current.map(keyOf)]), fresh = rows.filter(r => !have.has(keyOf(r)));
94
+ const out = await onChange([...latest.current, ...fresh]);
95
+ return out === false ? { notAdded: fresh.map(r => ({ id: r.id, reason: pasteText("refusedRow") })) } : out; }} />` : null}
86
96
  </div>`;
87
97
  }
88
98
 
@@ -134,7 +144,7 @@ export function NewRoomDialog({ client = hubClient(), onClose, onOpenRoom, assis
134
144
  aria-invalid=${error === hroom("nameRequired") || error === hn("nameTooLong") ? "true" : "false"} onInput=${(e) => { setName(e.target.value); if (error) setError(""); }} /></label>
135
145
  ${purposeSupported?html`<${RoomPurposeField} value=${purpose} onValue=${setPurpose} disabled=${busy} />`:null}
136
146
  ${error ? html`<p class="note hub-room-new-error" role="alert">${error}</p>` : null}
137
- <${RoomPicker} client=${client} id="hubRoomPeople" kinds=${["person", "team", "group"]} label=${hroom("members")} placeholder=${hroom("addPeople")}
147
+ <${RoomPicker} client=${client} id="hubRoomPeople" alreadyLabel=${pasteText("alreadyListed")} kinds=${["person", "team", "group"]} label=${hroom("members")} placeholder=${hroom("addPeople")}
138
148
  picked=${people} onChange=${(next) => { setPeople(next); setPeopleNote(""); }} fixed=${me} note=${peopleNote} />
139
149
  <${RoomPicker} client=${client} id="hubRoomAgents" kinds=${["agent", "team"]} label=${hn("agents")} placeholder=${hroom("addAgents")}
140
150
  picked=${agents} onChange=${setAgents} />
@@ -48,7 +48,7 @@ export function OwnerAgentRequestDialog({ client, roomId, roomName, onClose, onS
48
48
  <ul class="hub-room-tags" aria-labelledby="hubRequestOwnerLabel"><li class="tag">${owner.name}
49
49
  <button type="button" class="chip-btn" aria-label=${hn("remove", owner.name)} onClick=${() => { setPicked([]); setError(""); }}>×</button>
50
50
  </li></ul></div>`
51
- : html`<${RoomPicker} client=${client} id="hubRequestOwner" kinds=${["person"]} label=${hrq("choose")} placeholder=${hrq("search")}
51
+ : html`<${RoomPicker} client=${client} id="hubRequestOwner" paste=${false} kinds=${["person"]} label=${hrq("choose")} placeholder=${hrq("search")}
52
52
  picked=${picked} onChange=${next => { setPicked(next.slice(-1)); setError(""); }} />`}
53
53
  ${owner ? html`<p class="note">${hrq("lead", owner.name)}</p>
54
54
  <label class="field" for="hubOwnerAgentNote"><span>${hrq("note")}</span>
@@ -17,6 +17,7 @@ import { hroom, styleName } from "./hub-room-strings.js";
17
17
  import { hs } from "./hub-room-settings-strings.js";
18
18
  import {ha} from "./hub-ai-apps-strings.js";
19
19
  import { RoomPicker } from "./hub-room-new.js";
20
+ import { pasteText } from "./hub-people-paste.js";
20
21
  import { OwnerAgentRequestDialog, OwnerAgentRequestRows } from "./hub-room-owner-requests.js";
21
22
  import { hrq } from "./hub-room-owner-requests-strings.js";
22
23
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
@@ -132,9 +133,11 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
132
133
  void act(() => client.updateRoom(roomId, { name: title }), () => setName(room.name ?? ""));
133
134
  };
134
135
  /** A picked item is sent at once (the picker then starts empty again): a person, team or group joins; my agent joins; someone else's agent, or a team's agents, are invited. */
136
+ // M-3975 (Prism, #4652): returns what wasn't added, so a pasted list keeps refused and untried people with a reason.
135
137
  const add = async (next, setter) => {
136
138
  setter([]);
137
- for (const item of next) {
139
+ const notAdded = [];
140
+ for (const [i, item] of next.entries()) {
138
141
  const send = item.kind === "agent" && item.mine ? () => client.addRoomMember(roomId, { kind: "agent", id: item.id })
139
142
  : item.kind === "agent" ? () => client.inviteToRoom(roomId, { agents: [item.id] })
140
143
  : item.kind === "team-agents" ? () => client.inviteToRoom(roomId, { team: item.id })
@@ -145,8 +148,12 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
145
148
  if (no?.status === 503 && no.code === "group-unavailable" && item.kind === "group") { setPeopleNote(hn("groupUnavailable", item.name)); return true; }
146
149
  return false;
147
150
  });
148
- if (!r?.ok) break;
151
+ if (!r?.ok) {
152
+ notAdded.push({ id: item.id, reason: pasteText("refusedRow") }, ...next.slice(i + 1).map(rest => ({ id: rest.id, reason: pasteText("notTried") })));
153
+ break;
154
+ }
149
155
  }
156
+ return { notAdded };
150
157
  };
151
158
  const rowMenu = (m) => html`<${Menu} label=${hs("rowMenu", m.name)} items=${[
152
159
  m.kind === "person" ? { key: "role", label: m.role === "manager" ? hroom("makeMember") : hroom("makeManager"),
@@ -183,8 +190,8 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
183
190
  </section>
184
191
  <section class="form"><h4>${hroom("membersAndAgents")}</h4>
185
192
  <ul class="hub-settings-people">${members.filter(m => m.kind === "person").map(memberRow)}</ul>
186
- <${RoomPicker} client=${client} id="hubRoomAddPeople" kinds=${["person", "team", "group"]} label=${hroom("addMembers")} placeholder=${hroom("addPeople")}
187
- picked=${addPeople} exclude=${taken} note=${peopleNote} onChange=${(next) => { void add(next, setAddPeople); }} />
193
+ <${RoomPicker} client=${client} id="hubRoomAddPeople" alreadyLabel=${pasteText("alreadyRoom")} kinds=${["person", "team", "group"]} label=${hroom("addMembers")} placeholder=${hroom("addPeople")}
194
+ picked=${addPeople} exclude=${taken} note=${peopleNote} onChange=${(next) => add(next, setAddPeople)} />
188
195
  <ul class="hub-settings-agents">${members.filter(isAgent).map(memberRow)}</ul>
189
196
  ${invited.length ? html`<ul class="hub-settings-invited">${invited.map(row => html`<li class="hub-settings-row" key=${row.id} data-invitation=${row.id}><span>${invitedLabel(row)}</span>
190
197
  ${row.state === "expired"
@@ -235,7 +235,7 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
235
235
  // M-3125: a post's files, as the 1:1 chat maps them (images inline through the Hub's own route; HTML gets its preview card).
236
236
  ...(() => { const files = Array.isArray(m.files) ? m.files.map(hubFileAttachment).filter(Boolean) : []; return files.length ? { attachments: files } : {}; })(),
237
237
  ...(!direct && Array.isArray(m.reactions) && m.reactions.length ? { reactionBar: reactionBar(m.reactions, { meId, names }) } : {}),
238
- ...(!direct && kind !== "person" && m.buttons ? { buttons: roomButtons(m.buttons, meId) } : {}),
238
+ ...(kind !== "person" && m.buttons ? { buttons: roomButtons(m.buttons, meId) } : {}),
239
239
  ...(quotedId ? { replyTo: { boot: BOOT, id: num(quotedId), sender: quoted ? authorLine(quoted.author, quoted.author?.id === meId, direct) : "", text: quoted ? String(quoted.text || "").slice(0, 120) : "" } } : {}),
240
240
  ...(m.stage === "not-answered" && !(kind === "person" && m.reasonCode === "share-needs-reshare") ? { text: m.reasonCode === "owner-declined" ? hroom("noAnswerDeclined") : m.reasonCode === "share-needs-reshare" ? hroom("noAnswerReshare") : m.reasonCode === "owner-stopped-sharing" ? hroom("noAnswerStopped", author.owner?.name || "") : m.reasonCode==="finished-without-answer"?hroom("noAnswerUnanswered",author.name||""):hroom("noAnswer") } : {}) });
241
241
  if (kind === "person" && m.stage === "not-answered" && m.reasonCode === "share-needs-reshare")
@@ -257,7 +257,7 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
257
257
  * One room's store: `subscribe(fn)` → unsubscribe; `detail()` (the room GET: room, me, members, settings), `messages()`
258
258
  * (the thread's), `raw()` (seam-1 messages), `loaded()`, `error()`, `closed()` (archived, or I am no longer in it), `room()`;
259
259
  * `send(text, { mentions, replyTo })` → the client's answer (a refusal's code is the caller's to word; a soft warning is
260
- * stored and drawn), `older()`, `findQuoted(key)`, `markRead()`, `refresh()`, `stop()`. M-3127 B: `clickButton` / `vote` / `busy` / `mine` are the direct chat's button actions (hub-button-actions.js), on group rooms only.
260
+ * stored and drawn), `older()`, `findQuoted(key)`, `markRead()`, `refresh()`, `stop()`. M-3127 B: `clickButton` / `vote` / `busy` / `mine` are the direct chat's button actions (hub-button-actions.js), on group and supported direct rooms.
261
261
  */
262
262
  export function createRoomStore(roomId, { client, meId = "", pinsOn = false } = {}) {
263
263
  const subs = new Set(), ids = new Map(), expanded = new Set();
@@ -299,7 +299,7 @@ export function createRoomStore(roomId, { client, meId = "", pinsOn = false } =
299
299
  const on = (fn) => (data) => { if (st.live && data && data.roomId === roomId) { fn(data); changed(); } };
300
300
  // M-3127 B: an answer's buttons and polls — the direct chat's own actions (one key per intent, my vote kept in this tab),
301
301
  // on this room's messages; the Hub says who may press (403 not-asker) and closes polls.
302
- const actions = createHubButtonActions({ id: roomId, get features() { return closedNow() || st.detail?.room?.kind !== "group" ? [] : ["buttons-v1"]; } }, {
302
+ const actions = createHubButtonActions({ id: roomId, get features() { return closedNow() ? [] : st.detail?.room?.kind === "group" ? ["buttons-v1"] : st.detail?.room?.features || []; } }, {
303
303
  client, entries: () => st.view, refresh: () => refresh(), changed: () => { for (const fn of [...subs]) { try { fn(); } catch { /* a subscriber's own failure */ } } },
304
304
  });
305
305
  const unsubscribe = typeof client.subscribeRooms === "function" ? client.subscribeRooms({
@@ -2,19 +2,24 @@
2
2
  import { html, useEffect, useMemo, useRef, useState } from "/assets/app-html.js";
3
3
  import { register, t } from "/assets/app-i18n.js";
4
4
  import { GroupSearch } from "./hub-group-search.js";
5
+ import { searchablePeopleQuery } from "./hub-people-query.js";
6
+ import { PeoplePaste, pasteText } from "./hub-people-paste.js";
5
7
  register("hubSubjectPicker", {
6
- en: { kind:"Add a group, team or person", group:"AD group", team:"Team", person:"Person", teamPick:"Choose a team", findPerson:"Find a person", query:"Name or login", hint:"Type 2 to 64 characters.", searching:"Searching…", none:"No matching people. Try more of their name or login.", more:"More people match. Type more of the name.", pick:"Choose {0}", choose:"Choose", failed:"The directory could not be searched just now. Try again.", limited:"Too many searches. Try again shortly.", retry:"Search again", change:"Choose someone else", teamRow:"{0} · Team · {1} members · Lead: {2}", teamHint:"Its leads decide who is on this team.", personRow:"{0} · Person", teamChecked:"Team members checked: {0}" },
7
- "zh-TW": { kind:"新增群組、團隊或人員", group:"AD 群組", team:"團隊", person:"人員", teamPick:"選擇團隊", findPerson:"尋找同仁", query:"姓名或登入帳號", hint:"請輸入 2 到 64 個字。", searching:"搜尋中…", none:"找不到符合的同仁,請多輸入幾個姓名或帳號的字。", more:"還有更多同仁符合,請多輸入幾個字。", pick:"選擇 {0}", choose:"選擇", failed:"目前無法搜尋目錄,請再試一次。", limited:"搜尋太多次了,請稍後再試。", retry:"重新搜尋", change:"重新選擇對象", teamRow:"{0} · 團隊 · {1} 位成員 · 負責人:{2}", teamHint:"團隊成員由負責人決定。", personRow:"{0} · 人員", teamChecked:"已檢查的團隊成員:{0}" }
8
+ en: { kind:"Add a group, team or person", group:"AD group", team:"Team", person:"Person", teamPick:"Choose a team", findPerson:"Find a person", query:"Name or login", hint:"Type 2 to 64 characters.", peopleHint:"Type a name or account: 2 letters or more, or 1 Chinese character.", searching:"Searching…", none:"No matching people. Try more of their name or login.", more:"More people match. Type more of the name.", pick:"Choose {0}", choose:"Choose", failed:"The directory could not be searched just now. Try again.", limited:"Too many searches. Try again shortly.", retry:"Search again", change:"Choose someone else", teamRow:"{0} · Team · {1} members · Lead: {2}", teamHint:"Its leads decide who is on this team.", personRow:"{0} · Person", teamChecked:"Team members checked: {0}" },
9
+ "zh-TW": { kind:"新增群組、團隊或人員", group:"AD 群組", team:"團隊", person:"人員", teamPick:"選擇團隊", findPerson:"尋找同仁", query:"姓名或登入帳號", hint:"請輸入 2 到 64 個字。", peopleHint:"輸入姓名或帳號:至少 2 個英文字母,或 1 個中文字。", searching:"搜尋中…", none:"找不到符合的同仁,請多輸入幾個姓名或帳號的字。", more:"還有更多同仁符合,請多輸入幾個字。", pick:"選擇 {0}", choose:"選擇", failed:"目前無法搜尋目錄,請再試一次。", limited:"搜尋太多次了,請稍後再試。", retry:"重新搜尋", change:"重新選擇對象", teamRow:"{0} · 團隊 · {1} 位成員 · 負責人:{2}", teamHint:"團隊成員由負責人決定。", personRow:"{0} · 人員", teamChecked:"已檢查的團隊成員:{0}" }
8
10
  });
9
11
  export const subjectText = (key, ...args) => t(`hubSubjectPicker.${key}`, ...args);
10
12
  const g = subjectText;
11
13
  let sequence = 0;
12
- export function PeopleSearch({ search, disabled, onPick, id = "hubGrantPerson" }) {
14
+ /** Rows are { person, login, displayName }. M-3975: with `resolve`, a "Paste a list" box resolves many; `onPickMany` takes
15
+ * the picked rows (default: onPick each); `already(row)` names a person the place already has. */
16
+ const personView = (p) => ({ id: p?.person ? `${p.person.realm}/${p.person.objectId}` : "", name: p?.displayName || p?.login || "", detail: p?.login && p.login !== p.displayName ? p.login : "" });
17
+ export function PeopleSearch({ search, disabled, onPick, id = "hubGrantPerson", resolve, onPickMany, already, afterAdd = "" }) {
13
18
  const [query, setQuery] = useState(""), [answer, setAnswer] = useState(null), [busy, setBusy] = useState(false), [retry, setRetry] = useState(0);
14
19
  const sequence = useRef(0);
15
20
  useEffect(() => {
16
21
  const mine = ++sequence.current, q = query.trim(); setAnswer(null);
17
- if (q.length < 2 || q.length > 64) { setBusy(false); return; }
22
+ if (!searchablePeopleQuery(q)) { setBusy(false); return; }
18
23
  setBusy(true); const timer = setTimeout(async () => {
19
24
  let out; try { out = await search("person", q); } catch { out = { ok: false }; }
20
25
  if (mine !== sequence.current) return;
@@ -26,10 +31,12 @@ export function PeopleSearch({ search, disabled, onPick, id = "hubGrantPerson" }
26
31
  return html`<div class="hub-group-search">
27
32
  <label class="field" for=${id}><span>${g("findPerson")}</span><input id=${id} type="search" autocomplete="off" spellcheck=${false}
28
33
  disabled=${disabled} value=${query} placeholder=${g("query")} aria-describedby=${`${id}Note`} onInput=${e => setQuery(e.target.value)} /></label>
29
- <p id=${`${id}Note`} class="note" role="status">${busy ? g("searching") : !answer ? g("hint") : answer.ok ? hits.length ? answer.truncated ? g("more") : "" : g("none") : answer.status === 429 ? g("limited") : g("failed")}</p>
34
+ <p id=${`${id}Note`} class="note" role="status">${busy ? g("searching") : !answer ? g("peopleHint") : answer.ok ? hits.length ? answer.truncated ? g("more") : "" : g("none") : answer.status === 429 ? g("limited") : g("failed")}</p>
30
35
  ${answer && !answer.ok && !busy ? html`<button type="button" class="btn btn-sm" disabled=${disabled} onClick=${() => setRetry(n => n + 1)}>${g("retry")}</button>` : null}
31
36
  ${hits.length ? html`<ul class="hub-group-hits" role="list">${hits.map(p => html`<li key=${`${p.person?.realm}/${p.person?.objectId}`} class="s-row"><span class="hub-row-text"><strong>${p.displayName || p.login}</strong><small class="note"><code>${p.login}</code></small></span>
32
37
  <button type="button" class="btn btn-sm" disabled=${disabled} aria-label=${g("pick", p.displayName || p.login)} onClick=${() => onPick(p)}>${g("choose")}</button></li>`)}</ul>` : null}
38
+ ${resolve ? html`<${PeoplePaste} resolve=${resolve} view=${personView} disabled=${disabled} already=${already || (() => null)} afterAdd=${afterAdd}
39
+ onAdd=${(rows) => onPickMany ? onPickMany(rows) : rows.forEach(row => onPick(row))} />` : null}
33
40
  </div>`;
34
41
  }
35
42
  export function TeamPick({ client, disabled, onPick }) {
@@ -40,7 +47,7 @@ export function TeamPick({ client, disabled, onPick }) {
40
47
  return html`<label class="field"><span>${g("teamPick")}</span><select data-grant-team value="" disabled=${disabled} onChange=${e => { const row = answer.teams?.find(row => row.id === e.target.value); if (row) onPick(row); }}><option value="">${g("teamPick")}</option>${(answer.teams || []).map(row => html`<option value=${row.id}>${row.name}</option>`)}</select></label>`;
41
48
  }
42
49
 
43
- export function SubjectPicker({ client, search, kind: controlled, onKind, onPick, selected, onClear, disabled = false, id: inputId, exclude = [], onUnsupported, label, groupId }) {
50
+ export function SubjectPicker({ client, search, kind: controlled, onKind, onPick, selected, onClear, disabled = false, id: inputId, exclude = [], onUnsupported, label, groupId, resolve, onPickMany, already, afterAdd }) {
44
51
  const [local, setLocal] = useState("group"), id = useMemo(() => inputId || `hubSubject${++sequence}`, [inputId]);
45
52
  const kind = controlled || local;
46
53
  const query = useMemo(() => search || ((kind, q) => (kind === "group" ? client.searchGroups?.(q) : client.searchAllowedPeople?.(q)) || { ok: false, reason: "unsupported" }), [client, search]);
@@ -51,7 +58,9 @@ export function SubjectPicker({ client, search, kind: controlled, onKind, onPick
51
58
  <label class="field"><span>${label || g("kind")}</span><select data-subject-kind data-grant-kind=${inputId === "hubGrant" ? true : undefined} value=${kind} disabled=${disabled} onChange=${e => { setLocal(e.target.value); onKind?.(e.target.value); }}>
52
59
  <option value="group">${g("group")}</option>${teamLive ? html`<option value="team">${g("team")}</option>` : null}<option value="person">${g("person")}</option></select></label>
53
60
  ${selected ? html`<div class="s-row"><span class="hub-row-text"><strong>${selected.name || selected.displayName || selected.cn || selected.login}</strong><small class="note"><code>${selected.login || selected.dn || ""}</code></small></span><button type="button" class="btn btn-sm" disabled=${disabled} onClick=${onClear}>${g("change")}</button></div>`
54
- : kind === "person" ? html`<${PeopleSearch} search=${query} disabled=${disabled} id=${`${id}Person`} onPick=${picked} />`
61
+ : kind === "person" ? html`<${PeopleSearch} search=${query} disabled=${disabled} id=${`${id}Person`} onPick=${picked}
62
+ resolve=${resolve === undefined && !search && typeof client.resolveAllowedPeople === "function" ? (entries) => client.resolveAllowedPeople(entries) : resolve || undefined}
63
+ onPickMany=${onPickMany} already=${already} afterAdd=${afterAdd} />`
55
64
  : kind === "team" ? html`<${TeamPick} client=${client} disabled=${disabled} onPick=${picked} />`
56
65
  : html`<${GroupSearch} client=${groups} id=${groupId || `${id}Group`} disabled=${disabled} exclude=${exclude} unknownHint=${g("failed")} onUnsupported=${onUnsupported} onPick=${picked} />`}
57
66
  </div>`;
@@ -9,7 +9,7 @@ register("hubTeam", {
9
9
  create: "New team", edit: "Edit {0}", empty: "No teams yet.", noMine: "You do not lead any teams.", loading: "Loading teams…", retry: "Try again", refresh: "Refresh", back: "All teams",
10
10
  name: "Team name", department: "Department (optional)", departmentLine: "Department: {0}", chooseDepartment: "Choose a department", departmentQuery: "Search AD departments", leadPerson: "Leads (up to 5)", chooseLead: "Choose a lead",
11
11
  members: "Members", role: "Role", roleLead: "Lead", roleMember: "Member", signedIn: "Joined Hub", agents: "Shared agents", yes: "Yes", notYet: "Not yet", unobserved: "Not checked yet", none: "None",
12
- add: "Add member", remove: "Remove", search: "Search", personQuery: "Search everyone by name", searchHint: "Type 2 to 64 characters. People in any department can be selected.", groupHint: "Type 2 to 64 characters of the department name.",
12
+ add: "Add member", remove: "Remove", search: "Search", personQuery: "Search everyone by name", searchHint: "Type a name or account: 2 letters or more, or 1 Chinese character. People in any department can be selected.", groupHint: "Type 2 to 64 characters of the department name.",
13
13
  searching: "Searching…", noMatches: "No matches. Try more of the name.", choose: "Choose {0}", pick: "Choose", cancel: "Cancel", change: "Change", save: "Save", saving: "Saving…", saved: "Saved.", unsaved: "Unsaved changes",
14
14
  limit: "Up to 200 members, including the lead.", count: "{0} members", leadRequired: "Leads are members. Name another lead before you leave.",
15
15
  disabledLead: "The lead's directory account is disabled. Choose a new lead.",
@@ -26,7 +26,7 @@ register("hubTeam", {
26
26
  create: "新增團隊", edit: "編輯 {0}", empty: "還沒有團隊。", noMine: "你目前沒有負責的團隊。", loading: "正在讀取團隊…", retry: "再試一次", refresh: "重新整理", back: "所有團隊",
27
27
  name: "團隊名稱", department: "部門(選填)", departmentLine: "所屬部門:{0}", chooseDepartment: "選擇部門", departmentQuery: "搜尋 AD 部門", leadPerson: "負責人(最多 5 位)", chooseLead: "選擇負責人",
28
28
  members: "成員", role: "身分", roleLead: "負責人", roleMember: "成員", signedIn: "已加入 Hub", agents: "分享的 Agent", yes: "已加入", notYet: "尚未加入", unobserved: "尚未確認", none: "無",
29
- add: "加入成員", remove: "移除", search: "搜尋", personQuery: "輸入姓名搜尋所有人", searchHint: "請輸入 2 到 64 個字,可以選擇其他部門的同仁。", groupHint: "請輸入部門名稱的 2 到 64 個字。",
29
+ add: "加入成員", remove: "移除", search: "搜尋", personQuery: "輸入姓名搜尋所有人", searchHint: "輸入姓名或帳號:至少 2 個英文字母,或 1 個中文字。可以選擇其他部門的同仁。", groupHint: "請輸入部門名稱的 2 到 64 個字。",
30
30
  searching: "搜尋中…", noMatches: "找不到符合的對象,請多輸入幾個姓名的字。", choose: "選擇 {0}", pick: "選擇", cancel: "取消", change: "變更", save: "儲存", saving: "儲存中…", saved: "已儲存。", unsaved: "尚未儲存",
31
31
  limit: "最多 200 位成員,包含負責人。", count: "{0} 位成員", leadRequired: "負責人也是成員。離開之前,請先指定另一位負責人。",
32
32
  disabledLead: "負責人的帳號已停用,請指定新的負責人。",
@@ -4,6 +4,8 @@ import { Icon } from "/assets/ui-icons.js";
4
4
  import { navigate } from "/assets/app-nav.js";
5
5
  import { ht } from "./hub-teams-strings.js";
6
6
  import { assetUrl } from "/assets/asset-url.js";
7
+ import { searchablePeopleQuery } from "./hub-people-query.js";
8
+ import { PeoplePaste, pasteText } from "./hub-people-paste.js";
7
9
 
8
10
  const changes = new Set();
9
11
  const changed = () => { for (const fn of changes) fn(); };
@@ -64,12 +66,13 @@ export function HubMyTeamsEntry({ client, person, active, onPick }) {
64
66
  }
65
67
 
66
68
  /** Feedback is cancellable and never applies a result from a previous query or team. */
67
- export function TeamSuggestions({ client, kind = "person", teamId, disabled, onPick, policy = false }) {
69
+ /** M-3975: with `onPickMany` (people only), a "Paste a list" box resolves many through POST /hub/v1/teams/candidates. */
70
+ export function TeamSuggestions({ client, kind = "person", teamId, disabled, onPick, policy = false, onPickMany, already }) {
68
71
  const [query, setQuery] = useState(""), [answer, setAnswer] = useState(null), [busy, setBusy] = useState(false), epoch = useRef(0), controller = useRef(null);
69
72
  useEffect(() => { epoch.current++; controller.current?.abort(); setAnswer(null); setBusy(false);
70
73
  return () => { epoch.current++; controller.current?.abort(); }; }, [client, kind, teamId]);
71
74
  const search = async () => {
72
- const q = query.trim(); if (disabled || q.length < 2 || q.length > 64) return;
75
+ const q = query.trim(); if (disabled || !searchablePeopleQuery(q)) return;
73
76
  const mine = ++epoch.current; controller.current?.abort(); const current = controller.current = new AbortController(); setBusy(true); setAnswer(null);
74
77
  let out; try { out = await client.teamSuggestions(kind, q, teamId, current.signal); } catch { out = { ok: false }; }
75
78
  if (mine !== epoch.current || current.signal.aborted) return;
@@ -81,10 +84,13 @@ export function TeamSuggestions({ client, kind = "person", teamId, disabled, onP
81
84
  placeholder=${ht(kind === "group" ? policy ? "groupQuery" : "departmentQuery" : "personQuery")} value=${query} disabled=${disabled}
82
85
  onInput=${e => { epoch.current++; controller.current?.abort(); setQuery(e.target.value); setAnswer(null); setBusy(false); }}
83
86
  onKeyDown=${e => { if (e.key === "Enter") { e.preventDefault(); void search(); } }} /></label>
84
- <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>
87
+ <button type="button" class="btn hub-team-button" disabled=${disabled || busy || !searchablePeopleQuery(query)} onClick=${search}>${ht("search")}</button></div>
85
88
  <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>
86
89
  ${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>
87
90
  <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}
91
+ ${kind === "person" && onPickMany && typeof client.teamResolve === "function" ? html`<${PeoplePaste} resolve=${(entries) => client.teamResolve(entries, teamId)}
92
+ view=${(c) => ({ id: c?.id || "", name: c?.name || "", detail: [c?.login, c?.department].filter(Boolean).join(" · ") })}
93
+ already=${already || (() => null)} disabled=${disabled} onAdd=${onPickMany} closable=${false} addWord="join" afterAdd=${pasteText("saveToFinish")} />` : null}
88
94
  </div>`;
89
95
  }
90
96
  const draftFrom = team => ({ name: team?.name || "", department: team?.department || "", departmentName: team?.departmentName || "", lead: team?.lead || "", leads: leadIds(team),
@@ -131,6 +137,13 @@ function TeamEditor({ client, id, mode, onSaved, onBack }) {
131
137
  if (mine !== epoch.current) return; writing.current = false; setBusy(false);
132
138
  if (out.ok) { changed(); onBack(); } else setError(errorText(out, true));
133
139
  };
140
+ // M-3975: a pasted list joins the members draft (up to the 200-person limit); nothing is saved until Save.
141
+ const pickMany = rows => {
142
+ const room = Math.max(0, 200 - draft.members.length), fresh = rows.filter(row => !draft.members.some(member => member.id === row.id));
143
+ setSaved(false); setDraft(old => ({ ...old, members: [...old.members, ...fresh.slice(0, room).filter(row => !old.members.some(m => m.id === row.id))] }));
144
+ // The picker stays open: the paste box says who was added and keeps the rest (Lumen, #4652).
145
+ return { notAdded: fresh.slice(room).map(row => ({ id: row.id, reason: ht("limit") })) };
146
+ };
134
147
  const pick = row => {
135
148
  setSaved(false);
136
149
  if (picker === "department") setDraft(old => ({ ...old, department: row.id, departmentName: row.name }));
@@ -146,7 +159,8 @@ function TeamEditor({ client, id, mode, onSaved, onBack }) {
146
159
  <div class="hub-team-head"><p class="note">${ht("departmentLine", draft.departmentName || ht("chooseDepartment"))}</p>${html`<button type="button" class="btn hub-team-button" disabled=${busy || !allowed} onClick=${() => setPicker("department")}>${ht("change")}</button>${draft.department ? html`<button type="button" class="btn hub-team-button" disabled=${busy || !allowed} onClick=${() => setDraft(old => ({...old,department:"",departmentName:""}))}>${ht("clearDepartment")}</button>` : null}`}</div>
147
160
  ${view?.leadEligible === false ? html`<p class="warn" role="status">${ht("disabledLead")}</p>` : null}
148
161
  <div class="hub-team-head"><p>${ht("leadPerson")}: <strong>${draft.leads.map(id => draft.members.find(row => row.id === id)?.name || id).join(", ") || ht("creatorLead")}</strong></p>${id ? html`<button type="button" class="btn hub-team-button" disabled=${busy || !allowed || draft.leads.length >= 5} onClick=${() => setPicker("lead")}>${ht("chooseLead")}</button>` : null}</div>
149
- ${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}
162
+ ${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}
163
+ onPickMany=${picker === "member" ? pickMany : undefined} already=${row => draft.members.some(member => member.id === row.id) ? pasteText("alreadyTeam") : null} /><button type="button" class="btn hub-team-button" onClick=${() => setPicker(null)}>${ht("cancel")}</button></div>` : null}
150
164
  <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>
151
165
  <p class="note">${ht("limit")} ${ht("leadRequired")}</p>
152
166
  <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>
@@ -193,6 +207,8 @@ function CreationSettings({client,settings,onSaved}) {
193
207
  ${selected ? html`<p class="note">${ht("adminSelected")}</p>` : null}
194
208
  ${selected ? html`<ul class="hub-team-list">${rows.map(row => html`<li key=${row.kind+row.id}><span class="grow">${row.name} · ${ht(row.kind === "person" ? "personKind" : "groupKind")}</span><button type="button" class="btn hub-team-button" disabled=${busy} aria-label=${ht("remove")+" "+row.name} onClick=${() => setRows(rows.filter(r => r !== row))}>${ht("remove")}</button></li>`)}</ul>
195
209
  <div class="hub-team-actions"><button type="button" class="btn hub-team-button" disabled=${busy || rows.length >= 100} onClick=${() => setKind("person")}>${ht("addPerson")}</button><button type="button" class="btn hub-team-button" disabled=${busy || rows.length >= 100} onClick=${() => setKind("group")}>${ht("addGroup")}</button></div>
196
- ${kind ? html`<${TeamSuggestions} client=${client} kind=${kind} policy=${true} disabled=${busy} onPick=${row => {setRows(old => old.some(r => r.kind === row.kind && r.id === row.id) ? old : [...old,row]);setKind(null);}} />` : null}` : null}
210
+ ${kind ? html`<${TeamSuggestions} client=${client} kind=${kind} policy=${true} disabled=${busy} onPick=${row => {setRows(old => old.some(r => r.kind === row.kind && r.id === row.id) ? old : [...old,row]);setKind(null);}}
211
+ onPickMany=${rows_ => {setRows(old => [...old, ...rows_.filter(row => !old.some(r => r.kind === row.kind && r.id === row.id))]);setKind(null);}}
212
+ already=${row => rows.some(r => r.kind === "person" && r.id === row.id)} />` : null}` : null}
197
213
  ${error ? html`<p class="err" role="alert">${error}</p>` : null}<button type="button" class="btn hub-team-button" disabled=${busy} onClick=${save}>${ht(busy ? "saving" : "save")}</button></section>`;
198
214
  }