dsh-linked-workspace 0.20.2 → 0.22.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,22 @@
2
2
 
3
3
  English · [简体中文](CHANGELOG.zh.md)
4
4
 
5
+ ## 0.22.0 — 2026-11-20
6
+
7
+ - Workspace cards gained a **Reconnect** button: it drops the pooled socket, dials once and reports either “Reconnected” with the round-trip time or the host's own error message. New host method `hosts.reconnect` — the read-only `hosts.status` snapshot never dials, so a stale “Not connected” chip previously had no way to refresh itself.
8
+ - “Not connected” now has a documented meaning: the process has not dialled that host yet (or the last failure is older than 60 s), which is normal right after DSH starts. The README explains it and points at the new button.
9
+ - Fixed a mirror regression: turning the mirror off and on again handed the **cancelling** sync job back to the next `linked.sync`, which then finished as “cancelled” without pulling anything. A job that is already winding down is no longer reused.
10
+
11
+ ## 0.21.0 — 2026-11-20
12
+
13
+ - The diff preview is scoped: right-click a folder → “Push this to the remote”, or select files and choose “Push the N selected items to the remote”, and the rows you see are exactly the rows that get pushed (the host matches a folder as a prefix, so the old “shows 5, pushes 0” mismatch is gone).
14
+ - Each preview row now carries its size, both mtimes and the first eight characters of both hashes; the dialog also gained a “conflicts only” filter and a 500 / 2000 / 5000 plan limit.
15
+ - “Removed remotely” rows gained a “Delete remote file” action, and a file that is already gone counts as handled.
16
+ - New “Transfer and push history” dialog showing the last 50 transfer/push entries the host keeps on disk.
17
+ - The directory header shows an “auto push” chip with the time of the last push (hover for the debounce interval).
18
+ - Auto push follows the workspace lifecycle: a new workspace starts watching immediately and a removed one stops at once; failures now back off (2 s doubling, capped at 60 s, five attempts) instead of logging a failure every two seconds.
19
+ - Fixed an overlay regression introduced in 0.20.1: wheel scrolling inside dialogs works again (the inner list chains to the outer one at its edge) and focus lands on the first input when a dialog opens.
20
+
5
21
  ## 0.20.2 — 2026-11-19
6
22
 
7
23
  - **The sheet stays readable under a translucent theme.** Some themes (a mica / frosted preset, for example) make the panel background semi-transparent, and since the overlay moved into the top layer the host's own blur no longer applies to it — the page behind showed through as mirrored text. The sheet now blurs whatever sits behind it, and the top-layer backdrop paints its own dim layer instead of relying on a theme scrim.
package/README.en.md CHANGED
@@ -59,6 +59,8 @@ The plugin takes over the DSH sidebar/hero directory-selection hole; the dialog
59
59
  > Linked workspace rows no longer carry a `⇄` title prefix: a scoped stylesheet keyed on `data-row-key` swaps the host folder glyph for the workspace's own icon — two interlocking links for a linked workspace, a display with an outbound arrow for a remote workspace (normal local workspaces are untouched). When the SSH connection drops the row icon turns red, and the host's hover card gains one line under the name combining the SSH host with its live state (`RTX-PRO-6000-1 · Connected`, turning red with “Connection lost” once the link drops); a remote workspace shows the remote directory, a linked one shows both the remote and local directories. This is the only DOM-level adaptation of the host row; if DSH changes the row structure the selector stops matching and the original folder icon returns, with no other breakage.
60
60
  >
61
61
  > That state follows the real connection in both directions: the page asks the host for every host's state once every 6 seconds (memory only, it never dials), and only repaints that one line when the value actually changed — so a host that drops shows “Connection lost” within seconds while the card stays open, and one that recovers goes back to “Connected” without a reload. A single failure only describes that moment: an error nobody has re-checked decays to “Not connected” after 60 seconds, and “Test connection” finding a missing remote directory is no longer treated as a dead link, so it cannot paint the other workspaces on the same host red.
62
+ >
63
+ > That also explains why a workspace reads “Not connected” right after DSH starts: it means “this process has not dialled that host yet”, not “it cannot”. To find out immediately, press **Reconnect** on the card in settings — it drops the old socket, dials once, and either reports “Reconnected” with the round-trip time or shows the host's own error message.
62
64
 
63
65
  ### Sidebar: “Linked Workspace Directory”
64
66
 
@@ -277,3 +279,5 @@ On Windows, run `test/host-api.mjs` with DSH's bundled Electron Node (system Nod
277
279
  ## License
278
280
 
279
281
  MIT © 2026 Huangjh
282
+
283
+ Since 0.21.0 the diff preview follows your entry point: right-click a folder or select several items and only those rows appear, each with its size, both mtimes and the first eight hash characters, plus a “conflicts only” filter; “removed remotely” rows can delete the leftover file. The clock button in the toolbar opens the transfer and push history, and the “auto push” chip in the directory header shows when it last pushed — auto push now follows workspace creation and removal and backs off after five failed attempts.
package/README.md CHANGED
@@ -59,6 +59,8 @@
59
59
  > 左侧工作区行不再带 `⇄` 标题前缀:插件用一份按 `data-row-key` 定位的样式表,把宿主文件夹图标换成工作区自己的图标——联动工作区是**双链环**,远程工作区是**显示器 + 出链箭头**,普通本地工作区不受影响。SSH 连接断开时该行的图标会变红;把鼠标停在行上,宿主那张悬停信息卡里名字下面会多出一行「SSH 主机 · 连接状态」(形如 `RTX-PRO-6000-1 · 已连接`,掉线后变红并显示「连接已断开」);远程工作区显示远端目录、联动工作区同时显示远端与本地目录。这是对宿主行结构的唯一 DOM 级适配;如果 DSH 以后更改行结构,选择器会自然失配并回退到原来的文件夹图标,不破坏其他功能。
60
60
  >
61
61
  > 这一行状态是**跟着实际连通性走的**:页面每 6 秒向宿主取一次各主机的连接状态(只读内存、不发起新连接),只有状态真的变了才重绘那一行,卡片开着时也会即时更新——主机掉线几秒内变「连接已断开」,恢复后自动回到「已连接」,不用刷新页面。一次失败只代表当时:没人再验证的旧错误 60 秒后降级为「未连接」;「测试连接」发现远端目录不存在也不会被当成断连,不会把同一台主机上的其它工作区一起标红。
62
+ >
63
+ > 所以刚重启 DSH 时,还没打开过的工作区显示「未连接」是正常的——那是「这个进程还没连过」而不是「连不上」。想立刻确认,点设置页卡片上的**重新连接**:它会丢掉旧连接、当场拨一次号,成功就变「已连接」并显示耗时,失败则把主机的原话显示出来。
62
64
 
63
65
  ### 右侧栏「联动工作区目录」
64
66
 
@@ -277,3 +279,5 @@ node test/ssh-smoke.mjs # 真实 SSH 传输自检(按需)
277
279
  ## License
278
280
 
279
281
  MIT © 2026 Huangjh
282
+
283
+ 从 0.21.0 起,差异预览会跟着你的入口收窄:右键文件夹或选中若干项再推送,预览里只有这些范围内的条目,每行还带大小、两边时间与 hash 前 8 位,可以勾「只看冲突」;「远端已删」的行能直接删掉远端残留。工具栏的时钟按钮打开「传输与推送历史」,目录栏的「自动推送」chip 显示最近一次推送时间——自动推送现在跟随工作区增删,失败会退避重试最多 5 次。
package/docs/API.md CHANGED
@@ -58,6 +58,7 @@ scope root, or absolute inside it.
58
58
  | `hosts.hostKeys` | `{}` | `{ entries: [{ authority, fingerprint, firstSeen, hostId?, hostName? }] }` — the keys remembered in `known_hosts.json`; `hostId` is filled in when the authority still matches a configured host |
