dsh-wecom-bot 0.2.1 → 0.5.0

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 (52) hide show
  1. package/README.md +254 -68
  2. package/dist/client.js +1489 -624
  3. package/dist/host/bridge/commands.js +321 -48
  4. package/dist/host/bridge/commands.js.map +1 -1
  5. package/dist/host/bridge/directory.js +33 -10
  6. package/dist/host/bridge/directory.js.map +1 -1
  7. package/dist/host/bridge/format.js +23 -0
  8. package/dist/host/bridge/format.js.map +1 -1
  9. package/dist/host/bridge/index.js +227 -104
  10. package/dist/host/bridge/index.js.map +1 -1
  11. package/dist/host/bridge/interactions.js +2 -2
  12. package/dist/host/bridge/interactions.js.map +1 -1
  13. package/dist/host/bridge/notices.js +247 -46
  14. package/dist/host/bridge/notices.js.map +1 -1
  15. package/dist/host/bridge/outbox.js.map +1 -1
  16. package/dist/host/bridge/policy.js +16 -16
  17. package/dist/host/bridge/policy.js.map +1 -1
  18. package/dist/host/bridge/selection.js +1 -0
  19. package/dist/host/bridge/selection.js.map +1 -1
  20. package/dist/host/catalog.js +70 -7
  21. package/dist/host/catalog.js.map +1 -1
  22. package/dist/host/config.js +49 -31
  23. package/dist/host/config.js.map +1 -1
  24. package/dist/host/groups-view.js +394 -0
  25. package/dist/host/groups-view.js.map +1 -0
  26. package/dist/host/index.js +13 -20
  27. package/dist/host/index.js.map +1 -1
  28. package/dist/host/models.js +106 -0
  29. package/dist/host/models.js.map +1 -0
  30. package/dist/host/observation.js +53 -60
  31. package/dist/host/observation.js.map +1 -1
  32. package/dist/host/presets.js +49 -0
  33. package/dist/host/presets.js.map +1 -0
  34. package/dist/host/routes.js +81 -4
  35. package/dist/host/routes.js.map +1 -1
  36. package/dist/host/routing.js +71 -0
  37. package/dist/host/routing.js.map +1 -0
  38. package/dist/host/runtime.js +232 -23
  39. package/dist/host/runtime.js.map +1 -1
  40. package/dist/host/session-ops.js +132 -0
  41. package/dist/host/session-ops.js.map +1 -0
  42. package/dist/host/session-title.js +47 -0
  43. package/dist/host/session-title.js.map +1 -0
  44. package/dist/host/sessions.js +145 -0
  45. package/dist/host/sessions.js.map +1 -0
  46. package/dist/host/store.js +408 -0
  47. package/dist/host/store.js.map +1 -0
  48. package/dist/host/workspaces.js +154 -0
  49. package/dist/host/workspaces.js.map +1 -0
  50. package/dist/shared/protocol.js +33 -0
  51. package/dist/shared/protocol.js.map +1 -1
  52. package/package.json +2 -2
