dsh-multi-chat 0.6.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +20 -21
  2. package/README.zh.md +20 -21
  3. package/bin/dsh-multi-chat.mjs +5 -9
  4. package/lib/client.js +778 -0
  5. package/lib/client.js.map +1 -0
  6. package/{plugin/dsh-client-ui-multi-wall/lib → lib}/index.js +57 -69
  7. package/lib/tsconfig.tsbuildinfo +1 -0
  8. package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/WallToggle.d.ts +1 -1
  9. package/lib/types/client/WallToggle.d.ts.map +1 -0
  10. package/lib/types/client/WallToggle.js +36 -0
  11. package/lib/types/client/WallToggle.js.map +1 -0
  12. package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/WallView.d.ts +1 -1
  13. package/lib/types/client/WallView.d.ts.map +1 -0
  14. package/lib/types/client/WallView.js +218 -0
  15. package/lib/types/client/WallView.js.map +1 -0
  16. package/lib/types/client/index.d.ts.map +1 -0
  17. package/lib/types/client/index.js +59 -0
  18. package/lib/types/client/index.js.map +1 -0
  19. package/lib/types/client/locales.d.ts.map +1 -0
  20. package/lib/types/client/locales.js +96 -0
  21. package/lib/types/client/locales.js.map +1 -0
  22. package/lib/types/client/store.d.ts.map +1 -0
  23. package/lib/types/client/store.js +27 -0
  24. package/lib/types/client/store.js.map +1 -0
  25. package/lib/types/client/wall-injected.d.ts.map +1 -0
  26. package/lib/types/client/wall-injected.js +76 -0
  27. package/lib/types/client/wall-injected.js.map +1 -0
  28. package/lib/types/gateway.d.ts +57 -0
  29. package/lib/types/gateway.d.ts.map +1 -0
  30. package/lib/types/gateway.js +566 -0
  31. package/lib/types/gateway.js.map +1 -0
  32. package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/index.d.ts +1 -16
  33. package/lib/types/index.d.ts.map +1 -0
  34. package/lib/types/index.js +550 -0
  35. package/lib/types/index.js.map +1 -0
  36. package/lib/types/invariant.d.ts.map +1 -0
  37. package/lib/types/invariant.js +26 -0
  38. package/lib/types/invariant.js.map +1 -0
  39. package/package.json +31 -17
  40. package/scripts/install-plugin.ps1 +6 -9
  41. package/src/client/WallToggle.module.css +26 -0
  42. package/src/client/WallToggle.tsx +52 -0
  43. package/src/client/WallView.module.css +190 -0
  44. package/src/client/WallView.tsx +406 -0
  45. package/src/client/index.ts +103 -0
  46. package/src/client/locales.ts +100 -0
  47. package/src/client/store.ts +40 -0
  48. package/src/client/wall-injected.ts +123 -0
  49. package/src/css-modules.d.ts +5 -0
  50. package/src/gateway.ts +627 -0
  51. package/src/index.ts +618 -0
  52. package/src/invariant.ts +34 -0
  53. package/plugin/dsh-client-ui-multi-wall/README.md +0 -26
  54. package/plugin/dsh-client-ui-multi-wall/README.zh.md +0 -26
  55. package/plugin/dsh-client-ui-multi-wall/cordis.patch.yml +0 -7
  56. package/plugin/dsh-client-ui-multi-wall/lib/client.js +0 -781
  57. package/plugin/dsh-client-ui-multi-wall/lib/invariant.js +0 -27
  58. package/plugin/dsh-client-ui-multi-wall/package.json +0 -88
  59. /package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/index.d.ts +0 -0
  60. /package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/locales.d.ts +0 -0
  61. /package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/store.d.ts +0 -0
  62. /package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/client/wall-injected.d.ts +0 -0
  63. /package/{plugin/dsh-client-ui-multi-wall/lib → lib}/types/invariant.d.ts +0 -0
