dsh-linked-workspace 0.25.0 → 0.26.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/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  English · [简体中文](CHANGELOG.zh.md)
4
4
 
5
+ ## 0.26.0 — 2026-11-24
6
+
7
+ - The `@` picker now knows which workspace a session belongs to: DSH hands the trigger
8
+ source only a `sessionId`, so the plugin asks the new `linked.sessionScope` method, which
9
+ matches the session against the workspace registry (ids are compared with or without the
10
+ `session-` prefix).
11
+ - Remote candidates are listed one directory at a time through `fs.list` instead of walking the
12
+ whole tree: the `@` menu answers in a few hundred milliseconds, where `fs.references` took
13
+ 5–20 s (and returns nothing at all for an empty query).
14
+ - The remote group now comes first and says what it is: the plugin registers its trigger source
15
+ with `order: -1` (DSH sorts sources by `order`, its own one uses the default 0) and the group is
16
+ titled **Remote files & folders**. DSH's own group keeps its label — it lives in the shell's
17
+ `reference` locale namespace, and registering that namespace again throws, so the plugin cannot
18
+ rename it.
19
+ - Open file tabs now survive a page reload and a Host restart: the tab list is mirrored into
20
+ `localStorage` under one key per pane (session + mode + pinned workspace), so reopening the
21
+ directory tab reopens the files you had open, with the same active tab. Unsaved edits and the
22
+ caret position are deliberately not restored — only the list.
23
+ - The directory panel no longer gets demolished by session polling: while a session snapshot
24
+ briefly lacks a cwd the tab descriptors are kept instead of disposed, and a signature change
25
+ must stay stable for 900 ms before the tabs are re-registered, so an open file tab (and the
26
+ expanded folders behind it) survive idle refreshes. The per-pane memory key also ignores the
27
+ optional `session-` prefix.
28
+ - One `@` now lists the remote tree: inside a linked or remote workspace the picker grows a
29
+ **Remote files** group next to DSH's own local suggestions, so the remote tree needs a single
30
+ keystroke instead of the old double `@`.
31
+ - The `@@` entry point is gone, and with it the separate "link an address" group: an address
32
+ after `@` (`/shared_data_…`, `~/…` or a workspace-relative path) simply appears as a remote
33
+ candidate you can pick.
34
+ - Fixed `npm run build` failing on a Windows checkout: the inline-parts marker was matched with
35
+ an LF-only string, so a CRLF working copy refused to build.
36
+
5
37
  ## 0.25.0 — 2026-11-23
6
38
 
7
39
  - 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
- - typing **`@@`** lists files and folders of the current workspace's **remote tree** (group “Remote references”); picking one inserts a real reference chip, and the model receives that remote path;
147
- - `@` followed by an address (absolute path, `~/…`, or a workspace-relative path containing `/`) resolves that address and offers **the address itself** (group “Address link”), so picking it links the file or folder — in both linked and remote workspaces.
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
+ - Candidates are listed **one directory at a time**: `@` opens the remote root, further characters filter by name, and a trailing `/` descends into that folder (for example `@code/` lists what is inside the remote `code/`), so a huge tree never stalls the menu;
148
149
  - The context menu still copies addresses: **Copy relative address** / **Copy absolute address** give the path itself, without an `@` prefix.
149
150
  - 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
- - Known limitation: candidates come from the plugin's `fs.references` (name matching, at most 30 rows), so the menu lists “remote paths found by name” rather than the whole tree; browse and click in the sidebar tree for that.
151
+ - At most 30 candidates per listing and hidden files are skipped; keep typing to narrow and descend, and use the sidebar tree when you want to browse.
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,12 @@
143
144
 
144
145
  - `references` 动作(对应 `fs.references`)按**路径名**做大小写不敏感匹配,最佳匹配排在最前(完全同名 → 前缀 → 包含),目录带 `dir` 标记;模型可以用它把你口头提到的文件名解析成远端真实路径。