package/dist/client.js CHANGED
@@ -35,13 +35,23 @@ window.__ModuleLoader__.load({
35
35
  var CONFIG_NAMESPACE = "wecom-bot";
36
36
  var DEFAULT_SECRET_REF = "WECOM_BOT_SECRET";
37
37
  var STATE_ROUTE = "/api/wecom-bot/state";
38
+ var STORE_ROUTE = "/api/wecom-bot/store";
39
+ var MIN_QUESTION_TIMEOUT_MS = 1e3;
40
+ var MAX_QUESTION_TIMEOUT_MS = 3e5;
41
+ var DEFAULT_QUESTION_TIMEOUT_MS = 6e4;
42
+ var MIN_LOG_RETENTION_DAYS = 1;
43
+ var MAX_LOG_RETENTION_DAYS = 365;
44
+ var DEFAULT_LOG_RETENTION_DAYS = 14;
38
45
 
39
46
  // src/client/components/SettingsPage.tsx
40
- var import_react6 = require("react");
41
- var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
47
+ var import_react7 = require("react");
48
+
49
+ // src/client/hooks.ts
50
+ var import_react = require("react");
42
51
 
43
52
  // src/client/api.ts
44
53
  var STATE_URL = STATE_ROUTE.replace(/^\//, "");
54
+ var STORE_URL = STORE_ROUTE.replace(/^\//, "");
45
55
  async function fetchState(refresh, signal) {
46
56
  const response = await fetch(`${STATE_URL}${refresh ? "?refresh=1" : ""}`, {
47
57
  credentials: "same-origin",
@@ -53,6 +63,30 @@ window.__ModuleLoader__.load({
53
63
  if (!response.ok) throw new Error(`插件状态读取失败(HTTP ${response.status})。`);
54
64
  return await response.json();
55
65
  }
66
+ async function postStore(ops) {
67
+ let response;
68
+ try {
69
+ response = await fetch(STORE_URL, {
70
+ method: "POST",
71
+ credentials: "same-origin",
72
+ cache: "no-store",
73
+ headers: { "content-type": "application/json" },
74
+ body: JSON.stringify({ ops })
75
+ });
76
+ } catch {
77
+ throw new Error("无法连接插件后台,请确认 DSH 仍在运行。");
78
+ }
79
+ if (response.status === 401 || response.status === 403) throw new Error("DSH 登录已失效,请刷新页面。");
80
+ if (response.status === 404) throw new Error("插件后台尚未加载新版本,请重启 DSH 后再试。");
81
+ let body;
82
+ try {
83
+ body = await response.json();
84
+ } catch {
85
+ throw new Error(`修改失败(HTTP ${response.status})。`);
86
+ }
87
+ if (!body.ok) throw new Error(body.error ?? `修改失败(HTTP ${response.status})。`);
88
+ return body;
89
+ }
56
90
  function unwrap(result) {
57
91
  if (result && typeof result === "object" && "ok" in result && typeof result.ok === "boolean") {
58
92
  const envelope = result;
@@ -71,8 +105,220 @@ window.__ModuleLoader__.load({
71
105
  if (result !== void 0) unwrap(result);
72
106
  }
73
107
 
108
+ // src/client/model.ts
109
+ var DEFAULTS = {
110
+ botId: "",
111
+ secretEnv: DEFAULT_SECRET_REF
112
+ };
113
+ function text(value, fallback = "") {
114
+ return typeof value === "string" ? value : fallback;
115
+ }
116
+ function storedFrom(value) {
117
+ const v = value ?? {};
118
+ return {
119
+ botId: text(v.botId),
120
+ secretEnv: text(v.secretEnv).trim() || DEFAULTS.secretEnv
121
+ };
122
+ }
123
+ function normalizedScalar(key, draft) {
124
+ const value = draft[key];
125
+ return typeof value === "string" ? value.trim() : value;
126
+ }
127
+ function changedOperations(draft, base) {
128
+ const ops = [];
129
+ if (normalizedScalar("botId", draft) !== normalizedScalar("botId", base)) {
130
+ ops.push({ op: "set", path: ["botId"], value: normalizedScalar("botId", draft) });
131
+ }
132
+ return ops;
133
+ }
134
+ function validateCredentials(draft, secretConfigured) {
135
+ const errors = {};
136
+ if (!draft.botId.trim()) errors.botId = "请填写企业微信 Bot ID。";
137
+ if (!draft.secret.trim() && !secretConfigured) errors.secret = "首次配置需要填写 Bot Secret。";
138
+ return errors;
139
+ }
140
+ function validateAdvanced(draft) {
141
+ const errors = {};
142
+ const wsUrl = draft.wsUrl.trim();
143
+ if (wsUrl) {
144
+ try {
145
+ const url = new URL(wsUrl);
146
+ if (url.protocol !== "wss:" || url.username || url.password) errors.wsUrl = "只接受不含账号密码的 wss:// 地址。";
147
+ } catch {
148
+ errors.wsUrl = "不是有效的 URL。";
149
+ }
150
+ }
151
+ if (!Number.isFinite(draft.questionTimeoutMs) || draft.questionTimeoutMs < MIN_QUESTION_TIMEOUT_MS || draft.questionTimeoutMs > MAX_QUESTION_TIMEOUT_MS) {
152
+ errors.questionTimeoutMs = `请输入 ${MIN_QUESTION_TIMEOUT_MS / 1e3}–${MAX_QUESTION_TIMEOUT_MS / 1e3} 秒。`;
153
+ }
154
+ if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < MIN_LOG_RETENTION_DAYS || draft.logRetentionDays > MAX_LOG_RETENTION_DAYS) {
155
+ errors.logRetentionDays = `请输入 ${MIN_LOG_RETENTION_DAYS}–${MAX_LOG_RETENTION_DAYS} 的整数天数。`;
156
+ }
157
+ return errors;
158
+ }
159
+ function advancedSlice(settings) {
160
+ return {
161
+ remoteApprovals: settings?.remoteApprovals ?? false,
162
+ questionTimeoutMs: settings?.questionTimeoutMs ?? DEFAULT_QUESTION_TIMEOUT_MS,
163
+ wsUrl: settings?.wsUrl ?? "",
164
+ logEnabled: settings?.logEnabled ?? true,
165
+ logRetentionDays: settings?.logRetentionDays ?? DEFAULT_LOG_RETENTION_DAYS
166
+ };
167
+ }
168
+ function settingsPatch(draft, stored) {
169
+ const patch = {};
170
+ if (draft.remoteApprovals !== stored.remoteApprovals) patch.remoteApprovals = draft.remoteApprovals;
171
+ if (draft.questionTimeoutMs !== stored.questionTimeoutMs) patch.questionTimeoutMs = draft.questionTimeoutMs;
172
+ if (draft.wsUrl.trim() !== stored.wsUrl.trim()) patch.wsUrl = draft.wsUrl.trim();
173
+ if (draft.logEnabled !== stored.logEnabled) patch.logEnabled = draft.logEnabled;
174
+ if (draft.logRetentionDays !== stored.logRetentionDays) patch.logRetentionDays = draft.logRetentionDays;
175
+ return patch;
176
+ }
177
+ function toggle(values, id, on) {
178
+ const has = values.includes(id);
179
+ const want = on ?? !has;
180
+ if (want === has) return [...values];
181
+ return want ? [...values, id] : values.filter((value) => value !== id);
182
+ }
183
+ function scopeIncludes(values, path) {
184
+ return values.length === 0 || values.includes(path);
185
+ }
186
+ function toggleScope(values, allPaths, path, on) {
187
+ const next = new Set(values.length ? values : allPaths);
188
+ if (on) next.add(path);
189
+ else next.delete(path);
190
+ if (next.size >= allPaths.length) return [];
191
+ return allPaths.filter((item) => next.has(item));
192
+ }
193
+ function modelKey(provider, model) {
194
+ return provider && model ? `${provider}\0${model}` : "";
195
+ }
196
+ function parseModelKey(key) {
197
+ const [provider = "", model = ""] = key.split("\0");
198
+ return { provider, model };
199
+ }
200
+ function choiceLabel(choice) {
201
+ return choice.name === choice.model ? choice.model : `${choice.name}(${choice.model})`;
202
+ }
203
+ function effortsFor(catalog, provider, model) {
204
+ const choice = catalog?.choices.find((item) => item.provider === provider && item.model === model);
205
+ return choice?.efforts ?? [];
206
+ }
207
+ function modelLabel(catalog, selection) {
208
+ if (!selection) return "";
209
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
210
+ return choice ? choiceLabel(choice) : `${selection.provider}/${selection.model}`;
211
+ }
212
+ function modelName(catalog, selection) {
213
+ if (!selection) return "";
214
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
215
+ return choice ? choice.name : selection.model;
216
+ }
217
+ function effortLabel(catalog, selection) {
218
+ const effort = selection?.reasoningEffort;
219
+ if (!effort) return "";
220
+ const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
221
+ return choice?.efforts?.find((item) => item.id === effort)?.name ?? effort;
222
+ }
223
+ var BUILT_IN_PRESET_NAME = {
224
+ standard: "标准",
225
+ ptc: "PTC",
226
+ minimal: "极简",
227
+ cordis: "Cordis"
228
+ };
229
+ function presetName(preset) {
230
+ return preset.name || BUILT_IN_PRESET_NAME[preset.id] || preset.id;
231
+ }
232
+ function presetLabel(presets, id) {
233
+ if (!id) {
234
+ const fallback = presets?.presets.find((preset) => preset.isDefault);
235
+ return fallback ? `跟随 DSH 默认(${presetName(fallback)})` : "跟随 DSH 默认";
236
+ }
237
+ const found = presets?.presets.find((preset) => preset.id === id);
238
+ return found ? presetName(found) : id;
239
+ }
240
+ function presetSummaryLabel(presets, id) {
241
+ if (id) return presetLabel(presets, id);
242
+ const fallback = presets?.presets.find((preset) => preset.isDefault);
243
+ return fallback ? `${presetName(fallback)}(DSH 默认)` : "DSH 默认";
244
+ }
245
+ function formatTokens(value) {
246
+ if (value < 1e3) return String(Math.round(value));
247
+ if (value < 1e5) return `${(value / 1e3).toFixed(1)}k`;
248
+ if (value < 1e6) return `${Math.round(value / 1e3)}k`;
249
+ return `${(value / 1e6).toFixed(1)}M`;
250
+ }
251
+ function contextLabel(context) {
252
+ if (!context) return "";
253
+ const used = formatTokens(context.used);
254
+ if (!context.window) return used;
255
+ return `${used} / ${formatTokens(context.window)}(${Math.round(context.used / context.window * 100)}%)`;
256
+ }
257
+ function dshDefaultLabel(catalog) {
258
+ const value = catalog?.dshDefault;
259
+ if (!value) return "跟随 DSH 默认模型";
260
+ return `跟随 DSH 默认模型(${modelName(catalog, value)})`;
261
+ }
262
+ var BINDING_KIND_LABEL = { user: "个人", group: "群聊" };
263
+ var SESSION_STATE_LABEL = {
264
+ bound: "已绑定",
265
+ auto: "待创建",
266
+ blank: "待使用",
267
+ missing: "会话不存在",
268
+ archived: "会话已归档",
269
+ unusable: "会话不可用"
270
+ };
271
+ function personKey(kind, id) {
272
+ return `${kind}:${id}`;
273
+ }
274
+ function groupModelSummary(catalog, group) {
275
+ if (group.effectiveProvider && group.effectiveModel) {
276
+ return modelName(catalog, { provider: group.effectiveProvider, model: group.effectiveModel });
277
+ }
278
+ const fallback = catalog?.dshDefault;
279
+ return fallback ? `${modelName(catalog, fallback)}(DSH 默认)` : "DSH 默认";
280
+ }
281
+ function displayPath(path) {
282
+ return (path ?? "").replace(/^(\/Users|\/home)\/[^/]+(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+(?=\\|$)/, "~");
283
+ }
284
+ function relativeTime(at, now = Date.now()) {
285
+ if (!at) return "";
286
+ const diff = Math.max(0, now - at);
287
+ if (diff < 6e4) return "刚刚";
288
+ if (diff < 36e5) return `${Math.floor(diff / 6e4)} 分钟前`;
289
+ if (diff < 864e5) return `${Math.floor(diff / 36e5)} 小时前`;
290
+ if (diff < 30 * 864e5) return `${Math.floor(diff / 864e5)} 天前`;
291
+ return new Date(at).toLocaleDateString();
292
+ }
293
+ function setSettings(patch) {
294
+ return { op: "settings.set", patch };
295
+ }
296
+ function addGroup(name) {
297
+ return { op: "group.add", ...name ? { name } : {} };
298
+ }
299
+ function updateGroup(id, patch) {
300
+ return { op: "group.update", id, patch };
301
+ }
302
+ function deleteGroup(id) {
303
+ return { op: "group.delete", id };
304
+ }
305
+ function addMember(groupId, kind, id, label) {
306
+ return { op: "member.add", groupId, kind, id, ...label ? { label } : {} };
307
+ }
308
+ function updateMember(key, patch) {
309
+ return { op: "member.update", key, patch };
310
+ }
311
+ function setLabel(key, label) {
312
+ return { op: "label.set", key, label };
313
+ }
314
+ function removeMember(key) {
315
+ return { op: "member.remove", key };
316
+ }
317
+ function archiveMember(key) {
318
+ return { op: "member.archive", key };
319
+ }
320
+
74
321
  // src/client/hooks.ts
75
- var import_react = require("react");
76
322
  function useFormSnapshot(scope) {
77
323
  return (0, import_react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
78
324
  }
@@ -149,217 +395,142 @@ window.__ModuleLoader__.load({
149
395
  }), [remote, ref, refresh]);
150
396
  return { configured, known, refresh };
151
397
  }
152
-
153
- // src/client/model.ts
154
- var DEFAULTS = {
155
- botId: "",
156
- secretEnv: DEFAULT_SECRET_REF,
157
- chatIds: [],
158
- sessionIds: [],
159
- allowedUserIds: [],
160
- wsUrl: "",
161
- questionTimeoutMs: 6e4,
162
- remoteApprovals: false,
163
- logEnabled: true,
164
- logRetentionDays: 14
165
- };
166
- var LIST_KEYS = ["chatIds", "sessionIds", "allowedUserIds"];
167
- var SCALAR_KEYS = ["botId", "wsUrl", "questionTimeoutMs", "remoteApprovals", "logEnabled", "logRetentionDays"];
168
- function list(value) {
169
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
170
- }
171
- function storedFrom(value) {
172
- const v = value ?? {};
173
- return {
174
- botId: typeof v.botId === "string" ? v.botId : DEFAULTS.botId,
175
- secretEnv: typeof v.secretEnv === "string" && v.secretEnv.trim() ? v.secretEnv : DEFAULTS.secretEnv,
176
- chatIds: list(v.chatIds),
177
- sessionIds: list(v.sessionIds),
178
- allowedUserIds: list(v.allowedUserIds),
179
- wsUrl: typeof v.wsUrl === "string" ? v.wsUrl : DEFAULTS.wsUrl,
180
- questionTimeoutMs: typeof v.questionTimeoutMs === "number" ? v.questionTimeoutMs : DEFAULTS.questionTimeoutMs,
181
- remoteApprovals: v.remoteApprovals === true,
182
- logEnabled: v.logEnabled !== false,
183
- logRetentionDays: typeof v.logRetentionDays === "number" ? v.logRetentionDays : DEFAULTS.logRetentionDays
184
- };
185
- }
186
- function draftFrom(stored) {
187
- return { ...stored, chatIds: [...stored.chatIds], sessionIds: [...stored.sessionIds], allowedUserIds: [...stored.allowedUserIds], secret: "" };
188
- }
189
- function normalizedList(values) {
190
- return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
191
- }
192
- function sameList(a, b) {
193
- const left = normalizedList(a);
194
- const right = normalizedList(b);
195
- return left.length === right.length && left.every((item) => right.includes(item));
196
- }
197
- function normalizedScalar(key, draft) {
198
- const value = draft[key];
199
- return typeof value === "string" ? value.trim() : value;
200
- }
201
- function changedOperations(draft, base) {
202
- const ops = [];
203
- for (const key of SCALAR_KEYS) {
204
- const next = normalizedScalar(key, draft);
205
- if (next !== normalizedScalar(key, base)) ops.push({ op: "set", path: [key], value: next });
206
- }
207
- for (const key of LIST_KEYS) {
208
- if (!sameList(draft[key], base[key])) ops.push({ op: "set", path: [key], value: normalizedList(draft[key]) });
209
- }
210
- return ops;
211
- }
212
- function isDirty(draft, base) {
213
- return Boolean(draft.secret.trim()) || changedOperations(draft, base).length > 0;
214
- }
215
- function validate(draft, secretConfigured) {
216
- const errors = {};
217
- if (!draft.botId.trim()) errors.botId = "请填写企业微信 Bot ID。";
218
- if (!draft.secret.trim() && !secretConfigured) errors.secret = "首次配置需要填写 Bot Secret。";
219
- const wsUrl = draft.wsUrl.trim();
220
- if (wsUrl) {
398
+ function useStoreApply(onChanged) {
399
+ const [busy, setBusy] = (0, import_react.useState)("");
400
+ const [error, setError] = (0, import_react.useState)();
401
+ const apply2 = (0, import_react.useCallback)(async (key, ops) => {
402
+ setBusy(key);
403
+ setError(void 0);
221
404
  try {
222
- const url = new URL(wsUrl);
223
- if (url.protocol !== "wss:" || url.username || url.password) errors.wsUrl = "只接受不含账号密码的 wss:// 地址。";
224
- } catch {
225
- errors.wsUrl = "不是有效的 URL。";
405
+ const response = await postStore(ops);
406
+ onChanged();
407
+ return response;
408
+ } catch (cause) {
409
+ setError(cause instanceof Error ? cause.message : String(cause));
410
+ return void 0;
411
+ } finally {
412
+ setBusy("");
226
413
  }
227
- }
228
- if (!Number.isFinite(draft.questionTimeoutMs) || draft.questionTimeoutMs < 1e3 || draft.questionTimeoutMs > 3e5) {
229
- errors.questionTimeoutMs = "请输入 1–300 秒。";
230
- }
231
- if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < 1 || draft.logRetentionDays > 365) {
232
- errors.logRetentionDays = "请输入 1–365 的整数天数。";
233
- }
234
- return errors;
235
- }
236
- function accessSummary(draft) {
237
- const unrestricted = [];
238
- if (!normalizedList(draft.sessionIds).length) unrestricted.push("sessions");
239
- if (!normalizedList(draft.chatIds).length) unrestricted.push("chats");
240
- if (!normalizedList(draft.allowedUserIds).length) unrestricted.push("users");
241
- return { level: unrestricted.length === 3 ? "open" : unrestricted.length ? "partial" : "restricted", unrestricted };
242
- }
243
- function toggle(values, id, on) {
244
- const has = values.includes(id);
245
- const want = on ?? !has;
246
- if (want === has) return [...values];
247
- return want ? [...values, id] : values.filter((value) => value !== id);
248
- }
249
- function setAll(values, ids, on) {
250
- if (on) return [.../* @__PURE__ */ new Set([...values, ...ids])];
251
- const remove = new Set(ids);
252
- return values.filter((value) => !remove.has(value));
414
+ }, [onChanged]);
415
+ const dismiss = (0, import_react.useCallback)(() => setError(void 0), []);
416
+ return { busy, error, apply: apply2, dismiss };
253
417
  }
254
- function matches(session, group, needle) {
255
- return [session.title ?? "", session.sessionId, group.title, group.path ?? ""].some((text) => text.toLowerCase().includes(needle));
256
- }
257
- function filterGroups(groups, query, selected) {
258
- const needle = query.trim().toLowerCase();
259
- return groups.map((group) => ({
260
- ...group,
261
- sessions: group.sessions.filter((session) => (!needle || matches(session, group, needle)) && (!selected || selected.has(session.sessionId)))
262
- })).filter((group) => group.sessions.length > 0);
263
- }
264
- function identityRows(observed, configured) {
265
- const rows = observed.map((entry) => ({ id: entry.id, observed: entry }));
266
- const known = new Set(observed.map((entry) => entry.id));
267
- for (const id of configured) if (!known.has(id)) rows.push({ id });
268
- return rows;
269
- }
270
- function displayPath(path) {
271
- return (path ?? "").replace(/^(\/Users|\/home)\/[^/]+(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+(?=\\|$)/, "~");
272
- }
273
- function relativeTime(at, now = Date.now()) {
274
- if (!at) return "";
275
- const diff = Math.max(0, now - at);
276
- if (diff < 6e4) return "刚刚";
277
- if (diff < 36e5) return `${Math.floor(diff / 6e4)} 分钟前`;
278
- if (diff < 864e5) return `${Math.floor(diff / 36e5)} 小时前`;
279
- if (diff < 30 * 864e5) return `${Math.floor(diff / 864e5)} 天前`;
280
- return new Date(at).toLocaleDateString();
418
+ function useStoreSettingsSave(onSaved) {
419
+ const [saving, setSaving] = (0, import_react.useState)(false);
420
+ const [error, setError] = (0, import_react.useState)();
421
+ const [saved, setSaved] = (0, import_react.useState)(false);
422
+ const timer = (0, import_react.useRef)();
423
+ (0, import_react.useEffect)(() => () => {
424
+ if (timer.current) clearTimeout(timer.current);
425
+ }, []);
426
+ const save = (0, import_react.useCallback)(async (patch) => {
427
+ setSaving(true);
428
+ setError(void 0);
429
+ if (timer.current) clearTimeout(timer.current);
430
+ try {
431
+ await postStore([setSettings(patch)]);
432
+ setSaved(true);
433
+ timer.current = setTimeout(() => setSaved(false), 2e3);
434
+ onSaved();
435
+ return true;
436
+ } catch (cause) {
437
+ setError(cause instanceof Error ? cause.message : String(cause));
438
+ return false;
439
+ } finally {
440
+ setSaving(false);
441
+ }
442
+ }, [onSaved]);
443
+ return { saving, error, saved, save };
281
444
  }
282
-
283
- // src/client/components/AccessBanner.tsx
284
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
285
- var import_jsx_runtime = require("react/jsx-runtime");
286
- var DIMENSION_LABEL = {
287
- sessions: "DSH 会话:全部未归档会话",
288
- chats: "企微会话:所有单聊与群聊",
289
- users: "企微用户:任何人"
290
- };
291
- function AccessBanner({ summary }) {
292
- if (summary.level === "restricted") {
293
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner", "data-tone": "success", role: "status", children: [
294
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-banner-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCheckCircleOutlineRegular, { size: 18 }) }),
295
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
296
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-title", children: "已启用三重白名单" }),
297
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-body", children: "只有勾选的企微用户、在勾选的会话里,才能操作勾选的 DSH 会话。被拒绝的消息不会得到任何回复,但会出现在下方列表中供你审核。" })
298
- ] })
299
- ] });
300
- }
301
- const open = summary.level === "open";
302
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner", "data-tone": open ? "danger" : "warning", role: "alert", children: [
303
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-banner-icon", children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconWarningTriangleOutlineRegular, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconShieldOutlineRegular, { size: 18 }) }),
304
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
305
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-banner-title", children: open ? "安全风险:尚未设置任何白名单" : "部分范围未限制" }),
306
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-banner-body", children: [
307
- open ? "只要能给机器人发消息,任何企业微信用户都可以读取本轮回复、向你的 DSH 会话发送指令(可能触发命令执行和文件修改)。" : "以下范围留空,表示对该范围全部允许:",
308
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-chips", children: summary.unrestricted.map((dimension) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: open ? "danger" : "warning", children: DIMENSION_LABEL[dimension] }, dimension)) }),
309
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", { children: [
310
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "在下方「企业微信来源」中只勾选你自己的 userid,以及你与机器人的单聊。" }),
311
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "在「DSH 会话」中只勾选需要远程操作的会话。" }),
312
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: "群聊里的通知对所有群成员可见,请谨慎授权群聊。" })
313
- ] })
314
- ] })
315
- ] })
316
- ] });
445
+ function useConfigSave(scope, onSaved) {
446
+ const [saving, setSaving] = (0, import_react.useState)(false);
447
+ const [error, setError] = (0, import_react.useState)();
448
+ const [saved, setSaved] = (0, import_react.useState)(false);
449
+ const timer = (0, import_react.useRef)();
450
+ (0, import_react.useEffect)(() => () => {
451
+ if (timer.current) clearTimeout(timer.current);
452
+ }, []);
453
+ const save = (0, import_react.useCallback)(async (patch) => {
454
+ setSaving(true);
455
+ setError(void 0);
456
+ if (timer.current) clearTimeout(timer.current);
457
+ try {
458
+ for (let attempt = 0; attempt < 3; attempt++) {
459
+ const latest = scope.getSnapshot();
460
+ const stored = storedFrom(latest.value);
461
+ const ops = changedOperations({ ...stored, ...patch }, stored);
462
+ if (!ops.length) break;
463
+ if (await scope.mutate(ops, latest.revision)) break;
464
+ if (attempt === 2) throw new Error("配置已在别处被修改,请刷新页面后重试。");
465
+ }
466
+ setSaved(true);
467
+ timer.current = setTimeout(() => setSaved(false), 2e3);
468
+ onSaved();
469
+ return true;
470
+ } catch (cause) {
471
+ setError(cause instanceof Error ? cause.message : String(cause));
472
+ return false;
473
+ } finally {
474
+ setSaving(false);
475
+ }
476
+ }, [scope, onSaved]);
477
+ return { saving, error, saved, save };
317
478
  }
