dsh-linked-workspace 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.en.md +5 -3
- package/README.md +6 -3
- package/docs/API.md +2 -1
- package/docs/VERIFY.md +15 -3
- package/lib/client.js +186 -46
- package/lib/index.js +71 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
English · [简体中文](CHANGELOG.zh.md)
|
|
4
4
|
|
|
5
|
+
## 0.26.1 — 2026-11-24
|
|
6
|
+
|
|
7
|
+
- The remote candidates in the `@` menu now look and behave like DSH's own "Files & folders"
|
|
8
|
+
group: **an icon plus the bare name** (the extra detail line is gone), a folder carries the
|
|
9
|
+
"enter directory · Tab" hint, and pressing Tab (or clicking it) keeps the menu open, turns the
|
|
10
|
+
token into `@folder/` and lists that folder — you walk the tree level by level instead of
|
|
11
|
+
seeing one flattened list.
|
|
12
|
+
- Being able to descend also means the menu no longer needs to guess: every keystroke filters the
|
|
13
|
+
current directory, so the group answers in a few hundred milliseconds even when the remote
|
|
14
|
+
folder holds thousands of entries.
|
|
15
|
+
|
|
16
|
+
## 0.26.0 — 2026-11-24
|
|
17
|
+
|
|
18
|
+
- The `@` picker now knows which workspace a session belongs to: DSH hands the trigger
|
|
19
|
+
source only a `sessionId`, so the plugin asks the new `linked.sessionScope` method, which
|
|
20
|
+
matches the session against the workspace registry (ids are compared with or without the
|
|
21
|
+
`session-` prefix).
|
|
22
|
+
- Remote candidates are listed one directory at a time through `fs.list` instead of walking the
|
|
23
|
+
whole tree: the `@` menu answers in a few hundred milliseconds, where `fs.references` took
|
|
24
|
+
5–20 s (and returns nothing at all for an empty query).
|
|
25
|
+
- The remote group now comes first and says what it is: the plugin registers its trigger source
|
|
26
|
+
with `order: -1` (DSH sorts sources by `order`, its own one uses the default 0) and the group is
|
|
27
|
+
titled **Remote files & folders**. DSH's own group keeps its label — it lives in the shell's
|
|
28
|
+
`reference` locale namespace, and registering that namespace again throws, so the plugin cannot
|
|
29
|
+
rename it.
|
|
30
|
+
- Open file tabs now survive a page reload and a Host restart: the tab list is mirrored into
|
|
31
|
+
`localStorage` under one key per pane (session + mode + pinned workspace), so reopening the
|
|
32
|
+
directory tab reopens the files you had open, with the same active tab. Unsaved edits and the
|
|
33
|
+
caret position are deliberately not restored — only the list.
|
|
34
|
+
- The directory panel no longer gets demolished by session polling: while a session snapshot
|
|
35
|
+
briefly lacks a cwd the tab descriptors are kept instead of disposed, and a signature change
|
|
36
|
+
must stay stable for 900 ms before the tabs are re-registered, so an open file tab (and the
|
|
37
|
+
expanded folders behind it) survive idle refreshes. The per-pane memory key also ignores the
|
|
38
|
+
optional `session-` prefix.
|
|
39
|
+
- One `@` now lists the remote tree: inside a linked or remote workspace the picker grows a
|
|
40
|
+
**Remote files** group next to DSH's own local suggestions, so the remote tree needs a single
|
|
41
|
+
keystroke instead of the old double `@`.
|
|
42
|
+
- The `@@` entry point is gone, and with it the separate "link an address" group: an address
|
|
43
|
+
after `@` (`/shared_data_…`, `~/…` or a workspace-relative path) simply appears as a remote
|
|
44
|
+
candidate you can pick.
|
|
45
|
+
- Fixed `npm run build` failing on a Windows checkout: the inline-parts marker was matched with
|
|
46
|
+
an LF-only string, so a CRLF working copy refused to build.
|
|
47
|
+
|
|
5
48
|
## 0.25.0 — 2026-11-23
|
|
6
49
|
|
|
7
50
|
- Three more theme families — **Tokyo Night**, **Gruvbox** and **Ayu** — bring the grid to twelve. Every card now previews both halves of the pair (light band on top, dark underneath) with the palette's keyword/string/function colours, so a family is recognisable without switching the app mode first. It lists four colour dots per band — keyword, string, function name and comment.
|
package/README.en.md
CHANGED
|
@@ -80,6 +80,7 @@ hover it for the total size and the used percentage.
|
|
|
80
80
|
- **Show/hide hidden files**: applies to both trees; hidden entries are shown by default when a directory opens (including `.local`/`.remote`).
|
|
81
81
|
- **Refresh**: re-fetches the directory, git status and search; expanded directories refresh silently every 15 seconds and pause while the page is hidden.
|
|
82
82
|
- Coloured file-type icons (JS/TS/Python/JSON/Markdown/Shell/YAML/images/archives/config files…).
|
|
83
|
+
- **Tabs are remembered**: the files you opened are stored per pane (session + mode + pinned workspace) in the browser, so after a page reload or a DSH/Host restart the directory tab reopens them as they were (unsaved edits and the caret are not restored).
|
|
83
84
|
- **Tabs and editor**: up to 12 tabs, local and remote files share the same editor; line numbers, syntax highlighting (overlay), theme colours, `Ctrl/Cmd+S`, conflict prompt (reload / force save), read-only protection for binary and >2 MB files; the status bar shows encoding, line endings, line count and file size.
|
|
84
85
|
- **Find and replace**: `Ctrl/Cmd + F` opens an in-editor bar with a case-sensitive toggle, previous/next, a match counter, replace and replace all. Above 5000 matches the counter shows `5000+` while replace-all still edits the whole document; `Esc` closes it from the replace field too. The Markdown document panel has its own read-only find (`Ctrl+F`, counter, next/previous).
|
|
85
86
|
- **Image, CSV and HTML previews**: PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG render in the content panel (up to 24 MB) with zoom buttons, `Ctrl/Cmd + wheel`, fit-to-window and 1:1; CSV/TSV open as a table with a Table/Source toggle (the source view stays editable), capped at 1000 rows × 80 columns. HTML/HTM render in a sandboxed iframe whose scripts run in an opaque origin (charts draw, but the frame cannot reach the DSH UI or its storage); the cap is 8 MB, and beyond that the panel tells you to download the file and open it in a browser. Markdown previews strip scripts, event attributes and dangerous links.
|
|
@@ -143,11 +144,12 @@ Every attempt — including refused ones — appends a line to `$DSH_HOME/linked
|
|
|
143
144
|
|
|
144
145
|
- The `references` action (backed by `fs.references`) matches **path names** case-insensitively with the best match first (exact name → prefix → substring) and directories flagged `dir`, so the model can turn a file name you mention into a real remote path.
|
|
145
146
|
- `@` in the composer still opens DSH's own menu (local files, folders, conversations). The plugin adds its own candidate groups to that menu:
|
|
146
|
-
-
|
|
147
|
-
-
|
|
147
|
+
- inside a linked or remote workspace a single **`@`** adds a “**Remote files & folders**” group (listed first) on top of DSH's own local suggestions — it lists the workspace's remote tree; picking one inserts a real reference chip, and the model receives that remote path;
|
|
148
|
+
- Rows look exactly like DSH's own "Files & folders" group: **an icon plus the bare name** (no detail line), and a folder carries an "**enter directory · Tab**" hint. Press `Tab` (or click the folder) → the menu stays open, the token becomes `@folder/` and that folder's contents are listed, so you can keep walking down level by level;
|
|
149
|
+
- You can still just type: `@co` filters by name and `@code/` jumps straight into the remote `code/` folder. Candidates are listed **one directory at a time** (through `fs.list`), so a remote with thousands of files still answers in a few hundred milliseconds;
|
|
148
150
|
- The context menu still copies addresses: **Copy relative address** / **Copy absolute address** give the path itself, without an `@` prefix.
|
|
149
151
|
- Content search gained two switches — “search usually ignored folders” (`node_modules`/`.venv`/`dist` included, `.git` always out) and “file names only” — plus a “Stop” button that cancels a running sweep; the scan stats (“Scanned N files · X”) appear above the results.
|
|
150
|
-
-
|
|
152
|
+
- Group order: the plugin registers its trigger source with `order: -1` (DSH sorts sources by `order`, its own one uses the default 0), so “Remote files & folders” always comes first, then DSH's own “Files and folders” and “Conversations”. That second label belongs to the shell's `reference` locale namespace, so the plugin cannot rename it.
|
|
151
153
|
|
|
152
154
|
### Running icon / local skills
|
|
153
155
|
|
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
- **显示/隐藏隐藏文件**:同时约束远端树和本地树;打开目录时默认显示隐藏项(包括 `.local`/`.remote`),可用按钮隐藏。
|
|
80
80
|
- **刷新**:重新拉取目录、git 状态与搜索;展开的目录每 15 秒静默刷新一次,页面隐藏时暂停。
|
|
81
81
|
- 不同文件类型使用不同彩色图标(JS/TS/Python/JSON/Markdown/Shell/YAML/图片/压缩包/配置文件等)。
|
|
82
|
+
- **标签会记住**:打开的文件按面板(会话 + 模式 + 固定的工作区)记在浏览器本地,刷新页面或重启 DSH/Host 后重新打开目录标签,之前开着的文件会原样回来(未保存的编辑与光标位置不会恢复)。
|
|
82
83
|
- **标签与编辑器**:最多同时打开 12 个标签,本地与远端文件共用内部编辑器;行号、语法高亮(叠层渲染)、主题配色、`Ctrl/Cmd+S` 保存、冲突提示(重新加载/强制保存)、二进制与 >2 MB 文件只读保护;状态栏显示编码、换行符、行数与文件大小。
|
|
83
84
|
- **查找/替换**:编辑器内 `Ctrl/Cmd + F` 打开查找条,支持区分大小写、上一个/下一个、命中计数、替换与全部替换;命中超过 5000 处时计数显示 `5000+`,全部替换仍作用于全文。替换框内按 `Esc` 也能关闭查找条。Markdown 文档面板另有只读查找(同样 `Ctrl+F`,支持计数与上下跳转)。
|
|
84
85
|
- **图片、CSV 与网页预览**:PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG 直接在内容面板按图片显示(最大 24 MB),支持按钮缩放、`Ctrl/Cmd + 滚轮` 缩放、适应窗口和 1:1 原始大小;CSV/TSV 默认按表格显示,可在「表格 / 源码」间切换,源码视图仍可编辑保存,超过 1000 行或 80 列时只展示截断后的表格。HTML/HTM 以沙箱 iframe 渲染(脚本在独立源里运行,图表能画出来,但拿不到 DSH 界面与存储;上限 8 MB,超过时提示改下载后用浏览器打开),Markdown 预览会移除脚本、事件属性与危险链接。
|
|
@@ -143,11 +144,13 @@
|
|
|
143
144
|
|
|
144
145
|
- `references` 动作(对应 `fs.references`)按**路径名**做大小写不敏感匹配,最佳匹配排在最前(完全同名 → 前缀 → 包含),目录带 `dir` 标记;模型可以用它把你口头提到的文件名解析成远端真实路径。
|
|
145
146
|
- 输入框里的 **`@`** 仍然是 DSH 原有的菜单(本地文件、文件夹、对话);插件往这个菜单里又加了一组自己的候选:
|
|
146
|
-
-
|
|
147
|
-
-
|
|
147
|
+
- 只要会话属于联动/远程工作区,单打一个 **`@`** 就会在 DSH 原生的本地候选之上,多出一组「**远程文件与文件夹**」(排在最前)——列出当前工作区远端树的文件与文件夹;选中后插入一个真正的引用 chip,模型收到的是该远端路径;
|
|
148
|
+
- 行样式与 DSH 自带的「文件与文件夹」一致:**只有图标和名字**(不再跟一条释义),目录行右侧带「**进入目录 · Tab**」提示。按 `Tab` 或直接点该目录 → 菜单不关闭、光标处的 token 变成 `@目录/`,并列出这个目录里的内容,可以一层层往下走;
|
|
149
|
+
- 也可以纯键盘打字:`@co` 按名字过滤,`@code/` 直接进到远端 `code/` 这一层。候选**每次只列一个目录**(走 `fs.list`),远端有几千个文件也是几百毫秒出结果,不会卡住菜单;
|
|
150
|
+
- 只列当前目录、最多 30 条、跳过隐藏文件;想整体浏览仍用右侧栏的目录树。
|
|
148
151
|
- 右键仍然是取地址:**复制相对地址** / **复制绝对地址** 给出的是路径本身,不带 `@` 前缀。
|
|
149
152
|
- 内容搜索多了两枚开关:「包含通常忽略的目录」(`node_modules`/`.venv`/`dist` 也会搜,`.git` 始终排除)、「只列文件名」;搜索中可以点「停止」中途取消,结果上方会显示「扫描 N 个文件 · X」。
|
|
150
|
-
-
|
|
153
|
+
- 分组顺序:插件注册触发器时用 `order: -1`(DSH 按 `order` 升序排,它自己的 source 用默认 0),所以「远程文件与文件夹」总排在最前,其次是 DSH 原生的「文件与文件夹」「对话」。DSH 那组的标题归外壳的 `reference` 文案命名空间所有,插件无法改名。
|
|
151
154
|
|
|
152
155
|
### 运行中图标 / 本地技能
|
|
153
156
|
|
package/docs/API.md
CHANGED
|
@@ -112,7 +112,8 @@ scope root, or absolute inside it.
|
|
|
112
112
|
| `linked.push` | `{ id, paths?, dryRun?, conflict?, jobId? }` | `{ linkedId, dryRun, conflict, files, pushed, skipped, conflictsLeft, bytes, cancelled }` (`conflict` is `skip` by default; every file is written as a temporary file and renamed into place; `paths` entries may be files or folders — a folder matches everything under it — and every planned entry carries `localMtime` / `remoteMtime`) |
|
|
113
113
|
| `linked.pushCancel` | `{ jobId }` | `{ cancelled }` (stops after the file being written) |
|
|
114
114
|
| `transfer.history` | `{}` | `{ entries: [{ kind: "transfer" \| "push", direction?, linkedId?, files, bytes, skipped, truncated?, at }] }` (newest first, at most 50) |
|
|
115
|
-
| `
|
|
115
|
+
| `linked.sessionScope` | `{ sessionId }` | `{ scope: { linkedId?, remoteId?, root, cwd } \| null }` (resolves which linked/remote workspace a session belongs to by matching the registry path against every record; session ids are compared with or without the `session-` prefix. The `@` picker calls this instead of guessing from the agent context, which only carries `sessionId`) |
|
|
116
|
+
| `fs.references` | `{ linkedId?/remoteId?, query, limit?, includeIgnored?, side? }` | `{ ok, query, candidates: [{ path, relative, name, kind }], total, truncated, scannedEntries }` (path completion for `@`-style references: matches the **path**, case-insensitive, best match first — exact name, then prefix, then substring; `limit` defaults to 50 and caps at 200; walking stops after 20000 entries or 3 s; `side: 'local'` searches the local tree of a linked workspace. **An empty `query` returns no candidates**, and a full tree walk takes 5–20 s on a real remote, so the `@` picker no longer uses this method — it lists one directory at a time by calling `fs.list` with the parent path) |
|
|
116
117
|
| `fs.compare` | `{ linkedId?, path? }` | `{ path, relative, localPath, localMissing, counts: { onlyLocal, onlyRemote, changed, same }, onlyLocal, onlyRemote, changed, truncated, remoteTruncated, localTruncated, skippedLinks }` (linked workspaces only; excludes `.git`, `node_modules`, `.local`, `.remote`; 4000 files and depth 12 **per side**, 200 rows per group; `skippedLinks` counts symlinks and non-regular files) |
|
|
117
118
|
| `fs.pullToLocal` | `{ linkedId?, path, targetDir?, conflict? }` | `{ path, relative, size, mtime }` (linked workspaces only; single file, ≤64 MB; `targetDir` must stay inside the local root; `conflict` is `error` (default), `overwrite` or `unique`) |
|
|
118
119
|
| `fs.upload` | `{ linkedId?/remoteId?, path, paths, conflict? }` | `{ side: 'remote', target, files, bytes, skipped }` (≤50 local files, 64 MB each; `conflict` is `error` (default), `overwrite` or `unique`; a missing target directory is created) |
|
package/docs/VERIFY.md
CHANGED
|
@@ -30,8 +30,20 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
|
|
|
30
30
|
5. 右键任一文件或目录 → 「复制为 @ 引用」→ 剪贴板得到 `@相对路径`(如 `@src/app.py`),提示「已复制 @src/app.py」。
|
|
31
31
|
6. `fs.references { linkedId, query: 'a.txt' }` → `{ candidates: [{ relative, name, kind }], scannedEntries }`,完全同名的排最前;`limit` 生效;空 query 返回空候选而不是报错。
|
|
32
32
|
7. 模型侧:让它「用 linked_workspace 的 references 动作找一下 xxx 文件」→ 工具卡片按「dir/file + 相对路径」列出候选。
|
|
33
|
-
8.
|
|
33
|
+
8. 触发字符由 DSH 外壳写死:`detectTrigger` 只认 `@` 与 `/`,`#` 之类的自定义字符即使 `registerSource` 接受也永远不会被匹配(真机确认:输入 `#may` 没有任何菜单,`#` 被直接丢弃)。
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
9. 会话属于联动/远程工作区时,输入框单打一个 **`@`** → 菜单里除了 DSH 原生的「文件与文件夹」「对话」,还有一组「**远程文件与文件夹**」,并且排在 DSH 自己那两组之前(插件用 `order: -1`,DSH 自己的 source 用默认 0)。DSH 那组仍叫「文件与文件夹」——它属于外壳 `reference` 文案命名空间,重复注册会抛错,插件改不了。
|
|
37
|
+
10. 继续打字过滤:`@co` → 只剩匹配项(如 `.conda/`、`code/`);写到目录名再加 `/`(如 `@code/`)→ 列出该目录里的内容(每次只列一个目录,几百毫秒返回,远端几千个文件也不卡菜单)。
|
|
38
|
+
11. 选中任一远端候选 → 输入框出现真正的引用 chip(`data-composer-chip="linked-workspace"`,悬停显示相对路径),发送后模型收到该远端路径。
|
|
39
|
+
|
|
40
|
+
12. 接口自检:`linked.sessionScope { sessionId }` → `{ scope: { linkedId | remoteId, root, cwd } }`;会话 id 带不带 `session-` 前缀都能解析;不属于任何联动/远程工作区时返回 `{ scope: null }`,此时 `@` 只剩 DSH 原生分组。
|
|
41
|
+
|
|
42
|
+
13. 面板不被轮询冲掉:在会话里打开右侧「联动工作区目录」,展开两层目录并点开一个文件(出现文件标签),然后闲置 50 秒以上 → 文件标签仍在、展开状态不变;期间会话快照短暂缺少 cwd 时两个目录标签也不会被注销(旧实现会 dispose 后重建,正在看的文件随之关闭)。
|
|
43
|
+
|
|
44
|
+
14. 文件标签跨刷新与重启:打开「联动工作区目录」,点开两个文件(出现两个文件标签,记住当前标签)→ 刷新页面 → 两个标签与当前标签都恢复;再把 DSH(或 Web 实例的 Host 进程)整个重启,重新打开目录标签 → 标签依旧在。`localStorage` 里键为 `dsh-linked-workspace:pane-tabs`,每面板最多 24 个标签、最多记 12 个面板;关掉全部标签后该面板的记录会被删除。
|
|
45
|
+
|
|
46
|
+
15. 远程组的行样式与下钻:单打 `@` →「远程文件与文件夹」每行只有图标 + 名字(没有整条相对路径的释义),目录行右侧出现「进入目录 · Tab」提示;对目录按 **Tab**(或点该行)→ 菜单不关闭、token 变成 `@目录/` 并列出该目录内容(可再按 Tab 继续下钻);点文件 → 插入引用 chip、菜单关闭。实测:`@` → Tab → `@r4/`(列出 `sub/`、`content-needle.txt`、`demo.html`…)→ 再 Tab → `@r4/sub/`(列出 `inner.txt`)→ 点 `inner.txt` → chip `inner.txt`。
|
|
35
47
|
## 远端命令执行(0.17.0)
|
|
36
48
|
|
|
37
49
|
> 注意:本机这套 DSH **Web** 构建里没有可见的设置入口(账号菜单只有「意见反馈 / 退出登录」,`Ctrl+K` 是会话搜索,插件详情页只有「卸载」),所以设置区块的渲染要在**桌面端**确认;Host 侧行为可以直接用下面的 API 命令验证。
|
|
@@ -365,9 +377,9 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
|
|
|
365
377
|
2. 点「编辑」进入编辑,向下滚动一段,切到另一个文件再切回来:仍是编辑模式,且滚动位置没有跳回顶部。
|
|
366
378
|
3. 再点回「预览」,切走再切回:仍是预览,阅读位置保留。
|
|
367
379
|
4. 打开 `.xlsx` / `.pptx` / `.pdf`,切到第 2 个工作表 / 幻灯片 / 页面,切走再切回:仍停在原处。
|
|
368
|
-
5.
|
|
380
|
+
5. 在联动/远程工作区的会话里输入单个 `@`:除了 DSH 原生的本地候选,还会出现「远程目录」分组,列出远端文件与文件夹;选中一个后变成引用 chip。
|
|
369
381
|
6. 输入 `@` 再输入 `README.md` 之类的名字:菜单仍是原有的本地文件/文件夹/对话,没有被远程条目污染。
|
|
370
|
-
7. 输入
|
|
382
|
+
7. 输入 `@/shared_data_ssd1/huangjh` 或 `@code/projects_wpf`:「远程目录」分组会把这个地址本身列为候选,选中即插入引用。
|
|
371
383
|
8. 右键任一文件或文件夹:
|
|
372
384
|
- 「复制绝对地址」→ 得到完整路径(远端形如 `/shared_data_ssd1/huangjh/code/a.txt`,本地形如 `D:\…\a.txt`);
|
|
373
385
|
- 「复制相对地址」→ 左树得到相对**本地根**的路径(如 `code/a.txt`),右树得到相对**远端根**的路径;
|
package/lib/client.js
CHANGED
|
@@ -2793,9 +2793,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2793
2793
|
ctxCopy: '复制',
|
|
2794
2794
|
ctxPaste: '粘贴',
|
|
2795
2795
|
ctxCopyPath: '复制绝对地址',
|
|
2796
|
-
remoteRefSection: '
|
|
2797
|
-
addressRefSection: '按地址链接',
|
|
2798
|
-
addressLinkHint: '把这个地址变成引用',
|
|
2796
|
+
remoteRefSection: '远程文件与文件夹',
|
|
2799
2797
|
ctxRename: '重命名',
|
|
2800
2798
|
ctxDelete: '删除',
|
|
2801
2799
|
ctxChmod: '更改权限',
|
|
@@ -3382,9 +3380,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3382
3380
|
ctxCopy: 'Copy',
|
|
3383
3381
|
ctxPaste: 'Paste',
|
|
3384
3382
|
ctxCopyPath: 'Copy absolute address',
|
|
3385
|
-
remoteRefSection: 'Remote
|
|
3386
|
-
addressRefSection: 'Link an address',
|
|
3387
|
-
addressLinkHint: 'Turn this address into a reference',
|
|
3383
|
+
remoteRefSection: 'Remote files & folders',
|
|
3388
3384
|
ctxRename: 'Rename',
|
|
3389
3385
|
ctxDelete: 'Delete',
|
|
3390
3386
|
ctxChmod: 'Change permissions',
|
|
@@ -3541,7 +3537,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3541
3537
|
* Host methods the running DSH process does not have yet, the directory
|
|
3542
3538
|
* pane says so instead of surfacing an unrelated error.
|
|
3543
3539
|
*/
|
|
3544
|
-
var HOST_API_REVISION =
|
|
3540
|
+
var HOST_API_REVISION = 11;
|
|
3545
3541
|
var hostInfoProbe = null;
|
|
3546
3542
|
|
|
3547
3543
|
function probeHostInfo() {
|
|
@@ -4434,6 +4430,60 @@ function attributeViolation(name, value, tagName) {
|
|
|
4434
4430
|
panelMemory.set(key, Object.assign({}, panelMemory.get(key) || {}, next));
|
|
4435
4431
|
}
|
|
4436
4432
|
|
|
4433
|
+
// The panel memory dies with the page: keep the open file tabs in
|
|
4434
|
+
// localStorage too, one entry per pane key (session + mode + pinned
|
|
4435
|
+
// workspace), so a reload or a Host restart reopens what was open.
|
|
4436
|
+
var PANE_TABS_KEY = 'dsh-linked-workspace:pane-tabs';
|
|
4437
|
+
var PANE_TABS_LIMIT = 12;
|
|
4438
|
+
var PANE_FILES_LIMIT = 24;
|
|
4439
|
+
|
|
4440
|
+
function readPaneTabs() {
|
|
4441
|
+
try {
|
|
4442
|
+
var raw = window.localStorage.getItem(PANE_TABS_KEY);
|
|
4443
|
+
if (!raw) return {};
|
|
4444
|
+
var parsed = JSON.parse(raw);
|
|
4445
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
4446
|
+
} catch (error) { return {}; }
|
|
4447
|
+
}
|
|
4448
|
+
|
|
4449
|
+
function storedFile(file) {
|
|
4450
|
+
if (!file || typeof file !== 'object') return null;
|
|
4451
|
+
if (typeof file.key !== 'string' || file.key === '') return null;
|
|
4452
|
+
if (file.side !== 'local' && file.side !== 'remote') return null;
|
|
4453
|
+
if (typeof file.path !== 'string' || file.path === '') return null;
|
|
4454
|
+
var name = typeof file.name === 'string' && file.name !== '' ? file.name : file.path.split('/').pop();
|
|
4455
|
+
return { key: file.key, side: file.side, path: file.path, name: name, pinned: file.pinned !== false, line: 0 };
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
function recallPaneTabs(key) {
|
|
4459
|
+
if (!key) return null;
|
|
4460
|
+
var saved = readPaneTabs()[key];
|
|
4461
|
+
if (!saved || typeof saved !== 'object') return null;
|
|
4462
|
+
var files = (Array.isArray(saved.files) ? saved.files : [])
|
|
4463
|
+
.map(storedFile).filter(Boolean).slice(0, PANE_FILES_LIMIT);
|
|
4464
|
+
if (files.length === 0) return null;
|
|
4465
|
+
var activeKey = typeof saved.activeFileKey === 'string' ? saved.activeFileKey : '';
|
|
4466
|
+
var known = false;
|
|
4467
|
+
files.forEach(function (file) { if (file.key === activeKey) known = true; });
|
|
4468
|
+
if (!known) activeKey = files[files.length - 1].key;
|
|
4469
|
+
return { openFiles: files, activeFileKey: activeKey };
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4472
|
+
function rememberPaneTabs(key, openFiles, activeFileKey) {
|
|
4473
|
+
if (!key) return;
|
|
4474
|
+
try {
|
|
4475
|
+
var store = readPaneTabs();
|
|
4476
|
+
var files = (Array.isArray(openFiles) ? openFiles : []).map(storedFile).filter(Boolean).slice(0, PANE_FILES_LIMIT);
|
|
4477
|
+
if (files.length === 0) delete store[key];
|
|
4478
|
+
else store[key] = { files: files, activeFileKey: typeof activeFileKey === 'string' ? activeFileKey : '' };
|
|
4479
|
+
var keys = Object.keys(store);
|
|
4480
|
+
if (keys.length > PANE_TABS_LIMIT) {
|
|
4481
|
+
keys.slice(0, keys.length - PANE_TABS_LIMIT).forEach(function (stale) { delete store[stale]; });
|
|
4482
|
+
}
|
|
4483
|
+
window.localStorage.setItem(PANE_TABS_KEY, JSON.stringify(store));
|
|
4484
|
+
} catch (error) { /* a full or blocked localStorage must not break the panel */ }
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4437
4487
|
function clearHoverLines(card) {
|
|
4438
4488
|
var injected = card.querySelectorAll('[' + HOVER_LINE_ATTR + ']');
|
|
4439
4489
|
for (var index = 0; index < injected.length; index += 1) {
|
|
@@ -8171,8 +8221,10 @@ function rememberShowHidden(value) {
|
|
|
8171
8221
|
|
|
8172
8222
|
// Same idea as the trees: the tab strip outlives this component only if it
|
|
8173
8223
|
// is remembered per session.
|
|
8174
|
-
var
|
|
8175
|
-
|
|
8224
|
+
var paneSessionKey = String(props.sessionId || '').replace(/^session-/, '')
|
|
8225
|
+
|| String(pinnedLinkedId || pinnedRemoteId || '') || 'pane';
|
|
8226
|
+
var paneMemoryKey = [paneSessionKey, remoteOnly ? 'remote' : 'linked', pinnedLinkedId, pinnedRemoteId].join('|');
|
|
8227
|
+
var rememberedPane = recallPanel(paneMemoryKey) || recallPaneTabs(paneMemoryKey) || {};
|
|
8176
8228
|
var openFilesState = useState(function () {
|
|
8177
8229
|
return Array.isArray(rememberedPane.openFiles) ? rememberedPane.openFiles.slice() : [];
|
|
8178
8230
|
});
|
|
@@ -8186,6 +8238,7 @@ function rememberShowHidden(value) {
|
|
|
8186
8238
|
|
|
8187
8239
|
useEffect(function () {
|
|
8188
8240
|
rememberPanel(paneMemoryKey, { openFiles: openFiles, activeFileKey: activeFileKey });
|
|
8241
|
+
rememberPaneTabs(paneMemoryKey, openFiles, activeFileKey);
|
|
8189
8242
|
}, [openFiles, activeFileKey]);
|
|
8190
8243
|
var directoryOpenState = useState(true);
|
|
8191
8244
|
var directoryOpen = directoryOpenState[0];
|
|
@@ -12483,6 +12536,22 @@ function rememberShowHidden(value) {
|
|
|
12483
12536
|
function referenceScopeFor(session) {
|
|
12484
12537
|
var cwd = sessionCwdOf(session);
|
|
12485
12538
|
var workspaceId = sessionWorkspaceIdOf(session);
|
|
12539
|
+
var sessionId = String((session && (session.sessionId || session.id)) || '');
|
|
12540
|
+
// The session object handed to a trigger source only carries its id, so ask
|
|
12541
|
+
// the Host which workspace owns it; fall back to the local scan below.
|
|
12542
|
+
if (sessionId !== '') {
|
|
12543
|
+
return apiCall('linked.sessionScope', { sessionId: sessionId }).then(function (resolved) {
|
|
12544
|
+
var scope = resolved && resolved.scope;
|
|
12545
|
+
if (scope && (scope.linkedId || scope.remoteId)) {
|
|
12546
|
+
return { linkedId: scope.linkedId, remoteId: scope.remoteId, root: scope.root || '' };
|
|
12547
|
+
}
|
|
12548
|
+
return scanReferenceScope(cwd, workspaceId);
|
|
12549
|
+
}).catch(function () { return scanReferenceScope(cwd, workspaceId); });
|
|
12550
|
+
}
|
|
12551
|
+
return scanReferenceScope(cwd, workspaceId);
|
|
12552
|
+
}
|
|
12553
|
+
|
|
12554
|
+
function scanReferenceScope(cwd, workspaceId) {
|
|
12486
12555
|
return apiCall('linked.list').catch(function () { return { links: [] }; }).then(function (linked) {
|
|
12487
12556
|
var links = (linked && linked.links) || [];
|
|
12488
12557
|
for (var index = 0; index < links.length; index += 1) {
|
|
@@ -12514,54 +12583,86 @@ function rememberShowHidden(value) {
|
|
|
12514
12583
|
if (!service || typeof service.registerSource !== 'function') return;
|
|
12515
12584
|
var t = makeT(readLocale(ctx));
|
|
12516
12585
|
|
|
12586
|
+
// One "@" lists the remote tree next to DSH's own local suggestions; the
|
|
12587
|
+
// section title keeps the two groups apart. Sessions that are not backed
|
|
12588
|
+
// by a linked/remote workspace return nothing, leaving the stock menu as
|
|
12589
|
+
// it is.
|
|
12590
|
+
//
|
|
12591
|
+
// Only ONE directory is listed per keystroke: "dir/prefix" is split and the
|
|
12592
|
+
// folder is listed, so the menu answers immediately. A fuzzy scan of the
|
|
12593
|
+
// whole tree (fs.references) takes 5–20 s over SSH and always lost the race
|
|
12594
|
+
// with the menu.
|
|
12517
12595
|
function candidates(session, request) {
|
|
12518
12596
|
var query = String((request && request.query) || '');
|
|
12519
|
-
var
|
|
12520
|
-
|
|
12521
|
-
// A single "@" keeps the stock menu untouched unless the query already
|
|
12522
|
-
// reads like a path, which is the "type an address, get a reference" case.
|
|
12523
|
-
var looksLikePath = wanted.indexOf('/') >= 0 || wanted.indexOf('\\') >= 0 || wanted.charAt(0) === '~';
|
|
12524
|
-
if (!remoteIntent && !looksLikePath) return Promise.resolve([]);
|
|
12525
|
-
if (wanted === '') {
|
|
12526
|
-
if (!remoteIntent) return Promise.resolve([]);
|
|
12527
|
-
}
|
|
12597
|
+
var signal = request && request.signal;
|
|
12598
|
+
if (signal && signal.aborted) return Promise.resolve([]);
|
|
12528
12599
|
return referenceScopeFor(session).then(function (scope) {
|
|
12529
12600
|
if (!scope) return [];
|
|
12530
|
-
var
|
|
12601
|
+
var slash = query.lastIndexOf('/');
|
|
12602
|
+
var dirPart = slash >= 0 ? query.slice(0, slash) : '';
|
|
12603
|
+
var namePart = slash >= 0 ? query.slice(slash + 1) : query;
|
|
12604
|
+
var params = { path: dirPart === '' ? '.' : dirPart, limit: 500 };
|
|
12531
12605
|
if (scope.linkedId) params.linkedId = scope.linkedId;
|
|
12532
12606
|
if (scope.remoteId) params.remoteId = scope.remoteId;
|
|
12533
|
-
return apiCall('fs.
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12607
|
+
return apiCall('fs.list', params).catch(function () { return { entries: [] }; }).then(function (result) {
|
|
12608
|
+
if (signal && signal.aborted) return [];
|
|
12609
|
+
var needle = namePart.toLowerCase();
|
|
12610
|
+
var entries = (result && result.entries) || [];
|
|
12611
|
+
var out = [];
|
|
12612
|
+
for (var index = 0; index < entries.length && out.length < 30; index += 1) {
|
|
12613
|
+
var entry = entries[index] || {};
|
|
12614
|
+
var name = String(entry.name || '');
|
|
12615
|
+
if (name === '') continue;
|
|
12616
|
+
if (needle !== '' && name.toLowerCase().indexOf(needle) < 0) continue;
|
|
12617
|
+
var isDir = entry.type === 'dir';
|
|
12618
|
+
var relative = String(entry.relative || (dirPart === '' ? name : dirPart.replace(/\/+$/, '') + '/' + name));
|
|
12619
|
+
var mention = mentionRefFor(relative, isDir);
|
|
12620
|
+
if (!mention) continue;
|
|
12621
|
+
// Same shape as DSH's own file source: name carries the trailing
|
|
12622
|
+
// slash for folders, "drill" makes the row open the folder instead
|
|
12623
|
+
// of inserting it, and no description is rendered (the menu shows
|
|
12624
|
+
// the icon plus the bare name, exactly like "文件与文件夹").
|
|
12625
|
+
out.push(Object.assign({
|
|
12626
|
+
name: isDir ? name + '/' : name,
|
|
12541
12627
|
icon: isDir ? 'folder' : 'file',
|
|
12542
|
-
section:
|
|
12543
|
-
|
|
12544
|
-
};
|
|
12545
|
-
}
|
|
12628
|
+
section: t('remoteRefSection'),
|
|
12629
|
+
value: JSON.stringify({ kind: 'file', fileKind: isDir ? 'directory' : 'file', label: name, mention: mention }),
|
|
12630
|
+
}, isDir ? { drill: true } : {}));
|
|
12631
|
+
}
|
|
12632
|
+
return out;
|
|
12546
12633
|
});
|
|
12547
12634
|
});
|
|
12548
12635
|
}
|
|
12549
12636
|
|
|
12637
|
+
function candidateValue(candidate) {
|
|
12638
|
+
try {
|
|
12639
|
+
var parsed = JSON.parse(String((candidate && candidate.value) || ''));
|
|
12640
|
+
if (parsed && parsed.kind === 'file' && typeof parsed.mention === 'string' && parsed.mention !== '') return parsed;
|
|
12641
|
+
} catch (error) { /* fall through to the name-based path */ }
|
|
12642
|
+
return null;
|
|
12643
|
+
}
|
|
12644
|
+
|
|
12550
12645
|
function onPick(pick) {
|
|
12551
12646
|
var candidate = (pick && pick.candidate) || {};
|
|
12552
|
-
var
|
|
12553
|
-
|
|
12554
|
-
var
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
var
|
|
12647
|
+
var value = candidateValue(candidate);
|
|
12648
|
+
var isDir = value ? value.fileKind === 'directory' : candidate.icon === 'folder';
|
|
12649
|
+
var label = value && typeof value.label === 'string' && value.label !== ''
|
|
12650
|
+
? value.label
|
|
12651
|
+
: String(candidate.name || '').replace(/\/+$/, '').split('/').pop();
|
|
12652
|
+
var mention = value ? value.mention : mentionRefFor(String(candidate.name || ''), isDir);
|
|
12653
|
+
if (!mention) return undefined;
|
|
12654
|
+
// Tab (and clicking) on a folder walks INTO it, mirroring DSH's own file
|
|
12655
|
+
// group: the token becomes "@dir/" and the menu stays open.
|
|
12656
|
+
if (isDir && pick && pick.action === 'drill') {
|
|
12657
|
+
return { text: mention, continue: true };
|
|
12658
|
+
}
|
|
12558
12659
|
return {
|
|
12559
12660
|
insert: {
|
|
12560
12661
|
source: 'linked-workspace',
|
|
12561
|
-
ref:
|
|
12562
|
-
label: label ||
|
|
12662
|
+
ref: mention,
|
|
12663
|
+
label: isDir ? (label || mention) + '/' : (label || mention),
|
|
12563
12664
|
appearance: isDir ? 'folder' : 'file',
|
|
12564
|
-
clipboardText:
|
|
12665
|
+
clipboardText: mention,
|
|
12565
12666
|
},
|
|
12566
12667
|
};
|
|
12567
12668
|
}
|
|
@@ -12569,7 +12670,10 @@ function rememberShowHidden(value) {
|
|
|
12569
12670
|
var source = {
|
|
12570
12671
|
trigger: '@',
|
|
12571
12672
|
name: 'linked-workspace',
|
|
12572
|
-
order:
|
|
12673
|
+
// DSH's own @ sources leave `order` at 0 (see dsh-client-ui-reference:
|
|
12674
|
+
// `{ trigger: '@', name: 'reference' }`), and the menu sorts sources by
|
|
12675
|
+
// that number, so a negative value puts the remote group first.
|
|
12676
|
+
order: -1,
|
|
12573
12677
|
showGroupTitle: true,
|
|
12574
12678
|
candidates: candidates,
|
|
12575
12679
|
onPick: onPick,
|
|
@@ -12593,7 +12697,7 @@ function rememberShowHidden(value) {
|
|
|
12593
12697
|
// `sessions` is a core client service (the sidebar shell injects it too):
|
|
12594
12698
|
// the directory entries need the focused session's cwd/workspaceId to
|
|
12595
12699
|
// decide whether they belong in the "+" menu.
|
|
12596
|
-
var inject = ['slots', 'locale', 'sessions'];
|
|
12700
|
+
var inject = ['slots', 'locale', 'sessions', 'inputTriggers'];
|
|
12597
12701
|
|
|
12598
12702
|
function apply(ctx) {
|
|
12599
12703
|
ctx.effect(installStyles, 'dsh-linked-workspace: styles');
|
|
@@ -12764,13 +12868,23 @@ function rememberShowHidden(value) {
|
|
|
12764
12868
|
// notifies without touching the stored tabs, so open pages survive.
|
|
12765
12869
|
var visibilitySignature = '';
|
|
12766
12870
|
|
|
12871
|
+
// '' means "the session store has not caught up yet" — a poll can hand us
|
|
12872
|
+
// a snapshot without the session on screen for a moment, and tearing the
|
|
12873
|
+
// entries down then would close the pages open inside them.
|
|
12767
12874
|
function currentVisibilitySignature() {
|
|
12875
|
+
var scope = readActiveScope();
|
|
12876
|
+
if (!scope.cwd && !scope.workspaceId) return '';
|
|
12877
|
+
activeScopeCache = scope;
|
|
12768
12878
|
return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
|
|
12769
12879
|
}
|
|
12770
12880
|
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12881
|
+
// Re-registering is what makes the sidebar rebuild its "+" entries, and it
|
|
12882
|
+
// is only safe while the answer is stable: a page keeps its open files and
|
|
12883
|
+
// its scroll position as long as the descriptor stays put, so a short quiet
|
|
12884
|
+
// period is required before the descriptors are swapped.
|
|
12885
|
+
var visibilityTimer = null;
|
|
12886
|
+
|
|
12887
|
+
function applyVisibilitySignature(next) {
|
|
12774
12888
|
visibilitySignature = next;
|
|
12775
12889
|
if (linkedTabDisposer === null && remoteTabDisposer === null) return;
|
|
12776
12890
|
disposeLinkedTab();
|
|
@@ -12779,6 +12893,25 @@ function rememberShowHidden(value) {
|
|
|
12779
12893
|
installRemoteTab(false);
|
|
12780
12894
|
}
|
|
12781
12895
|
|
|
12896
|
+
function syncTabVisibility() {
|
|
12897
|
+
var next = currentVisibilitySignature();
|
|
12898
|
+
if (next === '') return;
|
|
12899
|
+
if (next === visibilitySignature) {
|
|
12900
|
+
if (visibilityTimer !== null) {
|
|
12901
|
+
clearTimeout(visibilityTimer);
|
|
12902
|
+
visibilityTimer = null;
|
|
12903
|
+
}
|
|
12904
|
+
return;
|
|
12905
|
+
}
|
|
12906
|
+
if (visibilityTimer !== null) clearTimeout(visibilityTimer);
|
|
12907
|
+
visibilityTimer = setTimeout(function () {
|
|
12908
|
+
visibilityTimer = null;
|
|
12909
|
+
var settled = currentVisibilitySignature();
|
|
12910
|
+
if (settled === '' || settled === visibilitySignature) return;
|
|
12911
|
+
applyVisibilitySignature(settled);
|
|
12912
|
+
}, 900);
|
|
12913
|
+
}
|
|
12914
|
+
|
|
12782
12915
|
function watchSessionScope() {
|
|
12783
12916
|
visibilitySignature = currentVisibilitySignature();
|
|
12784
12917
|
try {
|
|
@@ -12884,7 +13017,14 @@ function rememberShowHidden(value) {
|
|
|
12884
13017
|
installRemoteTab();
|
|
12885
13018
|
installSettingsTab();
|
|
12886
13019
|
watchSessionScope();
|
|
12887
|
-
|
|
13020
|
+
var initialSignature = currentVisibilitySignature();
|
|
13021
|
+
if (initialSignature !== '') applyVisibilitySignature(initialSignature);
|
|
13022
|
+
tabDisposers.push(function () {
|
|
13023
|
+
if (visibilityTimer !== null) {
|
|
13024
|
+
clearTimeout(visibilityTimer);
|
|
13025
|
+
visibilityTimer = null;
|
|
13026
|
+
}
|
|
13027
|
+
});
|
|
12888
13028
|
try {
|
|
12889
13029
|
tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
|
|
12890
13030
|
} catch (error) { /* state subscription is optional */ }
|
package/lib/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export const inject = ['webServer', 'tools', 'systemPrompt', 'workingDirectory']
|
|
|
39
39
|
* is still running an older copy of the Host — refreshing the page only swaps
|
|
40
40
|
* the browser bundle, so the two halves can drift by one restart.
|
|
41
41
|
*/
|
|
42
|
-
const API_REVISION =
|
|
42
|
+
const API_REVISION = 11
|
|
43
43
|
|
|
44
44
|
/** When this copy of the Host was loaded; shown by `meta.info`. */
|
|
45
45
|
const STARTED_AT = new Date().toISOString()
|
|
@@ -3170,6 +3170,31 @@ export function apply(ctx) {
|
|
|
3170
3170
|
|
|
3171
3171
|
// ── method table ─────────────────────────────────────────────────────────
|
|
3172
3172
|
|
|
3173
|
+
// The trigger hands us a bare session id, the registry stores "session-<id>".
|
|
3174
|
+
function sameSessionIdKey(value) {
|
|
3175
|
+
const text = String(value == null ? '' : value).trim().toLowerCase()
|
|
3176
|
+
return text.startsWith('session-') ? text.slice('session-'.length) : text
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
// Windows paths are case-insensitive and may mix separators; compare the
|
|
3180
|
+
// resolved forms so a session cwd still matches its workspace record.
|
|
3181
|
+
function sameWorkspacePath(left, right) {
|
|
3182
|
+
const a = String(left == null ? '' : left)
|
|
3183
|
+
const b = String(right == null ? '' : right)
|
|
3184
|
+
if (a === '' || b === '') return false
|
|
3185
|
+
const normalize = (value) => {
|
|
3186
|
+
let text = value
|
|
3187
|
+
try {
|
|
3188
|
+
text = resolve(value)
|
|
3189
|
+
} catch (error) {
|
|
3190
|
+
text = value
|
|
3191
|
+
}
|
|
3192
|
+
text = text.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
3193
|
+
return process.platform === 'win32' ? text.toLowerCase() : text
|
|
3194
|
+
}
|
|
3195
|
+
return normalize(a) === normalize(b)
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3173
3198
|
const methods = {
|
|
3174
3199
|
async 'hosts.list'(params) {
|
|
3175
3200
|
const hosts = await refreshHosts(Boolean(params && params.refresh))
|
|
@@ -4700,6 +4725,51 @@ export function apply(ctx) {
|
|
|
4700
4725
|
* Path completion for `@`-style references (0.18.0). Returns candidate
|
|
4701
4726
|
* paths relative to the remote root, best match first. Names only.
|
|
4702
4727
|
*/
|
|
4728
|
+
/**
|
|
4729
|
+
* Map one session to the linked/remote workspace that owns its directory.
|
|
4730
|
+
* The client half has no way to read a session's cwd, so the '@' reference
|
|
4731
|
+
* source asks for it here instead of guessing.
|
|
4732
|
+
*/
|
|
4733
|
+
async 'linked.sessionScope'(params = {}) {
|
|
4734
|
+
const sessionId = typeof params.sessionId === 'string' ? params.sessionId.trim() : ''
|
|
4735
|
+
if (sessionId === '') throw new ApiError('BAD_REQUEST', '缺少 sessionId')
|
|
4736
|
+
const registry = typeof ctx.get === 'function' ? ctx.get('workspaceRegistry') : null
|
|
4737
|
+
if (!registry || typeof registry.list !== 'function') return { scope: null }
|
|
4738
|
+
let cwd = ''
|
|
4739
|
+
let workspaces = []
|
|
4740
|
+
try {
|
|
4741
|
+
workspaces = registry.list() || []
|
|
4742
|
+
} catch (error) {
|
|
4743
|
+
workspaces = []
|
|
4744
|
+
}
|
|
4745
|
+
const wanted = sameSessionIdKey(sessionId)
|
|
4746
|
+
for (const workspace of workspaces) {
|
|
4747
|
+
if (!workspace || !Array.isArray(workspace.sessionIds)) continue
|
|
4748
|
+
let owned = false
|
|
4749
|
+
for (const candidate of workspace.sessionIds) {
|
|
4750
|
+
if (sameSessionIdKey(String(candidate == null ? '' : candidate)) === wanted) {
|
|
4751
|
+
owned = true
|
|
4752
|
+
break
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
if (!owned) continue
|
|
4756
|
+
cwd = String(workspace.path || '')
|
|
4757
|
+
break
|
|
4758
|
+
}
|
|
4759
|
+
if (cwd === '') return { scope: null }
|
|
4760
|
+
for (const record of linkedStore.list()) {
|
|
4761
|
+
if (sameWorkspacePath(cwd, record.localPath)) {
|
|
4762
|
+
return { scope: { linkedId: record.id, root: record.remotePath || '', cwd } }
|
|
4763
|
+
}
|
|
4764
|
+
}
|
|
4765
|
+
for (const record of remoteStore.list()) {
|
|
4766
|
+
if (sameWorkspacePath(cwd, record.placeholderPath)) {
|
|
4767
|
+
return { scope: { remoteId: record.id, root: record.remotePath || '', cwd } }
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
return { scope: null, cwd }
|
|
4771
|
+
},
|
|
4772
|
+
|
|
4703
4773
|
async 'fs.references'(params = {}) {
|
|
4704
4774
|
const scope = await requireScope(params)
|
|
4705
4775
|
const query = typeof params.query === 'string' ? params.query.trim() : ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "Linked local ⇄ remote workspaces and remote workspaces for DeepSeek Harness: theme-aware split editor, file-type icons, and agent tools that edit remote files directly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|