145
146
  - 输入框里的 **`@`** 仍然是 DSH 原有的菜单(本地文件、文件夹、对话);插件往这个菜单里又加了一组自己的候选:
146
- - 打 **`@@`** 会列出**当前工作区远端树**的文件与文件夹(分节标题「远程引用」),选中后插入一个真正的引用 chip,模型收到的是该远端路径;
147
- - `@` 后面直接跟地址(绝对路径、`~/…`、或含 `/` 的工作区相对路径)时,会检测该地址并给出**这个地址本身**(分节标题「地址链接」),选中即建立链接——远程工作区与联动工作区都适用。
147
+ - 只要会话属于联动/远程工作区,单打一个 **`@`** 就会在 DSH 原生的本地候选之上,多出一组「**远程文件与文件夹**」(排在最前)——列出当前工作区远端树的文件与文件夹;选中后插入一个真正的引用 chip,模型收到的是该远端路径;
148
+ - 候选**每次只列一个目录**:`@` 打开远端根目录,再打字符按名字过滤,写完目录名加 `/` 会进到下一层(例如 `@code/` 列出远端 `code/` 里的内容),几千个文件也不会卡住菜单;
148
149
  - 右键仍然是取地址:**复制相对地址** / **复制绝对地址** 给出的是路径本身,不带 `@` 前缀。
149
150
  - 内容搜索多了两枚开关:「包含通常忽略的目录」(`node_modules`/`.venv`/`dist` 也会搜,`.git` 始终排除)、「只列文件名」;搜索中可以点「停止」中途取消,结果上方会显示「扫描 N 个文件 · X」。
150
- - 已知限制:候选来源是插件的 `fs.references`(按路径名匹配、最多 30 条),所以它列的是「按名字找到的远端路径」,不是整棵树的浏览器;要逐层浏览请用右侧栏目录树。
151
+ - 每个候选最多 30 条、跳过隐藏文件;按 `Ctrl/⌘` 逐层打字即可下钻,想整体浏览仍用右侧栏目录树。
152
+ - 分组顺序:插件注册触发器时用 `order: -1`(DSH 按 `order` 升序排,它自己的 source 用默认 0),所以「远程文件与文件夹」总排在最前,其次是 DSH 原生的「文件与文件夹」「对话」。DSH 那组的标题归外壳的 `reference` 文案命名空间所有,插件无法改名。
151
153
 
152
154
  ### 运行中图标 / 本地技能
153
155
 
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
- | `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) |
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,7 +30,17 @@ 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. 已知限制(需人工确认未变化):`@` 补全弹窗里不会出现远端路径 —— 宿主 `fileReferences` 服务只有 `list(agent, query, signal)`,没有 provider 注册入口。
33
+ 8. 触发字符由 DSH 外壳写死:`detectTrigger` 只认 `@` 与 `/`,`#` 之类的自定义字符即使 `registerSource` 接受也永远不会被匹配(真机确认:输入 `#may` 没有任何菜单,`#` 被直接丢弃)。
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
+ 12. 接口自检:`linked.sessionScope { sessionId }` → `{ scope: { linkedId | remoteId, root, cwd } }`;会话 id 带不带 `session-` 前缀都能解析;不属于任何联动/远程工作区时返回 `{ scope: null }`,此时 `@` 只剩 DSH 原生分组。
40
+ 14. 文件标签跨刷新与重启:打开「联动工作区目录」,点开两个文件(出现两个文件标签,记住当前标签)→ 刷新页面 → 两个标签与当前标签都恢复;再把 DSH(或 Web 实例的 Host 进程)整个重启,重新打开目录标签 → 标签依旧在。`localStorage` 里键为 `dsh-linked-workspace:pane-tabs`,每面板最多 24 个标签、最多记 12 个面板;关掉全部标签后该面板的记录会被删除。
41
+
42
+ 13. 面板不被轮询冲掉:在会话里打开右侧「联动工作区目录」,展开两层目录并点开一个文件(出现文件标签),然后闲置 50 秒以上 → 文件标签仍在、展开状态不变;期间会话快照短暂缺少 cwd 时两个目录标签也不会被注销(旧实现会 dispose 后重建,正在看的文件随之关闭)。
43
+
34
44
 