318
479
 
319
- // src/client/components/AdvancedCard.tsx
320
- var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
480
+ // src/client/components/AdminCard.tsx
321
481
  var import_react2 = require("react");
482
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
322
483
 
323
484
  // src/client/components/ui.tsx
324
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
325
- var import_jsx_runtime2 = require("react/jsx-runtime");
485
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
486
+ var import_jsx_runtime = require("react/jsx-runtime");
487
+ function Select({ className, ...rest }) {
488
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...rest, className: ["wcb-select", className].filter(Boolean).join(" ") });
489
+ }
326
490
  function Card(props) {
327
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "wcb-card", children: [
328
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CardHead, { ...props }),
491
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "wcb-card", children: [
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardHead, { ...props }),
329
493
  props.children
330
494
  ] });
331
495
  }
332
496
  function CardHead({ step, title, description, aside }) {
333
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-card-head", children: [
334
- step !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-step", children: step }),
335
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-card-titles", children: [
336
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-title", children: title }),
337
- description && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-desc", children: description })
497
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-card-head", children: [
498
+ step !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-step", children: step }),
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-card-titles", children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-title", children: title }),
501
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-desc", children: description })
338
502
  ] }),
339
- aside && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-card-aside", children: aside })
503
+ aside && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-aside", children: aside })
504
+ ] });
505
+ }
506
+ function Collapse({ open, onToggle, title, summary, actions, children, className }) {
507
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ["wcb-group", className].filter(Boolean).join(" "), "data-open": open ? "" : void 0, children: [
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-group-head", children: [
509
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "wcb-group-toggle", "aria-expanded": open, onClick: onToggle, children: [
510
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 14 }) }),
511
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-title", children: title }),
512
+ summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-summary", children: summary })
513
+ ] }),
514
+ actions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-actions", children: actions })
515
+ ] }),
516
+ open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-group-body", children })
340
517
  ] });
341
518
  }
342
519
  function Field({ label, required, hint, error, children }) {
343
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field", "data-invalid": error ? "" : void 0, children: [
344
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field-label", children: [
520
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field", "data-invalid": error ? "" : void 0, children: [
521
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field-label", children: [
345
522
  label,
346
- required && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-required", "aria-label": "必填", children: "*" })
523
+ required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-required", "aria-label": "必填", children: "*" })
347
524
  ] }),
348
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-field-control", children: [
525
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-field-control", children: [
349
526
  children,
350
- error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }) : hint && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: hint })
527
+ error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }) : hint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-hint", children: hint })
351
528
  ] })
352
529
  ] });
353
530
  }
354
- function ScopeTag({ count }) {
355
- return count ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_dsh_client_ui_primitives2.Tag, { tone: "info", children: [
356
- "已选 ",
357
- count
358
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tag, { tone: "warning", children: "未限制 · 全部允许" });
359
- }
360
531
  function CheckRow({ checked, onToggle, label, children, meta, disabled }) {
361
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "wcb-row", "data-selected": checked ? "" : void 0, children: [
362
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
532
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "wcb-row", "data-selected": checked ? "" : void 0, children: [
533
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
534
  "input",
364
535
  {
365
536
  type: "checkbox",
@@ -370,18 +541,383 @@ window.__ModuleLoader__.load({
370
541
  onChange: (event) => onToggle(event.target.checked)
371
542
  }
372
543
  ),
373
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-row-main", children }),
374
- meta && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-row-meta", children: meta })
544
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-row-main", children }),
545
+ meta && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-row-meta", children: meta })
546
+ ] });
547
+ }
548
+ function KindBadge({ kind, plain }) {
549
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-avatar", "data-kind": kind, "data-plain": plain ? "" : void 0, "aria-hidden": "true", children: kind === "group" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUsersOutlineRegular, { size: 15 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUserOutlineRegular, { size: 15 }) });
550
+ }
551
+ function PersonAvatar({ kind, label, disabled, onClick }) {
552
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
553
+ "button",
554
+ {
555
+ type: "button",
556
+ className: "wcb-avatar",
557
+ "data-kind": kind,
558
+ "data-button": "",
559
+ "aria-label": label,
560
+ title: "查看详情、编辑备注",
561
+ disabled,
562
+ onClick,
563
+ children: [
564
+ kind === "group" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUsersOutlineRegular, { size: 15 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUserOutlineRegular, { size: 15 }),
565
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-avatar-pencil", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEditOutlineRegular, { size: 9 }) })
566
+ ]
567
+ }
568
+ );
569
+ }
570
+ function PersonRow({ kind, title, meta, label, disabled, onOpen }) {
571
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-head", children: [
572
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PersonAvatar, { kind, label, disabled, onClick: onOpen }),
573
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-row-title", title: typeof title === "string" ? title : void 0, children: title }),
574
+ meta && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-person-meta", children: meta })
575
+ ] });
576
+ }
577
+ function Fact({ name, children, mono }) {
578
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
579
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: name }),
580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ["wcb-fact-value", mono ? "wcb-mono" : ""].filter(Boolean).join(" "), children })
581
+ ] });
582
+ }
583
+ function PersonDialog({ open, onClose, title, typeLabel, id, label, noteLabel, disabled, onNote, children, footer }) {
584
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
585
+ import_dsh_client_ui_primitives.Modal,
586
+ {
587
+ open,
588
+ onClose,
589
+ title,
590
+ closeLabel: "关闭",
591
+ className: "wcb-modal",
592
+ contentClassName: "wcb-modal-content",
593
+ children: [
594
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-facts", children: [
595
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
596
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "企微 ID", mono: true, children: id }),
597
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
598
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: "备注" }),
599
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
600
+ import_dsh_client_ui_primitives.Input,
601
+ {
602
+ defaultValue: label,
603
+ placeholder: id,
604
+ disabled,
605
+ "aria-label": noteLabel,
606
+ className: "wcb-fact-input",
607
+ onBlur: (event) => {
608
+ const next = event.target.value.trim();
609
+ if (next !== label) onNote(next);
610
+ },
611
+ onKeyDown: (event) => {
612
+ if (event.key === "Enter") event.currentTarget.blur();
613
+ }
614
+ },
615
+ label
616
+ )
617
+ ] })
618
+ ] }),
619
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-hint", children: "备注即时生效,会代替企微 ID 显示;它属于这个人,移出分组后仍然保留。" }),
620
+ children,
621
+ footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-dialog-actions", children: footer })
622
+ ]
623
+ }
624
+ );
625
+ }
626
+ function SaveBar({ dirty, saving, saved, error, disabled, onSave, onDiscard }) {
627
+ if (!dirty && !saved && !error) return null;
628
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-savebar", children: [
629
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-savebar-msg", "data-tone": error ? "error" : saved && !dirty ? "success" : dirty ? "dirty" : void 0, role: "status", children: error ?? (saved && !dirty ? "已保存。" : "有未保存的更改") }),
630
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: disabled || saving || !dirty, onClick: onDiscard, children: "放弃" }),
631
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", disabled: disabled || saving || !dirty, onClick: onSave, children: saving ? "保存中…" : "保存" })
632
+ ] });
633
+ }
634
+ function ConfirmDialog({ open, title, children, confirmLabel, busy, disabled, onCancel, onConfirm }) {
635
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Modal, { open, onClose: onCancel, title, closeLabel: "关闭", className: "wcb-modal", contentClassName: "wcb-modal-content", children: [
636
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-confirm-body", children }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-dialog-actions", children: [
638
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: busy, onClick: onCancel, children: "取消" }),
639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", disabled: busy || disabled, onClick: onConfirm, children: busy ? "处理中…" : confirmLabel })
640
+ ] })
641
+ ] });
642
+ }
643
+ function Empty({ children }) {
644
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-empty", children });
645
+ }
646
+ function CountTag({ count, noun, tone }) {
647
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Tag, { tone: tone ?? (count ? "info" : "quiet"), children: [
648
+ count,
649
+ " ",
650
+ noun
651
+ ] });
652
+ }
653
+
654
+ // src/client/components/AdminCard.tsx
655
+ var import_jsx_runtime2 = require("react/jsx-runtime");
656
+ function AdminCard({ state, disabled, onChanged }) {
657
+ const storedIds = state?.settings?.adminUserIds ?? [];
658
+ const storedScope = state?.settings?.adminWorkspaces ?? [];
659
+ const [draft, setDraft] = (0, import_react2.useState)(() => ({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] }));
660
+ const [picking, setPicking] = (0, import_react2.useState)(false);
661
+ const [query, setQuery] = (0, import_react2.useState)("");
662
+ const [scopeOpen, setScopeOpen] = (0, import_react2.useState)(false);
663
+ const save = useStoreSettingsSave(onChanged);
664
+ const routing = useStoreApply(onChanged);
665
+ const admins = state?.admins ?? [];
666
+ const workspaces = state?.workspaces ?? [];
667
+ const all = draft.adminWorkspaces.length === 0;
668
+ const busy = disabled || save.saving;
669
+ const storedKey = `${storedIds.join("\0")}${storedScope.join("\0")}`;
670
+ (0, import_react2.useEffect)(() => {
671
+ setDraft({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] });
672
+ }, [storedKey]);
673
+ const apply2 = async (patch) => {
674
+ setDraft((current) => ({ ...current, ...patch }));
675
+ if (!await save.save(patch)) {
676
+ setDraft({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] });
677
+ }
678
+ };
679
+ const known = new Map(admins.map((admin) => [admin.id, admin]));
680
+ const candidates = (0, import_react2.useMemo)(() => {
681
+ const rows = /* @__PURE__ */ new Map();
682
+ for (const sender of state?.rejected ?? []) {
683
+ if (sender.kind !== "user") continue;
684
+ rows.set(sender.id, {
685
+ id: sender.id,
686
+ name: sender.label || sender.id,
687
+ hint: sender.label ? `未授权用户 · ${sender.id}` : "未授权用户(刚给机器人发过消息)"
688
+ });
689
+ }
690
+ for (const group of state?.routing?.groups ?? []) {
691
+ for (const member of group.members) {
692
+ if (member.kind !== "user") continue;
693
+ rows.set(member.id, {
694
+ id: member.id,
695
+ name: member.displayName,
696
+ hint: member.label ? `分组:${group.name} · ${member.id}` : `分组:${group.name}`
697
+ });
698
+ }
699
+ }
700
+ for (const id of draft.adminUserIds) rows.delete(id);
701
+ return [...rows.values()].sort((left, right) => left.name.localeCompare(right.name));
702
+ }, [state, draft.adminUserIds]);
703
+ const needle = query.trim().toLowerCase();
704
+ const matches = needle ? candidates.filter((row) => row.name.toLowerCase().includes(needle) || row.id.toLowerCase().includes(needle)) : candidates;
705
+ const typed = query.trim();
706
+ const addAdmin = (id) => {
707
+ void apply2({ adminUserIds: toggle(draft.adminUserIds, id, true) });
708
+ setQuery("");
709
+ setPicking(false);
710
+ };
711
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
712
+ Card,
713
+ {
714
+ step: 4,
715
+ title: "管理员",
716
+ description: "只有这里列出的 userid 可以切换会话(/sessions、/use、/new、/workspaces)、在单聊里审批工具调用,并按下面的范围接收通知。其它用户永远只能访问自己专属的会话。改动即时生效。",
717
+ aside: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
718
+ draft.adminUserIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: [
719
+ draft.adminUserIds.length,
720
+ " 人"
721
+ ] }),
722
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
723
+ import_dsh_client_ui_primitives2.Button,
724
+ {
725
+ variant: "outline",
726
+ size: "sm",
727
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconPlusOutlineRegular, {}),
728
+ disabled: busy,
729
+ "aria-label": "添加管理员",
730
+ onClick: () => setPicking(true),
731
+ children: "添加"
732
+ }
733
+ )
734
+ ] }),
735
+ children: [
736
+ routing.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner", "data-tone": "danger", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner-body", children: routing.error }) }) }),
737
+ save.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner", "data-tone": "danger", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-banner-body", children: save.error }) }) }),
738
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel", children: draft.adminUserIds.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { padding: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Empty, { children: [
739
+ "还没有管理员:没有人可以切换会话、审批工具调用或接收他人会话的通知。",
740
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconPlusOutlineRegular, {}), disabled: busy, onClick: () => setPicking(true), children: "添加管理员" }) })
741
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: draft.adminUserIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
742
+ AdminRow,
743
+ {
744
+ id,
745
+ label: known.get(id)?.label ?? "",
746
+ groupName: known.get(id)?.groupName,
747
+ disabled: busy || routing.busy === personKey("user", id),
748
+ onNote: (next) => {
749
+ void routing.apply(personKey("user", id), [setLabel(personKey("user", id), next)]);
750
+ },
751
+ onRemove: () => {
752
+ void apply2({ adminUserIds: toggle(draft.adminUserIds, id, false) });
753
+ }
754
+ },
755
+ id
756
+ )) }) }),
757
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginTop: 14 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
758
+ Collapse,
759
+ {
760
+ open: scopeOpen,
761
+ onToggle: () => setScopeOpen((value) => !value),
762
+ title: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
763
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconShieldOutlineRegular, { size: 15 }),
764
+ " 可接收通知的 Workspace"
765
+ ] }),
766
+ summary: all ? "全部 Workspace" : `${draft.adminWorkspaces.length} / ${workspaces.length || draft.adminWorkspaces.length} 个 Workspace`,
767
+ actions: all ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", disabled: busy, onClick: () => {
768
+ void apply2({ adminWorkspaces: [] });
769
+ }, children: "全选" }),
770
+ children: workspaces.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Empty, { children: "还没有注册任何 Workspace。默认分组的 Workspace 会在创建会话时注册。" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-panel", children: [
771
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: workspaces.map((workspace) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
772
+ CheckRow,
773
+ {
774
+ checked: scopeIncludes(draft.adminWorkspaces, workspace.path),
775
+ label: `管理员接收 ${workspace.title} 的通知`,
776
+ disabled: busy,
777
+ onToggle: (on) => {
778
+ void apply2({
779
+ adminWorkspaces: toggleScope(draft.adminWorkspaces, workspaces.map((item) => item.path), workspace.path, on)
780
+ });
781
+ },
782
+ meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-meta", children: workspace.sessionCount ? `${workspace.sessionCount} 个会话` : "暂无会话" }),
783
+ children: [
784
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-title", children: workspace.title }),
785
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-sub wcb-mono wcb-ellipsis", title: workspace.path, children: displayPath(workspace.path) })
786
+ ]
787
+ },
788
+ workspace.path
789
+ )) }),
790
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-add", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-grow wcb-hint", children: [
791
+ all ? "未限定(全部勾选):管理员会收到所有这些 Workspace 中会话的通知。取消勾选任意一项即改为只收勾选的 Workspace。" : "管理员只接收已勾选 Workspace 中会话的通知(外加他们自己绑定的会话)。",
792
+ " ",
793
+ "只有归档会话的 Workspace 也会列出。勾选即生效。"
794
+ ] }) })
795
+ ] })
796
+ }
797
+ ) }),
798
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
799
+ import_dsh_client_ui_primitives2.Modal,
800
+ {
801
+ open: picking,
802
+ onClose: () => setPicking(false),
803
+ title: "添加管理员",
804
+ closeLabel: "关闭",
805
+ className: "wcb-modal",
806
+ contentClassName: "wcb-modal-content",
807
+ children: [
808
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
809
+ import_dsh_client_ui_primitives2.Input,
810
+ {
811
+ value: query,
812
+ autoFocus: true,
813
+ placeholder: "搜索备注名或企微 userid",
814
+ "aria-label": "搜索已知用户",
815
+ onChange: (event) => setQuery(event.target.value)
816
+ }
817
+ ),
818
+ matches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-picker-list", role: "listbox", "aria-label": "已知用户", children: matches.map((row) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
819
+ "button",
820
+ {
821
+ type: "button",
822
+ className: "wcb-picker-row",
823
+ role: "option",
824
+ "aria-selected": false,
825
+ onClick: () => addAdmin(row.id),
826
+ children: [
827
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-title", children: row.name }),
828
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-picker-hint", children: row.hint })
829
+ ]
830
+ },
831
+ row.id
832
+ )) }),
833
+ typed && !candidates.some((row) => row.id === typed) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-picker-row", "data-manual": true, children: [
834
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-row-title", children: [
835
+ "直接添加「",
836
+ typed,
837
+ "」"
838
+ ] }),
839
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-picker-hint", children: "按 userid 添加一个还没给机器人发过消息的人" }),
840
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => addAdmin(typed), children: "添加" })
841
+ ] }),
842
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "名单来自未授权用户和已授权成员,优先显示备注名;没有备注时显示企微 userid。选中即生效。" })
843
+ ]
844
+ }
845
+ )
846
+ ]
847
+ }
848
+ );
849
+ }
850
+ function AdminRow({ id, label, groupName, disabled, onNote, onRemove }) {
851
+ const [details, setDetails] = (0, import_react2.useState)(false);
852
+ const name = label || id;
853
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-member", children: [
854
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
855
+ PersonRow,
856
+ {
857
+ kind: "user",
858
+ title: name,
859
+ label: `${name} 的详情`,
860
+ disabled,
861
+ onOpen: () => setDetails(true),
862
+ meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
863
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: "管理员" }),
864
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-sub", children: groupName ? `分组:${groupName}` : "不在任何分组" })
865
+ ] })
866
+ }
867
+ ),
868
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
869
+ PersonDialog,
870
+ {
871
+ open: details,
872
+ onClose: () => setDetails(false),
873
+ title: name,
874
+ typeLabel: "管理员(个人 userid)",
875
+ id,
876
+ label,
877
+ noteLabel: `管理员 ${id} 的备注`,
878
+ disabled,
879
+ onNote,
880
+ footer: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
881
+ import_dsh_client_ui_primitives2.Button,
882
+ {
883
+ variant: "ghost",
884
+ size: "sm",
885
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconTrashOutlineRegular, {}),
886
+ disabled,
887
+ "aria-label": `移除管理员 ${id}`,
888
+ onClick: onRemove,
889
+ children: "移除管理员"
890
+ }
891
+ ),
892
+ children: [
893
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-person-facts", children: [
894
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "授权来源", children: "插件设置里的管理员列表(改动即时生效)" }),
895
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "所属分组", children: groupName ?? "不在任何分组" })
896
+ ] }),
897
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "备注与管理员名单都即时生效。" })
898
+ ]
899
+ }
900
+ )
375
901
  ] });