59
59
  | `hosts.forgetHostKey` | `{ hostId?/authority? }` | `{ authority, removed }` — drops the stored key (and the live connection) so the next connect trusts the host again; `settings.hostKeyPolicy` decides whether an unknown key is accepted (`tofu`, default) or refused (`strict`) |
60
60
  | `hosts.status` | `{ hostIds? }` | `{ statuses: { [hostId]: { state, reason?, message?, latencyMs?, checkedAt? } } }` (in-memory snapshot of the pool, never dials; an `error` older than 60 s is reported as `idle`; defaults to every known host of the host list plus every workspace's host id) |
61
+ | `hosts.reconnect` | `{ hostId }` | `{ hostId, state, reason?, message?, latencyMs?, checkedAt? }` (drops the pooled socket and dials again; returns the resulting status instead of throwing, so the UI can show the reason) |
61
62
  | `hosts.mkdir` | `{ hostId, path?, name }` | `{ path }` (creates `name` inside `path`; defaults to the login home; `409`/`FS_EXISTS` when it already exists) |
62
63
  | `hosts.exec` | `{ hostId?/linkedId?/remoteId?, command, cwd?, timeoutMs? }` | `{ hostId, hostName, workspaceId, kind, command, cwd, exitCode, stdout, stderr, stdoutBytes, stderrBytes, truncated, durationMs, startedAt, auditId }` — runs **one** non-interactive command on the remote host. Three gates: `settings.execEnabled` must be `true`, the host must be in `settings.execHostIds`, and — when `settings.execWorkspaceIds` is non-empty — the workspace must be in it. Refusals are audited too and answer `403` (`EXEC_DISABLED` / `EXEC_HOST_NOT_ALLOWED` / `EXEC_WORKSPACE_NOT_ALLOWED`); a timeout answers `504` `EXEC_TIMEOUT`, other failures `502` `EXEC_FAILED`. Output is clipped to `settings.execMaxOutputChars` per stream (default 200000, head+tail). `cwd` is resolved inside the workspace root and may not escape it. Output is decoded with `settings.outputEncoding` (`utf8` by default, `gbk` for Chinese Windows remotes). |
63
64
  | `remote_workspaces.list` | `{}` | `{ workspaces: RemoteWorkspaceInfo[] }` |
@@ -101,7 +102,7 @@ scope root, or absolute inside it.
101
102
  | `fs.grep` | `{ linkedId?/remoteId?, side, query, maxResults?, path?, ignoreCase?, regex?, includeIgnored?, resultMode?, maxFiles?, maxFileBytes?, timeoutMs?, jobId? }` | `{ ok, query, entries: [{ path, relative, size, line, preview, matches }], truncated, truncatedReason, scannedFiles, scannedBytes, skippedFiles }` (searches file **contents**; `path` narrows the scan to a sub-folder; `ignoreCase` defaults to `true`; `regex` treats `query` as a regular expression; `includeIgnored: true` also walks usually ignored folders such as `node_modules`/`.venv`/`dist` (`.git`/`.hg`/`.svn` always stay out); `resultMode: 'files'` lists file names only (`line: 0`, empty `preview`, `matches` = hit count); `maxFiles` (default 2000), `maxFileBytes` (default 1 MB) and `timeoutMs` (default 5 s, max 10 s) raise or lower the sweep; limits are 1 MB per file, 2000 files, 8 MB and 5 s for both sides, and `truncatedReason` is one of `files`, `bytes`, `deadline`, `results`, `cancelled`; max 1000 rows) |
102
103
  | `fs.grepCancel` | `{ jobId }` | `{ cancelled }` (marks the job started by `fs.grep`'s `jobId`; the Host checks it between files and answers `truncatedReason: 'cancelled'`) |
103
104
  | `linked.plan` | `{ id, maxFiles? }` | `{ linkedId, localPath, remotePath, added, changed, conflict, removed, unchanged, pending, truncated, skipped, maxFiles }` (each entry carries `relative`, `size`, `localHash`, `remoteHash`; a file that moved on both sides since the last push lands in `conflict`) |
104
- | `linked.push` | `{ id, paths?, dryRun?, conflict?, jobId? }` | `{ linkedId, dryRun, conflict, files, pushed, skipped, conflictsLeft, bytes, cancelled }` (`conflict` is `skip` by default; every file is written as a temporary file and renamed into place) |
105
+ | `linked.push` | `{ id, paths?, dryRun?, conflict?, jobId? }` | `{ linkedId, dryRun, conflict, files, pushed, skipped, conflictsLeft, bytes, cancelled }` (`conflict` is `skip` by default; every file is written as a temporary file and renamed into place; `paths` entries may be files or folders — a folder matches everything under it — and every planned entry carries `localMtime` / `remoteMtime`) |
105
106
  | `linked.pushCancel` | `{ jobId }` | `{ cancelled }` (stops after the file being written) |
106
107
  | `transfer.history` | `{}` | `{ entries: [{ kind: "transfer" \| "push", direction?, linkedId?, files, bytes, skipped, truncated?, at }] }` (newest first, at most 50) |
107
108
  | `fs.references` | `{ linkedId?/remoteId?, query, limit?, includeIgnored?, side? }` | `{ ok, query, candidates: [{ path, relative, name, kind }], total, truncated, scannedEntries }` (path completion for `@`-style references: matches the **path**, case-insensitive, best match first — exact name, then prefix, then substring; `limit` defaults to 50 and caps at 200; walking stops after 20000 entries or 3 s; `side: 'local'` searches the local tree of a linked workspace) |
package/docs/VERIFY.md CHANGED
@@ -294,6 +294,16 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
294
294
  10. **悬停展开**:拖拽停在折叠目录行 700 ms:该目录应自动展开。
295
295
  11. **host-api**:`node test/host-api.mjs` 应为 33 步全部通过(0.15.0 起含 `meta.info`)。
296
296
 
297
+ ## 差异预览、历史与自动推送(0.21.0)
298
+
299
+ 1. 右键远端目录 → 「把这个推送到远端」:对话框只列该目录下的条目(不再是整库),摘要里的数字与列表一致。
300
+ 2. 在多选若干目录/文件后右键 → 「推送所选的 N 项到远端」:同样只列这些范围内的条目。
301
+ 3. 预览每行显示大小、本地/远端时间与两边 hash 前 8 位;勾选「只看冲突」后只剩冲突行。
302
+ 4. 计划上限切到 500 后重新预览,条目数不超过 500;被截断时顶部给出「请缩小范围」提示。
303
+ 5. 本地删掉一个已推送的文件后打开预览 → 「远端已删」出现该行,点「删除远端文件」后远端确实消失,行也随之消失。
304
+ 6. 工具栏时钟按钮打开「传输与推送历史」,能看到最近的推送/传输记录;目录栏的「自动推送」chip 显示最近一次推送时间。
305
+ 7. 打开「添加工作区」:焦点在第一个输入框;鼠标滚轮能滚动连接列表,滚到底会接着滚动外层表单,背后页面不动。
306
+
297
307
  ## 提示、对话框与下载(0.16.1)
298
308
 
299
309
  1. 目录栏标题右侧出现可用空间(如「7983.64 GB」),悬停显示「可用 …(已用 17%)· 已用 / 总量」;换工作区后数字随之变化。
@@ -317,6 +327,8 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
317
327
  18. 右键工作区根节点:菜单里**没有**「更改权限」(也没有「重命名」「删除」「移动到…」)。绕过界面直接请求 `fs.chmod` 并把 `path` 指向工作区远端根:返回 400「不能修改工作区根目录的权限」,随后 `fs.stat` 的权限保持不变。
318
328
  19. **覆盖层置顶(0.20.1)**:打开「添加工作区」弹窗时,右侧目录树与对话输入框都应变暗且完全在弹窗之下(在输入框位置 `document.elementFromPoint` 应命中遮罩);弹窗宿主是 `document.body` 下 `showModal()` 打开的 `<dialog class="rw-top-layer">`。按 Esc:弹窗消失且 `.rw-top-layer` 数量归 0(不能留下已关闭的 dialog),随后再点「添加工作区」仍能重新打开。
319
329
  20. **其它覆盖层(0.20.1)**:右键「移动到…」等确认对话框与首次运行欢迎卡片同样走 `.rw-top-layer`;Esc、点遮罩、点关闭按钮三种方式都能把宿主一起移除。
330
+ 21. **重新连接(0.22.0)**:刚重启 DSH 后打开设置 →「联动工作区」,卡片状态为「未连接」(这是「本进程还没连过」,不是故障)。点卡片上的**重新连接**:成功时出现绿色「已重新连接」且状态变「已连接」;把某个主机的端口临时改成不可达再点,则应出现红色「连接失败:…」并带上主机的原话(例如 `ECONNREFUSED`)。绕过界面调用 `hosts.reconnect { hostId: '不存在的 id' }` 返回 404。
331
+ 22. **镜像开关不再卡住同步(0.22.0)**:对开启镜像的联动工作区连续执行 `linked.update { mirror: false }` → `linked.update { mirror: true }` → `linked.sync`,轮询 `linked.syncStatus` 应最终为 `done`(不是 `cancelled`)且 `files >= 1`。
320
332
  ## 旧 Host 自检(0.15.0)
321
333
 
322
334
  1. **正常时不打扰**:插件已重启过后打开任意目录树,顶部**不应**出现任何黄色提示条。
package/lib/client.js CHANGED
@@ -2522,6 +2522,28 @@ function attributeViolation(name, value, tagName) {
2522
2522
  syncPushed: '已推送 {{pushed}} 个文件',
2523
2523
  syncConflictLeft: '{{count}} 个冲突未处理',
2524
2524
  ctxPushThis: '把这个推送到远端',
2525
+ ctxPushSelected: '推送所选的 {{count}} 项到远端',
2526
+ syncOnlyConflict: '只看冲突',
2527
+ syncLocalTime: '本地 {{when}}',
2528
+ syncRemoteTime: '远端 {{when}}',
2529
+ syncMaxFiles: '最多比较',
2530
+ syncTruncatedHint: '可提高上限或缩小范围。',
2531
+ syncDeleteRemote: '删除远端文件',
2532
+ syncDeleteRemoteDone: '已在远端删除 {{count}} 个文件',
2533
+ syncDeleteRemoteFailed: '{{count}} 个删除失败',
2534
+ historyTitle: '传输与推送历史',
2535
+ historyEmpty: '还没有记录。',
2536
+ historyPush: '推送',
2537
+ historyToRemote: '本地 → 远端',
2538
+ historyToMirror: '远端 → 镜像',
2539
+ historyDetail: '{{files}} 个文件 · {{size}}',
2540
+ autoPushChip: '自动推送',
2541
+ autoPushChipTitle: '已开启:本地静止 {{debounce}} ms 后推送',
2542
+ autoPushChipLast: '最近一次 {{when}}',
2543
+ reconnect: '重新连接',
2544
+ reconnecting: '正在连接…',
2545
+ reconnectOk: '已重新连接',
2546
+ reconnectFail: '连接失败:{{reason}}',
2525
2547
  autoPushTitle: '自动推回远端',
2526
2548
  autoPushLabel: '开启自动推送',
2527
2549
  autoPushWarn: '开启后,本地目录里保存的文件会在停止编辑约 1.5 秒后自动写回远端;如果同一文件在远端也被改过,会保留远端版本(不覆盖)。',
@@ -3059,6 +3081,28 @@ function attributeViolation(name, value, tagName) {
3059
3081
  syncPushed: 'Pushed {{pushed}} file(s)',
3060
3082
  syncConflictLeft: '{{count}} conflict(s) left',
3061
3083
  ctxPushThis: 'Push this to the remote side',
3084
+ ctxPushSelected: 'Push the {{count}} selected to the remote',
3085
+ syncOnlyConflict: 'Conflicts only',
3086
+ syncLocalTime: 'local {{when}}',
3087
+ syncRemoteTime: 'remote {{when}}',
3088
+ syncMaxFiles: 'Compare up to',
3089
+ syncTruncatedHint: 'Raise the limit or narrow the range.',
3090
+ syncDeleteRemote: 'Delete on remote',
3091
+ syncDeleteRemoteDone: 'Deleted {{count}} file(s) on the remote',
3092
+ syncDeleteRemoteFailed: '{{count}} delete(s) failed',
3093
+ historyTitle: 'Transfer and push history',
3094
+ historyEmpty: 'Nothing recorded yet.',
3095
+ historyPush: 'push',
3096
+ historyToRemote: 'local → remote',
3097
+ historyToMirror: 'remote → mirror',
3098
+ historyDetail: '{{files}} files · {{size}}',
3099
+ autoPushChip: 'auto push',
3100
+ autoPushChipTitle: 'on · pushes after {{debounce}} ms of local quiet',
3101
+ autoPushChipLast: 'last {{when}}',
3102
+ reconnect: 'Reconnect',
3103
+ reconnecting: 'Connecting…',
3104
+ reconnectOk: 'Reconnected',
3105
+ reconnectFail: 'Could not connect: {{reason}}',
3062
3106
  autoPushTitle: 'Push back automatically',
3063
3107
  autoPushLabel: 'Enable automatic push',
3064
3108
  autoPushWarn: 'Once enabled, files saved locally are written back about 1.5 s after you stop editing. If the same file also changed on the remote side, the remote version is kept (never overwritten).',
@@ -3285,7 +3329,7 @@ function attributeViolation(name, value, tagName) {
3285
3329
  * Host methods the running DSH process does not have yet, the directory
3286
3330
  * pane says so instead of surfacing an unrelated error.
3287
3331
  */
3288
- var HOST_API_REVISION = 6;
3332
+ var HOST_API_REVISION = 7;
3289
3333
  var hostInfoProbe = null;
3290
3334
 
3291
3335
  function probeHostInfo() {
@@ -3829,6 +3873,13 @@ function attributeViolation(name, value, tagName) {
3829
3873
  '.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
3830
3874
  '.rw-linked-notice{margin:6px 8px 0}',
3831
3875
  '.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
3876
+ '.rw-autopush-chip{display:inline-flex;align-items:center;gap:4px;flex:none;padding:0 5px;border-radius:999px;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.16));color:var(--dsw-alias-label-secondary,#8b949e);font-size:10px;letter-spacing:0;text-transform:none}',
3877
+ '.rw-autopush-when{font-variant-numeric:tabular-nums;opacity:.8}',
3878
+ '.rw-sync-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:2px 0 6px}',
3879
+ '.rw-sync-toggle{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary,#8b949e)}',
3880
+ '.rw-sync-max{padding:1px 4px;font-size:11.5px;border-radius:6px}',
3881
+ '.rw-sync-detail{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;color:var(--dsw-alias-label-tertiary,#8b949e);font-variant-numeric:tabular-nums}',
3882
+ '.rw-sync-delete{flex:none}',
3832
3883
  '.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
3833
3884
  '.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
3834
3885
  '.rw-search-stats{padding:2px 8px 4px;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
@@ -4480,6 +4531,12 @@ function attributeViolation(name, value, tagName) {
4480
4531
  h('path', { key: 'b', d: 'M11.2 2.2v3h-3M4.8 13.8v-3h3', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round' }),
4481
4532
  ]);
4482
4533
  }
4534
+ function IconClock(size) {
4535
+ return svg(size || 14, [
4536
+ h('circle', { key: 'a', cx: 8, cy: 8, r: 5.8, stroke: 'currentColor', strokeWidth: 1.3 }),
4537
+ h('path', { key: 'b', d: 'M8 4.6V8l2.4 1.6', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round' }),
4538
+ ]);
4539
+ }
4483
4540
  function Spinner(size) {
4484
4541
  var s = size || 14;
4485
4542
  return h('span', { className: 'rw-spinner', 'aria-hidden': 'true' }, svg(s, h('circle', {
@@ -6187,6 +6244,12 @@ function attributeViolation(name, value, tagName) {
6187
6244
  style: props.syncEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
6188
6245
  onClick: props.onSync,
6189
6246
  }, IconSync(14)),
6247
+ h('button', {
6248
+ type: 'button',
6249
+ className: 'rw-icon-btn',
6250
+ title: props.historyTitle || t('historyTitle'),
6251
+ onClick: props.onHistory,
6252
+ }, IconClock(14)),
6190
6253
  h('button', {
6191
6254
  type: 'button',
6192
6255
  className: 'rw-icon-btn',
@@ -6947,11 +7010,29 @@ function rememberShowHidden(value) {
6947
7010
  function SyncPlanDialog(props) {
6948
7011
  var t = props.t;
6949
7012
  var plan = props.plan;
7013
+ var conflictOnlyState = useState(false);
7014
+ var conflictOnly = conflictOnlyState[0];
7015
+ var setConflictOnly = conflictOnlyState[1];
7016
+ var when = function (value) {
7017
+ if (!value) return '';
7018
+ var date = new Date(value);
7019
+ return Number.isNaN(date.getTime()) ? '' : date.toLocaleString();
7020
+ };
7021
+ var detailOf = function (item) {
7022
+ var parts = [];
7023
+ if (typeof item.size === 'number') parts.push(formatBytes(item.size));
7024
+ if (item.localHash) parts.push('L ' + String(item.localHash).slice(0, 8));
7025
+ if (item.remoteHash) parts.push('R ' + String(item.remoteHash).slice(0, 8));
7026
+ if (item.localMtime) parts.push(t('syncLocalTime', { when: when(item.localMtime) }));
7027
+ if (item.remoteMtime) parts.push(t('syncRemoteTime', { when: when(item.remoteMtime) }));
7028
+ return parts.join(' · ');
7029
+ };
6950
7030
  var rows = []
6951
- .concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item }; }))
6952
- .concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item }; }))
6953
- .concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item }; }))
6954
- .concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item }; }));
7031
+ .concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item, kind: 'added' }; }))
7032
+ .concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item, kind: 'changed' }; }))
7033
+ .concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item, kind: 'conflict' }; }))
7034
+ .concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item, kind: 'removed' }; }));
7035
+ if (conflictOnly) rows = rows.filter(function (row) { return row.kind === 'conflict'; });
6955
7036
  var busy = Boolean(props.busy);
