@wfm-cn/dsh-mcp-connectors 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client.js +24 -8
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -68,7 +68,8 @@ window.__ModuleLoader__.load({
68
68
  presetCustom: '自定义 / 其他 MCP 服务',
69
69
  composerOpen: '连接器',
70
70
  composerNone: '当前会话未启用任何连接器',
71
- composerAll: '全部',
71
+ selectAll: '全选',
72
+ deselectAll: '全部取消',
72
73
  loadFailed: '加载失败',
73
74
  retry: '重试',
74
75
  hint: '工具将以 mcp__<标识>__<工具名> 出现在会话中。',
@@ -125,7 +126,8 @@ window.__ModuleLoader__.load({
125
126
  presetCustom: 'Custom MCP server',
126
127
  composerOpen: 'Connectors',
127
128
  composerNone: 'No connector enabled in this conversation',
128
- composerAll: 'All',
129
+ selectAll: 'Select all',
130
+ deselectAll: 'Deselect all',
129
131
  loadFailed: 'Failed to load',
130
132
  retry: 'Retry',
131
133
  hint: 'Tools appear as mcp__<server>__<tool> in conversations.',
@@ -631,12 +633,26 @@ window.__ModuleLoader__.load({
631
633
  const next = new Set(chosen);
632
634
  if (next.has(sn)) next.delete(sn); else next.add(sn);
633
635
  const r = await api.setSession({ sessionId, enabled: [...next] });
634
- if (r.ok) setData((d) => ({ ...d, sessions: { ...(d?.sessions ?? {}), [sessionId]: [...next] } }));
636
+ if (r.ok) applySession(next);
635
637
  };
636
- const selectAll = async () => {
637
- if (!api) return;
638
- const r = await api.setSession({ sessionId, enabled: enabledConnectors.map((c) => c.serverName) });
639
- if (r.ok) setData((d) => ({ ...d, sessions: { ...(d?.sessions ?? {}), [sessionId]: [] } }));
638
+ /** 与后端 POST /session 的落盘规则保持镜像:全选时删除会话记录(=默认全启用),否则保存列表 */
639
+ const applySession = (nextSet) => {
640
+ setData((d) => {
641
+ const sessions = { ...(d?.sessions ?? {}) };
642
+ const allOn = enabledConnectors.length > 0
643
+ && enabledConnectors.every((c) => nextSet.has(c.serverName));
644
+ if (allOn) delete sessions[sessionId];
645
+ else sessions[sessionId] = [...nextSet];
646
+ return { ...d, sessions };
647
+ });
648
+ };
649
+ const allOn = Boolean(chosen) && enabledConnectors.length > 0
650
+ && enabledConnectors.every((c) => chosen.has(c.serverName));
651
+ const toggleAll = async () => {
652
+ if (!sessionId || !api || !chosen) return;
653
+ const next = allOn ? new Set() : new Set(enabledConnectors.map((c) => c.serverName));
654
+ const r = await api.setSession({ sessionId, enabled: [...next] });
655
+ if (r.ok) applySession(next);
640
656
  };
641
657
 
642
658
  return h('div', { className: 'mcx-composer', ref: wrapRef },
@@ -652,7 +668,7 @@ window.__ModuleLoader__.load({
652
668
  : h(React.Fragment, null,
653
669
  h('div', { className: 'mcx-popover-head' },
654
670
  h('span', null, t('composerOpen')),
655
- h('button', { type: 'button', className: 'mcx-chipbtn', onClick: selectAll }, t('composerAll'))),
671
+ h('button', { type: 'button', className: 'mcx-chipbtn', onClick: toggleAll }, t(allOn ? 'deselectAll' : 'selectAll'))),
656
672
  enabledConnectors.map((c) => h('label', { key: c.id, className: 'mcx-popover-row' },
657
673
  h('input', {
658
674
  type: 'checkbox',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wfm-cn/dsh-mcp-connectors",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",