376
902
  }
377
- function Empty({ children }) {
378
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-empty", children });
379
- }
380
903
 
381
904
  // src/client/components/AdvancedCard.tsx
905
+ var import_react3 = require("react");
906
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
382
907
  var import_jsx_runtime3 = require("react/jsx-runtime");
383
- function AdvancedCard({ draft, errors, journal, disabled, onChange }) {
384
- const [copied, setCopied] = (0, import_react2.useState)(false);
908
+ function AdvancedCard({ settings, journal, disabled, onChanged }) {
909
+ const stored = advancedSlice(settings);
910
+ const [draft, setDraft] = (0, import_react3.useState)(() => advancedSlice(settings));
911
+ const [attempted, setAttempted] = (0, import_react3.useState)(false);
912
+ const [copied, setCopied] = (0, import_react3.useState)(false);
913
+ const save = useStoreSettingsSave(onChanged);
914
+ const patch = settingsPatch(draft, stored);
915
+ const dirty = Object.keys(patch).length > 0;
916
+ const errors = attempted ? validateAdvanced(draft) : {};
917
+ const storedKey = JSON.stringify(stored);
918
+ (0, import_react3.useEffect)(() => {
919
+ setDraft(advancedSlice(settings));
920
+ }, [storedKey]);
385
921
  const copy = async () => {
386
922
  if (!journal?.directory) return;
387
923
  setCopied(await (0, import_dsh_client_ui_primitives3.writeClipboard)(journal.directory));
@@ -391,7 +927,7 @@ window.__ModuleLoader__.load({
391
927
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
392
928
  CardHead,
393
929
  {
394
- step: 4,
930
+ step: 5,
395
931
  title: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
396
932
  "高级设置 ",
397
933
  draft.remoteApprovals && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Tag, { tone: "warning", children: "远程审批已开启" })
@@ -404,14 +940,14 @@ window.__ModuleLoader__.load({
404
940
  Field,
405
941
  {
406
942
  label: "远程审批工具调用",
407
- hint: "开启后,DSH 请求执行工具时会向已允许用户的单聊发送带验证码的审批消息,回复 /approve 或 /deny 即生效;群聊永远不能审批。不需要时请保持关闭。",
943
+ hint: "开启后,DSH 请求执行工具时会通知所有管理员,管理员在单聊里回复 /approve 或 /deny 即生效;群聊永远不能审批。关闭时只通知,审批仍需到 DSH 页面完成。",
408
944
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
945
  import_dsh_client_ui_primitives3.Switch,
410
946
  {
411
947
  checked: draft.remoteApprovals,
412
948
  disabled,
413
949
  label: "远程审批工具调用",
414
- onChange: (next) => onChange({ remoteApprovals: next })
950
+ onChange: (next) => setDraft((current) => ({ ...current, remoteApprovals: next }))
415
951
  }
416
952
  )
417
953
  }
@@ -433,23 +969,31 @@ window.__ModuleLoader__.load({
433
969
  value: Math.round(draft.questionTimeoutMs / 1e3),
434
970
  disabled,
435
971
  "aria-label": "等待企微回复的秒数",
436
- onChange: (event) => onChange({ questionTimeoutMs: Number(event.target.value) * 1e3 })
972
+ onChange: (event) => setDraft((current) => ({ ...current, questionTimeoutMs: Number(event.target.value) * 1e3 }))
437
973
  }
438
974
  )
439
975
  }
440
976
  ),
441
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "WebSocket 地址", error: errors.wsUrl, hint: "留空使用 SDK 默认地址。仅在企业私有化部署时需要,只接受 wss://。", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
442
- import_dsh_client_ui_primitives3.Input,
977
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
978
+ Field,
443
979
  {
444
- className: "wcb-grow",
445
- value: draft.wsUrl,
446
- placeholder: "wss://openws.work.weixin.qq.com",
447
- spellCheck: false,
448
- disabled,
449
- "aria-label": "WebSocket 地址",
450
- onChange: (event) => onChange({ wsUrl: event.target.value })
980
+ label: "WebSocket 地址",
981
+ error: errors.wsUrl,
982
+ hint: "留空使用 SDK 默认地址。仅在企业私有化部署时需要,只接受 wss://。保存这一项会重新连接机器人——它是连接的一半;本卡其余设置保存后立即生效,不会断开正在进行的对话。",
983
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
984
+ import_dsh_client_ui_primitives3.Input,
985
+ {
986
+ className: "wcb-grow",
987
+ value: draft.wsUrl,
988
+ placeholder: "wss://openws.work.weixin.qq.com",
989
+ spellCheck: false,
990
+ disabled,
991
+ "aria-label": "WebSocket 地址",
992
+ onChange: (event) => setDraft((current) => ({ ...current, wsUrl: event.target.value }))
993
+ }
994
+ )
451
995
  }
452
- ) }),
996
+ ),
453
997
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
454
998
  Field,
455
999
  {
@@ -475,7 +1019,7 @@ window.__ModuleLoader__.load({
475
1019
  checked: draft.logEnabled,
476
1020
  disabled,
477
1021
  label: "记录对话日志",
478
- onChange: (next) => onChange({ logEnabled: next })
1022
+ onChange: (next) => setDraft((current) => ({ ...current, logEnabled: next }))
479
1023
  }
480
1024
  ),
481
1025
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "保留" }),
@@ -490,7 +1034,7 @@ window.__ModuleLoader__.load({
490
1034
  value: draft.logRetentionDays,
491
1035
  disabled: disabled || !draft.logEnabled,
492
1036
  "aria-label": "日志保留天数",
493
- onChange: (event) => onChange({ logRetentionDays: Number(event.target.value) })
1037
+ onChange: (event) => setDraft((current) => ({ ...current, logRetentionDays: Number(event.target.value) }))
494
1038
  }
495
1039
  ),
496
1040
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { color: "var(--wcb-text-2)", fontSize: 13 }, children: "天" })
@@ -504,17 +1048,60 @@ window.__ModuleLoader__.load({
504
1048
  ] })
505
1049
  ]
506
1050
  }
1051
+ ),
1052
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1053
+ SaveBar,
1054
+ {
1055
+ dirty,
1056
+ saving: save.saving,
1057
+ saved: save.saved,
1058
+ error: save.error,
1059
+ disabled,
1060
+ onSave: () => {
1061
+ setAttempted(true);
1062
+ if (dirty) void save.save(patch);
1063
+ },
1064
+ onDiscard: () => {
1065
+ setDraft(advancedSlice(settings));
1066
+ setAttempted(false);
1067
+ }
1068
+ }
507
1069
  )
508
1070
  ] });
509
1071
  }
510
1072
 
511
1073
  // src/client/components/CredentialsCard.tsx
512
- var import_react3 = require("react");
1074
+ var import_react4 = require("react");
513
1075
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
514
1076
  var import_jsx_runtime4 = require("react/jsx-runtime");
515
- function CredentialsCard({ draft, errors, secretConfigured, disabled, onChange }) {
516
- const [reveal, setReveal] = (0, import_react3.useState)(false);
517
- const ready = Boolean(draft.botId.trim()) && (secretConfigured || Boolean(draft.secret.trim()));
1077
+ function CredentialsCard({ scope, base, disabled, remote, onChanged }) {
1078
+ const [reveal, setReveal] = (0, import_react4.useState)(false);
1079
+ const [secret, setSecret] = (0, import_react4.useState)("");
1080
+ const [botId, setBotId] = (0, import_react4.useState)(base.botId);
1081
+ const [error, setError] = (0, import_react4.useState)();
1082
+ const [attempted, setAttempted] = (0, import_react4.useState)(false);
1083
+ const save = useConfigSave(scope, onChanged);
1084
+ const status = useSecretStatus(remote, base.secretEnv);
1085
+ const ready = Boolean(botId.trim()) && (status.configured || Boolean(secret.trim()));
1086
+ const dirty = botId.trim() !== base.botId || Boolean(secret.trim());
1087
+ const errors = attempted ? validateCredentials({ botId, secret }, status.configured) : {};
1088
+ (0, import_react4.useEffect)(() => {
1089
+ setBotId(base.botId);
1090
+ }, [base.botId]);
1091
+ async function onSave() {
1092
+ setAttempted(true);
1093
+ setError(void 0);
1094
+ if (Object.keys(validateCredentials({ botId, secret }, status.configured)).length) return;
1095
+ if (!await save.save({ botId: botId.trim() })) return;
1096
+ if (!secret.trim()) return;
1097
+ try {
1098
+ await storeCredential(remote?.credentials, base.secretEnv, secret.trim());
1099
+ setSecret("");
1100
+ status.refresh();
1101
+ } catch (cause) {
1102
+ setError(`其它配置已保存,但 Secret 保存失败:${cause instanceof Error ? cause.message : String(cause)}`);
1103
+ }
1104
+ }
518
1105
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
519
1106
  Card,
520
1107
  {
@@ -527,26 +1114,26 @@ window.__ModuleLoader__.load({
527
1114
  import_dsh_client_ui_primitives4.Input,
528
1115
  {
529
1116
  className: "wcb-grow",
530
- value: draft.botId,
1117
+ value: botId,
531
1118
  placeholder: "例如 aib0xxxxxxxxxxxx",
532
1119
  spellCheck: false,
533
1120
  autoComplete: "off",
534
1121
  disabled,
535
1122
  "aria-label": "Bot ID",
536
- onChange: (event) => onChange({ botId: event.target.value })
1123
+ onChange: (event) => setBotId(event.target.value)
537
1124
  }
538
1125
  ) }),
539
1126
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
540
1127
  Field,
541
1128
  {
542
1129
  label: "Bot Secret",
543
- required: !secretConfigured,
1130
+ required: !status.configured,
544
1131
  error: errors.secret,
545
1132
  hint: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
546
1133
  "保存到 DSH 凭据库(引用名 ",
547
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "wcb-code", children: draft.secretEnv }),
1134
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "wcb-code", children: base.secretEnv }),
548
1135
  "),不会写入插件配置,也不会回显。",
