@hpyperry/dsh-ref-lib 0.8.0 → 0.9.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.
- package/README.md +2 -1
- package/lib/client/RefLibCommandCard.d.ts +29 -0
- package/lib/client/RefLibCommandCard.d.ts.map +1 -0
- package/lib/client/RefLibCommandCard.js +48 -0
- package/lib/client/RefLibCommandCard.js.map +1 -0
- package/lib/client/RefLibDock.d.ts.map +1 -1
- package/lib/client/RefLibDock.js +91 -15
- package/lib/client/RefLibDock.js.map +1 -1
- package/lib/client/RefLibPanel.d.ts.map +1 -1
- package/lib/client/RefLibPanel.js +7 -2
- package/lib/client/RefLibPanel.js.map +1 -1
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +8 -0
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +16 -0
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +20 -0
- package/lib/client/locales.js.map +1 -1
- package/lib/client/refresh-guard.d.ts +31 -0
- package/lib/client/refresh-guard.d.ts.map +1 -0
- package/lib/client/refresh-guard.js +38 -0
- package/lib/client/refresh-guard.js.map +1 -0
- package/lib/client/styles.d.ts.map +1 -1
- package/lib/client/styles.js +111 -0
- package/lib/client/styles.js.map +1 -1
- package/lib/client.js +911 -582
- package/lib/client.js.map +1 -1
- package/lib/logic.d.ts +16 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +19 -0
- package/lib/logic.js.map +1 -1
- package/lib/render.d.ts +6 -4
- package/lib/render.d.ts.map +1 -1
- package/lib/render.js +14 -7
- package/lib/render.js.map +1 -1
- package/lib/routes.d.ts.map +1 -1
- package/lib/routes.js +5 -1
- package/lib/routes.js.map +1 -1
- package/lib/service.d.ts +30 -2
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +71 -10
- package/lib/service.js.map +1 -1
- package/lib/spec.d.ts +9 -0
- package/lib/spec.d.ts.map +1 -1
- package/lib/validate.d.ts +1 -1
- package/lib/validate.d.ts.map +1 -1
- package/lib/validate.js +11 -3
- package/lib/validate.js.map +1 -1
- package/package.json +15 -15
package/lib/client.js
CHANGED
|
@@ -8,12 +8,21 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
//#region src/validate.ts
|
|
11
|
-
/**
|
|
11
|
+
/** 可用性字面量集合(status 字段合法值)。 */
|
|
12
|
+
const AVAILABILITY_VALUES = /* @__PURE__ */ new Set([
|
|
13
|
+
"available",
|
|
14
|
+
"missing",
|
|
15
|
+
"not-directory"
|
|
16
|
+
]);
|
|
17
|
+
/** 校验一个未知对象是否为合法条目(宽松:id/path 必填字符串,note/status/checkedAt 可选且类型正确)。 */
|
|
12
18
|
function isRefLibEntry(value) {
|
|
13
19
|
if (typeof value !== "object" || value === null) return false;
|
|
14
|
-
const { id, path, note } = value;
|
|
20
|
+
const { id, path, note, status, checkedAt } = value;
|
|
15
21
|
if (typeof id !== "string" || typeof path !== "string") return false;
|
|
16
|
-
|
|
22
|
+
if (note !== void 0 && typeof note !== "string") return false;
|
|
23
|
+
if (status !== void 0 && (typeof status !== "string" || !AVAILABILITY_VALUES.has(status))) return false;
|
|
24
|
+
if (checkedAt !== void 0 && (typeof checkedAt !== "number" || !Number.isFinite(checkedAt))) return false;
|
|
25
|
+
return true;
|
|
17
26
|
}
|
|
18
27
|
//#endregion
|
|
19
28
|
//#region src/client/data.ts
|
|
@@ -79,571 +88,18 @@ window.__ModuleLoader__.load({
|
|
|
79
88
|
return idx === -1 ? trimmed : trimmed.slice(idx + 1);
|
|
80
89
|
}
|
|
81
90
|
//#endregion
|
|
82
|
-
//#region src/client/
|
|
83
|
-
/**
|
|
84
|
-
* 应用内目录浏览器(browse 后端可用时,「选择目录」的落地实现)。
|
|
85
|
-
*
|
|
86
|
-
* 为什么需要它:v6 起 profile 把 directory-picker 从 -auto(本机解析为 native,
|
|
87
|
-
* OS 对话框硬编码英文且每次拉 osascript 进程)切换为 -browse 后,
|
|
88
|
-
* `host.pickDirectory`(native 专用 RPC)不再可用;本组件用 `listDirectory`
|
|
89
|
-
* (Node stdlib 列目录,zh/en 本地化、无 OS 进程)提供等价的目录选择:
|
|
90
|
-
* 面包屑 + 路径编辑 + 子目录列表,点击下行进入,「选择此目录」把当前层级添加为
|
|
91
|
-
* 参考库。简化为单列(与官方 DirectoryBrowser 的 Miller 双列相比),
|
|
92
|
-
* 但覆盖添加参考库的核心路径。
|
|
93
|
-
* @module @hpyperry/dsh-ref-lib/src/client/RefLibBrowser
|
|
94
|
-
*/
|
|
95
|
-
/** 面包屑展示:主目录子树内以本地化 Home 开头;之外显示完整祖先链。 */
|
|
96
|
-
function displayCrumbs(listing, homeLabel) {
|
|
97
|
-
const homeIndex = listing.crumbs.findIndex((crumb) => crumb.path === listing.home);
|
|
98
|
-
if (homeIndex === -1) return listing.crumbs;
|
|
99
|
-
const tail = listing.crumbs.slice(homeIndex + 1);
|
|
100
|
-
return [{
|
|
101
|
-
name: homeLabel,
|
|
102
|
-
path: listing.home,
|
|
103
|
-
hidden: false
|
|
104
|
-
}, ...tail];
|
|
105
|
-
}
|
|
106
|
-
/** 平台分隔符(由宿主主目录推断,绝不从键入文本推断)。 */
|
|
107
|
-
function separatorOf(listing) {
|
|
108
|
-
return listing.home.includes("\\") ? "\\" : "/";
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 渲染应用内目录浏览器。
|
|
112
|
-
* @param props - 见 {@link RefLibBrowserProps}。
|
|
113
|
-
* @returns 对话框元素(关闭时 Modal 返回 null)。
|
|
114
|
-
*/
|
|
115
|
-
function RefLibBrowser(props) {
|
|
116
|
-
const { open, onClose, listDirectory, t, onOpen } = props;
|
|
117
|
-
const [listing, setListing] = (0, react.useState)(null);
|
|
118
|
-
const [loading, setLoading] = (0, react.useState)(false);
|
|
119
|
-
const [error, setError] = (0, react.useState)(null);
|
|
120
|
-
const [pathDraft, setPathDraft] = (0, react.useState)(null);
|
|
121
|
-
const seq = (0, react.useRef)(0);
|
|
122
|
-
const controller = (0, react.useRef)(null);
|
|
123
|
-
const composing = (0, react.useRef)(false);
|
|
124
|
-
/** 新意图胜出:中止在途扫描并使旧结果失效。 */
|
|
125
|
-
const navigate = (target) => {
|
|
126
|
-
controller.current?.abort();
|
|
127
|
-
controller.current = null;
|
|
128
|
-
const mine = ++seq.current;
|
|
129
|
-
setLoading(true);
|
|
130
|
-
setError(null);
|
|
131
|
-
const ctrl = new AbortController();
|
|
132
|
-
controller.current = ctrl;
|
|
133
|
-
listDirectory(target, ctrl.signal).then((next) => {
|
|
134
|
-
if (mine !== seq.current) return;
|
|
135
|
-
setListing(next);
|
|
136
|
-
setLoading(false);
|
|
137
|
-
}, (cause) => {
|
|
138
|
-
if (mine !== seq.current) return;
|
|
139
|
-
setLoading(false);
|
|
140
|
-
setError(cause instanceof Error ? cause.message : String(cause));
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
(0, react.useEffect)(() => {
|
|
144
|
-
if (open) navigate();
|
|
145
|
-
else {
|
|
146
|
-
seq.current += 1;
|
|
147
|
-
controller.current?.abort();
|
|
148
|
-
controller.current = null;
|
|
149
|
-
setPathDraft(null);
|
|
150
|
-
setError(null);
|
|
151
|
-
}
|
|
152
|
-
}, [open]);
|
|
153
|
-
const openPathEditor = () => {
|
|
154
|
-
if (listing === null) {
|
|
155
|
-
setPathDraft("");
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const sep = separatorOf(listing);
|
|
159
|
-
const base = listing.path;
|
|
160
|
-
setPathDraft(base.endsWith(sep) ? base : base + sep);
|
|
161
|
-
};
|
|
162
|
-
const commitPath = () => {
|
|
163
|
-
const draft = pathDraft ?? "";
|
|
164
|
-
if (draft.trim() === "") return;
|
|
165
|
-
navigate(draft);
|
|
166
|
-
setPathDraft(null);
|
|
167
|
-
};
|
|
168
|
-
const crumbs = listing === null ? [] : displayCrumbs(listing, t("browser.home"));
|
|
169
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
170
|
-
open,
|
|
171
|
-
onClose,
|
|
172
|
-
title: t("browser.title"),
|
|
173
|
-
closeLabel: t("browser.cancel"),
|
|
174
|
-
className: "reflib-browser",
|
|
175
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
176
|
-
className: "reflib-panel",
|
|
177
|
-
children: [
|
|
178
|
-
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
179
|
-
className: "reflib-error",
|
|
180
|
-
role: "alert",
|
|
181
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
182
|
-
size: 14,
|
|
183
|
-
className: "reflib-errorIcon"
|
|
184
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: error })]
|
|
185
|
-
}),
|
|
186
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
187
|
-
className: "reflib-browserPath",
|
|
188
|
-
children: pathDraft === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
189
|
-
className: "reflib-browserCrumbs",
|
|
190
|
-
role: "navigation",
|
|
191
|
-
children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
192
|
-
className: "reflib-browserCrumb",
|
|
193
|
-
children: [index > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, {
|
|
194
|
-
size: 12,
|
|
195
|
-
className: "reflib-browserCrumbChevron"
|
|
196
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
197
|
-
type: "button",
|
|
198
|
-
className: "reflib-browserCrumbBtn",
|
|
199
|
-
disabled: loading,
|
|
200
|
-
onClick: () => {
|
|
201
|
-
navigate(crumb.path);
|
|
202
|
-
},
|
|
203
|
-
children: crumb.name
|
|
204
|
-
})]
|
|
205
|
-
}, crumb.path))
|
|
206
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
207
|
-
type: "button",
|
|
208
|
-
className: "reflib-browserEdit",
|
|
209
|
-
"aria-label": t("browser.editPath"),
|
|
210
|
-
title: t("browser.editPath"),
|
|
211
|
-
disabled: loading,
|
|
212
|
-
onClick: openPathEditor,
|
|
213
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, { size: 14 })
|
|
214
|
-
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
215
|
-
className: "reflib-browserInput",
|
|
216
|
-
value: pathDraft,
|
|
217
|
-
"aria-label": t("browser.editPath"),
|
|
218
|
-
placeholder: t("browser.pathPlaceholder"),
|
|
219
|
-
autoFocus: true,
|
|
220
|
-
disabled: loading,
|
|
221
|
-
onChange: (event) => {
|
|
222
|
-
setPathDraft(event.currentTarget.value);
|
|
223
|
-
},
|
|
224
|
-
onCompositionStart: () => {
|
|
225
|
-
composing.current = true;
|
|
226
|
-
},
|
|
227
|
-
onCompositionEnd: () => {
|
|
228
|
-
composing.current = false;
|
|
229
|
-
},
|
|
230
|
-
onKeyDown: (event) => {
|
|
231
|
-
if (event.key === "Enter" && !composing.current) {
|
|
232
|
-
event.preventDefault();
|
|
233
|
-
commitPath();
|
|
234
|
-
}
|
|
235
|
-
if (event.key === "Escape") {
|
|
236
|
-
event.stopPropagation();
|
|
237
|
-
setPathDraft(null);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
}),
|
|
242
|
-
loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
243
|
-
className: "reflib-status",
|
|
244
|
-
role: "status",
|
|
245
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
246
|
-
size: 20,
|
|
247
|
-
className: "reflib-spin reflib-statusIcon"
|
|
248
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
249
|
-
className: "reflib-statusText",
|
|
250
|
-
children: t("browser.loading")
|
|
251
|
-
})]
|
|
252
|
-
}) : listing !== null && listing.entries.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
253
|
-
className: "reflib-status",
|
|
254
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
255
|
-
size: 22,
|
|
256
|
-
className: "reflib-statusIcon"
|
|
257
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
258
|
-
className: "reflib-statusText",
|
|
259
|
-
children: t("browser.empty")
|
|
260
|
-
})]
|
|
261
|
-
}) : listing !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
262
|
-
className: "reflib-browserList",
|
|
263
|
-
children: listing.entries.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
264
|
-
type: "button",
|
|
265
|
-
className: "reflib-browserRow",
|
|
266
|
-
"aria-label": t("browser.enter.aria", { name: entry.name }),
|
|
267
|
-
disabled: loading,
|
|
268
|
-
onClick: () => {
|
|
269
|
-
navigate(entry.path);
|
|
270
|
-
},
|
|
271
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, {
|
|
272
|
-
size: 16,
|
|
273
|
-
className: "reflib-browserRowIcon"
|
|
274
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
275
|
-
className: "reflib-browserRowName",
|
|
276
|
-
children: entry.name
|
|
277
|
-
})]
|
|
278
|
-
}, entry.path))
|
|
279
|
-
}),
|
|
280
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "reflib-divider" }),
|
|
281
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
282
|
-
className: "reflib-browserFooter",
|
|
283
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
284
|
-
variant: "outline",
|
|
285
|
-
size: "sm",
|
|
286
|
-
disabled: loading,
|
|
287
|
-
onClick: onClose,
|
|
288
|
-
children: t("browser.cancel")
|
|
289
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
290
|
-
variant: "primary",
|
|
291
|
-
size: "sm",
|
|
292
|
-
disabled: loading || listing === null,
|
|
293
|
-
"aria-label": t("browser.open.aria"),
|
|
294
|
-
onClick: () => {
|
|
295
|
-
if (listing !== null) onOpen(listing.path);
|
|
296
|
-
},
|
|
297
|
-
children: t("browser.open")
|
|
298
|
-
})]
|
|
299
|
-
})
|
|
300
|
-
]
|
|
301
|
-
})
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region src/client/RefLibPanel.tsx
|
|
91
|
+
//#region src/client/styles.ts
|
|
306
92
|
/**
|
|
307
|
-
*
|
|
93
|
+
* ref-lib client 样式注入:在文档头挂一张本插件专属的 <style data-plugin> 标签。
|
|
308
94
|
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const NOTE_MAX_LENGTH = 120;
|
|
318
|
-
/**
|
|
319
|
-
* 渲染参考库管理面板。
|
|
320
|
-
* @param props - 见 {@link RefLibPanelProps}。
|
|
321
|
-
* @returns 对话框元素(关闭时 Modal 返回 null)。
|
|
322
|
-
*/
|
|
323
|
-
function RefLibPanel(props) {
|
|
324
|
-
const { open, onClose, libs, loading, busy, picking, removingId, error, t, onRemove, onAddPath, onUpdateNote, onBrowse } = props;
|
|
325
|
-
const [draft, setDraft] = (0, react.useState)("");
|
|
326
|
-
const [noteDraft, setNoteDraft] = (0, react.useState)("");
|
|
327
|
-
const [detailId, setDetailId] = (0, react.useState)(null);
|
|
328
|
-
const [editNote, setEditNote] = (0, react.useState)("");
|
|
329
|
-
(0, react.useEffect)(() => {
|
|
330
|
-
if (!open) {
|
|
331
|
-
setDraft("");
|
|
332
|
-
setNoteDraft("");
|
|
333
|
-
setDetailId(null);
|
|
334
|
-
}
|
|
335
|
-
}, [open]);
|
|
336
|
-
const handleSubmit = async () => {
|
|
337
|
-
const trimmed = draft.trim();
|
|
338
|
-
if (trimmed === "") return;
|
|
339
|
-
try {
|
|
340
|
-
const note = noteDraft.trim();
|
|
341
|
-
await onAddPath(trimmed, note === "" ? void 0 : note);
|
|
342
|
-
setDraft("");
|
|
343
|
-
setNoteDraft("");
|
|
344
|
-
} catch {}
|
|
345
|
-
};
|
|
346
|
-
/** 浏览选中目录 → 填入路径字段(不直接添加,用户可补用途后提交)。 */
|
|
347
|
-
const handleBrowse = async () => {
|
|
348
|
-
const path = await onBrowse();
|
|
349
|
-
if (path !== null) setDraft(path);
|
|
350
|
-
};
|
|
351
|
-
/** 展开/收起条目详情;展开时载入当前用途草稿。 */
|
|
352
|
-
const toggleDetail = (entry) => {
|
|
353
|
-
if (detailId === entry.id) {
|
|
354
|
-
setDetailId(null);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
setDetailId(entry.id);
|
|
358
|
-
setEditNote(entry.note ?? "");
|
|
359
|
-
};
|
|
360
|
-
/** 保存详情编辑的用途说明;成功后收起详情。 */
|
|
361
|
-
const handleSaveNote = async () => {
|
|
362
|
-
if (detailId === null) return;
|
|
363
|
-
await onUpdateNote(detailId, editNote);
|
|
364
|
-
setDetailId(null);
|
|
365
|
-
};
|
|
366
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
367
|
-
open,
|
|
368
|
-
onClose,
|
|
369
|
-
title: t("panel.title"),
|
|
370
|
-
closeLabel: t("panel.close"),
|
|
371
|
-
description: t("panel.description", { count: String(libs.length) }),
|
|
372
|
-
className: "reflib-modal",
|
|
373
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
374
|
-
className: "reflib-panel",
|
|
375
|
-
children: [
|
|
376
|
-
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
377
|
-
className: "reflib-error",
|
|
378
|
-
role: "alert",
|
|
379
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
380
|
-
size: 14,
|
|
381
|
-
className: "reflib-errorIcon"
|
|
382
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: error })]
|
|
383
|
-
}),
|
|
384
|
-
loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
385
|
-
className: "reflib-status",
|
|
386
|
-
role: "status",
|
|
387
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
388
|
-
size: 20,
|
|
389
|
-
className: "reflib-spin reflib-statusIcon"
|
|
390
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
391
|
-
className: "reflib-statusText",
|
|
392
|
-
children: t("list.loading")
|
|
393
|
-
})]
|
|
394
|
-
}) : libs.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
395
|
-
className: "reflib-status",
|
|
396
|
-
children: [
|
|
397
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
398
|
-
size: 22,
|
|
399
|
-
className: "reflib-statusIcon"
|
|
400
|
-
}),
|
|
401
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
402
|
-
className: "reflib-statusText",
|
|
403
|
-
children: t("list.empty")
|
|
404
|
-
}),
|
|
405
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
406
|
-
className: "reflib-statusHint",
|
|
407
|
-
children: t("list.empty.hint")
|
|
408
|
-
})
|
|
409
|
-
]
|
|
410
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
411
|
-
className: "reflib-list",
|
|
412
|
-
children: libs.map((entry) => {
|
|
413
|
-
const name = libBasename(entry.path);
|
|
414
|
-
const removing = removingId === entry.id;
|
|
415
|
-
const detailOpen = detailId === entry.id;
|
|
416
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
417
|
-
className: "reflib-listItem",
|
|
418
|
-
"data-removing": removing || void 0,
|
|
419
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
420
|
-
className: "reflib-row",
|
|
421
|
-
children: [
|
|
422
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
423
|
-
size: 16,
|
|
424
|
-
className: "reflib-rowIcon"
|
|
425
|
-
}),
|
|
426
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
427
|
-
className: "reflib-rowBody",
|
|
428
|
-
children: [
|
|
429
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
430
|
-
className: "reflib-rowName",
|
|
431
|
-
title: entry.path,
|
|
432
|
-
children: name
|
|
433
|
-
}),
|
|
434
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
435
|
-
className: "reflib-rowPath",
|
|
436
|
-
title: entry.path,
|
|
437
|
-
children: entry.path
|
|
438
|
-
}),
|
|
439
|
-
entry.note !== void 0 && entry.note !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
440
|
-
className: "reflib-rowNote",
|
|
441
|
-
title: entry.note,
|
|
442
|
-
children: entry.note.replace(/\s+/g, " ")
|
|
443
|
-
})
|
|
444
|
-
]
|
|
445
|
-
}),
|
|
446
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
447
|
-
label: t("detail.open"),
|
|
448
|
-
side: "top",
|
|
449
|
-
delayMs: 400,
|
|
450
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
451
|
-
type: "button",
|
|
452
|
-
className: "reflib-rowAction",
|
|
453
|
-
"aria-label": t("detail.open.aria", { name }),
|
|
454
|
-
"aria-expanded": detailOpen || void 0,
|
|
455
|
-
disabled: busy || removingId !== null,
|
|
456
|
-
onClick: () => {
|
|
457
|
-
toggleDetail(entry);
|
|
458
|
-
},
|
|
459
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, { size: 14 })
|
|
460
|
-
})
|
|
461
|
-
}),
|
|
462
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
463
|
-
label: t("list.remove"),
|
|
464
|
-
side: "top",
|
|
465
|
-
delayMs: 400,
|
|
466
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
467
|
-
type: "button",
|
|
468
|
-
className: "reflib-rowRemove",
|
|
469
|
-
"aria-label": t("list.remove.aria", { name }),
|
|
470
|
-
disabled: busy || removingId !== null,
|
|
471
|
-
onClick: () => {
|
|
472
|
-
onRemove(entry.id);
|
|
473
|
-
},
|
|
474
|
-
children: removing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
475
|
-
size: 14,
|
|
476
|
-
className: "reflib-spin"
|
|
477
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 })
|
|
478
|
-
})
|
|
479
|
-
})
|
|
480
|
-
]
|
|
481
|
-
}), detailOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
482
|
-
className: "reflib-detail",
|
|
483
|
-
children: [
|
|
484
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
485
|
-
className: "reflib-detailMeta",
|
|
486
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
487
|
-
className: "reflib-detailKey",
|
|
488
|
-
children: "ID"
|
|
489
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
490
|
-
className: "reflib-detailValue",
|
|
491
|
-
children: entry.id
|
|
492
|
-
})]
|
|
493
|
-
}),
|
|
494
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
495
|
-
className: "reflib-detailMeta",
|
|
496
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
497
|
-
className: "reflib-detailKey",
|
|
498
|
-
children: t("detail.path")
|
|
499
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
500
|
-
className: "reflib-detailValue",
|
|
501
|
-
title: entry.path,
|
|
502
|
-
children: entry.path
|
|
503
|
-
})]
|
|
504
|
-
}),
|
|
505
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
506
|
-
className: "reflib-detailKey",
|
|
507
|
-
children: t("add.note.label")
|
|
508
|
-
}),
|
|
509
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
510
|
-
className: "reflib-noteWrap",
|
|
511
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
512
|
-
className: "reflib-noteTextarea",
|
|
513
|
-
value: editNote,
|
|
514
|
-
placeholder: t("add.note.placeholder"),
|
|
515
|
-
"aria-label": t("add.note.label"),
|
|
516
|
-
disabled: busy,
|
|
517
|
-
rows: 3,
|
|
518
|
-
maxLength: NOTE_MAX_LENGTH,
|
|
519
|
-
onChange: (event) => {
|
|
520
|
-
setEditNote(event.currentTarget.value);
|
|
521
|
-
}
|
|
522
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
523
|
-
className: "reflib-noteCount",
|
|
524
|
-
children: [
|
|
525
|
-
editNote.length,
|
|
526
|
-
"/",
|
|
527
|
-
NOTE_MAX_LENGTH
|
|
528
|
-
]
|
|
529
|
-
})]
|
|
530
|
-
}),
|
|
531
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
532
|
-
className: "reflib-detailActions",
|
|
533
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
534
|
-
variant: "ghost",
|
|
535
|
-
size: "sm",
|
|
536
|
-
disabled: busy,
|
|
537
|
-
onClick: () => {
|
|
538
|
-
setDetailId(null);
|
|
539
|
-
},
|
|
540
|
-
children: t("detail.cancel")
|
|
541
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
542
|
-
variant: "primary",
|
|
543
|
-
size: "sm",
|
|
544
|
-
disabled: busy,
|
|
545
|
-
onClick: () => {
|
|
546
|
-
handleSaveNote();
|
|
547
|
-
},
|
|
548
|
-
children: t("detail.save")
|
|
549
|
-
})]
|
|
550
|
-
})
|
|
551
|
-
]
|
|
552
|
-
})]
|
|
553
|
-
}, entry.id);
|
|
554
|
-
})
|
|
555
|
-
}),
|
|
556
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "reflib-divider" }),
|
|
557
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
558
|
-
className: "reflib-add",
|
|
559
|
-
children: [
|
|
560
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
561
|
-
className: "reflib-addLabel",
|
|
562
|
-
children: t("add.label")
|
|
563
|
-
}),
|
|
564
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
565
|
-
className: "reflib-addRow",
|
|
566
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
567
|
-
className: "reflib-addInputWrap",
|
|
568
|
-
value: draft,
|
|
569
|
-
placeholder: t("add.placeholder"),
|
|
570
|
-
"aria-label": t("add.label"),
|
|
571
|
-
disabled: busy || picking,
|
|
572
|
-
onChange: (event) => {
|
|
573
|
-
setDraft(event.currentTarget.value);
|
|
574
|
-
},
|
|
575
|
-
onKeyDown: (event) => {
|
|
576
|
-
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
577
|
-
event.preventDefault();
|
|
578
|
-
handleSubmit();
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
582
|
-
variant: "outline",
|
|
583
|
-
size: "sm",
|
|
584
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: 14 }),
|
|
585
|
-
disabled: busy || picking,
|
|
586
|
-
onClick: () => {
|
|
587
|
-
handleBrowse();
|
|
588
|
-
},
|
|
589
|
-
children: t("add.browse")
|
|
590
|
-
})]
|
|
591
|
-
}),
|
|
592
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
593
|
-
className: "reflib-noteWrap",
|
|
594
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
595
|
-
className: "reflib-noteTextarea",
|
|
596
|
-
value: noteDraft,
|
|
597
|
-
placeholder: t("add.note.placeholder"),
|
|
598
|
-
"aria-label": t("add.note.label"),
|
|
599
|
-
disabled: busy || picking,
|
|
600
|
-
rows: 2,
|
|
601
|
-
maxLength: NOTE_MAX_LENGTH,
|
|
602
|
-
onChange: (event) => {
|
|
603
|
-
setNoteDraft(event.currentTarget.value);
|
|
604
|
-
}
|
|
605
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
606
|
-
className: "reflib-noteCount",
|
|
607
|
-
children: [
|
|
608
|
-
noteDraft.length,
|
|
609
|
-
"/",
|
|
610
|
-
NOTE_MAX_LENGTH
|
|
611
|
-
]
|
|
612
|
-
})]
|
|
613
|
-
}),
|
|
614
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
615
|
-
variant: "primary",
|
|
616
|
-
className: "reflib-addSubmit",
|
|
617
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }),
|
|
618
|
-
disabled: busy || picking || draft.trim() === "",
|
|
619
|
-
onClick: () => {
|
|
620
|
-
handleSubmit();
|
|
621
|
-
},
|
|
622
|
-
children: t("add.submit")
|
|
623
|
-
}),
|
|
624
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
625
|
-
className: "reflib-addHint",
|
|
626
|
-
children: t("add.hint")
|
|
627
|
-
})
|
|
628
|
-
]
|
|
629
|
-
})
|
|
630
|
-
]
|
|
631
|
-
})
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region src/client/styles.ts
|
|
636
|
-
/**
|
|
637
|
-
* ref-lib client 样式注入:在文档头挂一张本插件专属的 <style data-plugin> 标签。
|
|
638
|
-
*
|
|
639
|
-
* 为什么不用 CSS Modules:ref-lib 的 tsdown 配置未移植 core 的 lightningcss
|
|
640
|
-
* CSS-Modules 插件(避免新增 native 依赖与构建面),而内联 style 无法表达
|
|
641
|
-
* hover/媒体查询/动画。因此采用运行时注入单张样式表——与 loader 的清理契约
|
|
642
|
-
* 兼容(`data-plugin` 标签在插件卸载/HMR 时由 loader 移除,重新物化时本模块
|
|
643
|
-
* 重新注入,幂等)。类名统一 `reflib-` 前缀防碰撞;颜色/字号/圆角全部走
|
|
644
|
-
* `--dsw-*` 设计令牌,随主题(浅色/深色)自动适配——这是"字体显示不一致、
|
|
645
|
-
* 没有设计感"的根因修复之一(旧实现硬编码 #d33 等,不随主题变化)。
|
|
646
|
-
* @module @hpyperry/dsh-ref-lib/src/client/styles
|
|
95
|
+
* 为什么不用 CSS Modules:ref-lib 的 tsdown 配置未移植 core 的 lightningcss
|
|
96
|
+
* CSS-Modules 插件(避免新增 native 依赖与构建面),而内联 style 无法表达
|
|
97
|
+
* hover/媒体查询/动画。因此采用运行时注入单张样式表——与 loader 的清理契约
|
|
98
|
+
* 兼容(`data-plugin` 标签在插件卸载/HMR 时由 loader 移除,重新物化时本模块
|
|
99
|
+
* 重新注入,幂等)。类名统一 `reflib-` 前缀防碰撞;颜色/字号/圆角全部走
|
|
100
|
+
* `--dsw-*` 设计令牌,随主题(浅色/深色)自动适配——这是"字体显示不一致、
|
|
101
|
+
* 没有设计感"的根因修复之一(旧实现硬编码 #d33 等,不随主题变化)。
|
|
102
|
+
* @module @hpyperry/dsh-ref-lib/src/client/styles
|
|
647
103
|
*/
|
|
648
104
|
/** 插件 id(与 package.json 的 bundle 手递一致,loader 按它清理样式)。 */
|
|
649
105
|
const PLUGIN_ID = "@hpyperry/dsh-ref-lib";
|
|
@@ -727,6 +183,22 @@ window.__ModuleLoader__.load({
|
|
|
727
183
|
font-weight: 500;
|
|
728
184
|
}
|
|
729
185
|
|
|
186
|
+
/* 失效条目计数角标(v9):红色系,与普通数量徽标区分。 */
|
|
187
|
+
.reflib-chipWarn {
|
|
188
|
+
display: inline-flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
justify-content: center;
|
|
191
|
+
min-width: 18px;
|
|
192
|
+
height: 18px;
|
|
193
|
+
padding: 0 5px;
|
|
194
|
+
border-radius: 9px;
|
|
195
|
+
background: var(--dsw-alias-state-error-primary);
|
|
196
|
+
color: #fff;
|
|
197
|
+
font-size: 11px;
|
|
198
|
+
line-height: 18px;
|
|
199
|
+
font-weight: 500;
|
|
200
|
+
}
|
|
201
|
+
|
|
730
202
|
/* ── 应用内目录浏览器(browse 后端)── */
|
|
731
203
|
.reflib-browser {
|
|
732
204
|
width: min(460px, 100%);
|
|
@@ -942,6 +414,11 @@ window.__ModuleLoader__.load({
|
|
|
942
414
|
color: var(--dsw-alias-label-tertiary);
|
|
943
415
|
}
|
|
944
416
|
|
|
417
|
+
/* 失效条目行图标(v9):警示色。 */
|
|
418
|
+
.reflib-rowIconWarn {
|
|
419
|
+
color: var(--dsw-alias-state-error-primary);
|
|
420
|
+
}
|
|
421
|
+
|
|
945
422
|
.reflib-rowBody {
|
|
946
423
|
display: flex;
|
|
947
424
|
flex: 1;
|
|
@@ -980,6 +457,16 @@ window.__ModuleLoader__.load({
|
|
|
980
457
|
white-space: nowrap;
|
|
981
458
|
}
|
|
982
459
|
|
|
460
|
+
/* 失效条目状态行(v9):红色警示文案,位于路径之下 */
|
|
461
|
+
.reflib-rowStatus {
|
|
462
|
+
overflow: hidden;
|
|
463
|
+
color: var(--dsw-alias-state-error-primary);
|
|
464
|
+
font-size: 12px;
|
|
465
|
+
line-height: 16px;
|
|
466
|
+
text-overflow: ellipsis;
|
|
467
|
+
white-space: nowrap;
|
|
468
|
+
}
|
|
469
|
+
|
|
983
470
|
.reflib-rowRemove {
|
|
984
471
|
display: inline-flex;
|
|
985
472
|
align-items: center;
|
|
@@ -1253,6 +740,86 @@ window.__ModuleLoader__.load({
|
|
|
1253
740
|
color: var(--dsw-alias-label-caption);
|
|
1254
741
|
}
|
|
1255
742
|
|
|
743
|
+
/* ── /ref-lib 命令结果卡片(conversation.chat.commandview)── */
|
|
744
|
+
.reflib-cmd {
|
|
745
|
+
display: flex;
|
|
746
|
+
flex-direction: column;
|
|
747
|
+
gap: 6px;
|
|
748
|
+
min-width: 0;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.reflib-cmdHead {
|
|
752
|
+
display: flex;
|
|
753
|
+
align-items: center;
|
|
754
|
+
gap: 8px;
|
|
755
|
+
min-width: 0;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.reflib-cmdHeadIcon {
|
|
759
|
+
flex: none;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.reflib-cmdName {
|
|
763
|
+
flex: none;
|
|
764
|
+
color: var(--dsw-alias-label-primary);
|
|
765
|
+
font-size: 14px;
|
|
766
|
+
line-height: 20px;
|
|
767
|
+
font-weight: 500;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/* 摘要行 = 结果首行;过长单行省略(完整结果见下方 body) */
|
|
771
|
+
.reflib-cmdSummary {
|
|
772
|
+
min-width: 0;
|
|
773
|
+
flex: 1 1 auto;
|
|
774
|
+
overflow: hidden;
|
|
775
|
+
color: var(--dsw-alias-label-tertiary);
|
|
776
|
+
font-size: 13px;
|
|
777
|
+
line-height: 20px;
|
|
778
|
+
text-overflow: ellipsis;
|
|
779
|
+
white-space: nowrap;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.reflib-cmdSummary[data-error] {
|
|
783
|
+
color: var(--dsw-alias-state-error-primary);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.reflib-cmdCopy {
|
|
787
|
+
flex: none;
|
|
788
|
+
display: inline-flex;
|
|
789
|
+
align-items: center;
|
|
790
|
+
gap: 4px;
|
|
791
|
+
padding: 2px 8px;
|
|
792
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
793
|
+
border-radius: 6px;
|
|
794
|
+
background: transparent;
|
|
795
|
+
color: var(--dsw-alias-label-secondary);
|
|
796
|
+
font-size: 12px;
|
|
797
|
+
line-height: 18px;
|
|
798
|
+
cursor: pointer;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.reflib-cmdCopy:hover {
|
|
802
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/* 完整结果:默认全展开(无 max-height 截断),超宽自动换行 */
|
|
806
|
+
.reflib-cmdBody {
|
|
807
|
+
margin: 0;
|
|
808
|
+
padding: 10px 14px;
|
|
809
|
+
overflow: auto;
|
|
810
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
811
|
+
border-radius: 10px;
|
|
812
|
+
background: var(--dsw-alias-markdown-code-block);
|
|
813
|
+
color: var(--dsw-alias-label-primary);
|
|
814
|
+
font: var(--dsw-font-markdown-code-block-small);
|
|
815
|
+
white-space: pre-wrap;
|
|
816
|
+
word-break: break-word;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
.reflib-cmdBody[data-error] {
|
|
820
|
+
color: var(--dsw-alias-state-error-primary);
|
|
821
|
+
}
|
|
822
|
+
|
|
1256
823
|
/* 窄视口:路径行换行,输入框占满一行 */
|
|
1257
824
|
@media (max-width: 440px) {
|
|
1258
825
|
.reflib-addRow {
|
|
@@ -1279,6 +846,688 @@ window.__ModuleLoader__.load({
|
|
|
1279
846
|
document.head.appendChild(tag);
|
|
1280
847
|
}
|
|
1281
848
|
//#endregion
|
|
849
|
+
//#region src/client/RefLibCommandCard.tsx
|
|
850
|
+
/**
|
|
851
|
+
* `/ref-lib` 命令结果专属卡片(conversation.chat.commandview,key='ref-lib')。
|
|
852
|
+
*
|
|
853
|
+
* 背景(历史 bug):官方 `GenericCommandCard` 对命令结果折叠态 `white-space:
|
|
854
|
+
* nowrap` + `text-overflow: ellipsis` 单行截断,展开态 `max-height: 260px` 内滚动
|
|
855
|
+
* ——`/ref-lib list` 等多行长结果会显示不全。本卡片注册在
|
|
856
|
+
* `conversation.chat.commandview`(keyed,按命令名分派)的 `ref-lib` 键上:
|
|
857
|
+
* **默认全展开展示完整结果**(无高度上限)+ 一键复制按钮。只影响 `/ref-lib`,
|
|
858
|
+
* 其他命令仍走官方卡片。
|
|
859
|
+
* @module @hpyperry/dsh-ref-lib/src/client/RefLibCommandCard
|
|
860
|
+
*/
|
|
861
|
+
ensureRefLibStyles();
|
|
862
|
+
/**
|
|
863
|
+
* `/ref-lib` 命令结果卡片:完整展示 `outcome.text`(pre-wrap、无高度截断)+
|
|
864
|
+
* 复制按钮。running 态显示执行中;error 态红色。
|
|
865
|
+
* @param props - node(owner)与本地化 seat。
|
|
866
|
+
* @returns 卡片元素。
|
|
867
|
+
*/
|
|
868
|
+
function RefLibCommandCard(props) {
|
|
869
|
+
const { node, t } = props;
|
|
870
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
871
|
+
const outcome = node.outcome;
|
|
872
|
+
const text = outcome?.text;
|
|
873
|
+
const running = outcome === null;
|
|
874
|
+
const error = outcome?.kind === "error";
|
|
875
|
+
/** 复制完整结果到剪贴板;成功后短暂显示"已复制"(权限失败静默)。 */
|
|
876
|
+
const copy = async () => {
|
|
877
|
+
if (text === void 0 || text === "") return;
|
|
878
|
+
try {
|
|
879
|
+
await navigator.clipboard.writeText(text);
|
|
880
|
+
setCopied(true);
|
|
881
|
+
window.setTimeout(() => {
|
|
882
|
+
setCopied(false);
|
|
883
|
+
}, 1500);
|
|
884
|
+
} catch {}
|
|
885
|
+
};
|
|
886
|
+
const summary = running ? t("command.running") : text !== void 0 && text !== "" ? text.split("\n")[0] : t("command.done");
|
|
887
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
888
|
+
className: "reflib-cmd",
|
|
889
|
+
"data-state": running ? "running" : error ? "error" : "ok",
|
|
890
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
891
|
+
className: "reflib-cmdHead",
|
|
892
|
+
children: [
|
|
893
|
+
running && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
894
|
+
size: 14,
|
|
895
|
+
className: "reflib-spin reflib-cmdHeadIcon"
|
|
896
|
+
}),
|
|
897
|
+
!running && error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
898
|
+
size: 14,
|
|
899
|
+
className: "reflib-cmdHeadIcon"
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
902
|
+
className: "reflib-cmdName",
|
|
903
|
+
children: "/ref-lib"
|
|
904
|
+
}),
|
|
905
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
906
|
+
className: "reflib-cmdSummary",
|
|
907
|
+
"data-error": error || void 0,
|
|
908
|
+
children: summary
|
|
909
|
+
}),
|
|
910
|
+
!running && text !== void 0 && text !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
911
|
+
type: "button",
|
|
912
|
+
className: "reflib-cmdCopy",
|
|
913
|
+
"aria-label": t("command.copy"),
|
|
914
|
+
title: t("command.copy"),
|
|
915
|
+
onClick: () => {
|
|
916
|
+
copy();
|
|
917
|
+
},
|
|
918
|
+
children: [copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCopyOutline16, { size: 14 }), copied ? t("command.copied") : t("command.copy")]
|
|
919
|
+
})
|
|
920
|
+
]
|
|
921
|
+
}), !running && text !== void 0 && text !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
922
|
+
className: "reflib-cmdBody",
|
|
923
|
+
"data-error": error || void 0,
|
|
924
|
+
children: text
|
|
925
|
+
})]
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region src/client/refresh-guard.ts
|
|
930
|
+
/**
|
|
931
|
+
* 并发读守卫(竞态控制核心):只接受"最后发起"的请求结果。
|
|
932
|
+
*
|
|
933
|
+
* RefLibDock 有多个并发"拉取列表"来源——挂载预载、打开面板、30s 轮询、操作后的
|
|
934
|
+
* 刷新——网络返回顺序不保证,旧快照可能覆盖新快照。守卫用递增编号标记每次发起:
|
|
935
|
+
* 返回时只有仍持有**最新编号**的请求结果才被应用,其余一律丢弃。
|
|
936
|
+
*
|
|
937
|
+
* 为什么"最后发起"就代表最新:`list` 返回的是请求发起时刻的服务端快照,发起越晚
|
|
938
|
+
* 快照越新,所以只信最后发起者 ≈ 只信最新快照。操作后的刷新总是最后发起(操作
|
|
939
|
+
* 完成后才发起),天然胜出;响应乱序时旧号被丢弃,最终一致。
|
|
940
|
+
*
|
|
941
|
+
* 纯 TS、零依赖、零 DOM——node 环境可直接单元测试(tests/refresh-guard.spec.ts)。
|
|
942
|
+
* @module @hpyperry/dsh-ref-lib/src/client/refresh-guard
|
|
943
|
+
*/
|
|
944
|
+
var RefreshGuard = class {
|
|
945
|
+
seq = 0;
|
|
946
|
+
/** 发起一次请求,返回本次请求的编号。 */
|
|
947
|
+
begin() {
|
|
948
|
+
this.seq += 1;
|
|
949
|
+
return this.seq;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* 该编号是否仍是最新发起者。
|
|
953
|
+
* @param mine - 发起时 {@link begin} 返回的编号。
|
|
954
|
+
* @returns true 表示应应用该请求的结果;false 表示期间又有新请求发起,结果已过期。
|
|
955
|
+
*/
|
|
956
|
+
isLatest(mine) {
|
|
957
|
+
return mine === this.seq;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* 作废所有 in-flight 请求的结果(会话切换 / 组件卸载时调用):seq 递增后,
|
|
961
|
+
* 任何旧编号的 {@link isLatest} 都返回 false。
|
|
962
|
+
*/
|
|
963
|
+
invalidate() {
|
|
964
|
+
this.seq += 1;
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/client/RefLibBrowser.tsx
|
|
969
|
+
/**
|
|
970
|
+
* 应用内目录浏览器(browse 后端可用时,「选择目录」的落地实现)。
|
|
971
|
+
*
|
|
972
|
+
* 为什么需要它:v6 起 profile 把 directory-picker 从 -auto(本机解析为 native,
|
|
973
|
+
* OS 对话框硬编码英文且每次拉 osascript 进程)切换为 -browse 后,
|
|
974
|
+
* `host.pickDirectory`(native 专用 RPC)不再可用;本组件用 `listDirectory`
|
|
975
|
+
* (Node stdlib 列目录,zh/en 本地化、无 OS 进程)提供等价的目录选择:
|
|
976
|
+
* 面包屑 + 路径编辑 + 子目录列表,点击下行进入,「选择此目录」把当前层级添加为
|
|
977
|
+
* 参考库。简化为单列(与官方 DirectoryBrowser 的 Miller 双列相比),
|
|
978
|
+
* 但覆盖添加参考库的核心路径。
|
|
979
|
+
* @module @hpyperry/dsh-ref-lib/src/client/RefLibBrowser
|
|
980
|
+
*/
|
|
981
|
+
/** 面包屑展示:主目录子树内以本地化 Home 开头;之外显示完整祖先链。 */
|
|
982
|
+
function displayCrumbs(listing, homeLabel) {
|
|
983
|
+
const homeIndex = listing.crumbs.findIndex((crumb) => crumb.path === listing.home);
|
|
984
|
+
if (homeIndex === -1) return listing.crumbs;
|
|
985
|
+
const tail = listing.crumbs.slice(homeIndex + 1);
|
|
986
|
+
return [{
|
|
987
|
+
name: homeLabel,
|
|
988
|
+
path: listing.home,
|
|
989
|
+
hidden: false
|
|
990
|
+
}, ...tail];
|
|
991
|
+
}
|
|
992
|
+
/** 平台分隔符(由宿主主目录推断,绝不从键入文本推断)。 */
|
|
993
|
+
function separatorOf(listing) {
|
|
994
|
+
return listing.home.includes("\\") ? "\\" : "/";
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* 渲染应用内目录浏览器。
|
|
998
|
+
* @param props - 见 {@link RefLibBrowserProps}。
|
|
999
|
+
* @returns 对话框元素(关闭时 Modal 返回 null)。
|
|
1000
|
+
*/
|
|
1001
|
+
function RefLibBrowser(props) {
|
|
1002
|
+
const { open, onClose, listDirectory, t, onOpen } = props;
|
|
1003
|
+
const [listing, setListing] = (0, react.useState)(null);
|
|
1004
|
+
const [loading, setLoading] = (0, react.useState)(false);
|
|
1005
|
+
const [error, setError] = (0, react.useState)(null);
|
|
1006
|
+
const [pathDraft, setPathDraft] = (0, react.useState)(null);
|
|
1007
|
+
const seq = (0, react.useRef)(0);
|
|
1008
|
+
const controller = (0, react.useRef)(null);
|
|
1009
|
+
const composing = (0, react.useRef)(false);
|
|
1010
|
+
/** 新意图胜出:中止在途扫描并使旧结果失效。 */
|
|
1011
|
+
const navigate = (target) => {
|
|
1012
|
+
controller.current?.abort();
|
|
1013
|
+
controller.current = null;
|
|
1014
|
+
const mine = ++seq.current;
|
|
1015
|
+
setLoading(true);
|
|
1016
|
+
setError(null);
|
|
1017
|
+
const ctrl = new AbortController();
|
|
1018
|
+
controller.current = ctrl;
|
|
1019
|
+
listDirectory(target, ctrl.signal).then((next) => {
|
|
1020
|
+
if (mine !== seq.current) return;
|
|
1021
|
+
setListing(next);
|
|
1022
|
+
setLoading(false);
|
|
1023
|
+
}, (cause) => {
|
|
1024
|
+
if (mine !== seq.current) return;
|
|
1025
|
+
setLoading(false);
|
|
1026
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
(0, react.useEffect)(() => {
|
|
1030
|
+
if (open) navigate();
|
|
1031
|
+
else {
|
|
1032
|
+
seq.current += 1;
|
|
1033
|
+
controller.current?.abort();
|
|
1034
|
+
controller.current = null;
|
|
1035
|
+
setPathDraft(null);
|
|
1036
|
+
setError(null);
|
|
1037
|
+
}
|
|
1038
|
+
}, [open]);
|
|
1039
|
+
const openPathEditor = () => {
|
|
1040
|
+
if (listing === null) {
|
|
1041
|
+
setPathDraft("");
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const sep = separatorOf(listing);
|
|
1045
|
+
const base = listing.path;
|
|
1046
|
+
setPathDraft(base.endsWith(sep) ? base : base + sep);
|
|
1047
|
+
};
|
|
1048
|
+
const commitPath = () => {
|
|
1049
|
+
const draft = pathDraft ?? "";
|
|
1050
|
+
if (draft.trim() === "") return;
|
|
1051
|
+
navigate(draft);
|
|
1052
|
+
setPathDraft(null);
|
|
1053
|
+
};
|
|
1054
|
+
const crumbs = listing === null ? [] : displayCrumbs(listing, t("browser.home"));
|
|
1055
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
1056
|
+
open,
|
|
1057
|
+
onClose,
|
|
1058
|
+
title: t("browser.title"),
|
|
1059
|
+
closeLabel: t("browser.cancel"),
|
|
1060
|
+
className: "reflib-browser",
|
|
1061
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1062
|
+
className: "reflib-panel",
|
|
1063
|
+
children: [
|
|
1064
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1065
|
+
className: "reflib-error",
|
|
1066
|
+
role: "alert",
|
|
1067
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
1068
|
+
size: 14,
|
|
1069
|
+
className: "reflib-errorIcon"
|
|
1070
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: error })]
|
|
1071
|
+
}),
|
|
1072
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1073
|
+
className: "reflib-browserPath",
|
|
1074
|
+
children: pathDraft === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1075
|
+
className: "reflib-browserCrumbs",
|
|
1076
|
+
role: "navigation",
|
|
1077
|
+
children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1078
|
+
className: "reflib-browserCrumb",
|
|
1079
|
+
children: [index > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, {
|
|
1080
|
+
size: 12,
|
|
1081
|
+
className: "reflib-browserCrumbChevron"
|
|
1082
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1083
|
+
type: "button",
|
|
1084
|
+
className: "reflib-browserCrumbBtn",
|
|
1085
|
+
disabled: loading,
|
|
1086
|
+
onClick: () => {
|
|
1087
|
+
navigate(crumb.path);
|
|
1088
|
+
},
|
|
1089
|
+
children: crumb.name
|
|
1090
|
+
})]
|
|
1091
|
+
}, crumb.path))
|
|
1092
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1093
|
+
type: "button",
|
|
1094
|
+
className: "reflib-browserEdit",
|
|
1095
|
+
"aria-label": t("browser.editPath"),
|
|
1096
|
+
title: t("browser.editPath"),
|
|
1097
|
+
disabled: loading,
|
|
1098
|
+
onClick: openPathEditor,
|
|
1099
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEditOutline16, { size: 14 })
|
|
1100
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1101
|
+
className: "reflib-browserInput",
|
|
1102
|
+
value: pathDraft,
|
|
1103
|
+
"aria-label": t("browser.editPath"),
|
|
1104
|
+
placeholder: t("browser.pathPlaceholder"),
|
|
1105
|
+
autoFocus: true,
|
|
1106
|
+
disabled: loading,
|
|
1107
|
+
onChange: (event) => {
|
|
1108
|
+
setPathDraft(event.currentTarget.value);
|
|
1109
|
+
},
|
|
1110
|
+
onCompositionStart: () => {
|
|
1111
|
+
composing.current = true;
|
|
1112
|
+
},
|
|
1113
|
+
onCompositionEnd: () => {
|
|
1114
|
+
composing.current = false;
|
|
1115
|
+
},
|
|
1116
|
+
onKeyDown: (event) => {
|
|
1117
|
+
if (event.key === "Enter" && !composing.current) {
|
|
1118
|
+
event.preventDefault();
|
|
1119
|
+
commitPath();
|
|
1120
|
+
}
|
|
1121
|
+
if (event.key === "Escape") {
|
|
1122
|
+
event.stopPropagation();
|
|
1123
|
+
setPathDraft(null);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
})
|
|
1127
|
+
}),
|
|
1128
|
+
loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1129
|
+
className: "reflib-status",
|
|
1130
|
+
role: "status",
|
|
1131
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
1132
|
+
size: 20,
|
|
1133
|
+
className: "reflib-spin reflib-statusIcon"
|
|
1134
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1135
|
+
className: "reflib-statusText",
|
|
1136
|
+
children: t("browser.loading")
|
|
1137
|
+
})]
|
|
1138
|
+
}) : listing !== null && listing.entries.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1139
|
+
className: "reflib-status",
|
|
1140
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
1141
|
+
size: 22,
|
|
1142
|
+
className: "reflib-statusIcon"
|
|
1143
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1144
|
+
className: "reflib-statusText",
|
|
1145
|
+
children: t("browser.empty")
|
|
1146
|
+
})]
|
|
1147
|
+
}) : listing !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1148
|
+
className: "reflib-browserList",
|
|
1149
|
+
children: listing.entries.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1150
|
+
type: "button",
|
|
1151
|
+
className: "reflib-browserRow",
|
|
1152
|
+
"aria-label": t("browser.enter.aria", { name: entry.name }),
|
|
1153
|
+
disabled: loading,
|
|
1154
|
+
onClick: () => {
|
|
1155
|
+
navigate(entry.path);
|
|
1156
|
+
},
|
|
1157
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderClose16, {
|
|
1158
|
+
size: 16,
|
|
1159
|
+
className: "reflib-browserRowIcon"
|
|
1160
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1161
|
+
className: "reflib-browserRowName",
|
|
1162
|
+
children: entry.name
|
|
1163
|
+
})]
|
|
1164
|
+
}, entry.path))
|
|
1165
|
+
}),
|
|
1166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "reflib-divider" }),
|
|
1167
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1168
|
+
className: "reflib-browserFooter",
|
|
1169
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1170
|
+
variant: "outline",
|
|
1171
|
+
size: "sm",
|
|
1172
|
+
disabled: loading,
|
|
1173
|
+
onClick: onClose,
|
|
1174
|
+
children: t("browser.cancel")
|
|
1175
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1176
|
+
variant: "primary",
|
|
1177
|
+
size: "sm",
|
|
1178
|
+
disabled: loading || listing === null,
|
|
1179
|
+
"aria-label": t("browser.open.aria"),
|
|
1180
|
+
onClick: () => {
|
|
1181
|
+
if (listing !== null) onOpen(listing.path);
|
|
1182
|
+
},
|
|
1183
|
+
children: t("browser.open")
|
|
1184
|
+
})]
|
|
1185
|
+
})
|
|
1186
|
+
]
|
|
1187
|
+
})
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region src/client/RefLibPanel.tsx
|
|
1192
|
+
/**
|
|
1193
|
+
* 参考库管理面板(Modal):列表(基名 + 全路径、移除操作)+ 添加表单。
|
|
1194
|
+
*
|
|
1195
|
+
* 设计(优化点 1/2):全部样式走 “--dsw-*” 设计令牌(随浅/深主题适配),
|
|
1196
|
+
* 列表行以「基名为主行、完整路径为次行」呈现,移除为带危险 hover 的图标按钮,
|
|
1197
|
+
* 添加为主按钮 + 路径输入(支持直接粘贴路径,绕开卡顿的系统选择器)+ 系统选择器
|
|
1198
|
+
* 兜底;空态/加载态/错误态各有独立视觉。文案全部经 `t` 本地化(zh/en)。
|
|
1199
|
+
* 本组件为纯展示:异步操作与错误归集由 RefLibDock 持有。
|
|
1200
|
+
* @module @hpyperry/dsh-ref-lib/src/client/RefLibPanel
|
|
1201
|
+
*/
|
|
1202
|
+
/** 用途说明最大长度(与 node half service.NOTE_MAX_LENGTH 一致)。 */
|
|
1203
|
+
const NOTE_MAX_LENGTH = 120;
|
|
1204
|
+
/**
|
|
1205
|
+
* 渲染参考库管理面板。
|
|
1206
|
+
* @param props - 见 {@link RefLibPanelProps}。
|
|
1207
|
+
* @returns 对话框元素(关闭时 Modal 返回 null)。
|
|
1208
|
+
*/
|
|
1209
|
+
function RefLibPanel(props) {
|
|
1210
|
+
const { open, onClose, libs, loading, busy, picking, removingId, error, t, onRemove, onAddPath, onUpdateNote, onBrowse } = props;
|
|
1211
|
+
const [draft, setDraft] = (0, react.useState)("");
|
|
1212
|
+
const [noteDraft, setNoteDraft] = (0, react.useState)("");
|
|
1213
|
+
const [detailId, setDetailId] = (0, react.useState)(null);
|
|
1214
|
+
const [editNote, setEditNote] = (0, react.useState)("");
|
|
1215
|
+
(0, react.useEffect)(() => {
|
|
1216
|
+
if (!open) {
|
|
1217
|
+
setDraft("");
|
|
1218
|
+
setNoteDraft("");
|
|
1219
|
+
setDetailId(null);
|
|
1220
|
+
}
|
|
1221
|
+
}, [open]);
|
|
1222
|
+
const handleSubmit = async () => {
|
|
1223
|
+
const trimmed = draft.trim();
|
|
1224
|
+
if (trimmed === "") return;
|
|
1225
|
+
try {
|
|
1226
|
+
const note = noteDraft.trim();
|
|
1227
|
+
await onAddPath(trimmed, note === "" ? void 0 : note);
|
|
1228
|
+
setDraft("");
|
|
1229
|
+
setNoteDraft("");
|
|
1230
|
+
} catch {}
|
|
1231
|
+
};
|
|
1232
|
+
/** 浏览选中目录 → 填入路径字段(不直接添加,用户可补用途后提交)。 */
|
|
1233
|
+
const handleBrowse = async () => {
|
|
1234
|
+
const path = await onBrowse();
|
|
1235
|
+
if (path !== null) setDraft(path);
|
|
1236
|
+
};
|
|
1237
|
+
/** 展开/收起条目详情;展开时载入当前用途草稿。 */
|
|
1238
|
+
const toggleDetail = (entry) => {
|
|
1239
|
+
if (detailId === entry.id) {
|
|
1240
|
+
setDetailId(null);
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
setDetailId(entry.id);
|
|
1244
|
+
setEditNote(entry.note ?? "");
|
|
1245
|
+
};
|
|
1246
|
+
/** 保存详情编辑的用途说明;成功后收起详情。 */
|
|
1247
|
+
const handleSaveNote = async () => {
|
|
1248
|
+
if (detailId === null) return;
|
|
1249
|
+
await onUpdateNote(detailId, editNote);
|
|
1250
|
+
setDetailId(null);
|
|
1251
|
+
};
|
|
1252
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
1253
|
+
open,
|
|
1254
|
+
onClose,
|
|
1255
|
+
title: t("panel.title"),
|
|
1256
|
+
closeLabel: t("panel.close"),
|
|
1257
|
+
description: t("panel.description", { count: String(libs.length) }),
|
|
1258
|
+
className: "reflib-modal",
|
|
1259
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1260
|
+
className: "reflib-panel",
|
|
1261
|
+
children: [
|
|
1262
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1263
|
+
className: "reflib-error",
|
|
1264
|
+
role: "alert",
|
|
1265
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
1266
|
+
size: 14,
|
|
1267
|
+
className: "reflib-errorIcon"
|
|
1268
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: error })]
|
|
1269
|
+
}),
|
|
1270
|
+
loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1271
|
+
className: "reflib-status",
|
|
1272
|
+
role: "status",
|
|
1273
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
1274
|
+
size: 20,
|
|
1275
|
+
className: "reflib-spin reflib-statusIcon"
|
|
1276
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1277
|
+
className: "reflib-statusText",
|
|
1278
|
+
children: t("list.loading")
|
|
1279
|
+
})]
|
|
1280
|
+
}) : libs.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1281
|
+
className: "reflib-status",
|
|
1282
|
+
children: [
|
|
1283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
1284
|
+
size: 22,
|
|
1285
|
+
className: "reflib-statusIcon"
|
|
1286
|
+
}),
|
|
1287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1288
|
+
className: "reflib-statusText",
|
|
1289
|
+
children: t("list.empty")
|
|
1290
|
+
}),
|
|
1291
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1292
|
+
className: "reflib-statusHint",
|
|
1293
|
+
children: t("list.empty.hint")
|
|
1294
|
+
})
|
|
1295
|
+
]
|
|
1296
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1297
|
+
className: "reflib-list",
|
|
1298
|
+
children: libs.map((entry) => {
|
|
1299
|
+
const name = libBasename(entry.path);
|
|
1300
|
+
const removing = removingId === entry.id;
|
|
1301
|
+
const detailOpen = detailId === entry.id;
|
|
1302
|
+
const unavailable = entry.status !== void 0 && entry.status !== "available";
|
|
1303
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1304
|
+
className: "reflib-listItem",
|
|
1305
|
+
"data-removing": removing || void 0,
|
|
1306
|
+
"data-status": unavailable ? entry.status : void 0,
|
|
1307
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1308
|
+
className: "reflib-row",
|
|
1309
|
+
children: [
|
|
1310
|
+
unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {
|
|
1311
|
+
size: 16,
|
|
1312
|
+
className: "reflib-rowIcon reflib-rowIconWarn"
|
|
1313
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconFolderOpen16, {
|
|
1314
|
+
size: 16,
|
|
1315
|
+
className: "reflib-rowIcon"
|
|
1316
|
+
}),
|
|
1317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1318
|
+
className: "reflib-rowBody",
|
|
1319
|
+
children: [
|
|
1320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1321
|
+
className: "reflib-rowName",
|
|
1322
|
+
title: entry.path,
|
|
1323
|
+
children: name
|
|
1324
|
+
}),
|
|
1325
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1326
|
+
className: "reflib-rowPath",
|
|
1327
|
+
title: entry.path,
|
|
1328
|
+
children: entry.path
|
|
1329
|
+
}),
|
|
1330
|
+
unavailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1331
|
+
className: "reflib-rowStatus",
|
|
1332
|
+
role: "status",
|
|
1333
|
+
children: t(entry.status === "missing" ? "status.missing" : "status.notDirectory")
|
|
1334
|
+
}),
|
|
1335
|
+
entry.note !== void 0 && entry.note !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1336
|
+
className: "reflib-rowNote",
|
|
1337
|
+
title: entry.note,
|
|
1338
|
+
children: entry.note.replace(/\s+/g, " ")
|
|
1339
|
+
})
|
|
1340
|
+
]
|
|
1341
|
+
}),
|
|
1342
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
1343
|
+
label: t("detail.open"),
|
|
1344
|
+
side: "top",
|
|
1345
|
+
delayMs: 400,
|
|
1346
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1347
|
+
type: "button",
|
|
1348
|
+
className: "reflib-rowAction",
|
|
1349
|
+
"aria-label": t("detail.open.aria", { name }),
|
|
1350
|
+
"aria-expanded": detailOpen || void 0,
|
|
1351
|
+
disabled: busy || removingId !== null || unavailable,
|
|
1352
|
+
onClick: () => {
|
|
1353
|
+
toggleDetail(entry);
|
|
1354
|
+
},
|
|
1355
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconEllipsisOutline16, { size: 14 })
|
|
1356
|
+
})
|
|
1357
|
+
}),
|
|
1358
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
1359
|
+
label: t("list.remove"),
|
|
1360
|
+
side: "top",
|
|
1361
|
+
delayMs: 400,
|
|
1362
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "reflib-rowRemove",
|
|
1365
|
+
"aria-label": t("list.remove.aria", { name }),
|
|
1366
|
+
disabled: busy || removingId !== null,
|
|
1367
|
+
onClick: () => {
|
|
1368
|
+
onRemove(entry.id);
|
|
1369
|
+
},
|
|
1370
|
+
children: removing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {
|
|
1371
|
+
size: 14,
|
|
1372
|
+
className: "reflib-spin"
|
|
1373
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 })
|
|
1374
|
+
})
|
|
1375
|
+
})
|
|
1376
|
+
]
|
|
1377
|
+
}), detailOpen && !unavailable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1378
|
+
className: "reflib-detail",
|
|
1379
|
+
children: [
|
|
1380
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1381
|
+
className: "reflib-detailMeta",
|
|
1382
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1383
|
+
className: "reflib-detailKey",
|
|
1384
|
+
children: "ID"
|
|
1385
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1386
|
+
className: "reflib-detailValue",
|
|
1387
|
+
children: entry.id
|
|
1388
|
+
})]
|
|
1389
|
+
}),
|
|
1390
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1391
|
+
className: "reflib-detailMeta",
|
|
1392
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1393
|
+
className: "reflib-detailKey",
|
|
1394
|
+
children: t("detail.path")
|
|
1395
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1396
|
+
className: "reflib-detailValue",
|
|
1397
|
+
title: entry.path,
|
|
1398
|
+
children: entry.path
|
|
1399
|
+
})]
|
|
1400
|
+
}),
|
|
1401
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1402
|
+
className: "reflib-detailKey",
|
|
1403
|
+
children: t("add.note.label")
|
|
1404
|
+
}),
|
|
1405
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1406
|
+
className: "reflib-noteWrap",
|
|
1407
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
1408
|
+
className: "reflib-noteTextarea",
|
|
1409
|
+
value: editNote,
|
|
1410
|
+
placeholder: t("add.note.placeholder"),
|
|
1411
|
+
"aria-label": t("add.note.label"),
|
|
1412
|
+
disabled: busy,
|
|
1413
|
+
rows: 3,
|
|
1414
|
+
maxLength: NOTE_MAX_LENGTH,
|
|
1415
|
+
onChange: (event) => {
|
|
1416
|
+
setEditNote(event.currentTarget.value);
|
|
1417
|
+
}
|
|
1418
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1419
|
+
className: "reflib-noteCount",
|
|
1420
|
+
children: [
|
|
1421
|
+
editNote.length,
|
|
1422
|
+
"/",
|
|
1423
|
+
NOTE_MAX_LENGTH
|
|
1424
|
+
]
|
|
1425
|
+
})]
|
|
1426
|
+
}),
|
|
1427
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1428
|
+
className: "reflib-detailActions",
|
|
1429
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1430
|
+
variant: "ghost",
|
|
1431
|
+
size: "sm",
|
|
1432
|
+
disabled: busy,
|
|
1433
|
+
onClick: () => {
|
|
1434
|
+
setDetailId(null);
|
|
1435
|
+
},
|
|
1436
|
+
children: t("detail.cancel")
|
|
1437
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1438
|
+
variant: "primary",
|
|
1439
|
+
size: "sm",
|
|
1440
|
+
disabled: busy,
|
|
1441
|
+
onClick: () => {
|
|
1442
|
+
handleSaveNote();
|
|
1443
|
+
},
|
|
1444
|
+
children: t("detail.save")
|
|
1445
|
+
})]
|
|
1446
|
+
})
|
|
1447
|
+
]
|
|
1448
|
+
})]
|
|
1449
|
+
}, entry.id);
|
|
1450
|
+
})
|
|
1451
|
+
}),
|
|
1452
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "reflib-divider" }),
|
|
1453
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1454
|
+
className: "reflib-add",
|
|
1455
|
+
children: [
|
|
1456
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1457
|
+
className: "reflib-addLabel",
|
|
1458
|
+
children: t("add.label")
|
|
1459
|
+
}),
|
|
1460
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1461
|
+
className: "reflib-addRow",
|
|
1462
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
1463
|
+
className: "reflib-addInputWrap",
|
|
1464
|
+
value: draft,
|
|
1465
|
+
placeholder: t("add.placeholder"),
|
|
1466
|
+
"aria-label": t("add.label"),
|
|
1467
|
+
disabled: busy || picking,
|
|
1468
|
+
onChange: (event) => {
|
|
1469
|
+
setDraft(event.currentTarget.value);
|
|
1470
|
+
},
|
|
1471
|
+
onKeyDown: (event) => {
|
|
1472
|
+
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
1473
|
+
event.preventDefault();
|
|
1474
|
+
handleSubmit();
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1478
|
+
variant: "outline",
|
|
1479
|
+
size: "sm",
|
|
1480
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutline16, { size: 14 }),
|
|
1481
|
+
disabled: busy || picking,
|
|
1482
|
+
onClick: () => {
|
|
1483
|
+
handleBrowse();
|
|
1484
|
+
},
|
|
1485
|
+
children: t("add.browse")
|
|
1486
|
+
})]
|
|
1487
|
+
}),
|
|
1488
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1489
|
+
className: "reflib-noteWrap",
|
|
1490
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
1491
|
+
className: "reflib-noteTextarea",
|
|
1492
|
+
value: noteDraft,
|
|
1493
|
+
placeholder: t("add.note.placeholder"),
|
|
1494
|
+
"aria-label": t("add.note.label"),
|
|
1495
|
+
disabled: busy || picking,
|
|
1496
|
+
rows: 2,
|
|
1497
|
+
maxLength: NOTE_MAX_LENGTH,
|
|
1498
|
+
onChange: (event) => {
|
|
1499
|
+
setNoteDraft(event.currentTarget.value);
|
|
1500
|
+
}
|
|
1501
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1502
|
+
className: "reflib-noteCount",
|
|
1503
|
+
children: [
|
|
1504
|
+
noteDraft.length,
|
|
1505
|
+
"/",
|
|
1506
|
+
NOTE_MAX_LENGTH
|
|
1507
|
+
]
|
|
1508
|
+
})]
|
|
1509
|
+
}),
|
|
1510
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1511
|
+
variant: "primary",
|
|
1512
|
+
className: "reflib-addSubmit",
|
|
1513
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }),
|
|
1514
|
+
disabled: busy || picking || draft.trim() === "",
|
|
1515
|
+
onClick: () => {
|
|
1516
|
+
handleSubmit();
|
|
1517
|
+
},
|
|
1518
|
+
children: t("add.submit")
|
|
1519
|
+
}),
|
|
1520
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1521
|
+
className: "reflib-addHint",
|
|
1522
|
+
children: t("add.hint")
|
|
1523
|
+
})
|
|
1524
|
+
]
|
|
1525
|
+
})
|
|
1526
|
+
]
|
|
1527
|
+
})
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
//#endregion
|
|
1282
1531
|
//#region src/client/RefLibDock.tsx
|
|
1283
1532
|
/**
|
|
1284
1533
|
* 参考库入口(conversation.input.dock,输入卡正上方)+ 面板状态持有者。
|
|
@@ -1297,12 +1546,16 @@ window.__ModuleLoader__.load({
|
|
|
1297
1546
|
* 目录选择走系统原生选择器,另提供路径输入直加(绕开卡顿的原生对话框)。
|
|
1298
1547
|
* @module @hpyperry/dsh-ref-lib/src/client/RefLibDock
|
|
1299
1548
|
*/
|
|
1549
|
+
/** 挂载预载失败重试:间隔与上限(重启后会话 live 通常 <1s,重试 1–2 次即成功)。 */
|
|
1550
|
+
const MOUNT_RETRY_DELAY_MS = 800;
|
|
1551
|
+
const MOUNT_RETRY_MAX = 5;
|
|
1300
1552
|
/** wire 错误码 → 本地化文案键(未知码回退原始消息)。 */
|
|
1301
1553
|
const ERROR_KEYS = {
|
|
1302
1554
|
"ref-lib/missing": "error.missing",
|
|
1303
1555
|
"ref-lib/not-directory": "error.notDirectory",
|
|
1304
1556
|
"ref-lib/unsafe": "error.unsafe",
|
|
1305
|
-
"ref-lib/unknown-id": "error.unknownId"
|
|
1557
|
+
"ref-lib/unknown-id": "error.unknownId",
|
|
1558
|
+
"ref-lib/unavailable": "error.unavailable"
|
|
1306
1559
|
};
|
|
1307
1560
|
/** 把未知错误规整为可展示文案。 */
|
|
1308
1561
|
function messageOf(cause) {
|
|
@@ -1327,7 +1580,7 @@ window.__ModuleLoader__.load({
|
|
|
1327
1580
|
* @returns 胶囊入口(+ 打开时的管理面板)。
|
|
1328
1581
|
*/
|
|
1329
1582
|
function RefLibDock(props) {
|
|
1330
|
-
const { sessionId, load, add, remove, setNote, pickDirectory, listDirectory, t } = props;
|
|
1583
|
+
const { sessionId, session, load, add, remove, setNote, pickDirectory, listDirectory, t } = props;
|
|
1331
1584
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1332
1585
|
const [libs, setLibs] = (0, react.useState)([]);
|
|
1333
1586
|
const [loading, setLoading] = (0, react.useState)(false);
|
|
@@ -1335,7 +1588,7 @@ window.__ModuleLoader__.load({
|
|
|
1335
1588
|
const [picking, setPicking] = (0, react.useState)(false);
|
|
1336
1589
|
const [removingId, setRemovingId] = (0, react.useState)(null);
|
|
1337
1590
|
const [error, setError] = (0, react.useState)(null);
|
|
1338
|
-
const
|
|
1591
|
+
const guard = (0, react.useRef)(new RefreshGuard());
|
|
1339
1592
|
const [pickerMode, setPickerMode] = (0, react.useState)(null);
|
|
1340
1593
|
const [browserOpen, setBrowserOpen] = (0, react.useState)(false);
|
|
1341
1594
|
const pendingPick = (0, react.useRef)(null);
|
|
@@ -1351,23 +1604,57 @@ window.__ModuleLoader__.load({
|
|
|
1351
1604
|
setPickerMode(mode);
|
|
1352
1605
|
return mode;
|
|
1353
1606
|
};
|
|
1354
|
-
|
|
1355
|
-
|
|
1607
|
+
/**
|
|
1608
|
+
* 拉取会话参考库列表并更新 UI。
|
|
1609
|
+
* @param silent - 静默模式(轮询用):失败不写入错误槽;成功也**不碰 error/loading**
|
|
1610
|
+
* ——错误与加载态只由用户操作/打开面板管理,避免后台轮询吞掉操作错误提示或
|
|
1611
|
+
* 提前结束面板加载态(轮询仅更新 libs 数据)。
|
|
1612
|
+
*/
|
|
1613
|
+
const refresh = async (silent = false) => {
|
|
1614
|
+
const mine = guard.current.begin();
|
|
1356
1615
|
try {
|
|
1357
1616
|
const next = await load(sessionId);
|
|
1358
|
-
if (
|
|
1617
|
+
if (!guard.current.isLatest(mine)) return;
|
|
1359
1618
|
setLibs(next);
|
|
1360
|
-
setError(null);
|
|
1619
|
+
if (!silent) setError(null);
|
|
1361
1620
|
} catch (cause) {
|
|
1362
|
-
if (
|
|
1363
|
-
setError(formatError(cause, t));
|
|
1621
|
+
if (!guard.current.isLatest(mine)) return;
|
|
1622
|
+
if (!silent) setError(formatError(cause, t));
|
|
1364
1623
|
} finally {
|
|
1365
|
-
if (mine
|
|
1624
|
+
if (guard.current.isLatest(mine) && !silent) setLoading(false);
|
|
1366
1625
|
}
|
|
1367
1626
|
};
|
|
1368
1627
|
(0, react.useEffect)(() => {
|
|
1369
1628
|
ensureRefLibStyles();
|
|
1370
|
-
|
|
1629
|
+
let stopped = false;
|
|
1630
|
+
let retries = 0;
|
|
1631
|
+
let timer;
|
|
1632
|
+
const attempt = async () => {
|
|
1633
|
+
const mine = guard.current.begin();
|
|
1634
|
+
try {
|
|
1635
|
+
const next = await load(sessionId);
|
|
1636
|
+
if (stopped || !guard.current.isLatest(mine)) return;
|
|
1637
|
+
setLibs(next);
|
|
1638
|
+
setError(null);
|
|
1639
|
+
} catch (cause) {
|
|
1640
|
+
if (stopped || !guard.current.isLatest(mine)) return;
|
|
1641
|
+
if (retries < MOUNT_RETRY_MAX) {
|
|
1642
|
+
retries += 1;
|
|
1643
|
+
timer = window.setTimeout(() => {
|
|
1644
|
+
attempt();
|
|
1645
|
+
}, MOUNT_RETRY_DELAY_MS);
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
setError(formatError(cause, t));
|
|
1649
|
+
} finally {
|
|
1650
|
+
if (!stopped && guard.current.isLatest(mine)) setLoading(false);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
attempt();
|
|
1654
|
+
return () => {
|
|
1655
|
+
stopped = true;
|
|
1656
|
+
if (timer !== void 0) window.clearTimeout(timer);
|
|
1657
|
+
};
|
|
1371
1658
|
}, [sessionId]);
|
|
1372
1659
|
(0, react.useEffect)(() => {
|
|
1373
1660
|
if (open) {
|
|
@@ -1375,6 +1662,14 @@ window.__ModuleLoader__.load({
|
|
|
1375
1662
|
refresh();
|
|
1376
1663
|
}
|
|
1377
1664
|
}, [open]);
|
|
1665
|
+
const userMessageCount = session.nodes.filter((node) => node.kind === "user").length;
|
|
1666
|
+
(0, react.useEffect)(() => {
|
|
1667
|
+
refresh(true);
|
|
1668
|
+
}, [userMessageCount]);
|
|
1669
|
+
const refLibCommandDone = session.nodes.filter((node) => node.kind === "command" && node.name === "ref-lib" && node.outcome !== null).length;
|
|
1670
|
+
(0, react.useEffect)(() => {
|
|
1671
|
+
refresh(true);
|
|
1672
|
+
}, [refLibCommandDone]);
|
|
1378
1673
|
const handleRemove = async (id) => {
|
|
1379
1674
|
setRemovingId(id);
|
|
1380
1675
|
setBusy(true);
|
|
@@ -1456,6 +1751,14 @@ window.__ModuleLoader__.load({
|
|
|
1456
1751
|
pendingPick.current = null;
|
|
1457
1752
|
resolve?.(null);
|
|
1458
1753
|
};
|
|
1754
|
+
/**
|
|
1755
|
+
* 胶囊计数(v9):徽标显示**可用**数量(失效不计入),红色角标显示失效数量
|
|
1756
|
+
* (总数 − 可用数),仅存在失效条目时显示。注意:UI 数据只在打开面板/操作后
|
|
1757
|
+
* 刷新,外部变更(如删除目录)不会自动反向同步到界面(与命令修改后不刷新同属
|
|
1758
|
+
* 待解决的 UI 数据同步问题,见设计文档"遗留备注")。
|
|
1759
|
+
*/
|
|
1760
|
+
const availableCount = libs.filter((entry) => entry.status === "available").length;
|
|
1761
|
+
const unavailableCount = libs.length - availableCount;
|
|
1459
1762
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1460
1763
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1461
1764
|
className: "reflib-dock",
|
|
@@ -1465,7 +1768,7 @@ window.__ModuleLoader__.load({
|
|
|
1465
1768
|
"data-active": open || void 0,
|
|
1466
1769
|
"aria-haspopup": "dialog",
|
|
1467
1770
|
"aria-expanded": open,
|
|
1468
|
-
"aria-label":
|
|
1771
|
+
"aria-label": unavailableCount > 0 ? t("dock.unavailable", { count: String(unavailableCount) }) : availableCount > 0 ? t("dock.count.aria", { count: String(availableCount) }) : t("dock.aria"),
|
|
1469
1772
|
title: t("dock.aria"),
|
|
1470
1773
|
onClick: () => {
|
|
1471
1774
|
setOpen((value) => !value);
|
|
@@ -1479,9 +1782,14 @@ window.__ModuleLoader__.load({
|
|
|
1479
1782
|
className: "reflib-chipLabel",
|
|
1480
1783
|
children: t("dock.label")
|
|
1481
1784
|
}),
|
|
1482
|
-
|
|
1785
|
+
availableCount > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1483
1786
|
className: "reflib-chipBadge",
|
|
1484
|
-
children:
|
|
1787
|
+
children: availableCount
|
|
1788
|
+
}),
|
|
1789
|
+
unavailableCount > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1790
|
+
className: "reflib-chipWarn",
|
|
1791
|
+
title: t("dock.unavailable", { count: String(unavailableCount) }),
|
|
1792
|
+
children: unavailableCount
|
|
1485
1793
|
})
|
|
1486
1794
|
]
|
|
1487
1795
|
})
|
|
@@ -1530,6 +1838,9 @@ window.__ModuleLoader__.load({
|
|
|
1530
1838
|
"dock.label": "参考库",
|
|
1531
1839
|
"dock.aria": "管理只读参考库",
|
|
1532
1840
|
"dock.count.aria": "参考库,共 {count} 个",
|
|
1841
|
+
"dock.unavailable": "参考库,{count} 个失效",
|
|
1842
|
+
"status.missing": "目录已删除或不可访问",
|
|
1843
|
+
"status.notDirectory": "路径不再是目录",
|
|
1533
1844
|
"panel.title": "参考库",
|
|
1534
1845
|
"panel.close": "关闭",
|
|
1535
1846
|
"panel.description": "共 {count} 个只读参考库:供 agent 读取参考,禁止修改其中文件",
|
|
@@ -1563,13 +1874,21 @@ window.__ModuleLoader__.load({
|
|
|
1563
1874
|
"error.missing": "目录不存在:{path}",
|
|
1564
1875
|
"error.notDirectory": "不是目录:{path}",
|
|
1565
1876
|
"error.unsafe": "路径包含控制字符,已拒绝:{path}",
|
|
1566
|
-
"error.unknownId": "未找到参考库条目:{id}"
|
|
1877
|
+
"error.unknownId": "未找到参考库条目:{id}",
|
|
1878
|
+
"error.unavailable": "参考库目录不可用(仅允许移除)",
|
|
1879
|
+
"command.running": "执行中…",
|
|
1880
|
+
"command.done": "完成",
|
|
1881
|
+
"command.copy": "复制",
|
|
1882
|
+
"command.copied": "已复制"
|
|
1567
1883
|
};
|
|
1568
1884
|
/** 英文词典,与 zh 键集逐键对齐(编译期校验)。 */
|
|
1569
1885
|
const en = {
|
|
1570
1886
|
"dock.label": "Reference Library",
|
|
1571
1887
|
"dock.aria": "Manage read-only reference libraries",
|
|
1572
1888
|
"dock.count.aria": "Reference library, {count} total",
|
|
1889
|
+
"dock.unavailable": "Reference library, {count} unavailable",
|
|
1890
|
+
"status.missing": "Directory deleted or unavailable",
|
|
1891
|
+
"status.notDirectory": "Path is no longer a directory",
|
|
1573
1892
|
"panel.title": "Reference Library",
|
|
1574
1893
|
"panel.close": "Close",
|
|
1575
1894
|
"panel.description": "{count} read-only reference libraries: the agent may read them for reference, but must not modify any files",
|
|
@@ -1603,7 +1922,12 @@ window.__ModuleLoader__.load({
|
|
|
1603
1922
|
"error.missing": "Directory does not exist: {path}",
|
|
1604
1923
|
"error.notDirectory": "Not a directory: {path}",
|
|
1605
1924
|
"error.unsafe": "Path contains control characters and was rejected: {path}",
|
|
1606
|
-
"error.unknownId": "Reference library entry not found: {id}"
|
|
1925
|
+
"error.unknownId": "Reference library entry not found: {id}",
|
|
1926
|
+
"error.unavailable": "Reference library directory unavailable (remove only)",
|
|
1927
|
+
"command.running": "Running…",
|
|
1928
|
+
"command.done": "Done",
|
|
1929
|
+
"command.copy": "Copy",
|
|
1930
|
+
"command.copied": "Copied"
|
|
1607
1931
|
};
|
|
1608
1932
|
//#endregion
|
|
1609
1933
|
//#region src/client/index.ts
|
|
@@ -1678,6 +2002,11 @@ window.__ModuleLoader__.load({
|
|
|
1678
2002
|
locale: NS,
|
|
1679
2003
|
inject: injected
|
|
1680
2004
|
}, RefLibDock));
|
|
2005
|
+
ctx.slots.inject("conversation.chat.commandview", () => ctx.slots.register({
|
|
2006
|
+
name: "conversation.chat.commandview",
|
|
2007
|
+
key: "ref-lib",
|
|
2008
|
+
locale: NS
|
|
2009
|
+
}, RefLibCommandCard));
|
|
1681
2010
|
}
|
|
1682
2011
|
//#endregion
|
|
1683
2012
|
exports.apply = apply;
|