dsh-linked-workspace 0.14.0 → 0.16.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,45 @@
2
2
 
3
3
  English · [简体中文](CHANGELOG.zh.md)
4
4
 
5
+ ## 0.16.0 — 2026-11-16
6
+
7
+ - The workspace root no longer offers “Change permissions”, and the Host rejects it too: a stray 644 on the root makes the whole workspace look empty.
8
+ - The workspace root no longer offers “Rename” or “Delete”: the Host rejects both, so the old menu only produced a confirm dialog followed by an error.
9
+ - “Change permissions” starts from the right default per kind — 755 for folders (with a note that the execute bit matters) and 644 for files; the dialog also explains why 644 on a folder makes it look empty.
10
+ - Permission failures now name the usual cause (a folder missing its execute bit — set 755 again) in the editor panel, inside dialogs and in the banner.
11
+ - The hidden-file toggle is remembered in localStorage, so it survives reopening the tab; its tooltip no longer reads like a stutter.
12
+ - Starting a new action (open a file, refresh the tree, run a search) clears the previous error banner instead of leaving it pinned.
13
+ - The transfer queue reports throughput (for example `12.4 MB/s`) next to the byte count.
14
+ - Tree header shows the free space of the remote volume the workspace lives on
15
+ (`hosts.df`) and refreshes with the tree.
16
+ - "Download to the default folder" reports what actually landed — file count and
17
+ size — and warns when the 150-file / 15 MB cap cut the run short or a single
18
+ file over 20 MB was skipped. Multi-select can download every selected remote
19
+ entry at once ("Download N selected").
20
+ - Every confirmation dialog answers Escape, keeps Tab inside the dialog and
21
+ returns focus to the row that opened it.
22
+ - Notices can be closed by hand and are announced to screen readers; error
23
+ notices no longer vanish after 4.2 seconds, so a long SSH message can be read
24
+ and copied.
25
+ - Content search remembers the last eight queries and offers them as chips when
26
+ the box is empty; inside the editor Ctrl+Up / Ctrl+Down walk the hits of the
27
+ query that opened the file.
28
+ - The transfer dialog keeps the last 20 finished transfers, so closing it no
29
+ longer loses the record.
30
+ - The context menu gains "Copy ssh command" for remote folders — a ready to
31
+ paste `ssh host -t 'cd <dir> && exec $SHELL -l'`.
32
+ - "Open a copy in Notepad" is labelled as such (the copy is never written back)
33
+ and copies older than a day are swept on start, so the temp folder stops
34
+ growing forever.
35
+ - The host API suite removes its remote scratch tree in `finally` and clears
36
+ leftovers before it starts, so a failed run cannot leave debris behind.
37
+
38
+ ## 0.15.0 — 2026-11-15
39
+
40
+ - **Remote workspace files are editable**: a remote workspace’s remote tree now behaves like the remote side of a linked workspace — files open in the built-in editor, `Ctrl/Cmd+S` (and autosave) write straight back to the host, save conflicts are detected the usual way, and Markdown / Word / Excel / PowerPoint / PDF documents open in their document panes. Only the features that need a local directory stay linked-only: transfer to the local mirror, the transfer queue, two-way comparison, and the local terminal / local pane (the transfer button is disabled there and its tooltip says so).
41
+ - **`docs.*` accepts `remoteId`**: the document methods used to ignore `remoteId`, so remote documents were resolved as local absolute paths and failed; they now resolve the remote scope exactly like the `fs.*` methods do.
42
+ - **A stale Host is called out**: a new `meta.info` check (`{ version, apiRevision, startedAt }`) means a DSH process that still runs an older copy of the plugin now shows a banner in the directory pane (quit and restart DSH), instead of failing later with something like `ENOENT ... C:\shared_data_...`.
43
+
5
44
  ## 0.14.0 — 2026-11-14
6
45
 
7
46
  - **Content search shows the hit**: results now list the file **and** the matching line (number + trimmed snippet, one row per hit), clicking one opens the file with the caret on that line, and Markdown files switch to the code editor for the jump. Local and remote searches share the same limits (1 MB per file, 2000 files, 8 MB, 5 s) and the same default folder exclusions (`node_modules`, `.git`, `site-packages`, `dist`, `build`, `target`, `.venv`, `.conda`, …), so a remote scan no longer crawls a conda tree; when a scan is cut short the notice names the reason (files / bytes / time / result cap) instead of a bare “too many”.
package/README.en.md CHANGED
@@ -60,6 +60,9 @@ The plugin takes over the DSH sidebar/hero directory-selection hole; the dialog
60
60
 
61
61
  ### Sidebar: “Linked Workspace Directory”
62
62
 
63
+ The heading shows the free space of the remote volume that holds the workspace;
64
+ hover it for the total size and the used percentage.
65
+
63
66
  - Fixed on the far right of the sidebar: **remote tree on top, local tree below**, both rooted at “All files”; the plugin's `.local`/`.remote` internal folders are hidden from the local tree.
64
67
  - **Single-click opens, double-click pins**: single-click a folder to expand/collapse; single-click a file to open it in the content panel, replacing the current unpinned preview. Double-click a file to pin it so later single clicks do not replace it; double-clicking a folder only keeps it expanded.
65
68
  - Toolbar (top right of the sidebar):
@@ -89,8 +92,10 @@ Selecting several rows (`Ctrl/Cmd`-click toggles, `Shift`-click selects a range)
89
92
  Appears automatically for sessions that belong to a remote workspace (and can be opened any time from the settings card):
90
93
 
91
94
  - A **single remote tree** with no local pane; it is rooted at “All files” and the header shows `user@host · Remote`.
92
- - Files open **read-only** in the built-in editor (encoding, line endings, line count and size are still shown) and are never written back locally.
93
- - Context menu, search (name / content), hidden-file toggle and the 15-second refresh throttle match the remote tree of a linked workspace; transfer, two-way comparison and local-side actions are unavailable in this mode.
95
+ - Files are **editable in the built-in editor and saved straight back to the host** (Ctrl/Cmd+S, autosave, save-conflict prompt, find & replace and jump-to-match all behave like the linked workspace). Read-only protection still follows each file: binaries, files over 2 MB and truncated reads show “Read-only” and reject typing.
96
+ - Markdown, Word, Excel, PowerPoint and PDF documents open in their own panes and save back to the host as well.
97
+ - The context menu, search (name / content, including case, regex and “search this folder only”), hidden-file toggle and the 15-second refresh throttle match the linked workspace's remote tree: open, edit in Notepad, copy / paste, copy path, move to…, rename, delete, change permissions, open terminal here, new file / folder, properties, download, plus the batch “delete selected”, “move selected” and “rename selected”.
98
+ - Only the four features that need a local directory stay linked-only: **transfer to the local mirror, the transfer queue, two-way comparison, and the local terminal / local pane** (in a remote workspace the transfer button is disabled and its tooltip reads “Transfer needs a linked workspace (remote → local)”).
94
99
  - Both directory tabs (linked and remote) register eagerly, so a remote tree can be opened from settings even while the current session belongs to a linked workspace.
95
100
 
96
101
  ### Transfer, comparison and conflicts
@@ -206,7 +211,10 @@ Web browsers do not expose dropped file paths; the notice tells you to use the d
206
211
  `Ctrl+W` and `Ctrl+Tab` are taken by the browser; use the DSH desktop app for those shortcuts.
207
212
 
208
213
  **Changed the code but the UI is unchanged?**
209
- Run `npm run build` to regenerate `lib/client.js`, then restart the DSH client; Host changes require a process restart.
214
+ Run `npm run build` to regenerate `lib/client.js`, then restart the DSH client. Host changes are loaded when the DSH **process** starts; refreshing the page only swaps the browser half.
215
+
216
+ **The directory pane says “the plugin host is still running older code”?**
217
+ The copy of the plugin on disk is newer than the Host loaded by this DSH process. Quit DSH completely and open it again (a page refresh is not enough, and the plugin does not need reinstalling). Every directory pane compares versions through `meta.info`, so the notice never shows up on a matching install.
210
218
 
211
219
  ## Architecture and development
212
220
 
package/README.md CHANGED
@@ -60,6 +60,8 @@
60
60
 
61
61
  ### 右侧栏「联动工作区目录」
62
62
 
63
+ 目录栏标题右侧显示该工作区所在远端卷的可用空间,悬停可看到总量与已用百分比。
64
+
63
65
  - 面板固定在右侧栏最右边:**上方远端树,下方本地树**,两棵树根部都显示「所有文件」;本地树自动隐藏插件的 `.local`/`.remote` 内部目录。
64
66
  - **单击打开,双击固定**:单击文件夹立即展开/折叠;单击文件直接在文件内容面板打开,再次单击其他文件会替换当前未固定的预览标签。双击文件可固定该标签,之后单击其他文件不会覆盖它;双击文件夹只保持展开。
65
67
  - 工具栏(右侧栏右上角):
@@ -89,8 +91,10 @@
89
91
  会话属于某个远程工作区时自动出现(设置页的「打开目录树」也能随时打开):
90
92
 
91
93
  - 只有**一棵远端树**,不显示本地分栏;根节点同样是「所有文件」,标题栏显示 `用户名@主机 · 远程`。
92
- - 文件以**只读**方式在内部编辑器打开(显示编码、换行符、行数与大小),不会写回本地。
93
- - 右键菜单、搜索(文件名 / 内容)、隐藏文件开关、刷新节流(15 秒)与联动工作区的远端树一致;传输、双向对比、本地相关操作在该模式下不可用。
94
+ - 文件可在内部编辑器里**直接编辑并保存回远端**(`Ctrl/Cmd+S`、自动保存、保存冲突提示、查找替换、按命中行跳转都与联动工作区一致);只读保护仍按文件本身生效:二进制文件、超过 2 MB 或读取被截断时显示「只读」且不可输入。
95
+ - Markdown、Word、Excel、PowerPoint、PDF 等文档走各自的文档面板打开,编辑后同样保存回远端。
96
+ - 右键菜单、搜索(文件名 / 内容,含大小写、正则、限定当前目录)、隐藏文件开关、刷新节流(15 秒)与联动工作区的远端树完全一致:打开、用记事本编辑、复制 / 粘贴、复制路径、移动到…、重命名、删除、更改权限、在此打开终端、新建文件 / 文件夹、属性、下载,以及批量的「删除所选」「移动所选」「批量重命名所选」。
97
+ - 只有依赖本地目录的四项仍然只对联动工作区开放:**传输到本地镜像、传输队列、与本地目录对比、本地终端 / 本地分栏**(远程工作区里传输按钮为禁用态,悬停提示「传输只在联动工作区可用(远端 → 本地)」)。
94
98
  - 两个目录标签(联动 / 远程)都常驻注册,因此当前会话属于联动工作区时也能从设置页打开远程工作区目录树。