549
- secretConfigured ? "留空表示保持当前 Secret。" : ""
1136
+ status.configured ? "留空表示保持当前 Secret。" : ""
550
1137
  ] }),
551
1138
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "wcb-field-row", children: [
552
1139
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -554,343 +1141,572 @@ window.__ModuleLoader__.load({
554
1141
  {
555
1142
  className: "wcb-grow",
556
1143
  type: reveal ? "text" : "password",
557
- value: draft.secret,
558
- placeholder: secretConfigured ? "已保存 · 输入新值以替换" : "粘贴 Bot Secret",
1144
+ value: secret,
1145
+ placeholder: status.configured ? "已保存 · 输入新值以替换" : "粘贴 Bot Secret",
559
1146
  autoComplete: "new-password",
560
1147
  spellCheck: false,
561
1148
  disabled,
562
1149
  "aria-label": "Bot Secret",
563
- onChange: (event) => onChange({ secret: event.target.value })
1150
+ onChange: (event) => setSecret(event.target.value)
564
1151
  }
565
1152
  ),
566
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", type: "button", onClick: () => setReveal((value) => !value), disabled: !draft.secret, children: reveal ? "隐藏" : "显示" }),
567
- secretConfigured ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "success", children: "已保存" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "warning", children: "未设置" })
1153
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", type: "button", onClick: () => setReveal((value) => !value), disabled: !secret, children: reveal ? "隐藏" : "显示" }),
1154
+ status.configured ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "success", children: "已保存" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Tag, { tone: "warning", children: "未设置" })
568
1155
  ] })
569
1156
  }
1157
+ ),
1158
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1159
+ SaveBar,
1160
+ {
1161
+ dirty,
1162
+ saving: save.saving,
1163
+ saved: save.saved,
1164
+ error: error ?? save.error,
1165
+ disabled,
1166
+ onSave: () => {
1167
+ void onSave();
1168
+ },
1169
+ onDiscard: () => {
1170
+ setBotId(base.botId);
1171
+ setSecret("");
1172
+ setError(void 0);
1173
+ setAttempted(false);
1174
+ }
1175
+ }
570
1176
  )
571
1177
  ]
572
1178
  }
573
1179
  );
574
1180
  }
575
1181
 
576
- // src/client/components/IdentityPicker.tsx
577
- var import_react4 = require("react");
1182
+ // src/client/components/GroupsCard.tsx
1183
+ var import_react5 = require("react");
578
1184
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
579
1185
  var import_jsx_runtime5 = require("react/jsx-runtime");
580
- var REASON = {
581
- user: "用户不在白名单",
582
- chat: "会话不在白名单",
583
- "user+chat": "用户和会话都不在白名单"
584
- };
585
- function IdentityPicker({ observed, chatIds, userIds, disabled, connected, onChange }) {
586
- const rejected = (observed?.users ?? []).filter((user) => user.decision === "rejected").length;
1186
+ function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged }) {
1187
+ const { busy, error: applyError, apply: apply2 } = useStoreApply(onChanged);
1188
+ const [freshId, setFreshId] = (0, import_react5.useState)();
1189
+ const view = state?.routing;
1190
+ (0, import_react5.useEffect)(() => {
1191
+ if (freshId && view?.groups.some((group) => group.id === freshId)) setFreshId(void 0);
1192
+ }, [freshId, view]);
1193
+ const add = async () => {
1194
+ const response = await apply2("group:new", [addGroup()]);
1195
+ if (response?.createdGroupId) setFreshId(response.createdGroupId);
1196
+ };
587
1197
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
588
1198
  Card,
589
1199
  {
590
- step: 3,
591
- title: "企业微信来源",
592
- description: "这里只列出最近 24 小时内真正给机器人发过消息的 ID,包括被白名单拒绝的。勾选即加入白名单;某一列不勾选表示该项不限制。",
593
- aside: rejected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_dsh_client_ui_primitives5.Tag, { tone: "danger", children: [
594
- rejected,
595
- " 个用户被拒绝"
596
- ] }) : void 0,
1200
+ step: 2,
1201
+ title: "用户分组",
1202
+ description: "每个分组决定成员在哪个 Workspace、用哪个模型与 preset;把企微用户或群聊放进分组即为授权。改动即时生效。",
1203
+ aside: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1204
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CountTag, { count: view?.groups.length ?? 0, noun: "个分组", tone: "quiet" }),
1205
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CountTag, { count: view?.total ?? 0, noun: "位成员" })
1206
+ ] }),
597
1207
  children: [
598
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-columns", children: [
599
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
600
- IdentityPanel,
601
- {
602
- kind: "users",
603
- title: "允许的用户",
604
- hint: "企业微信 userid",
605
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconUserOutlineRegular, { size: 16 }),
606
- observed: observed?.users ?? [],
607
- selected: userIds,
608
- disabled,
609
- connected,
610
- onChange: (next) => onChange({ allowedUserIds: next })
611
- }
612
- ),
613
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
614
- IdentityPanel,
615
- {
616
- kind: "chats",
617
- title: "允许的会话",
618
- hint: "单聊 = 对方 userid;群聊 = chatid",
619
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconUsersOutlineRegular, { size: 16 }),
620
- observed: observed?.chats ?? [],
621
- selected: chatIds,
622
- disabled,
623
- connected,
624
- onChange: (next) => onChange({ chatIds: next })
625
- }
626
- )
1208
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-toolbar", children: [
1209
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-grow wcb-hint", children: "没有分组的用户无法与机器人对话;他们发消息后会出现在「未授权用户」卡片里,加入分组即完成授权。" }),
1210
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconRefreshOutlineRegular, {}), disabled: refreshing, onClick: onRefresh, children: refreshing ? "刷新中" : "刷新" }),
1211
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconPlusOutlineRegular, {}), disabled: disabled || busy === "group:new", onClick: () => {
1212
+ void add();
1213
+ }, children: "添加分组" })
627
1214
  ] }),
628
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-list-foot", children: [
629
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "ID 列表保存在内存中,DSH 重启后需要重新收到消息才会出现。" }),
630
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
631
- "在企业微信里发送 ",
632
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-code", children: "/whoami" }),
633
- " 也可查看自己的 ID(仅限已允许的用户)。"
634
- ] })
635
- ] })
1215
+ applyError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-banner", "data-tone": "danger", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-banner-body", children: applyError }) }) }),
1216
+ !view ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Empty, { children: error ?? state?.routingError ?? "正在读取分组信息…" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-groups", children: view.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1217
+ GroupPanel,
1218
+ {
1219
+ group,
1220
+ state,
1221
+ startEditing: group.id === freshId,
1222
+ disabled: disabled || busy.startsWith(`group:${group.id}`),
1223
+ onApply: apply2
1224
+ },
1225
+ group.id
1226
+ )) })
636
1227
  ]
637
1228
  }
638
1229
  );
639
1230
  }
640
- function IdentityPanel({ kind, title, hint, icon, observed, selected, disabled, connected, onChange }) {
641
- const [manual, setManual] = (0, import_react4.useState)("");
642
- const rows = identityRows(observed, selected);
643
- const add = () => {
644
- const id = manual.trim();
645
- if (!id) return;
646
- onChange(toggle(selected, id, true));
647
- setManual("");
1231
+ function draftOf(group) {
1232
+ return {
1233
+ name: group.name,
1234
+ workspace: group.workspace,
1235
+ provider: group.provider,
1236
+ model: group.model,
1237
+ effort: group.reasoningEffort ?? "",
1238
+ preset: group.preset
648
1239
  };
649
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
650
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-subhead", children: [
651
- icon,
652
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-subhead-title", children: title }),
653
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-subhead-hint", children: hint }),
654
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-card-aside", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ScopeTag, { count: selected.length }) })
1240
+ }
1241
+ function patchOf(group, draft) {
1242
+ const patch = {};
1243
+ const name = draft.name.trim();
1244
+ if (name && name !== group.name) patch.name = name;
1245
+ if (draft.workspace !== group.workspace) patch.workspace = draft.workspace;
1246
+ if (draft.provider !== group.provider || draft.model !== group.model) {
1247
+ patch.provider = draft.provider;
1248
+ patch.model = draft.model;
1249
+ patch.reasoningEffort = "";
1250
+ } else if (draft.effort !== (group.reasoningEffort ?? "")) {
1251
+ patch.reasoningEffort = draft.effort;
1252
+ }
1253
+ if (draft.preset !== group.preset) patch.preset = draft.preset;
1254
+ return patch;
1255
+ }
1256
+ function GroupPanel({ group, state, startEditing, disabled, onApply }) {
1257
+ const [open, setOpen] = (0, import_react5.useState)(startEditing);
1258
+ const [editing, setEditing] = (0, import_react5.useState)(startEditing);
1259
+ const [draft, setDraft] = (0, import_react5.useState)(() => draftOf(group));
1260
+ const [confirming, setConfirming] = (0, import_react5.useState)(false);
1261
+ const catalog = state?.models;
1262
+ const presets = state?.presets;
1263
+ const workspaces = state?.workspaces ?? [];
1264
+ const key = `group:${group.id}`;
1265
+ const effort = group.reasoningEffort ? effortLabel(catalog, {
1266
+ provider: group.effectiveProvider,
1267
+ model: group.effectiveModel,
1268
+ reasoningEffort: group.reasoningEffort
1269
+ }) || group.reasoningEffort : "默认";
1270
+ const summary = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1271
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1272
+ group.memberCount,
1273
+ " 位成员"
655
1274
  ] }),
656
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-panel", children: [
657
- rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { padding: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Empty, { children: [
658
- connected ? "还没有收到消息。" : "机器人尚未在线。",
659
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ol", { children: [
660
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "填写 Bot ID 与 Secret 并保存;" }),
661
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "在企业微信里给机器人发一条消息(群聊里请 @机器人);" }),
662
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: "几秒后 ID 会自动出现在这里。" })
663
- ] })
664
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-panel-scroll", children: rows.map(({ id, observed: entry }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
665
- CheckRow,
666
- {
667
- checked: selected.includes(id),
668
- label: `允许${kind === "users" ? "用户" : "会话"} ${id}`,
669
- disabled,
670
- onToggle: (on) => onChange(toggle(selected, id, on)),
671
- meta: entry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DecisionTag, { entry }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "手动添加" }),
672
- children: [
673
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-row-title wcb-mono", style: { fontSize: 13 }, title: id, children: id }),
674
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-row-sub", children: entry ? describe(kind, entry) : "24 小时内未收到消息" })
675
- ]
676
- },
677
- id
678
- )) }),
679
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-add", children: [
680
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
681
- import_dsh_client_ui_primitives5.Input,
682
- {
683
- className: "wcb-grow",
684
- value: manual,
685
- placeholder: kind === "users" ? "手动添加 userid" : "手动添加 chatid / userid",
686
- "aria-label": kind === "users" ? "手动添加 userid" : "手动添加会话 ID",
687
- disabled,
688
- onChange: (event) => setManual(event.target.value),
689
- onKeyDown: (event) => {
690
- if (event.key === "Enter") {
691
- event.preventDefault();
692
- add();
693
- }
694
- }
695
- }
696
- ),
697
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconPlusOutlineRegular, {}), disabled: disabled || !manual.trim(), onClick: add, children: "添加" })
698
- ] })
1275
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1276
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "Workspace" }),
1277
+ group.workspaceTitle
1278
+ ] }),
1279
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1280
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1281
+ groupModelSummary(catalog, group)
1282
+ ] }),
1283
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1284
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1285
+ effort
1286
+ ] }),
1287
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1288
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1289
+ presetSummaryLabel(presets, group.preset)
699
1290
  ] })
700
1291
  ] });