35
45
  ## 远端命令执行(0.17.0)
36
46
 
@@ -365,9 +375,9 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
365
375
  2. 点「编辑」进入编辑,向下滚动一段,切到另一个文件再切回来:仍是编辑模式,且滚动位置没有跳回顶部。
366
376
  3. 再点回「预览」,切走再切回:仍是预览,阅读位置保留。
367
377
  4. 打开 `.xlsx` / `.pptx` / `.pdf`,切到第 2 个工作表 / 幻灯片 / 页面,切走再切回:仍停在原处。
368
- 5. 在输入框里输入 `@@`:菜单出现「远程工作区」分组,列出远端文件与文件夹;选中一个后变成引用 chip。
378
+ 5. 在联动/远程工作区的会话里输入单个 `@`:除了 DSH 原生的本地候选,还会出现「远程目录」分组,列出远端文件与文件夹;选中一个后变成引用 chip。
369
379
  6. 输入 `@` 再输入 `README.md` 之类的名字:菜单仍是原有的本地文件/文件夹/对话,没有被远程条目污染。
370
- 7. 输入 `@@/shared_data_ssd1/huangjh` 或 `@code/projects_wpf`:菜单出现「按地址链接」分组,选中该地址即插入引用。
380
+ 7. 输入 `@/shared_data_ssd1/huangjh` 或 `@code/projects_wpf`:「远程目录」分组会把这个地址本身列为候选,选中即插入引用。
371
381
  8. 右键任一文件或文件夹:
372
382
  - 「复制绝对地址」→ 得到完整路径(远端形如 `/shared_data_ssd1/huangjh/code/a.txt`,本地形如 `D:\…\a.txt`);
