dsh-linked-workspace 0.15.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,39 @@
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
+
5
38
  ## 0.15.0 — 2026-11-15
6
39
 
7
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).
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):
package/README.md CHANGED
@@ -60,6 +60,8 @@
60
60
 
61
61
  ### 右侧栏「联动工作区目录」
62
62
 
63
+ 目录栏标题右侧显示该工作区所在远端卷的可用空间,悬停可看到总量与已用百分比。
64
+
63
65
  - 面板固定在右侧栏最右边:**上方远端树,下方本地树**,两棵树根部都显示「所有文件」;本地树自动隐藏插件的 `.local`/`.remote` 内部目录。
64
66
  - **单击打开,双击固定**:单击文件夹立即展开/折叠;单击文件直接在文件内容面板打开,再次单击其他文件会替换当前未固定的预览标签。双击文件可固定该标签,之后单击其他文件不会覆盖它;双击文件夹只保持展开。
65
67
  - 工具栏(右侧栏右上角):
package/docs/API.md CHANGED
@@ -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 }` |
package/docs/VERIFY.md CHANGED
@@ -250,6 +250,27 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
250
250
  10. **悬停展开**:拖拽停在折叠目录行 700 ms:该目录应自动展开。
251
251
  11. **host-api**:`node test/host-api.mjs` 应为 33 步全部通过(0.15.0 起含 `meta.info`)。
252
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` 的权限保持不变。
253
274
  ## 旧 Host 自检(0.15.0)
254
275
 
