dsh-magpie-connect 0.3.4 → 0.3.6

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-magpie-connect
2
2
 
3
- 把 Magpie 局域网网关上的模型接进 DeepSeek Harness(DSH)的模型选择器。
3
+ 把 Magpie 网关上的模型接进 DeepSeek Harness(DSH)的模型选择器。
4
4
 
5
5
  装好之后,你就能在 DSH 里直接选用网关提供的模型,不需要额外跑进程,也不用配代理。
6
6
 
@@ -24,7 +24,7 @@ dsh plugin --profile web add dsh-magpie-connect
24
24
 
25
25
  已有安装用同一条命令即可更新到最新版本。
26
26
 
27
- **需要**:DSH 的 web profile、Node.js ≥ 20、能访问网关所在局域网。
27
+ **需要**:DSH 的 web profile、Node.js ≥ 20、能访问网关。
28
28
 
29
29
  ## 使用
30
30
 
@@ -46,8 +46,22 @@ dsh plugin --profile web add dsh-magpie-connect
46
46
  点 **获取可用模型**,会弹出网关当前的模型列表:勾选你想要的,再点「应用选择」。
47
47
  弹窗里可以搜索、全选、取消全选。
48
48
 
49
- 主列表只显示已启用的模型。不想要的点该行末尾的「删除」,它就会从选择器里消失;
50
- 想加回来,再回到弹窗里勾选。
49
+ 模型列表是**白名单**,和 DSH 自带的「模型」设置语义一致:列表里有什么,选择器就提供
50
+ 什么。不想要的点该行末尾的「删除」,它就从列表和选择器里一起消失;想加回来,点
51
+ 「获取可用模型」,在弹窗里勾上它再「应用选择」。
52
+
53
+ **新增的模型不会自己出现**:网关新上架的模型要你在弹窗里勾选并应用后才会进入列表。
54
+ 这是白名单的代价,也是它的好处——网关某条 lane 抖动(临时掉线又恢复)不会把你删掉的
55
+ 模型偷偷放回来。
56
+
57
+ **「恢复默认模型」**:清掉自定义列表,回到「直接使用网关的完整目录」。列表为空
58
+ (`[]`)和继承网关目录是两种不同状态:前者一个模型都不提供,后者全提供。
59
+
60
+ **「获取可用模型」会同步本地目录**:弹窗拿到的就是网关此刻的完整目录,读取成功后本地
61
+ 目录整体替换成它,所以网关已下架的模型会同时从弹窗和列表消失;读取失败(地址错、
62
+ Key 无效、网关不通)不会清空本地目录,避免把选择器误清成空。
63
+
64
+ > 行末的 `内置快照` 标签说明这条来自插件的兜底快照(网关暂时不可达时),不是网关当前列表。
51
65
 
52
66
  > 弹窗查的是**你当前填的地址和 Key**(哪怕还没保存),所以换网关是一趟的事。
53
67
  > 连不上也不会卡住——失败原因会显示在列表下方,已列出的行仍然可以操作。
@@ -66,7 +80,29 @@ dsh plugin --profile web add dsh-magpie-connect
66
80
 
67
81
  **删掉的模型怎么加回来?**
68
82
 
69
- 点「获取可用模型」,在弹窗里重新勾上,再点「应用选择」。
83
+ 点「获取可用模型」,在弹窗里勾上它再「应用选择」。弹窗列出的是网关当前提供的全部
84
+ 模型,勾选会**替换**整份列表——只想保留某几个,就只勾那几个。
85
+
86
+ **网关新加了模型,为什么列表里没有?**
87
+
88
+ 白名单语义:新模型需要你在「获取可用模型」里勾选并应用后才会出现。
89
+
90
+ **从旧版本升级,我原来的删除记录还在吗?**
91
+
92
+ 在。首次启动会自动把旧的 `hiddenModels`(黑名单)换算成 `enabledModels`(白名单),
93
+ 并写回 `~/.dsh-magpie-connect/settings.json`,只执行一次。若升级时网关不可达、
94
+ 算不出旧列表,则退回「继承网关目录」,不会误删你能用的模型。
95
+
96
+ **为什么我删掉的模型又出现了?**
97
+
98
+ 不应该再出现:删除记录会原样保存(网关某轮没列出它也不会被忘掉),而「获取可用模型」
99
+ 只改动它这次列出的模型。如果你在**旧版本**上删过模型,那份删除记录可能已被旧逻辑丢掉,
100
+ 升级后重新删一次即可。
101
+
102
+ **网关下架了某个模型,列表里为什么还显示?**
103
+
104
+ 现在不会了:点一次「获取可用模型」,本地目录就会同步成网关当前目录,下架的模型随之消失。
105
+ 如果它仍显示,说明本地目录还停在旧快照上——看列表下方是否报了网关错误。
70
106
 