6956
7037
  return h(DialogShell, { title: t('syncTitle'), onClose: busy ? function () {} : props.onClose },
6957
7038
  h('div', { className: 'rw-dialog-message' },
@@ -6961,14 +7042,43 @@ function rememberShowHidden(value) {
6961
7042
  conflict: (plan.conflict || []).length,
6962
7043
  removed: (plan.removed || []).length,
6963
7044
  })),
6964
- plan.truncated ? h('div', { className: 'rw-dialog-message rw-warn-text' }, t('syncTruncated', { max: plan.maxFiles })) : null,
7045
+ h('div', { className: 'rw-sync-toolbar' },
7046
+ h('label', { className: 'rw-sync-toggle' },
7047
+ h('input', {
7048
+ type: 'checkbox',
7049
+ checked: conflictOnly,
7050
+ onChange: function (event) { setConflictOnly(event.currentTarget.checked); },
7051
+ }),
7052
+ h('span', null, t('syncOnlyConflict'))),
7053
+ h('label', { className: 'rw-sync-toggle' },
7054
+ h('span', null, t('syncMaxFiles')),
7055
+ h('select', {
7056
+ className: 'rw-input rw-sync-max',
7057
+ value: String(props.maxFiles || 2000),
7058
+ disabled: busy,
7059
+ onChange: function (event) { props.onReload(Number(event.currentTarget.value)); },
7060
+ }, [500, 2000, 5000].map(function (value) {
7061
+ return h('option', { key: value, value: String(value) }, String(value));
7062
+ })))),
7063
+ plan.truncated
7064
+ ? h('div', { className: 'rw-dialog-message rw-warn-text' }, t('syncTruncated', { max: plan.maxFiles }) + ' ' + t('syncTruncatedHint'))
7065
+ : null,
6965
7066
  plan.skipped ? h('div', { className: 'rw-dialog-message' }, t('syncSkipped', { count: plan.skipped })) : null,
