dsh-linked-workspace 0.23.0 → 0.24.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,14 @@
2
2
 
3
3
  English · [简体中文](CHANGELOG.zh.md)
4
4
 
5
+ ## 0.24.0 — 2026-11-22
6
+
7
+ - Auto push moved from one global switch to **each linked workspace card**: every workspace has its own on/off switch, its own debounce (300–60000 ms) and its own include/exclude globs, so "watch this repo" no longer means "watch all of them".
8
+ - The Host keeps one `fs.watch` per enabled workspace (`linked.json` → `autoPush`), re-reads the record before every push and stops the watcher the moment the switch goes off or the workspace is removed.
9
+ - `linked.list` now reports each record's `autoPush`, and `linked.update { id, autoPush }` writes it (the debounce is clamped, globs are trimmed, de-duplicated and capped at 100). The four old global `autoPush*` settings are still accepted so an existing `settings.json` loads unchanged, but they no longer drive anything.
10
+ - The first time you turn it on for a workspace, an inline confirmation still explains that files will be written behind your back; cancelling leaves the switch off.
11
+ - The "allowed workspaces (second layer)" list in the remote-exec settings now starts **collapsed**, with a button that shows how many are ticked and expands the list only when you ask for it.
12
+
5
13
  ## 0.23.0 — 2026-11-21
6
14
 
7
15
  - Models can read the **text of PDF / Word / Excel / PowerPoint** files: new `read_doc` action and `docs.text` method (PDF page by page, Word paragraphs and tables, one block per Excel sheet, PPT slides plus notes, 40k characters by default). No more installing PyPDF2 to read one paper.
package/README.en.md CHANGED
@@ -287,4 +287,4 @@ On Windows, run `test/host-api.mjs` with DSH's bundled Electron Node (system Nod
287
287
 
288
288
  MIT © 2026 Huangjh
289
289
 
290
- 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.
290
+ 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; since 0.24.0 it lives on **each linked workspace card**, so every workspace has its own switch, debounce and include/exclude globs.
package/README.md CHANGED
@@ -287,4 +287,4 @@ node test/ssh-smoke.mjs # 真实 SSH 传输自检(按需)
287
287
 
288
288
  MIT © 2026 Huangjh
289
289
 
290
- 从 0.21.0 起,差异预览会跟着你的入口收窄:右键文件夹或选中若干项再推送,预览里只有这些范围内的条目,每行还带大小、两边时间与 hash 前 8 位,可以勾「只看冲突」;「远端已删」的行能直接删掉远端残留。工具栏的时钟按钮打开「传输与推送历史」,目录栏的「自动推送」chip 显示最近一次推送时间——自动推送现在跟随工作区增删,失败会退避重试最多 5 次。
290
+ 从 0.21.0 起,差异预览会跟着你的入口收窄:右键文件夹或选中若干项再推送,预览里只有这些范围内的条目,每行还带大小、两边时间与 hash 前 8 位,可以勾「只看冲突」;「远端已删」的行能直接删掉远端残留。工具栏的时钟按钮打开「传输与推送历史」,目录栏的「自动推送」chip 显示最近一次推送时间——自动推送现在跟随工作区增删,失败会退避重试最多 5 次;从 0.24.0 起它下沉到**每个联动工作区卡片**上,各工作区可以单独开关,并各自配置 debounce 与「包含/排除」glob。
package/docs/API.md CHANGED
@@ -147,7 +147,8 @@ Under `$DSH_HOME/linked-workspace/`:
147
147
 
148
148
  - `linked.json` — linked workspaces (no credentials).
149
149
  - `remote-workspaces.json` — remote workspaces (no credentials).