95
99
 
96
100
  ### 传输、对比与冲突处理
@@ -206,7 +210,10 @@ Web 端浏览器不暴露拖入文件的真实路径,会提示改用桌面端
206
210
  `Ctrl+W`、`Ctrl+Tab` 会被浏览器占用,请在 DSH 桌面端使用这些快捷键。
207
211
 
208
212
  **改了代码但界面没变?**
209
- 先 `npm run build` 重新生成 `lib/client.js`,再重启 DSH 客户端;Host 代码改动需要重启进程。
213
+ 先 `npm run build` 重新生成 `lib/client.js`,再重启 DSH 客户端;Host 代码改动需要在 **DSH 进程启动时**加载,刷新页面只换浏览器端的那一半。
214
+
215
+ **目录树顶部提示「DSH 的插件进程仍在运行旧版代码」?**
216
+ 说明磁盘上的插件已经更新,但当前 DSH 进程加载的还是旧版 Host。完全退出 DSH(不是刷新页面,也不需要重装插件)再打开即可;插件每次打开目录树都会用 `meta.info` 比对一次 Host 版本,正常时不会出现这条提示。
210
217
 
211
218
  ## 架构与开发
212
219
 
package/docs/API.md CHANGED
@@ -20,11 +20,11 @@ Codes: `BAD_REQUEST`, `NOT_FOUND`, `SSH_CONNECT`, `AUTH_FAILED`,
20
20
 
21
21
  | Method | Params | Result |
22
22
  | --- | --- | --- |
23
- | `docs.read` | `{ path, linkedId?, workspaceId? }` | kind-specific document model |
24
- | `docs.write` | `{ path, data, expectedMtime?, linkedId?, workspaceId? }` | `{ kind, path, size, mtime }` |
25
- | `docs.create` | `{ path, kind?, linkedId?, workspaceId? }` | `{ kind, path, size, mtime }` |
26
- | `docs.mdPreview` | `{ path, text?, linkedId?, workspaceId? }` | `{ kind, html }` |
27
- | `docs.mdPdf` | `{ path, text?, linkedId?, workspaceId? }` | `{ kind: "pdf", path, size, mtime }` |
23
+ | `docs.read` | `{ path, linkedId?, remoteId? }` | kind-specific document model |
24
+ | `docs.write` | `{ path, data, expectedMtime?, linkedId?, remoteId? }` | `{ kind, path, size, mtime }` |
25
+ | `docs.create` | `{ path, kind?, linkedId?, remoteId? }` | `{ kind, path, size, mtime }` |
26
+ | `docs.mdPreview` | `{ path, text?, linkedId?, remoteId? }` | `{ kind, html }` |
27
+ | `docs.mdPdf` | `{ path, text?, linkedId?, remoteId? }` | `{ kind: "pdf", path, size, mtime }` |
28
28
 
29
29
  ## Records
30
30
 
@@ -54,6 +54,7 @@ scope root, or absolute inside it.
54
54
  | `hosts.list` | `{ refresh? }` | `{ hosts: HostInfo[] }` (`HostInfo` carries `authType`, `hasCredential`, `hasStoredPassword`) |