6966
7067
  rows.length === 0
6967
7068
  ? h('div', { className: 'rw-dialog-message' }, t('syncNothing'))
6968
7069
  : h('div', { className: 'rw-sync-list' }, rows.slice(0, 40).map(function (row) {
6969
7070
  return h('div', { key: row.tag + row.item.relative, className: 'rw-sync-row' },
6970
7071
  h('span', { className: 'rw-sync-tag' }, row.tag),
6971
- h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative));
7072
+ h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative),
7073
+ row.kind === 'removed'
7074
+ ? h('button', {
7075
+ type: 'button',
7076
+ className: 'rw-btn rw-btn-sm rw-sync-delete',
7077
+ disabled: busy,
7078
+ title: t('syncDeleteRemote'),
7079
+ onClick: function () { props.onDeleteRemote(row.item.relative); },
7080
+ }, t('syncDeleteRemote'))
7081
+ : h('span', { className: 'rw-sync-detail', title: detailOf(row.item) }, detailOf(row.item)));
6972
7082
  })),
6973
7083
  rows.length > 40 ? h('div', { className: 'rw-dialog-message' }, t('syncMore', { count: rows.length - 40 })) : null,
6974
7084
  props.message ? h('div', { className: 'rw-dialog-message' }, props.message) : null,
@@ -6988,6 +7098,30 @@ function rememberShowHidden(value) {
6988
7098
  }, t('syncPushOverwrite'))));
6989
7099
  }
6990
7100
 