255
276
  1. **正常时不打扰**:插件已重启过后打开任意目录树,顶部**不应**出现任何黄色提示条。
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,6 +2576,7 @@ 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: '清空已完成',
@@ -2568,8 +2584,8 @@ function attributeViolation(name, value, tagName) {
2568
2584
  transferSelected: '传输所选文件/文件夹',
2569
2585
  transferNeedsLinked: '传输只在联动工作区可用(远端 → 本地)',
2570
2586
  selectFirst: '先在目录树中选择一个远端文件或文件夹。',
2571
- showHidden: '显示隐藏的文件',
2572
- hideHidden: '隐藏隐藏的文件',
2587
+ showHidden: '显示以 . 开头的文件',
2588
+ hideHidden: '不显示以 . 开头的文件',
2573
2589
  syncStarting: '正在启动同步…',
2574
2590
  syncRunning: '同步中:{{files}} 个文件 / {{size}}',
2575
2591
  syncDone2: '同步完成:{{files}} 个文件({{size}})',
@@ -2976,7 +2992,7 @@ function attributeViolation(name, value, tagName) {
2976
2992
  ctxDownload: 'Download to default folder',
2977
2993
  ctxQueue: 'Queue',
2978
2994
  ctxOpen: 'Open',
2979
- ctxNotepad: 'Edit in Notepad',
2995
+ ctxNotepad: 'Open a copy in Notepad (edits are not written back)',
2980
2996
  ctxCopy: 'Copy',
2981
2997
  ctxPaste: 'Paste',
2982
2998
  ctxCopyPath: 'Copy path',
@@ -2996,6 +3012,20 @@ function attributeViolation(name, value, tagName) {
2996
3012
  transferDone: 'Transferred {{files}} files ({{size}})',
2997
3013
  transferTruncated: ' (limit reached; not everything was transferred)',
2998
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',
2999
3029
  renameTitle: 'Rename',
3000
3030
  renameLabel: 'New name',
3001
3031
  deleteTitle: 'Confirm delete',
@@ -3006,6 +3036,7 @@ function attributeViolation(name, value, tagName) {
3006
3036
  nameLabel: 'Name',
3007
3037
  chmodTitle: 'Change permissions',
3008
3038
  chmodLabel: 'Octal permissions (e.g. 644 / 0755)',
3039
+ chmodLabelDir: 'Directory permissions (needs a 7 to stay enterable, e.g. 755)',
3009
3040
  propsTitle: 'Properties',
3010
3041
  propsName: 'Name',
3011
3042
  propsPath: 'Path',
@@ -3022,6 +3053,7 @@ function attributeViolation(name, value, tagName) {
3022
3053
  deleteDone: 'Deleted',
3023
3054
  chmodDone: 'Permissions updated',
3024
3055
  actionFailed: 'Action failed',
3056
+ permissionHint: ' (a folder without the execute bit — use “Change permissions” and set 755 again)',
3025
3057
  close: 'Close',
3026
3058
  confirm: 'OK',
3027
3059
  queueClear: 'Clear finished',
@@ -3029,8 +3061,8 @@ function attributeViolation(name, value, tagName) {
3029
3061
  transferSelected: 'Transfer the selected file/folder',
3030
3062
  transferNeedsLinked: 'Transfer needs a linked workspace (remote → local)',
3031
3063
  selectFirst: 'Select a remote file or folder in the tree first.',
3032
- showHidden: 'Show hidden files',
3033
- hideHidden: 'Hide hidden files',
3064
+ showHidden: 'Show dotfiles (names starting with .)',
3065
+ hideHidden: 'Hide dotfiles (names starting with .)',
3034
3066
  syncStarting: 'Starting sync…',
3035
3067
  syncRunning: 'Syncing: {{files}} files / {{size}}',
3036
3068
  syncDone2: 'Sync finished: {{files}} files ({{size}})',
@@ -3182,8 +3214,11 @@ function attributeViolation(name, value, tagName) {
3182
3214
  // Keep the server's own wording: "All configured authentication methods
3183
3215
  // failed" tells the user far more than the generic code text alone.
3184
3216
  var detail = typeof error.message === 'string' ? error.message.trim() : '';
3185
- if (!detail || detail === known) return known;
3186
- 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;
3187
3222
  }
3188
3223
 
3189
3224
  function documentKindOf(path) {
@@ -3638,6 +3673,14 @@ function attributeViolation(name, value, tagName) {
3638
3673
  '.rw-result-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
3639
3674
  '.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
3640
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}',
3641
3684
  '.rw-ctx-backdrop{position:fixed;inset:0;z-index:70}',
3642
3685
  '.rw-workspace-body{display:flex;flex:1 1 auto;min-height:0;min-width:0}',
3643
3686
  '.rw-content-pane{display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0}',
@@ -5150,6 +5193,38 @@ function attributeViolation(name, value, tagName) {
5150
5193
  return function () { timers.forEach(function (timer) { clearTimeout(timer); }); };
5151
5194
  }, [filePath, props.focusLine, load.loading, load.error, content]);
5152
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
+
5153
5228
  useEffect(function () {
5154
5229
  if (!sidebar || typeof sidebar.updateTab !== 'function' || !props.tabId) return;
5155
5230
  try {
@@ -6101,6 +6176,26 @@ function attributeViolation(name, value, tagName) {
6101
6176
  // F6: the settings page can replay the card, so the flag is cleared and an
6102
6177
  // event wakes the overlay instead of the user hunting for local storage.
6103
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
+ }
6104
6199
 
6105
6200
  function welcomeSeen() {
6106
6201
  try {
@@ -6117,6 +6212,35 @@ function attributeViolation(name, value, tagName) {
6117
6212
  } catch (error) { /* storage unavailable: the card simply shows again */ }
6118
6213
  }
6119
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
+
6120
6244
  function WelcomeRow(props) {
6121
6245
  return h('div', { className: 'rw-welcome-row' },
6122
6246
  h('div', { className: 'rw-welcome-row-main' }, props.main),
@@ -6186,10 +6310,57 @@ function attributeViolation(name, value, tagName) {
6186
6310
  }
6187
6311
 
6188
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]);
6189
6353
  return h('div', {
6190
6354
  className: 'rw-dialog-backdrop',
6191
6355
  onMouseDown: function (event) { if (event.target === event.currentTarget) props.onClose(); },
6192
- }, 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
+ },
6193
6364
  h('div', { className: 'rw-dialog-title' }, props.title),
6194
6365
  props.children));
6195
6366
  }
@@ -6466,6 +6637,7 @@ function attributeViolation(name, value, tagName) {
6466
6637
  }
6467
6638
 
6468
6639
  function QueueDialog(props) {
6640
+ var history = props.history && props.history.length > 0 ? props.history : null;
6469
6641
  return h(DialogShell, { title: props.title, onClose: props.onClose },
6470
6642
  props.queue.length === 0
6471
6643
  ? h('div', { className: 'rw-dialog-message' }, props.t('queueEmpty'))
@@ -6489,6 +6661,15 @@ function attributeViolation(name, value, tagName) {
6489
6661
  }, props.t('queueRetry'))
6490
6662
  : null);
6491
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,
6492
6673
  h('div', { className: 'rw-dialog-actions' },
6493
6674
  props.queue.some(function (entry) { return entry.state === 'done' || entry.state === 'error'; })
6494
6675
  ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClear }, props.t('queueClear'))
@@ -6932,6 +7113,28 @@ function attributeViolation(name, value, tagName) {
6932
7113
  var queueState = useState([]);
6933
7114
  var queueList = queueState[0];
6934
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]);
6935
7138
  var queueRef = useRef([]);
6936
7139
  var queueRunning = useRef(false);
6937
7140
  var selectedEntryState = useState(null);
@@ -6942,14 +7145,16 @@ function attributeViolation(name, value, tagName) {
6942
7145
  var setMulti = multiState[1];
6943
7146
  // Anchor for Shift+click range selection (a ref: it must not re-render).
6944
7147
  var selectionAnchorRef = useRef(null);
6945
- var showHiddenState = useState(true);
7148
+ var showHiddenState = useState(readShowHidden);
6946
7149
  var showHidden = showHiddenState[0];
6947
7150
  var setShowHidden = showHiddenState[1];
6948
7151
  // A refresh only reloads this bundle, so the running Host may be older.
6949
7152
  var hostStaleState = useState(false);
6950
7153
  var hostStale = hostStaleState[0];
6951
7154
  var setHostStale = hostStaleState[1];
6952
- useEffect(function () {
7155
+ var searchHistoryState = useState(readSearchHistory);
7156
+ var searchHistory = searchHistoryState[0];
7157
+ var setSearchHistory = searchHistoryState[1]; useEffect(function () {
6953
7158
  var alive = true;
6954
7159
  probeHostInfo().then(function (result) {
6955
7160
  if (alive && result && result.stale) setHostStale(true);
@@ -6988,6 +7193,7 @@ function attributeViolation(name, value, tagName) {
6988
7193
  localPath: null,
6989
7194
  placeholderPath: item.placeholderPath,
6990
7195
  remotePath: item.remotePath,
7196
+ hostId: item.hostId,
6991
7197
  host: item.host,
6992
7198
  username: item.username,
6993
7199
  hostName: item.hostName,
@@ -7002,6 +7208,7 @@ function attributeViolation(name, value, tagName) {
7002
7208
  name: item.name,
7003
7209
  localPath: item.localPath,
7004
7210
  remotePath: item.remotePath,
7211
+ hostId: item.hostId,
7005
7212
  host: item.host,
7006
7213
  username: item.username,
7007
7214
  hostName: item.hostName,
@@ -7034,6 +7241,22 @@ function attributeViolation(name, value, tagName) {
7034
7241
 
7035
7242
  var scopeRef = selected ? sourceScopeOf(selected) : null;
7036
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
+
7037
7260
  var openFilesState = useState([]);
7038
7261
  var openFiles = openFilesState[0];
7039
7262
  var setOpenFiles = openFilesState[1];
@@ -7134,6 +7357,9 @@ function attributeViolation(name, value, tagName) {
7134
7357
  function showNotice(kind, text) {
7135
7358
  if (noticeTimer.current) clearTimeout(noticeTimer.current);
7136
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;
7137
7363
  noticeTimer.current = setTimeout(function () { setNotice(null); }, 4200);
7138
7364
  }
7139
7365
 
@@ -7143,6 +7369,7 @@ function attributeViolation(name, value, tagName) {
7143
7369
  }
7144
7370
 
7145
7371
  function refreshTree() {
7372
+ clearStaleError();
7146
7373
  bumpVersion(function (value) { return value + 1; });
7147
7374
  data.reload();
7148
7375
  }
@@ -7192,6 +7419,7 @@ function attributeViolation(name, value, tagName) {
7192
7419
 
7193
7420
  function openByMode(side, filePath, options) {
7194
7421
  if (!selected || !filePath) return;
7422
+ clearStaleError();
7195
7423
  var openMode = settings.fileOpenMode || 'editor';
7196
7424
  if (openMode === 'copy') {
7197
7425
  try {
@@ -7330,6 +7558,14 @@ function attributeViolation(name, value, tagName) {
7330
7558
  showNotice('error', t('actionFailed') + ':' + messageOf(error, t, locale));
7331
7559
  }
7332
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
+
7333
7569
  // Ctrl/Cmd-click toggles an entry in the multi-selection; a plain click
7334
7570
  // collapses the selection to that entry (Shift extends it).
7335
7571
  function updateSelection(side, info) {
@@ -7403,6 +7639,22 @@ function attributeViolation(name, value, tagName) {
7403
7639
  } catch (error) { /* clipboard unavailable */ }
7404
7640
  }
7405
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
+
7406
7658
  function enqueueTransfer(side, filePath, name) {
7407
7659
  var entry = {
7408
7660
  id: String(Date.now()) + Math.random().toString(16).slice(2),
@@ -7438,6 +7690,7 @@ function attributeViolation(name, value, tagName) {
7438
7690
  next.files = 0;
7439
7691
  next.bytes = 0;
7440
7692
  next.message = t('queueRunning');
7693
+ next.startedAt = Date.now();
7441
7694
  setQueueList(queueRef.current.slice());
7442
7695
  // Poll the Host while the transfer runs: a folder can take minutes and
7443
7696
  // the row otherwise sits on “running” with no evidence of progress.
@@ -7447,7 +7700,9 @@ function attributeViolation(name, value, tagName) {
7447
7700
  if (!job || next.state !== 'running') return;
7448
7701
  next.files = job.files;
7449
7702
  next.bytes = job.bytes;
7450
- 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' : '');
7451
7706
  setQueueList(queueRef.current.slice());
7452
7707
  }).catch(function () { /* progress is best-effort */ });
7453
7708
  }, 700);
@@ -7469,12 +7724,55 @@ function attributeViolation(name, value, tagName) {
7469
7724
  });
7470
7725
  }
7471
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
+
7472
7734
  function downloadEntry(entry) {
7473
- apiCall('fs.download', Object.assign({ path: entry.path }, scopeParams(scopeRef))).then(function (result) {
7474
- 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;
7475
7744
  }).catch(noticeError);
7476
7745
  }
7477
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
+
7478
7776
  function editNotepad(side, filePath) {
7479
7777
  var method = side === 'remote' ? 'fs.edit' : 'local.edit';
7480
7778
  var params = side === 'remote'
@@ -7863,6 +8161,10 @@ function attributeViolation(name, value, tagName) {
7863
8161
  } });
7864
8162
  }
7865
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
+ }
7866
8168
  if (batch.some(function (item) { return item.path === menu.path; })) {
7867
8169
  items.push({ label: t('ctxMoveSelected', { count: batch.length }), onSelect: function () {
7868
8170
  setDialog({
@@ -7902,6 +8204,9 @@ function attributeViolation(name, value, tagName) {
7902
8204
  items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
7903
8205
  items.push({ separator: true });
7904
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
+ }
7905
8210
  items.push({ separator: true });
7906
8211
  var rootPath = menu.side === 'remote' ? selected.remotePath : selected.localPath;
7907
8212
  if (menu.path !== rootPath) {
@@ -7912,15 +8217,23 @@ function attributeViolation(name, value, tagName) {
7912
8217
  });
7913
8218
  } });
7914
8219
  }
7915
- items.push({ label: t('ctxRename'), onSelect: function () {
7916
- setDialog({ kind: 'rename', side: menu.side, path: menu.path, value: menu.name, title: t('renameTitle'), label: t('renameLabel') });
7917
- } });
7918
- items.push({ label: t('ctxDelete'), onSelect: function () {
7919
- setDialog({ kind: 'delete', side: menu.side, path: menu.path, name: menu.name, isDir: menu.isDir });
7920
- } });
7921
- items.push({ label: t('ctxChmod'), onSelect: function () {
7922
- setDialog({ kind: 'chmod', side: menu.side, path: menu.path, title: t('chmodTitle'), label: t('chmodLabel'), value: '644' });
7923
- } });
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
+ }
7924
8237
  if (menu.isDir) {
7925
8238
  items.push({ separator: true });
7926
8239
  items.push({ label: t('ctxTerminalHere'), onSelect: function () { openTerminal(menu.side, menu.path); } });
@@ -7983,6 +8296,7 @@ function attributeViolation(name, value, tagName) {
7983
8296
  t: t,
7984
8297
  title: t('queueTitle'),
7985
8298
  queue: queueList,
8299
+ history: transferHistory,
7986
8300
  onClose: function () { setDialog(null); },
7987
8301
  onClear: function () {
7988
8302
  queueRef.current = queueRef.current.filter(function (entry) { return entry.state !== 'done' && entry.state !== 'error'; });
@@ -8118,6 +8432,7 @@ function attributeViolation(name, value, tagName) {
8118
8432
  }
8119
8433
  var alive = true;
8120
8434
  var timer = setTimeout(function () {
8435
+ clearStaleError();
8121
8436
  setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, truncatedReason: '', error: null }; });
8122
8437
  var scopeNow = sourceScopeOf(selected);
8123
8438
  var contentMode = searchMode === 'content';
@@ -8167,8 +8482,18 @@ function attributeViolation(name, value, tagName) {
8167
8482
  }
8168
8483
 
8169
8484
  var info = null;
8170
- if (notice) info = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: notice.kind }, notice.text));
8171
- 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)));
8172
8497
  if (hostStale) {
8173
8498
  var staleNotice = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'warn' }, t('staleHost')));
8174
8499
  info = info ? h('div', null, staleNotice, info) : staleNotice;
@@ -8290,6 +8615,7 @@ function attributeViolation(name, value, tagName) {
8290
8615
  local: activeFile.side === 'local',
8291
8616
  hideHeader: true,
8292
8617
  focusLine: activeFile.line || 0,
8618
+ hitQuery: searchQuery,
8293
8619
  onSaveReady: function (handler) {
8294
8620
  if (handler) saveHandlersRef.current[activeFile.key] = handler;
8295
8621
  else delete saveHandlersRef.current[activeFile.key];
@@ -8320,7 +8646,11 @@ function attributeViolation(name, value, tagName) {
8320
8646
  onOpenTerminal: openTerminal,
8321
8647
  localEnabled: !remoteOnly && selected.kind === 'linked',
8322
8648
  showHidden: showHidden,
8323
- onToggleHidden: function () { setShowHidden(!showHidden); },
8649
+ onToggleHidden: function () {
8650
+ var next = !showHidden;
8651
+ rememberShowHidden(next);
8652
+ setShowHidden(next);
8653
+ },
8324
8654
  transferEnabled: selected.kind === 'linked' && (multi.length > 0 || Boolean(selectedEntry)),
8325
8655
  transferTitle: selected.kind === 'linked' ? undefined : t('transferNeedsLinked'),
8326
8656
  transferSelected: function () {
@@ -8358,6 +8688,11 @@ function attributeViolation(name, value, tagName) {
8358
8688
  autoFocus: true,
8359
8689
  onChange: function (event) { setSearchQuery(event.currentTarget.value); },
8360
8690
  onKeyDown: function (event) {
8691
+ if (event.key === 'Enter') {
8692
+ var remembered = rememberSearch(searchQuery);
8693
+ setSearchHistory(remembered);
8694
+ return;
8695
+ }
8361
8696
  if (event.key !== 'ArrowDown') return;
8362
8697
  // Landing on the first hit without leaving the keyboard is the
8363
8698
  // whole point of the list shortcuts.
@@ -8398,6 +8733,19 @@ function attributeViolation(name, value, tagName) {
8398
8733
  onClick: function () { setSearchOpen(false); setSearchQuery(''); },
8399
8734
  }, IconClose(12)))
8400
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,
8401
8749
  sources.length > 1
8402
8750
  ? h('div', { className: 'rw-chips' },
8403
8751
  sources.map(function (source) {
@@ -8446,6 +8794,12 @@ function attributeViolation(name, value, tagName) {
8446
8794
  h('div', { className: 'rw-directory-head' },
8447
8795
  IconFolder(11, false),
8448
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,
8449
8803
  h('button', { type: 'button', className: 'rw-icon-btn', title: t('toggleDirectory'), onClick: function () { setDirectoryOpen(false); } }, IconClose(11))),
8450
8804
  h('div', { className: 'rw-directory-body' }, body))
8451
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'
@@ -920,6 +920,11 @@ export function apply(ctx) {
920
920
  const settingsStore = new SettingsStore(join(dir, 'settings.json'))
921
921
  const linkedStore = new linkedFs.LinkedStore(join(dir, 'linked.json'))
922
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)
923
928
  // 0.5.0: mirror sync is opt-in. Records created under the old default
924
929
  // (mirror on, never explicitly chosen) are switched off once.
925
930
  for (const existing of linkedStore.list()) {
@@ -1752,6 +1757,23 @@ export function apply(ctx) {
1752
1757
  return { path: destination, files: 1, bytes: read.data.length, skipped: 0, truncated: false }
1753
1758
  }
1754
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
+
1755
1777
  const openTempCopy = async (remote, target, app) => {
1756
1778
  const stat = await remote.stat(target)
1757
1779
  if (stat.type !== 'file') throw new ApiError('FS_IS_DIR', '只能编辑文件')
@@ -2230,6 +2252,28 @@ export function apply(ctx) {
2230
2252
  return { path: target }
2231
2253
  },
2232
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
+
2233
2277
  async 'fs.list'(params = {}) {
2234
2278
  const scope = await requireScope(params)
2235
2279
  const target = params.path === undefined || params.path === ''
@@ -2660,6 +2704,9 @@ export function apply(ctx) {
2660
2704
  async 'fs.chmod'(params = {}) {
2661
2705
  const scope = await requireScope(params)
2662
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', '不能修改工作区根目录的权限')
2663
2710
  const mode = String(params.mode || '').trim()
2664
2711
  if (!/^[0-7]{3,4}$/.test(mode)) throw new ApiError('BAD_REQUEST', '权限必须是 3-4 位八进制,例如 644 或 0755')
2665
2712
  await scope.remote.exec(`chmod ${mode} ${shellQuoteArg(target)}`, { timeoutMs: 15000 })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.15.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",