150
- - `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave, execEnabled, execHostIds, execWorkspaceIds, execTimeoutMs, execMaxOutputChars, execShell, autoPushEnabled, autoPushDebounceMs, autoPushInclude, autoPushExclude, hostKeyPolicy, outputEncoding }`.
150
+ - `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave, execEnabled, execHostIds, execWorkspaceIds, execTimeoutMs, execMaxOutputChars, execShell, hostKeyPolicy, outputEncoding, extraRoots }`. The four `autoPush*` keys are still accepted so an old file loads unchanged, but since 0.24.0 auto push is configured per workspace (`linked.json` → each record's `autoPush`), and those keys no longer drive any watcher.
151
+ - `linked.json` — every record carries `autoPush: { enabled, debounceMs, include[], exclude[] }` (`debounceMs` clamped to 300–60000, default 1500). `linked.list` returns it, `linked.update { id, autoPush }` writes it, and the Host starts/stops one `fs.watch` per enabled workspace.
151
152
  The exec keys are off unless you turn them on: `execEnabled` defaults to
152
153
  `false`, `execHostIds` (host allow-list) starts empty, and
153
154
  `execWorkspaceIds` is an optional second layer where an empty list means
package/docs/VERIFY.md CHANGED
@@ -15,7 +15,8 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
15
15
  2. 点「推送(跳过冲突)」后提示「已推送 N 个文件」,远端目录刷新后能看到新内容(`ssh … cat` 核对)。
16
16
  3. 在**远端**改同一个文件、本地再改一次,重新打开差异预览:该文件出现在「冲突」里;点「推送(跳过冲突)」后远端内容保持不变,提示里带「1 个冲突未处理」;点「推送并覆盖冲突」才会用本地版本覆盖。
17
17
  4. 在行菜单上对某个远端文件点「把这个推送到远端」:差异预览只包含该文件。
18
- 5. 设置 → 联动工作区 → 「自动推回远端」:打开开关会先出现黄色说明与「我明白,开启自动推送」,未确认前不会开启;确认后本地保存文件约 1.5 秒后自动出现在远端,同一文件远端也改过时保留远端版本。
18
+ 5. 设置 → 联动工作区 → 某个联动工作区卡片上的「自动推回远端」:打开开关会先出现黄色说明与「我明白,开启自动推送」,未确认前不会开启;确认后下方出现 debounce 与「包含/排除」两个输入框(按行写 glob,如 `src/**`)。保存文件约 1.5 秒后自动出现在远端,同一文件远端也改过时保留远端版本。
19
+ > 0.24.0 起这个开关属于**每个工作区自己**:卡片 A 开着、卡片 B 关着互不影响,各自的 debounce 与 glob 也独立生效;两个工作区都开着时,只会有匹配 glob 的文件被推送。
19
20
  6. 断网或 SSH 断开时推送会失败并显示原因,本地文件不受影响。
20
21
 
21
22
  ## @ 引用与搜索增强(0.18.0)
package/lib/client.js CHANGED
@@ -2540,6 +2540,10 @@ function attributeViolation(name, value, tagName) {
2540
2540
  autoPushChip: '自动推送',
2541
2541
  autoPushChipTitle: '已开启:本地静止 {{debounce}} ms 后推送',
2542
2542
  autoPushChipLast: '最近一次 {{when}}',
2543
+ autoPushOn: '已开启:本工作区的本地改动会自动推回远端',
2544
+ autoPushOff: '已关闭:本工作区的改动不会自动推回远端',
2545
+ execWorkspacesShow: '展开(已选 {{count}} 个)',
2546
+ execWorkspacesHide: '收起',
2543
2547
  reconnect: '重新连接',
2544
2548
  reconnecting: '正在连接…',
2545
2549
  reconnectOk: '已重新连接',
@@ -2728,7 +2732,6 @@ function attributeViolation(name, value, tagName) {
2728
2732
  welcomeReplay: 'Show the welcome card again',
2729
2733
  intro: 'Turn an SSH connection into a workspace: a linked workspace pairs a local folder with a remote folder, and a remote workspace runs sessions directly inside the remote folder. Either way sessions can read, search and edit remote files.',
2730
2734
  addWorkspace: 'Add workspace',
2731
- addRemoteDir: 'Add remote directory',
2732
2735
  addLinked: 'Add linked workspace',
2733
2736
  createLinked: 'Create linked workspace',
2734
2737
  addShort: 'Add',
@@ -3114,6 +3117,10 @@ function attributeViolation(name, value, tagName) {
3114
3117
  autoPushChip: 'auto push',
3115
3118
  autoPushChipTitle: 'on · pushes after {{debounce}} ms of local quiet',
3116
3119
  autoPushChipLast: 'last {{when}}',
3120
+ autoPushOn: 'on: local edits in this workspace are pushed automatically',
3121
+ autoPushOff: 'off: local edits in this workspace stay local',
3122
+ execWorkspacesShow: 'Show ({{count}} ticked)',
3123
+ execWorkspacesHide: 'Hide',
3117
3124
  reconnect: 'Reconnect',
3118
3125
  reconnecting: 'Connecting…',
3119
3126
  reconnectOk: 'Reconnected',
@@ -3359,7 +3366,7 @@ function attributeViolation(name, value, tagName) {
3359
3366
  * Host methods the running DSH process does not have yet, the directory
3360
3367
  * pane says so instead of surfacing an unrelated error.
3361
3368
  */
3362
- var HOST_API_REVISION = 8;
3369
+ var HOST_API_REVISION = 9;
3363
3370
  var hostInfoProbe = null;
3364
3371
 
3365
3372
  function probeHostInfo() {
@@ -3850,6 +3857,8 @@ function attributeViolation(name, value, tagName) {
3850
3857
  '.rw-sync-tag{flex:none;min-width:52px;color:rgb(150,150,152)}',
3851
3858
  '.rw-sync-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-mono,monospace)}',
3852
3859
  '.rw-autopush-list{width:100%;resize:vertical;font-family:var(--dsw-font-mono,monospace);font-size:12px}',
3860
+ '.rw-autopush-card{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-separator,rgba(127,127,127,0.18))}',
3861
+ '.rw-autopush-row{display:flex;align-items:center;gap:8px;margin-top:8px}',
3853
3862
  '.rw-known-keys{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
3854
3863
  '.rw-known-key{display:flex;align-items:center;gap:10px}',
3855
3864
  '.rw-known-key-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}',
@@ -7742,6 +7751,7 @@ function rememberShowHidden(value) {
7742
7751
  username: item.username,
7743
7752
  hostName: item.hostName,
7744
7753
  mirror: item.mirror,
7754
+ autoPush: item.autoPush,
7745
7755
  status: item.status,
7746
7756
  };
7747
7757
  }
@@ -7786,28 +7796,25 @@ function rememberShowHidden(value) {
7786
7796
  return function () { alive = false; };
7787
7797
  }, [diskHostId, diskPath]);
7788
7798
 
7789
- // autoPush is host-side and silent, so surface it here: the switch state
7790
- // plus the newest push from the transfer history.
7799
+ // autoPush is host-side and silent, so surface it here: the per-workspace
7800
+ // switch state (0.24.0) plus the newest push from the transfer history.
7791
7801
  var autoPushState = useState(null);
7792
7802
  var autoPush = autoPushState[0];
7793
7803
  var setAutoPush = autoPushState[1];
7794
7804
  useEffect(function () {
7795
7805
  var alive = true;
7796
7806
  function load() {
7797
- Promise.all([
7798
- apiCall('settings.get', {}),
7799
- apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }),
7800
- ]).then(function (results) {
7807
+ apiCall('transfer.history', {}).catch(function () { return { entries: [] }; }).then(function (result) {
7801
7808
  if (!alive) return;
7802
- var settings = results[0] || {};
7803
- var entries = (results[1] && results[1].entries) || [];
7809
+ var entries = (result && result.entries) || [];
7804
7810
  var lastPush = null;
7805
7811
  for (var index = 0; index < entries.length; index += 1) {
7806
7812
  if (entries[index] && entries[index].kind === 'push') { lastPush = entries[index]; break; }
7807
7813
  }
7814
+ var config = (selected && selected.autoPush) || null;
7808
7815
  setAutoPush({
7809
- enabled: settings.autoPushEnabled === true,
7810
- debounceMs: settings.autoPushDebounceMs || 1500,
7816
+ enabled: Boolean(config && config.enabled === true),
7817
+ debounceMs: (config && config.debounceMs) || 1500,
7811
7818
  lastPushAt: lastPush ? lastPush.at : null,
7812
7819
  });
7813
7820
  }).catch(function () { if (alive) setAutoPush(null); });
@@ -7816,7 +7823,7 @@ function rememberShowHidden(value) {
7816
7823
  var timer = setInterval(load, 15000);
7817
7824
  if (timer && typeof timer.unref === 'function') timer.unref();
7818
7825
  return function () { alive = false; clearInterval(timer); };
7819
- }, [selected && selected.key]);
7826
+ }, [selected && selected.key, selected && selected.autoPush]);
7820
7827
 
7821
7828
  var openFilesState = useState([]);
7822
7829
  var openFiles = openFilesState[0];
@@ -10917,6 +10924,7 @@ function rememberShowHidden(value) {
10917
10924
  text: t('mirrorLabel'),
10918
10925
  })),
10919
10926
  h('div', { className: 'rw-hint' }, t('mirrorHint')),
10927
+ h(AutoPushCardSection, { t: t, locale: locale, link: link, refresh: refresh }),
10920
10928
  local.removing
10921
10929
  ? h('div', { className: 'rw-warn-box' },
10922
10930
  h('div', null, t('removeWorkspaceHint')),
@@ -11272,6 +11280,10 @@ function rememberShowHidden(value) {
11272
11280
  });
11273
11281
  var local = state[0];
11274
11282
  var setLocal = state[1];
11283
+ // The second-layer list is long and rarely touched: start collapsed.
11284
+ var workspaceListState = useState(false);
11285
+ var workspacesOpen = workspaceListState[0];
11286
+ var setWorkspacesOpen = workspaceListState[1];
11275
11287
 
11276
11288
  var adopt = function (settings, extra) {
11277
11289
  var value = settings || {};
@@ -11397,25 +11409,39 @@ function rememberShowHidden(value) {
11397
11409
  h('span', { className: 'rw-exec-name' }, host.name || host.host || host.id),
11398
11410
  h('span', { className: 'rw-exec-meta' }, (host.username ? host.username + '@' : '') + (host.host || '') + (host.port ? ':' + host.port : '')));
11399
11411
  })));