7101
+ function TransferHistoryDialog(props) {
7102
+ var t = props.t;
7103
+ var entries = props.entries || [];
7104
+ var when = function (value) {
7105
+ var date = new Date(value || 0);
7106
+ return Number.isNaN(date.getTime()) ? '' : date.toLocaleString();
7107
+ };
7108
+ return h(DialogShell, { title: t('historyTitle'), onClose: props.onClose },
7109
+ entries.length === 0
7110
+ ? h('div', { className: 'rw-dialog-message' }, t('historyEmpty'))
7111
+ : h('div', { className: 'rw-sync-list' }, entries.slice(0, 50).map(function (entry, index) {
7112
+ var direction = entry.kind === 'push'
7113
+ ? t('historyPush')
7114
+ : entry.direction === 'remote-to-mirror' ? t('historyToMirror') : t('historyToRemote');
7115
+ return h('div', { key: String(entry.at || '') + index, className: 'rw-sync-row' },
7116
+ h('span', { className: 'rw-sync-tag' }, direction),
7117
+ h('span', { className: 'rw-sync-path', title: entry.remotePath || '' }, when(entry.at)),
7118
+ h('span', { className: 'rw-sync-detail' },
7119
+ t('historyDetail', { files: entry.files || 0, size: formatBytes(entry.bytes || 0) })));
7120
+ })),
7121
+ h('div', { className: 'rw-dialog-actions' },
7122
+ h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('close'))));
7123
+ }
7124
+
6991
7125
  function QueueDialog(props) {
6992
7126
  var history = props.history && props.history.length > 0 ? props.history : null;
6993
7127
  return h(DialogShell, { title: props.title, onClose: props.onClose },
@@ -7450,6 +7584,9 @@ function rememberShowHidden(value) {
7450
7584
  var searchStats = searchStatsState[0];
7451
7585
  var setSearchStats = searchStatsState[1];
7452
7586
  var searchJobRef = useRef('');
7587
+ // Relatives the user deleted from the remote side: the push baseline
7588
+ // still remembers them, so the plan would keep offering them.
7589
+ var removedRemotely = useRef(new Set());
7453
7590
  var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
7454
7591
  var search = searchState[0];
7455
7592
  var setSearch = searchState[1];
@@ -7619,6 +7756,38 @@ function rememberShowHidden(value) {
7619
7756
  return function () { alive = false; };
7620
7757
  }, [diskHostId, diskPath]);
7621
7758
 
7759
+ // autoPush is host-side and silent, so surface it here: the switch state
7760
+ // plus the newest push from the transfer history.
7761
+ var autoPushState = useState(null);
7762
+ var autoPush = autoPushState[0];
7763
+ var setAutoPush = autoPushState[1];
7764
+ useEffect(function () {
7765
+ var alive = true;
7766
+ function load() {
7767
+ Promise.all([
7768
+ apiCall('settings.get', {}),
7769
+ apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }),
7770
+ ]).then(function (results) {
7771
+ if (!alive) return;
7772
+ var settings = results[0] || {};
7773
+ var entries = (results[1] && results[1].entries) || [];
7774
+ var lastPush = null;
7775
+ for (var index = 0; index < entries.length; index += 1) {
7776
+ if (entries[index] && entries[index].kind === 'push') { lastPush = entries[index]; break; }
7777
+ }
7778
+ setAutoPush({
7779
+ enabled: settings.autoPushEnabled === true,
7780
+ debounceMs: settings.autoPushDebounceMs || 1500,
7781
+ lastPushAt: lastPush ? lastPush.at : null,
7782
+ });
7783
+ }).catch(function () { if (alive) setAutoPush(null); });
7784
+ }
7785
+ load();
7786
+ var timer = setInterval(load, 15000);
7787
+ if (timer && typeof timer.unref === 'function') timer.unref();
7788
+ return function () { alive = false; clearInterval(timer); };
7789
+ }, [selected && selected.key]);
7790
+
7622
7791
  var openFilesState = useState([]);
7623
7792
  var openFiles = openFilesState[0];
7624
7793
  var setOpenFiles = openFilesState[1];
@@ -8002,6 +8171,14 @@ function rememberShowHidden(value) {
8002
8171
  }
8003
8172
 
8004
8173
  /** Copy the `@relative/path` form the model understands for a workspace path. */
8174
+ /** Turn an absolute remote path into a workspace-relative one (for linked.plan). */
8175
+ function relativeToRemote(filePath) {
8176
+ var root = (selected && selected.remotePath) || '';
8177
+ var relative = String(filePath || '');
8178
+ if (root && relative.indexOf(root) === 0) relative = relative.slice(root.length);
8179
+ return relative.replace(/^\/+/, '');
8180
+ }
8181
+
8005
8182
  function copyReference(filePath) {
8006
8183
  var scope = sourceScopeOf(selected);
8007
8184
  var root = selected && selected.kind === 'remote' ? selected.remotePath : (selected && selected.remotePath) || '';
@@ -8156,26 +8333,101 @@ function rememberShowHidden(value) {
8156
8333
  });
8157
8334
  }
8158
8335
 
8159
- /** Open the diff preview for the whole workspace (or the given paths). */
8160
- function openSyncPlan(paths) {
8336
+ /**
8337
+ * Open the diff preview. `paths` narrows both the preview and the push to
8338
+ * a file or a folder (the server matches a folder as a prefix, so what the
8339
+ * dialog shows is exactly what gets pushed).
8340
+ */
8341
+ function openSyncPlan(paths, maxFiles) {
8161
8342
  var scope = sourceScopeOf(selected);
8162
8343
  if (!scope || scope.kind !== 'linked') return;
8163
- apiCall('linked.plan', { id: scope.id, maxFiles: 2000 }).then(function (plan) {
8344
+ var limit = maxFiles || 2000;
8345
+ apiCall('linked.plan', { id: scope.id, maxFiles: limit }).then(function (plan) {
8346
+ var narrowed = restrictPlan(plan, paths, removedRemotely.current);
8164
8347
  setDialog({
8165
8348
  kind: 'syncPlan',
8166
- plan: plan,
8349
+ plan: narrowed,
8167
8350
  paths: Array.isArray(paths) && paths.length > 0 ? paths : null,
8351
+ maxFiles: limit,
8168
8352
  busy: false,
8169
8353
  message: '',
8170
8354
  });
8171
8355
  }).catch(noticeError);
8172
8356
  }
8173
8357
 
8358
+ /**
8359
+ * Keep only the plan rows that live inside `paths` (files or folders).
8360
+ * Rows the user deleted from the remote side are dropped too: the push
8361
+ * baseline still lists them, so re-planning would show them again.
8362
+ */
8363
+ function restrictPlan(plan, paths, deleted) {
8364
+ var prefixes = Array.isArray(paths) && paths.length > 0
8365
+ ? paths.map(function (item) { return String(item).replace(/^\/+/, '').replace(/\/+$/, ''); })
8366
+ : null;
8367
+ var gone = new Set(Array.isArray(deleted) ? deleted : []);
8368
+ var keep = function (item) {
8369
+ if (gone.has(item.relative)) return false;
8370
+ if (!prefixes) return true;
8371
+ return prefixes.some(function (prefix) {
8372
+ return item.relative === prefix || item.relative.indexOf(prefix + '/') === 0;
8373
+ });
8374
+ };
8375
+ var added = (plan.added || []).filter(keep);
8376
+ var changed = (plan.changed || []).filter(keep);
8377
+ return Object.assign({}, plan, {
8378
+ added: added,
8379
+ changed: changed,
8380
+ conflict: (plan.conflict || []).filter(keep),
8381
+ removed: (plan.removed || []).filter(keep),
8382
+ pending: added.length + changed.length,
8383
+ });
8384
+ }
8385
+
8386
+ /** Delete the local-only leftovers from the remote side (the `removed` rows). */
8387
+ function deleteRemoteEntries(dialog, relatives) {
8388
+ var scope = sourceScopeOf(selected);
8389
+ var root = String((selected && selected.remotePath) || '').replace(/\/+$/, '');
8390
+ if (!scope || scope.kind !== 'linked' || root === '') return;
8391
+ var target = relatives.map(function (relative) {
8392
+ return root + '/' + String(relative).replace(/^\/+/, '');
8393
+ });
8394
+ Promise.all(target.map(function (filePath) {
8395
+ return apiCall('fs.delete', Object.assign({ path: filePath }, scopeParams(scope))).catch(function (error) {
8396
+ // Already gone on the remote side counts as done: the baseline can
8397
+ // list files that were removed outside the plugin.
8398
+ if (error && (error.code === 'FS_NOT_FOUND' || /ENOENT|No such file/i.test(String(error.message || '')))) {
8399
+ return { missing: true };
8400
+ }
8401
+ return { error: error };
8402
+ });
8403
+ })).then(function (results) {
8404
+ var failed = results.filter(function (item) { return item && item.error; }).length;
8405
+ var done = target.length - failed;
8406
+ if (failed === 0) {
8407
+ relatives.forEach(function (relative) { removedRemotely.current.add(relative); });
8408
+ }
8409
+ showNotice(failed === 0 ? 'success' : 'warn',
8410
+ failed === 0 ? t('syncDeleteRemoteDone', { count: done }) : t('syncDeleteRemoteFailed', { count: failed }));
8411
+ refreshTree();
8412
+ openSyncPlan(dialog.paths, dialog.maxFiles);
8413
+ });
8414
+ }
8415
+
8416
+ /** Show the recent transfer / push history the host keeps on disk. */
8417
+ function openHistory() {
8418
+ apiCall('transfer.history', {}).then(function (result) {
8419
+ setDialog({ kind: 'history', entries: (result && result.entries) || [] });
8420
+ }).catch(noticeError);
8421
+ }
8422
+
8174
8423
  /** Push the planned files back to the remote directory. */
8175
- function pushPlan(plan, conflict, paths) {
8424
+ function pushPlan(plan, conflict, paths, maxFiles) {
8176
8425
  var scope = sourceScopeOf(selected);
8177
8426
  if (!scope || scope.kind !== 'linked') return;
8178
- setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: true, message: t('syncPushing') });
8427
+ setDialog({
8428
+ kind: 'syncPlan', plan: plan, paths: paths || null, maxFiles: maxFiles || 2000,
8429
+ busy: true, message: t('syncPushing'),
8430
+ });
8179
8431
  var jobId = 'push-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
8180
8432
  var params = { id: scope.id, conflict: conflict, jobId: jobId };
8181
8433
  if (Array.isArray(paths) && paths.length > 0) params.paths = paths;
@@ -8186,7 +8438,10 @@ function rememberShowHidden(value) {
8186
8438
  showNotice(result.pushed > 0 ? 'success' : 'warn', text);
8187
8439
  refreshTree();
8188
8440
  }).catch(function (error) {
8189
- setDialog({ kind: 'syncPlan', plan: plan, paths: paths || null, busy: false, message: messageOf(error, t, locale) });
8441
+ setDialog({
8442
+ kind: 'syncPlan', plan: plan, paths: paths || null, maxFiles: maxFiles || 2000,
8443
+ busy: false, message: messageOf(error, t, locale),
8444
+ });
8190
8445
  });
8191
8446
  }
8192
8447
 
@@ -8592,6 +8847,12 @@ function rememberShowHidden(value) {
8592
8847
  items.push({ label: t('ctxRenameSelected', { count: batch.length }), onSelect: function () {
8593
8848
  setDialog({ kind: 'renameMany', side: menu.side, entries: batch });
8594
8849
  } });
8850
+ if (hasLocal && isRemote) {
8851
+ // Push several entries at once; folders are matched as prefixes.
8852
+ items.push({ label: t('ctxPushSelected', { count: batch.length }), onSelect: function () {
8853
+ openSyncPlan(batch.map(function (item) { return relativeToRemote(item.path); }));
8854
+ } });
8855
+ }
8595
8856
  }
8596
8857
  items.push({ separator: true });
8597
8858
  }
