dsh-linked-workspace 0.21.0 → 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,12 @@
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
+
5
11
  ## 0.21.0 — 2026-11-20
6
12
 
7
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).
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
 
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
 
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[] }` |
package/docs/VERIFY.md CHANGED
@@ -327,6 +327,8 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
327
327
  18. 右键工作区根节点:菜单里**没有**「更改权限」(也没有「重命名」「删除」「移动到…」)。绕过界面直接请求 `fs.chmod` 并把 `path` 指向工作区远端根:返回 400「不能修改工作区根目录的权限」,随后 `fs.stat` 的权限保持不变。
328
328
  19. **覆盖层置顶(0.20.1)**:打开「添加工作区」弹窗时,右侧目录树与对话输入框都应变暗且完全在弹窗之下(在输入框位置 `document.elementFromPoint` 应命中遮罩);弹窗宿主是 `document.body` 下 `showModal()` 打开的 `<dialog class="rw-top-layer">`。按 Esc:弹窗消失且 `.rw-top-layer` 数量归 0(不能留下已关闭的 dialog),随后再点「添加工作区」仍能重新打开。
329
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`。
330
332
  ## 旧 Host 自检(0.15.0)
331
333
 
332
334
  1. **正常时不打扰**:插件已重启过后打开任意目录树,顶部**不应**出现任何黄色提示条。
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
+ reconnect: '重新连接',
2544
+ reconnecting: '正在连接…',
2545
+ reconnectOk: '已重新连接',
2546
+ reconnectFail: '连接失败:{{reason}}',
2543
2547
  autoPushTitle: '自动推回远端',
2544
2548
  autoPushLabel: '开启自动推送',
2545
2549
  autoPushWarn: '开启后,本地目录里保存的文件会在停止编辑约 1.5 秒后自动写回远端;如果同一文件在远端也被改过,会保留远端版本(不覆盖)。',
@@ -3095,6 +3099,10 @@ function attributeViolation(name, value, tagName) {
3095
3099
  autoPushChip: 'auto push',
3096
3100
  autoPushChipTitle: 'on · pushes after {{debounce}} ms of local quiet',
3097
3101
  autoPushChipLast: 'last {{when}}',
3102
+ reconnect: 'Reconnect',
3103
+ reconnecting: 'Connecting…',
3104
+ reconnectOk: 'Reconnected',
3105
+ reconnectFail: 'Could not connect: {{reason}}',
3098
3106
  autoPushTitle: 'Push back automatically',
3099
3107
  autoPushLabel: 'Enable automatic push',
3100
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).',
@@ -3321,7 +3329,7 @@ function attributeViolation(name, value, tagName) {
3321
3329
  * Host methods the running DSH process does not have yet, the directory
3322
3330
  * pane says so instead of surfacing an unrelated error.
3323
3331
  */
3324
- var HOST_API_REVISION = 6;
3332
+ var HOST_API_REVISION = 7;
3325
3333
  var hostInfoProbe = null;
3326
3334
 
3327
3335
  function probeHostInfo() {
@@ -10793,6 +10801,29 @@ function rememberShowHidden(value) {
10793
10801
  });
10794
10802
  }
10795
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
+
10796
10827
  function remove() {
10797
10828
  if (!local.removing) {
10798
10829
  setLocal(function (previous) { return Object.assign({}, previous, { removing: true, message: null }); });
@@ -10842,6 +10873,10 @@ function rememberShowHidden(value) {
10842
10873
  local.busy === 'sync'
10843
10874
  ? h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: cancelSync }, t('syncCancel'))
10844
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')),
10845
10880
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove }, IconTrash(12), t('removeLinked')))),
10846
10881
  h('div', { className: 'rw-meta' },
10847
10882
  h('span', { className: 'rw-chip' }, link.mirror ? t('mirrorOn') : t('mirrorOff')),
@@ -10938,6 +10973,29 @@ function rememberShowHidden(value) {
10938
10973
  });
10939
10974
  }
10940
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
+
10941
10999
  function testConnection() {
10942
11000
  setLocal(function (previous) { return Object.assign({}, previous, { busy: 'test', message: null }); });
10943
11001
  apiCall('remote_workspaces.test', { id: workspace.id }).then(function (result) {
@@ -11011,6 +11069,10 @@ function rememberShowHidden(value) {
11011
11069
  : null,
11012
11070
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openTree }, IconFolderTree(12), t('openTree')),
11013
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')),
11014
11076
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: startRename, disabled: local.busy !== '' }, t('rename')),
11015
11077
  h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('removeRemote'))))),
11016
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,
@@ -3011,6 +3014,33 @@ export function apply(ctx) {
3011
3014
  return { statuses }
3012
3015
  },
3013
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
+
3014
3044
  /**
3015
3045
  * Store a credential for one SSH host on this machine.
3016
3046
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.21.0",
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",