11412
+ var picked = local.execWorkspaceIds;
11400
11413
  children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11401
11414
  h('span', { className: 'rw-group-title' }, t('execWorkspacesTitle')),
11402
- h('span', { className: 'rw-group-hint' }, t('execWorkspacesHint'))));
11403
- children.push(workspaces.length === 0
11404
- ? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
11405
- : h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
11406
- var checked = local.execWorkspaceIds.indexOf(item.id) >= 0;
11407
- return h('label', { key: item.id, className: 'rw-exec-item' },
11408
- h('input', {
11409
- type: 'checkbox',
11410
- checked: checked,
11411
- onChange: function (event) {
11412
- var on = event.currentTarget.checked;
11413
- save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
11414
- },
11415
- }),
11416
- h('span', { className: 'rw-exec-name' }, item.name || item.id),
11417
- h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
11418
- })));
11415
+ h('button', {
11416
+ type: 'button',
11417
+ className: 'rw-btn rw-btn-ghost rw-btn-sm',
11418
+ onClick: function () { setWorkspacesOpen(function (open) { return !open; }); },
11419
+ }, t(workspacesOpen ? 'execWorkspacesHide' : 'execWorkspacesShow', { count: String(picked.length) }))));
11420
+ if (workspacesOpen) {
11421
+ children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 4 } }, t('execWorkspacesHint')));
11422
+ children.push(workspaces.length === 0
11423
+ ? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
11424
+ : h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
11425
+ var checked = picked.indexOf(item.id) >= 0;
11426
+ return h('label', { key: item.id, className: 'rw-exec-item' },
11427
+ h('input', {
11428
+ type: 'checkbox',
11429
+ checked: checked,
11430
+ onChange: function (event) {
11431
+ var on = event.currentTarget.checked;
11432
+ save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
11433
+ },
11434
+ }),
11435
+ h('span', { className: 'rw-exec-name' }, item.name || item.id),
11436
+ h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
11437
+ })));
11438
+ } else if (picked.length > 0) {
11439
+ // Collapsed but not empty: spell out what is allowed, one line.
11440
+ var names = workspaces.filter(function (item) { return picked.indexOf(item.id) >= 0; })
11441
+ .map(function (item) { return item.name || item.id; });
11442
+ children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 4 } },
11443
+ names.length > 0 ? names.join('、') : String(picked.length)));
11444
+ }
11419
11445
  children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