55
55
  | `hosts.credentials` | `{ hostId, password?, passphrase?, privateKey?, clear? }` | `{ hostId, authType, hasCredential, hasStoredPassword }` (stores the secret in the plugin's own `ssh-credentials.json`; `clear: true` deletes it) |
56
56
  | `hosts.browse` | `{ hostId, path? }` | `{ path, parent, home, entries }` (dirs + files) |
57
+ | `hosts.df` | `{ hostId, path? }` | `{ disk: { path, size, used, avail, percent } \| null }` (free space of the volume holding `path`; defaults to the login home) |
57
58
  | `hosts.mkdir` | `{ hostId, path?, name }` | `{ path }` (creates `name` inside `path`; defaults to the login home; `409`/`FS_EXISTS` when it already exists) |
58
59
  | `remote_workspaces.list` | `{}` | `{ workspaces: RemoteWorkspaceInfo[] }` |
59
60
  | `remote_workspaces.create` | `{ hostId, remotePath, name? }` | `{ workspace }` |
@@ -71,6 +72,7 @@ scope root, or absolute inside it.
71
72
  | `fs.move` | `{ linkedId?/remoteId?, path, targetDir? }` | `{ path }` (same remote tree; collision → 409) |
72
73
  | `fs.delete` | `{ linkedId?/remoteId?, path }` | `{}` |
73
74
  | `fs.home` | `{ linkedId?/remoteId? }` | `{ home }` |
75
+ | `meta.info` | `{}` | `{ version, apiRevision, startedAt }` (the client warns when `apiRevision` is older than its own, i.e. DSH still runs an older copy of this plugin) |
74
76
  | `settings.get` | `{}` | `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }` |
75
77
  | `settings.update` | `{ editorTheme?, editorThemeFamily?, editorThemeMode?, fileOpenMode?, autoSave? }` | `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }` |
76
78
  | `local.browse` | `{ path? }` | `{ path, parent, home, entries: [{ name, path }] }` |
package/docs/VERIFY.md CHANGED
@@ -27,16 +27,18 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
27
27
  7. 远程页签:`1. 选择 SSH 连接 / 2. 远程目录 / 3. 工作区名称`(编号连续、无本地目录步骤)→ 创建后左侧出现占位目录工作区。
28
28
  8. 已有旧工作区若标题仍带 `⇄ `:Host 启动约 1 s 内自动去掉前缀(`linked.list` 的 `workspaceTitle` 同步更新)。
29
29
 
30
- ## 远程工作区(0.11.0)
30
+ ## 远程工作区(0.11.0,0.15.0 起可编辑)
31
31
 
32
32
  1. **设置页分组**:设置 → 联动工作区 →「远程工作区」组显示计数与说明「会话运行在远端目录:DSH 不在本地创建项目文件,模型通过 remote_workspace 与 linked_workspace 工具读写远端。」;无记录时显示「还没有远程工作区…」。
33
33
  2. **创建**:顶部「创建远程工作区」→ 选主机、填已存在的远端目录、名称 → 卡片出现,左侧工作区列表同步新增同名 DSH 工作区。
34
34
  3. **卡片操作**:打开工作区(跳转并关闭设置)、打开目录树(新标签页出现并关闭设置对话框)、测试连接(Banner「连接正常」)、重命名(卡片与左侧工作区同步改名)、移除远程工作区(两步确认,文案「只移除记录与占位目录,不会删除远端文件。」)。
35
- 4. **目录树**:点「打开目录树」→ 右侧栏出现「远程工作区目录」标签,只有「远程目录」一棵树,根节点「所有文件」;点文件以只读方式打开(状态栏显示 UTF-8 / LF / 行数 / 大小 / 只读)。
36
- 5. **会话链路**:切到该工作区新建会话,让模型 `linked_workspace` `list` / `list_dir` → 能确认 workspaceId、占位目录与远端根目录,并列出远端顶层内容。
37
- 6. **移除清理**:移除后卡片消失、计数归零、左侧工作区消失;`$DSH_HOME/linked-workspace/remote-placeholders/` 下不再有该占位目录,`remote-workspaces.json` 中记录被删除。
38
- 7. **远端目录必须已存在**:填一个不存在的路径 → 报错 `FS_NOT_FOUND`(不会自动创建)。
39
- 8. **标签常驻**:当前会话属于联动工作区时,设置页仍能打开远程工作区目录树(不再依赖会话 scope 才注册标签)。
35
+ 4. **目录树编辑**:点「打开目录树」→ 右侧栏出现「远程工作区目录」标签,只有「远程目录」一棵树,根节点「所有文件」;点一个文本文件以可编辑方式打开(状态栏显示 UTF-8 / LF / 行数 / 大小),改一行后 `Ctrl/Cmd+S` 保存,状态栏出现「已保存」;用 `ssh` 查看远端文件确认内容已变。二进制文件、超过 2 MB 的文件仍显示「只读」且无法输入。
36
+ 5. **文档面板**:打开远端的 `.md` → 文档面板可编辑并保存回远端;`.xlsx` / `.docx` 打开不再报错(旧版本会落到本地路径而失败)。
37
+ 6. **菜单与工具栏对齐**:右键菜单出现「用记事本编辑 / 复制 / 粘贴 / 复制路径 / 移动到… / 重命名 / 删除 / 更改权限 / 在此打开终端 / 新建文件 / 新建文件夹 / 属性 / 下载」,**不出现**「传输… / 队列 / 与本地对比」;多选后出现「删除所选的 N 项 / 移动所选的 N 项 / 批量重命名所选的 N 项」,不出现「传输所选的 N 项」;工具栏传输按钮为禁用态,悬停提示「传输只在联动工作区可用(远端 → 本地)」。
38
+ 7. **会话链路**:切到该工作区新建会话,让模型 `linked_workspace` `list` / `list_dir` → 能确认 workspaceId、占位目录与远端根目录,并列出远端顶层内容。
39
+ 8. **移除清理**:移除后卡片消失、计数归零、左侧工作区消失;`$DSH_HOME/linked-workspace/remote-placeholders/` 下不再有该占位目录,`remote-workspaces.json` 中记录被删除。
40
+ 9. **远端目录必须已存在**:填一个不存在的路径 → 报错 `FS_NOT_FOUND`(不会自动创建)。
41
+ 10. **标签常驻**:当前会话属于联动工作区时,设置页仍能打开远程工作区目录树(不再依赖会话 scope 才注册标签)。
40
42
 
41
43
  ## 首次运行欢迎卡片(0.13.0)
42
44
 
@@ -246,7 +248,36 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
246
248
  8. **注册工作区**:联动记录的 `workspaceId` 为空时,设置页应显示「注册为工作区」,点击后变为正常的工作区信息。
247
249
  9. **拖拽提示**:拖本地目录到远端、拖远端目录到本地:应分别给出「暂不支持把本地目录拖拽到远端…」「暂不支持把远程目录拖拽到本地…」(同一棵树内拖拽是移动,见下一节)。
248
250
  10. **悬停展开**:拖拽停在折叠目录行 700 ms:该目录应自动展开。
249
- 11. **host-api**:`node test/host-api.mjs` 应为 28 步全部通过。
251
+ 11. **host-api**:`node test/host-api.mjs` 应为 33 步全部通过(0.15.0 起含 `meta.info`)。
252
+
253
+ ## 提示、对话框与下载(Unreleased)
254
+
255
+ 1. 目录栏标题右侧出现可用空间(如「7983.64 GB」),悬停显示「可用 …(已用 17%)· 已用 / 总量」;换工作区后数字随之变化。
256
+ 2. 对含 150 个以上文件的远端目录右键「下载到默认文件夹」:提示里带文件数与体积,并以「达到上限,未全部下载」结尾;下载目录里确实是 150 个文件。
257
+ 3. 对含超过 20 MB 单文件的目录执行同样操作:提示以「跳过 1 个(超过 20 MB)」结尾。
258
+ 4. 多选两个远端文件后右键:出现「下载所选的 2 项」,执行后一条汇总提示,本地两个文件都在。
259
+ 5. 右键「移动到…」打开对话框后按 Esc:对话框关闭,焦点回到刚才那一行;对话框内按 Tab 不会跑到后面的页面上。
260
+ 6. 触发一条错误提示(例如对只读目录重命名):提示不再自动消失,右侧有 × 可关闭;读屏软件能读到(role=status)。
261
+ 7. 内容搜索输入关键词回车,清空输入框后出现「最近搜索」chip;点 chip 重新搜索。
262
+ 8. 打开一条命中后按 Ctrl+↓:光标跳到下一处命中并被选中,Ctrl+↑ 回到上一处。
263
+ 9. 传输一个文件后打开「队列」:除队列外还有「最近的传输」,关闭对话框再打开仍在。
264
+ 10. 远端目录右键出现「复制 ssh 命令」,粘贴得到 `ssh <主机> -t 'cd <目录> && exec $SHELL -l'`。
265
+ 11. 右键菜单显示「用记事本打开副本(不回写)」;`%TEMP%\dsh-linked-workspace-open` 里超过一天的文件在下次启动后消失。
266
+
267
+ 12. 右键工作区根节点(最上面的「所有文件」/远端根目录):菜单里**没有**「重命名」「删除」,其余项(复制、粘贴、复制路径、复制 ssh 命令、更改权限、在此打开终端、新建…、与本地对比、属性)照常出现。
268
+ 13. 对**目录**点「更改权限」:标题下方写「目录权限(需要含 7 才有进入权限,如 755)」,默认值 `755`;对**文件**点同名项:文案是「八进制权限(如 644 / 0755)」,默认值 `644`。
269
+ 14. 故意把某个目录改成 644,再打开目录里的文件:编辑器显示「没有权限访问该路径…Permission denied(目录可能缺少执行位:用「更改权限」改回 755 即可恢复)」;改回 755 后文件恢复可读。
270
+ 15. 关闭隐藏文件显示后刷新页面:按钮仍显示「显示以 . 开头的文件」,树里依旧不出现 `.conda` 等点开头条目(选择被记住)。
271
+ 16. 触发一次错误提示后,再打开一个文件或点「刷新目录」:之前那条红色提示自动消失。
272
+ 17. 传一个较大的目录到远端,观察队列对话框的进行中行:进度后面会跟上吞吐,形如 `已传 3 个 · 12.0 MB · 4.1 MB/s`。
273
+ 18. 右键工作区根节点:菜单里**没有**「更改权限」(也没有「重命名」「删除」「移动到…」)。绕过界面直接请求 `fs.chmod` 并把 `path` 指向工作区远端根:返回 400「不能修改工作区根目录的权限」,随后 `fs.stat` 的权限保持不变。
274
+ ## 旧 Host 自检(0.15.0)
275
+
276
+ 1. **正常时不打扰**:插件已重启过后打开任意目录树,顶部**不应**出现任何黄色提示条。
277
+ 2. **旧进程会被指出来**:把 `lib/index.js` 的 `const API_REVISION` 临时改成比客户端 `HOST_API_REVISION`(`src/client.js`)小的值,`npm run build` 后重启实例、打开目录树:顶部出现黄色提示「DSH 的插件进程仍在运行旧版代码,请完全退出并重启 DSH 后再试」。改回原值并重启后提示消失。
278
+ 3. **方法缺失同样算旧**:让 Host 不提供 `meta.info`(例如回退到 0.14.0 的 `lib/index.js`)时,客户端收到 `unknown method`,同样显示上面那条提示,而不是把后续操作失败暴露成 `ENOENT` 之类的原始错误。
279
+ 4. **接口自检**:`curl` 或 Debug 面板调用 `meta.info` 应返回 `{ version, apiRevision, startedAt }`,`apiRevision` 与客户端常量一致。
280
+ 5. **host-api**:`node test/host-api.mjs` 应包含并通过 `meta.info` 一步(33 步全部通过)。
250
281
 
251
282
  ## 批量拖拽与移动(0.13.0)
252
283
 
package/lib/client.js CHANGED
@@ -2515,7 +2515,7 @@ function attributeViolation(name, value, tagName) {
2515
2515
  ctxDownload: '下载到默认文件夹',
2516
2516
  ctxQueue: '队列',
2517
2517
  ctxOpen: '打开',
2518
- ctxNotepad: '用记事本编辑',
2518
+ ctxNotepad: '用记事本打开副本(不回写)',
2519
2519
  ctxCopy: '复制',
2520
2520
  ctxPaste: '粘贴',
2521
2521
  ctxCopyPath: '复制路径',
@@ -2535,6 +2535,20 @@ function attributeViolation(name, value, tagName) {
2535
2535
  transferDone: '已传输 {{files}} 个文件({{size}})',
2536
2536
  transferTruncated: '(达到上限,未全部传输)',
2537
2537
  downloadDone: '已下载到 {{path}}',
2538
+ downloadCount: '{{files}} 个文件({{size}})',
2539
+ downloadTruncated: '达到上限,未全部下载',
2540
+ downloadSkipped: '跳过 {{count}} 个(超过 20 MB)',
2541
+ downloadManyDone: '已下载 {{count}} 项,共 {{files}} 个文件({{size}})',
2542
+ downloadFailed: '{{count}} 项失败',
2543
+ ctxDownloadSelected: '下载所选的 {{count}} 项',
2544
+ ctxCopySsh: '复制 ssh 命令',
2545
+ sshCopied: '已复制 ssh 命令',
2546
+ searchRecent: '最近搜索',
2547
+ editorNextHit: '下一个命中(Ctrl+↓)',
2548
+ transferHistoryTitle: '最近的传输',
2549
+ transferHistoryEmpty: '还没有传输记录。',
2550
+ diskFree: '可用 {{free}}(已用 {{percent}}%)',
2551
+ diskUnavailable: '磁盘信息不可用',
2538
2552
  renameTitle: '重命名',
2539
2553
  renameLabel: '新名称',
2540
2554
  deleteTitle: '确认删除',
@@ -2545,6 +2559,7 @@ function attributeViolation(name, value, tagName) {
2545
2559
  nameLabel: '名称',
2546
2560
  chmodTitle: '更改权限',
2547
2561
  chmodLabel: '八进制权限(如 644 / 0755)',
2562
+ chmodLabelDir: '目录权限(需要含 7 才有进入权限,如 755)',
2548
2563
  propsTitle: '属性',
2549
2564
  propsName: '名称',
2550
2565
  propsPath: '路径',
@@ -2561,14 +2576,16 @@ function attributeViolation(name, value, tagName) {
2561
2576
  deleteDone: '已删除',
2562
2577
  chmodDone: '权限已更新',
2563
2578
  actionFailed: '操作失败',
2579
+ permissionHint: '(目录可能缺少执行位:用「更改权限」改回 755 即可恢复)',
2564
2580
  close: '关闭',
2565
2581
  confirm: '确定',
2566
2582
  queueClear: '清空已完成',
2567
2583
  tooManyTabs: '同时打开的文件标签已达上限(12 个),请先关闭一些标签。',
2568
2584
  transferSelected: '传输所选文件/文件夹',
2585
+ transferNeedsLinked: '传输只在联动工作区可用(远端 → 本地)',
2569
2586
  selectFirst: '先在目录树中选择一个远端文件或文件夹。',
2570
- showHidden: '显示隐藏的文件',
2571
- hideHidden: '隐藏隐藏的文件',
2587
+ showHidden: '显示以 . 开头的文件',
2588
+ hideHidden: '不显示以 . 开头的文件',
2572
2589
  syncStarting: '正在启动同步…',
2573
2590
  syncRunning: '同步中:{{files}} 个文件 / {{size}}',
2574
2591
  syncDone2: '同步完成:{{files}} 个文件({{size}})',
@@ -2975,7 +2992,7 @@ function attributeViolation(name, value, tagName) {
2975
2992
  ctxDownload: 'Download to default folder',
2976
2993
  ctxQueue: 'Queue',
2977
2994
  ctxOpen: 'Open',
2978
- ctxNotepad: 'Edit in Notepad',
2995
+ ctxNotepad: 'Open a copy in Notepad (edits are not written back)',
2979
2996
  ctxCopy: 'Copy',
2980
2997
  ctxPaste: 'Paste',
2981
2998
  ctxCopyPath: 'Copy path',
@@ -2995,6 +3012,20 @@ function attributeViolation(name, value, tagName) {
2995
3012
  transferDone: 'Transferred {{files}} files ({{size}})',
2996
3013
  transferTruncated: ' (limit reached; not everything was transferred)',
2997
3014
  downloadDone: 'Downloaded to {{path}}',
3015
+ downloadCount: '{{files}} files ({{size}})',
3016
+ downloadTruncated: 'hit the cap, not everything was downloaded',
3017
+ downloadSkipped: 'skipped {{count}} (over 20 MB)',
3018
+ downloadManyDone: 'Downloaded {{count}} items, {{files}} files ({{size}})',
3019
+ downloadFailed: '{{count}} failed',
3020
+ ctxDownloadSelected: 'Download {{count}} selected',
3021
+ ctxCopySsh: 'Copy ssh command',
3022
+ sshCopied: 'ssh command copied',
3023
+ searchRecent: 'Recent searches',
3024
+ editorNextHit: 'Next hit (Ctrl+Down)',
3025
+ transferHistoryTitle: 'Recent transfers',
3026
+ transferHistoryEmpty: 'No transfers yet.',
3027
+ diskFree: '{{free}} free ({{percent}}% used)',
3028
+ diskUnavailable: 'Disk usage unavailable',
2998
3029
  renameTitle: 'Rename',
2999
3030
  renameLabel: 'New name',
3000
3031
  deleteTitle: 'Confirm delete',
@@ -3005,6 +3036,7 @@ function attributeViolation(name, value, tagName) {
3005
3036
  nameLabel: 'Name',
3006
3037
  chmodTitle: 'Change permissions',
3007
3038
  chmodLabel: 'Octal permissions (e.g. 644 / 0755)',
3039
+ chmodLabelDir: 'Directory permissions (needs a 7 to stay enterable, e.g. 755)',
3008
3040
  propsTitle: 'Properties',
3009
3041
  propsName: 'Name',
3010
3042
  propsPath: 'Path',
@@ -3021,14 +3053,16 @@ function attributeViolation(name, value, tagName) {
3021
3053
  deleteDone: 'Deleted',
3022
3054
  chmodDone: 'Permissions updated',
3023
3055
  actionFailed: 'Action failed',
3056
+ permissionHint: ' (a folder without the execute bit — use “Change permissions” and set 755 again)',
3024
3057
  close: 'Close',
3025
3058
  confirm: 'OK',
3026
3059
  queueClear: 'Clear finished',
3027
3060
  tooManyTabs: 'At most 12 file tabs can be open at once; close one first.',
3028
3061
  transferSelected: 'Transfer the selected file/folder',
3062
+ transferNeedsLinked: 'Transfer needs a linked workspace (remote → local)',
3029
3063
  selectFirst: 'Select a remote file or folder in the tree first.',
3030
- showHidden: 'Show hidden files',
3031
- hideHidden: 'Hide hidden files',
3064
+ showHidden: 'Show dotfiles (names starting with .)',
3065
+ hideHidden: 'Hide dotfiles (names starting with .)',
3032
3066
  syncStarting: 'Starting sync…',
3033
3067
  syncRunning: 'Syncing: {{files}} files / {{size}}',
3034
3068
  syncDone2: 'Sync finished: {{files}} files ({{size}})',
@@ -3113,6 +3147,27 @@ function attributeViolation(name, value, tagName) {
3113
3147
  });
3114
3148
  }
3115
3149
 
3150
+ /**
3151
+ * Keep in sync with `API_REVISION` in lib/index.js. When this build needs
3152
+ * Host methods the running DSH process does not have yet, the directory
3153
+ * pane says so instead of surfacing an unrelated error.
3154
+ */
3155
+ var HOST_API_REVISION = 2;
3156
+ var hostInfoProbe = null;
3157
+
3158
+ function probeHostInfo() {
3159
+ if (hostInfoProbe) return hostInfoProbe;
3160
+ hostInfoProbe = apiCall('meta.info', {}).then(function (info) {
3161
+ var revision = Number(info && info.apiRevision) || 0;
3162
+ return { stale: revision < HOST_API_REVISION, info: info || null };
3163
+ }, function (error) {
3164
+ var message = error && typeof error.message === 'string' ? error.message : '';
3165
+ // No such method: the running Host predates this Client.
3166
+ return { stale: message.indexOf('unknown method:') === 0, info: null };
3167
+ });
3168
+ return hostInfoProbe;
3169
+ }
3170
+
3116
3171
  var CODE_TEXT = {
3117
3172
  zh: {
3118
3173
  NOT_FOUND: '远端对象不存在',
@@ -3159,8 +3214,11 @@ function attributeViolation(name, value, tagName) {
3159
3214
  // Keep the server's own wording: "All configured authentication methods
3160
3215
  // failed" tells the user far more than the generic code text alone.
3161
3216
  var detail = typeof error.message === 'string' ? error.message.trim() : '';
3162
- if (!detail || detail === known) return known;
3163
- return known + (locale === 'zh' ? ':' : ': ') + detail;
3217
+ // A folder without the execute bit looks empty instead of failing loudly,
3218
+ // so name the usual cause and the way back whenever this code shows up.
3219
+ var hint = error.code === 'FS_PERMISSION' ? t('permissionHint') : '';
3220
+ if (!detail || detail === known) return known + hint;
3221
+ return known + (locale === 'zh' ? ':' : ': ') + detail + hint;
3164
3222
  }
3165
3223
 
3166
3224
  function documentKindOf(path) {
@@ -3615,6 +3673,14 @@ function attributeViolation(name, value, tagName) {
3615
3673
  '.rw-result-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
3616
3674
  '.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
3617
3675
  '.rw-linked-notice{margin:6px 8px 0}',
3676
+ '.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
3677
+ '.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
3678
+ '.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
3679
+ '.rw-queue-history{margin-top:12px;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.28));padding-top:8px}',
3680
+ '.rw-queue-history-title{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);margin-bottom:4px}',
3681
+ '.rw-queue-row.is-history .rw-queue-state{opacity:.75}',
3682
+ '.rw-notice-body{display:flex;align-items:flex-start;gap:8px}',
3683
+ '.rw-notice-text{flex:1 1 auto;min-width:0;white-space:pre-wrap;word-break:break-word}',
3618
3684
  '.rw-ctx-backdrop{position:fixed;inset:0;z-index:70}',
3619
3685
  '.rw-workspace-body{display:flex;flex:1 1 auto;min-height:0;min-width:0}',
3620
3686
  '.rw-content-pane{display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0}',
@@ -5036,7 +5102,6 @@ function attributeViolation(name, value, tagName) {
5036
5102
  var locale = props.locale;
5037
5103
  var scope = props.scope;
5038
5104
  var local = props.local === true;
5039
- var readOnly = props.readOnly === true;
5040
5105
  var filePath = props.path;
5041
5106
  var sidebar = sidebarService(ctx);
5042
5107
  var settings = useRuntimeSettings();
@@ -5064,7 +5129,7 @@ function attributeViolation(name, value, tagName) {
5064
5129
  var gutterRef = useRef(null);
5065
5130
  var baseTitle = basename(filePath) || t('fileTabTitle');
5066
5131
  var params = scopeParams(scope);
5067
- var editable = Boolean(load.file && load.file.editable) && !readOnly;
5132
+ var editable = Boolean(load.file && load.file.editable);
5068
5133
 
5069
5134
  var loadFile = useCallback(function () {
5070
5135
  if (!filePath || (!local && !scope)) {
@@ -5128,6 +5193,38 @@ function attributeViolation(name, value, tagName) {
5128
5193
  return function () { timers.forEach(function (timer) { clearTimeout(timer); }); };
5129
5194
  }, [filePath, props.focusLine, load.loading, load.error, content]);
5130
5195
 
5196
+ // F5: hop between the hits of the current search without leaving the
5197
+ // keyboard — Ctrl+Down / Ctrl+Up move to the next / previous occurrence.
5198
+ useEffect(function () {
5199
+ var query = String(props.hitQuery || '');
5200
+ if (query === '') return undefined;
5201
+ function move(direction) {
5202
+ var area = textareaRef.current;
5203
+ if (!area) return;
5204
+ var haystack = String(content).toLowerCase();
5205
+ var needle = query.toLowerCase();
5206
+ var from = area.selectionStart;
5207
+ var at = direction > 0
5208
+ ? haystack.indexOf(needle, Math.min(from + 1, haystack.length))
5209
+ : haystack.lastIndexOf(needle, Math.max(from - 1, 0));
5210
+ if (at < 0) at = direction > 0 ? haystack.indexOf(needle) : haystack.lastIndexOf(needle);
5211
+ if (at < 0) return;
5212
+ area.focus();
5213
+ try { area.setSelectionRange(at, at + needle.length); } catch (error) { /* not focusable yet */ }
5214
+ var lineIndex = haystack.slice(0, at).split('\n').length - 1;
5215
+ area.scrollTop = Math.max(0, (lineIndex - 4) * 18);
5216
+ if (highlightRef.current) highlightRef.current.scrollTop = area.scrollTop;
5217
+ if (gutterRef.current) gutterRef.current.scrollTop = area.scrollTop;
5218
+ }
5219
+ function onKey(event) {
5220
+ if (!event.ctrlKey && !event.metaKey) return;
5221
+ if (event.key === 'ArrowDown') { event.preventDefault(); move(1); }
5222
+ else if (event.key === 'ArrowUp') { event.preventDefault(); move(-1); }
5223
+ }
5224
+ window.addEventListener('keydown', onKey, true);
5225
+ return function () { window.removeEventListener('keydown', onKey, true); };
5226
+ }, [props.hitQuery, content]);
5227
+
5131
5228
  useEffect(function () {
5132
5229
  if (!sidebar || typeof sidebar.updateTab !== 'function' || !props.tabId) return;
5133
5230
  try {
@@ -5136,7 +5233,7 @@ function attributeViolation(name, value, tagName) {
5136
5233
  }, [dirty, baseTitle]);
5137
5234
 
5138
5235
  function saveFile(force) {
5139
- if (readOnly || !load.file || load.file.binary || load.file.tooLarge || save.saving) return Promise.resolve(false);
5236
+ if (!load.file || load.file.binary || load.file.tooLarge || save.saving) return Promise.resolve(false);
5140
5237
  setSave({ saving: true, conflict: false, error: '', ok: false });
5141
5238
  var payload = local ? { path: filePath, content: content } : Object.assign({ path: filePath, content: content }, params);
5142
5239
  if (!force && load.file && typeof load.file.mtime === 'number') payload.expectedMtime = load.file.mtime;
@@ -5461,7 +5558,7 @@ function attributeViolation(name, value, tagName) {
5461
5558
  h('textarea', {
5462
5559
  ref: textareaRef,
5463
5560
  className: 'rw-textarea',
5464
- readOnly: readOnly || !editable,
5561
+ readOnly: !editable,
5465
5562
  value: content,
5466
5563
  spellCheck: false,
5467
5564
  wrap: 'off',
@@ -5502,9 +5599,7 @@ function attributeViolation(name, value, tagName) {
5502
5599
  h('span', { className: 'rw-status-chip' }, formatBytes(file.size)),
5503
5600
  dirty
5504
5601
  ? h('span', { className: 'rw-status-chip rw-status-warn' }, t('dirty'))
5505
- : readOnly
5506
- ? h('span', { className: 'rw-status-chip rw-status-error' }, t('readOnly'))
5507
- : file.tooLarge || file.truncated || file.binary
5602
+ : file.tooLarge || file.truncated || file.binary
5508
5603
  ? h('span', { className: 'rw-status-chip rw-status-error' }, t('readOnly'))
5509
5604
  : h('span', { className: 'rw-status-chip rw-status-ok' }, theme.label ? (locale === 'zh' ? theme.label.zh : theme.label.en) : theme.id),
5510
5605
  h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } })));
@@ -5853,7 +5948,7 @@ function attributeViolation(name, value, tagName) {
5853
5948
  h('button', {
5854
5949
  type: 'button',
5855
5950
  className: 'rw-icon-btn',
5856
- title: t('transferSelected'),
5951
+ title: props.transferTitle || t('transferSelected'),
5857
5952
  disabled: !props.transferEnabled,
5858
5953
  style: props.transferEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
5859
5954
  onClick: props.transferSelected,
@@ -6081,6 +6176,26 @@ function attributeViolation(name, value, tagName) {
6081
6176
  // F6: the settings page can replay the card, so the flag is cleared and an
6082
6177
  // event wakes the overlay instead of the user hunting for local storage.
6083
6178
  var WELCOME_EVENT = 'dsh-linked-workspace:welcome-open';
6179
+ var SHOW_HIDDEN_KEY = 'dsh-linked-workspace:show-hidden';
6180
+
6181
+ function readShowHidden() {
6182
+ try {
6183
+ var stored = window.localStorage.getItem(SHOW_HIDDEN_KEY);
6184
+ if (stored === '0') return false;
6185
+ if (stored === '1') return true;
6186
+ } catch (error) {
6187
+ /* private mode: fall through to the default */
6188
+ }
6189
+ return true;
6190
+ }
6191
+
6192
+ function rememberShowHidden(value) {
6193
+ try {
6194
+ window.localStorage.setItem(SHOW_HIDDEN_KEY, value ? '1' : '0');
6195
+ } catch (error) {
6196
+ /* ignore quota / private mode */
6197
+ }
6198
+ }
6084
6199
 
6085
6200
  function welcomeSeen() {
6086
6201
  try {
@@ -6097,6 +6212,35 @@ function attributeViolation(name, value, tagName) {
6097
6212
  } catch (error) { /* storage unavailable: the card simply shows again */ }
6098
6213
  }
6099
6214
 
6215
+ // F4: keep the last few content searches so the bar is not blank every time.
6216
+ var SEARCH_HISTORY_KEY = 'dsh-linked-workspace:search-history';
6217
+ var SEARCH_HISTORY_MAX = 8;
6218
+
6219
+ function readSearchHistory() {
6220
+ try {
6221
+ if (typeof window === 'undefined' || !window.localStorage) return [];
6222
+ var raw = window.localStorage.getItem(SEARCH_HISTORY_KEY);
6223
+ if (!raw) return [];
6224
+ var list = JSON.parse(raw);
6225
+ if (!Array.isArray(list)) return [];
6226
+ return list.filter(function (item) { return typeof item === 'string' && item !== ''; }).slice(0, SEARCH_HISTORY_MAX);
6227
+ } catch (error) {
6228
+ return [];
6229
+ }
6230
+ }
6231
+
6232
+ function rememberSearch(term) {
6233
+ var text = String(term || '').trim();
6234
+ if (text === '') return readSearchHistory();
6235
+ var list = readSearchHistory().filter(function (item) { return item !== text; });
6236
+ list.unshift(text);
6237
+ list = list.slice(0, SEARCH_HISTORY_MAX);
6238
+ try {
6239
+ if (typeof window !== 'undefined' && window.localStorage) window.localStorage.setItem(SEARCH_HISTORY_KEY, JSON.stringify(list));
6240
+ } catch (error) { /* storage unavailable: history stays in memory */ }
6241
+ return list;
6242
+ }
6243
+
6100
6244
  function WelcomeRow(props) {
6101
6245
  return h('div', { className: 'rw-welcome-row' },
6102
6246
  h('div', { className: 'rw-welcome-row-main' }, props.main),
@@ -6166,10 +6310,57 @@ function attributeViolation(name, value, tagName) {
6166
6310
  }
6167
6311
 
6168
6312
  function DialogShell(props) {
6313
+ var boxRef = useRef(null);
6314
+ var restoreRef = useRef(null);
6315
+ useEffect(function () {
6316
+ restoreRef.current = typeof document === 'undefined' ? null : document.activeElement;
6317
+ var box = boxRef.current;
6318
+ if (box) {
6319
+ var target = box.querySelector('input:not([disabled]), textarea:not([disabled]), select:not([disabled])')
6320
+ || box.querySelector('button:not([disabled])')
6321
+ || box;
6322
+ try { target.focus(); } catch (error) { /* focus is cosmetic */ }
6323
+ }
6324
+ return function () {
6325
+ var previous = restoreRef.current;
6326
+ if (previous && typeof previous.focus === 'function') {
6327
+ try { previous.focus(); } catch (error) { /* the row may be gone */ }
6328
+ }
6329
+ };
6330
+ }, []);
6331
+ useEffect(function () {
6332
+ function onKey(event) {
6333
+ if (event.key === 'Escape') {
6334
+ event.preventDefault();
6335
+ event.stopPropagation();
6336
+ props.onClose();
6337
+ return;
6338
+ }
6339
+ if (event.key !== 'Tab') return;
6340
+ var box = boxRef.current;
6341
+ if (!box) return;
6342
+ var nodes = box.querySelectorAll('input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');
6343
+ var focusable = [].slice.call(nodes).filter(function (node) { return node.offsetParent !== null; });
6344
+ if (focusable.length === 0) return;
6345
+ var first = focusable[0];
6346
+ var last = focusable[focusable.length - 1];
6347
+ if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
6348
+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
6349
+ }
6350
+ window.addEventListener('keydown', onKey, true);
6351
+ return function () { window.removeEventListener('keydown', onKey, true); };
6352
+ }, [props.onClose]);
6169
6353
  return h('div', {
6170
6354
  className: 'rw-dialog-backdrop',
6171
6355
  onMouseDown: function (event) { if (event.target === event.currentTarget) props.onClose(); },
6172
- }, h('div', { className: 'rw-dialog' },
6356
+ }, h('div', {
6357
+ className: 'rw-dialog',
6358
+ ref: boxRef,
6359
+ role: 'dialog',
6360
+ 'aria-modal': 'true',
6361
+ 'aria-label': typeof props.title === 'string' ? props.title : undefined,
6362
+ tabIndex: -1,
6363
+ },
6173
6364
  h('div', { className: 'rw-dialog-title' }, props.title),
6174
6365
  props.children));
6175
6366
  }
@@ -6446,6 +6637,7 @@ function attributeViolation(name, value, tagName) {
6446
6637
  }
6447
6638
 
6448
6639
  function QueueDialog(props) {
6640
+ var history = props.history && props.history.length > 0 ? props.history : null;
6449
6641
  return h(DialogShell, { title: props.title, onClose: props.onClose },
6450
6642
  props.queue.length === 0
6451
6643
  ? h('div', { className: 'rw-dialog-message' }, props.t('queueEmpty'))
@@ -6469,6 +6661,15 @@ function attributeViolation(name, value, tagName) {
6469
6661
  }, props.t('queueRetry'))
6470
6662
  : null);
6471
6663
  }),
6664
+ history
6665
+ ? h('div', { className: 'rw-queue-history' },
6666
+ h('div', { className: 'rw-queue-history-title' }, props.t('transferHistoryTitle')),
6667
+ history.slice().reverse().map(function (item) {
6668
+ return h('div', { key: item.id, className: 'rw-queue-row is-history' },
6669
+ h('span', { className: 'rw-queue-label' }, item.label),
6670
+ h('span', { className: 'rw-queue-state' }, item.message || item.state));
6671
+ }))
6672
+ : null,
6472
6673
  h('div', { className: 'rw-dialog-actions' },
6473
6674
  props.queue.some(function (entry) { return entry.state === 'done' || entry.state === 'error'; })
6474
6675
  ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClear }, props.t('queueClear'))
@@ -6912,6 +7113,28 @@ function attributeViolation(name, value, tagName) {
6912
7113
  var queueState = useState([]);
6913
7114
  var queueList = queueState[0];
6914
7115
  var setQueueList = queueState[1];
7116
+ // F6: keep the last finished transfers so closing the queue dialog does
7117
+ // not lose the record of what actually went through.
7118
+ var transferHistoryState = useState([]);
7119
+ var transferHistory = transferHistoryState[0];
7120
+ var setTransferHistory = transferHistoryState[1];
7121
+ useEffect(function () {
7122
+ var finished = queueList.filter(function (entry) {
7123
+ return entry.state === 'done' || entry.state === 'error' || entry.state === 'cancelled';
7124
+ });
7125
+ if (finished.length === 0) return;
7126
+ setTransferHistory(function (previous) {
7127
+ var seen = {};
7128
+ previous.forEach(function (item) { seen[item.id] = true; });
7129
+ var next = previous.slice();
7130
+ finished.forEach(function (entry) {
7131
+ if (seen[entry.id]) return;
7132
+ seen[entry.id] = true;
7133
+ next.push({ id: entry.id, label: entry.label, state: entry.state, message: entry.message || entry.state });
7134
+ });
7135
+ return next.slice(-20);
7136
+ });
7137
+ }, [queueList]);
6915
7138
  var queueRef = useRef([]);
6916
7139
  var queueRunning = useRef(false);
6917
7140
  var selectedEntryState = useState(null);
@@ -6922,9 +7145,22 @@ function attributeViolation(name, value, tagName) {
6922
7145
  var setMulti = multiState[1];
6923
7146
  // Anchor for Shift+click range selection (a ref: it must not re-render).
6924
7147
  var selectionAnchorRef = useRef(null);
6925
- var showHiddenState = useState(true);
7148
+ var showHiddenState = useState(readShowHidden);
6926
7149
  var showHidden = showHiddenState[0];
6927
7150
  var setShowHidden = showHiddenState[1];
7151
+ // A refresh only reloads this bundle, so the running Host may be older.
7152
+ var hostStaleState = useState(false);
7153
+ var hostStale = hostStaleState[0];
7154
+ var setHostStale = hostStaleState[1];
7155
+ var searchHistoryState = useState(readSearchHistory);
7156
+ var searchHistory = searchHistoryState[0];
7157
+ var setSearchHistory = searchHistoryState[1]; useEffect(function () {
7158
+ var alive = true;
7159
+ probeHostInfo().then(function (result) {
7160
+ if (alive && result && result.stale) setHostStale(true);
7161
+ });
7162
+ return function () { alive = false; };
7163
+ }, []);
6928
7164
 
6929
7165
  // Rename tabs persisted before 0.3.0 (type alias keeps the title "远程目录").
6930
7166
  useEffect(function () {
@@ -6957,6 +7193,7 @@ function attributeViolation(name, value, tagName) {
6957
7193
  localPath: null,
6958
7194
  placeholderPath: item.placeholderPath,
6959
7195
  remotePath: item.remotePath,
7196
+ hostId: item.hostId,
6960
7197
  host: item.host,
6961
7198
  username: item.username,
6962
7199
  hostName: item.hostName,
@@ -6971,6 +7208,7 @@ function attributeViolation(name, value, tagName) {
6971
7208
  name: item.name,
6972
7209
  localPath: item.localPath,
6973
7210
  remotePath: item.remotePath,
7211
+ hostId: item.hostId,
6974
7212
  host: item.host,
6975
7213
  username: item.username,
6976
7214
  hostName: item.hostName,
@@ -7003,6 +7241,22 @@ function attributeViolation(name, value, tagName) {
7003
7241
 
7004
7242
  var scopeRef = selected ? sourceScopeOf(selected) : null;
7005
7243
 
7244
+ // Free space on the remote volume (F2): fetched once per workspace and
7245
+ // refreshed when the tree is refreshed. Cheap enough to keep on screen.
7246
+ var diskState = useState(null);
7247
+ var disk = diskState[0];
7248
+ var setDisk = diskState[1];
7249
+ var diskHostId = selected && selected.hostId ? selected.hostId : '';
7250
+ var diskPath = selected && selected.remotePath ? selected.remotePath : '';
7251
+ useEffect(function () {
7252
+ if (!diskHostId) { setDisk(null); return; }
7253
+ var alive = true;
7254
+ apiCall('hosts.df', { hostId: diskHostId, path: diskPath || undefined }).then(function (result) {
7255
+ if (alive) setDisk(result && result.disk ? result.disk : null);
7256
+ }).catch(function () { if (alive) setDisk(null); });
7257
+ return function () { alive = false; };
7258
+ }, [diskHostId, diskPath]);
7259
+
7006
7260
  var openFilesState = useState([]);
7007
7261
  var openFiles = openFilesState[0];
7008
7262
  var setOpenFiles = openFilesState[1];
@@ -7103,6 +7357,9 @@ function attributeViolation(name, value, tagName) {
7103
7357
  function showNotice(kind, text) {
7104
7358
  if (noticeTimer.current) clearTimeout(noticeTimer.current);
7105
7359
  setNotice({ kind: kind, text: text });
7360
+ // Errors stay until dismissed: they can carry a whole SSH message and
7361
+ // the user may want to read or copy it.
7362
+ if (kind === 'error') return;
7106
7363
  noticeTimer.current = setTimeout(function () { setNotice(null); }, 4200);
7107
7364
  }
7108
7365
 
@@ -7112,6 +7369,7 @@ function attributeViolation(name, value, tagName) {
7112
7369
  }
7113
7370
 
7114
7371
  function refreshTree() {
7372
+ clearStaleError();
7115
7373
  bumpVersion(function (value) { return value + 1; });
7116
7374
  data.reload();
7117
7375
  }
@@ -7161,6 +7419,7 @@ function attributeViolation(name, value, tagName) {
7161
7419
 
7162
7420
  function openByMode(side, filePath, options) {
7163
7421
  if (!selected || !filePath) return;
7422
+ clearStaleError();
7164
7423
  var openMode = settings.fileOpenMode || 'editor';
7165
7424
  if (openMode === 'copy') {
7166
7425
  try {
@@ -7299,6 +7558,14 @@ function attributeViolation(name, value, tagName) {
7299
7558
  showNotice('error', t('actionFailed') + ':' + messageOf(error, t, locale));
7300
7559
  }
7301
7560
 
7561
+ // Errors stay on screen until the user closes them, so anything that
7562
+ // navigates or starts a new job drops the old one first.
7563
+ function clearStaleError() {
7564
+ setNotice(function (previous) {
7565
+ return previous && previous.kind === 'error' ? null : previous;
7566
+ });
7567
+ }
7568
+
7302
7569
  // Ctrl/Cmd-click toggles an entry in the multi-selection; a plain click
7303
7570
  // collapses the selection to that entry (Shift extends it).
7304
7571
  function updateSelection(side, info) {
@@ -7372,6 +7639,22 @@ function attributeViolation(name, value, tagName) {
7372
7639
  } catch (error) { /* clipboard unavailable */ }
7373
7640
  }
7374
7641
 
7642
+ /** Copy a ready-made ssh command that lands in the given remote directory. */
7643
+ function copySshCommand(dirPath) {
7644
+ var source = selected || {};
7645
+ var target = source.hostName
7646
+ ? source.hostName
7647
+ : (source.username ? source.username + '@' : '') + (source.host || '');
7648
+ if (!target) return;
7649
+ var command = 'ssh ' + target + " -t 'cd " + String(dirPath).replace(/'/g, "'\\''") + " && exec $SHELL -l'";
7650
+ try {
7651
+ if (navigator.clipboard && navigator.clipboard.writeText) {
7652
+ navigator.clipboard.writeText(command).then(function () { showNotice('success', t('sshCopied')); }).catch(function () {});
7653
+ return;
7654
+ }
7655
+ } catch (error) { /* clipboard unavailable */ }
7656
+ }
7657
+
7375
7658
  function enqueueTransfer(side, filePath, name) {
7376
7659
  var entry = {
7377
7660
  id: String(Date.now()) + Math.random().toString(16).slice(2),
@@ -7407,6 +7690,7 @@ function attributeViolation(name, value, tagName) {
7407
7690
  next.files = 0;
7408
7691
  next.bytes = 0;
7409
7692
  next.message = t('queueRunning');
7693
+ next.startedAt = Date.now();
7410
7694
  setQueueList(queueRef.current.slice());
7411
7695
  // Poll the Host while the transfer runs: a folder can take minutes and
7412
7696
  // the row otherwise sits on “running” with no evidence of progress.
@@ -7416,7 +7700,9 @@ function attributeViolation(name, value, tagName) {
7416
7700
  if (!job || next.state !== 'running') return;
7417
7701
  next.files = job.files;
7418
7702
  next.bytes = job.bytes;
7419
- next.message = t('queueProgress', { files: job.files, size: formatBytes(job.bytes) });
7703
+ var span = (Date.now() - (next.startedAt || Date.now())) / 1000;
7704
+ next.message = t('queueProgress', { files: job.files, size: formatBytes(job.bytes) })
7705
+ + (span >= 1 && job.bytes > 0 ? ' · ' + formatBytes(job.bytes / span) + '/s' : '');
7420
7706
  setQueueList(queueRef.current.slice());
7421
7707
  }).catch(function () { /* progress is best-effort */ });
7422
7708
  }, 700);
@@ -7438,12 +7724,55 @@ function attributeViolation(name, value, tagName) {
7438
7724
  });
7439
7725
  }
7440
7726
 
7727
+ function downloadSuffix(result) {
7728
+ var text = '';
7729
+ if (result.truncated) text += ' · ' + t('downloadTruncated');
7730
+ if (result.skipped) text += ' · ' + t('downloadSkipped', { count: result.skipped });
7731
+ return text;
7732
+ }
7733
+
7441
7734
  function downloadEntry(entry) {
7442
- apiCall('fs.download', Object.assign({ path: entry.path }, scopeParams(scopeRef))).then(function (result) {
7443
- showNotice('success', t('downloadDone', { path: result.path }));
7735
+ return apiCall('fs.download', Object.assign({ path: entry.path }, scopeParams(scopeRef))).then(function (result) {
7736
+ var files = typeof result.files === 'number' ? result.files : 1;
7737
+ var bytes = typeof result.bytes === 'number' ? result.bytes : 0;
7738
+ var summary = result.files === 1 && !result.truncated
7739
+ ? t('downloadDone', { path: result.path })
7740
+ : t('downloadManyDone', { count: 1, files: files, size: formatBytes(bytes) }) + ' · ' + t('downloadDone', { path: result.path });
7741
+ var kind = result.truncated || result.skipped ? 'warn' : 'success';
7742
+ showNotice(kind, summary + downloadSuffix(result));
7743
+ return result;
7444
7744
  }).catch(noticeError);
7445
7745
  }
7446
7746
 
7747
+ /** Download several selected remote entries one after another. */
7748
+ function downloadSelected(entries) {
7749
+ var batch = (entries || []).filter(function (item) { return item.side === 'remote'; });
7750
+ if (batch.length === 0) return;
7751
+ var files = 0;
7752
+ var bytes = 0;
7753
+ var skipped = 0;
7754
+ var truncated = 0;
7755
+ var failed = 0;
7756
+ var chain = Promise.resolve();
7757
+ batch.forEach(function (item) {
7758
+ chain = chain.then(function () {
7759
+ return apiCall('fs.download', Object.assign({ path: item.path }, scopeParams(scopeRef))).then(function (result) {
7760
+ files += typeof result.files === 'number' ? result.files : 1;
7761
+ bytes += typeof result.bytes === 'number' ? result.bytes : 0;
7762
+ skipped += result.skipped || 0;
7763
+ if (result.truncated) truncated += 1;
7764
+ }).catch(function () { failed += 1; });
7765
+ });
7766
+ });
7767
+ chain.then(function () {
7768
+ var text = t('downloadManyDone', { count: batch.length, files: files, size: formatBytes(bytes) });
7769
+ if (truncated) text += ' · ' + t('downloadTruncated');
7770
+ if (skipped) text += ' · ' + t('downloadSkipped', { count: skipped });
7771
+ if (failed) text += ' · ' + t('downloadFailed', { count: failed });
7772
+ showNotice(truncated || skipped || failed ? 'warn' : 'success', text);
7773
+ });
7774
+ }
7775
+
7447
7776
  function editNotepad(side, filePath) {
7448
7777
  var method = side === 'remote' ? 'fs.edit' : 'local.edit';
7449
7778
  var params = side === 'remote'
@@ -7818,24 +8147,24 @@ function attributeViolation(name, value, tagName) {
7818
8147
 
7819
8148
  function buildContextItems(menu) {
7820
8149
  var isRemote = menu.side === 'remote';
7821
- if (remoteOnly) {
7822
- var readOnlyItems = [];
7823
- if (isRemote) readOnlyItems.push({ label: t('ctxDownload'), onSelect: function () { downloadEntry(menu); } });
7824
- if (!menu.isDir) readOnlyItems.push({ label: t('ctxOpen'), onSelect: function () { openByMode(menu.side, menu.path); } });
7825
- readOnlyItems.push({ separator: true });
7826
- readOnlyItems.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
7827
- readOnlyItems.push({ separator: true });
7828
- readOnlyItems.push({ label: t('ctxProperties'), onSelect: function () { showProperties(menu.side, menu.path); } });
7829
- return readOnlyItems;
7830
- }
8150
+ // Transfer, compare and the local terminal need a local directory, so
8151
+ // they only show up for a linked workspace; everything else works on
8152
+ // both kinds (a remote workspace just has the remote side).
8153
+ var hasLocal = Boolean(selected && selected.kind === 'linked');
7831
8154
  var canPaste = clipboard !== null && clipboard.side === menu.side && menu.isDir;
7832
8155
  var items = [];
7833
8156
  var batch = multi.filter(function (item) { return item.side === menu.side; });
7834
8157
  if (batch.length > 1) {
7835
- items.push({ label: t('ctxTransferSelected', { count: batch.length }), onSelect: function () {
7836
- batch.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
7837
- } });
8158
+ if (hasLocal) {
8159
+ items.push({ label: t('ctxTransferSelected', { count: batch.length }), onSelect: function () {
8160
+ batch.forEach(function (item) { enqueueTransfer(item.side, item.path, item.name); });
8161
+ } });
8162
+ }
7838
8163
  items.push({ label: t('ctxDeleteSelected', { count: batch.length }), onSelect: deleteSelection });
8164
+ var downloadable = batch.filter(function (item) { return item.side === 'remote'; });
8165
+ if (downloadable.length > 0) {
8166
+ items.push({ label: t('ctxDownloadSelected', { count: downloadable.length }), onSelect: function () { downloadSelected(downloadable); } });
8167
+ }
7839
8168
  if (batch.some(function (item) { return item.path === menu.path; })) {
7840
8169
  items.push({ label: t('ctxMoveSelected', { count: batch.length }), onSelect: function () {
7841
8170
  setDialog({
@@ -7850,9 +8179,13 @@ function attributeViolation(name, value, tagName) {
7850
8179
  items.push({ separator: true });
7851
8180
  }
7852
8181
  if (isRemote) {
7853
- items.push({ label: t('ctxTransfer'), onSelect: function () { enqueueTransfer('remote', menu.path, menu.name); } });
8182
+ if (hasLocal) {
8183
+ items.push({ label: t('ctxTransfer'), onSelect: function () { enqueueTransfer('remote', menu.path, menu.name); } });
8184
+ }
7854
8185
  items.push({ label: t('ctxDownload'), onSelect: function () { downloadEntry(menu); } });
7855
- items.push({ label: t('ctxQueue'), onSelect: function () { setDialog({ kind: 'queue' }); } });
8186
+ if (hasLocal) {
8187
+ items.push({ label: t('ctxQueue'), onSelect: function () { setDialog({ kind: 'queue' }); } });
8188
+ }
7856
8189
  items.push({ separator: true });
7857
8190
  } else {
7858
8191
  items.push({ label: t('ctxTransferLocal'), onSelect: function () { enqueueTransfer('local', menu.path, menu.name); } });
@@ -7871,6 +8204,9 @@ function attributeViolation(name, value, tagName) {
7871
8204
  items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
7872
8205
  items.push({ separator: true });
7873
8206
  items.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
8207
+ if (menu.side === 'remote' && menu.isDir) {
8208
+ items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
8209
+ }
7874
8210
  items.push({ separator: true });
7875
8211
  var rootPath = menu.side === 'remote' ? selected.remotePath : selected.localPath;
7876
8212
  if (menu.path !== rootPath) {
@@ -7881,21 +8217,29 @@ function attributeViolation(name, value, tagName) {
7881
8217
  });
7882
8218
  } });
7883
8219
  }
7884
- items.push({ label: t('ctxRename'), onSelect: function () {
7885
- setDialog({ kind: 'rename', side: menu.side, path: menu.path, value: menu.name, title: t('renameTitle'), label: t('renameLabel') });
7886
- } });
7887
- items.push({ label: t('ctxDelete'), onSelect: function () {
7888
- setDialog({ kind: 'delete', side: menu.side, path: menu.path, name: menu.name, isDir: menu.isDir });
7889
- } });
7890
- items.push({ label: t('ctxChmod'), onSelect: function () {
7891
- setDialog({ kind: 'chmod', side: menu.side, path: menu.path, title: t('chmodTitle'), label: t('chmodLabel'), value: '644' });
7892
- } });
8220
+ if (menu.path !== rootPath) {
8221
+ items.push({ label: t('ctxRename'), onSelect: function () {
8222
+ setDialog({ kind: 'rename', side: menu.side, path: menu.path, value: menu.name, title: t('renameTitle'), label: t('renameLabel') });
8223
+ } });
8224
+ items.push({ label: t('ctxDelete'), onSelect: function () {
8225
+ setDialog({ kind: 'delete', side: menu.side, path: menu.path, name: menu.name, isDir: menu.isDir });
8226
+ } });
8227
+ // The Host refuses chmod on the workspace root: a stray 644 there makes
8228
+ // the whole tree look empty, so the entry is not offered at all.
8229
+ items.push({ label: t('ctxChmod'), onSelect: function () {
8230
+ setDialog({
8231
+ kind: 'chmod', side: menu.side, path: menu.path, title: t('chmodTitle'),
8232
+ label: menu.isDir ? t('chmodLabelDir') : t('chmodLabel'),
8233
+ value: menu.isDir ? '755' : '644',
8234
+ });
8235
+ } });
8236
+ }
7893
8237
  if (menu.isDir) {
7894
8238
  items.push({ separator: true });
7895
8239
  items.push({ label: t('ctxTerminalHere'), onSelect: function () { openTerminal(menu.side, menu.path); } });
7896
8240
  items = items.concat(newEntryMenuItems(menu, t, setDialog));
7897
8241
  }
7898
- if (menu.isDir && menu.side === 'remote' && selected && selected.kind === 'linked') {
8242
+ if (menu.isDir && menu.side === 'remote' && hasLocal) {
7899
8243
  items.push({ label: t('ctxCompare'), onSelect: function () { openCompare(menu.path); } });
7900
8244
  }
7901
8245
  items.push({ separator: true });
@@ -7952,6 +8296,7 @@ function attributeViolation(name, value, tagName) {
7952
8296
  t: t,
7953
8297
  title: t('queueTitle'),
7954
8298
  queue: queueList,
8299
+ history: transferHistory,
7955
8300
  onClose: function () { setDialog(null); },
7956
8301
  onClear: function () {
7957
8302
  queueRef.current = queueRef.current.filter(function (entry) { return entry.state !== 'done' && entry.state !== 'error'; });
@@ -8087,6 +8432,7 @@ function attributeViolation(name, value, tagName) {
8087
8432
  }
8088
8433
  var alive = true;
8089
8434
  var timer = setTimeout(function () {
8435
+ clearStaleError();
8090
8436
  setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, truncatedReason: '', error: null }; });
8091
8437
  var scopeNow = sourceScopeOf(selected);
8092
8438
  var contentMode = searchMode === 'content';
@@ -8136,8 +8482,22 @@ function attributeViolation(name, value, tagName) {
8136
8482
  }
8137
8483
 
8138
8484
  var info = null;
8139
- if (notice) info = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: notice.kind }, notice.text));
8140
- else if (data.data.error) info = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'error' }, t('workspacesFailed') + ':' + messageOf(data.data.error, t, locale)));
8485
+ if (notice) {
8486
+ info = h('div', { className: 'rw-linked-notice', role: 'status', 'aria-live': 'polite' },
8487
+ h(Banner, { kind: notice.kind },
8488
+ h('div', { className: 'rw-notice-body' },
8489
+ h('span', { className: 'rw-notice-text' }, notice.text),
8490
+ h('button', {
8491
+ type: 'button',
8492
+ className: 'rw-icon-btn',
8493
+ title: t('close'),
8494
+ onClick: function () { setNotice(null); },
8495
+ }, IconClose(12)))));
8496
+ } else if (data.data.error) info = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'error' }, t('workspacesFailed') + ':' + messageOf(data.data.error, t, locale)));
8497
+ if (hostStale) {
8498
+ var staleNotice = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'warn' }, t('staleHost')));
8499
+ info = info ? h('div', null, staleNotice, info) : staleNotice;
8500
+ }
8141
8501
 
8142
8502
  var body;
8143
8503
  if (searchOpen && searchQuery.trim().length >= 2) {
@@ -8253,9 +8613,9 @@ function attributeViolation(name, value, tagName) {
8253
8613
  scope: activeFile.side === 'remote' ? sourceScopeOf(selected) : undefined,
8254
8614
  path: activeFile.path,
8255
8615
  local: activeFile.side === 'local',
8256
- readOnly: remoteOnly,
8257
8616
  hideHeader: true,
8258
8617
  focusLine: activeFile.line || 0,
8618
+ hitQuery: searchQuery,
8259
8619
  onSaveReady: function (handler) {
8260
8620
  if (handler) saveHandlersRef.current[activeFile.key] = handler;
8261
8621
  else delete saveHandlersRef.current[activeFile.key];
@@ -8286,8 +8646,13 @@ function attributeViolation(name, value, tagName) {
8286
8646
  onOpenTerminal: openTerminal,
8287
8647
  localEnabled: !remoteOnly && selected.kind === 'linked',
8288
8648
  showHidden: showHidden,
8289
- onToggleHidden: function () { setShowHidden(!showHidden); },
8290
- transferEnabled: !remoteOnly && (multi.length > 0 || Boolean(selectedEntry)),
8649
+ onToggleHidden: function () {
8650
+ var next = !showHidden;
8651
+ rememberShowHidden(next);
8652
+ setShowHidden(next);
8653
+ },
8654
+ transferEnabled: selected.kind === 'linked' && (multi.length > 0 || Boolean(selectedEntry)),
8655
+ transferTitle: selected.kind === 'linked' ? undefined : t('transferNeedsLinked'),
8291
8656
  transferSelected: function () {
8292
8657
  if (multi.length === 0 && !selectedEntry) {
8293
8658
  showNotice('info', t('selectFirst'));
@@ -8323,6 +8688,11 @@ function attributeViolation(name, value, tagName) {
8323
8688
  autoFocus: true,
8324
8689
  onChange: function (event) { setSearchQuery(event.currentTarget.value); },
8325
8690
  onKeyDown: function (event) {
8691
+ if (event.key === 'Enter') {
8692
+ var remembered = rememberSearch(searchQuery);
8693
+ setSearchHistory(remembered);
8694
+ return;
8695
+ }
8326
8696
  if (event.key !== 'ArrowDown') return;
8327
8697
  // Landing on the first hit without leaving the keyboard is the
8328
8698
  // whole point of the list shortcuts.
@@ -8363,6 +8733,19 @@ function attributeViolation(name, value, tagName) {
8363
8733
  onClick: function () { setSearchOpen(false); setSearchQuery(''); },
8364
8734
  }, IconClose(12)))
8365
8735
  : null,
8736
+ searchOpen && searchMode === 'content' && searchQuery === '' && searchHistory.length > 0
8737
+ ? h('div', { className: 'rw-search-history' },
8738
+ h('span', { className: 'rw-search-history-label' }, t('searchRecent')),
8739
+ searchHistory.map(function (term) {
8740
+ return h('button', {
8741
+ key: term,
8742
+ type: 'button',
8743
+ className: 'rw-chip-btn',
8744
+ title: term,
8745
+ onClick: function () { setSearchQuery(term); },
8746
+ }, h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: '160px' } }, term));
8747
+ }))
8748
+ : null,
8366
8749
  sources.length > 1
8367
8750
  ? h('div', { className: 'rw-chips' },
8368
8751
  sources.map(function (source) {
@@ -8411,6 +8794,12 @@ function attributeViolation(name, value, tagName) {
8411
8794
  h('div', { className: 'rw-directory-head' },
8412
8795
  IconFolder(11, false),
8413
8796
  h('span', { style: { flex: '1 1 auto', minWidth: 0 } }, remoteOnly ? t('remoteTabTitle') : t('tabTitle')),
8797
+ disk
8798
+ ? h('span', {
8799
+ className: 'rw-disk',
8800
+ title: (disk.path ? disk.path + ' · ' : '') + t('diskFree', { free: formatBytes(disk.avail), percent: disk.percent }) + (disk.used ? ' · ' + formatBytes(disk.used) + ' / ' + formatBytes(disk.size) : ''),
8801
+ }, formatBytes(disk.avail))
8802
+ : null,
8414
8803
  h('button', { type: 'button', className: 'rw-icon-btn', title: t('toggleDirectory'), onClick: function () { setDirectoryOpen(false); } }, IconClose(11))),
8415
8804
  h('div', { className: 'rw-directory-body' }, body))
8416
8805
  : null),
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@
18
18
  import { randomUUID } from 'node:crypto'
19
19
  import { chmodSync, closeSync, cpSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
20
20
  import { spawn } from 'node:child_process'
21
- import { mkdir, readdir, stat as fsStat } from 'node:fs/promises'
21
+ import { mkdir, readdir, rm, stat as fsStat } from 'node:fs/promises'
22
22
  import { homedir, tmpdir } from 'node:os'
23
23
  import { basename, dirname, extname, isAbsolute, join, posix, resolve, sep } from 'node:path'
24
24
  import { fileURLToPath } from 'node:url'
@@ -32,6 +32,27 @@ export const name = 'dsh-linked-workspace'
32
32
  /** The web server carries the JSON API; the rest are the linked-workspace tool faces. */
33
33
  export const inject = ['webServer', 'tools', 'systemPrompt', 'workingDirectory']
34
34
 
35
+ /**
36
+ * Bumped whenever the Client half starts relying on a newer Host method table.
37
+ * The Client compares this number with its own and warns when the DSH process
38
+ * is still running an older copy of the Host — refreshing the page only swaps
39
+ * the browser bundle, so the two halves can drift by one restart.
40
+ */
41
+ const API_REVISION = 2
42
+
43
+ /** When this copy of the Host was loaded; shown by `meta.info`. */
44
+ const STARTED_AT = new Date().toISOString()
45
+
46
+ /** The published plugin version, read once so `meta.info` can report it. */
47
+ const PACKAGE_VERSION = (() => {
48
+ try {
49
+ const file = fileURLToPath(new URL('../package.json', import.meta.url))
50
+ return JSON.parse(readFileSync(file, 'utf8')).version || ''
51
+ } catch {
52
+ return ''
53
+ }
54
+ })()
55
+
35
56
  const DATA_VERSION = 1
36
57
  const SETTINGS_VERSION = 1
37
58
  const SETTINGS_DEFAULTS = Object.freeze({ editorTheme: 'github-light', editorThemeFamily: 'github', editorThemeMode: 'system', fileOpenMode: 'editor', autoSave: false })
@@ -899,6 +920,11 @@ export function apply(ctx) {
899
920
  const settingsStore = new SettingsStore(join(dir, 'settings.json'))
900
921
  const linkedStore = new linkedFs.LinkedStore(join(dir, 'linked.json'))
901
922
  const remoteStore = new RemoteWorkspaceStore(join(dir, 'remote-workspaces.json'))
923
+ // Old "open in notepad" copies are dead weight; clear them once per start.
924
+ // Deferred: the helper is declared further down in this function body.
925
+ setTimeout(() => {
926
+ sweepOpenTempCopies().catch((error) => log('warn', `could not sweep the open-file temp dir: ${error && error.message ? error.message : error}`))
927
+ }, 0)
902
928
  // 0.5.0: mirror sync is opt-in. Records created under the old default
903
929
  // (mirror on, never explicitly chosen) are switched off once.
904
930
  for (const existing of linkedStore.list()) {
@@ -1731,6 +1757,23 @@ export function apply(ctx) {
1731
1757
  return { path: destination, files: 1, bytes: read.data.length, skipped: 0, truncated: false }
1732
1758
  }
1733
1759
 
1760
+ // Copies opened in an external editor are throw-away: sweep the ones from
1761
+ // earlier sessions so the temp folder does not grow forever (D4).
1762
+ const OPEN_TEMP_MAX_AGE_MS = 24 * 60 * 60 * 1000
1763
+
1764
+ const sweepOpenTempCopies = async () => {
1765
+ const dir = join(tmpdir(), 'dsh-linked-workspace-open')
1766
+ const names = await readdir(dir).catch(() => [])
1767
+ const now = Date.now()
1768
+ await Promise.all(names.map(async (name) => {
1769
+ const target = join(dir, name)
1770
+ const info = await fsStat(target).catch(() => null)
1771
+ if (!info || !info.isFile()) return
1772
+ if (now - info.mtimeMs < OPEN_TEMP_MAX_AGE_MS) return
1773
+ await rm(target, { force: true }).catch(() => {})
1774
+ }))
1775
+ }
1776
+
1734
1777
  const openTempCopy = async (remote, target, app) => {
1735
1778
  const stat = await remote.stat(target)
1736
1779
  if (stat.type !== 'file') throw new ApiError('FS_IS_DIR', '只能编辑文件')
@@ -1827,7 +1870,7 @@ export function apply(ctx) {
1827
1870
  }
1828
1871
 
1829
1872
  async function docTarget(params) {
1830
- if (params.linkedId || params.workspaceId) {
1873
+ if (params.linkedId || params.remoteId || params.workspaceId) {
1831
1874
  const scope = await requireScope(params)
1832
1875
  const target = scopeTarget(scope, params.path)
1833
1876
  return { remote: true, scope, path: target }
@@ -2209,6 +2252,28 @@ export function apply(ctx) {
2209
2252
  return { path: target }
2210
2253
  },
2211
2254
 
2255
+ // Free space on the volume that holds a remote path (F2). `df -Pk` is the
2256
+ // portable form: one line of numbers in 1K blocks.
2257
+ async 'hosts.df'(params = {}) {
2258
+ const host = await findHost(params.hostId)
2259
+ const remote = await connectHost(host)
2260
+ const rawPath = typeof params.path === 'string' && params.path.trim() !== ''
2261
+ ? params.path
2262
+ : await remote.homeDir()
2263
+ const target = await normalizeRemotePath(remote, rawPath)
2264
+ const result = await remote.exec(`df -Pk ${shellQuoteArg(target)} 2>/dev/null || true`)
2265
+ const lines = String(result.stdout || '').trim().split('\n')
2266
+ if (lines.length < 2) return { disk: null }
2267
+ const cols = lines[lines.length - 1].trim().split(/\s+/)
2268
+ if (cols.length < 6) return { disk: null }
2269
+ const size = Number(cols[1]) * 1024
2270
+ const used = Number(cols[2]) * 1024
2271
+ const avail = Number(cols[3]) * 1024
2272
+ if (!Number.isFinite(size) || !Number.isFinite(avail)) return { disk: null }
2273
+ const percent = size > 0 ? Math.round((used / size) * 100) : 0
2274
+ return { disk: { path: target, size, used, avail, percent } }
2275
+ },
2276
+
2212
2277
  async 'fs.list'(params = {}) {
2213
2278
  const scope = await requireScope(params)
2214
2279
  const target = params.path === undefined || params.path === ''
@@ -2639,6 +2704,9 @@ export function apply(ctx) {
2639
2704
  async 'fs.chmod'(params = {}) {
2640
2705
  const scope = await requireScope(params)
2641
2706
  const target = scopeTarget(scope, params.path)
2707
+ // chmod 644 on the root would hide the whole workspace from the plugin
2708
+ // (a directory without the execute bit looks empty and unreadable).
2709
+ if (target === scope.root) throw new ApiError('BAD_REQUEST', '不能修改工作区根目录的权限')
2642
2710
  const mode = String(params.mode || '').trim()
2643
2711
  if (!/^[0-7]{3,4}$/.test(mode)) throw new ApiError('BAD_REQUEST', '权限必须是 3-4 位八进制,例如 644 或 0755')
2644
2712
  await scope.remote.exec(`chmod ${mode} ${shellQuoteArg(target)}`, { timeoutMs: 15000 })
@@ -2650,6 +2718,17 @@ export function apply(ctx) {
2650
2718
  return { home: await scope.remote.homeDir() }
2651
2719
  },
2652
2720
 
2721
+ // ── build info ─────────────────────────────────────────────────────────
2722
+
2723
+ /**
2724
+ * Lets the Client detect a Host that predates the code on disk: the method
2725
+ * itself is missing on old builds, and the revision is lower once a Client
2726
+ * needs newer methods.
2727
+ */
2728
+ async 'meta.info'() {
2729
+ return { version: PACKAGE_VERSION, apiRevision: API_REVISION, startedAt: STARTED_AT }
2730
+ },
2731
+
2653
2732
  // ── settings ───────────────────────────────────────────────────────────
2654
2733
 
2655
2734
  async 'settings.get'() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.14.0",
3
+ "version": "0.16.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",