@@ -8783,10 +9044,20 @@ function rememberShowHidden(value) {
8783
9044
  return h(SyncPlanDialog, {
8784
9045
  t: t,
8785
9046
  plan: dialog.plan,
9047
+ maxFiles: dialog.maxFiles || 2000,
8786
9048
  busy: Boolean(dialog.busy),
8787
9049
  message: dialog.message,
8788
9050
  onClose: function () { if (!dialog.busy) setDialog(null); },
8789
9051
  onPush: function (conflict) { return pushPlan(dialog.plan, conflict, dialog.paths); },
9052
+ onReload: function (nextMax) { openSyncPlan(dialog.paths, nextMax); },
9053
+ onDeleteRemote: function (relative) { deleteRemoteEntries(dialog, [relative]); },
9054
+ });
9055
+ }
9056
+ if (dialog.kind === 'history') {
9057
+ return h(TransferHistoryDialog, {
9058
+ t: t,
9059
+ entries: dialog.entries,
9060
+ onClose: function () { setDialog(null); },
8790
9061
  });
8791
9062
  }
8792
9063
  if (dialog.kind === 'renameMany') {
@@ -9121,6 +9392,8 @@ function rememberShowHidden(value) {
9121
9392
  syncEnabled: selected.kind === 'linked',
9122
9393
  syncTitle: selected.kind === 'linked' ? t('syncTitle') : t('syncNeedsLinked'),
9123
9394
  onSync: function () { openSyncPlan(null); },
9395
+ historyTitle: t('historyTitle'),
9396
+ onHistory: openHistory,
9124
9397
  }),
9125
9398
  searchOpen
9126
9399
  ? h('div', { className: 'rw-searchbar' },
@@ -9288,6 +9561,15 @@ function rememberShowHidden(value) {
9288
9561
  title: (disk.path ? disk.path + ' · ' : '') + t('diskFree', { free: formatBytes(disk.avail), percent: disk.percent }) + (disk.used ? ' · ' + formatBytes(disk.used) + ' / ' + formatBytes(disk.size) : ''),
9289
9562
  }, formatBytes(disk.avail))
9290
9563
  : null,
9564
+ autoPush && autoPush.enabled
9565
+ ? h('span', {
9566
+ className: 'rw-autopush-chip',
9567
+ title: t('autoPushChipTitle', { debounce: autoPush.debounceMs }) +
9568
+ (autoPush.lastPushAt ? ' · ' + t('autoPushChipLast', { when: new Date(autoPush.lastPushAt).toLocaleString() }) : ''),
9569
+ }, t('autoPushChip'), autoPush.lastPushAt
9570
+ ? h('span', { className: 'rw-autopush-when' }, new Date(autoPush.lastPushAt).toLocaleTimeString())
9571
+ : null)
9572
+ : null,
9291
9573
  h('button', { type: 'button', className: 'rw-icon-btn', title: t('toggleDirectory'), onClick: function () { setDirectoryOpen(false); } }, IconClose(11))),
9292
9574
  h('div', { className: 'rw-directory-body' }, body))
9293
9575
  : null),
@@ -10210,6 +10492,16 @@ function rememberShowHidden(value) {
10210
10492
  }
10211
10493
 
10212
10494
  var modalRef = useRef(null);
10495
+ // The overlay lives in a portal (`PortalBackdrop`), so the modal element
10496
+ // only exists one commit after `open` flips. Keep it in state: the focus
10497
+ // and wheel effects below must run again once it is really mounted.
10498
+ var modalNodeState = useState(null);
10499
+ var modalNode = modalNodeState[0];
10500
+ var setModalNode = modalNodeState[1];
10501
+ var attachModal = function (node) {
10502
+ modalRef.current = node;
10503
+ if (node !== modalNode) setModalNode(node);
10504
+ };
10213
10505
  var focusablesOf = function () {
10214
10506
  var node = modalRef.current;
10215
10507
  if (!node) return [];
@@ -10225,7 +10517,7 @@ function rememberShowHidden(value) {
10225
10517
  // Focus the first real field, not the tab strip, so typing works at once.
10226
10518
  var target = node.querySelector('.rw-modal-body input, .rw-modal-body textarea') || focusablesOf()[0];
10227
10519
  if (target && typeof target.focus === 'function') target.focus();
10228
- }, [props.open, flow]);
10520
+ }, [props.open, flow, modalNode]);
10229
10521
 
10230
10522
  // The app shell listens for wheel gestures on the document root and moves
10231
10523
  // the conversation behind the dialog, so a wheel over the host list (or