11420
11446
  numberRow(t('execTimeoutLabel'), local.execTimeoutSec, 1, 600, 1, {
11421
11447
  field: 'execTimeoutSec',
@@ -11448,161 +11474,139 @@ function rememberShowHidden(value) {
11448
11474
  return h('div', { className: 'rw-group' }, children);
11449
11475
  }
11450
11476
 
11451
- function AutoPushSettingsGroup(props) {
11477
+ /**
11478
+ * Auto push lives on the workspace card (0.24.0): every linked workspace has
11479
+ * its own switch, debounce and include/exclude globs, so "watch this repo"
11480
+ * never implies "watch all of them".
11481
+ */
11482
+ function AutoPushCardSection(props) {
11452
11483
  var t = props.t;
11453
11484
  var locale = props.locale;
11454
- var localState = useState({ loading: true, saving: false, message: null, asking: false });
11455
- var local = localState[0];
11456
- var setLocal = localState[1];
11457
- var valuesState = useState({
11458
- autoPushEnabled: false,
11459
- autoPushDebounceMs: 1500,
11460
- autoPushInclude: '',
11461
- autoPushExclude: '',
11485
+ var link = props.link;
11486
+ var config = link.autoPush || { enabled: false, debounceMs: 1500, include: [], exclude: [] };
11487
+ var statePack = useState({
11488
+ saving: false,
11489
+ asking: false,
11490
+ message: null,
11491
+ include: (config.include || []).join('\n'),
11492
+ exclude: (config.exclude || []).join('\n'),
11493
+ debounceMs: Number(config.debounceMs) || 1500,
11462
11494
  });
11463
- var values = valuesState[0];
11464
- var setValues = valuesState[1];
11495
+ var local = statePack[0];
11496
+ var setLocal = statePack[1];
11465
11497
 
11466
- useEffect(function () {
11467
- var alive = true;
11468
- apiCall('settings.get', {}).then(function (settings) {
11469
- if (!alive) return;
11470
- setValues({
11471
- autoPushEnabled: settings.autoPushEnabled === true,
11472
- autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
11473
- autoPushInclude: (settings.autoPushInclude || []).join('\n'),
11474
- autoPushExclude: (settings.autoPushExclude || []).join('\n'),
11475
- });
11476
- setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
11477
- }).catch(function () {
11478
- if (alive) setLocal(function (previous) { return Object.assign({}, previous, { loading: false }); });
11479
- });
11480
- return function () { alive = false; };
11481
- }, []);
11498
+ function patchLocal(patch) {
11499
+ setLocal(function (previous) { return Object.assign({}, previous, patch); });
11500
+ }
11501
+
11502
+ function lines(text) {
11503
+ return String(text || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
11504
+ }
11482
11505
 
11483
11506
  function save(patch, okText) {
11484
- setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
11485
- apiCall('settings.update', patch).then(function (settings) {
11486
- setValues({
11487
- autoPushEnabled: settings.autoPushEnabled === true,
11488
- autoPushDebounceMs: Number(settings.autoPushDebounceMs) || 1500,
11489
- autoPushInclude: (settings.autoPushInclude || []).join('\n'),
11490
- autoPushExclude: (settings.autoPushExclude || []).join('\n'),
11491
- });
11492
- setLocal({ loading: false, saving: false, asking: false, message: { kind: 'success', text: okText } });
11507
+ var next = {
11508
+ enabled: patch.enabled !== undefined ? patch.enabled : config.enabled === true,
11509
+ debounceMs: patch.debounceMs !== undefined ? patch.debounceMs : Math.round(Number(local.debounceMs) || 1500),
11510
+ include: patch.include !== undefined ? patch.include : lines(local.include),
11511
+ exclude: patch.exclude !== undefined ? patch.exclude : lines(local.exclude),
11512
+ };
11513
+ patchLocal({ saving: true, message: null, asking: false });
11514
+ apiCall('linked.update', { id: link.id, autoPush: next }).then(function () {
11515
+ patchLocal({ saving: false, message: { kind: 'success', text: okText } });
11516
+ if (typeof props.refresh === 'function') props.refresh();
11493
11517
  }).catch(function (error) {
11494
- setLocal({
11495
- loading: false,
11496
- saving: false,
11497
- asking: false,
11498
- message: { kind: 'error', text: messageOf(error, t, locale) },
11499
- });
11518
+ patchLocal({ saving: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
11500
11519
  });
11501
11520
  }
11502
11521
 
11503
11522
  function toggle(next) {
11504
- if (next === true && values.autoPushEnabled === false) {
11523
+ if (next === true && config.enabled !== true) {
11505
11524
  // Turning it on writes files behind the user's back: ask once, in
11506
11525
  // place, before the switch actually flips.
11507
- setLocal(function (previous) { return Object.assign({}, previous, { asking: true, message: null }); });
11526
+ patchLocal({ asking: true, message: null });
11508
11527
  return;
11509
11528
  }
11510
- save({ autoPushEnabled: Boolean(next) }, t('autoPushSaved'));
11511
- }
11512
-
11513
- function commitList(field, key) {
11514
- var lines = String(values[field] || '').split('\n').map(function (line) { return line.trim(); }).filter(function (line) { return line !== ''; });
11515
- var patch = {};
11516
- patch[key] = lines;
11517
- save(patch, t('autoPushSaved'));
11529
+ save({ enabled: Boolean(next) }, t('autoPushSaved'));
11518
11530
  }
11519
11531
 
11520
11532
  var children = [
11521
- h('div', { className: 'rw-group-head' },
11522
- h('span', { className: 'rw-group-title' }, t('autoPushTitle'))),
11523
- h('div', { className: 'rw-setting-row' },
11533
+ h('div', { className: 'rw-meta' },
11534
+ h('span', { className: 'rw-chip' }, t('autoPushTitle')),
11535
+ h('span', { className: 'rw-hint', style: { flex: '1 1 auto', margin: 0 } }, config.enabled ? t('autoPushOn') : t('autoPushOff')),
11536
+ local.saving ? Spinner(12) : null,
11524
11537
  h(Switch, {
11525
- checked: values.autoPushEnabled,
11538
+ checked: config.enabled === true,
11526
11539
  onChange: toggle,
11527
11540
  label: t('autoPushLabel'),
11528
11541
  text: t('autoPushLabel'),
11529
- }),
11530
- local.saving ? Spinner(12) : null),
11542
+ })),
11531
11543
  ];
11532
11544
 
11533
- if (local.asking && !values.autoPushEnabled) {
11534
- children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
11535
- children.push(h('div', { className: 'rw-dialog-actions', style: { marginTop: 10 } },
11545
+ if (local.asking && config.enabled !== true) {
11546
+ children.push(h('div', { className: 'rw-hint', style: { color: 'rgb(210,153,34)' } }, t('autoPushWarn')));
11547
+ children.push(h('div', { className: 'rw-actions', style: { marginTop: 6 } },
11536
11548
  h('button', {
11537
- type: 'button',
11538
- className: 'rw-btn rw-btn-sm',
11539
- onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { asking: false }); }); },
11549
+ type: 'button', className: 'rw-btn rw-btn-sm',
11550
+ onClick: function () { patchLocal({ asking: false }); },
11540
11551
  }, t('autoPushCancel')),
11541
11552
  h('button', {
11542
- type: 'button',
11543
- className: 'rw-btn rw-btn-sm rw-btn-primary',
11544
- onClick: function () { save({ autoPushEnabled: true }, t('autoPushSaved')); },
11553
+ type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
11554
+ onClick: function () { save({ enabled: true }, t('autoPushSaved')); },
11545
11555
  }, t('autoPushConfirm'))));
11546
11556
  }
11547
11557
 
11548
- if (values.autoPushEnabled) {
11549
- children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('autoPushWarn')));
11550
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11551
- h('span', { className: 'rw-group-title' }, t('autoPushIncludeLabel'))));
11558
+ if (config.enabled === true) {
11559
+ children.push(h('div', { className: 'rw-autopush-row' },
11560
+ h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
11561
+ h('input', {
11562
+ className: 'rw-input rw-input-num',
11563
+ type: 'number',
11564
+ min: 300,
11565
+ max: 60000,
11566
+ step: 100,
11567
+ value: local.debounceMs,
11568
+ onChange: function (event) {
11569
+ var value = event.currentTarget.value;
11570
+ patchLocal({ debounceMs: value });
11571
+ },
11572
+ onBlur: function () { save({ debounceMs: Math.round(Number(local.debounceMs) || 1500) }, t('autoPushSaved')); },
11573
+ })));
11574
+ children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
11575
+ h('span', { className: 'rw-setting-label' }, t('autoPushIncludeLabel'))));
11552
11576
  children.push(h('textarea', {
11553
11577
  className: 'rw-input rw-input-mono rw-autopush-list',
11554
- rows: 3,
11555
- value: values.autoPushInclude,
11578
+ rows: 2,
11579
+ value: local.include,
11556
11580
  placeholder: 'src/**\ndocs/*.md',
11557
11581
  onChange: function (event) {
11558
11582
  var value = event.currentTarget.value;
11559
- setValues(function (previous) { return Object.assign({}, previous, { autoPushInclude: value }); });
11583
+ patchLocal({ include: value });
11560
11584
  },
11561
- onBlur: function () { commitList('autoPushInclude', 'autoPushInclude'); },
11585
+ onBlur: function () { save({ include: lines(local.include) }, t('autoPushSaved')); },
11562
11586
  }));
11563
- children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
11564
- h('span', { className: 'rw-group-title' }, t('autoPushExcludeLabel'))));
11587
+ children.push(h('div', { className: 'rw-group-head', style: { marginTop: 8 } },
11588
+ h('span', { className: 'rw-setting-label' }, t('autoPushExcludeLabel'))));
11565
11589
  children.push(h('textarea', {
11566
11590
  className: 'rw-input rw-input-mono rw-autopush-list',
11567
- rows: 3,
11568
- value: values.autoPushExclude,
11591
+ rows: 2,
11592
+ value: local.exclude,
11569
11593
  placeholder: '*.log\n.remote/**',
11570
11594
  onChange: function (event) {
11571
11595
  var value = event.currentTarget.value;
11572
- setValues(function (previous) { return Object.assign({}, previous, { autoPushExclude: value }); });
11596
+ patchLocal({ exclude: value });
11573
11597
  },
11574
- onBlur: function () { commitList('autoPushExclude', 'autoPushExclude'); },
11598
+ onBlur: function () { save({ exclude: lines(local.exclude) }, t('autoPushSaved')); },
11575
11599
  }));
11576
- children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
11577
- h('span', { className: 'rw-setting-label' }, t('autoPushDebounceLabel')),
11578
- h('input', {
11579
- className: 'rw-input rw-input-num',
11580
- type: 'number',
11581
- min: 300,
11582
- max: 60000,
11583
- step: 100,
11584
- value: values.autoPushDebounceMs,
11585
- onChange: function (event) {
11586
- var value = event.currentTarget.value;
11587
- setValues(function (previous) { return Object.assign({}, previous, { autoPushDebounceMs: value }); });
11588
- },
11589
- onBlur: function () {
11590
- var ms = Math.round(Number(values.autoPushDebounceMs) || 1500);
11591
- save({ autoPushDebounceMs: ms }, t('autoPushSaved'));
11592
- },
11593
- })));
11594
11600
  }