71
107
  **改了网关地址,模型列表没变?**
72
108
 
@@ -94,7 +130,7 @@ dsh plugin --profile web add dsh-magpie-connect
94
130
  providerId: dsh-magpie-connect
95
131
  displayName: Magpie
96
132
  baseUrl: http://127.0.0.1:3425/v1 # 带版本号的完整地址
97
- apiKey: not-needed # 局域网网关通常不校验,但必须非空
133
+ apiKey: not-needed # 网关通常不校验,但必须非空
98
134
  refreshSeconds: 300
99
135
  maxRetries: 2
100
136
  timeoutMs: 300000
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-magpie-connect",
3
- "description": "Magpie LAN gateway models for the DeepSeek Harness web GUI",
4
- "version": "0.3.4",
3
+ "description": "Magpie gateway models for the DeepSeek Harness web GUI",
4
+ "version": "0.3.6",
5
5
  "entry": {
6
6
  "name": "dsh-magpie-connect",
7
7
  "inject": [
package/lib/client.js CHANGED
@@ -38,7 +38,7 @@ var NS = "magpie-connect";
38
38
  var EN = {
39
39
  nav: "Magpie",
40
40
  title: "Magpie gateway",
41
- intro: "Connect DSH to the Magpie LAN model gateway. Changes save to this machine and apply immediately \u2014 no restart needed.",
41
+ intro: "Connect DSH to the Magpie model gateway. Changes save to this machine and apply immediately \u2014 no restart needed.",
42
42
  connection: "Connection",
43
43
  baseUrl: "API URL",
44
44
  baseUrlPlaceholder: "http://127.0.0.1:3425/v1",
@@ -54,15 +54,19 @@ var EN = {
54
54
  modelsSaved: "Models saved \u2014 the picker is up to date.",
55
55
  testOk: "Connection OK: {count} models found.",
56
56
  models: "Models",
57
- enabled: "{count} enabled in the picker.",
58
- allHidden: "Every model is hidden \u2014 fetch available models to bring some back.",
57
+ modelsInherited: "Using the gateway\u2019s full catalog.",
58
+ modelsCustomized: "{count} models offered by the picker.",
59
+ resetModels: "Restore defaults",
60
+ allRemoved: "No model is offered right now \u2014 fetch available models to add some, or restore defaults.",
59
61
  remove: "Remove",
60
- removeHint: "Hide this model from the picker. Fetch available models to bring it back.",
62
+ removeHint: "Remove this model from the picker. Fetch available models and tick it again to bring it back.",
63
+ sourceStatic: "built-in snapshot",
64
+ sourceStale: "not listed by gateway",
61
65
  search: "Filter models\u2026",
62
66
  fetchModels: "Fetch available models",
63
67
  fetching: "Fetching\u2026",
64
68
  fetchTitle: "Available models",
65
- fetchDescription: "Models the gateway currently serves. Tick the ones the model picker should offer.",
69
+ fetchDescription: "Models the gateway lists right now. Tick the ones the picker should offer \u2014 applying replaces the list with exactly your selection.",
66
70
  fetchSearch: "Search models\u2026",
67
71
  fetchSelectAll: "Select all",
68
72
  fetchDeselectAll: "Deselect all",
@@ -77,7 +81,7 @@ var EN = {
77
81
  responses: "responses",
78
82
  reasoning: "reasoning",
79
83
  context: "{window} ctx",
80
- saveHint: "These are the models the picker offers. Changes save on their own \u2014 the credential fields above still need Save.",
84
+ saveHint: "These are the models the picker offers; the gateway\u2019s catalog is not shown until you add from it. Changes save on their own \u2014 the credential fields above still need Save.",
81
85
  notConfigured: "Not fully configured: the model picker stays empty and calls fail until both fields are saved.",
82
86
  pluginVersion: "Plugin version:",
83
87
  loadFailed: "Failed to load settings: {message}",
@@ -87,7 +91,7 @@ var EN = {
87
91
  var ZH = {
88
92
  nav: "Magpie \u7F51\u5173",
89
93
  title: "Magpie \u7F51\u5173",
90
- intro: "\u628A DSH \u63A5\u5165 Magpie \u5C40\u57DF\u7F51\u6A21\u578B\u7F51\u5173\u3002\u4FEE\u6539\u4FDD\u5B58\u5728\u672C\u673A\u5E76\u7ACB\u5373\u751F\u6548\uFF0C\u65E0\u9700\u91CD\u542F\u3002",
94
+ intro: "\u628A DSH \u63A5\u5165 Magpie \u6A21\u578B\u7F51\u5173\u3002\u4FEE\u6539\u4FDD\u5B58\u5728\u672C\u673A\u5E76\u7ACB\u5373\u751F\u6548\uFF0C\u65E0\u9700\u91CD\u542F\u3002",
91
95
  connection: "\u8FDE\u63A5",
92
96
  baseUrl: "API \u5730\u5740",
93
97
  baseUrlPlaceholder: "http://127.0.0.1:3425/v1",
@@ -103,15 +107,19 @@ var ZH = {
103
107
  modelsSaved: "\u6A21\u578B\u5DF2\u4FDD\u5B58\uFF0C\u9009\u62E9\u5668\u5DF2\u66F4\u65B0\u3002",
104
108
  testOk: "\u8FDE\u63A5\u6B63\u5E38\uFF0C\u5171\u53D1\u73B0 {count} \u4E2A\u6A21\u578B\u3002",
105
109
  models: "\u6A21\u578B\u5217\u8868",
106
- enabled: "\u9009\u62E9\u5668\u4E2D\u5DF2\u542F\u7528 {count} \u4E2A\u3002",
107
- allHidden: "\u6240\u6709\u6A21\u578B\u90FD\u5DF2\u9690\u85CF\u2014\u2014\u7528\u201C\u83B7\u53D6\u53EF\u7528\u6A21\u578B\u201D\u628A\u5B83\u4EEC\u52A0\u56DE\u6765\u3002",
110
+ modelsInherited: "\u6B63\u5728\u4F7F\u7528\u7F51\u5173\u7684\u5B8C\u6574\u76EE\u5F55\u3002",
111
+ modelsCustomized: "\u9009\u62E9\u5668\u4E2D\u63D0\u4F9B {count} \u4E2A\u6A21\u578B\u3002",
112
+ resetModels: "\u6062\u590D\u9ED8\u8BA4\u6A21\u578B",
113
+ allRemoved: "\u5F53\u524D\u6CA1\u6709\u63D0\u4F9B\u4EFB\u4F55\u6A21\u578B\u2014\u2014\u7528\u201C\u83B7\u53D6\u53EF\u7528\u6A21\u578B\u201D\u6DFB\u52A0\uFF0C\u6216\u6062\u590D\u9ED8\u8BA4\u3002",
108
114
  remove: "\u5220\u9664",
109
- removeHint: "\u4ECE\u9009\u62E9\u5668\u4E2D\u9690\u85CF\u8BE5\u6A21\u578B\uFF0C\u53EF\u7528\u201C\u83B7\u53D6\u53EF\u7528\u6A21\u578B\u201D\u91CD\u65B0\u52A0\u56DE\u3002",
115
+ removeHint: "\u4ECE\u9009\u62E9\u5668\u4E2D\u79FB\u9664\u8BE5\u6A21\u578B\uFF1B\u7528\u201C\u83B7\u53D6\u53EF\u7528\u6A21\u578B\u201D\u91CD\u65B0\u52FE\u9009\u5373\u53EF\u52A0\u56DE\u3002",
116
+ sourceStatic: "\u5185\u7F6E\u5FEB\u7167",
117
+ sourceStale: "\u7F51\u5173\u672A\u5217\u51FA",
110
118
  search: "\u7B5B\u9009\u6A21\u578B\u2026",
111
119
  fetchModels: "\u83B7\u53D6\u53EF\u7528\u6A21\u578B",
112
120
  fetching: "\u83B7\u53D6\u4E2D\u2026",
113
121
  fetchTitle: "\u53EF\u7528\u6A21\u578B",
114
- fetchDescription: "\u7F51\u5173\u5F53\u524D\u63D0\u4F9B\u7684\u6A21\u578B\u3002\u52FE\u9009\u9700\u8981\u51FA\u73B0\u5728\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u7684\u90A3\u4E9B\u3002",
122
+ fetchDescription: "\u7F51\u5173\u6B64\u523B\u5217\u51FA\u7684\u6A21\u578B\u3002\u52FE\u9009\u9700\u8981\u51FA\u73B0\u5728\u9009\u62E9\u5668\u4E2D\u7684\u90A3\u4E9B\u2014\u2014\u5E94\u7528\u540E\u5217\u8868\u5C31\u6B63\u597D\u662F\u8FD9\u4E9B\u3002",
115
123
  fetchSearch: "\u641C\u7D22\u6A21\u578B\u2026",
116
124
  fetchSelectAll: "\u5168\u9009",
117
125
  fetchDeselectAll: "\u53D6\u6D88\u5168\u9009",
@@ -126,7 +134,7 @@ var ZH = {
126
134
  responses: "responses",
127
135
  reasoning: "\u601D\u8003",
128
136
  context: "{window} \u4E0A\u4E0B\u6587",
129
- saveHint: "\u4EE5\u4E0B\u5373\u9009\u62E9\u5668\u4E2D\u53EF\u7528\u7684\u6A21\u578B\uFF0C\u6539\u52A8\u4F1A\u81EA\u52A8\u4FDD\u5B58\uFF1B\u4E0A\u65B9\u7684\u5730\u5740\u4E0E Key \u4ECD\u9700\u70B9\u201C\u4FDD\u5B58\u201D\u3002",
137
+ saveHint: "\u4EE5\u4E0B\u5373\u9009\u62E9\u5668\u63D0\u4F9B\u7684\u6A21\u578B\uFF0C\u7F51\u5173\u76EE\u5F55\u91CC\u7684\u5176\u4F59\u6A21\u578B\u4E0D\u4F1A\u81EA\u52A8\u51FA\u73B0\uFF1B\u6539\u52A8\u4F1A\u81EA\u52A8\u4FDD\u5B58\uFF0C\u4E0A\u65B9\u7684\u5730\u5740\u4E0E Key \u4ECD\u9700\u70B9\u201C\u4FDD\u5B58\u201D\u3002",
130
138
  notConfigured: "\u914D\u7F6E\u4E0D\u5B8C\u6574\uFF1A\u4E24\u4E2A\u5B57\u6BB5\u90FD\u4FDD\u5B58\u540E\uFF0C\u6A21\u578B\u9009\u62E9\u5668\u624D\u4F1A\u6709\u5185\u5BB9\uFF0C\u8C03\u7528\u624D\u4F1A\u653E\u884C\u3002",
131
139
  pluginVersion: "\u63D2\u4EF6\u7248\u672C\uFF1A",
132
140
  loadFailed: "\u52A0\u8F7D\u8BBE\u7F6E\u5931\u8D25\uFF1A{message}",
@@ -237,18 +245,23 @@ var import_react2 = require("react");
237
245
  var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
238
246
 
239
247
  // src/client/model-visibility.ts
240
- function initialPicked(candidates, visibleIds) {
241
- return new Set(candidates.filter((candidate) => visibleIds.has(candidate.id)).map((candidate) => candidate.id));
248
+ function initialPicked(candidates, offeredIds) {
249
+ return new Set(candidates.filter((candidate) => offeredIds.has(candidate.id)).map((candidate) => candidate.id));
242
250
  }
243
- function hiddenAfterAdopt(candidates, picked) {
244
- return candidates.filter((candidate) => !picked.has(candidate.id)).map((candidate) => candidate.id);
251
+ function enabledAfterAdopt(candidates, picked) {
252
+ return candidates.filter((candidate) => picked.has(candidate.id)).map((candidate) => candidate.id);
245
253
  }
246
- function hideOne(hidden, id) {
247
- return hidden.includes(id) ? [...hidden] : [...hidden, id];
254
+ function disableOne(enabled, id) {
255
+ return enabled.filter((entry) => entry !== id);
256
+ }
257
+ function toggleAllWouldClear(visible, picked) {
258
+ const addable = visible.some((candidate) => !picked.has(candidate.id));
259
+ const clearable = visible.some((candidate) => picked.has(candidate.id));
260
+ return !addable && clearable;
248
261
  }
249
262
  function toggleAllPicked(current, visible) {
250
263
  const next = new Set(current);
251
- if (visible.length > 0 && visible.every((candidate) => current.has(candidate.id))) {
264
+ if (toggleAllWouldClear(visible, next)) {
252
265
  for (const candidate of visible) next.delete(candidate.id);
253
266
  return next;
254
267
  }
@@ -277,6 +290,9 @@ var css = {
277
290
  itemId: { fontSize: 13, lineHeight: "20px", fontWeight: 500, color: "var(--dsw-alias-label-primary)", overflowWrap: "anywhere", fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace" },
278
291
  chips: { display: "flex", gap: 6, flexWrap: "wrap" },
279
292
  chip: { fontSize: 11, lineHeight: "18px", padding: "0 7px", borderRadius: 999, border: "1px solid var(--dsw-alias-border-l2)", color: "var(--dsw-alias-label-secondary)", whiteSpace: "nowrap" },
293
+ // A row the live gateway does not list is informational, not a capability the
294
+ // user is choosing: read it as dimmer than the capability chips.
295
+ chipStale: { color: "var(--dsw-alias-label-tertiary)", borderStyle: "dashed" },
280
296
  candidateToolbar: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6 },
281
297
  candidateSearch: { flex: 1, minWidth: 0 },
282
298
  candidateList: { display: "flex", flexDirection: "column", gap: 2, maxHeight: 320, margin: 0, padding: 0, listStyle: "none", overflowY: "auto" },
@@ -303,20 +319,31 @@ function chipsFor(row) {
303
319
  if (row.contextWindow !== void 0) chips.push({ key: "context", label: text("context", { window: formatWindow(row.contextWindow) }) });
304
320
  return chips;
305
321
  }
322
+ function sourceChip(row) {
323
+ if (row.source === "static") return { key: "source", label: text("sourceStatic") };
324
+ if (row.source === "none") return { key: "source", label: text("sourceStale") };
325
+ return void 0;
326
+ }
327
+ function filterRows(rows, query) {
328
+ const needle = query.trim().toLowerCase();
329
+ if (needle === "") return rows;
330
+ return rows.filter((row) => row.id.toLowerCase().includes(needle) || row.displayName.toLowerCase().includes(needle));
331
+ }
306
332
  function ModelListEditor(props) {
307
- const { models, visibleIds, onFetch, onRefresh, onRemove, onHiddenChange, disabled, fetchable, status } = props;
333
+ const { models, enabled, onFetch, onRefresh, onEnabledChange, disabled, fetchable, status } = props;
308
334
  const [filter, setFilter] = (0, import_react2.useState)("");
309
335
  const [busy, setBusy] = (0, import_react2.useState)(false);
310
336
  const [fetchFailure, setFetchFailure] = (0, import_react2.useState)(void 0);
311
337
  const [candidates, setCandidates] = (0, import_react2.useState)(void 0);
312
338
  const [picked, setPicked] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
313
339
  const [candidateQuery, setCandidateQuery] = (0, import_react2.useState)("");
314
- const enabledRows = (0, import_react2.useMemo)(() => models.filter((row) => visibleIds.has(row.id)), [models, visibleIds]);
315
- const visibleRows = (0, import_react2.useMemo)(() => {
316
- const needle = filter.trim().toLowerCase();
317
- if (needle === "") return enabledRows;
318
- return enabledRows.filter((row) => row.id.toLowerCase().includes(needle) || row.displayName.toLowerCase().includes(needle));
319
- }, [enabledRows, filter]);
340
+ const inheriting = enabled === void 0;
341
+ const offeredIds = (0, import_react2.useMemo)(
342
+ () => enabled === void 0 ? new Set(models.filter((row) => row.enabled).map((row) => row.id)) : new Set(enabled),
343
+ [models, enabled]
344
+ );
345
+ const enabledRows = (0, import_react2.useMemo)(() => models.filter((row) => offeredIds.has(row.id)), [models, offeredIds]);
346
+ const visibleRows = (0, import_react2.useMemo)(() => filterRows(enabledRows, filter), [enabledRows, filter]);
320
347
  const togglePicked = (id) => {
321
348
  setPicked((current) => {
322
349
  const next = new Set(current);
@@ -332,7 +359,7 @@ function ModelListEditor(props) {
332
359
  (candidate) => candidate.id.toLowerCase().includes(needle) || candidate.displayName.toLowerCase().includes(needle)
333
360
  );
334
361
  }, [candidates, candidateQuery]);
335
- const allVisiblePicked = visibleCandidates.length > 0 && visibleCandidates.every((candidate) => picked.has(candidate.id));
362
+ const wouldClear = (0, import_react2.useMemo)(() => toggleAllWouldClear(visibleCandidates, picked), [visibleCandidates, picked]);
336
363
  const closePicker = () => {
337
364
  setCandidates(void 0);
338
365
  setPicked(/* @__PURE__ */ new Set());
@@ -351,7 +378,7 @@ function ModelListEditor(props) {
351
378
  });
352
379
  setCandidateQuery("");
353
380
  setCandidates(found);
354
- setPicked(initialPicked(found, visibleIds));
381
+ setPicked(initialPicked(found, offeredIds));
355
382
  } catch (cause) {
356
383
  setFetchFailure(cause instanceof Error ? cause.message : String(cause));
357
384
  } finally {
@@ -360,7 +387,7 @@ function ModelListEditor(props) {
360
387
  };
361
388
  const adoptPicked = () => {
362
389
  if (candidates === void 0) return;
363
- onHiddenChange(hiddenAfterAdopt(candidates, picked));
390
+ onEnabledChange(enabledAfterAdopt(candidates, picked));
364
391
  closePicker();
365
392
  };
366
393
  const working = disabled || busy;
@@ -392,25 +419,44 @@ function ModelListEditor(props) {
392
419
  onChange: (event) => setFilter(event.currentTarget.value)
393
420
  }
394
421
  ),
395
- enabledRows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: css.empty, children: models.length === 0 ? text("fetchEmpty") : text("allHidden") }) : null,
396
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: css.list, children: visibleRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: css.item, children: [
397
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: css.itemMain, children: [
398
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: css.itemId, children: row.id }),
399
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: css.chips, children: chipsFor(row).map((chip) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: css.chip, children: chip.label }, chip.key)) })
400
- ] }),
401
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
422
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { style: css.meta, children: [
423
+ inheriting ? text("modelsInherited") : text("modelsCustomized", { count: enabledRows.length }),
424
+ inheriting || disabled ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
402
425
  "button",
403
426
  {
404
427
  type: "button",
405
- style: { ...css.removeButton, ...disabled ? { opacity: 0.5, cursor: "default" } : {} },
428
+ style: css.linkButton,
406
429
  disabled,
407
- title: text("removeHint"),
408
- "aria-label": `${text("remove")} ${row.id}`,
409
- onClick: () => onRemove(row.id),
410
- children: text("remove")
430
+ onClick: () => onEnabledChange(void 0),
431
+ children: text("resetModels")
411
432
  }
412
433
  )
413
- ] }, row.id)) }),
434
+ ] }),
435
+ enabledRows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: css.empty, children: models.length === 0 ? text("fetchEmpty") : text("allRemoved") }) : null,
436
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: css.list, children: visibleRows.map((row) => {
437
+ const source = sourceChip(row);
438
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: css.item, children: [
439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: css.itemMain, children: [
440
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: css.itemId, children: row.id }),
441
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: css.chips, children: [
442
+ chipsFor(row).map((chip) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: css.chip, children: chip.label }, chip.key)),
443
+ source === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { ...css.chip, ...css.chipStale }, children: source.label }, source.key)
444
+ ] })
445
+ ] }),
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
447
+ "button",
448
+ {
449
+ type: "button",
450
+ style: { ...css.removeButton, ...disabled ? { opacity: 0.5, cursor: "default" } : {} },
451
+ disabled,
452
+ title: text("removeHint"),
453
+ "aria-label": `${text("remove")} ${row.id}`,
454
+ onClick: () => onEnabledChange(disableOne(enabled ?? [], row.id)),
455
+ children: text("remove")
456
+ }
457
+ )
458
+ ] }, row.id);
459
+ }) }),
414
460
  fetchFailure === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", style: css.error, children: fetchFailure }),