701
- }
702
- function describe(kind, entry) {
703
- const parts = [`${relativeTime(entry.lastSeenAt)}`, `${entry.messages} 条消息`];
704
- if (kind === "chats") parts.unshift(entry.chatType === "group" ? "群聊" : "单聊");
705
- if (kind === "chats" && entry.chatType === "group" && entry.via) parts.push(`最近发言 ${entry.via}`);
706
- if (kind === "users" && entry.via && entry.via !== entry.id) parts.push(`来自群 ${entry.via}`);
707
- return parts.join(" · ");
708
- }
709
- function DecisionTag({ entry }) {
710
- return entry.decision === "rejected" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { title: entry.reason ? REASON[entry.reason] : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "danger", children: "上次被拒绝" }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "上次已接受" });
711
- }
712
-
713
- // src/client/components/SessionPicker.tsx
714
- var import_react5 = require("react");
715
- var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
716
- var import_jsx_runtime6 = require("react/jsx-runtime");
717
- var HIDDEN_REASON = {
718
- archived: "已归档",
719
- subagent: "子代理会话",
720
- blank: "空会话",
721
- missing: "已删除或不可见"
722
- };
723
- var UNTITLED = "未命名会话";
724
- function SessionPicker({ catalog, error, loading, refreshing, selected, disabled, onChange, onRefresh }) {
725
- const [query, setQuery] = (0, import_react5.useState)("");
726
- const [onlySelected, setOnlySelected] = (0, import_react5.useState)(false);
727
- const [open, setOpen] = (0, import_react5.useState)({});
728
- const selectedSet = (0, import_react5.useMemo)(() => new Set(selected), [selected]);
729
- const groups = (0, import_react5.useMemo)(
730
- () => filterGroups(catalog?.groups ?? [], query, onlySelected ? selectedSet : void 0),
731
- [catalog, query, onlySelected, selectedSet]
732
- );
733
- const shown = groups.reduce((sum, group) => sum + group.sessions.length, 0);
734
- const searching = Boolean(query.trim()) || onlySelected;
735
- const isOpen = (group, index) => searching || (open[group.key] ?? (index < 2 || group.sessions.some((session) => selectedSet.has(session.sessionId))));
736
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
737
- Card,
1292
+ (0, import_react5.useEffect)(() => {
1293
+ if (!editing) setDraft(draftOf(group));
1294
+ }, [group, editing]);
1295
+ const efforts = effortsFor(catalog, draft.provider || group.effectiveProvider, draft.model || group.effectiveModel);
1296
+ const update = (patch) => setDraft((current) => ({ ...current, ...patch }));
1297
+ const startEdit = () => {
1298
+ setDraft(draftOf(group));
1299
+ setEditing(true);
1300
+ setOpen(true);
1301
+ };
1302
+ const save = async () => {
1303
+ const patch = patchOf(group, draft);
1304
+ if (!Object.keys(patch).length) {
1305
+ setEditing(false);
1306
+ return;
1307
+ }
1308
+ const response = await onApply(key, [updateGroup(group.id, patch)]);
1309
+ if (response) setEditing(false);
1310
+ };
1311
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1312
+ Collapse,
738
1313
  {
739
- step: 2,
740
- title: "DSH 会话范围",
741
- description: "勾选允许从企业微信查看与操作的会话;不勾选表示所有未归档会话都可操作。已归档、子代理和空会话不会显示。",
742
- aside: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScopeTag, { count: selected.length }),
743
- children: [
744
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-toolbar", children: [
745
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
746
- import_dsh_client_ui_primitives6.Input,
1314
+ open,
1315
+ onToggle: () => setOpen((value) => !value),
1316
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1317
+ group.name,
1318
+ group.isDefault && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "默认" })
1319
+ ] }),
1320
+ summary,
1321
+ actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1322
+ editing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1323
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => {
1324
+ setEditing(false);
1325
+ setDraft(draftOf(group));
1326
+ }, children: "取消" }),
1327
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "primary", size: "sm", disabled, onClick: () => {
1328
+ void save();
1329
+ }, children: "保存" })
1330
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, "aria-label": `编辑 ${group.name}`, onClick: startEdit, children: "编辑" }),
1331
+ !group.isDefault && (confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1332
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1333
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1334
+ import_dsh_client_ui_primitives5.Button,
747
1335
  {
748
- className: "wcb-search",
749
- icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconSearchOutlineRegular, {}),
750
- value: query,
751
- placeholder: "搜索会话名称、ID 或工作区",
752
- "aria-label": "搜索会话",
753
- onChange: (event) => setQuery(event.target.value)
1336
+ variant: "ghost",
1337
+ size: "sm",
1338
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1339
+ disabled,
1340
+ onClick: () => {
1341
+ void onApply(key, [deleteGroup(group.id)]);
1342
+ },
1343
+ children: "确认删除"
754
1344
  }
755
- ),
756
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: onlySelected ? "toolbar" : "ghost", size: "sm", "aria-pressed": onlySelected, onClick: () => setOnlySelected((value) => !value), children: "仅看已选" }),
757
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "ghost", size: "sm", disabled: disabled || !selected.length, onClick: () => onChange([]), children: "清空选择" }),
758
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconRefreshOutlineRegular, {}), disabled: refreshing, onClick: onRefresh, "aria-label": "刷新会话列表", children: refreshing ? "刷新中" : "刷新" })
759
- ] }),
760
- !catalog ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: error ?? (loading ? "正在读取 DSH 会话列表…" : "会话列表不可用。") }) : groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: searching ? "没有匹配的会话。" : "还没有可选择的会话。在 DSH 中开始一个对话后,它会出现在这里。" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-scroll", children: groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
761
- SessionGroup,
762
- {
763
- group,
764
- open: isOpen(group, index),
765
- selected: selectedSet,
766
- disabled,
767
- onToggleOpen: () => setOpen((state) => ({ ...state, [group.key]: !isOpen(group, index) })),
768
- onSelectGroup: (on) => onChange(setAll(selected, group.sessions.map((session) => session.sessionId), on)),
769
- onSelect: (id, on) => onChange(toggle(selected, id, on))
770
- },
771
- group.key
772
- )) }),
773
- catalog && catalog.hiddenSelections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-hidden-list", children: [
774
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-hidden-head", children: [
775
- "已勾选但当前不可操作(",
776
- catalog.hiddenSelections.length,
777
- ")",
778
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { flex: 1 } }),
779
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
780
- import_dsh_client_ui_primitives6.Button,
1345
+ )
1346
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "删除分组" }))
1347
+ ] }),
1348
+ children: [
1349
+ editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-binding-controls", children: [
1350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1351
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "分组名称" }),
1352
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1353
+ import_dsh_client_ui_primitives5.Input,
781
1354
  {
782
- variant: "ghost",
783
- size: "sm",
1355
+ value: draft.name,
784
1356
  disabled,
785
- onClick: () => onChange(setAll(selected, catalog.hiddenSelections.map((item) => item.sessionId), false)),
786
- children: "全部移除"
1357
+ "aria-label": `${group.name} 的名称`,
1358
+ onChange: (event) => update({ name: event.target.value })
787
1359
  }
788
1360
  )
789
1361
  ] }),
790
- catalog.hiddenSelections.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
791
- CheckRow,
792
- {
793
- checked: selectedSet.has(item.sessionId),
794
- label: `取消勾选 ${item.title ?? item.sessionId}`,
795
- disabled,
796
- onToggle: (on) => onChange(toggle(selected, item.sessionId, on)),
797
- meta: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Tag, { tone: "warning", children: HIDDEN_REASON[item.reason] }),
798
- children: [
799
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", "data-muted": item.title ? void 0 : "", children: item.title ?? UNTITLED }),
800
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-sub wcb-mono", children: item.sessionId })
801
- ]
802
- },
803
- item.sessionId
804
- ))
805
- ] }),
806
- catalog && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-list-foot", children: [
807
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
808
- "显示 ",
809
- shown,
810
- " / ",
811
- catalog.total,
812
- " 个会话"
1362
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1363
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "Workspace" }),
1364
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1365
+ Select,
1366
+ {
1367
+ value: draft.workspace,
1368
+ disabled,
1369
+ "aria-label": `${group.name} 的 Workspace`,
1370
+ onChange: (event) => update({ workspace: event.target.value }),
1371
+ children: [
1372
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
1373
+ "插件自带(",
1374
+ displayPath(workspaces.find((workspace) => workspace.pluginOwned)?.path),
1375
+ ")"
1376
+ ] }),
1377
+ workspaces.map((workspace) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: workspace.path, children: [
1378
+ workspace.title,
1379
+ " — ",
1380
+ displayPath(workspace.path)
1381
+ ] }, workspace.path)),
1382
+ draft.workspace && !workspaces.some((workspace) => workspace.path === draft.workspace) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: draft.workspace, children: [
1383
+ displayPath(draft.workspace),
1384
+ "(未注册)"
1385
+ ] })
1386
+ ]
1387
+ }
1388
+ )
1389
+ ] }),
1390
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1391
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "模型" }),
1392
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1393
+ Select,
1394
+ {
1395
+ value: modelKey(draft.provider, draft.model),
1396
+ disabled: disabled || !catalog,
1397
+ "aria-label": `${group.name} 的模型`,
1398
+ onChange: (event) => {
1399
+ const next = parseModelKey(event.target.value);
1400
+ update({ provider: next.provider, model: next.model, effort: "" });
1401
+ },
1402
+ children: [
1403
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: dshDefaultLabel(catalog) }),
1404
+ (catalog?.choices ?? []).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: modelKey(choice.provider, choice.model), children: [
1405
+ choice.providerName,
1406
+ " / ",
1407
+ choiceLabel(choice)
1408
+ ] }, modelKey(choice.provider, choice.model)))
1409
+ ]
1410
+ }
1411
+ )
813
1412
  ] }),
814
- catalog.archived > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
815
- "已隐藏 ",
816
- catalog.archived,
817
- " 个已归档会话"
1413
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1414
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "effort(思考强度)" }),
1415
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1416
+ Select,
1417
+ {
1418
+ value: draft.effort,
1419
+ disabled: disabled || !efforts.length || !(draft.provider || draft.model),
1420
+ "aria-label": `${group.name} 的 effort`,
1421
+ onChange: (event) => update({ effort: event.target.value }),
1422
+ children: [
1423
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "默认" }),
1424
+ efforts.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1425
+ ]
1426
+ }
1427
+ )
818
1428
  ] }),
819
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
820
- "更新于 ",
821
- relativeTime(catalog.generatedAt)
1429
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1430
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "preset" }),
1431
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1432
+ Select,
1433
+ {
1434
+ value: draft.preset,
1435
+ disabled: disabled || !presets?.presets.length,
1436
+ "aria-label": `${group.name} 的 preset`,
1437
+ onChange: (event) => update({ preset: event.target.value }),
1438
+ children: [
1439
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: presetLabel(presets, "") }),
1440
+ (presets?.presets ?? []).map((preset) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: preset.id, children: [
1441
+ presetName(preset),
1442
+ preset.broken ? "(不可用)" : ""
1443
+ ] }, preset.id))
1444
+ ]
1445
+ }
1446
+ )
822
1447
  ] })
823
- ] })
1448
+ ] }),
1449
+ editing && (!efforts.length || !presets?.presets.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-hint", children: [
1450
+ !efforts.length && "当前模型没有可选的 effort:先选一个支持思考强度的模型,或让 DSH 默认模型决定。",
1451
+ !efforts.length && !presets?.presets.length && " ",
1452
+ !presets?.presets.length && `没有读到 DSH 的 preset 列表${state?.presetsError ? `:${state.presetsError}` : "(这个部署没有挂载 preset registry)"}。`
1453
+ ] }),
1454
+ group.workspaceError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint wcb-inline-error", children: group.workspaceError }),
1455
+ editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint", children: "更换 Workspace 后,本组成员的会话会在下一条消息时重新创建。模型与 effort 在下一条消息时安装到已有会话; preset 只影响此后新建的会话(DSH 不允许改写已经开始的会话)。" }),
1456
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-members", children: group.members.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Empty, { children: "这个分组还没有成员。让对方先给机器人发一条消息,然后在「未授权用户」里把 TA 加入本组。" }) : group.members.map((member) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1457
+ MemberRow,
1458
+ {
1459
+ member,
1460
+ group,
1461
+ groups: state?.routing?.groups ?? [],
1462
+ state,
1463
+ disabled,
1464
+ onApply
1465
+ },
1466
+ member.key
1467
+ )) })
824
1468
  ]
825
1469
  }
826
1470
  );
827
1471
  }
828
- function SessionGroup({ group, open, selected, disabled, onToggleOpen, onSelectGroup, onSelect }) {
829
- const count = group.sessions.filter((session) => selected.has(session.sessionId)).length;
830
- const all = count === group.sessions.length;
831
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-group", "data-open": open ? "" : void 0, children: [
832
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
833
- "div",
1472
+ function MemberRow({ member, group, groups, state, disabled, onApply }) {
1473
+ const [details, setDetails] = (0, import_react5.useState)(false);
1474
+ const [archiving, setArchiving] = (0, import_react5.useState)(false);
1475
+ const catalog = state?.models;
1476
+ const presets = state?.presets;
1477
+ const others = groups.filter((item) => item.id !== group.id);
1478
+ const effort = effortLabel(catalog, member.sessionModel);
1479
+ const name = member.displayName;
1480
+ const title = member.sessionId ? member.sessionTitle ?? "未命名会话" : "待创建";
1481
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-member-row", children: [
1482
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PersonAvatar, { kind: member.kind, label: `${name} 的详情`, disabled, onClick: () => setDetails(true) }),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-name", title: name, children: name }),
1484
+ member.admin && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "管理员" }),
1485
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-member-facts", children: [
1486
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1487
+ member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.StateDot, { state: member.sessionRunning ? "ongoing" : "done", size: 8 }),
1488
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-strong", children: title }),
1489
+ member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: member.sessionState === "bound" || member.sessionState === "blank" ? "quiet" : "warning", children: SESSION_STATE_LABEL[member.sessionState] })
1490
+ ] }),
1491
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1492
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1493
+ presetLabel(presets, member.sessionPreset)
1494
+ ] }),
1495
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1496
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1497
+ member.sessionModel ? modelName(catalog, member.sessionModel) : "—"
1498
+ ] }),
1499
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1500
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1501
+ effort || "—"
1502
+ ] }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1504
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "上下文" }),
1505
+ contextLabel(member.sessionContext) || "—"
1506
+ ] })
1507
+ ] }),
1508
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-actions", children: member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1509
+ import_dsh_client_ui_primitives5.Button,
1510
+ {
1511
+ variant: "ghost",
1512
+ size: "sm",
1513
+ disabled,
1514
+ "aria-label": `归档 ${name} 的会话`,
1515
+ onClick: () => setArchiving(true),
1516
+ children: "归档会话"
1517
+ }
1518
+ ) }),
1519
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1520
+ PersonDialog,
834
1521
  {
835
- className: "wcb-group-head",
836
- role: "button",
837
- tabIndex: 0,
838
- "aria-expanded": open,
839
- onClick: onToggleOpen,
840
- onKeyDown: (event) => {
841
- if (event.target !== event.currentTarget || event.key !== "Enter" && event.key !== " ") return;
842
- event.preventDefault();
843
- onToggleOpen();
1522
+ open: details,
1523
+ onClose: () => setDetails(false),
1524
+ title: name,
1525
+ typeLabel: BINDING_KIND_LABEL[member.kind],
1526
+ id: member.id,
1527
+ label: member.label,
1528
+ noteLabel: `${member.id} 的备注`,
1529
+ disabled,
1530
+ onNote: (next) => {
1531
+ void onApply(member.key, [setLabel(member.key, next)]);
844
1532
  },
1533
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RemoveMember, { member, disabled, onApply }),
845
1534
  children: [
846
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconChevronRightOutlineRegular, { size: 14 }) }),
847
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
848
- "input",
849
- {
850
- type: "checkbox",
851
- className: "wcb-check",
852
- checked: all,
853
- disabled,
854
- "aria-label": `选择工作区 ${group.title} 的全部会话`,
855
- ref: (element) => {
856
- if (element) element.indeterminate = count > 0 && !all;
857
- },
858
- onClick: (event) => event.stopPropagation(),
859
- onChange: (event) => onSelectGroup(event.target.checked)
860
- }
861
- ),
862
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-icon", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconFolderCloseRegular, { size: 16 }) }),
863
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-title", title: group.title, children: group.title }),
864
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-group-path", title: group.path, children: displayPath(group.path) }),
865
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-group-count", children: [
866
- count ? `${count}/` : "",
867
- group.sessions.length
1535
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-dialog-section wcb-person-facts", children: [
1536
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "所属分组", children: group.name }),
1537
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "会话", children: member.sessionId ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1538
+ member.sessionTitle ?? "未命名会话",
1539
+ " ",
1540
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-mono", children: member.sessionId.slice(-8) })
1541
+ ] }) : "尚未创建" }),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "preset", children: presetLabel(presets, member.sessionPreset) }),
1543
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "模型", children: member.sessionModel ? modelLabel(catalog, member.sessionModel) : "—" }),
1544
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "effort", children: effort || "—" }),
1545
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "上下文", children: contextLabel(member.sessionContext) || "—" }),
1546
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "消息", children: member.messages ? `${member.messages} 条 · ${relativeTime(member.lastSeenAt)}` : "尚未收到消息" })
1547
+ ] }),
1548
+ others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1549
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "移动到分组" }),
1550
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1551
+ Select,
1552
+ {
1553
+ value: "",
1554
+ disabled,
1555
+ "aria-label": `把 ${member.id} 移动到分组`,
1556
+ onChange: (event) => {
1557
+ if (!event.target.value) return;
1558
+ void onApply(member.key, [updateMember(member.key, { groupId: event.target.value })]);
1559
+ },
1560
+ children: [
1561
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
1562
+ "保持在「",
1563
+ group.name,
1564
+ "」"
1565
+ ] }),
1566
+ others.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1567
+ ]
1568
+ }
1569
+ )
868
1570
  ] })