11595
11601
 
11596
11602
  if (local.message) {
11597
11603
  children.push(h(Banner, {
11598
11604
  kind: local.message.kind === 'success' ? 'success' : 'error',
11599
- onClose: function () {
11600
- setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
11601
- },
11605
+ onClose: function () { patchLocal({ message: null }); },
11602
11606
  }, local.message.text));
11603
11607
  }
11604
11608
 
11605
- return h('div', { className: 'rw-group' }, children);
11609
+ return h('div', { className: 'rw-autopush-card' }, children);
11606
11610
  }
11607
11611
 
11608
11612
  /**
@@ -11995,7 +11999,6 @@ function rememberShowHidden(value) {
11995
11999
  hosts: remote.data.hosts || [],
11996
12000
  workspaces: links.concat(remotes),
11997
12001
  }),
11998
- h(AutoPushSettingsGroup, { t: t, locale: locale }),
11999
12002
  h(SshTrustSettingsGroup, { t: t, locale: locale }),
12000
12003
  h(ExtraRootsSettingsGroup, { t: t, locale: locale }),
12001
12004
  h(ForwardSettingsGroup, { t: t, locale: locale, hosts: hosts }),
package/lib/index.js CHANGED
@@ -1268,6 +1268,7 @@ export function apply(ctx) {
1268
1268
  username: host ? host.username : snapshot.username || '',
1269
1269
  remotePath: record.remotePath,
1270
1270
  mirror: Boolean(record.mirror),
1271
+ autoPush: record.autoPush,
1271
1272
  running: Boolean(runningKeys && runningKeys.has(linkedFs.localPathKey(record.localPath))),
1272
1273
  createdAt: record.createdAt,
1273
1274
  workspaceId: workspace ? String(workspace.id) : null,
@@ -2264,16 +2265,18 @@ export function apply(ctx) {
2264
2265
  return false
2265
2266
  }
2266
2267
 
2267
- const autoPushFilter = (settings, plan) => {
2268
- const include = autoPushMatches(settings.autoPushInclude, '')
2268
+ // The include/exclude globs and the debounce now live on each linked record
2269
+ // (`record.autoPush`, see lib/linked.js), so two workspaces can behave very
2270
+ // differently: one pushes every save, another only `docs/**`.
2271
+
2272
+ const autoPushFilter = (autoPush, plan) => {
2269
2273
  const keep = (item) => {
2270
- const included = autoPushMatches(settings.autoPushInclude, item.relative)
2274
+ const included = autoPushMatches(autoPush.include, item.relative)
2271
2275
  if (included === false) return false
2272
- const excluded = autoPushMatches(settings.autoPushExclude, item.relative)
2276
+ const excluded = autoPushMatches(autoPush.exclude, item.relative)
2273
2277
  if (excluded === true) return false
2274
2278
  return true
2275
2279
  }
2276
- void include
2277
2280
  return { ...plan, added: plan.added.filter(keep), changed: plan.changed.filter(keep) }
2278
2281
  }
2279
2282
 
@@ -2285,15 +2288,20 @@ export function apply(ctx) {
2285
2288
  autoPushWatchers.delete(id)
2286
2289
  }
2287
2290
 
2288
- const runAutoPush = async (record, entry) => {
2291
+ const runAutoPush = async (recordId, entry) => {
2289
2292
  if (entry.running) return
2290
2293
  entry.running = true
2291
2294
  try {
2292
- const settings = settingsStore.get()
2293
- if (!settings.autoPushEnabled) return
2295
+ // Re-read the record: the config may have changed (or the workspace may
2296
+ // be gone) since the watcher was armed.
2297
+ const record = linkedStore.get(recordId)
2298
+ if (!record || record.autoPush.enabled !== true) {
2299
+ stopAutoPush(recordId)
2300
+ return
2301
+ }
2294
2302
  const host = await findHost(record.hostId)
2295
2303
  const remote = await connectHost(host)
2296
- const plan = autoPushFilter(settings, await buildPlan(record, remote, {}))
2304
+ const plan = autoPushFilter(record.autoPush, await buildPlan(record, remote, {}))
2297
2305
  if (plan.added.length === 0 && plan.changed.length === 0) {
2298
2306
  entry.failures = 0
2299
2307
  return
@@ -2309,45 +2317,45 @@ export function apply(ctx) {
2309
2317
  // An unreachable host must not retry forever: five attempts with
2310
2318
  // backoff, then wait for the next local edit to start over.
2311
2319
  entry.failures = 0
2312
- log('warn', `autoPush ${record.name} gave up after ${AUTO_PUSH_MAX_ATTEMPTS} attempts: ${message}`)
2320
+ log('warn', `autoPush ${recordId} gave up after ${AUTO_PUSH_MAX_ATTEMPTS} attempts: ${message}`)
2313
2321
  return
2314
2322
  }
2315
2323
  const wait = Math.min(AUTO_PUSH_RETRY_MS * 2 ** (entry.failures - 1), AUTO_PUSH_RETRY_MAX)
2316
- log('warn', `autoPush ${record.name} failed (attempt ${entry.failures}/${AUTO_PUSH_MAX_ATTEMPTS}, retry in ${wait}ms): ${message}`)
2317
- entry.timer = setTimeout(() => { entry.timer = null; void runAutoPush(record, entry) }, wait)
2324
+ log('warn', `autoPush ${recordId} failed (attempt ${entry.failures}/${AUTO_PUSH_MAX_ATTEMPTS}, retry in ${wait}ms): ${message}`)
2325
+ entry.timer = setTimeout(() => { entry.timer = null; void runAutoPush(recordId, entry) }, wait)
2318
2326
  if (entry.timer && typeof entry.timer.unref === 'function') entry.timer.unref()
2319
2327
  } finally {
2320
2328
  entry.running = false
2321
2329
  }
2322
2330
  }
2323
2331
 
2324
- const scheduleAutoPush = (record, entry) => {
2332
+ const scheduleAutoPush = (recordId, entry) => {
2325
2333
  if (entry.timer) clearTimeout(entry.timer)
2326
- const settings = settingsStore.get()
2327
- const delay = clampInt(settings.autoPushDebounceMs, AUTO_PUSH_DEBOUNCE_MIN, AUTO_PUSH_DEBOUNCE_MAX, 1500)
2334
+ const record = linkedStore.get(recordId)
2335
+ if (!record) {
2336
+ stopAutoPush(recordId)
2337
+ return
2338
+ }
2339
+ const delay = clampInt(record.autoPush.debounceMs, AUTO_PUSH_DEBOUNCE_MIN, AUTO_PUSH_DEBOUNCE_MAX, 1500)
2328
2340
  entry.timer = setTimeout(() => {
2329
2341
  entry.timer = null
2330
- void runAutoPush(record, entry)
2342
+ void runAutoPush(recordId, entry)
2331
2343
  }, delay)
2332
2344
  if (entry.timer && typeof entry.timer.unref === 'function') entry.timer.unref()
2333
2345
  }
2334
2346
 
2335
- /** Start/stop watchers so they match the current settings; safe to call often. */
2347
+ /** Start/stop watchers so they match each workspace's own autoPush switch. */
2336
2348
  const syncAutoPush = () => {
2337
- const settings = settingsStore.get()
2338
- const wanted = settings.autoPushEnabled === true
2339
- for (const id of [...autoPushWatchers.keys()]) {
2340
- const record = linkedStore.get(id)
2341
- if (!wanted || !record) stopAutoPush(id)
2342
- }
2343
- if (!wanted) return
2349
+ const live = new Set()
2344
2350
  for (const record of linkedStore.list()) {
2351
+ if (record.autoPush.enabled !== true) continue
2352
+ live.add(record.id)
2345
2353
  if (autoPushWatchers.has(record.id)) continue
2346
2354
  let watcher
2347
2355
  try {
2348
2356
  watcher = watch(record.localPath, { recursive: true, persistent: false }, () => {
2349
2357
  const entry = autoPushWatchers.get(record.id)
2350
- if (entry) scheduleAutoPush(record, entry)
2358
+ if (entry) scheduleAutoPush(record.id, entry)
2351
2359
  })
2352
2360
  } catch (error) {
2353
2361
  log('warn', `autoPush watcher for ${record.name} failed: ${error && error.message ? error.message : error}`)
@@ -2356,6 +2364,9 @@ export function apply(ctx) {
2356
2364
  watcher.on('error', () => stopAutoPush(record.id))
2357
2365
  autoPushWatchers.set(record.id, { watcher, timer: null, running: false })
2358
2366
  }
2367
+ for (const id of [...autoPushWatchers.keys()]) {
2368
+ if (!live.has(id)) stopAutoPush(id)
2369
+ }
2359
2370
  }
2360
2371
 
2361
2372
  // A content search can run for seconds; the client can stop it by job id the
@@ -4962,11 +4973,22 @@ export function apply(ctx) {
4962
4973
  const renamed = nextName !== '' && nextName !== record.name
4963
4974
  record.name = nextName !== '' ? nextName : record.name
4964
4975
  record.mirror = nextMirror
4976
+ const nextAutoPush = params.autoPush !== undefined ? params.autoPush : record.autoPush
4977
+ if (nextAutoPush !== null && typeof nextAutoPush !== 'object') throw new ApiError('BAD_REQUEST', '自动推送设置无效')
4965
4978
  if (nextMirror === false) {
4966
4979
  const running = syncJobs.get(record.id)
4967
4980
  if (running && running.state === 'running') running.cancel = true
4968
4981
  }
4969
- linkedStore.update(record.id, { name: record.name, mirror: record.mirror, syncChoice: true })
4982
+ linkedStore.update(record.id, {
4983
+ name: record.name,
4984
+ mirror: record.mirror,
4985
+ autoPush: nextAutoPush,
4986
+ syncChoice: true,
4987
+ })
4988
+ // The store normalises what we just wrote (debounce clamps, glob cleanup),
4989
+ // so read it back before describing it or arming watchers.
4990
+ const saved = linkedStore.get(record.id) || record
4991
+ if (params.autoPush !== undefined) syncAutoPush()
4970
4992
  if (renamed) {
4971
4993
  const workspace = findWorkspaceByPath(linkedRegistry(), record.localPath)
4972
4994
  if (workspace) await renameDshWorkspace(ctx, String(workspace.id), linkedWorkspaceTitle(record.name))
@@ -4985,7 +5007,7 @@ export function apply(ctx) {
4985
5007
  log('warn', `could not start the first mirror check: ${error && error.message ? error.message : error}`)
4986
5008
  }
4987
5009
  }
4988
- return { link: describeLink(record) }
5010
+ return { link: describeLink(saved) }
4989
5011
  },
4990
5012
 
4991
5013
  async 'linked.remove'(params = {}) {
package/lib/linked.js CHANGED
@@ -67,6 +67,7 @@ const ALLOWED_UPDATE_FIELDS = Object.freeze([
67
67
  'hostSnapshot',
68
68
  'remotePath',
69
69
  'mirror',
70
+ 'autoPush',
70
71
  ])
71
72
 
72
73
  // -- small helpers ----------------------------------------------------------
@@ -252,6 +253,47 @@ function sanitizeHostSnapshot(input, previous) {
252
253
  }
253
254
  }
254
255
 
256
+ /** autoPush knobs, clamped here so a hand-edited registry cannot break a watcher. */
257
+ const AUTO_PUSH_DEBOUNCE_MIN = 300
258
+ const AUTO_PUSH_DEBOUNCE_MAX = 60000
259
+ const AUTO_PUSH_DEBOUNCE_DEFAULT = 1500
260
+
261
+ function autoPushPatterns(value, fallback) {
262
+ const source = Array.isArray(value) ? value : Array.isArray(fallback) ? fallback : []
263
+ const seen = new Set()
264
+ const out = []
265
+ for (const item of source) {
266
+ if (typeof item !== 'string') continue
267
+ const pattern = item.trim()
268
+ if (pattern === '' || seen.has(pattern)) continue
269
+ seen.add(pattern)
270
+ out.push(pattern)
271
+ if (out.length >= 100) break
272
+ }
273
+ return out
274
+ }
275
+
276
+ /**
277
+ * Per-workspace push config (0.24.0). `enabled` alone decides whether this
278
+ * workspace gets a watcher; the other three are per-workspace overrides of the
279
+ * old global settings.
280
+ */
281
+ function sanitizeAutoPush(input, previous) {
282
+ const source = isObject(input) ? input : {}
283
+ const base = isObject(previous) ? previous : {}
284
+ const enabled = typeof source.enabled === 'boolean' ? source.enabled : base.enabled === true
285
+ const raw = Number(source.debounceMs ?? base.debounceMs)
286
+ const debounceMs = Number.isFinite(raw)
287
+ ? Math.min(AUTO_PUSH_DEBOUNCE_MAX, Math.max(AUTO_PUSH_DEBOUNCE_MIN, Math.round(raw)))
288
+ : AUTO_PUSH_DEBOUNCE_DEFAULT
289
+ return {
290
+ enabled,
291
+ debounceMs,
292
+ include: autoPushPatterns(source.include, base.include),
293
+ exclude: autoPushPatterns(source.exclude, base.exclude),
294
+ }
295
+ }
296
+
255
297
  /**
256
298
  * Build a persisted LinkRecord from untrusted JSON or caller input.
257
299
  * `previous` supplies defaults for a merge-style update.
@@ -279,6 +321,7 @@ function sanitizeRecord(input, previous) {
279
321
  remotePath,
280
322
  mirror,
281
323
  syncChoice,
324
+ autoPush: sanitizeAutoPush(input.autoPush, base.autoPush),
282
325
  createdAt,
283
326
  }
284
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.23.0",
3
+ "version": "0.24.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",