@@ -10269,7 +10561,7 @@ function rememberShowHidden(value) {
10269
10561
 
10270
10562
  window.addEventListener('wheel', onWheel, { passive: false, capture: true });
10271
10563
  return function () { window.removeEventListener('wheel', onWheel, { capture: true }); };
10272
- }, [props.open]);
10564
+ }, [props.open, modalNode]);
10273
10565
 
10274
10566
  // Esc has to be caught on the window: the overlay now lives in a top-layer
10275
10567
  // <dialog>, so key events start at that element and never reach the modal
@@ -10317,7 +10609,7 @@ function rememberShowHidden(value) {
10317
10609
  onEscape: function () { if (props.onCancel) props.onCancel(); },
10318
10610
  },
10319
10611
  h('div', {
10320
- ref: modalRef,
10612
+ ref: attachModal,
10321
10613
  className: 'rw-modal',
10322
10614
  role: 'dialog',
10323
10615
  'aria-modal': 'true',
@@ -10509,6 +10801,29 @@ function rememberShowHidden(value) {
10509
10801
  });
10510
10802
  }
10511
10803
 
10804
+ /**
10805
+ * Drop this host's socket and dial again. A stale “not connected” chip is
10806
+ * the usual reason to press it: nothing else asks the host for a file, so
10807
+ * the status would otherwise stay idle until some other action dials.
10808
+ */
10809
+ function reconnect() {
10810
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'reconnect', message: null }); });
10811
+ apiCall('hosts.reconnect', { hostId: link.hostId }).then(function (status) {
10812
+ var ok = Boolean(status && status.state === 'connected');
10813
+ setLocal(function (previous) {
10814
+ return Object.assign({}, previous, {
10815
+ busy: '',
10816
+ message: ok
10817
+ ? { kind: 'success', text: t('reconnectOk') }
10818
+ : { kind: 'error', text: t('reconnectFail', { reason: (status && status.message) || t('errorState') }) },
10819
+ });
10820
+ });
10821
+ refresh();
10822
+ }).catch(function (error) {
10823
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: messageOf(error, t, locale) } }); });
10824
+ });
10825
+ }
10826
+
10512
10827
  function remove() {
10513
10828
  if (!local.removing) {
10514
10829
  setLocal(function (previous) { return Object.assign({}, previous, { removing: true, message: null }); });
@@ -10558,6 +10873,10 @@ function rememberShowHidden(value) {
10558
10873
  local.busy === 'sync'
10559
10874
  ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: cancelSync }, t('syncCancel'))
10560
10875
  : null,
10876
+ h('button', {
10877
+ type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: reconnect,
10878
+ disabled: local.busy !== '', title: t('reconnect'),
10879
+ }, local.busy === 'reconnect' ? Spinner(12) : IconRefresh(12), local.busy === 'reconnect' ? t('reconnecting') : t('reconnect')),
10561
10880
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove }, IconTrash(12), t('removeLinked')))),
10562
10881
  h('div', { className: 'rw-meta' },
10563
10882
  h('span', { className: 'rw-chip' }, link.mirror ? t('mirrorOn') : t('mirrorOff')),
@@ -10654,6 +10973,29 @@ function rememberShowHidden(value) {
10654
10973
  });
10655
10974
  }
10656
10975
 
10976
+ /**
10977
+ * Drop this host's socket and dial again. A stale “not connected” chip is
10978
+ * the usual reason to press it: nothing else asks the host for a file, so
10979
+ * the status would otherwise stay idle until some other action dials.
10980
+ */
10981
+ function reconnect() {
10982
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: 'reconnect', message: null }); });
10983
+ apiCall('hosts.reconnect', { hostId: workspace.hostId }).then(function (status) {
10984
+ var ok = Boolean(status && status.state === 'connected');
10985
+ setLocal(function (previous) {
10986
+ return Object.assign({}, previous, {
10987
+ busy: '',
10988
+ message: ok
10989
+ ? { kind: 'success', text: t('reconnectOk') }
10990
+ : { kind: 'error', text: t('reconnectFail', { reason: (status && status.message) || t('errorState') }) },
10991
+ });
10992
+ });
10993
+ refresh();
10994
+ }).catch(function (error) {
10995
+ setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: messageOf(error, t, locale) } }); });
10996
+ });
10997
+ }
10998
+
10657
10999
  function testConnection() {
10658
11000
  setLocal(function (previous) { return Object.assign({}, previous, { busy: 'test', message: null }); });
10659
11001
  apiCall('remote_workspaces.test', { id: workspace.id }).then(function (result) {
@@ -10727,6 +11069,10 @@ function rememberShowHidden(value) {
10727
11069
  : null,
10728
11070
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openTree }, IconFolderTree(12), t('openTree')),
10729
11071
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: testConnection, disabled: local.busy !== '' }, local.busy === 'test' ? Spinner(12) : IconRefresh(12), t('testConnection')),
11072
+ h('button', {
11073
+ type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: reconnect,
11074
+ disabled: local.busy !== '', title: t('reconnect'),
11075
+ }, local.busy === 'reconnect' ? Spinner(12) : IconSync(12), local.busy === 'reconnect' ? t('reconnecting') : t('reconnect')),
10730
11076
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: startRename, disabled: local.busy !== '' }, t('rename')),
10731
11077
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('removeRemote'))))),
10732
11078
  h('div', { className: 'rw-hint' }, t('remoteSessionHint')),
package/lib/index.js CHANGED
@@ -38,7 +38,7 @@ export const inject = ['webServer', 'tools', 'systemPrompt', 'workingDirectory']
38
38
  * is still running an older copy of the Host — refreshing the page only swaps
39
39
  * the browser bundle, so the two halves can drift by one restart.
40
40
  */
41
- const API_REVISION = 6
41
+ const API_REVISION = 7
42
42
 
43
43
  /** When this copy of the Host was loaded; shown by `meta.info`. */
44
44
  const STARTED_AT = new Date().toISOString()