@@ -1,781 +0,0 @@
1
- window.__ModuleLoader__.load({
2
- id: "@deepseek-ai/dsh-client-ui-multi-wall",
3
- factory: (require) => {
4
- var module = { exports: {} };
5
- var exports = module.exports;
6
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
- let _deepseek_ai_dsh_client_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
8
- let react = require("react");
9
- let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
10
- let react_jsx_runtime = require("react/jsx-runtime");
11
- //#region src/client/locales.ts
12
- /** `multiWall` namespace dictionaries. */
13
- /** Simplified Chinese dictionary (the key-set source of truth). */
14
- const zh = {
15
- "toggle": "多窗口",
16
- "toggle.aria": "打开或关闭多窗口",
17
- "view.multiWall": "多窗口",
18
- "overlay.title": "多窗口",
19
- "overlay.close": "关闭",
20
- "scan": "发现实例",
21
- "scan.from": "起始端口",
22
- "scan.to": "结束端口",
23
- "create": "新建窗口",
24
- "create.pending": "启动中…",
25
- "create.done": "已创建窗口 :{port}",
26
- "create.failed": "创建失败:{error}",
27
- "create.unknown": "未知原因",
28
- "exit": "退出",
29
- "exit.aria": "退出多窗口,返回对话",
30
- "link": "手机访问",
31
- "link.aria": "获取手机访问链接",
32
- "link.fetching": "正在获取链接…",
33
- "link.none": "未检测到局域网地址",
34
- "link.copy": "复制链接",
35
- "link.copied": "已复制",
36
- "link.hint": "提示:{hint}",
37
- "link.reachable": "手机在同一网络时可用:{urls}",
38
- "link.unreachable": "当前实例仅绑定本机,手机无法访问。{hint}",
39
- "link.token": "口令:{token}",
40
- "columns": "列数",
41
- "columns.auto": "自动",
42
- "refresh": "全部刷新",
43
- "openTab": "新标签页打开",
44
- "reload": "重新加载",
45
- "remove": "从视图移除",
46
- "stop": "关闭实例",
47
- "stop.confirm": "确定关闭?",
48
- "stop.self": "即将关闭当前实例(本页面将断开)",
49
- "stop.done": "已关闭 :{port}",
50
- "stop.failed": "关闭 :{port} 失败:{error}",
51
- "zoom": "放大",
52
- "loading": "加载中",
53
- "empty": "没有检测到 DSH 实例",
54
- "empty.hint": "先启动若干 dsh web --port <n> 实例,再点击「发现实例」或手动添加端口。",
55
- "status.scanning": "扫描 {from}–{to} …",
56
- "status.found": "发现 {count} 个实例:{ports}",
57
- "status.none": "区间 {from}–{to} 未发现 DSH 实例",
58
- "status.refreshed": "已刷新全部窗口"
59
- };
60
- /** English dictionary, checked complete against the zh key set. */
61
- const en = {
62
- "toggle": "Multi-Window",
63
- "toggle.aria": "Toggle multi-window",
64
- "view.multiWall": "Multi-Window",
65
- "overlay.title": "Multi-Window",
66
- "overlay.close": "Close",
67
- "scan": "Discover",
68
- "scan.from": "Start port",
69
- "scan.to": "End port",
70
- "create": "New window",
71
- "create.pending": "Starting…",
72
- "create.done": "Created window :{port}",
73
- "create.failed": "Create failed: {error}",
74
- "create.unknown": "unknown reason",
75
- "exit": "Exit",
76
- "exit.aria": "Exit multi-window and return to chat",
77
- "link": "Phone access",
78
- "link.aria": "Get phone access link",
79
- "link.fetching": "Fetching link…",
80
- "link.none": "No LAN address detected",
81
- "link.copy": "Copy link",
82
- "link.copied": "Copied",
83
- "link.hint": "Hint: {hint}",
84
- "link.reachable": "Reachable on the same network: {urls}",
85
- "link.unreachable": "This instance binds loopback only; phones cannot reach it. {hint}",
86
- "link.token": "Token: {token}",
87
- "columns": "Columns",
88
- "columns.auto": "Auto",
89
- "refresh": "Refresh all",
90
- "openTab": "Open in new tab",
91
- "reload": "Reload",
92
- "remove": "Remove from view",
93
- "stop": "Stop instance",
94
- "stop.confirm": "Confirm stop?",
95
- "stop.self": "Stopping the current instance (this page will disconnect)",
96
- "stop.done": "Stopped :{port}",
97
- "stop.failed": "Failed to stop :{port}: {error}",
98
- "zoom": "Zoom",
99
- "loading": "Loading",
100
- "empty": "No DSH instances found",
101
- "empty.hint": "Start a few `dsh web --port <n>` instances first, then click \"Discover\" or add a port manually.",
102
- "status.scanning": "Scanning {from}–{to} …",
103
- "status.found": "Found {count} instance(s): {ports}",
104
- "status.none": "No DSH instances in {from}–{to}",
105
- "status.refreshed": "Refreshed all windows"
106
- };
107
- //#endregion
108
- //#region src/client/store.ts
109
- /**
110
- * Wall store: which instances are shown and the grid columns. The ports list
111
- * is the wall's whole business state — discovery writes it, removal filters
112
- * it, and the grid renders from it. Open/closed is NOT stored here: the wall
113
- * is a `conversation.view` ring entry, so the active view (chat store's
114
- * `view` field) decides whether it renders.
115
- */
116
- /**
117
- * Create the wall store handle. Persisted under `dsh.multi-wall` so the port
118
- * set and column choice survive view switches and reloads.
119
- * @returns the store handle (spec + type + identity + factory in one).
120
- */
121
- function createWallStore() {
122
- return (0, _deepseek_ai_dsh_client_runtime_client.defineStore)({
123
- init: () => ({
124
- ports: [],
125
- columns: "auto"
126
- }),
127
- persist: "dsh.multi-wall",
128
- actions: {
129
- setPorts: (d, ports) => {
130
- d.ports = ports;
131
- },
132
- addPort: (d, port) => {
133
- if (!d.ports.includes(port)) d.ports = [...d.ports, port];
134
- },
135
- removePort: (d, port) => {
136
- d.ports = d.ports.filter((p) => p !== port);
137
- },
138
- setColumns: (d, columns) => {
139
- d.columns = columns;
140
- }
141
- }
142
- });
143
- }
144
- //#endregion
145
- //#region src/client/wall-injected.ts
146
- /**
147
- * Build the probe face bound to this origin's /multi/api routes.
148
- * @param mount - the API base path ('' at the root, '/multi' when mounted).
149
- * @returns the injected callbacks.
150
- */
151
- function createWallInjected(mount = "") {
152
- const base = mount.replace(/\/+$/, "");
153
- return {
154
- discover: async () => {
155
- const res = await fetch(`${base}/multi/api/ports`);
156
- if (!res.ok) return [];
157
- return ((await res.json()).ports ?? []).filter((p) => p.alive).map((p) => p.port);
158
- },
159
- probe: async (ports) => {
160
- const res = await fetch(`${base}/multi/api/status?ports=${ports.join(",")}`);
161
- if (!res.ok) return [];
162
- return (await res.json()).ports ?? [];
163
- },
164
- stop: async (port) => {
165
- const res = await fetch(`${base}/multi/api/stop?port=${port}`, { method: "POST" });
166
- if (!res.ok) return {
167
- port,
168
- ok: false,
169
- error: `HTTP ${res.status}`
170
- };
171
- return (await res.json()).ports?.[0] ?? {
172
- port,
173
- ok: false,
174
- error: "no result"
175
- };
176
- },
177
- create: async () => {
178
- const res = await fetch(`${base}/multi/api/create`, { method: "POST" });
179
- if (!res.ok) return {
180
- ok: false,
181
- error: `HTTP ${res.status}`
182
- };
183
- const text = await res.text();
184
- let data;
185
- try {
186
- data = JSON.parse(text);
187
- } catch {
188
- const snippet = text.trim().slice(0, 120);
189
- return {
190
- ok: false,
191
- error: `invalid response: ${snippet === "" ? "<empty body>" : snippet}`
192
- };
193
- }
194
- if (data.ok === true) return data.port !== void 0 ? {
195
- ok: true,
196
- port: data.port
197
- } : {
198
- ok: false,
199
- error: "no port in response"
200
- };
201
- return {
202
- ok: false,
203
- ...typeof data.error === "string" ? { error: data.error } : { error: "server returned no reason" }
204
- };
205
- },
206
- link: async () => {
207
- const data = await (await fetch(`${base}/multi/api/link`)).json().catch(() => ({}));
208
- return {
209
- port: data.port ?? 0,
210
- host: data.host ?? "unknown",
211
- lan: data.lan ?? [],
212
- reachable: data.reachable === true,
213
- ...typeof data.gatewayPort === "number" ? { gatewayPort: data.gatewayPort } : {},
214
- ...typeof data.token === "string" ? { token: data.token } : {},
215
- ...typeof data.hint === "string" ? { hint: data.hint } : {}
216
- };
217
- }
218
- };
219
- }
220
- //#endregion
221
- //#region C:/Users/ASUS/AppData/Roaming/npm/node_modules/@deepseek-ai/dsh/node_modules/clsx/dist/clsx.mjs
222
- function r(e) {
223
- var t, f, n = "";
224
- if ("string" == typeof e || "number" == typeof e) n += e;
225
- else if ("object" == typeof e) if (Array.isArray(e)) {
226
- var o = e.length;
227
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
228
- } else for (f in e) e[f] && (n && (n += " "), n += f);
229
- return n;
230
- }
231
- function clsx() {
232
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
233
- return n;
234
- }
235
- //#endregion
236
- //#region \0dsh-css:D:\2026AppDev\dsh-plugins-multi-task\harness-src\packages\client\ui-multi-wall\src\client\WallView.module.css.mjs
237
- const css$1 = "[data-conversation-scroll]:has([data-wall-view]) [data-composer-seat]{display:none}.ouhzTG_wall{background:var(--dsw-alias-bg-base);min-width:0;min-height:0;color:var(--dsw-alias-label-primary);flex-direction:column;flex:1;display:flex}.ouhzTG_toolbar{border-bottom:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);flex-wrap:wrap;flex:none;align-items:center;gap:12px;padding:8px 14px;display:flex}.ouhzTG_title{font-size:14px;font-weight:600}.ouhzTG_linkBar{border-bottom:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);flex-wrap:wrap;flex:none;align-items:center;gap:10px;padding:6px 14px;display:flex}.ouhzTG_linkText{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;flex:1;min-width:160px;font-size:12px}.ouhzTG_status{color:var(--dsw-alias-label-secondary);flex:1;min-width:120px;font-size:12px}.ouhzTG_controls{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.ouhzTG_field{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;font-size:12px;display:inline-flex}.ouhzTG_field>span{width:76px}.ouhzTG_grid{flex:1;grid-auto-rows:minmax(280px,1fr);align-content:start;gap:8px;padding:8px;display:grid;overflow:auto}.ouhzTG_grid[data-cols=auto]{grid-template-columns:repeat(auto-fit,minmax(280px,1fr))}.ouhzTG_grid[data-cols=\"1\"]{grid-template-columns:1fr}.ouhzTG_grid[data-cols=\"2\"]{grid-template-columns:repeat(2,1fr)}.ouhzTG_grid[data-cols=\"3\"]{grid-template-columns:repeat(3,1fr)}.ouhzTG_grid[data-cols=\"4\"]{grid-template-columns:repeat(4,1fr)}.ouhzTG_grid[data-cols=\"6\"]{grid-template-columns:repeat(6,1fr)}.ouhzTG_pane{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);border-radius:8px;flex-direction:column;min-width:0;min-height:0;display:flex;overflow:hidden}.ouhzTG_pane.ouhzTG_zoomed{grid-area:1/1/-1/-1}.ouhzTG_paneHead{border-bottom:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);flex:none;align-items:center;gap:8px;padding:4px 8px;display:flex}.ouhzTG_dot{flex:none}.ouhzTG_paneTitle{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.ouhzTG_paneActions{flex:none;gap:2px;margin-left:auto;display:flex}.ouhzTG_action{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:4px;padding:2px 6px;line-height:1}.ouhzTG_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.ouhzTG_action.ouhzTG_danger:hover{color:var(--dsw-static-amber-600)}.ouhzTG_action.ouhzTG_danger.ouhzTG_confirm{background:var(--dsw-static-amber-500);color:var(--dsw-static-neutral-00);padding:2px 8px;font-size:11px}.ouhzTG_action.ouhzTG_danger.ouhzTG_confirm:hover{background:var(--dsw-static-amber-600);color:var(--dsw-static-neutral-00)}.ouhzTG_paneBody{flex:1;min-height:0;position:relative}.ouhzTG_paneBody iframe{border:none;width:100%;height:100%;display:block}.ouhzTG_empty{color:var(--dsw-alias-label-secondary);flex-direction:column;grid-column:1/-1;justify-content:center;align-items:center;gap:6px;display:flex}.ouhzTG_empty .ouhzTG_hint{font-size:12px}";
238
- const tagId$1 = "@deepseek-ai/dsh-client-ui-multi-wall/WallView.module.css";
239
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
240
- const tag = document.createElement("style");
241
- tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-multi-wall";
242
- tag.dataset.pluginCss = tagId$1;
243
- tag.textContent = css$1;
244
- document.head.appendChild(tag);
245
- }
246
- var WallView_module_css_default = {
247
- "empty": "ouhzTG_empty",
248
- "paneActions": "ouhzTG_paneActions",
249
- "paneHead": "ouhzTG_paneHead",
250
- "wall": "ouhzTG_wall",
251
- "field": "ouhzTG_field",
252
- "status": "ouhzTG_status",
253
- "confirm": "ouhzTG_confirm",
254
- "dot": "ouhzTG_dot",
255
- "title": "ouhzTG_title",
256
- "linkText": "ouhzTG_linkText",
257
- "danger": "ouhzTG_danger",
258
- "paneBody": "ouhzTG_paneBody",
259
- "controls": "ouhzTG_controls",
260
- "action": "ouhzTG_action",
261
- "pane": "ouhzTG_pane",
262
- "grid": "ouhzTG_grid",
263
- "hint": "ouhzTG_hint",
264
- "toolbar": "ouhzTG_toolbar",
265
- "linkBar": "ouhzTG_linkBar",
266
- "paneTitle": "ouhzTG_paneTitle",
267
- "zoomed": "ouhzTG_zoomed"
268
- };
269
- //#endregion
270
- //#region src/client/WallView.tsx
271
- /**
272
- * WallView: the multi-window wall as a `conversation.view` ring entry. When
273
- * the header's "多窗口" tab is selected, the right panel swaps from the
274
- * chat to this view — a toolbar plus a grid of iframes, one pane per running
275
- * DSH instance (127.0.0.1:<port>). Pure additive UI; no existing slot is
276
- * replaced.
277
- *
278
- * Recursion guard: panes embed `?multi-wall=embed` (the embedded page
279
- * registers no wall UI). The serving instance is itself a pane, so the user
280
- * can watch — or stop — the very instance they are in.
281
- *
282
- * Live data channels: the store owns ports/columns; discovery writes
283
- * `setPorts` from /multi/api/ports (same-origin, served by the node half);
284
- * per-pane liveness arrives from /multi/api/status polls. Components never
285
- * see ctx — the fetch helpers are injected through the registration.
286
- */
287
- /** Grid column presets, driven by the toolbar menu. 'auto' fills the row. */
288
- const COLUMN_PRESETS = [
289
- "auto",
290
- "1",
291
- "2",
292
- "3",
293
- "4",
294
- "6"
295
- ];
296
- /** Embed flag appended to every pane URL; such pages register no wall UI. */
297
- const EMBED_FLAG = "multi-wall=embed";
298
- /**
299
- * Whether this wall is being viewed through the phone gateway (a non-loopback
300
- * host) rather than on the machine running DSH. When remote, pane iframes must
301
- * load through the gateway's `/gw/<port>` route — a phone's `127.0.0.1` points
302
- * at the phone itself, not the host.
303
- */
304
- function isRemoteViewer() {
305
- const host = typeof window !== "undefined" ? window.location.hostname : "";
306
- return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
307
- }
308
- /**
309
- * The iframe URL for a pane. Local viewers embed the loopback instance
310
- * directly; remote (phone) viewers route through the gateway that is already
311
- * serving this page, appending the port so the gateway proxies to it.
312
- * @param port - target DSH instance port.
313
- * @returns the pane URL.
314
- */
315
- function paneUrl(port) {
316
- if (isRemoteViewer()) return `${window.location.origin}/gw/${port}/?${EMBED_FLAG}`;
317
- return `http://127.0.0.1:${port}/?${EMBED_FLAG}`;
318
- }
319
- /**
320
- * One pane: header (port, liveness dot, zoom/refresh/open/stop/remove) plus
321
- * the embedded original DSH UI.
322
- */
323
- function WallPane(props) {
324
- const { port, alive, zoomed, stopping, onZoom, onStop, onRemove, t } = props;
325
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
326
- className: clsx(WallView_module_css_default.pane, zoomed && WallView_module_css_default.zoomed),
327
- "data-port": port,
328
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
329
- className: WallView_module_css_default.paneHead,
330
- children: [
331
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
332
- state: alive ? "done" : "warning",
333
- size: 8,
334
- className: WallView_module_css_default.dot
335
- }),
336
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
337
- className: WallView_module_css_default.paneTitle,
338
- children: ["127.0.0.1:", port]
339
- }),
340
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
341
- className: WallView_module_css_default.paneActions,
342
- children: [
343
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
344
- type: "button",
345
- className: WallView_module_css_default.action,
346
- title: t("zoom"),
347
- onClick: onZoom,
348
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutline16, { size: 14 })
349
- }),
350
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
351
- type: "button",
352
- className: WallView_module_css_default.action,
353
- title: t("reload"),
354
- onClick: (e) => {
355
- e.currentTarget.closest("section")?.querySelector("iframe")?.contentWindow?.location.reload();
356
- },
357
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutline16, { size: 14 })
358
- }),
359
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
360
- type: "button",
361
- className: WallView_module_css_default.action,
362
- title: t("openTab"),
363
- onClick: () => {
364
- window.open(paneUrl(port), "_blank");
365
- },
366
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutline16, { size: 14 })
367
- }),
368
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
369
- type: "button",
370
- className: clsx(WallView_module_css_default.action, WallView_module_css_default.danger, stopping && WallView_module_css_default.confirm),
371
- title: t("stop"),
372
- onClick: onStop,
373
- children: stopping ? t("stop.confirm") : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconStopFill16, { size: 14 })
374
- }),
375
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
376
- type: "button",
377
- className: WallView_module_css_default.action,
378
- title: t("remove"),
379
- onClick: onRemove,
380
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutline16, { size: 14 })
381
- })
382
- ]
383
- })
384
- ]
385
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
386
- className: WallView_module_css_default.paneBody,
387
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
388
- title: `DSH :${port}`,
389
- src: paneUrl(port),
390
- loading: "lazy"
391
- })
392
- })]
393
- });
394
- }
395
- /**
396
- * Render the wall: toolbar plus the horizontally-filled pane grid. Discovery
397
- * runs on mount and liveness polls every 5s; the store's persisted ports
398
- * survive view switches and reloads.
399
- * @param props - composed slot props.
400
- * @returns the wall surface.
401
- */
402
- function WallView({ useStore, actions, discover, probe, stop, create, link, t }) {
403
- const ports = useStore((s) => s.ports);
404
- const columns = useStore((s) => s.columns);
405
- const [alive, setAlive] = (0, react.useState)({});
406
- const [zoomedPort, setZoomedPort] = (0, react.useState)(null);
407
- const [confirmingStop, setConfirmingStop] = (0, react.useState)(null);
408
- const [scanFrom, setScanFrom] = (0, react.useState)(3070);
409
- const [scanTo, setScanTo] = (0, react.useState)(3110);
410
- const [colsMenuOpen, setColsMenuOpen] = (0, react.useState)(false);
411
- const [creating, setCreating] = (0, react.useState)(false);
412
- const [linkOpen, setLinkOpen] = (0, react.useState)(false);
413
- const [linkInfo, setLinkInfo] = (0, react.useState)(null);
414
- const [linkCopied, setLinkCopied] = (0, react.useState)(false);
415
- const [status, setStatus] = (0, react.useState)("");
416
- const aliveRef = (0, react.useRef)({});
417
- aliveRef.current = alive;
418
- (0, react.useEffect)(() => {
419
- discover().then((found) => {
420
- if (found.length > 0) actions.setPorts(found);
421
- setStatus(found.length > 0 ? t("status.found").replace("{count}", String(found.length)).replace("{ports}", found.join(", ")) : "");
422
- });
423
- const timer = setInterval(() => {
424
- if (ports.length === 0) return;
425
- probe(ports).then((rows) => {
426
- const next = {};
427
- for (const row of rows) next[row.port] = row.alive;
428
- setAlive(next);
429
- });
430
- }, 5e3);
431
- return () => {
432
- clearInterval(timer);
433
- };
434
- }, []);
435
- const handleStop = async (port) => {
436
- if (confirmingStop !== port) {
437
- setConfirmingStop(port);
438
- return;
439
- }
440
- setConfirmingStop(null);
441
- const result = await stop(port);
442
- if (result.ok) {
443
- actions.removePort(port);
444
- setAlive((current) => ({
445
- ...current,
446
- [port]: false
447
- }));
448
- setStatus(t("stop.done").replace("{port}", String(port)));
449
- } else setStatus(t("stop.failed").replace("{port}", String(port)).replace("{error}", result.error ?? ""));
450
- };
451
- const runDiscovery = async () => {
452
- setStatus(t("status.scanning").replace("{from}", String(scanFrom)).replace("{to}", String(scanTo)));
453
- const found = await discover();
454
- if (found.length === 0) {
455
- setStatus(t("status.none").replace("{from}", String(scanFrom)).replace("{to}", String(scanTo)));
456
- return;
457
- }
458
- actions.setPorts(found);
459
- setStatus(t("status.found").replace("{count}", String(found.length)).replace("{ports}", found.join(", ")));
460
- };
461
- const handleCreate = async () => {
462
- setCreating(true);
463
- setStatus("");
464
- try {
465
- const result = await create();
466
- if (result.ok && result.port !== void 0) {
467
- actions.addPort(result.port);
468
- setAlive((current) => ({
469
- ...current,
470
- [result.port]: true
471
- }));
472
- setStatus(t("create.done").replace("{port}", String(result.port)));
473
- } else setStatus(t("create.failed").replace("{error}", result.error ?? t("create.unknown")));
474
- } catch (error) {
475
- setStatus(t("create.failed").replace("{error}", error instanceof Error ? error.message : String(error)));
476
- } finally {
477
- setCreating(false);
478
- }
479
- };
480
- const exitWall = () => {
481
- document.querySelector("[role=\"tablist\"] [role=\"tab\"]")?.click();
482
- };
483
- const handleLink = async () => {
484
- if (linkInfo === null) {
485
- setStatus(t("link.fetching"));
486
- setLinkInfo(await link());
487
- }
488
- setLinkOpen(true);
489
- setLinkCopied(false);
490
- setStatus("");
491
- };
492
- const copyFirstLink = async () => {
493
- if (linkInfo === null || linkInfo.lan.length === 0) return;
494
- try {
495
- const base = linkInfo.lan[0] ?? "";
496
- const token = linkInfo.token ?? "";
497
- const url = token !== "" ? `${base}?token=${encodeURIComponent(token)}` : base;
498
- await navigator.clipboard.writeText(url);
499
- setLinkCopied(true);
500
- } catch {
501
- setLinkCopied(false);
502
- }
503
- };
504
- const shown = ports;
505
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
506
- className: WallView_module_css_default.wall,
507
- role: "region",
508
- "aria-label": t("overlay.title"),
509
- "data-wall-view": "",
510
- children: [
511
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
512
- className: WallView_module_css_default.toolbar,
513
- children: [
514
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
515
- className: WallView_module_css_default.title,
516
- children: t("overlay.title")
517
- }),
518
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
519
- className: WallView_module_css_default.status,
520
- children: status
521
- }),
522
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
523
- className: WallView_module_css_default.controls,
524
- children: [
525
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
526
- className: WallView_module_css_default.field,
527
- children: [t("scan.from"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
528
- type: "number",
529
- value: scanFrom,
530
- onChange: (e) => setScanFrom(Number(e.target.value))
531
- })]
532
- }),
533
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
534
- className: WallView_module_css_default.field,
535
- children: [t("scan.to"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
536
- type: "number",
537
- value: scanTo,
538
- onChange: (e) => setScanTo(Number(e.target.value))
539
- })]
540
- }),
541
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
542
- variant: "toolbar",
543
- size: "sm",
544
- onClick: () => {
545
- runDiscovery();
546
- },
547
- children: t("scan")
548
- }),
549
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
550
- variant: "toolbar",
551
- size: "sm",
552
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }),
553
- disabled: creating,
554
- onClick: () => {
555
- handleCreate();
556
- },
557
- children: creating ? t("create.pending") : t("create")
558
- }),
559
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
560
- open: colsMenuOpen,
561
- anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
562
- variant: "toolbar",
563
- size: "sm",
564
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutline16, { size: 14 }),
565
- onClick: () => {
566
- setColsMenuOpen(true);
567
- },
568
- children: columns === "auto" ? t("columns.auto") : columns
569
- }),
570
- items: COLUMN_PRESETS.map((c) => ({
571
- id: c,
572
- label: c === "auto" ? t("columns.auto") : c
573
- })),
574
- selectedId: columns,
575
- onSelect: (id) => {
576
- actions.setColumns(id);
577
- setColsMenuOpen(false);
578
- },
579
- onClose: () => {
580
- setColsMenuOpen(false);
581
- },
582
- compact: true
583
- }),
584
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
585
- variant: "toolbar",
586
- size: "sm",
587
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutline14, { size: 14 }),
588
- onClick: () => {
589
- document.querySelectorAll(`.${WallView_module_css_default.paneBody} iframe`).forEach((f) => {
590
- f.contentWindow?.location.reload();
591
- });
592
- setStatus(t("status.refreshed"));
593
- },
594
- children: t("refresh")
595
- }),
596
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
597
- variant: "toolbar",
598
- size: "sm",
599
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconGlobeOutline14, { size: 14 }),
600
- "aria-label": t("link.aria"),
601
- onClick: () => {
602
- handleLink();
603
- },
604
- children: t("link")
605
- }),
606
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
607
- variant: "toolbar",
608
- size: "sm",
609
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutline16, { size: 14 }),
610
- "aria-label": t("exit.aria"),
611
- title: t("exit"),
612
- onClick: () => {
613
- exitWall();
614
- },
615
- children: t("exit")
616
- })
617
- ]
618
- })
619
- ]
620
- }),
621
- linkOpen && linkInfo !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
622
- className: WallView_module_css_default.linkBar,
623
- children: [linkInfo.reachable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
624
- className: WallView_module_css_default.linkText,
625
- children: [t("link.reachable").replace("{urls}", linkInfo.lan.join(" ")), linkInfo.token !== void 0 && linkInfo.token !== "" ? ` ${t("link.token").replace("{token}", linkInfo.token)}` : ""]
626
- }), linkInfo.lan.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
627
- variant: "outline",
628
- size: "sm",
629
- onClick: () => {
630
- copyFirstLink();
631
- },
632
- children: linkCopied ? t("link.copied") : t("link.copy")
633
- })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
634
- className: WallView_module_css_default.linkText,
635
- children: t("link.unreachable").replace("{hint}", linkInfo.hint ?? "")
636
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
637
- variant: "ghost",
638
- size: "sm",
639
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutline16, { size: 14 }),
640
- onClick: () => {
641
- setLinkOpen(false);
642
- },
643
- children: t("overlay.close")
644
- })]
645
- }),
646
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
647
- className: WallView_module_css_default.grid,
648
- "data-cols": columns,
649
- children: [shown.map((port) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WallPane, {
650
- port,
651
- alive: aliveRef.current[port] ?? true,
652
- zoomed: zoomedPort === port,
653
- stopping: confirmingStop === port,
654
- onZoom: () => setZoomedPort(zoomedPort === port ? null : port),
655
- onStop: () => {
656
- handleStop(port);
657
- },
658
- onRemove: () => {
659
- setConfirmingStop(null);
660
- actions.removePort(port);
661
- },
662
- t
663
- }, port)), shown.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
664
- className: WallView_module_css_default.empty,
665
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("empty") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
666
- className: WallView_module_css_default.hint,
667
- children: t("empty.hint")
668
- })]
669
- })]
670
- })
671
- ]
672
- });
673
- }
674
- //#endregion
675
- //#region \0dsh-css:D:\2026AppDev\dsh-plugins-multi-task\harness-src\packages\client\ui-multi-wall\src\client\WallToggle.module.css.mjs
676
- const css = ".bmjS6q_row{box-sizing:border-box;width:calc(100% + 8px);height:34px;color:var(--dsw-alias-label-secondary);cursor:pointer;font:inherit;background:0 0;border:none;border-radius:12px;align-items:center;gap:8px;margin:4px -4px;padding:6px 2px 6px 10px;display:flex;overflow:hidden}.bmjS6q_row:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.bmjS6q_label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
677
- const tagId = "@deepseek-ai/dsh-client-ui-multi-wall/WallToggle.module.css";
678
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
679
- const tag = document.createElement("style");
680
- tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-multi-wall";
681
- tag.dataset.pluginCss = tagId;
682
- tag.textContent = css;
683
- document.head.appendChild(tag);
684
- }
685
- var WallToggle_module_css_default = {
686
- "label": "bmjS6q_label",
687
- "row": "bmjS6q_row"
688
- };
689
- //#endregion
690
- //#region src/client/WallToggle.tsx
691
- /**
692
- * WallToggle: the sidebar-foot shortcut. Clicking it opens the wall view —
693
- * the `conversation.view` ring switches to the 'multi-wall' entry, which the
694
- * header renders as the "多窗口" tab. The click is a plain user-equivalent
695
- * activation: it finds the header's view-ring tab for this plugin's label and
696
- * clicks it, so the official view-ring state machine (the chat store's active
697
- * view field) performs the switch. No store is declared: the ring decides
698
- * what renders, so this row owns no state.
699
- *
700
- * Session-scoped by design: the view ring (and its header tabs) only renders
701
- * with an active session, so the shortcut is inert on the empty-hero screen —
702
- * the user first opens or creates a session (the official flow), after which
703
- * the tab is present and the click lands.
704
- */
705
- /**
706
- * Render the wall shortcut row (icon; label only in the wide column).
707
- * @param props - composed slot props.
708
- * @returns the shortcut row.
709
- */
710
- function WallToggle({ wide, t }) {
711
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
712
- type: "button",
713
- className: WallToggle_module_css_default.row,
714
- "aria-label": t("toggle.aria"),
715
- title: t("toggle"),
716
- onClick: () => {
717
- const label = t("view.multiWall");
718
- Array.from(document.querySelectorAll("[role=\"tab\"]")).find((el) => el.textContent?.trim() === label)?.click();
719
- },
720
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutline16, { size: wide ? 16 : 18 }), wide && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
721
- className: WallToggle_module_css_default.label,
722
- children: t("toggle")
723
- })]
724
- });
725
- }
726
- //#endregion
727
- //#region src/client/index.ts
728
- /** Dictionary namespace owned by this plugin. */
729
- const NS = "multiWall";
730
- /** Required services: slots for both registrations, locale for copy. */
731
- const inject = ["slots", "locale"];
732
- /**
733
- * Whether this page is an embedded wall pane. Panes load
734
- * `?multi-wall=embed`; such pages register no wall UI at all, which stops a
735
- * wall inside a wall (the pane would otherwise recursively embed the
736
- * serving instance).
737
- * @returns true when the query flag is present.
738
- */
739
- function isEmbeddedPane() {
740
- return new URLSearchParams(window.location.search).has("multi-wall");
741
- }
742
- /**
743
- * Client plugin body: register the dictionaries, the view-ring entry (the
744
- * wall), and the sidebar footer shortcut. Embedded panes register nothing.
745
- * @param ctx - client root context.
746
- */
747
- function apply(ctx) {
748
- if (isEmbeddedPane()) return;
749
- ctx.effect(() => ctx.locale.register(NS, {
750
- zh,
751
- en
752
- }), "ui-multi-wall: dictionaries");
753
- const t = ctx.locale.bind(NS);
754
- const wallStore = createWallStore();
755
- ctx.slots.inject("conversation.view", () => ctx.slots.register({
756
- name: "conversation.view",
757
- id: "multi-wall",
758
- order: 20,
759
- label: () => t("view.multiWall"),
760
- locale: NS,
761
- store: wallStore,
762
- inject: () => createWallInjected()
763
- }, WallView));
764
- ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
765
- name: "sidebar.footer.action",
766
- id: "multi-wall",
767
- order: 10,
768
- locale: NS
769
- }, WallToggle));
770
- }
771
- //#endregion
772
- exports.WallToggle = WallToggle;
773
- exports.WallView = WallView;
774
- exports.apply = apply;
775
- exports.createWallStore = createWallStore;
776
- exports.inject = inject;
777
- return module.exports;
778
- }
779
- });
780
-
781
- //# sourceMappingURL=client.js.map