869
1571
  ]
870
1572
  }
871
1573
  ),
872
- open && group.sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
873
- CheckRow,
1574
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1575
+ ConfirmDialog,
874
1576
  {
875
- checked: selected.has(session.sessionId),
876
- label: `选择会话 ${session.title ?? session.sessionId}`,
1577
+ open: archiving,
1578
+ title: `归档「${name}」的会话?`,
1579
+ confirmLabel: "确认归档",
877
1580
  disabled,
878
- onToggle: (on) => onSelect(session.sessionId, on),
879
- meta: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
880
- session.pinned && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-pin", title: "已置顶", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconPinFillRegular, { size: 12 }) }),
881
- session.running && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-running", children: [
882
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.StateDot, { state: "ongoing", size: 12 }),
883
- "运行中"
884
- ] }),
885
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: relativeTime(session.updatedAt) })
886
- ] }),
1581
+ onCancel: () => setArchiving(false),
1582
+ onConfirm: () => {
1583
+ void Promise.resolve(onApply(member.key, [archiveMember(member.key)])).then((result) => {
1584
+ if (result) setArchiving(false);
1585
+ });
1586
+ },
1587
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "归档后这个会话不再被继续,它的历史不会再进入任何请求;下一条消息会按分组当前的 Workspace、模型与 preset 新建一个会话。DSH 的会话文件仍保留在磁盘上,需要时可到 DSH 页面查看。" })
1588
+ }
1589
+ )
1590
+ ] });
1591
+ }
1592
+ function RemoveMember({ member, disabled, onApply }) {
1593
+ const [confirming, setConfirming] = (0, import_react5.useState)(false);
1594
+ return confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1595
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1596
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1597
+ import_dsh_client_ui_primitives5.Button,
1598
+ {
1599
+ variant: "ghost",
1600
+ size: "sm",
1601
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1602
+ disabled,
1603
+ onClick: () => {
1604
+ void onApply(member.key, [removeMember(member.key)]);
1605
+ },
887
1606
  children: [
888
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", "data-muted": session.title ? void 0 : "", title: session.title ?? UNTITLED, children: session.title ?? UNTITLED }),
889
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-sub wcb-mono wcb-ellipsis", title: session.sessionId, children: session.sessionId })
1607
+ "确认移出「",
1608
+ member.displayName,
1609
+ "」"
890
1610
  ]
891
- },
892
- session.sessionId
893
- ))
1611
+ }
1612
+ )
1613
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "移出分组" });
1614
+ }
1615
+
1616
+ // src/client/components/RejectedCard.tsx
1617
+ var import_react6 = require("react");
1618
+ var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
1619
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1620
+ function RejectedCard({ state, disabled, onChanged }) {
1621
+ const rows = state?.rejected ?? [];
1622
+ const groups = state?.routing?.groups ?? [];
1623
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1624
+ Card,
1625
+ {
1626
+ step: 3,
1627
+ title: "未授权用户",
1628
+ description: "给机器人发过消息、但不在任何分组里的人。选择分组并确认即完成授权;备注会代替 userid 显示。列表只保留在内存中,重启 DSH 后清空。",
1629
+ aside: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_dsh_client_ui_primitives6.Tag, { tone: rows.length ? "warning" : "quiet", children: [
1630
+ rows.length,
1631
+ " 个待处理"
1632
+ ] }),
1633
+ children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { children: "暂时没有被拒绝的用户。任何人给机器人发消息后,如果它不在任何分组里,就会出现在这里。" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-scroll", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RejectedRow, { row, groups, disabled, onChanged }, row.key)) })
1634
+ }
1635
+ );
1636
+ }
1637
+ function RejectedRow({ row, groups, disabled, onChanged }) {
1638
+ const [open, setOpen] = (0, import_react6.useState)(false);
1639
+ const [groupId, setGroupId] = (0, import_react6.useState)(groups.find((group) => group.id === "default")?.id ?? groups[0]?.id ?? "");
1640
+ const [label, setLabel2] = (0, import_react6.useState)("");
1641
+ const [busy, setBusy] = (0, import_react6.useState)(false);
1642
+ const [error, setError] = (0, import_react6.useState)();
1643
+ async function authorize() {
1644
+ if (!groupId) {
1645
+ setError("还没有可用的分组。");
1646
+ return;
1647
+ }
1648
+ setBusy(true);
1649
+ setError(void 0);
1650
+ try {
1651
+ await postStore([addMember(groupId, row.kind, row.id, label.trim())]);
1652
+ onChanged();
1653
+ } catch (cause) {
1654
+ setError(cause instanceof Error ? cause.message : String(cause));
1655
+ } finally {
1656
+ setBusy(false);
1657
+ }
1658
+ }
1659
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member", children: [
1660
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member-head", children: [
1661
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KindBadge, { kind: row.kind, plain: true }),
1662
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-row-title", title: row.id, children: row.displayName }),
1663
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { flex: 1 } }),
1664
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "wcb-row-sub", children: [
1665
+ row.messages,
1666
+ " 次 · ",
1667
+ relativeTime(row.lastSeenAt)
1668
+ ] }),
1669
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "outline", size: "sm", disabled: disabled || !groups.length, onClick: () => setOpen((value) => !value), children: open ? "收起" : "加入分组" })
1670
+ ] }),
1671
+ row.text && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-rejected-text", title: row.text, children: row.text }),
1672
+ open && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "wcb-member-edit", children: [
1673
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "wcb-binding-field", children: [
1674
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-binding-label", children: "分组" }),
1675
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1676
+ Select,
1677
+ {
1678
+ value: groupId,
1679
+ disabled: disabled || busy,
1680
+ "aria-label": `${row.id} 的分组`,
1681
+ onChange: (event) => setGroupId(event.target.value),
1682
+ children: groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: group.id, children: group.name }, group.id))
1683
+ }
1684
+ )
1685
+ ] }),
1686
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "wcb-binding-field", children: [
1687
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "wcb-binding-label", children: "备注(优先显示)" }),
1688
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1689
+ import_dsh_client_ui_primitives6.Input,
1690
+ {
1691
+ value: label,
1692
+ placeholder: row.id,
1693
+ disabled: disabled || busy,
1694
+ "aria-label": `${row.id} 的备注`,
1695
+ onChange: (event) => setLabel2(event.target.value),
1696
+ onKeyDown: (event) => {
1697
+ if (event.key === "Enter") {
1698
+ event.preventDefault();
1699
+ void authorize();
1700
+ }
1701
+ }
1702
+ }
1703
+ )
1704
+ ] }),
1705
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-member-actions", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "primary", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives6.IconCheckCircleOutlineRegular, {}), disabled: disabled || busy, onClick: () => {
1706
+ void authorize();
1707
+ }, children: busy ? "授权中…" : "确认授权" }) }),
1708
+ error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "wcb-field-error", role: "alert", children: error })
1709
+ ] })
894
1710
  ] });
895
1711
  }
896
1712
 
@@ -953,115 +1769,29 @@ window.__ModuleLoader__.load({
953
1769
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote });
954
1770
  }
955
1771
  function SettingsEditor({ snapshot, scope, remote }) {
956
- const base = (0, import_react6.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
957
- const [draft, setDraft] = (0, import_react6.useState)(() => draftFrom(base));
958
- const [save, setSave] = (0, import_react6.useState)({ phase: "idle" });
959
- const [showErrors, setShowErrors] = (0, import_react6.useState)(false);
960
- const baseRef = (0, import_react6.useRef)(base);
1772
+ const base = (0, import_react7.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
961
1773
  const bridge = useBridgeState();
962
- const secret = useSecretStatus(remote, base.secretEnv);
963
1774
  const writable = snapshot.writable !== false;
964
- const busy = save.phase === "saving";
965
- (0, import_react6.useEffect)(() => {
966
- const previous = baseRef.current;
967
- baseRef.current = base;
968
- setDraft((current) => isDirty({ ...current, secret: "" }, previous) ? current : { ...draftFrom(base), secret: current.secret });
969
- }, [base]);
970
- const errors = validate(draft, secret.configured);
971
- const invalid = Object.keys(errors).length > 0;
972
- const dirty = isDirty(draft, base);
973
- const summary = accessSummary(draft);
974
- const update = (patch) => {
975
- setDraft((current) => ({ ...current, ...patch }));
976
- if (save.phase !== "saving") setSave({ phase: "idle" });
977
- };
978
- async function onSave() {
979
- if (invalid) {
980
- setShowErrors(true);
981
- return;
982
- }
983
- setSave({ phase: "saving" });
984
- try {
985
- const ops = changedOperations(draft, base);
986
- if (ops.length && !await scope.mutate(ops, snapshot.revision)) {
987
- throw new Error("配置已在别处被修改,请刷新页面后重试。");
988
- }
989
- if (draft.secret.trim()) {
990
- try {
991
- await storeCredential(remote?.credentials, base.secretEnv, draft.secret.trim());
992
- } catch (error) {
993
- throw new Error(`其他配置已保存,但 Secret 保存失败:${error instanceof Error ? error.message : String(error)}`);
994
- }
995
- setDraft((current) => ({ ...current, secret: "" }));
996
- secret.refresh();
997
- }
998
- setShowErrors(false);
999
- setSave({ phase: "saved" });
1000
- setTimeout(() => bridge.refresh(true), 800);
1001
- } catch (error) {
1002
- setSave({ phase: "error", message: error instanceof Error ? error.message : String(error) });
1003
- }
1004
- }
1005
- const visibleErrors = showErrors ? errors : {};
1006
- const footer = !writable ? { tone: "error", text: "此部署的设置为只读。" } : save.phase === "error" ? { tone: "error", text: save.message } : showErrors && invalid ? { tone: "error", text: "请先修正标红的字段。" } : busy ? { tone: "", text: "正在保存…" } : dirty ? { tone: "dirty", text: "有未保存的更改" } : save.phase === "saved" ? { tone: "success", text: "已保存,机器人会按新配置重新连接。" } : { tone: "", text: "所有更改均已保存。" };
1775
+ const state = bridge.data;
1776
+ const onChanged = () => bridge.refresh(true);
1007
1777
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "wcb-page", children: [
1008
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusHeader, { state: bridge.data, error: bridge.error }),
1009
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AccessBanner, { summary }),
1010
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1011
- CredentialsCard,
1012
- {
1013
- draft,
1014
- errors: visibleErrors,
1015
- secretConfigured: secret.configured,
1016
- disabled: !writable || busy,
1017
- onChange: update
1018
- }
1019
- ),
1778
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StatusHeader, { state, error: bridge.error }),
1779
+ state?.notices.map((notice) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-banner", "data-tone": "warning", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-banner-body", children: notice }) }) }, notice)),
1780
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CredentialsCard, { scope, base, disabled: !writable, remote, onChanged }),
1020
1781
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1021
- SessionPicker,
1782
+ GroupsCard,
1022
1783
  {
1023
- catalog: bridge.data?.sessions,
1024
- error: bridge.data?.sessionsError ?? bridge.error,
1025
- loading: bridge.loading,
1784
+ state,
1785
+ error: bridge.error,
1786
+ disabled: !writable,
1026
1787
  refreshing: bridge.refreshing,
1027
- selected: draft.sessionIds,
1028
- disabled: !writable || busy,
1029
- onChange: (sessionIds) => update({ sessionIds }),
1030
- onRefresh: () => bridge.refresh(true)
1788
+ onRefresh: () => bridge.refresh(true),
1789
+ onChanged
1031
1790
  }
1032
1791
  ),
1033
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1034
- IdentityPicker,
1035
- {
1036
- observed: bridge.data?.observed,
1037
- chatIds: draft.chatIds,
1038
- userIds: draft.allowedUserIds,
1039
- disabled: !writable || busy,
1040
- connected: bridge.data?.connection.phase === "online",
1041
- onChange: (patch) => update(patch)
1042
- }
1043
- ),
1044
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1045
- AdvancedCard,
1046
- {
1047
- draft,
1048
- errors: visibleErrors,
1049
- journal: bridge.data?.journal,
1050
- disabled: !writable || busy,
1051
- onChange: update
1052
- }
1053
- ),
1054
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "wcb-footer", children: [
1055
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-footer-msg", "data-tone": footer.tone || void 0, role: "status", children: footer.text }),
1056
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives8.Button, { variant: "outline", size: "sm", disabled: !dirty || busy, onClick: () => {
1057
- setDraft(draftFrom(base));
1058
- setShowErrors(false);
1059
- setSave({ phase: "idle" });
1060
- }, children: "放弃更改" }),
1061
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives8.Button, { variant: "primary", size: "sm", disabled: !writable || busy || !dirty, onClick: () => {
1062
- void onSave();
1063
- }, children: busy ? "保存中…" : "保存配置" })
1064
- ] })
1792
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RejectedCard, { state, disabled: !writable, onChanged }),
1793
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdminCard, { state, disabled: !writable, onChanged }),
1794
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdvancedCard, { settings: state?.settings, journal: state?.journal, disabled: !writable, onChanged })
1065
1795
  ] });
