dsh-linked-workspace 0.20.1 → 0.21.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 +14 -0
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/docs/API.md +1 -1
- package/docs/VERIFY.md +10 -0
- package/lib/client.js +306 -17
- package/lib/index.js +50 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
English · [简体中文](CHANGELOG.zh.md)
|
|
4
4
|
|
|
5
|
+
## 0.21.0 — 2026-11-20
|
|
6
|
+
|
|
7
|
+
- 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).
|
|
8
|
+
- 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.
|
|
9
|
+
- “Removed remotely” rows gained a “Delete remote file” action, and a file that is already gone counts as handled.
|
|
10
|
+
- New “Transfer and push history” dialog showing the last 50 transfer/push entries the host keeps on disk.
|
|
11
|
+
- The directory header shows an “auto push” chip with the time of the last push (hover for the debounce interval).
|
|
12
|
+
- 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.
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
15
|
+
## 0.20.2 — 2026-11-19
|
|
16
|
+
|
|
17
|
+
- **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.
|
|
18
|
+
|
|
5
19
|
## 0.20.1 — 2026-11-19
|
|
6
20
|
|
|
7
21
|
- **Overlays now live in the browser top layer.** The add-workspace dialog, every confirm/prompt dialog and the welcome card render into a `<dialog>` element with `showModal()`, so no neighbouring column (the right pane or the chat composer) can cover them. The old `z-index` values only worked inside one stacking context, which is why the same dialog was sometimes clipped.
|
package/README.en.md
CHANGED
|
@@ -277,3 +277,5 @@ On Windows, run `test/host-api.mjs` with DSH's bundled Electron Node (system Nod
|
|
|
277
277
|
## License
|
|
278
278
|
|
|
279
279
|
MIT © 2026 Huangjh
|
|
280
|
+
|
|
281
|
+
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
|
@@ -277,3 +277,5 @@ node test/ssh-smoke.mjs # 真实 SSH 传输自检(按需)
|
|
|
277
277
|
## License
|
|
278
278
|
|
|
279
279
|
MIT © 2026 Huangjh
|
|
280
|
+
|
|
281
|
+
从 0.21.0 起,差异预览会跟着你的入口收窄:右键文件夹或选中若干项再推送,预览里只有这些范围内的条目,每行还带大小、两边时间与 hash 前 8 位,可以勾「只看冲突」;「远端已删」的行能直接删掉远端残留。工具栏的时钟按钮打开「传输与推送历史」,目录栏的「自动推送」chip 显示最近一次推送时间——自动推送现在跟随工作区增删,失败会退避重试最多 5 次。
|
package/docs/API.md
CHANGED
|
@@ -101,7 +101,7 @@ scope root, or absolute inside it.
|
|
|
101
101
|
| `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
102
|
| `fs.grepCancel` | `{ jobId }` | `{ cancelled }` (marks the job started by `fs.grep`'s `jobId`; the Host checks it between files and answers `truncatedReason: 'cancelled'`) |
|
|
103
103
|
| `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) |
|
|
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; `paths` entries may be files or folders — a folder matches everything under it — and every planned entry carries `localMtime` / `remoteMtime`) |
|
|
105
105
|
| `linked.pushCancel` | `{ jobId }` | `{ cancelled }` (stops after the file being written) |
|
|
106
106
|
| `transfer.history` | `{}` | `{ entries: [{ kind: "transfer" \| "push", direction?, linkedId?, files, bytes, skipped, truncated?, at }] }` (newest first, at most 50) |
|
|
107
107
|
| `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%)· 已用 / 总量」;换工作区后数字随之变化。
|
package/lib/client.js
CHANGED
|
@@ -2522,6 +2522,24 @@ 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}}',
|
|
2525
2543
|
autoPushTitle: '自动推回远端',
|
|
2526
2544
|
autoPushLabel: '开启自动推送',
|
|
2527
2545
|
autoPushWarn: '开启后,本地目录里保存的文件会在停止编辑约 1.5 秒后自动写回远端;如果同一文件在远端也被改过,会保留远端版本(不覆盖)。',
|
|
@@ -3059,6 +3077,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
3059
3077
|
syncPushed: 'Pushed {{pushed}} file(s)',
|
|
3060
3078
|
syncConflictLeft: '{{count}} conflict(s) left',
|
|
3061
3079
|
ctxPushThis: 'Push this to the remote side',
|
|
3080
|
+
ctxPushSelected: 'Push the {{count}} selected to the remote',
|
|
3081
|
+
syncOnlyConflict: 'Conflicts only',
|
|
3082
|
+
syncLocalTime: 'local {{when}}',
|
|
3083
|
+
syncRemoteTime: 'remote {{when}}',
|
|
3084
|
+
syncMaxFiles: 'Compare up to',
|
|
3085
|
+
syncTruncatedHint: 'Raise the limit or narrow the range.',
|
|
3086
|
+
syncDeleteRemote: 'Delete on remote',
|
|
3087
|
+
syncDeleteRemoteDone: 'Deleted {{count}} file(s) on the remote',
|
|
3088
|
+
syncDeleteRemoteFailed: '{{count}} delete(s) failed',
|
|
3089
|
+
historyTitle: 'Transfer and push history',
|
|
3090
|
+
historyEmpty: 'Nothing recorded yet.',
|
|
3091
|
+
historyPush: 'push',
|
|
3092
|
+
historyToRemote: 'local → remote',
|
|
3093
|
+
historyToMirror: 'remote → mirror',
|
|
3094
|
+
historyDetail: '{{files}} files · {{size}}',
|
|
3095
|
+
autoPushChip: 'auto push',
|
|
3096
|
+
autoPushChipTitle: 'on · pushes after {{debounce}} ms of local quiet',
|
|
3097
|
+
autoPushChipLast: 'last {{when}}',
|
|
3062
3098
|
autoPushTitle: 'Push back automatically',
|
|
3063
3099
|
autoPushLabel: 'Enable automatic push',
|
|
3064
3100
|
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).',
|
|
@@ -3752,7 +3788,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
3752
3788
|
'.rw-tab{flex:1 1 auto;height:28px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:7px;background:transparent;font:inherit;font-size:12px;color:var(--dsw-alias-label-secondary);cursor:pointer}',
|
|
3753
3789
|
'.rw-tab.is-on{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-weight:600;box-shadow:0 0 0 1px var(--dsw-alias-border-l1)}',
|
|
3754
3790
|
'.rw-top-layer{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;overflow:visible;color:inherit}',
|
|
3755
|
-
'.rw-top-layer::backdrop{background:
|
|
3791
|
+
'.rw-top-layer::backdrop{background:rgba(0,0,0,.42);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}',
|
|
3792
|
+
// A theme can make the sheet translucent (the mica / floating-card look),
|
|
3793
|
+
// and because the sheet now lives in the top layer the host's own blur no
|
|
3794
|
+
// longer applies to it — the page behind would show through as readable
|
|
3795
|
+
// mirrored text. Blur whatever sits behind the sheet so only colour leaks.
|
|
3796
|
+
'.rw-top-layer .rw-modal,.rw-top-layer .rw-dialog,.rw-top-layer .rw-welcome{backdrop-filter:blur(18px) saturate(140%);-webkit-backdrop-filter:blur(18px) saturate(140%)}',
|
|
3756
3797
|
'.rw-modal-backdrop{position:fixed;inset:0;z-index:1200;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.34)}',
|
|
3757
3798
|
'.rw-modal{display:flex;flex-direction:column;width:min(620px,100%);max-height:min(760px,88vh);border:1px solid var(--dsw-alias-border-l2);border-radius:16px;background:var(--dsw-alias-bg-overlay);box-shadow:0 18px 60px rgba(0,0,0,.35);overflow:hidden}',
|
|
3758
3799
|
'.rw-modal-head{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
|
|
@@ -3824,6 +3865,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
3824
3865
|
'.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3825
3866
|
'.rw-linked-notice{margin:6px 8px 0}',
|
|
3826
3867
|
'.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3868
|
+
'.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}',
|
|
3869
|
+
'.rw-autopush-when{font-variant-numeric:tabular-nums;opacity:.8}',
|
|
3870
|
+
'.rw-sync-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:2px 0 6px}',
|
|
3871
|
+
'.rw-sync-toggle{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary,#8b949e)}',
|
|
3872
|
+
'.rw-sync-max{padding:1px 4px;font-size:11.5px;border-radius:6px}',
|
|
3873
|
+
'.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}',
|
|
3874
|
+
'.rw-sync-delete{flex:none}',
|
|
3827
3875
|
'.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
|
|
3828
3876
|
'.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
|
|
3829
3877
|
'.rw-search-stats{padding:2px 8px 4px;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
@@ -4475,6 +4523,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
4475
4523
|
h('path', { key: 'b', d: 'M11.2 2.2v3h-3M4.8 13.8v-3h3', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
4476
4524
|
]);
|
|
4477
4525
|
}
|
|
4526
|
+
function IconClock(size) {
|
|
4527
|
+
return svg(size || 14, [
|
|
4528
|
+
h('circle', { key: 'a', cx: 8, cy: 8, r: 5.8, stroke: 'currentColor', strokeWidth: 1.3 }),
|
|
4529
|
+
h('path', { key: 'b', d: 'M8 4.6V8l2.4 1.6', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
4530
|
+
]);
|
|
4531
|
+
}
|
|
4478
4532
|
function Spinner(size) {
|
|
4479
4533
|
var s = size || 14;
|
|
4480
4534
|
return h('span', { className: 'rw-spinner', 'aria-hidden': 'true' }, svg(s, h('circle', {
|
|
@@ -6182,6 +6236,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6182
6236
|
style: props.syncEnabled ? undefined : { opacity: 0.42, cursor: 'default' },
|
|
6183
6237
|
onClick: props.onSync,
|
|
6184
6238
|
}, IconSync(14)),
|
|
6239
|
+
h('button', {
|
|
6240
|
+
type: 'button',
|
|
6241
|
+
className: 'rw-icon-btn',
|
|
6242
|
+
title: props.historyTitle || t('historyTitle'),
|
|
6243
|
+
onClick: props.onHistory,
|
|
6244
|
+
}, IconClock(14)),
|
|
6185
6245
|
h('button', {
|
|
6186
6246
|
type: 'button',
|
|
6187
6247
|
className: 'rw-icon-btn',
|
|
@@ -6942,11 +7002,29 @@ function rememberShowHidden(value) {
|
|
|
6942
7002
|
function SyncPlanDialog(props) {
|
|
6943
7003
|
var t = props.t;
|
|
6944
7004
|
var plan = props.plan;
|
|
7005
|
+
var conflictOnlyState = useState(false);
|
|
7006
|
+
var conflictOnly = conflictOnlyState[0];
|
|
7007
|
+
var setConflictOnly = conflictOnlyState[1];
|
|
7008
|
+
var when = function (value) {
|
|
7009
|
+
if (!value) return '';
|
|
7010
|
+
var date = new Date(value);
|
|
7011
|
+
return Number.isNaN(date.getTime()) ? '' : date.toLocaleString();
|
|
7012
|
+
};
|
|
7013
|
+
var detailOf = function (item) {
|
|
7014
|
+
var parts = [];
|
|
7015
|
+
if (typeof item.size === 'number') parts.push(formatBytes(item.size));
|
|
7016
|
+
if (item.localHash) parts.push('L ' + String(item.localHash).slice(0, 8));
|
|
7017
|
+
if (item.remoteHash) parts.push('R ' + String(item.remoteHash).slice(0, 8));
|
|
7018
|
+
if (item.localMtime) parts.push(t('syncLocalTime', { when: when(item.localMtime) }));
|
|
7019
|
+
if (item.remoteMtime) parts.push(t('syncRemoteTime', { when: when(item.remoteMtime) }));
|
|
7020
|
+
return parts.join(' · ');
|
|
7021
|
+
};
|
|
6945
7022
|
var rows = []
|
|
6946
|
-
.concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item }; }))
|
|
6947
|
-
.concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item }; }))
|
|
6948
|
-
.concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item }; }))
|
|
6949
|
-
.concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item }; }));
|
|
7023
|
+
.concat((plan.added || []).map(function (item) { return { tag: t('syncAdded'), item: item, kind: 'added' }; }))
|
|
7024
|
+
.concat((plan.changed || []).map(function (item) { return { tag: t('syncChanged'), item: item, kind: 'changed' }; }))
|
|
7025
|
+
.concat((plan.conflict || []).map(function (item) { return { tag: t('syncConflict'), item: item, kind: 'conflict' }; }))
|
|
7026
|
+
.concat((plan.removed || []).map(function (item) { return { tag: t('syncRemoved'), item: item, kind: 'removed' }; }));
|
|
7027
|
+
if (conflictOnly) rows = rows.filter(function (row) { return row.kind === 'conflict'; });
|
|
6950
7028
|
var busy = Boolean(props.busy);
|
|
6951
7029
|
return h(DialogShell, { title: t('syncTitle'), onClose: busy ? function () {} : props.onClose },
|
|
6952
7030
|
h('div', { className: 'rw-dialog-message' },
|
|
@@ -6956,14 +7034,43 @@ function rememberShowHidden(value) {
|
|
|
6956
7034
|
conflict: (plan.conflict || []).length,
|
|
6957
7035
|
removed: (plan.removed || []).length,
|
|
6958
7036
|
})),
|
|
6959
|
-
|
|
7037
|
+
h('div', { className: 'rw-sync-toolbar' },
|
|
7038
|
+
h('label', { className: 'rw-sync-toggle' },
|
|
7039
|
+
h('input', {
|
|
7040
|
+
type: 'checkbox',
|
|
7041
|
+
checked: conflictOnly,
|
|
7042
|
+
onChange: function (event) { setConflictOnly(event.currentTarget.checked); },
|
|
7043
|
+
}),
|
|
7044
|
+
h('span', null, t('syncOnlyConflict'))),
|
|
7045
|
+
h('label', { className: 'rw-sync-toggle' },
|
|
7046
|
+
h('span', null, t('syncMaxFiles')),
|
|
7047
|
+
h('select', {
|
|
7048
|
+
className: 'rw-input rw-sync-max',
|
|
7049
|
+
value: String(props.maxFiles || 2000),
|
|
7050
|
+
disabled: busy,
|
|
7051
|
+
onChange: function (event) { props.onReload(Number(event.currentTarget.value)); },
|
|
7052
|
+
}, [500, 2000, 5000].map(function (value) {
|
|
7053
|
+
return h('option', { key: value, value: String(value) }, String(value));
|
|
7054
|
+
})))),
|
|
7055
|
+
plan.truncated
|
|
7056
|
+
? h('div', { className: 'rw-dialog-message rw-warn-text' }, t('syncTruncated', { max: plan.maxFiles }) + ' ' + t('syncTruncatedHint'))
|
|
7057
|
+
: null,
|
|
6960
7058
|
plan.skipped ? h('div', { className: 'rw-dialog-message' }, t('syncSkipped', { count: plan.skipped })) : null,
|
|
6961
7059
|
rows.length === 0
|
|
6962
7060
|
? h('div', { className: 'rw-dialog-message' }, t('syncNothing'))
|
|
6963
7061
|
: h('div', { className: 'rw-sync-list' }, rows.slice(0, 40).map(function (row) {
|
|
6964
7062
|
return h('div', { key: row.tag + row.item.relative, className: 'rw-sync-row' },
|
|
6965
7063
|
h('span', { className: 'rw-sync-tag' }, row.tag),
|
|
6966
|
-
h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative)
|
|
7064
|
+
h('span', { className: 'rw-sync-path', title: row.item.relative }, row.item.relative),
|
|
7065
|
+
row.kind === 'removed'
|
|
7066
|
+
? h('button', {
|
|
7067
|
+
type: 'button',
|
|
7068
|
+
className: 'rw-btn rw-btn-sm rw-sync-delete',
|
|
7069
|
+
disabled: busy,
|
|
7070
|
+
title: t('syncDeleteRemote'),
|
|
7071
|
+
onClick: function () { props.onDeleteRemote(row.item.relative); },
|
|
7072
|
+
}, t('syncDeleteRemote'))
|
|
7073
|
+
: h('span', { className: 'rw-sync-detail', title: detailOf(row.item) }, detailOf(row.item)));
|
|
6967
7074
|
})),
|
|
6968
7075
|
rows.length > 40 ? h('div', { className: 'rw-dialog-message' }, t('syncMore', { count: rows.length - 40 })) : null,
|
|
6969
7076
|
props.message ? h('div', { className: 'rw-dialog-message' }, props.message) : null,
|
|
@@ -6983,6 +7090,30 @@ function rememberShowHidden(value) {
|
|
|
6983
7090
|
}, t('syncPushOverwrite'))));
|
|
6984
7091
|
}
|
|
6985
7092
|
|
|
7093
|
+
function TransferHistoryDialog(props) {
|
|
7094
|
+
var t = props.t;
|
|
7095
|
+
var entries = props.entries || [];
|
|
7096
|
+
var when = function (value) {
|
|
7097
|
+
var date = new Date(value || 0);
|
|
7098
|
+
return Number.isNaN(date.getTime()) ? '' : date.toLocaleString();
|
|
7099
|
+
};
|
|
7100
|
+
return h(DialogShell, { title: t('historyTitle'), onClose: props.onClose },
|
|
7101
|
+
entries.length === 0
|
|
7102
|
+
? h('div', { className: 'rw-dialog-message' }, t('historyEmpty'))
|
|
7103
|
+
: h('div', { className: 'rw-sync-list' }, entries.slice(0, 50).map(function (entry, index) {
|
|
7104
|
+
var direction = entry.kind === 'push'
|
|
7105
|
+
? t('historyPush')
|
|
7106
|
+
: entry.direction === 'remote-to-mirror' ? t('historyToMirror') : t('historyToRemote');
|
|
7107
|
+
return h('div', { key: String(entry.at || '') + index, className: 'rw-sync-row' },
|
|
7108
|
+
h('span', { className: 'rw-sync-tag' }, direction),
|
|
7109
|
+
h('span', { className: 'rw-sync-path', title: entry.remotePath || '' }, when(entry.at)),
|
|
7110
|
+
h('span', { className: 'rw-sync-detail' },
|
|
7111
|
+
t('historyDetail', { files: entry.files || 0, size: formatBytes(entry.bytes || 0) })));
|
|
7112
|
+
})),
|
|
7113
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
7114
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('close'))));
|
|
7115
|
+
}
|
|
7116
|
+
|
|
6986
7117
|
function QueueDialog(props) {
|
|
6987
7118
|
var history = props.history && props.history.length > 0 ? props.history : null;
|
|
6988
7119
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
@@ -7445,6 +7576,9 @@ function rememberShowHidden(value) {
|
|
|
7445
7576
|
var searchStats = searchStatsState[0];
|
|
7446
7577
|
var setSearchStats = searchStatsState[1];
|
|
7447
7578
|
var searchJobRef = useRef('');
|
|
7579
|
+
// Relatives the user deleted from the remote side: the push baseline
|
|
7580
|
+
// still remembers them, so the plan would keep offering them.
|
|
7581
|
+
var removedRemotely = useRef(new Set());
|
|
7448
7582
|
var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7449
7583
|
var search = searchState[0];
|
|
7450
7584
|
var setSearch = searchState[1];
|
|
@@ -7614,6 +7748,38 @@ function rememberShowHidden(value) {
|
|
|
7614
7748
|
return function () { alive = false; };
|
|
7615
7749
|
}, [diskHostId, diskPath]);
|
|
7616
7750
|
|
|
7751
|
+
// autoPush is host-side and silent, so surface it here: the switch state
|
|
7752
|
+
// plus the newest push from the transfer history.
|
|
7753
|
+
var autoPushState = useState(null);
|
|
7754
|
+
var autoPush = autoPushState[0];
|
|
7755
|
+
var setAutoPush = autoPushState[1];
|
|
7756
|
+
useEffect(function () {
|
|
7757
|
+
var alive = true;
|
|
7758
|
+
function load() {
|
|
7759
|
+
Promise.all([
|
|
7760
|
+
apiCall('settings.get', {}),
|
|
7761
|
+
apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }),
|
|
7762
|
+
]).then(function (results) {
|
|
7763
|
+
if (!alive) return;
|
|
7764
|
+
var settings = results[0] || {};
|
|
7765
|
+
var entries = (results[1] && results[1].entries) || [];
|
|
7766
|
+
var lastPush = null;
|
|
7767
|
+
for (var index = 0; index < entries.length; index += 1) {
|
|
7768
|
+
if (entries[index] && entries[index].kind === 'push') { lastPush = entries[index]; break; }
|
|
7769
|
+
}
|
|
7770
|
+
setAutoPush({
|
|
7771
|
+
enabled: settings.autoPushEnabled === true,
|
|
7772
|
+
debounceMs: settings.autoPushDebounceMs || 1500,
|
|
7773
|
+
lastPushAt: lastPush ? lastPush.at : null,
|
|
7774
|
+
});
|
|
7775
|
+
}).catch(function () { if (alive) setAutoPush(null); });
|
|
7776
|
+
}
|
|
7777
|
+
load();
|
|
7778
|
+
var timer = setInterval(load, 15000);
|
|
7779
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
7780
|
+
return function () { alive = false; clearInterval(timer); };
|
|
7781
|
+
}, [selected && selected.key]);
|
|
7782
|
+
|
|
7617
7783
|
var openFilesState = useState([]);
|
|
7618
7784
|
var openFiles = openFilesState[0];
|
|
7619
7785
|
var setOpenFiles = openFilesState[1];
|
|
@@ -7997,6 +8163,14 @@ function rememberShowHidden(value) {
|
|
|
7997
8163
|
}
|
|
7998
8164
|
|
|
7999
8165
|
/** Copy the `@relative/path` form the model understands for a workspace path. */
|
|
8166
|
+
/** Turn an absolute remote path into a workspace-relative one (for linked.plan). */
|
|
8167
|
+
function relativeToRemote(filePath) {
|
|
8168
|
+
var root = (selected && selected.remotePath) || '';
|
|
8169
|
+
var relative = String(filePath || '');
|
|
8170
|
+
if (root && relative.indexOf(root) === 0) relative = relative.slice(root.length);
|
|
8171
|
+
return relative.replace(/^\/+/, '');
|
|
8172
|
+
}
|
|
8173
|
+
|
|
8000
8174
|
function copyReference(filePath) {
|
|
8001
8175
|
var scope = sourceScopeOf(selected);
|
|
8002
8176
|
var root = selected && selected.kind === 'remote' ? selected.remotePath : (selected && selected.remotePath) || '';
|
|
@@ -8151,26 +8325,101 @@ function rememberShowHidden(value) {
|
|
|
8151
8325
|
});
|
|
8152
8326
|
}
|
|
8153
8327
|
|
|
8154
|
-
/**
|
|
8155
|
-
|
|
8328
|
+
/**
|
|
8329
|
+
* Open the diff preview. `paths` narrows both the preview and the push to
|
|
8330
|
+
* a file or a folder (the server matches a folder as a prefix, so what the
|
|
8331
|
+
* dialog shows is exactly what gets pushed).
|
|
8332
|
+
*/
|
|
8333
|
+
function openSyncPlan(paths, maxFiles) {
|
|
8156
8334
|
var scope = sourceScopeOf(selected);
|
|
8157
8335
|
if (!scope || scope.kind !== 'linked') return;
|
|
8158
|
-
|
|
8336
|
+
var limit = maxFiles || 2000;
|
|
8337
|
+
apiCall('linked.plan', { id: scope.id, maxFiles: limit }).then(function (plan) {
|
|
8338
|
+
var narrowed = restrictPlan(plan, paths, removedRemotely.current);
|
|
8159
8339
|
setDialog({
|
|
8160
8340
|
kind: 'syncPlan',
|
|
8161
|
-
plan:
|
|
8341
|
+
plan: narrowed,
|
|
8162
8342
|
paths: Array.isArray(paths) && paths.length > 0 ? paths : null,
|
|
8343
|
+
maxFiles: limit,
|
|
8163
8344
|
busy: false,
|
|
8164
8345
|
message: '',
|
|
8165
8346
|
});
|
|
8166
8347
|
}).catch(noticeError);
|
|
8167
8348
|
}
|
|
8168
8349
|
|
|
8350
|
+
/**
|
|
8351
|
+
* Keep only the plan rows that live inside `paths` (files or folders).
|
|
8352
|
+
* Rows the user deleted from the remote side are dropped too: the push
|
|
8353
|
+
* baseline still lists them, so re-planning would show them again.
|
|
8354
|
+
*/
|
|
8355
|
+
function restrictPlan(plan, paths, deleted) {
|
|
8356
|
+
var prefixes = Array.isArray(paths) && paths.length > 0
|
|
8357
|
+
? paths.map(function (item) { return String(item).replace(/^\/+/, '').replace(/\/+$/, ''); })
|
|
8358
|
+
: null;
|
|
8359
|
+
var gone = new Set(Array.isArray(deleted) ? deleted : []);
|
|
8360
|
+
var keep = function (item) {
|
|
8361
|
+
if (gone.has(item.relative)) return false;
|
|
8362
|
+
if (!prefixes) return true;
|
|
8363
|
+
return prefixes.some(function (prefix) {
|
|
8364
|
+
return item.relative === prefix || item.relative.indexOf(prefix + '/') === 0;
|
|
8365
|
+
});
|
|
8366
|
+
};
|
|
8367
|
+
var added = (plan.added || []).filter(keep);
|
|
8368
|
+
var changed = (plan.changed || []).filter(keep);
|
|
8369
|
+
return Object.assign({}, plan, {
|
|
8370
|
+
added: added,
|
|
8371
|
+
changed: changed,
|
|
8372
|
+
conflict: (plan.conflict || []).filter(keep),
|
|
8373
|
+
removed: (plan.removed || []).filter(keep),
|
|
8374
|
+
pending: added.length + changed.length,
|
|
8375
|
+
});
|
|
8376
|
+
}
|
|
8377
|
+
|
|
8378
|
+
/** Delete the local-only leftovers from the remote side (the `removed` rows). */
|
|
8379
|
+
function deleteRemoteEntries(dialog, relatives) {
|
|
8380
|
+
var scope = sourceScopeOf(selected);
|
|
8381
|
+
var root = String((selected && selected.remotePath) || '').replace(/\/+$/, '');
|
|
8382
|
+
if (!scope || scope.kind !== 'linked' || root === '') return;
|
|
8383
|
+
var target = relatives.map(function (relative) {
|
|
8384
|
+
return root + '/' + String(relative).replace(/^\/+/, '');
|
|
8385
|
+
});
|
|
8386
|
+
Promise.all(target.map(function (filePath) {
|
|
8387
|
+
return apiCall('fs.delete', Object.assign({ path: filePath }, scopeParams(scope))).catch(function (error) {
|
|
8388
|
+
// Already gone on the remote side counts as done: the baseline can
|
|
8389
|
+
// list files that were removed outside the plugin.
|
|
8390
|
+
if (error && (error.code === 'FS_NOT_FOUND' || /ENOENT|No such file/i.test(String(error.message || '')))) {
|
|
8391
|
+
return { missing: true };
|
|
8392
|
+
}
|
|
8393
|
+
return { error: error };
|
|
8394
|
+
});
|
|
8395
|
+
})).then(function (results) {
|
|
8396
|
+
var failed = results.filter(function (item) { return item && item.error; }).length;
|
|
8397
|
+
var done = target.length - failed;
|
|
8398
|
+
if (failed === 0) {
|
|
8399
|
+
relatives.forEach(function (relative) { removedRemotely.current.add(relative); });
|
|
8400
|
+
}
|
|
8401
|
+
showNotice(failed === 0 ? 'success' : 'warn',
|
|
8402
|
+
failed === 0 ? t('syncDeleteRemoteDone', { count: done }) : t('syncDeleteRemoteFailed', { count: failed }));
|
|
8403
|
+
refreshTree();
|
|
8404
|
+
openSyncPlan(dialog.paths, dialog.maxFiles);
|
|
8405
|
+
});
|
|
8406
|
+
}
|
|
8407
|
+
|
|
8408
|
+
/** Show the recent transfer / push history the host keeps on disk. */
|
|
8409
|
+
function openHistory() {
|
|
8410
|
+
apiCall('transfer.history', {}).then(function (result) {
|
|
8411
|
+
setDialog({ kind: 'history', entries: (result && result.entries) || [] });
|
|
8412
|
+
}).catch(noticeError);
|
|
8413
|
+
}
|
|
8414
|
+
|
|
8169
8415
|
/** Push the planned files back to the remote directory. */
|
|
8170
|
-
function pushPlan(plan, conflict, paths) {
|
|
8416
|
+
function pushPlan(plan, conflict, paths, maxFiles) {
|
|
8171
8417
|
var scope = sourceScopeOf(selected);
|
|
8172
8418
|
if (!scope || scope.kind !== 'linked') return;
|
|
8173
|
-
setDialog({
|
|
8419
|
+
setDialog({
|
|
8420
|
+
kind: 'syncPlan', plan: plan, paths: paths || null, maxFiles: maxFiles || 2000,
|
|
8421
|
+
busy: true, message: t('syncPushing'),
|
|
8422
|
+
});
|
|
8174
8423
|
var jobId = 'push-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
8175
8424
|
var params = { id: scope.id, conflict: conflict, jobId: jobId };
|
|
8176
8425
|
if (Array.isArray(paths) && paths.length > 0) params.paths = paths;
|
|
@@ -8181,7 +8430,10 @@ function rememberShowHidden(value) {
|
|
|
8181
8430
|
showNotice(result.pushed > 0 ? 'success' : 'warn', text);
|
|
8182
8431
|
refreshTree();
|
|
8183
8432
|
}).catch(function (error) {
|
|
8184
|
-
setDialog({
|
|
8433
|
+
setDialog({
|
|
8434
|
+
kind: 'syncPlan', plan: plan, paths: paths || null, maxFiles: maxFiles || 2000,
|
|
8435
|
+
busy: false, message: messageOf(error, t, locale),
|
|
8436
|
+
});
|
|
8185
8437
|
});
|
|
8186
8438
|
}
|
|
8187
8439
|
|
|
@@ -8587,6 +8839,12 @@ function rememberShowHidden(value) {
|
|
|
8587
8839
|
items.push({ label: t('ctxRenameSelected', { count: batch.length }), onSelect: function () {
|
|
8588
8840
|
setDialog({ kind: 'renameMany', side: menu.side, entries: batch });
|
|
8589
8841
|
} });
|
|
8842
|
+
if (hasLocal && isRemote) {
|
|
8843
|
+
// Push several entries at once; folders are matched as prefixes.
|
|
8844
|
+
items.push({ label: t('ctxPushSelected', { count: batch.length }), onSelect: function () {
|
|
8845
|
+
openSyncPlan(batch.map(function (item) { return relativeToRemote(item.path); }));
|
|
8846
|
+
} });
|
|
8847
|
+
}
|
|
8590
8848
|
}
|
|
8591
8849
|
items.push({ separator: true });
|
|
8592
8850
|
}
|
|
@@ -8778,10 +9036,20 @@ function rememberShowHidden(value) {
|
|
|
8778
9036
|
return h(SyncPlanDialog, {
|
|
8779
9037
|
t: t,
|
|
8780
9038
|
plan: dialog.plan,
|
|
9039
|
+
maxFiles: dialog.maxFiles || 2000,
|
|
8781
9040
|
busy: Boolean(dialog.busy),
|
|
8782
9041
|
message: dialog.message,
|
|
8783
9042
|
onClose: function () { if (!dialog.busy) setDialog(null); },
|
|
8784
9043
|
onPush: function (conflict) { return pushPlan(dialog.plan, conflict, dialog.paths); },
|
|
9044
|
+
onReload: function (nextMax) { openSyncPlan(dialog.paths, nextMax); },
|
|
9045
|
+
onDeleteRemote: function (relative) { deleteRemoteEntries(dialog, [relative]); },
|
|
9046
|
+
});
|
|
9047
|
+
}
|
|
9048
|
+
if (dialog.kind === 'history') {
|
|
9049
|
+
return h(TransferHistoryDialog, {
|
|
9050
|
+
t: t,
|
|
9051
|
+
entries: dialog.entries,
|
|
9052
|
+
onClose: function () { setDialog(null); },
|
|
8785
9053
|
});
|
|
8786
9054
|
}
|
|
8787
9055
|
if (dialog.kind === 'renameMany') {
|
|
@@ -9116,6 +9384,8 @@ function rememberShowHidden(value) {
|
|
|
9116
9384
|
syncEnabled: selected.kind === 'linked',
|
|
9117
9385
|
syncTitle: selected.kind === 'linked' ? t('syncTitle') : t('syncNeedsLinked'),
|
|
9118
9386
|
onSync: function () { openSyncPlan(null); },
|
|
9387
|
+
historyTitle: t('historyTitle'),
|
|
9388
|
+
onHistory: openHistory,
|
|
9119
9389
|
}),
|
|
9120
9390
|
searchOpen
|
|
9121
9391
|
? h('div', { className: 'rw-searchbar' },
|
|
@@ -9283,6 +9553,15 @@ function rememberShowHidden(value) {
|
|
|
9283
9553
|
title: (disk.path ? disk.path + ' · ' : '') + t('diskFree', { free: formatBytes(disk.avail), percent: disk.percent }) + (disk.used ? ' · ' + formatBytes(disk.used) + ' / ' + formatBytes(disk.size) : ''),
|
|
9284
9554
|
}, formatBytes(disk.avail))
|
|
9285
9555
|
: null,
|
|
9556
|
+
autoPush && autoPush.enabled
|
|
9557
|
+
? h('span', {
|
|
9558
|
+
className: 'rw-autopush-chip',
|
|
9559
|
+
title: t('autoPushChipTitle', { debounce: autoPush.debounceMs }) +
|
|
9560
|
+
(autoPush.lastPushAt ? ' · ' + t('autoPushChipLast', { when: new Date(autoPush.lastPushAt).toLocaleString() }) : ''),
|
|
9561
|
+
}, t('autoPushChip'), autoPush.lastPushAt
|
|
9562
|
+
? h('span', { className: 'rw-autopush-when' }, new Date(autoPush.lastPushAt).toLocaleTimeString())
|
|
9563
|
+
: null)
|
|
9564
|
+
: null,
|
|
9286
9565
|
h('button', { type: 'button', className: 'rw-icon-btn', title: t('toggleDirectory'), onClick: function () { setDirectoryOpen(false); } }, IconClose(11))),
|
|
9287
9566
|
h('div', { className: 'rw-directory-body' }, body))
|
|
9288
9567
|
: null),
|
|
@@ -10205,6 +10484,16 @@ function rememberShowHidden(value) {
|
|
|
10205
10484
|
}
|
|
10206
10485
|
|
|
10207
10486
|
var modalRef = useRef(null);
|
|
10487
|
+
// The overlay lives in a portal (`PortalBackdrop`), so the modal element
|
|
10488
|
+
// only exists one commit after `open` flips. Keep it in state: the focus
|
|
10489
|
+
// and wheel effects below must run again once it is really mounted.
|
|
10490
|
+
var modalNodeState = useState(null);
|
|
10491
|
+
var modalNode = modalNodeState[0];
|
|
10492
|
+
var setModalNode = modalNodeState[1];
|
|
10493
|
+
var attachModal = function (node) {
|
|
10494
|
+
modalRef.current = node;
|
|
10495
|
+
if (node !== modalNode) setModalNode(node);
|
|
10496
|
+
};
|
|
10208
10497
|
var focusablesOf = function () {
|
|
10209
10498
|
var node = modalRef.current;
|
|
10210
10499
|
if (!node) return [];
|
|
@@ -10220,7 +10509,7 @@ function rememberShowHidden(value) {
|
|
|
10220
10509
|
// Focus the first real field, not the tab strip, so typing works at once.
|
|
10221
10510
|
var target = node.querySelector('.rw-modal-body input, .rw-modal-body textarea') || focusablesOf()[0];
|
|
10222
10511
|
if (target && typeof target.focus === 'function') target.focus();
|
|
10223
|
-
}, [props.open, flow]);
|
|
10512
|
+
}, [props.open, flow, modalNode]);
|
|
10224
10513
|
|
|
10225
10514
|
// The app shell listens for wheel gestures on the document root and moves
|
|
10226
10515
|
// the conversation behind the dialog, so a wheel over the host list (or
|
|
@@ -10264,7 +10553,7 @@ function rememberShowHidden(value) {
|
|
|
10264
10553
|
|
|
10265
10554
|
window.addEventListener('wheel', onWheel, { passive: false, capture: true });
|
|
10266
10555
|
return function () { window.removeEventListener('wheel', onWheel, { capture: true }); };
|
|
10267
|
-
}, [props.open]);
|
|
10556
|
+
}, [props.open, modalNode]);
|
|
10268
10557
|
|
|
10269
10558
|
// Esc has to be caught on the window: the overlay now lives in a top-layer
|
|
10270
10559
|
// <dialog>, so key events start at that element and never reach the modal
|
|
@@ -10312,7 +10601,7 @@ function rememberShowHidden(value) {
|
|
|
10312
10601
|
onEscape: function () { if (props.onCancel) props.onCancel(); },
|
|
10313
10602
|
},
|
|
10314
10603
|
h('div', {
|
|
10315
|
-
ref:
|
|
10604
|
+
ref: attachModal,
|
|
10316
10605
|
className: 'rw-modal',
|
|
10317
10606
|
role: 'dialog',
|
|
10318
10607
|
'aria-modal': 'true',
|
package/lib/index.js
CHANGED
|
@@ -2003,7 +2003,14 @@ export function apply(ctx) {
|
|
|
2003
2003
|
remoteStat = null
|
|
2004
2004
|
}
|
|
2005
2005
|
if (!remoteStat || remoteStat.type !== 'file') {
|
|
2006
|
-
buckets.added.push({
|
|
2006
|
+
buckets.added.push({
|
|
2007
|
+
relative: file.relative,
|
|
2008
|
+
size: file.size,
|
|
2009
|
+
localHash,
|
|
2010
|
+
remoteHash: null,
|
|
2011
|
+
localMtime: file.mtimeMs,
|
|
2012
|
+
remoteMtime: null,
|
|
2013
|
+
})
|
|
2007
2014
|
continue
|
|
2008
2015
|
}
|
|
2009
2016
|
const remoteHash = await readRemoteHash(remote, remotePath, remoteStat.size)
|
|
@@ -2012,7 +2019,14 @@ export function apply(ctx) {
|
|
|
2012
2019
|
continue
|
|
2013
2020
|
}
|
|
2014
2021
|
const baselineHash = known && typeof known.hash === 'string' ? known.hash : ''
|
|
2015
|
-
const entry = {
|
|
2022
|
+
const entry = {
|
|
2023
|
+
relative: file.relative,
|
|
2024
|
+
size: file.size,
|
|
2025
|
+
localHash,
|
|
2026
|
+
remoteHash,
|
|
2027
|
+
localMtime: file.mtimeMs,
|
|
2028
|
+
remoteMtime: remoteStat.mtime,
|
|
2029
|
+
}
|
|
2016
2030
|
if (baselineHash === '' || baselineHash === remoteHash) buckets.changed.push(entry)
|
|
2017
2031
|
else buckets.conflict.push(entry)
|
|
2018
2032
|
}
|
|
@@ -2047,15 +2061,21 @@ export function apply(ctx) {
|
|
|
2047
2061
|
|
|
2048
2062
|
const applyPlan = async (record, remote, plan, options = {}, job = null) => {
|
|
2049
2063
|
const mode = PUSH_FILES_CONFLICT.has(options.conflict) ? options.conflict : 'skip'
|
|
2064
|
+
// `paths` may name files or whole folders: the tree hands over whatever the
|
|
2065
|
+
// user right-clicked, so a folder has to match everything below it.
|
|
2050
2066
|
const only = Array.isArray(options.paths) && options.paths.length > 0
|
|
2051
|
-
?
|
|
2067
|
+
? options.paths.map((item) => String(item).replace(/^\/+/, '').replace(/\/+$/, '')).filter(Boolean)
|
|
2052
2068
|
: null
|
|
2069
|
+
const inScope = (relative) => {
|
|
2070
|
+
if (!only) return true
|
|
2071
|
+
return only.some((prefix) => relative === prefix || relative.startsWith(`${prefix}/`))
|
|
2072
|
+
}
|
|
2053
2073
|
const state = readPushState()
|
|
2054
2074
|
const baseline = state.byWorkspace[record.id] && typeof state.byWorkspace[record.id] === 'object'
|
|
2055
2075
|
? state.byWorkspace[record.id]
|
|
2056
2076
|
: {}
|
|
2057
|
-
const queue = [...plan.added, ...plan.changed].filter((item) =>
|
|
2058
|
-
const conflicted = plan.conflict.filter((item) =>
|
|
2077
|
+
const queue = [...plan.added, ...plan.changed].filter((item) => inScope(item.relative))
|
|
2078
|
+
const conflicted = plan.conflict.filter((item) => inScope(item.relative))
|
|
2059
2079
|
const pushed = []
|
|
2060
2080
|
let bytes = 0
|
|
2061
2081
|
let skipped = 0
|
|
@@ -2158,6 +2178,8 @@ export function apply(ctx) {
|
|
|
2158
2178
|
// workspace-relative path.
|
|
2159
2179
|
|
|
2160
2180
|
const AUTO_PUSH_RETRY_MS = 2000
|
|
2181
|
+
const AUTO_PUSH_RETRY_MAX = 60000
|
|
2182
|
+
const AUTO_PUSH_MAX_ATTEMPTS = 5
|
|
2161
2183
|
const autoPushWatchers = new Map()
|
|
2162
2184
|
|
|
2163
2185
|
const globToRegExp = (pattern) => {
|
|
@@ -2203,13 +2225,28 @@ export function apply(ctx) {
|
|
|
2203
2225
|
const host = await findHost(record.hostId)
|
|
2204
2226
|
const remote = await connectHost(host)
|
|
2205
2227
|
const plan = autoPushFilter(settings, await buildPlan(record, remote, {}))
|
|
2206
|
-
if (plan.added.length === 0 && plan.changed.length === 0)
|
|
2228
|
+
if (plan.added.length === 0 && plan.changed.length === 0) {
|
|
2229
|
+
entry.failures = 0
|
|
2230
|
+
return
|
|
2231
|
+
}
|
|
2207
2232
|
const result = await applyPlan(record, remote, plan, { conflict: 'skip' })
|
|
2233
|
+
entry.failures = 0
|
|
2208
2234
|
forgetListings()
|
|
2209
2235
|
log('info', `autoPush ${record.name}: ${result.pushed} file(s), ${result.skipped} skipped`)
|
|
2210
2236
|
} catch (error) {
|
|
2211
|
-
|
|
2212
|
-
|
|
2237
|
+
entry.failures = (entry.failures || 0) + 1
|
|
2238
|
+
const message = error && error.message ? error.message : String(error)
|
|
2239
|
+
if (entry.failures >= AUTO_PUSH_MAX_ATTEMPTS) {
|
|
2240
|
+
// An unreachable host must not retry forever: five attempts with
|
|
2241
|
+
// backoff, then wait for the next local edit to start over.
|
|
2242
|
+
entry.failures = 0
|
|
2243
|
+
log('warn', `autoPush ${record.name} gave up after ${AUTO_PUSH_MAX_ATTEMPTS} attempts: ${message}`)
|
|
2244
|
+
return
|
|
2245
|
+
}
|
|
2246
|
+
const wait = Math.min(AUTO_PUSH_RETRY_MS * 2 ** (entry.failures - 1), AUTO_PUSH_RETRY_MAX)
|
|
2247
|
+
log('warn', `autoPush ${record.name} failed (attempt ${entry.failures}/${AUTO_PUSH_MAX_ATTEMPTS}, retry in ${wait}ms): ${message}`)
|
|
2248
|
+
entry.timer = setTimeout(() => { entry.timer = null; void runAutoPush(record, entry) }, wait)
|
|
2249
|
+
if (entry.timer && typeof entry.timer.unref === 'function') entry.timer.unref()
|
|
2213
2250
|
} finally {
|
|
2214
2251
|
entry.running = false
|
|
2215
2252
|
}
|
|
@@ -4614,6 +4651,8 @@ export function apply(ctx) {
|
|
|
4614
4651
|
linkedStore.add(record)
|
|
4615
4652
|
const workspace = await ensureDshWorkspace(linkedRegistry(), localPath, linkedWorkspaceTitle(name))
|
|
4616
4653
|
pool.setStatus(host.id, { state: 'connected', latencyMs: 0 })
|
|
4654
|
+
// A new workspace has to be watched too while autoPush is on.
|
|
4655
|
+
syncAutoPush()
|
|
4617
4656
|
log('info', `linked workspace "${name}" (${localPath} ⇄ ${record.hostSnapshot.username}@${record.hostSnapshot.host}:${remoteRoot})`)
|
|
4618
4657
|
return { link: describeLink(record), workspaceId: workspace ? workspace.id : null }
|
|
4619
4658
|
},
|
|
@@ -4654,6 +4693,9 @@ export function apply(ctx) {
|
|
|
4654
4693
|
|
|
4655
4694
|
async 'linked.remove'(params = {}) {
|
|
4656
4695
|
const record = requireLinked(params.id)
|
|
4696
|
+
// Drop the watcher before the record disappears, otherwise a stale
|
|
4697
|
+
// fs.watch keeps firing for a workspace that is gone.
|
|
4698
|
+
stopAutoPush(record.id)
|
|
4657
4699
|
linkedStore.remove(record.id)
|
|
4658
4700
|
let removedWorkspace = false
|
|
4659
4701
|
if (params.removeWorkspace === true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.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",
|