373
383
  - 「复制相对地址」→ 左树得到相对**本地根**的路径(如 `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 workspace',
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 = 10;
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 paneMemoryKey = [props.sessionId || '', remoteOnly ? 'remote' : 'linked', pinnedLinkedId, pinnedRemoteId].join('|');
8175
- var rememberedPane = recallPanel(paneMemoryKey) || {};
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,35 +12583,48 @@ 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 remoteIntent = query.charAt(0) === '@';
12520
- var wanted = remoteIntent ? query.slice(1) : query;
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 params = { query: wanted, limit: 30 };
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.references', params).catch(function () { return { candidates: [] }; }).then(function (result) {
12534
- var items = (result && result.candidates) || [];
12535
- return items.map(function (item) {
12536
- var isDir = item.kind === 'directory';
12537
- return {
12538
- name: String(item.path || ''),
12539
- label: (item.name || String(item.path || '').split('/').pop()) + (isDir ? '/' : ''),
12540
- description: String(item.path || ''),
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
+ out.push({
12620
+ name: relative,
12621
+ label: name + (isDir ? '/' : ''),
12622
+ description: relative,
12541
12623
  icon: isDir ? 'folder' : 'file',
12542
- section: remoteIntent ? t('remoteRefSection') : t('addressRefSection'),
12543
- hint: remoteIntent ? undefined : t('addressLinkHint'),
12544
- };
12545
- }).filter(function (item) { return item.name !== ''; });
12624
+ section: t('remoteRefSection'),
12625
+ });
12626
+ }
12627
+ return out;
12546
12628
  });
12547
12629
  });
12548
12630
  }
@@ -12569,7 +12651,10 @@ function rememberShowHidden(value) {
12569
12651
  var source = {
12570
12652
  trigger: '@',
12571
12653
  name: 'linked-workspace',
12572
- order: 40,
12654
+ // DSH's own @ sources leave `order` at 0 (see dsh-client-ui-reference:
12655
+ // `{ trigger: '@', name: 'reference' }`), and the menu sorts sources by
12656
+ // that number, so a negative value puts the remote group first.
12657
+ order: -1,
12573
12658
  showGroupTitle: true,
12574
12659
  candidates: candidates,
12575
12660
  onPick: onPick,
@@ -12593,7 +12678,7 @@ function rememberShowHidden(value) {
12593
12678
  // `sessions` is a core client service (the sidebar shell injects it too):
12594
12679
  // the directory entries need the focused session's cwd/workspaceId to
12595
12680
  // decide whether they belong in the "+" menu.
12596
- var inject = ['slots', 'locale', 'sessions'];
12681
+ var inject = ['slots', 'locale', 'sessions', 'inputTriggers'];
12597
12682
 
12598
12683
  function apply(ctx) {
12599
12684
  ctx.effect(installStyles, 'dsh-linked-workspace: styles');
@@ -12764,13 +12849,23 @@ function rememberShowHidden(value) {
12764
12849
  // notifies without touching the stored tabs, so open pages survive.
12765
12850
  var visibilitySignature = '';
12766
12851
 
12852
+ // '' means "the session store has not caught up yet" — a poll can hand us
12853
+ // a snapshot without the session on screen for a moment, and tearing the
12854
+ // entries down then would close the pages open inside them.
12767
12855
  function currentVisibilitySignature() {
12856
+ var scope = readActiveScope();
12857
+ if (!scope.cwd && !scope.workspaceId) return '';
12858
+ activeScopeCache = scope;
12768
12859
  return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
12769
12860
  }
12770
12861
 
12771
- function syncTabVisibility() {
12772
- var next = currentVisibilitySignature();
12773
- if (next === visibilitySignature) return;
12862
+ // Re-registering is what makes the sidebar rebuild its "+" entries, and it
12863
+ // is only safe while the answer is stable: a page keeps its open files and
12864
+ // its scroll position as long as the descriptor stays put, so a short quiet
12865
+ // period is required before the descriptors are swapped.
12866
+ var visibilityTimer = null;
12867
+
12868
+ function applyVisibilitySignature(next) {
12774
12869
  visibilitySignature = next;
12775
12870
  if (linkedTabDisposer === null && remoteTabDisposer === null) return;
12776
12871
  disposeLinkedTab();
@@ -12779,6 +12874,25 @@ function rememberShowHidden(value) {
12779
12874
  installRemoteTab(false);
12780
12875
  }
12781
12876
 
12877
+ function syncTabVisibility() {
12878
+ var next = currentVisibilitySignature();
12879
+ if (next === '') return;
12880
+ if (next === visibilitySignature) {
12881
+ if (visibilityTimer !== null) {
12882
+ clearTimeout(visibilityTimer);
12883
+ visibilityTimer = null;
12884
+ }
12885
+ return;
12886
+ }
12887
+ if (visibilityTimer !== null) clearTimeout(visibilityTimer);
12888
+ visibilityTimer = setTimeout(function () {
12889
+ visibilityTimer = null;
12890
+ var settled = currentVisibilitySignature();
12891
+ if (settled === '' || settled === visibilitySignature) return;
12892
+ applyVisibilitySignature(settled);
12893
+ }, 900);
12894
+ }
12895
+
12782
12896
  function watchSessionScope() {
12783
12897
  visibilitySignature = currentVisibilitySignature();
12784
12898
  try {
@@ -12884,7 +12998,14 @@ function rememberShowHidden(value) {
12884
12998
  installRemoteTab();
12885
12999
  installSettingsTab();
12886
13000
  watchSessionScope();
12887
- syncTabVisibility();
13001
+ var initialSignature = currentVisibilitySignature();
13002
+ if (initialSignature !== '') applyVisibilitySignature(initialSignature);
13003
+ tabDisposers.push(function () {
13004
+ if (visibilityTimer !== null) {
13005
+ clearTimeout(visibilityTimer);
13006
+ visibilityTimer = null;
13007
+ }
13008
+ });
12888
13009
  try {
12889
13010
  tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
12890
13011
  } 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 = 10
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.25.0",
3
+ "version": "0.26.0",
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",