@@ -1437,7 +1437,10 @@ export function apply(ctx) {
1437
1437
  const startSyncJob = (record, options = {}) => {
1438
1438
  if (!record.mirror) throw new ApiError('BAD_REQUEST', '该联动工作区未启用 .remote 存档;请先在设置中打开镜像')
1439
1439
  const running = syncJobs.get(record.id)
1440
- if (running && running.state === 'running') return running
1440
+ // A job that is already winding down must not be handed back: turning the
1441
+ // mirror off and on again used to return the cancelled job, so the next
1442
+ // `linked.sync` reported "cancelled" without pulling anything.
1443
+ if (running && running.state === 'running' && !running.cancel) return running
1441
1444
  const job = {
1442
1445
  id: randomUUID(),
1443
1446
  linkId: record.id,
@@ -2003,7 +2006,14 @@ export function apply(ctx) {
2003
2006
  remoteStat = null
2004
2007
  }
2005
2008
  if (!remoteStat || remoteStat.type !== 'file') {
2006
- buckets.added.push({ relative: file.relative, size: file.size, localHash, remoteHash: null })
2009
+ buckets.added.push({
2010
+ relative: file.relative,
2011
+ size: file.size,
2012
+ localHash,
2013
+ remoteHash: null,
2014
+ localMtime: file.mtimeMs,
2015
+ remoteMtime: null,
2016
+ })
2007
2017
  continue
2008
2018
  }
2009
2019
  const remoteHash = await readRemoteHash(remote, remotePath, remoteStat.size)
@@ -2012,7 +2022,14 @@ export function apply(ctx) {
2012
2022
  continue
2013
2023
  }
2014
2024
  const baselineHash = known && typeof known.hash === 'string' ? known.hash : ''
2015
- const entry = { relative: file.relative, size: file.size, localHash, remoteHash }
2025
+ const entry = {
2026
+ relative: file.relative,
2027
+ size: file.size,
2028
+ localHash,
2029
+ remoteHash,
2030
+ localMtime: file.mtimeMs,
2031
+ remoteMtime: remoteStat.mtime,
2032
+ }
2016
2033
  if (baselineHash === '' || baselineHash === remoteHash) buckets.changed.push(entry)
2017
2034
  else buckets.conflict.push(entry)
2018
2035
  }
@@ -2047,15 +2064,21 @@ export function apply(ctx) {
2047
2064
 
2048
2065
  const applyPlan = async (record, remote, plan, options = {}, job = null) => {
2049
2066
  const mode = PUSH_FILES_CONFLICT.has(options.conflict) ? options.conflict : 'skip'
2067
+ // `paths` may name files or whole folders: the tree hands over whatever the
2068
+ // user right-clicked, so a folder has to match everything below it.
2050
2069
  const only = Array.isArray(options.paths) && options.paths.length > 0
2051
- ? new Set(options.paths.map((item) => String(item).replace(/^\/+/, '')))
2070
+ ? options.paths.map((item) => String(item).replace(/^\/+/, '').replace(/\/+$/, '')).filter(Boolean)
2052
2071
  : null
2072
+ const inScope = (relative) => {
2073
+ if (!only) return true
2074
+ return only.some((prefix) => relative === prefix || relative.startsWith(`${prefix}/`))
2075
+ }
2053
2076
  const state = readPushState()
2054
2077
  const baseline = state.byWorkspace[record.id] && typeof state.byWorkspace[record.id] === 'object'
2055
2078
  ? state.byWorkspace[record.id]
2056
2079
  : {}
2057
- const queue = [...plan.added, ...plan.changed].filter((item) => !only || only.has(item.relative))
2058
- const conflicted = plan.conflict.filter((item) => !only || only.has(item.relative))
2080
+ const queue = [...plan.added, ...plan.changed].filter((item) => inScope(item.relative))
2081
+ const conflicted = plan.conflict.filter((item) => inScope(item.relative))
2059
2082
  const pushed = []
2060
2083
  let bytes = 0
2061
2084
  let skipped = 0
@@ -2158,6 +2181,8 @@ export function apply(ctx) {
2158
2181
  // workspace-relative path.
2159
2182
 
2160
2183
  const AUTO_PUSH_RETRY_MS = 2000
2184
+ const AUTO_PUSH_RETRY_MAX = 60000
2185
+ const AUTO_PUSH_MAX_ATTEMPTS = 5
2161
2186
  const autoPushWatchers = new Map()
2162
2187
 
2163
2188
  const globToRegExp = (pattern) => {
@@ -2203,13 +2228,28 @@ export function apply(ctx) {
2203
2228
  const host = await findHost(record.hostId)
2204
2229
  const remote = await connectHost(host)
2205
2230
  const plan = autoPushFilter(settings, await buildPlan(record, remote, {}))
2206
- if (plan.added.length === 0 && plan.changed.length === 0) return
2231
+ if (plan.added.length === 0 && plan.changed.length === 0) {
2232
+ entry.failures = 0
2233
+ return
2234
+ }
2207
2235
  const result = await applyPlan(record, remote, plan, { conflict: 'skip' })
2236
+ entry.failures = 0
2208
2237
  forgetListings()
2209
2238
  log('info', `autoPush ${record.name}: ${result.pushed} file(s), ${result.skipped} skipped`)
2210
2239
  } catch (error) {
2211
- log('warn', `autoPush ${record.name} failed: ${error && error.message ? error.message : error}`)
2212
- entry.timer = setTimeout(() => { entry.timer = null; void runAutoPush(record, entry) }, AUTO_PUSH_RETRY_MS)
2240
+ entry.failures = (entry.failures || 0) + 1
2241
+ const message = error && error.message ? error.message : String(error)
2242
+ if (entry.failures >= AUTO_PUSH_MAX_ATTEMPTS) {
2243
+ // An unreachable host must not retry forever: five attempts with
2244
+ // backoff, then wait for the next local edit to start over.
2245
+ entry.failures = 0
2246
+ log('warn', `autoPush ${record.name} gave up after ${AUTO_PUSH_MAX_ATTEMPTS} attempts: ${message}`)
2247
+ return
2248
+ }
2249
+ const wait = Math.min(AUTO_PUSH_RETRY_MS * 2 ** (entry.failures - 1), AUTO_PUSH_RETRY_MAX)
2250
+ log('warn', `autoPush ${record.name} failed (attempt ${entry.failures}/${AUTO_PUSH_MAX_ATTEMPTS}, retry in ${wait}ms): ${message}`)
2251
+ entry.timer = setTimeout(() => { entry.timer = null; void runAutoPush(record, entry) }, wait)
2252
+ if (entry.timer && typeof entry.timer.unref === 'function') entry.timer.unref()
2213
2253
  } finally {
2214
2254
  entry.running = false
2215
2255
  }
@@ -2974,6 +3014,33 @@ export function apply(ctx) {
2974
3014
  return { statuses }
2975
3015
  },
2976
3016
 
3017
+ /**
3018
+ * Drop whatever socket we hold for this host and dial again.
3019
+ *
3020
+ * `hosts.status` never dials, so a host whose status went stale (a slept
3021
+ * laptop, a server that came back) keeps reporting "not connected" until
3022
+ * something asks for a file. This is the explicit escape hatch: it returns
3023
+ * the resulting status instead of throwing, so the caller can show the real
3024
+ * reason in the card.
3025
+ */
3026
+ async 'hosts.reconnect'(params = {}) {
3027
+ const host = await findHost(params.hostId)
3028
+ const live = pool.connection(host.id)
3029
+ if (live) {
3030
+ pool.connections.delete(host.id)
3031
+ live.dispose().catch(() => {})
3032
+ }
3033
+ const startedAt = Date.now()
3034
+ try {
3035
+ await pool.remote(host)
3036
+ pool.setStatus(host.id, { state: 'connected', latencyMs: Date.now() - startedAt })
3037
+ } catch (error) {
3038
+ const message = error && error.message ? String(error.message) : String(error)
3039
+ pool.setStatus(host.id, { state: 'error', reason: 'connect', message })
3040
+ }
3041
+ return { hostId: host.id, ...hostStatusView(host.id) }
3042
+ },
3043
+
2977
3044
  /**
2978
3045
  * Store a credential for one SSH host on this machine.
2979
3046
  *
@@ -4614,6 +4681,8 @@ export function apply(ctx) {
4614
4681
  linkedStore.add(record)
4615
4682
  const workspace = await ensureDshWorkspace(linkedRegistry(), localPath, linkedWorkspaceTitle(name))
4616
4683
  pool.setStatus(host.id, { state: 'connected', latencyMs: 0 })
4684
+ // A new workspace has to be watched too while autoPush is on.
4685
+ syncAutoPush()
4617
4686
  log('info', `linked workspace "${name}" (${localPath} ⇄ ${record.hostSnapshot.username}@${record.hostSnapshot.host}:${remoteRoot})`)
4618
4687
  return { link: describeLink(record), workspaceId: workspace ? workspace.id : null }
4619
4688
  },
@@ -4654,6 +4723,9 @@ export function apply(ctx) {
4654
4723
 
4655
4724
  async 'linked.remove'(params = {}) {
4656
4725
  const record = requireLinked(params.id)
4726
+ // Drop the watcher before the record disappears, otherwise a stale
4727
+ // fs.watch keeps firing for a workspace that is gone.
4728
+ stopAutoPush(record.id)
4657
4729
  linkedStore.remove(record.id)
4658
4730
  let removedWorkspace = false
4659
4731
  if (params.removeWorkspace === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.20.2",
3
+ "version": "0.22.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",