1066
1796
  }
1067
1797
 
@@ -1069,7 +1799,9 @@ window.__ModuleLoader__.load({
1069
1799
  var STYLES = (
1070
1800
  /* css */
1071
1801
  `
1072
- .wcb-page {
1802
+ /* The person dialog is portalled to document.body, outside .wcb-page, so the
1803
+ token set is declared once for both roots. */
1804
+ .wcb-page, .wcb-modal {
1073
1805
  /* DSH is monochrome; the business blue is its accent for focus and info. */
1074
1806
  --wcb-brand: var(--dsw-alias-state-business-primary, #4176e6);
1075
1807
  --wcb-text: var(--dsw-alias-label-primary, #0f1115);
@@ -1095,7 +1827,8 @@ window.__ModuleLoader__.load({
1095
1827
  font-size: 14px;
1096
1828
  line-height: 1.5;
1097
1829
  }
1098
- .wcb-page *, .wcb-page *::before, .wcb-page *::after { box-sizing: border-box; }
1830
+ .wcb-page *, .wcb-page *::before, .wcb-page *::after,
1831
+ .wcb-modal *, .wcb-modal *::before, .wcb-modal *::after { box-sizing: border-box; }
1099
1832
 
1100
1833
  /* Hero */
1101
1834
  .wcb-hero {
@@ -1192,19 +1925,32 @@ window.__ModuleLoader__.load({
1192
1925
  .wcb-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
1193
1926
  .wcb-toolbar .wcb-search { flex: 1; min-width: 220px; }
1194
1927
  .wcb-scroll { max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 1px; }
1928
+ /* The group list grows with the page: nested scroll boxes inside another
1929
+ scroll box are what make a settings page impossible to scan. */
1930
+ .wcb-groups { display: flex; flex-direction: column; gap: 8px; padding: 1px; }
1195
1931
  .wcb-group { border: .5px solid var(--wcb-line); border-radius: 12px; overflow: hidden; background: var(--wcb-surface); }
1196
1932
  .wcb-group-head {
1197
1933
  display: flex; align-items: center; gap: 8px; width: 100%;
1198
- padding: 9px 12px; background: var(--wcb-surface-2);
1199
- border: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
1934
+ padding: 0 12px 0 0; background: var(--wcb-surface-2);
1935
+ }
1936
+ .wcb-group-toggle {
1937
+ flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
1938
+ padding: 9px 12px; background: none; border: none; color: inherit;
1939
+ font: inherit; text-align: left; cursor: pointer;
1200
1940
  }
1201
- .wcb-group-head:hover { box-shadow: inset 0 0 0 999px var(--wcb-hover); }
1941
+ .wcb-group-toggle:hover { box-shadow: inset 0 0 0 999px var(--wcb-hover); }
1942
+ .wcb-group-actions { flex: none; display: flex; gap: 6px; align-items: center; }
1943
+ .wcb-group-body { border-top: .5px solid var(--wcb-line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
1202
1944
  .wcb-chevron { flex: none; color: var(--wcb-text-3); transition: transform .15s ease; }
1203
1945
  .wcb-group[data-open] .wcb-chevron { transform: rotate(90deg); }
1204
1946
  .wcb-group-icon { flex: none; color: var(--wcb-text-2); }
1205
- .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
1206
- .wcb-group-path { flex: 1; min-width: 0; color: var(--wcb-text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1207
- .wcb-group-count { flex: none; color: var(--wcb-text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
1947
+ .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
1948
+ /* The group overview: labelled facts that wrap instead of hiding behind an ellipsis. */
1949
+ .wcb-group-summary {
1950
+ flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
1951
+ gap: 2px 10px; color: var(--wcb-text-3); font-size: 12px; text-align: right;
1952
+ }
1953
+ .wcb-group-summary .wcb-fact-inline { white-space: nowrap; }
1208
1954
  .wcb-row {
1209
1955
  display: flex; align-items: center; gap: 12px;
1210
1956
  padding: 9px 12px; border-top: .5px solid var(--wcb-line); cursor: pointer;
@@ -1254,20 +2000,139 @@ window.__ModuleLoader__.load({
1254
2000
  }
1255
2001
  .wcb-code { font-family: var(--wcb-mono); font-size: 12px; background: var(--wcb-surface-2); padding: 1px 5px; border-radius: 5px; }
1256
2002
 
1257
- /* Footer */
1258
- .wcb-footer {
1259
- position: sticky; bottom: 12px; z-index: 2;
1260
- display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
1261
- padding: 12px 14px 12px 18px; border-radius: 16px;
1262
- background: color-mix(in srgb, var(--wcb-surface) 88%, transparent);
2003
+ /* Per-section save row: a card saves itself, nothing waits at the bottom. */
2004
+ .wcb-savebar {
2005
+ display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
2006
+ margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--wcb-line);
2007
+ }
2008
+ .wcb-savebar-msg { flex: 1; min-width: 160px; color: var(--wcb-text-2); font-size: 12.5px; }
2009
+ .wcb-savebar-msg[data-tone="error"] { color: var(--wcb-err); }
2010
+ .wcb-savebar-msg[data-tone="success"] { color: var(--wcb-ok); }
2011
+ .wcb-savebar-msg[data-tone="dirty"] { color: var(--wcb-warn); }
2012
+
2013
+ /* Selects and inline text */
2014
+ .wcb-select {
2015
+ min-width: 0; max-width: 100%; height: 32px; padding: 0 8px;
2016
+ border: .5px solid var(--wcb-line-2); border-radius: 8px;
2017
+ background: var(--wcb-surface); color: var(--wcb-text); font: inherit; font-size: 13px;
2018
+ cursor: pointer; appearance: auto;
2019
+ }
2020
+ .wcb-select:disabled { opacity: .55; cursor: not-allowed; }
2021
+ .wcb-muted { color: var(--wcb-text-3); }
2022
+ .wcb-inline-error { color: var(--wcb-err); }
2023
+ .wcb-link {
2024
+ border: none; background: none; padding: 0; cursor: pointer;
2025
+ color: var(--wcb-brand); font: inherit; font-size: 12px; text-decoration: underline;
2026
+ }
2027
+ .wcb-link:disabled { color: var(--wcb-text-3); cursor: not-allowed; text-decoration: none; }
2028
+ .wcb-banner-foot { margin-top: 6px; color: var(--wcb-text-3); font-size: 12px; }
2029
+ .wcb-row-meta-inner { display: inline-flex; align-items: center; gap: 6px; }
2030
+
2031
+ /* Groups and members */
2032
+ /* Name, Workspace, model, effort, preset: the model needs the most room. */
2033
+ .wcb-binding-controls {
2034
+ display: grid; gap: 8px;
2035
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1.6fr) minmax(0, .8fr) minmax(0, 1.25fr);
2036
+ }
2037
+ @media (max-width: 900px) {
2038
+ .wcb-binding-controls { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
2039
+ }
2040
+ .wcb-binding-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
2041
+ .wcb-binding-label { color: var(--wcb-text-3); font-size: 11.5px; }
2042
+ .wcb-members { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: .5px solid var(--wcb-line); border-radius: 10px; }
2043
+ .wcb-member { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 8px; }
2044
+ .wcb-member + .wcb-member { border-top: .5px solid var(--wcb-line); border-top-left-radius: 0; border-top-right-radius: 0; }
2045
+ .wcb-member-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
2046
+
2047
+ /* A person line: the colored badge is the only thing that opens the details. */
2048
+ .wcb-person-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
2049
+ .wcb-person-meta { flex: none; display: flex; align-items: center; gap: 6px; color: var(--wcb-text-3); font-size: 12px; margin-left: auto; }
2050
+ .wcb-avatar {
2051
+ flex: none; position: relative; display: grid; place-items: center;
2052
+ width: 26px; height: 26px; padding: 0; border-radius: 50%;
2053
+ border: .5px solid transparent;
2054
+ }
2055
+ .wcb-avatar[data-kind="user"] { color: #2a6df4; background: color-mix(in srgb, #2a6df4 12%, transparent); }
2056
+ .wcb-avatar[data-kind="group"] { color: #b06f00; background: color-mix(in srgb, #bf8700 18%, transparent); }
2057
+ .wcb-avatar[data-button] { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
2058
+ .wcb-avatar[data-button]:hover:not(:disabled) {
2059
+ transform: translateY(-1px);
2060
+ box-shadow: 0 2px 8px color-mix(in srgb, var(--wcb-text) 22%, transparent);
2061
+ }
2062
+ .wcb-avatar[data-button]:active:not(:disabled) { transform: none; }
2063
+ .wcb-avatar[data-button]:focus-visible { outline: 2px solid var(--wcb-brand); outline-offset: 2px; }
2064
+ .wcb-avatar[data-button]:disabled { cursor: not-allowed; opacity: .5; }
2065
+ /* The pencil badge: "pressing this opens the details form". */
2066
+ .wcb-avatar-pencil {
2067
+ position: absolute; right: -3px; bottom: -3px;
2068
+ width: 13px; height: 13px; border-radius: 50%;
2069
+ display: grid; place-items: center;
2070
+ color: var(--wcb-text-2); background: var(--wcb-surface);
1263
2071
  border: .5px solid var(--wcb-line-2);
1264
- box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
1265
- backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
1266
2072
  }
1267
- .wcb-footer-msg { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; color: var(--wcb-text-2); font-size: 13px; }
1268
- .wcb-footer-msg[data-tone="error"] { color: var(--wcb-err); }
1269
- .wcb-footer-msg[data-tone="success"] { color: var(--wcb-ok); }
1270
- .wcb-footer-msg[data-tone="dirty"] { color: var(--wcb-warn); }
2073
+
2074
+ /* One member, one line: badge, name, the Session's facts, its 归档 action. */
2075
+ .wcb-member-row {
2076
+ display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap;
2077
+ padding: 6px 8px; border-radius: 8px;
2078
+ }
2079
+ .wcb-member-row:hover { background: var(--wcb-hover); }
2080
+ .wcb-member-name {
2081
+ font-weight: 500; white-space: nowrap; overflow: hidden;
2082
+ text-overflow: ellipsis; max-width: 140px;
2083
+ }
2084
+ .wcb-member-facts { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-width: 0; flex: 1; }
2085
+ .wcb-fact-inline {
2086
+ display: inline-flex; align-items: center; gap: 5px; min-width: 0;
2087
+ color: var(--wcb-text-2); font-size: 12px;
2088
+ }
2089
+ .wcb-fact-key { color: var(--wcb-text-3); font-size: 11px; }
2090
+ .wcb-fact-strong {
2091
+ color: var(--wcb-text); white-space: nowrap; overflow: hidden;
2092
+ text-overflow: ellipsis; max-width: 170px;
2093
+ }
2094
+ .wcb-member-edit {
2095
+ display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
2096
+ align-items: end; padding: 8px 10px; border-radius: 8px; background: var(--wcb-surface-2);
2097
+ }
2098
+ @media (max-width: 820px) { .wcb-member-edit { grid-template-columns: 1fr; } }
2099
+ .wcb-member-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
2100
+
2101
+ /* A picker list inside a dialog: one known person per row. */
2102
+ .wcb-picker-list {
2103
+ display: flex; flex-direction: column; max-height: 300px; overflow: auto;
2104
+ border: .5px solid var(--wcb-line); border-radius: 10px;
2105
+ }
2106
+ .wcb-picker-row {
2107
+ display: flex; align-items: baseline; gap: 10px; width: 100%;
2108
+ padding: 8px 12px; background: none; border: none; border-top: .5px solid var(--wcb-line);
2109
+ color: inherit; font: inherit; text-align: left; cursor: pointer;
2110
+ }
2111
+ .wcb-picker-row:first-child { border-top: none; }
2112
+ .wcb-picker-row:hover { background: var(--wcb-hover); }
2113
+ .wcb-picker-row[data-manual] { border: .5px dashed var(--wcb-line-2); border-radius: 10px; padding: 10px 12px; flex-wrap: wrap; }
2114
+ .wcb-picker-hint { color: var(--wcb-text-3); font-size: 12px; min-width: 0; }
2115
+ .wcb-confirm-body { color: var(--wcb-text-2); font-size: 13px; }
2116
+ .wcb-confirm-body p { margin: 0; }
2117
+
2118
+ /* The person dialog (portalled, so it re-declares the page tokens). */
2119
+ .wcb-modal { padding: 0; }
2120
+ .wcb-modal-content { display: flex; flex-direction: column; gap: 14px; }
2121
+ .wcb-person-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; }
2122
+ .wcb-person-facts + .wcb-hint { margin-top: 0; }
2123
+ /* The session block sits under the identity facts, behind a hairline. */
2124
+ .wcb-dialog-section { border-top: .5px solid var(--wcb-line); padding-top: 14px; }
2125
+ .wcb-dialog-section .wcb-binding-field { margin-top: 12px; }
2126
+ .wcb-fact { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
2127
+ .wcb-fact-key { color: var(--wcb-text-3); font-size: 11.5px; }
2128
+ .wcb-fact-value { min-width: 0; overflow-wrap: anywhere; }
2129
+ .wcb-fact-input { width: 100%; }
2130
+ .wcb-dialog-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
2131
+ .wcb-rejected-text {
2132
+ color: var(--wcb-text-2); font-size: 12.5px; padding: 6px 10px; border-radius: 8px;
2133
+ background: var(--wcb-surface-2); border-left: 2px solid var(--wcb-line-2);
2134
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
2135
+ }
1271
2136
  `
1272
2137
  );
1273
2138
  function insertStyles(doc = document) {