dsh-wecom-bot 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +160 -60
  2. package/dist/client.js +604 -383
  3. package/dist/host/bridge/commands.js +71 -20
  4. package/dist/host/bridge/commands.js.map +1 -1
  5. package/dist/host/bridge/directory.js +6 -8
  6. package/dist/host/bridge/directory.js.map +1 -1
  7. package/dist/host/bridge/index.js +124 -54
  8. package/dist/host/bridge/index.js.map +1 -1
  9. package/dist/host/bridge/interactions.js +61 -25
  10. package/dist/host/bridge/interactions.js.map +1 -1
  11. package/dist/host/bridge/notices.js +88 -3
  12. package/dist/host/bridge/notices.js.map +1 -1
  13. package/dist/host/bridge/outbox.js +11 -0
  14. package/dist/host/bridge/outbox.js.map +1 -1
  15. package/dist/host/bridge/policy.js +3 -4
  16. package/dist/host/bridge/policy.js.map +1 -1
  17. package/dist/host/bridge/selection.js +7 -0
  18. package/dist/host/bridge/selection.js.map +1 -1
  19. package/dist/host/catalog.js +24 -11
  20. package/dist/host/catalog.js.map +1 -1
  21. package/dist/host/config.js +31 -32
  22. package/dist/host/config.js.map +1 -1
  23. package/dist/host/groups-view.js +442 -143
  24. package/dist/host/groups-view.js.map +1 -1
  25. package/dist/host/index.js +11 -28
  26. package/dist/host/index.js.map +1 -1
  27. package/dist/host/interaction-transport.js +170 -0
  28. package/dist/host/interaction-transport.js.map +1 -0
  29. package/dist/host/journal.js +10 -3
  30. package/dist/host/journal.js.map +1 -1
  31. package/dist/host/observation.js +1 -1
  32. package/dist/host/observation.js.map +1 -1
  33. package/dist/host/routes.js +21 -13
  34. package/dist/host/routes.js.map +1 -1
  35. package/dist/host/routing.js +26 -13
  36. package/dist/host/routing.js.map +1 -1
  37. package/dist/host/runtime.js +142 -40
  38. package/dist/host/runtime.js.map +1 -1
  39. package/dist/host/session-ops.js +35 -3
  40. package/dist/host/session-ops.js.map +1 -1
  41. package/dist/host/session-title.js +47 -0
  42. package/dist/host/session-title.js.map +1 -0
  43. package/dist/host/sessions.js +38 -6
  44. package/dist/host/sessions.js.map +1 -1
  45. package/dist/host/{routing-store.js → store.js} +173 -26
  46. package/dist/host/store.js.map +1 -0
  47. package/dist/host/turns.js +5 -0
  48. package/dist/host/turns.js.map +1 -1
  49. package/dist/shared/protocol.js +18 -8
  50. package/dist/shared/protocol.js.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/host/routing-store.js.map +0 -1
package/dist/client.js CHANGED
@@ -35,17 +35,20 @@ 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 ROUTING_ROUTE = "/api/wecom-bot/routing";
38
+ var STORE_ROUTE = "/api/wecom-bot/store";
39
+ var MIN_LOG_RETENTION_DAYS = 1;
40
+ var MAX_LOG_RETENTION_DAYS = 365;
41
+ var DEFAULT_LOG_RETENTION_DAYS = 14;
39
42
 
40
43
  // src/client/components/SettingsPage.tsx
41
- var import_react7 = require("react");
44
+ var import_react8 = require("react");
42
45
 
43
46
  // src/client/hooks.ts
44
47
  var import_react = require("react");
45
48
 
46
49
  // src/client/api.ts
