dsh-wecom-bot 0.5.0 → 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 (39) hide show
  1. package/README.md +41 -22
  2. package/dist/client.js +486 -281
  3. package/dist/host/bridge/commands.js +62 -17
  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 +113 -51
  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 +70 -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/groups-view.js +369 -156
  22. package/dist/host/groups-view.js.map +1 -1
  23. package/dist/host/interaction-transport.js +170 -0
  24. package/dist/host/interaction-transport.js.map +1 -0
  25. package/dist/host/journal.js +10 -3
  26. package/dist/host/journal.js.map +1 -1
  27. package/dist/host/routes.js +3 -0
  28. package/dist/host/routes.js.map +1 -1
  29. package/dist/host/routing.js +25 -12
  30. package/dist/host/routing.js.map +1 -1
  31. package/dist/host/runtime.js +81 -18
  32. package/dist/host/runtime.js.map +1 -1
  33. package/dist/host/sessions.js +33 -6
  34. package/dist/host/sessions.js.map +1 -1
  35. package/dist/host/store.js +107 -19
  36. package/dist/host/store.js.map +1 -1
  37. package/dist/host/turns.js +5 -0
  38. package/dist/host/turns.js.map +1 -1
  39. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -36,15 +36,12 @@ window.__ModuleLoader__.load({
36
36
  var DEFAULT_SECRET_REF = "WECOM_BOT_SECRET";
37
37
  var STATE_ROUTE = "/api/wecom-bot/state";
38
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
39
  var MIN_LOG_RETENTION_DAYS = 1;
43
40
  var MAX_LOG_RETENTION_DAYS = 365;
44
41
  var DEFAULT_LOG_RETENTION_DAYS = 14;
45
42
 
46
43
  // src/client/components/SettingsPage.tsx
47
- var import_react7 = require("react");
44
+ var import_react8 = require("react");
48
45
 
49
46
  // src/client/hooks.ts
50
47
  var import_react = require("react");
@@ -148,9 +145,6 @@ window.__ModuleLoader__.load({
148
145
  errors.wsUrl = "不是有效的 URL。";
149
146
  }
150
147
  }
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
148
  if (!Number.isInteger(draft.logRetentionDays) || draft.logRetentionDays < MIN_LOG_RETENTION_DAYS || draft.logRetentionDays > MAX_LOG_RETENTION_DAYS) {
155
149
  errors.logRetentionDays = `请输入 ${MIN_LOG_RETENTION_DAYS}–${MAX_LOG_RETENTION_DAYS} 的整数天数。`;
156
150
  }
@@ -158,8 +152,6 @@ window.__ModuleLoader__.load({
158
152
  }
159
153
  function advancedSlice(settings) {
160
154
  return {
161
- remoteApprovals: settings?.remoteApprovals ?? false,
162
- questionTimeoutMs: settings?.questionTimeoutMs ?? DEFAULT_QUESTION_TIMEOUT_MS,
163
155
  wsUrl: settings?.wsUrl ?? "",
164
156
  logEnabled: settings?.logEnabled ?? true,
165
157
  logRetentionDays: settings?.logRetentionDays ?? DEFAULT_LOG_RETENTION_DAYS
@@ -167,8 +159,6 @@ window.__ModuleLoader__.load({
167
159
  }
168
160
  function settingsPatch(draft, stored) {
169
161
  const patch = {};
170
- if (draft.remoteApprovals !== stored.remoteApprovals) patch.remoteApprovals = draft.remoteApprovals;
171
- if (draft.questionTimeoutMs !== stored.questionTimeoutMs) patch.questionTimeoutMs = draft.questionTimeoutMs;
172
162
  if (draft.wsUrl.trim() !== stored.wsUrl.trim()) patch.wsUrl = draft.wsUrl.trim();
173
163
  if (draft.logEnabled !== stored.logEnabled) patch.logEnabled = draft.logEnabled;
174
164
  if (draft.logRetentionDays !== stored.logRetentionDays) patch.logRetentionDays = draft.logRetentionDays;
@@ -204,11 +194,6 @@ window.__ModuleLoader__.load({
204
194
  const choice = catalog?.choices.find((item) => item.provider === provider && item.model === model);
205
195
  return choice?.efforts ?? [];
206
196
  }
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
197
  function modelName(catalog, selection) {
213
198
  if (!selection) return "";
214
199
  const choice = catalog?.choices.find((item) => item.provider === selection.provider && item.model === selection.model);
@@ -259,7 +244,6 @@ window.__ModuleLoader__.load({
259
244
  if (!value) return "跟随 DSH 默认模型";
260
245
  return `跟随 DSH 默认模型(${modelName(catalog, value)})`;
261
246
  }
262
- var BINDING_KIND_LABEL = { user: "个人", group: "群聊" };
263
247
  var SESSION_STATE_LABEL = {
264
248
  bound: "已绑定",
265
249
  auto: "待创建",
@@ -314,6 +298,9 @@ window.__ModuleLoader__.load({
314
298
  function removeMember(key) {
315
299
  return { op: "member.remove", key };
316
300
  }
301
+ function setMemberModel(key, sessionId, selection) {
302
+ return { op: "member.model", key, sessionId, selection };
303
+ }
317
304
  function archiveMember(key) {
318
305
  return { op: "member.archive", key };
319
306
  }
@@ -478,10 +465,11 @@ window.__ModuleLoader__.load({
478
465
  }
479
466
 
480
467
  // src/client/components/AdminCard.tsx
481
- var import_react2 = require("react");
468
+ var import_react3 = require("react");
482
469
  var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
483
470
 
484
471
  // src/client/components/ui.tsx
472
+ var import_react2 = require("react");
485
473
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
486
474
  var import_jsx_runtime = require("react/jsx-runtime");
487
475
  function Select({ className, ...rest }) {
@@ -503,13 +491,21 @@ window.__ModuleLoader__.load({
503
491
  aside && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "wcb-card-aside", children: aside })
504
492
  ] });
505
493
  }
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: [
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: [
508
498
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-group-head", children: [
509
499
  /* @__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 })
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)) })
513
509
  ] }),
514
510
  actions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-group-actions", children: actions })
515
511
  ] }),
@@ -592,7 +588,7 @@ window.__ModuleLoader__.load({
592
588
  contentClassName: "wcb-modal-content",
593
589
  children: [
594
590
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-person-facts", children: [
595
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
591
+ typeLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "类型", children: typeLabel }),
596
592
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, { name: "企微 ID", mono: true, children: id }),
597
593
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-fact", children: [
598
594
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "wcb-fact-key", children: "备注" }),
@@ -623,6 +619,44 @@ window.__ModuleLoader__.load({
623
619
  }
624
620
  );
625
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
+ }
626
660
  function SaveBar({ dirty, saving, saved, error, disabled, onSave, onDiscard }) {
627
661
  if (!dirty && !saved && !error) return null;
628
662
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wcb-savebar", children: [
@@ -656,18 +690,19 @@ window.__ModuleLoader__.load({
656
690
  function AdminCard({ state, disabled, onChanged }) {
657
691
  const storedIds = state?.settings?.adminUserIds ?? [];
658
692
  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);
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);
663
697
  const save = useStoreSettingsSave(onChanged);
664
698
  const routing = useStoreApply(onChanged);
665
699
  const admins = state?.admins ?? [];
700
+ const groups = state?.routing?.groups ?? [];
666
701
  const workspaces = state?.workspaces ?? [];
667
702
  const all = draft.adminWorkspaces.length === 0;
668
703
  const busy = disabled || save.saving;
669
704
  const storedKey = `${storedIds.join("\0")}${storedScope.join("\0")}`;
670
- (0, import_react2.useEffect)(() => {
705
+ (0, import_react3.useEffect)(() => {
671
706
  setDraft({ adminUserIds: [...storedIds], adminWorkspaces: [...storedScope] });
672
707
  }, [storedKey]);
673
708
  const apply2 = async (patch) => {
@@ -677,7 +712,7 @@ window.__ModuleLoader__.load({
677
712
  }
678
713
  };
679
714
  const known = new Map(admins.map((admin) => [admin.id, admin]));
680
- const candidates = (0, import_react2.useMemo)(() => {
715
+ const candidates = (0, import_react3.useMemo)(() => {
681
716
  const rows = /* @__PURE__ */ new Map();
682
717
  for (const sender of state?.rejected ?? []) {
683
718
  if (sender.kind !== "user") continue;
@@ -744,7 +779,9 @@ window.__ModuleLoader__.load({
744
779
  id,
745
780
  label: known.get(id)?.label ?? "",
746
781
  groupName: known.get(id)?.groupName,
782
+ groups,
747
783
  disabled: busy || routing.busy === personKey("user", id),
784
+ onAssign: (groupId) => routing.apply(personKey("user", id), [addMember(groupId, "user", id)]),
748
785
  onNote: (next) => {
749
786
  void routing.apply(personKey("user", id), [setLabel(personKey("user", id), next)]);
750
787
  },
@@ -764,7 +801,7 @@ window.__ModuleLoader__.load({
764
801
  " 可接收通知的 Workspace"
765
802
  ] }),
766
803
  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: () => {
804
+ actions: all ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => {
768
805
  void apply2({ adminWorkspaces: [] });
769
806
  }, children: "全选" }),
770
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: [
@@ -847,8 +884,9 @@ window.__ModuleLoader__.load({
847
884
  }
848
885
  );
849
886
  }
850
- function AdminRow({ id, label, groupName, disabled, onNote, onRemove }) {
851
- 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);
852
890
  const name = label || id;
853
891
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "wcb-member", children: [
854
892
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -861,10 +899,51 @@ window.__ModuleLoader__.load({
861
899
  onOpen: () => setDetails(true),
862
900
  meta: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
863
901
  /* @__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}` : "不在任何分组" })
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
+ )
865
917
  ] })
866
918
  }
867
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
+ ] }),
868
947
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
869
948
  PersonDialog,
870
949
  {
@@ -880,7 +959,7 @@ window.__ModuleLoader__.load({
880
959
  footer: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
881
960
  import_dsh_client_ui_primitives2.Button,
882
961
  {
883
- variant: "ghost",
962
+ variant: "outline",
884
963
  size: "sm",
885
964
  icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconTrashOutlineRegular, {}),
886
965
  disabled,
@@ -902,20 +981,20 @@ window.__ModuleLoader__.load({
902
981
  }
903
982
 
904
983
  // src/client/components/AdvancedCard.tsx
905
- var import_react3 = require("react");
984
+ var import_react4 = require("react");
906
985
  var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
907
986
  var import_jsx_runtime3 = require("react/jsx-runtime");
908
987
  function AdvancedCard({ settings, journal, disabled, onChanged }) {
909
988
  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);
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);
913
992
  const save = useStoreSettingsSave(onChanged);
914
993
  const patch = settingsPatch(draft, stored);
915
994
  const dirty = Object.keys(patch).length > 0;
916
995
  const errors = attempted ? validateAdvanced(draft) : {};
917
996
  const storedKey = JSON.stringify(stored);
918
- (0, import_react3.useEffect)(() => {
997
+ (0, import_react4.useEffect)(() => {
919
998
  setDraft(advancedSlice(settings));
920
999
  }, [storedKey]);
921
1000
  const copy = async () => {
@@ -928,52 +1007,11 @@ window.__ModuleLoader__.load({
928
1007
  CardHead,
929
1008
  {
930
1009
  step: 5,
931
- title: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
932
- "高级设置 ",
933
- draft.remoteApprovals && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.Tag, { tone: "warning", children: "远程审批已开启" })
934
- ] }),
935
- description: "远程审批、等待时间、自定义连接地址与对话日志。均可保持默认。",
1010
+ title: "连接与日志",
1011
+ description: "私有化部署的 WebSocket 地址,以及对话日志的开关、保留天数与目录。",
936
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 }) })
937
1013
  }
938
1014
  ) }),
939
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
940
- Field,
941
- {
942
- label: "远程审批工具调用",
943
- hint: "开启后,DSH 请求执行工具时会通知所有管理员,管理员在单聊里回复 /approve 或 /deny 即生效;群聊永远不能审批。关闭时只通知,审批仍需到 DSH 页面完成。",
944
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
945
- import_dsh_client_ui_primitives3.Switch,
946
- {
947
- checked: draft.remoteApprovals,
948
- disabled,
949
- label: "远程审批工具调用",
950
- onChange: (next) => setDraft((current) => ({ ...current, remoteApprovals: next }))
951
- }
952
- )
953
- }
954
- ),
955
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
956
- Field,
957
- {
958
- label: "等待企微回复(秒)",
959
- error: errors.questionTimeoutMs,
960
- hint: "DSH 提问或审批时,先等待企业微信回复的时间;超时后回到 DSH 页面处理。",
961
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
962
- import_dsh_client_ui_primitives3.Input,
963
- {
964
- className: "wcb-number",
965
- type: "number",
966
- min: 1,
967
- max: 300,
968
- step: 1,
969
- value: Math.round(draft.questionTimeoutMs / 1e3),
970
- disabled,
971
- "aria-label": "等待企微回复的秒数",
972
- onChange: (event) => setDraft((current) => ({ ...current, questionTimeoutMs: Number(event.target.value) * 1e3 }))
973
- }
974
- )
975
- }
976
- ),
977
1015
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
978
1016
  Field,
979
1017
  {
@@ -1042,7 +1080,7 @@ window.__ModuleLoader__.load({
1042
1080
  errors.logRetentionDays && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-field-error", children: errors.logRetentionDays }),
1043
1081
  journal?.directory && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "wcb-field-row", style: { marginTop: 10 }, children: [
1044
1082
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "wcb-path wcb-grow", title: journal.file, children: journal.directory }),
1045
- /* @__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: () => {
1046
1084
  void copy();
1047
1085
  }, children: copied ? "已复制" : "复制路径" })
1048
1086
  ] })
@@ -1071,21 +1109,21 @@ window.__ModuleLoader__.load({
1071
1109
  }
1072
1110
 
1073
1111
  // src/client/components/CredentialsCard.tsx
1074
- var import_react4 = require("react");
1112
+ var import_react5 = require("react");
1075
1113
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
1076
1114
  var import_jsx_runtime4 = require("react/jsx-runtime");
1077
1115
  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);
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);
1083
1121
  const save = useConfigSave(scope, onChanged);
1084
1122
  const status = useSecretStatus(remote, base.secretEnv);
1085
1123
  const ready = Boolean(botId.trim()) && (status.configured || Boolean(secret.trim()));
1086
1124
  const dirty = botId.trim() !== base.botId || Boolean(secret.trim());
1087
1125
  const errors = attempted ? validateCredentials({ botId, secret }, status.configured) : {};
1088
- (0, import_react4.useEffect)(() => {
1126
+ (0, import_react5.useEffect)(() => {
1089
1127
  setBotId(base.botId);
1090
1128
  }, [base.botId]);
1091
1129
  async function onSave() {
@@ -1150,7 +1188,7 @@ window.__ModuleLoader__.load({
1150
1188
  onChange: (event) => setSecret(event.target.value)
1151
1189
  }
1152
1190
  ),
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 ? "隐藏" : "显示" }),
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 ? "隐藏" : "显示" }),
1154
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: "未设置" })
1155
1193
  ] })
1156
1194
  }
@@ -1180,14 +1218,14 @@ window.__ModuleLoader__.load({
1180
1218
  }
1181
1219
 
1182
1220
  // src/client/components/GroupsCard.tsx
1183
- var import_react5 = require("react");
1221
+ var import_react6 = require("react");
1184
1222
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
1185
1223
  var import_jsx_runtime5 = require("react/jsx-runtime");
1186
- function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged }) {
1224
+ function GroupsCard({ state, error, disabled, refreshing, onRefresh, onChanged, onOpenSession }) {
1187
1225
  const { busy, error: applyError, apply: apply2 } = useStoreApply(onChanged);
1188
- const [freshId, setFreshId] = (0, import_react5.useState)();
1226
+ const [freshId, setFreshId] = (0, import_react6.useState)();
1189
1227
  const view = state?.routing;
1190
- (0, import_react5.useEffect)(() => {
1228
+ (0, import_react6.useEffect)(() => {
1191
1229
  if (freshId && view?.groups.some((group) => group.id === freshId)) setFreshId(void 0);
1192
1230
  }, [freshId, view]);
1193
1231
  const add = async () => {
@@ -1207,7 +1245,7 @@ window.__ModuleLoader__.load({
1207
1245
  children: [
1208
1246
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-toolbar", children: [
1209
1247
  /* @__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 ? "刷新中" : "刷新" }),
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 ? "刷新中" : "刷新" }),
1211
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: () => {
1212
1250
  void add();
1213
1251
  }, children: "添加分组" })
@@ -1220,7 +1258,9 @@ window.__ModuleLoader__.load({
1220
1258
  state,
1221
1259
  startEditing: group.id === freshId,
1222
1260
  disabled: disabled || busy.startsWith(`group:${group.id}`),
1223
- onApply: apply2
1261
+ onApply: apply2,
1262
+ onChanged,
1263
+ onOpenSession
1224
1264
  },
1225
1265
  group.id
1226
1266
  )) })
@@ -1253,11 +1293,11 @@ window.__ModuleLoader__.load({
1253
1293
  if (draft.preset !== group.preset) patch.preset = draft.preset;
1254
1294
  return patch;
1255
1295
  }
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);
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);
1261
1301
  const catalog = state?.models;
1262
1302
  const presets = state?.presets;
1263
1303
  const workspaces = state?.workspaces ?? [];
@@ -1267,29 +1307,14 @@ window.__ModuleLoader__.load({
1267
1307
  model: group.effectiveModel,
1268
1308
  reasoningEffort: group.reasoningEffort
1269
1309
  }) || 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
- " 位成员"
1274
- ] }),
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)
1290
- ] })
1291
- ] });
1292
- (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)(() => {
1293
1318
  if (!editing) setDraft(draftOf(group));
1294
1319
  }, [group, editing]);
1295
1320
  const efforts = effortsFor(catalog, draft.provider || group.effectiveProvider, draft.model || group.effectiveModel);
@@ -1317,7 +1342,7 @@ window.__ModuleLoader__.load({
1317
1342
  group.name,
1318
1343
  group.isDefault && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: "quiet", children: "默认" })
1319
1344
  ] }),
1320
- summary,
1345
+ facts,
1321
1346
  actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1322
1347
  editing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1323
1348
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => {
@@ -1327,13 +1352,13 @@ window.__ModuleLoader__.load({
1327
1352
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "primary", size: "sm", disabled, onClick: () => {
1328
1353
  void save();
1329
1354
  }, 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: "编辑" }),
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: "编辑" }),
1331
1356
  !group.isDefault && (confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1332
1357
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1333
1358
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1334
1359
  import_dsh_client_ui_primitives5.Button,
1335
1360
  {
1336
- variant: "ghost",
1361
+ variant: "outline",
1337
1362
  size: "sm",
1338
1363
  icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1339
1364
  disabled,
@@ -1343,7 +1368,7 @@ window.__ModuleLoader__.load({
1343
1368
  children: "确认删除"
1344
1369
  }
1345
1370
  )
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: "删除分组" }))
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: "删除分组" }))
1347
1372
  ] }),
1348
1373
  children: [
1349
1374
  editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "wcb-binding-controls", children: [
@@ -1452,151 +1477,268 @@ window.__ModuleLoader__.load({
1452
1477
  !presets?.presets.length && `没有读到 DSH 的 preset 列表${state?.presetsError ? `:${state.presetsError}` : "(这个部署没有挂载 preset registry)"}。`
1453
1478
  ] }),
1454
1479
  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
- )) })
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
+ ] }) })
1468
1497
  ]
1469
1498
  }
1470
1499
  );
1471
1500
  }
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);
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);
1475
1509
  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);
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");
1479
1513
  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 || "—"
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
+ )
1502
1606
  ] }),
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) || "—"
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
+ )
1506
1729
  ] })
1507
1730
  ] }),
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,
1521
- {
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)]);
1532
- },
1533
- footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RemoveMember, { member, disabled, onApply }),
1534
- children: [
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
- )
1570
- ] })
1571
- ]
1572
- }
1573
- ),
1574
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1575
- ConfirmDialog,
1576
- {
1577
- open: archiving,
1578
- title: `归档「${name}」的会话?`,
1579
- confirmLabel: "确认归档",
1580
- disabled,
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
- )
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 }) }) })
1590
1732
  ] });
1591
1733
  }
1592
1734
  function RemoveMember({ member, disabled, onApply }) {
1593
- const [confirming, setConfirming] = (0, import_react5.useState)(false);
1735
+ const [confirming, setConfirming] = (0, import_react6.useState)(false);
1594
1736
  return confirming ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1595
1737
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.Button, { variant: "ghost", size: "sm", disabled, onClick: () => setConfirming(false), children: "取消" }),
1596
1738
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1597
1739
  import_dsh_client_ui_primitives5.Button,
1598
1740
  {
1599
- variant: "ghost",
1741
+ variant: "outline",
1600
1742
  size: "sm",
1601
1743
  icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives5.IconTrashOutlineRegular, {}),
1602
1744
  disabled,
@@ -1610,11 +1752,11 @@ window.__ModuleLoader__.load({
1610
1752
  ]
1611
1753
  }
1612
1754
  )
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: "移出分组" });
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: "移出分组" });
1614
1756
  }
1615
1757
 
1616
1758
  // src/client/components/RejectedCard.tsx
1617
- var import_react6 = require("react");
1759
+ var import_react7 = require("react");
1618
1760
  var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
1619
1761
  var import_jsx_runtime6 = require("react/jsx-runtime");
1620
1762
  function RejectedCard({ state, disabled, onChanged }) {
@@ -1635,11 +1777,11 @@ window.__ModuleLoader__.load({
1635
1777
  );
1636
1778
  }
1637
1779
  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)();
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)();
1643
1785
  async function authorize() {
1644
1786
  if (!groupId) {
1645
1787
  setError("还没有可用的分组。");
@@ -1761,15 +1903,15 @@ window.__ModuleLoader__.load({
1761
1903
 
1762
1904
  // src/client/components/SettingsPage.tsx
1763
1905
  var import_jsx_runtime8 = require("react/jsx-runtime");
1764
- function SettingsPage({ scope, remote }) {
1906
+ function SettingsPage({ scope, remote, onOpenSession }) {
1765
1907
  const snapshot = useFormSnapshot(scope);
1766
1908
  if (snapshot.status !== "ready") {
1767
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" ? "正在加载插件配置…" : "插件配置暂不可用:请确认插件已启用。" }) });
1768
1910
  }
1769
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote });
1911
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsEditor, { snapshot, scope, remote, onOpenSession });
1770
1912
  }
1771
- function SettingsEditor({ snapshot, scope, remote }) {
1772
- 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]);
1773
1915
  const bridge = useBridgeState();
1774
1916
  const writable = snapshot.writable !== false;
1775
1917
  const state = bridge.data;
@@ -1786,7 +1928,8 @@ window.__ModuleLoader__.load({
1786
1928
  disabled: !writable,
1787
1929
  refreshing: bridge.refreshing,
1788
1930
  onRefresh: () => bridge.refresh(true),
1789
- onChanged
1931
+ onChanged,
1932
+ onOpenSession
1790
1933
  }
1791
1934
  ),
1792
1935
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RejectedCard, { state, disabled: !writable, onChanged }),
@@ -1944,6 +2087,7 @@ window.__ModuleLoader__.load({
1944
2087
  .wcb-chevron { flex: none; color: var(--wcb-text-3); transition: transform .15s ease; }
1945
2088
  .wcb-group[data-open] .wcb-chevron { transform: rotate(90deg); }
1946
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; }
1947
2091
  .wcb-group-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
1948
2092
  /* The group overview: labelled facts that wrap instead of hiding behind an ellipsis. */
1949
2093
  .wcb-group-summary {
@@ -1951,6 +2095,24 @@ window.__ModuleLoader__.load({
1951
2095
  gap: 2px 10px; color: var(--wcb-text-3); font-size: 12px; text-align: right;
1952
2096
  }
1953
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
+ }
1954
2116
  .wcb-row {
1955
2117
  display: flex; align-items: center; gap: 12px;
1956
2118
  padding: 9px 12px; border-top: .5px solid var(--wcb-line); cursor: pointer;
@@ -2071,17 +2233,53 @@ window.__ModuleLoader__.load({
2071
2233
  border: .5px solid var(--wcb-line-2);
2072
2234
  }
2073
2235
 
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
- }
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; }
2079
2253
  .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; }
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; }
2085
2283
  .wcb-fact-inline {
2086
2284
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
2087
2285
  color: var(--wcb-text-2); font-size: 12px;
@@ -2151,10 +2349,17 @@ window.__ModuleLoader__.load({
2151
2349
  const forms = ctx.get("configForms");
2152
2350
  const remote = ctx.get("remote");
2153
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
+ };
2154
2359
  ctx.effect(() => insertStyles(), "wecom-bot: styles");
2155
2360
  ctx.effect(() => forms.whileServed([CONFIG_NAMESPACE], () => slots.inject("plugins.bundle.config", () => slots.register(
2156
2361
  { name: "plugins.bundle.config", key: PACKAGE_NAME },
2157
- ({ 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
2158
2363
  ))), "wecom-bot: plugin homepage");
2159
2364
  }
2160
2365