415
461
  status === "saving" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: css.hint, children: text("savingModels") }) : null,
416
462
  status === "saved" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: css.ok, children: text("modelsSaved") }) : null,
@@ -440,7 +486,7 @@ function ModelListEditor(props) {
440
486
  style: css.candidateSearch
441
487
  }
442
488
  ),
443
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: visibleCandidates.length === 0, onClick: () => setPicked((current) => toggleAllPicked(current, visibleCandidates)), children: allVisiblePicked ? text("fetchDeselectAll") : text("fetchSelectAll") })
489
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "ghost", size: "sm", disabled: visibleCandidates.length === 0, onClick: () => setPicked((current) => toggleAllPicked(current, visibleCandidates)), children: wouldClear ? text("fetchDeselectAll") : text("fetchSelectAll") })
444
490
  ] }),
445
491
  visibleCandidates.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: css.candidateEmpty, role: "status", children: text("fetchNoMatches") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { style: css.candidateList, children: visibleCandidates.map((candidate) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { style: css.candidate, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: css.candidateLabel, children: [
446
492
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -514,7 +560,7 @@ function createWriteQueue(write, onSettled) {
514
560
 
515
561
  // src/client/page.tsx
516
562
  var import_jsx_runtime2 = require("react/jsx-runtime");
517
- var PLUGIN_VERSION = "0.3.4";
563
+ var PLUGIN_VERSION = "0.3.6";
518
564
  var css2 = {
519
565
  section: { display: "flex", flexDirection: "column", gap: 16, maxWidth: 780, paddingBottom: 32 },
520
566
  title: { margin: 0, fontSize: 22, lineHeight: "30px", fontWeight: 600, color: "var(--dsw-alias-label-primary)" },
@@ -557,14 +603,14 @@ async function request(path, method = "GET", body) {
557
603
  }
558
604
  return payload.value;
559
605
  }
560
- async function saveHiddenModels(hidden) {
561
- await request("/api/magpie-settings", "POST", { hiddenModels: hidden });
606
+ async function saveEnabledModels(enabled) {
607
+ await request("/api/magpie-settings", "POST", enabled === void 0 ? {} : { enabledModels: enabled });
562
608
  }
563
609
  function MagpieSettings() {
564
610
  useLocaleRevision();
565
611
  const [baseUrl, setBaseUrl] = (0, import_react3.useState)("");
566
612
  const [apiKey, setApiKey] = (0, import_react3.useState)("");
567
- const [hidden, setHidden] = (0, import_react3.useState)([]);
613
+ const [enabled, setEnabled] = (0, import_react3.useState)(void 0);
568
614
  const [models, setModels] = (0, import_react3.useState)([]);
569
615
  const [busy, setBusy] = (0, import_react3.useState)("idle");
570
616
  const [error, setError] = (0, import_react3.useState)(void 0);
@@ -573,7 +619,7 @@ function MagpieSettings() {
573
619
  const [modelsError, setModelsError] = (0, import_react3.useState)(void 0);
574
620
  const [loaded, setLoaded] = (0, import_react3.useState)(false);
575
621
  const modelsQueue = (0, import_react3.useRef)(
576
- createWriteQueue((next) => saveHiddenModels(next), (outcome) => {
622
+ createWriteQueue((next) => saveEnabledModels(next), (outcome) => {
577
623
  if (outcome.ok) {
578
624
  setModelsStatus("saved");
579
625
  setModelsError(void 0);
@@ -592,7 +638,7 @@ function MagpieSettings() {
592
638
  const listed = modelsValue.models ?? [];
593
639
  setBaseUrl(settings.baseUrl ?? "");
594
640
  setApiKey(settings.apiKey ?? "");
595
- setHidden(settings.hiddenModels ?? []);
641
+ setEnabled(settings.enabledModels);
596
642
  setModels(listed);
597
643
  setLoaded(true);
598
644
  },
@@ -606,8 +652,6 @@ function MagpieSettings() {
606
652
  alive = false;
607
653
  };
608
654
  }, []);
609
- const hiddenSet = (0, import_react3.useMemo)(() => new Set(hidden), [hidden]);
610
- const visibleIds = (0, import_react3.useMemo)(() => new Set(models.filter((row) => !hiddenSet.has(row.id)).map((row) => row.id)), [models, hiddenSet]);
611
655
  const fetchCandidates = async () => {
612
656
  const result = await request("/api/magpie-discover", "POST", { baseUrl, apiKey });
613
657
  return result.models ?? [];
@@ -616,8 +660,8 @@ function MagpieSettings() {
616
660
  const value = await request("/api/magpie-models");
617
661
  setModels(value.models ?? []);
618
662
  };
619
- const applyHidden = (next) => {
620
- setHidden(next);
663
+ const applyEnabled = (next) => {
664
+ setEnabled(next);
621
665
  setNotice(void 0);
622
666
  setModelsStatus("saving");
623
667
  setModelsError(void 0);
@@ -628,10 +672,14 @@ function MagpieSettings() {
628
672
  setError(void 0);
629
673
  setNotice(void 0);
630
674
  try {
631
- const saved = await request("/api/magpie-settings", "POST", { baseUrl, apiKey, hiddenModels: hidden });
675
+ const saved = await request("/api/magpie-settings", "POST", {
676
+ baseUrl,
677
+ apiKey,
678
+ ...enabled === void 0 ? {} : { enabledModels: enabled }
679
+ });
632
680
  setBaseUrl(saved.baseUrl);
633
681
  setApiKey(saved.apiKey);
634
- setHidden(saved.hiddenModels ?? []);
682
+ setEnabled(saved.enabledModels);
635
683
  await refreshModels();
636
684
  setNotice(text("saved"));
637
685
  } catch (cause) {
@@ -681,11 +729,10 @@ function MagpieSettings() {
681
729
  ModelListEditor,
682
730
  {
683
731
  models,
684
- visibleIds,
732
+ enabled,
685
733
  onFetch: fetchCandidates,
686
734
  onRefresh: refreshModels,
687
- onRemove: (id) => applyHidden(hideOne(hidden, id)),
688
- onHiddenChange: applyHidden,
735
+ onEnabledChange: applyEnabled,
689
736
  disabled: !loaded || working,
690
737
  fetchable: !incomplete,
691
738
  status: modelsStatus,