47
50
  var STATE_URL = STATE_ROUTE.replace(/^\//, "");
48
- var ROUTING_URL = ROUTING_ROUTE.replace(/^\//, "");
51
+ var STORE_URL = STORE_ROUTE.replace(/^\//, "");
49
52
  async function fetchState(refresh, signal) {
50
53
  const response = await fetch(`${STATE_URL}${refresh ? "?refresh=1" : ""}`, {
51
54
  credentials: "same-origin",
@@ -57,10 +60,10 @@ window.__ModuleLoader__.load({
57
60
  if (!response.ok) throw new Error(`插件状态读取失败(HTTP ${response.status})。`);
58
61
  return await response.json();
59
62
  }
60
- async function postRouting(ops) {
63
+ async function postStore(ops) {
61
64
  let response;
62
65
  try {
63
- response = await fetch(ROUTING_URL, {
66
+ response = await fetch(STORE_URL, {
64
67
  method: "POST",
65
68
  credentials: "same-origin",
66
69
  cache: "no-store",
@@ -102,27 +105,8 @@ window.__ModuleLoader__.load({
102
105
  // src/client/model.ts
103
106
  var DEFAULTS = {
104
107
  botId: "",
105
- secretEnv: DEFAULT_SECRET_REF,
106
- adminUserIds: [],
107
- adminWorkspaces: [],
108
- wsUrl: "",
109
- questionTimeoutMs: 6e4,
110
- remoteApprovals: false,
111
- logEnabled: true,
112
- logRetentionDays: 14
108
+ secretEnv: DEFAULT_SECRET_REF
113
109
  };
114
- var LIST_KEYS = ["adminUserIds", "adminWorkspaces"];
115
- var SCALAR_KEYS = [
116
- "botId",
117
- "wsUrl",
118
- "questionTimeoutMs",
119
- "remoteApprovals",
120
- "logEnabled",
121
- "logRetentionDays"
122
- ];
123
- function list(value) {
124
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
125
- }
126
110
  function text(value, fallback = "") {
127
111
  return typeof value === "string" ? value : fallback;
128
112
  }
@@ -130,36 +114,17 @@ window.__ModuleLoader__.load({
130
114
  const v = value ?? {};
131
115
  return {
132
116
  botId: text(v.botId),
133
- secretEnv: text(v.secretEnv).trim() || DEFAULTS.secretEnv,
134
- adminUserIds: list(v.adminUserIds),
135
- adminWorkspaces: list(v.adminWorkspaces),
136
- wsUrl: text(v.wsUrl),
137
- questionTimeoutMs: typeof v.questionTimeoutMs === "number" ? v.questionTimeoutMs : DEFAULTS.questionTimeoutMs,
138
- remoteApprovals: v.remoteApprovals === true,
139
- logEnabled: v.logEnabled !== false,
140
- logRetentionDays: typeof v.logRetentionDays === "number" ? v.logRetentionDays : DEFAULTS.logRetentionDays
117
+ secretEnv: text(v.secretEnv).trim() || DEFAULTS.secretEnv
141
118
  };
142
119
  }
143
- function normalizedList(values) {
144
- return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
145
- }
146
- function sameList(a, b) {
147
- const left = normalizedList(a);
148
- const right = normalizedList(b);
149
- return left.length === right.length && left.every((item) => right.includes(item));
150
- }
151
120
  function normalizedScalar(key, draft) {
152
121
  const value = draft[key];
153
122
  return typeof value === "string" ? value.trim() : value;
154
123
  }
155
124
  function changedOperations(draft, base) {
156
125
  const ops = [];
157
- for (const key of SCALAR_KEYS) {
158
- const next = normalizedScalar(key, draft);
159
- if (next !== normalizedScalar(key, base)) ops.push({ op: "set", path: [key], value: next });
160
- }
161
- for (const key of LIST_KEYS) {
162
- if (!sameList(draft[key], base[key])) ops.push({ op: "set", path: [key], value: normalizedList(draft[key]) });
126
+ if (normalizedScalar("botId", draft) !== normalizedScalar("botId", base)) {
127
+ ops.push({ op: "set", path: ["botId"], value: normalizedScalar("botId", draft) });
163
128
  }
164
129
  return ops;
165
130
  }
@@ -180,14 +145,25 @@ window.__ModuleLoader__.load({
180
145
  errors.wsUrl = "不是有效的 URL。";
181
146
  }
182
147
  }
183
- if (!Number.isFinite(draft.questionTimeoutMs) || draft.questionTimeoutMs < 1e3 || draft.questionTimeoutMs > 3e5) {
184
- errors.questionTimeoutMs = "请输入 1–300 秒。";
185
- }
186
- if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < 1 || draft.logRetentionDays > 365) {
187
- errors.logRetentionDays = "请输入 1–365 的整数天数。";
148
+ if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < MIN_LOG_RETENTION_DAYS || draft.logRetentionDays > MAX_LOG_RETENTION_DAYS) {
149
+ errors.logRetentionDays = `请输入 ${MIN_LOG_RETENTION_DAYS}–${MAX_LOG_RETENTION_DAYS} 的整数天数。`;
188
150
  }
189
151
  return errors;
190
152
  }
153
+ function advancedSlice(settings) {
154
+ return {
155
+ wsUrl: settings?.wsUrl ?? "",
156
+ logEnabled: settings?.logEnabled ?? true,
157
+ logRetentionDays: settings?.logRetentionDays ?? DEFAULT_LOG_RETENTION_DAYS
158
+ };
159
+ }
160
+ function settingsPatch(draft, stored) {
161
+ const patch = {};
162
+ if (draft.wsUrl.trim() !== stored.wsUrl.trim()) patch.wsUrl = draft.wsUrl.trim();
163
+ if (draft.logEnabled !== stored.logEnabled) patch.logEnabled = draft.logEnabled;
164
+ if (draft.logRetentionDays !== stored.logRetentionDays) patch.logRetentionDays = draft.logRetentionDays;
165
+ return patch;
166
+ }
191
167
  function toggle(values, id, on) {
192
168
  const has = values.includes(id);
193
169
  const want = on ?? !has;
@@ -218,11 +194,6 @@ window.__ModuleLoader__.load({
218
194
  const choice = catalog?.choices.find((item) => item.provider === provider && item.model === model);
219
195
  return choice?.efforts ?? [];
220
196
  }
221
- function modelLabel(catalog, selection) {
222
- if (!selection) return "";
223
- const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
224
- return choice ? choiceLabel(choice) : `${selection.provider}/${selection.model}`;
225
- }
226
197
  function modelName(catalog, selection) {
227
198
  if (!selection) return "";
228
199
  const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
@@ -273,7 +244,6 @@ window.__ModuleLoader__.load({
273
244
  if (!value) return "跟随 DSH 默认模型";
274
245
  return `跟随 DSH 默认模型(${modelName(catalog, value)})`;
275
246
  }
276
- var BINDING_KIND_LABEL = { user: "个人", group: "群聊" };
277
247
  var SESSION_STATE_LABEL = {
278
248
  bound: "已绑定",
279
249
  auto: "待创建",
@@ -304,6 +274,9 @@ window.__ModuleLoader__.load({
304
274
  if (diff < 30 * 864e5) return `${Math.floor(diff / 864e5)} 天前`;
305
275
  return new Date(at).toLocaleDateString();
306
276
  }
277
+ function setSettings(patch) {
278
+ return { op: "settings.set", patch };
279
+ }
307
280
  function addGroup(name) {
308
281
  return { op: "group.add", ...name ? { name } : {} };
309
282
  }
@@ -325,6 +298,9 @@ window.__ModuleLoader__.load({
325
298
  function removeMember(key) {
326
299
  return { op: "member.remove", key };
327
300
  }
301
+ function setMemberModel(key, sessionId, selection) {
302
+ return { op: "member.model", key, sessionId, selection };
303
+ }
328
304
  function archiveMember(key) {
329
305
  return { op: "member.archive", key };
330
306
  }
@@ -406,14 +382,14 @@ window.__ModuleLoader__.load({
406
382
  }), [remote, ref, refresh]);
407
383
  return { configured, known, refresh };
408
384
  }
409
- function useRoutingApply(onChanged) {
385
+ function useStoreApply(onChanged) {
410
386
  const [busy, setBusy] = (0, import_react.useState)("");
411
387
  const [error, setError] = (0, import_react.useState)();
412
388
  const apply2 = (0, import_react.useCallback)(async (key, ops) => {
413
389
  setBusy(key);
414
390
  setError(void 0);
415
391
  try {
416
- const response = await postRouting(ops);
392
+ const response = await postStore(ops);
417
393
  onChanged();
418
394
  return response;
419
395
  } catch (cause) {
@@ -426,6 +402,33 @@ window.__ModuleLoader__.load({
426
402
  const dismiss = (0, import_react.useCallback)(() => setError(void 0), []);
427
403
  return { busy, error, apply: apply2, dismiss };
428
404
  }
405
+ function useStoreSettingsSave(onSaved) {
406
+ const [saving, setSaving] = (0, import_react.useState)(false);
407
+ const [error, setError] = (0, import_react.useState)();
408
+ const [saved, setSaved] = (0, import_react.useState)(false);
409
+ const timer = (0, import_react.useRef)();
410
+ (0, import_react.useEffect)(() => () => {
411
+ if (timer.current) clearTimeout(timer.current);
412
+ }, []);
413
+ const save = (0, import_react.useCallback)(async (patch) => {
414
+ setSaving(true);
415
+ setError(void 0);
416
+ if (timer.current) clearTimeout(timer.current);
417
+ try {
418
+ await postStore([setSettings(patch)]);
419
+ setSaved(true);
420
+ timer.current = setTimeout(() => setSaved(false), 2e3);
421
+ onSaved();
422
+ return true;
423
+ } catch (cause) {
424
+ setError(cause instanceof Error ? cause.message : String(cause));
425
+ return false;
426
+ } finally {
427
+ setSaving(false);
428
+ }
429
+ }, [onSaved]);
430
+ return { saving, error, saved, save };
431
+ }
429
432
  function useConfigSave(scope, onSaved) {
430
433
  const [saving, setSaving] = (0, import_react.useState)(false);
431
434
  const [error, setError] = (0, import_react.useState)();
@@ -462,10 +465,11 @@ window.__ModuleLoader__.load({
462
465
  }
463
466
 
464
467
  // src/client/components/AdminCard.tsx
465
- var import_react2 = require("react");
468
+ var import_react3 = require("react");
466
469
  var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
467
470
 
468
471
  // src/client/components/ui.tsx
472
+ var import_react2 = require("react");
469
473
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
470
474
  var import_jsx_runtime = require("react/jsx-runtime");
471
475
  function Select({ className, ...rest }) {
@@ -487,13 +491,21 @@ window.__ModuleLoader__.load({
487
491
  aside && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-aside", children: aside })
488
492
  ] });
489
493
  }
490
- function Collapse({ open, onToggle, title, summary, actions, children, className }) {
491
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ["wcb-group", className].filter(Boolean).join(" "), "data-open": open ? "" : void 0, children: [
494
+ function Collapse({ open, onToggle, title, summary, facts, actions, children, className }) {
495
+ const hasFacts = Boolean(facts?.length);
496
+ const showFacts = hasFacts && !open;
497
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ["wcb-group", className].filter(Boolean).join(" "), "data-open": open ? "" : void 0, "data-facts": showFacts ? "" : void 0, children: [
492
498
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-group-head", children: [
493
499
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "wcb-group-toggle", "aria-expanded": open, onClick: onToggle, children: [
494
- /* @__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 }) }),
495
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-title", children: title }),
496
- summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-summary", children: summary })
500
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "wcb-group-title-line", children: [
501
+ /* @__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 }) }),
502
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-title", children: title })
503
+ ] }),
504
+ summary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-summary", children: summary }),
505
+ showFacts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-facts", children: facts.map((fact) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "wcb-group-fact", children: [
506
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-fact-label", children: fact.label }),
507
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-fact-value", title: fact.title, children: fact.value })
508
+ ] }, fact.key)) })
497
509
  ] }),
498
510
  actions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-actions", children: actions })
499
511
  ] }),
@@ -576,7 +588,7 @@ window.__ModuleLoader__.load({
576
588
  contentClassName: "wcb-modal-content",
577
589
  children: [
578
590
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-facts", children: [
579
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
591
+ typeLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
580
592
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "企微 ID", mono: true, children: id }),
581
593
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
582
594
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: "备注" }),
@@ -607,6 +619,44 @@ window.__ModuleLoader__.load({
607
619
  }
608
620
  );
609
621
  }
622
+ function SessionDialog({ open, onClose, name, title, id, running, blank, disabled, error, onOpen }) {
623
+ const [copied, setCopied] = (0, import_react2.useState)(false);
624
+ const copy = async () => {
625
+ if (!await (0, import_dsh_client_ui_primitives.writeClipboard)(id)) return;
626
+ setCopied(true);
627
+ setTimeout(() => setCopied(false), 1500);
628
+ };
629
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
630
+ import_dsh_client_ui_primitives.Modal,
631
+ {
632
+ open,
633
+ onClose,
634
+ title: `${name} 的会话`,
635
+ closeLabel: "关闭",
636
+ className: "wcb-modal",
637
+ contentClassName: "wcb-modal-content",
638
+ children: [
639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-facts", children: [
640
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "会话名称", children: title }),
641
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "Session ID", mono: true, children: id }),
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "状态", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "wcb-running", children: [
643
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.StateDot, { state: running ? "ongoing" : "idle", size: 8 }),
644
+ blank ? "待使用(还没有开始)" : running ? "运行中" : "空闲"
645
+ ] }) })
646
+ ] }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-hint", children: "这里只展示会话身份,不会切换页面;点「在 DSH 中打开」才会跳转到这个会话。打开不会改变绑定,也不会新建会话。" }),
648
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }),
649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-dialog-actions", children: [
650
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "outline", size: "sm", onClick: () => {
651
+ void copy();
652
+ }, children: copied ? "已复制" : "复制 Session ID" }),
653
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", onClick: onClose, children: "关闭" }),
654
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", size: "sm", disabled, onClick: onOpen, children: "在 DSH 中打开" })
655
+ ] })
656
+ ]
657
+ }
658
+ );
659
+ }
610
660
  function SaveBar({ dirty, saving, saved, error, disabled, onSave, onDiscard }) {
611
661
  if (!dirty && !saved && !error) return null;
612
662
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-savebar", children: [
@@ -637,25 +687,32 @@ window.__ModuleLoader__.load({
637
687
 
638
688
  // src/client/components/AdminCard.tsx
639
689
  var import_jsx_runtime2 = require("react/jsx-runtime");
640
- function AdminCard({ scope, base, state, disabled, onChanged }) {
641
- const [draft, setDraft] = (0, import_react2.useState)(() => ({
642
- adminUserIds: [...base.adminUserIds],
643
- adminWorkspaces: [...base.adminWorkspaces]
644
- }));
645
- const [picking, setPicking] = (0, import_react2.useState)(false);
646
- const [query, setQuery] = (0, import_react2.useState)("");
647
- const [scopeOpen, setScopeOpen] = (0, import_react2.useState)(false);
648
- const save = useConfigSave(scope, onChanged);
649
- const routing = useRoutingApply(onChanged);
690
+ function AdminCard({ state, disabled, onChanged }) {
691
+ const storedIds = state?.settings?.adminUserIds ?? [];
692
+ const storedScope = state?.settings?.adminWorkspaces ?? [];
693
+ const [draft, setDraft] = (0, import_react3.useState)(() => ({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] }));
694
+ const [picking, setPicking] = (0, import_react3.useState)(false);
695
+ const [query, setQuery] = (0, import_react3.useState)("");
696
+ const [scopeOpen, setScopeOpen] = (0, import_react3.useState)(false);
697
+ const save = useStoreSettingsSave(onChanged);
698
+ const routing = useStoreApply(onChanged);
650
699
  const admins = state?.admins ?? [];
700
+ const groups = state?.routing?.groups ?? [];
651
701
  const workspaces = state?.workspaces ?? [];
652
702
  const all = draft.adminWorkspaces.length === 0;
653
- (0, import_react2.useEffect)(() => {
654
- setDraft({ adminUserIds: [...base.adminUserIds], adminWorkspaces: [...base.adminWorkspaces] });
655
- }, [base]);
656
- const dirty = changedOperations({ ...base, ...draft }, base).length > 0;
703
+ const busy = disabled || save.saving;
704
+ const storedKey = `${storedIds.join("\0")}${storedScope.join("\0")}`;
705
+ (0, import_react3.useEffect)(() => {
706
+ setDraft({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] });
707
+ }, [storedKey]);
708
+ const apply2 = async (patch) => {
709
+ setDraft((current) => ({ ...current, ...patch }));
710
+ if (!await save.save(patch)) {
711
+ setDraft({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] });
712
+ }
713
+ };
657
714
  const known = new Map(admins.map((admin) => [admin.id, admin]));
658
- const candidates = (0, import_react2.useMemo)(() => {
715
+ const candidates = (0, import_react3.useMemo)(() => {
659
716
  const rows = /* @__PURE__ */ new Map();
660
717
  for (const sender of state?.rejected ?? []) {
661
718
  if (sender.kind !== "user") continue;
@@ -682,7 +739,7 @@ window.__ModuleLoader__.load({
682
739
  const matches = needle ? candidates.filter((row) => row.name.toLowerCase().includes(needle) || row.id.toLowerCase().includes(needle)) : candidates;
683
740
  const typed = query.trim();
684
741
  const addAdmin = (id) => {
685
- setDraft((current) => ({ ...current, adminUserIds: toggle(current.adminUserIds, id, true) }));
742
+ void apply2({ adminUserIds: toggle(draft.adminUserIds, id, true) });
686
743
  setQuery("");
687
744
  setPicking(false);
688
745
  };
@@ -691,7 +748,7 @@ window.__ModuleLoader__.load({
691
748
  {
692
749
  step: 4,
693
750
  title: "管理员",
694
- description: "只有这里列出的 userid 可以切换会话(/sessions、/use、/new、/workspaces)、在单聊里审批工具调用,并按下面的范围接收通知。其它用户永远只能访问自己专属的会话。",
751
+ description: "只有这里列出的 userid 可以切换会话(/sessions、/use、/new、/workspaces)、在单聊里审批工具调用,并按下面的范围接收通知。其它用户永远只能访问自己专属的会话。改动即时生效。",
695
752
  aside: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
696
753
  draft.adminUserIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: [
697
754
  draft.adminUserIds.length,
@@ -703,7 +760,7 @@ window.__ModuleLoader__.load({
703
760
  variant: "outline",
704
761
  size: "sm",
705
762
  icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconPlusOutlineRegular, {}),
706
- disabled,
763
+ disabled: busy,
707
764
  "aria-label": "添加管理员",
708
765
  onClick: () => setPicking(true),
709
766
  children: "添加"
@@ -712,20 +769,25 @@ window.__ModuleLoader__.load({
712
769
  ] }),
713
770
  children: [
714
771
  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 }) }) }),
772
+ 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 }) }) }),
715
773
  /* @__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: [
716
774
  "还没有管理员:没有人可以切换会话、审批工具调用或接收他人会话的通知。",
717
- /* @__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, onClick: () => setPicking(true), children: "添加管理员" }) })
775
+ /* @__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: "添加管理员" }) })
718
776
  ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: draft.adminUserIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
719
777
  AdminRow,
720
778
  {
721
779
  id,
722
780
  label: known.get(id)?.label ?? "",
723
781
  groupName: known.get(id)?.groupName,
724
- disabled: disabled || routing.busy === personKey("user", id),
782
+ groups,
783
+ disabled: busy || routing.busy === personKey("user", id),
784
+ onAssign: (groupId) => routing.apply(personKey("user", id), [addMember(groupId, "user", id)]),
725
785
  onNote: (next) => {
726
786
  void routing.apply(personKey("user", id), [setLabel(personKey("user", id), next)]);
727
787
  },
728
- onRemove: () => setDraft((current) => ({ ...current, adminUserIds: toggle(current.adminUserIds, id, false) }))
788
+ onRemove: () => {
789
+ void apply2({ adminUserIds: toggle(draft.adminUserIds, id, false) });
790
+ }
729
791
  },
730
792
  id
731
793
  )) }) }),
@@ -739,18 +801,21 @@ window.__ModuleLoader__.load({
739
801
  " 可接收通知的 Workspace"
740
802
  ] }),
741
803
  summary: all ? "全部 Workspace" : `${draft.adminWorkspaces.length} / ${workspaces.length || draft.adminWorkspaces.length} 个 Workspace`,
742
- actions: all ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setDraft((current) => ({ ...current, adminWorkspaces: [] })), children: "全选" }),
804
+ actions: all ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => {
805
+ void apply2({ adminWorkspaces: [] });
806
+ }, children: "全选" }),
743
807
  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: [
744
808
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-panel-scroll", children: workspaces.map((workspace) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
745
809
  CheckRow,
746
810
  {
747
811
  checked: scopeIncludes(draft.adminWorkspaces, workspace.path),
748
812
  label: `管理员接收 ${workspace.title} 的通知`,
749
- disabled,
750
- onToggle: (on) => setDraft((current) => ({
751
- ...current,
752
- adminWorkspaces: toggleScope(current.adminWorkspaces, workspaces.map((item) => item.path), workspace.path, on)
753
- })),
813
+ disabled: busy,
814
+ onToggle: (on) => {
815
+ void apply2({
816
+ adminWorkspaces: toggleScope(draft.adminWorkspaces, workspaces.map((item) => item.path), workspace.path, on)
817
+ });
818
+ },
754
819
  meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-meta", children: workspace.sessionCount ? `${workspace.sessionCount} 个会话` : "暂无会话" }),
755
820
  children: [
756
821
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-title", children: workspace.title }),
@@ -762,25 +827,11 @@ window.__ModuleLoader__.load({
762
827
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-add", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-grow wcb-hint", children: [
763
828
  all ? "未限定(全部勾选):管理员会收到所有这些 Workspace 中会话的通知。取消勾选任意一项即改为只收勾选的 Workspace。" : "管理员只接收已勾选 Workspace 中会话的通知(外加他们自己绑定的会话)。",
764
829
  " ",
765
- "只有归档会话的 Workspace 也会列出。"
830
+ "只有归档会话的 Workspace 也会列出。勾选即生效。"
766
831
  ] }) })
767
832
  ] })
768
833
  }
769
834
  ) }),
770
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
771
- SaveBar,
772
- {
773
- dirty,
774
- saving: save.saving,
775
- saved: save.saved,
776
- error: save.error,
777
- disabled,
778
- onSave: () => {
779
- void save.save(draft);
780
- },
781
- onDiscard: () => setDraft({ adminUserIds: [...base.adminUserIds], adminWorkspaces: [...base.adminWorkspaces] })
782
- }
783
- ),
784
835
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
785
836
  import_dsh_client_ui_primitives2.Modal,
786
837
  {
@@ -825,7 +876,7 @@ window.__ModuleLoader__.load({
825
876
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-picker-hint", children: "按 userid 添加一个还没给机器人发过消息的人" }),
826
877
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", onClick: () => addAdmin(typed), children: "添加" })
827
878
  ] }),
828
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "名单来自未授权用户和已授权成员,优先显示备注名;没有备注时显示企微 userid。改动在点「保存」后生效。" })
879
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "名单来自未授权用户和已授权成员,优先显示备注名;没有备注时显示企微 userid。选中即生效。" })
829
880
  ]
830
881
  }
831
882
  )
@@ -833,8 +884,9 @@ window.__ModuleLoader__.load({
833
884
  }
834
885
  );
835
886
  }
836
- function AdminRow({ id, label, groupName, disabled, onNote, onRemove }) {
837
- const [details, setDetails] = (0, import_react2.useState)(false);
887
+ function AdminRow({ id, label, groupName, groups, disabled, onAssign, onNote, onRemove }) {
888
+ const [details, setDetails] = (0, import_react3.useState)(false);
889
+ const [assigning, setAssigning] = (0, import_react3.useState)(false);
838
890
  const name = label || id;
839
891
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-member", children: [
840
892
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -847,10 +899,51 @@ window.__ModuleLoader__.load({
847
899
  onOpen: () => setDetails(true),
848
900
  meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
849
901
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tag, { tone: "success", children: "管理员" }),
850
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-row-sub", children: groupName ? `分组:${groupName}` : "不在任何分组" })
902
+ groupName ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "wcb-row-sub", children: [
903
+ "分组:",
904
+ groupName
905
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
906
+ "button",
907
+ {
908
+ type: "button",
909
+ className: "wcb-link",
910
+ disabled,
911
+ "aria-label": `为 ${name} 分配分组`,
912
+ "aria-expanded": assigning,
913
+ onClick: () => setAssigning((value) => !value),
914
+ children: "不在任何分组"
915
+ }
916
+ )
851
917
  ] })
852
918
  }
853
919
  ),
920
+ assigning && !groupName && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-member-edit", children: [
921
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "wcb-binding-field", children: [
922
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-binding-label", children: "加入分组" }),
923
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
924
+ Select,
925
+ {
926
+ value: "",
927
+ autoFocus: true,
928
+ disabled: disabled || !groups.length,
929
+ "aria-label": `管理员 ${id} 的分组`,
930
+ onChange: (event) => {
931
+ const groupId = event.target.value;
932
+ if (!groupId) return;
933
+ void onAssign(groupId).then((result) => {
934
+ if (result) setAssigning(false);
935
+ });
936
+ },
937
+ children: [
938
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", disabled: true, children: groups.length ? "请选择分组" : "暂无可用分组" }),
939
+ groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: group.id, children: group.name }, group.id))
940
+ ]
941
+ }
942
+ ),
943
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "wcb-hint", children: "选择后立即加入;下一条消息按该组的 Workspace、模型与 preset 创建会话,管理员权限不变。" })
944
+ ] }),
945
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setAssigning(false), children: "取消" })
946
+ ] }),
854
947
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
855
948
  PersonDialog,
856
949
  {
@@ -866,7 +959,7 @@ window.__ModuleLoader__.load({
866
959
  footer: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
867
960
  import_dsh_client_ui_primitives2.Button,
868
961
  {
869
- variant: "ghost",
962
+ variant: "outline",
870
963
  size: "sm",
871
964
  icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconTrashOutlineRegular, {}),
872
965
  disabled,
@@ -877,10 +970,10 @@ window.__ModuleLoader__.load({
877
970
  ),
878
971
  children: [
879
972
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-person-facts", children: [
880
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "授权来源", children: "插件设置里的管理员列表(点本卡片的「保存」后生效)" }),
973
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "授权来源", children: "插件设置里的管理员列表(改动即时生效)" }),
881
974
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fact, { name: "所属分组", children: groupName ?? "不在任何分组" })
882
975
  ] }),
883
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "备注即时生效;加入或移出管理员名单需要点「保存」。" })
976
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "wcb-hint", children: "备注与管理员名单都即时生效。" })
884
977
  ]
885
978
  }
886
979
  )
@@ -888,19 +981,22 @@ window.__ModuleLoader__.load({
888
981
  }
889
982
 
890
983
  // src/client/components/AdvancedCard.tsx
891
- var import_react3 = require("react");
984
+ var import_react4 = require("react");
892
985
  var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
893
986
  var import_jsx_runtime3 = require("react/jsx-runtime");
894
- function AdvancedCard({ scope, base, journal, disabled, onChanged }) {
895
- const [draft, setDraft] = (0, import_react3.useState)(() => slice(base));
896
- const [attempted, setAttempted] = (0, import_react3.useState)(false);
897
- const [copied, setCopied] = (0, import_react3.useState)(false);
898
- const save = useConfigSave(scope, onChanged);
899
- const dirty = changedOperations({ ...base, ...draft }, base).length > 0;
987
+ function AdvancedCard({ settings, journal, disabled, onChanged }) {
988
+ const stored = advancedSlice(settings);
989
+ const [draft, setDraft] = (0, import_react4.useState)(() => advancedSlice(settings));
990
+ const [attempted, setAttempted] = (0, import_react4.useState)(false);
991
+ const [copied, setCopied] = (0, import_react4.useState)(false);
992
+ const save = useStoreSettingsSave(onChanged);
993
+ const patch = settingsPatch(draft, stored);
994
+ const dirty = Object.keys(patch).length > 0;
900
995
  const errors = attempted ? validateAdvanced(draft) : {};
901
- (0, import_react3.useEffect)(() => {
902
- setDraft(slice(base));
903
- }, [base]);
996
+ const storedKey = JSON.stringify(stored);
997
+ (0, import_react4.useEffect)(() => {
998
+ setDraft(advancedSlice(settings));
999
+ }, [storedKey]);
904
1000
  const copy = async () => {
905
1001
  if (!journal?.directory) return;
906
1002
  setCopied(await (0, import_dsh_client_ui_primitives3.writeClipboard)(journal.directory));
@@ -911,64 +1007,31 @@ window.__ModuleLoader__.load({
911
1007
  CardHead,
912
1008
  {
913
1009
  step: 5,
914
- title: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
915
- "高级设置 ",
916
- draft.remoteApprovals && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Tag, { tone: "warning", children: "远程审批已开启" })
917
- ] }),
918
- description: "远程审批、等待时间、自定义连接地址与对话日志。均可保持默认。",
1010
+ title: "连接与日志",
1011
+ description: "私有化部署的 WebSocket 地址,以及对话日志的开关、保留天数与目录。",
919
1012
  aside: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "wcb-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconChevronRightOutlineRegular, { size: 16 }) })
920
1013
  }
921
1014
  ) }),
922
1015
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
923
1016
  Field,
924
1017
  {
925
- label: "远程审批工具调用",
926
- hint: "开启后,DSH 请求执行工具时会通知所有管理员,管理员在单聊里回复 /approve 或 /deny 即生效;群聊永远不能审批。关闭时只通知,审批仍需到 DSH 页面完成。",
927
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
928
- import_dsh_client_ui_primitives3.Switch,
929
- {
930
- checked: draft.remoteApprovals,
931
- disabled,
932
- label: "远程审批工具调用",
933
- onChange: (next) => setDraft((current) => ({ ...current, remoteApprovals: next }))
934
- }
935
- )
936
- }
937
- ),
938
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
939
- Field,
940
- {
941
- label: "等待企微回复(秒)",
942
- error: errors.questionTimeoutMs,
943
- hint: "DSH 提问或审批时,先等待企业微信回复的时间;超时后回到 DSH 页面处理。",
1018
+ label: "WebSocket 地址",
1019
+ error: errors.wsUrl,
1020
+ hint: "留空使用 SDK 默认地址。仅在企业私有化部署时需要,只接受 wss://。保存这一项会重新连接机器人——它是连接的一半;本卡其余设置保存后立即生效,不会断开正在进行的对话。",
944
1021
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
945
1022
  import_dsh_client_ui_primitives3.Input,
946
1023
  {
947
- className: "wcb-number",
948
- type: "number",
949
- min: 1,
950
- max: 300,
951
- step: 1,
952
- value: Math.round(draft.questionTimeoutMs / 1e3),
1024
+ className: "wcb-grow",
1025
+ value: draft.wsUrl,
1026
+ placeholder: "wss://openws.work.weixin.qq.com",
1027
+ spellCheck: false,
953
1028
  disabled,
954
- "aria-label": "等待企微回复的秒数",
955
- onChange: (event) => setDraft((current) => ({ ...current, questionTimeoutMs: Number(event.target.value) * 1e3 }))
1029
+ "aria-label": "WebSocket 地址",
1030
+ onChange: (event) => setDraft((current) => ({ ...current, wsUrl: event.target.value }))
956
1031
  }
957
1032
  )
958
1033
  }
959
1034
  ),
960
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Field, { label: "WebSocket 地址", error: errors.wsUrl, hint: "留空使用 SDK 默认地址。仅在企业私有化部署时需要,只接受 wss://。", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
961
- import_dsh_client_ui_primitives3.Input,
962
- {
963
- className: "wcb-grow",
964
- value: draft.wsUrl,
965
- placeholder: "wss://openws.work.weixin.qq.com",
966
- spellCheck: false,
967
- disabled,
968
- "aria-label": "WebSocket 地址",
969
- onChange: (event) => setDraft((current) => ({ ...current, wsUrl: event.target.value }))
970
- }
971
- ) }),
972
1035
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
973
1036
  Field,
974
1037
  {
@@ -1017,7 +1080,7 @@ window.__ModuleLoader__.load({
1017
1080
  errors.logRetentionDays && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-field-error", children: errors.logRetentionDays }),
1018
1081
  journal?.directory && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "wcb-field-row", style: { marginTop: 10 }, children: [
1019
1082
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-path wcb-grow", title: journal.file, children: journal.directory }),
1020
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "ghost", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconCopyOutlineRegular, {}), onClick: () => {
1083
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Button, { variant: "outline", size: "sm", icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.IconCopyOutlineRegular, {}), onClick: () => {
1021
1084
  void copy();
1022
1085
  }, children: copied ? "已复制" : "复制路径" })
1023
1086
  ] })
@@ -1034,42 +1097,33 @@ window.__ModuleLoader__.load({
1034
1097
  disabled,
1035
1098
  onSave: () => {
1036
1099
  setAttempted(true);
1037
- void save.save(draft);
1100
+ if (dirty) void save.save(patch);
1038
1101
  },
1039
1102
  onDiscard: () => {
1040
- setDraft(slice(base));
1103
+ setDraft(advancedSlice(settings));
1041
1104
  setAttempted(false);
1042
1105
  }
1043
1106
  }
1044
1107
  )
1045
1108
  ] });
1046
1109
  }
1047
- function slice(base) {
1048
- return {
1049
- remoteApprovals: base.remoteApprovals,
1050
- questionTimeoutMs: base.questionTimeoutMs,
1051
- wsUrl: base.wsUrl,
1052
- logEnabled: base.logEnabled,
1053
- logRetentionDays: base.logRetentionDays
1054
- };
1055
- }
1056
1110
 
1057
1111
  // src/client/components/CredentialsCard.tsx
1058
- var import_react4 = require("react");
1112
+ var import_react5 = require("react");
1059
1113
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
1060
1114
  var import_jsx_runtime4 = require("react/jsx-runtime");
1061
1115
  function CredentialsCard({ scope, base, disabled, remote, onChanged }) {
1062
- const [reveal, setReveal] = (0, import_react4.useState)(false);
1063
- const [secret, setSecret] = (0, import_react4.useState)("");
1064
- const [botId, setBotId] = (0, import_react4.useState)(base.botId);
1065
- const [error, setError] = (0, import_react4.useState)();
1066
- const [attempted, setAttempted] = (0, import_react4.useState)(false);
1116
+ const [reveal, setReveal] = (0, import_react5.useState)(false);
1117
+ const [secret, setSecret] = (0, import_react5.useState)("");
1118
+ const [botId, setBotId] = (0, import_react5.useState)(base.botId);
1119
+ const [error, setError] = (0, import_react5.useState)();
1120
+ const [attempted, setAttempted] = (0, import_react5.useState)(false);
1067
1121
  const save = useConfigSave(scope, onChanged);
1068
1122
  const status = useSecretStatus(remote, base.secretEnv);
1069
1123
  const ready = Boolean(botId.trim()) && (status.configured || Boolean(secret.trim()));
1070
1124
  const dirty = botId.trim() !== base.botId || Boolean(secret.trim());
1071
1125
  const errors = attempted ? validateCredentials({ botId, secret }, status.configured) : {};
1072
- (0, import_react4.useEffect)(() => {
1126
+ (0, import_react5.useEffect)(() => {
1073
1127
  setBotId(base.botId);
1074
1128
  }, [base.botId]);
1075
1129
  async function onSave() {
@@ -1134,7 +1188,7 @@ window.__ModuleLoader__.load({
1134
1188
  onChange: (event) => setSecret(event.target.value)
1135
1189
  }
1136
1190
  ),
1137
- /* @__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 ? "隐藏" : "显示" }),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "outline", size: "sm", type: "button", onClick: () => setReveal((value) => !value), disabled: !secret, children: reveal ? "隐藏" : "显示" }),
1138
1192
  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: "未设置" })
1139
1193
  ] })
1140
1194
  }
@@ -1164,14 +1218,14 @@ window.__ModuleLoader__.load({
1164
1218
  }
1165
1219
 
1166
1220
  // src/client/components/GroupsCard.tsx
1167
- var import_react5 = require("react");
1221
+ var import_react6 = require("react");
1168
1222
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
1169
1223
  var import_jsx_runtime5 = require("react/jsx-runtime");
1170
- function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged }) {
1171
- const { busy, error: applyError, apply: apply2 } = useRoutingApply(onChanged);
1172
- const [freshId, setFreshId] = (0, import_react5.useState)();
1224
+ function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged, onOpenSession }) {
1225
+ const { busy, error: applyError, apply: apply2 } = useStoreApply(onChanged);
1226
+ const [freshId, setFreshId] = (0, import_react6.useState)();
1173
1227
  const view = state?.routing;
1174
- (0, import_react5.useEffect)(() => {
1228
+ (0, import_react6.useEffect)(() => {
1175
1229
  if (freshId && view?.groups.some((group) => group.id === freshId)) setFreshId(void 0);
1176
1230
  }, [freshId, view]);
1177
1231
  const add = async () => {
@@ -1191,7 +1245,7 @@ window.__ModuleLoader__.load({
1191
1245
  children: [
1192
1246
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-toolbar", children: [
1193
1247
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-grow wcb-hint", children: "没有分组的用户无法与机器人对话;他们发消息后会出现在「未授权用户」卡片里,加入分组即完成授权。" }),
1194
- /* @__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 ? "刷新中" : "刷新" }),
1248
+ /* @__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.IconRefreshOutlineRegular, {}), disabled: refreshing, onClick: onRefresh, children: refreshing ? "刷新中" : "刷新" }),
1195
1249
  /* @__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: () => {
1196
1250
  void add();
1197
1251
  }, children: "添加分组" })
@@ -1204,7 +1258,9 @@ window.__ModuleLoader__.load({
1204
1258
  state,
1205
1259
  startEditing: group.id === freshId,
1206
1260
  disabled: disabled || busy.startsWith(`group:${group.id}`),
1207
- onApply: apply2
1261
+ onApply: apply2,
1262
+ onChanged,
1263
+ onOpenSession
1208
1264
  },
1209
1265
  group.id
1210
1266
  )) })
@@ -1237,11 +1293,11 @@ window.__ModuleLoader__.load({
1237
1293
  if (draft.preset !== group.preset) patch.preset = draft.preset;
1238
1294
  return patch;
1239
1295
  }
1240
- function GroupPanel({ group, state, startEditing, disabled, onApply }) {
1241
- const [open, setOpen] = (0, import_react5.useState)(startEditing);
1242
- const [editing, setEditing] = (0, import_react5.useState)(startEditing);
1243
- const [draft, setDraft] = (0, import_react5.useState)(() => draftOf(group));
1244
- const [confirming, setConfirming] = (0, import_react5.useState)(false);
1296
+ function GroupPanel({ group, state, startEditing, disabled, onApply, onChanged, onOpenSession }) {
1297
+ const [open, setOpen] = (0, import_react6.useState)(startEditing);
1298
+ const [editing, setEditing] = (0, import_react6.useState)(startEditing);
1299
+ const [draft, setDraft] = (0, import_react6.useState)(() => draftOf(group));
1300
+ const [confirming, setConfirming] = (0, import_react6.useState)(false);
1245
1301
  const catalog = state?.models;
1246
1302
  const presets = state?.presets;
1247
1303
  const workspaces = state?.workspaces ?? [];
@@ -1251,29 +1307,14 @@ window.__ModuleLoader__.load({
1251
1307
  model: group.effectiveModel,
1252
1308
  reasoningEffort: group.reasoningEffort
1253
1309
  }) || group.reasoningEffort : "默认";
1254
- const summary = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1255
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1256
- group.memberCount,
1257
- " 位成员"
1258
- ] }),
1259
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1260
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "Workspace" }),
1261
- group.workspaceTitle
1262
- ] }),
1263
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1264
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1265
- groupModelSummary(catalog, group)
1266
- ] }),
1267
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1268
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1269
- effort
1270
- ] }),
1271
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1272
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1273
- presetSummaryLabel(presets, group.preset)
1274
- ] })
1275
- ] });
1276
- (0, import_react5.useEffect)(() => {
1310
+ const facts = [
1311
+ { key: "members", label: "成员", value: `${group.memberCount} 位` },
1312
+ { key: "workspace", label: "Workspace", value: group.workspaceTitle, title: group.workspacePath },
1313
+ { key: "model", label: "模型", value: groupModelSummary(catalog, group) },
1314
+ { key: "effort", label: "effort", value: effort },
1315
+ { key: "preset", label: "preset", value: presetSummaryLabel(presets, group.preset) }
1316
+ ];
1317
+ (0, import_react6.useEffect)(() => {
1277
1318
  if (!editing) setDraft(draftOf(group));
1278
1319
  }, [group, editing]);
1279
1320
  const efforts = effortsFor(catalog, draft.provider || group.effectiveProvider, draft.model || group.effectiveModel);
@@ -1301,7 +1342,7 @@ window.__ModuleLoader__.load({
1301
1342
  group.name,
1302
1343
  group.isDefault && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "默认" })
1303
1344
  ] }),
1304
- summary,
1345
+ facts,
1305
1346
  actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1306
1347
  editing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1307
1348
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => {
@@ -1311,13 +1352,13 @@ window.__ModuleLoader__.load({
1311
1352
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "primary", size: "sm", disabled, onClick: () => {
1312
1353
  void save();
1313
1354
  }, children: "保存" })
1314
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, "aria-label": `编辑 ${group.name}`, onClick: startEdit, children: "编辑" }),
1355
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "outline", size: "sm", disabled, "aria-label": `编辑 ${group.name}`, onClick: startEdit, children: "编辑" }),
1315
1356
  !group.isDefault && (confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1316
1357
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1317
1358
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1318
1359
  import_dsh_client_ui_primitives5.Button,
1319
1360
  {
1320
- variant: "ghost",
1361
+ variant: "outline",
1321
1362
  size: "sm",
1322
1363
  icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1323
1364
  disabled,
@@ -1327,7 +1368,7 @@ window.__ModuleLoader__.load({
1327
1368
  children: "确认删除"
1328
1369
  }
1329
1370
  )
1330
- ] }) : /* @__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: "删除分组" }))
1371
+ ] }) : /* @__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.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "删除分组" }))
1331
1372
  ] }),
1332
1373
  children: [
1333
1374
  editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-binding-controls", children: [
@@ -1436,151 +1477,268 @@ window.__ModuleLoader__.load({
1436
1477
  !presets?.presets.length && `没有读到 DSH 的 preset 列表${state?.presetsError ? `:${state.presetsError}` : "(这个部署没有挂载 preset registry)"}。`
1437
1478
  ] }),
1438
1479
  group.workspaceError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint wcb-inline-error", children: group.workspaceError }),
1439
- editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint", children: "更换 Workspace 后,本组成员的会话会在下一条消息时重新创建。模型与 effort 在下一条消息时安装到已有会话; preset 只影响此后新建的会话(DSH 不允许改写已经开始的会话)。" }),
1440
- /* @__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)(
1441
- MemberRow,
1442
- {
1443
- member,
1444
- group,
1445
- groups: state?.routing?.groups ?? [],
1446
- state,
1447
- disabled,
1448
- onApply
1449
- },
1450
- member.key
1451
- )) })
1480
+ editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-hint", children: "更换 Workspace 后,本组成员的会话会在下一条消息时重新创建。模型与 effort 是本组默认值,不覆盖成员为当前会话单独选择的模型; preset 只影响此后新建的会话(DSH 不允许改写已经开始的会话)。" }),
1481
+ group.members.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Empty, { children: "这个分组还没有成员。让对方先给机器人发一条消息,然后在「未授权用户」里把 TA 加入本组。" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-members-scroll", tabIndex: 0, role: "region", "aria-label": `${group.name} 成员表格,可横向滚动`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "wcb-members-table", "aria-label": `${group.name} 的成员`, children: [
1482
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: ["成员", "会话", "preset", "模型", "effort", "上下文", "操作"].map((label) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { scope: "col", children: label }, label)) }) }),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { children: group.members.map((member) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1484
+ MemberRow,
1485
+ {
1486
+ member,
1487
+ group,
1488
+ groups: state?.routing?.groups ?? [],
1489
+ state,
1490
+ disabled,
1491
+ onChanged,
1492
+ onOpenSession
1493
+ },
1494
+ `${member.key}:${member.sessionId}`
1495
+ )) })
1496
+ ] }) })
1452
1497
  ]
1453
1498
  }
1454
1499
  );
1455
1500
  }
1456
- function MemberRow({ member, group, groups, state, disabled, onApply }) {
1457
- const [details, setDetails] = (0, import_react5.useState)(false);
1458
- const [archiving, setArchiving] = (0, import_react5.useState)(false);
1501
+ function MemberRow({ member, group, groups, state, disabled, onChanged, onOpenSession }) {
1502
+ const [details, setDetails] = (0, import_react6.useState)(false);
1503
+ const [archiving, setArchiving] = (0, import_react6.useState)(false);
1504
+ const [sessionOpen, setSessionOpen] = (0, import_react6.useState)(false);
1505
+ const [navigationError, setNavigationError] = (0, import_react6.useState)();
1506
+ const pending = (0, import_react6.useRef)(false);
1507
+ const write = useStoreApply(onChanged);
1508
+ const blocked = disabled || Boolean(write.busy);
1459
1509
  const catalog = state?.models;
1460
- const presets = state?.presets;
1461
- const others = groups.filter((item) => item.id !== group.id);
1462
- const effort = effortLabel(catalog, member.sessionModel);
1510
+ const selection = member.sessionSelection ?? member.sessionModel;
1511
+ const efforts = effortsFor(catalog, selection?.provider ?? "", selection?.model ?? "");
1512
+ const usable = Boolean(member.sessionId) && (member.sessionState === "bound" || member.sessionState === "blank");
1463
1513
  const name = member.displayName;
1464
- const title = member.sessionId ? member.sessionTitle ?? "未命名会话" : "待创建";
1465
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-member-row", children: [
1466
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PersonAvatar, { kind: member.kind, label: `${name} 的详情`, disabled, onClick: () => setDetails(true) }),
1467
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-name", title: name, children: name }),
1468
- member.admin && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "管理员" }),
1469
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-member-facts", children: [
1470
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1471
- member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.StateDot, { state: member.sessionRunning ? "ongoing" : "done", size: 8 }),
1472
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-strong", children: title }),
1473
- 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] })
1474
- ] }),
1475
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1476
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "preset" }),
1477
- presetLabel(presets, member.sessionPreset)
1478
- ] }),
1479
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1480
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "模型" }),
1481
- member.sessionModel ? modelName(catalog, member.sessionModel) : "—"
1482
- ] }),
1483
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1484
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "effort" }),
1485
- effort || "—"
1514
+ const sessionTitle = member.sessionTitle || "未命名会话";
1515
+ const sessionInfo = `会话:${sessionTitle}
1516
+ Session ID:${member.sessionId}`;
1517
+ const error = write.error ?? navigationError;
1518
+ const apply2 = async (_key, ops) => {
1519
+ if (disabled || pending.current) return void 0;
1520
+ pending.current = true;
1521
+ setNavigationError(void 0);
1522
+ try {
1523
+ return await write.apply(member.key, ops);
1524
+ } finally {
1525
+ pending.current = false;
1526
+ }
1527
+ };
1528
+ const openSession = async () => {
1529
+ setNavigationError(void 0);
1530
+ try {
1531
+ if (!onOpenSession) throw new Error("DSH 会话导航暂不可用,请刷新页面后重试。");
1532
+ await onOpenSession(member.sessionId);
1533
+ setSessionOpen(false);
1534
+ } catch (cause) {
1535
+ setNavigationError(cause instanceof Error ? cause.message : String(cause));
1536
+ }
1537
+ };
1538
+ const showSession = () => {
1539
+ setNavigationError(void 0);
1540
+ setSessionOpen(true);
1541
+ };
1542
+ const closeSession = () => {
1543
+ if (pending.current) return;
1544
+ setSessionOpen(false);
1545
+ setNavigationError(void 0);
1546
+ };
1547
+ const changeModel = async (value) => {
1548
+ const next = parseModelKey(value);
1549
+ if (!usable || !next.provider || !next.model) return;
1550
+ if (next.provider === selection?.provider && next.model === selection?.model) return;
1551
+ await apply2(member.key, [setMemberModel(member.key, member.sessionId, next)]);
1552
+ };
1553
+ const changeEffort = async (value) => {
1554
+ if (!usable || !selection || value && !efforts.some((item) => item.id === value)) return;
1555
+ if (value === (selection.reasoningEffort ?? "")) return;
1556
+ const next = { provider: selection.provider, model: selection.model, ...value ? { reasoningEffort: value } : {} };
1557
+ await apply2(member.key, [setMemberModel(member.key, member.sessionId, next)]);
1558
+ };
1559
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1560
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "wcb-member-row", "aria-busy": Boolean(write.busy), children: [
1561
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("td", { children: [
1562
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-member-identity", children: [
1563
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PersonAvatar, { kind: member.kind, label: `${name} 的详情`, disabled: blocked, onClick: () => setDetails(true) }),
1564
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-name", title: name, children: name }),
1565
+ member.admin && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "success", children: "管理员" })
1566
+ ] }),
1567
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1568
+ PersonDialog,
1569
+ {
1570
+ open: details,
1571
+ onClose: () => {
1572
+ if (!pending.current) setDetails(false);
1573
+ },
1574
+ title: name,
1575
+ id: member.id,
1576
+ label: member.label,
1577
+ noteLabel: `${member.id} 的备注`,
1578
+ disabled: blocked,
1579
+ onNote: (next) => {
1580
+ void apply2(member.key, [setLabel(member.key, next)]);
1581
+ },
1582
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RemoveMember, { member, disabled: blocked, onApply: apply2 }),
1583
+ children: [
1584
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1585
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "所属分组" }),
1586
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1587
+ Select,
1588
+ {
1589
+ value: group.id,
1590
+ disabled: blocked,
1591
+ "aria-label": `${member.id} 的所属分组`,
1592
+ onChange: (event) => {
1593
+ const groupId = event.target.value;
1594
+ if (!groupId || groupId === group.id) return;
1595
+ void apply2(member.key, [updateMember(member.key, { groupId })]);
1596
+ },
1597
+ children: groups.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1598
+ }
1599
+ ),
1600
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-hint", children: "切换后解除当前绑定,恢复目标分组原有的可用会话;没有可恢复会话时,下一条消息按目标组配置创建。" })
1601
+ ] }),
1602
+ write.error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-field-error", role: "alert", children: write.error })
1603
+ ]
1604
+ }
1605
+ )
1486
1606
  ] }),
1487
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "wcb-fact-inline", children: [
1488
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-fact-key", children: "上下文" }),
1489
- contextLabel(member.sessionContext) || "—"
1607
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { children: usable ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1608
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1609
+ "button",
1610
+ {
1611
+ type: "button",
1612
+ className: "wcb-cell-pill",
1613
+ title: sessionInfo,
1614
+ "aria-label": `查看 ${name} 的会话详情`,
1615
+ onClick: showSession,
1616
+ children: [
1617
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.StateDot, { state: member.sessionRunning ? "ongoing" : "idle", size: 8 }),
1618
+ member.sessionState === "blank" ? "待使用" : "已绑定",
1619
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-cell-pill-chevron", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconChevronRightOutlineRegular, { size: 11 }) })
1620
+ ]
1621
+ }
1622
+ ),
1623
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1624
+ SessionDialog,
1625
+ {
1626
+ open: sessionOpen,
1627
+ onClose: closeSession,
1628
+ name,
1629
+ title: sessionTitle,
1630
+ id: member.sessionId,
1631
+ running: member.sessionRunning,
1632
+ blank: member.sessionState === "blank",
1633
+ disabled: Boolean(write.busy),
1634
+ error: navigationError,
1635
+ onOpen: () => {
1636
+ void openSession();
1637
+ }
1638
+ }
1639
+ )
1640
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-muted", title: member.sessionId ? sessionInfo : void 0, children: SESSION_STATE_LABEL[member.sessionState] }) }),
1641
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { children: member.sessionPreset ? presetLabel(state?.presets, member.sessionPreset) : "—" }),
1642
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { children: usable ? (
1643
+ // Always a select: one click opens the list. The previous
1644
+ // click-to-swap-a-button behaviour needed a second click, because
1645
+ // an autofocused select does not open its popup by itself.
1646
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1647
+ Select,
1648
+ {
1649
+ className: "wcb-cell-select",
1650
+ value: modelKey(selection?.provider ?? "", selection?.model ?? ""),
1651
+ disabled: blocked || !catalog?.choices.length,
1652
+ "aria-label": `${member.id} 当前会话的模型`,
1653
+ title: "只修改当前会话;新会话仍使用分组默认模型",
1654
+ onChange: (event) => {
1655
+ void changeModel(event.target.value);
1656
+ },
1657
+ children: [
1658
+ !selection && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", disabled: true, children: "请选择模型" }),
1659
+ selection && !catalog?.choices.some((item) => item.provider === selection.provider && item.model === selection.model) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: modelKey(selection.provider, selection.model), children: [
1660
+ modelName(catalog, selection),
1661
+ "(当前)"
1662
+ ] }),
1663
+ (catalog?.choices ?? []).map((choice) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1664
+ "option",
1665
+ {
1666
+ value: modelKey(choice.provider, choice.model),
1667
+ title: `${choice.providerName} / ${choiceLabel(choice)}`,
1668
+ children: choice.name
1669
+ },
1670
+ modelKey(choice.provider, choice.model)
1671
+ ))
1672
+ ]
1673
+ }
1674
+ )
1675
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-muted", children: "—" }) }),
1676
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { children: usable && selection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1677
+ Select,
1678
+ {
1679
+ className: "wcb-cell-select",
1680
+ value: selection.reasoningEffort ?? "",
1681
+ disabled: blocked || !efforts.length,
1682
+ "aria-label": `${member.id} 当前会话的 effort`,
1683
+ title: efforts.length ? "只修改当前会话的思考强度" : "当前模型没有可选的思考强度",
1684
+ onChange: (event) => {
1685
+ void changeEffort(event.target.value);
1686
+ },
1687
+ children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "默认" }),
1689
+ efforts.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1690
+ ]
1691
+ }
1692
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-muted", children: "—" }) }),
1693
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "wcb-context-cell", children: contextLabel(member.sessionContext) || "—" }),
1694
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("td", { children: [
1695
+ member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1696
+ import_dsh_client_ui_primitives5.Button,
1697
+ {
1698
+ variant: "outline",
1699
+ size: "sm",
1700
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1701
+ disabled: blocked,
1702
+ "aria-label": `归档 ${name} 的会话`,
1703
+ onClick: () => setArchiving(true),
1704
+ children: "归档会话"
1705
+ }
1706
+ ),
1707
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1708
+ ConfirmDialog,
1709
+ {
1710
+ open: archiving,
1711
+ title: `归档「${name}」的会话?`,
1712
+ confirmLabel: "确认归档",
1713
+ busy: Boolean(write.busy),
1714
+ disabled,
1715
+ onCancel: () => {
1716
+ if (!pending.current) setArchiving(false);
1717
+ },
1718
+ onConfirm: () => {
1719
+ void apply2(member.key, [archiveMember(member.key)]).then((result) => {
1720
+ if (result) setArchiving(false);
1721
+ });
1722
+ },
1723
+ children: [
1724
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "归档后这个会话不再被继续,它的历史不会再进入任何请求;下一条消息会按分组当前的 Workspace、模型与 preset 新建一个会话。DSH 的会话文件仍保留在磁盘上,需要时可到 DSH 页面查看。" }),
1725
+ write.error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-field-error", role: "alert", children: write.error })
1726
+ ]
1727
+ }
1728
+ )
1490
1729
  ] })
1491
1730
  ] }),
1492
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-member-actions", children: member.sessionId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1493
- import_dsh_client_ui_primitives5.Button,
1494
- {
1495
- variant: "ghost",
1496
- size: "sm",
1497
- disabled,
1498
- "aria-label": `归档 ${name} 的会话`,
1499
- onClick: () => setArchiving(true),
1500
- children: "归档会话"
1501
- }
1502
- ) }),
1503
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1504
- PersonDialog,
1505
- {
1506
- open: details,
1507
- onClose: () => setDetails(false),
1508
- title: name,
1509
- typeLabel: BINDING_KIND_LABEL[member.kind],
1510
- id: member.id,
1511
- label: member.label,
1512
- noteLabel: `${member.id} 的备注`,
1513
- disabled,
1514
- onNote: (next) => {
1515
- void onApply(member.key, [setLabel(member.key, next)]);
1516
- },
1517
- footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RemoveMember, { member, disabled, onApply }),
1518
- children: [
1519
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-dialog-section wcb-person-facts", children: [
1520
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "所属分组", children: group.name }),
1521
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "会话", children: member.sessionId ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1522
- member.sessionTitle ?? "未命名会话",
1523
- " ",
1524
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-mono", children: member.sessionId.slice(-8) })
1525
- ] }) : "尚未创建" }),
1526
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "preset", children: presetLabel(presets, member.sessionPreset) }),
1527
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "模型", children: member.sessionModel ? modelLabel(catalog, member.sessionModel) : "—" }),
1528
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "effort", children: effort || "—" }),
1529
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "上下文", children: contextLabel(member.sessionContext) || "—" }),
1530
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fact, { name: "消息", children: member.messages ? `${member.messages} 条 · ${relativeTime(member.lastSeenAt)}` : "尚未收到消息" })
1531
- ] }),
1532
- others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "wcb-binding-field", children: [
1533
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "wcb-binding-label", children: "移动到分组" }),
1534
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1535
- Select,
1536
- {
1537
- value: "",
1538
- disabled,
1539
- "aria-label": `把 ${member.id} 移动到分组`,
1540
- onChange: (event) => {
1541
- if (!event.target.value) return;
1542
- void onApply(member.key, [updateMember(member.key, { groupId: event.target.value })]);
1543
- },
1544
- children: [
1545
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
1546
- "保持在「",
1547
- group.name,
1548
- "」"
1549
- ] }),
1550
- others.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: item.id, children: item.name }, item.id))
1551
- ]
1552
- }
1553
- )
1554
- ] })
1555
- ]
1556
- }
1557
- ),
1558
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1559
- ConfirmDialog,
1560
- {
1561
- open: archiving,
1562
- title: `归档「${name}」的会话?`,
1563
- confirmLabel: "确认归档",
1564
- disabled,
1565
- onCancel: () => setArchiving(false),
1566
- onConfirm: () => {
1567
- void Promise.resolve(onApply(member.key, [archiveMember(member.key)])).then((result) => {
1568
- if (result) setArchiving(false);
1569
- });
1570
- },
1571
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "归档后这个会话不再被继续,它的历史不会再进入任何请求;下一条消息会按分组当前的 Workspace、模型与 preset 新建一个会话。DSH 的会话文件仍保留在磁盘上,需要时可到 DSH 页面查看。" })
1572
- }
1573
- )
1731
+ error && !details && !archiving && !sessionOpen && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { className: "wcb-member-error", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: 7, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "wcb-field-error", role: "alert", children: error }) }) })
1574
1732
  ] });
1575
1733
  }
1576
1734
  function RemoveMember({ member, disabled, onApply }) {
1577
- const [confirming, setConfirming] = (0, import_react5.useState)(false);
1735
+ const [confirming, setConfirming] = (0, import_react6.useState)(false);
1578
1736
  return confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1579
1737
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1580
1738
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1581
1739
  import_dsh_client_ui_primitives5.Button,
1582
1740
  {
1583
- variant: "ghost",
1741
+ variant: "outline",
1584
1742
  size: "sm",
1585
1743
  icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1586
1744
  disabled,
@@ -1594,11 +1752,11 @@ window.__ModuleLoader__.load({
1594
1752
  ]
1595
1753
  }
1596
1754
  )
1597
- ] }) : /* @__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: "移出分组" });
1755
+ ] }) : /* @__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.IconTrashOutlineRegular, {}), disabled, onClick: () => setConfirming(true), children: "移出分组" });
1598
1756
  }
1599
1757
 
1600
1758
  // src/client/components/RejectedCard.tsx
1601
- var import_react6 = require("react");
1759
+ var import_react7 = require("react");
1602
1760
  var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
1603
1761
  var import_jsx_runtime6 = require("react/jsx-runtime");
1604
1762
  function RejectedCard({ state, disabled, onChanged }) {
@@ -1619,11 +1777,11 @@ window.__ModuleLoader__.load({
1619
1777
  );
1620
1778
  }
1621
1779
  function RejectedRow({ row, groups, disabled, onChanged }) {
1622
- const [open, setOpen] = (0, import_react6.useState)(false);
1623
- const [groupId, setGroupId] = (0, import_react6.useState)(groups.find((group) => group.id === "default")?.id ?? groups[0]?.id ?? "");
1624
- const [label, setLabel2] = (0, import_react6.useState)("");
1625
- const [busy, setBusy] = (0, import_react6.useState)(false);
1626
- const [error, setError] = (0, import_react6.useState)();
1780
+ const [open, setOpen] = (0, import_react7.useState)(false);
1781
+ const [groupId, setGroupId] = (0, import_react7.useState)(groups.find((group) => group.id === "default")?.id ?? groups[0]?.id ?? "");
1782
+ const [label, setLabel2] = (0, import_react7.useState)("");
1783
+ const [busy, setBusy] = (0, import_react7.useState)(false);
1784
+ const [error, setError] = (0, import_react7.useState)();
1627
1785
  async function authorize() {
1628
1786
  if (!groupId) {
1629
1787
  setError("还没有可用的分组。");
@@ -1632,7 +1790,7 @@ window.__ModuleLoader__.load({
1632
1790
  setBusy(true);
1633
1791
  setError(void 0);
1634
1792
  try {
1635
- await postRouting([addMember(groupId, row.kind, row.id, label.trim())]);
1793
+ await postStore([addMember(groupId, row.kind, row.id, label.trim())]);
1636
1794
  onChanged();
1637
1795
  } catch (cause) {
1638
1796
  setError(cause instanceof Error ? cause.message : String(cause));
@@ -1745,15 +1903,15 @@ window.__ModuleLoader__.load({
1745
1903
 
1746
1904
  // src/client/components/SettingsPage.tsx
1747
1905
  var import_jsx_runtime8 = require("react/jsx-runtime");
1748
- function SettingsPage({ scope, remote }) {
1906
+ function SettingsPage({ scope, remote, onOpenSession }) {
1749
1907
  const snapshot = useFormSnapshot(scope);
1750
1908
  if (snapshot.status !== "ready") {
1751
1909
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-page", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "wcb-card", children: snapshot.status === "loading" ? "正在加载插件配置…" : "插件配置暂不可用:请确认插件已启用。" }) });
1752
1910
  }
1753
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote });
1911
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote, onOpenSession });
1754
1912
  }
1755
- function SettingsEditor({ snapshot, scope, remote }) {
1756
- const base = (0, import_react7.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
1913
+ function SettingsEditor({ snapshot, scope, remote, onOpenSession }) {
1914
+ const base = (0, import_react8.useMemo)(() => storedFrom(snapshot.value), [snapshot.revision]);
1757
1915
  const bridge = useBridgeState();
1758
1916
  const writable = snapshot.writable !== false;
1759
1917
  const state = bridge.data;
@@ -1770,12 +1928,13 @@ window.__ModuleLoader__.load({
1770
1928
  disabled: !writable,
1771
1929
  refreshing: bridge.refreshing,
1772
1930
  onRefresh: () => bridge.refresh(true),
1773
- onChanged
1931
+ onChanged,
1932
+ onOpenSession
1774
1933
  }
1775
1934
  ),
1776
1935
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RejectedCard, { state, disabled: !writable, onChanged }),
1777
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdminCard, { scope, base, state, disabled: !writable, onChanged }),
1778
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdvancedCard, { scope, base, journal: state?.journal, disabled: !writable, onChanged })
1936
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdminCard, { state, disabled: !writable, onChanged }),
1937
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdvancedCard, { settings: state?.settings, journal: state?.journal, disabled: !writable, onChanged })
1779
1938
  ] });
1780
1939
  }
1781
1940
 
@@ -1928,6 +2087,7 @@ window.__ModuleLoader__.load({
1928
2087
  .wcb-chevron { flex: none; color: var(--wcb-text-3); transition: transform .15s ease; }
1929
2088
  .wcb-group[data-open] .wcb-chevron { transform: rotate(90deg); }
1930
2089
  .wcb-group-icon { flex: none; color: var(--wcb-text-2); }
2090
+ .wcb-group-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
1931
2091
  .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
1932
2092
  /* The group overview: labelled facts that wrap instead of hiding behind an ellipsis. */
1933
2093
  .wcb-group-summary {
@@ -1935,6 +2095,24 @@ window.__ModuleLoader__.load({
1935
2095
  gap: 2px 10px; color: var(--wcb-text-3); font-size: 12px; text-align: right;
1936
2096
  }
1937
2097
  .wcb-group-summary .wcb-fact-inline { white-space: nowrap; }
2098
+ /* A group owns five facts, so its collapsed header is a five-track grid: the
2099
+ label sits above its value and the same track holds the same fact in every
2100
+ group. Values wrap; nothing is hidden behind an ellipsis. */
2101
+ .wcb-group[data-facts] .wcb-group-head { align-items: flex-start; }
2102
+ .wcb-group[data-facts] .wcb-group-toggle { flex-direction: column; align-items: stretch; gap: 5px; }
2103
+ .wcb-group[data-facts] .wcb-group-actions { padding-top: 5px; }
2104
+ .wcb-group-facts {
2105
+ display: grid;
2106
+ grid-template-columns: 64px 128px minmax(150px, 1.6fr) 64px minmax(100px, 1fr);
2107
+ gap: 2px 14px;
2108
+ width: 100%; text-align: left;
2109
+ }
2110
+ .wcb-group-fact { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
2111
+ .wcb-group-fact-label { color: var(--wcb-text-3); font-size: 10.5px; line-height: 1.2; }
2112
+ .wcb-group-fact-value { color: var(--wcb-text-2); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
2113
+ @media (max-width: 860px) {
2114
+ .wcb-group-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
2115
+ }
1938
2116
  .wcb-row {
1939
2117
  display: flex; align-items: center; gap: 12px;
1940
2118
  padding: 9px 12px; border-top: .5px solid var(--wcb-line); cursor: pointer;
@@ -2055,17 +2233,53 @@ window.__ModuleLoader__.load({
2055
2233
  border: .5px solid var(--wcb-line-2);
2056
2234
  }
2057
2235
 
2058
- /* One member, one line: badge, name, the Session's facts, its 归档 action. */
2059
- .wcb-member-row {
2060
- display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap;
2061
- padding: 6px 8px; border-radius: 8px;
2062
- }
2236
+ /* Native table semantics keep every member's facts aligned under one header.
2237
+ Narrow surfaces scroll the table rather than wrapping unrelated columns.
2238
+ Every column is centred: the row is a set of short facts, not prose. */
2239
+ .wcb-members-scroll { overflow-x: auto; border: .5px solid var(--wcb-line); border-radius: 10px; }
2240
+ .wcb-members-scroll:focus-visible { outline: 2px solid var(--wcb-brand); outline-offset: 2px; }
2241
+ .wcb-members-table { width: 100%; min-width: 860px; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
2242
+ .wcb-members-table th, .wcb-members-table td { padding: 9px 10px; text-align: center; vertical-align: middle; white-space: nowrap; }
2243
+ .wcb-members-table th { color: var(--wcb-text-3); background: var(--wcb-surface-2); font-weight: 500; font-size: 11.5px; }
2244
+ .wcb-members-table td { border-top: .5px solid var(--wcb-line); color: var(--wcb-text-2); }
2245
+ /* Fixed widths keep a long model name from squeezing every other column. */
2246
+ .wcb-members-table th:nth-child(1) { width: 18%; }
2247
+ .wcb-members-table th:nth-child(2) { width: 88px; }
2248
+ .wcb-members-table th:nth-child(3) { width: 70px; }
2249
+ .wcb-members-table th:nth-child(4) { width: 195px; }
2250
+ .wcb-members-table th:nth-child(5) { width: 86px; }
2251
+ .wcb-members-table th:nth-child(6) { width: 160px; }
2252
+ .wcb-members-table th:nth-child(7) { width: 112px; }
2063
2253
  .wcb-member-row:hover { background: var(--wcb-hover); }
2064
- .wcb-member-name {
2065
- font-weight: 500; white-space: nowrap; overflow: hidden;
2066
- text-overflow: ellipsis; max-width: 140px;
2067
- }
2068
- .wcb-member-facts { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-width: 0; flex: 1; }
2254
+ .wcb-member-identity { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
2255
+ .wcb-member-name { color: var(--wcb-text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
2256
+
2257
+ /* One convention for every interactive cell: it looks like a control, not like
2258
+ plain text. The Session identity is a pill, the model/effort are selects. */
2259
+ .wcb-cell-pill {
2260
+ display: inline-flex; align-items: center; gap: 6px;
2261
+ height: 26px; padding: 0 9px 0 10px;
2262
+ border: .5px solid color-mix(in srgb, var(--wcb-brand) 35%, transparent);
2263
+ border-radius: 999px;
2264
+ background: color-mix(in srgb, var(--wcb-brand) 7%, transparent);
2265
+ color: var(--wcb-brand); font: inherit; font-size: 12px; font-weight: 550;
2266
+ cursor: pointer; transition: background .12s ease, border-color .12s ease;
2267
+ }
2268
+ .wcb-cell-pill:hover:not(:disabled) {
2269
+ background: color-mix(in srgb, var(--wcb-brand) 15%, transparent);
2270
+ border-color: color-mix(in srgb, var(--wcb-brand) 55%, transparent);
2271
+ }
2272
+ .wcb-cell-pill:active:not(:disabled) { background: color-mix(in srgb, var(--wcb-brand) 20%, transparent); }
2273
+ .wcb-cell-pill:focus-visible { outline: 2px solid var(--wcb-brand); outline-offset: 2px; }
2274
+ .wcb-cell-pill:disabled { cursor: default; opacity: .55; }
2275
+ .wcb-cell-pill-chevron { display: inline-flex; color: color-mix(in srgb, var(--wcb-brand) 70%, transparent); }
2276
+ .wcb-members-table .wcb-cell-select {
2277
+ display: block; width: 100%; max-width: 220px; margin: 0 auto;
2278
+ min-width: 0; height: 28px; font-size: 12px; text-align: center;
2279
+ }
2280
+ .wcb-members-table .wcb-context-cell { font-variant-numeric: tabular-nums; }
2281
+ .wcb-member-error td { white-space: normal; text-align: center !important; }
2282
+ .wcb-member-error .wcb-field-error { margin-top: 0; display: inline-block; max-width: 640px; text-align: left; }
2069
2283
  .wcb-fact-inline {
2070
2284
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
2071
2285
  color: var(--wcb-text-2); font-size: 12px;
@@ -2135,10 +2349,17 @@ window.__ModuleLoader__.load({
2135
2349
  const forms = ctx.get("configForms");
2136
2350
  const remote = ctx.get("remote");
2137
2351
  if (!slots || !forms) return;
2352
+ const openSession = (sessionId) => {
2353
+ const navigation = ctx.get("uiWorkspace");
2354
+ if (!navigation || typeof navigation.openSession !== "function") {
2355
+ throw new Error("DSH 会话导航暂不可用,请刷新页面后重试。");
2356
+ }
2357
+ navigation.openSession(sessionId);
2358
+ };
2138
2359
  ctx.effect(() => insertStyles(), "wecom-bot: styles");
2139
2360
  ctx.effect(() => forms.whileServed([CONFIG_NAMESPACE], () => slots.inject("plugins.bundle.config", () => slots.register(
2140
2361
  { name: "plugins.bundle.config", key: PACKAGE_NAME },
2141
- ({ view }) => view === "page" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsPage, { scope: forms.get(CONFIG_NAMESPACE), remote }) : null
2362
+ ({ view }) => view === "page" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SettingsPage, { scope: forms.get(CONFIG_NAMESPACE), remote, onOpenSession: openSession }) : null
2142
2363
  ))), "wecom-bot: plugin homepage");
2143
2364
  }
2144
2365