dsh-linked-workspace 0.27.1 → 0.28.1
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 +19 -0
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/docs/API.md +2 -1
- package/docs/VERIFY.md +19 -0
- package/lib/client.js +279 -5
- package/lib/index.js +40 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.28.1 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
- Links inside a Markdown preview no longer navigate the window — that navigation is what turned the whole
|
|
6
|
+
DSH window white. A link that resolves to a file inside the workspace now opens it in a file tab of the
|
|
7
|
+
same panel; a link that leaves the workspace is refused with a note instead of being followed; `#anchor`
|
|
8
|
+
scrolls the preview itself; and `http(s)` / `mailto` / `tel` links go to the system browser through the
|
|
9
|
+
new `local.openUrl` Host method (those four schemes, nothing else).
|
|
10
|
+
|
|
11
|
+
## 0.28.0 — 2026-11-26
|
|
12
|
+
|
|
13
|
+
- The directory tree now follows renames and deletions instead of waiting for a page reload. Every
|
|
14
|
+
mutation made through the plugin bumps a Host-side `listings` counter that the panel polls every
|
|
15
|
+
five seconds, a quiet refresh no longer keeps rows the listing stopped returning, the remote tree
|
|
16
|
+
refreshes on the same tick as the local one, and the refresh button forces a real re-list instead of
|
|
17
|
+
remounting a panel that restored its cached rows.
|
|
18
|
+
- An open file tab no longer outlives its file: pane tabs re-check their path with `fs.stat` /
|
|
19
|
+
`local.stat` whenever the trees refresh, sidebar file tabs probe it every ten seconds, and a tab
|
|
20
|
+
whose file disappeared closes itself, re-lists the tree and says why.
|
|
21
|
+
|
|
3
22
|
## 0.27.1 — 2026-11-26
|
|
4
23
|
|
|
5
24
|
- Markdown previews **refuse documents above 512 Ki characters** instead of rendering them
|
package/README.en.md
CHANGED
|
@@ -77,6 +77,8 @@ Settings → Linked workspaces → *Where the last artifact opens* picks the def
|
|
|
77
77
|
The heading shows the free space of the remote volume that holds the workspace;
|
|
78
78
|
hover it for the total size and the used percentage.
|
|
79
79
|
|
|
80
|
+
The tree follows the remote side on its own: a file renamed or deleted in a session is relisted within seconds (the old name never lingers as a clickable ghost), the panel asks the Host for a change counter every five seconds, both trees share one four-second tick, and the refresh button really re-lists. A file tab whose target was renamed or deleted closes itself and says “that file is gone from the remote side”.
|
|
81
|
+
|
|
80
82
|
- Fixed on the far right of the sidebar: **remote tree on top, local tree below**, both rooted at “All files”; the plugin's `.local`/`.remote` internal folders are hidden from the local tree.
|
|
81
83
|
- **Single-click opens, double-click pins**: single-click a folder to expand/collapse; single-click a file to open it in the content panel, replacing the current unpinned preview. Double-click a file to pin it so later single clicks do not replace it; double-clicking a folder only keeps it expanded.
|
|
82
84
|
- Toolbar (top right of the sidebar):
|
package/README.md
CHANGED
|
@@ -78,6 +78,8 @@
|
|
|
78
78
|
|
|
79
79
|
目录栏标题右侧显示该工作区所在远端卷的可用空间,悬停可看到总量与已用百分比。
|
|
80
80
|
|
|
81
|
+
目录树跟着远端走,不用手动刷新:会话里改名或删除的文件,几秒内从树里换成新名字(旧名不会残留成可点的幽灵条目);面板打开时每 5 秒问一次 Host 的改动计数,远端树与本地树共用同一个 4 秒刷新节拍,「刷新目录」按钮是真正的重新列举。已经打开的文件标签在文件被改名/删除后会自己关闭,并提示「这个文件已不在远端」。
|
|
82
|
+
|
|
81
83
|
- 面板固定在右侧栏最右边:**上方远端树,下方本地树**,两棵树根部都显示「所有文件」;本地树自动隐藏插件的 `.local`/`.remote` 内部目录。
|
|
82
84
|
- **单击打开,双击固定**:单击文件夹立即展开/折叠;单击文件直接在文件内容面板打开,再次单击其他文件会替换当前未固定的预览标签。双击文件可固定该标签,之后单击其他文件不会覆盖它;双击文件夹只保持展开。
|
|
83
85
|
- 工具栏(右侧栏右上角):
|
package/docs/API.md
CHANGED
|
@@ -84,7 +84,7 @@ scope root, or absolute inside it.
|
|
|
84
84
|
| `fs.move` | `{ linkedId?/remoteId?, path, targetDir? }` | `{ path }` (same remote tree; collision → 409) |
|
|
85
85
|
| `fs.delete` | `{ linkedId?/remoteId?, path }` | `{}` |
|
|
86
86
|
| `fs.home` | `{ linkedId?/remoteId? }` | `{ home }` |
|
|
87
|
-
| `meta.info` | `{}` | `{ version, apiRevision, startedAt }` (the client warns when `apiRevision` is older than its own, i.e. DSH still runs an older copy of this plugin) |
|
|
87
|
+
| `meta.info` | `{}` | `{ version, apiRevision, startedAt, listings }` (the client warns when `apiRevision` is older than its own, i.e. DSH still runs an older copy of this plugin; `listings` is a counter that every mutation bumps, so the panel can notice changes made elsewhere) |
|
|
88
88
|
| `settings.get` | `{}` | `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }` |
|
|
89
89
|
| `settings.update` | `{ editorTheme?, editorThemeFamily?, editorThemeMode?, fileOpenMode?, autoSave? }` | `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }` |
|
|
90
90
|
| `local.browse` | `{ path? }` | `{ path, parent, home, entries: [{ name, path }] }` |
|
|
@@ -98,6 +98,7 @@ scope root, or absolute inside it.
|
|
|
98
98
|
| `linked.syncCancel` | `{ id }` | `{ cancelled: boolean }` |
|
|
99
99
|
| `local.list` | `{ path, limit?, offset? }` | `{ path, entries: [{ name, path, type, size, mtime }], total, offset, limit, hasMore }` |
|
|
100
100
|
| `local.openExternal` | `{ path }` | `{ opened, path }` |
|
|
101
|
+
| `local.openUrl` | `{ url }` | `{ opened, url }` (only `http:`, `https:`, `mailto:` and `tel:`; the preview hands external links here instead of navigating — anything else is `BAD_REQUEST`) |
|
|
101
102
|
| `terminal.open` | `{ linkedId?/remoteId?, side: 'remote'\|'local', path? }` | `{ opened, side, path, host? }` (`path` must stay inside the workspace; remote workspaces only support `side: 'remote'`) |
|
|
102
103
|
| `fs.openExternal` | `{ linkedId?/remoteId?, path }` | `{ opened, localPath, size }` |
|
|
103
104
|
| `localWorkspace.create` | `{ path, name? }` | `{ workspaceId, title, path }` |
|
package/docs/VERIFY.md
CHANGED
|
@@ -439,6 +439,15 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
|
|
|
439
439
|
4. 占位目录下带子目录的路径(例如 `…\remote-placeholders\<uuid>\sub\notes.md`)同样转交成功;目录与无扩展名的路径不转交。
|
|
440
440
|
5. 关闭并重启 DSH 后再点一次这样的链接:行为不变(首次轮询就能转交,不需要刷新页面);新建一个远程工作区后不刷新页面也能转交。
|
|
441
441
|
|
|
442
|
+
## 目录同步与陈旧条目(Unreleased)
|
|
443
|
+
|
|
444
|
+
1. 在会话里让 Agent 重命名或删除一个已打开的文件:5 秒内该文件的标签自己关闭,顶部提示「这个文件已不在远端(可能被重命名或删除),已关闭它的标签并刷新目录。」,目录树里旧名字消失、新名字出现,不需要手动刷新。
|
|
445
|
+
2. 用插件之外的手段(例如另开一个 SSH 会话 `mv a.txt b.txt`)改名:不点任何按钮,目录树在 15 秒内自动换成新名字,旧行不会残留成可点的幽灵条目。
|
|
446
|
+
3. 展开的目录里删掉一个文件后点「刷新目录」:立即重新列举(不走 15 秒节流),被删的行立刻消失。
|
|
447
|
+
4. 打开一个文件后,在另一个会话里改名,再切回本会话:面板里的旧标签已关闭、树是新名字,不会出现「点开就报 `lstat … No such file`」的死标签。
|
|
448
|
+
5. 侧边栏的独立文件标签(`远程文件`)在文件被改名后 10 秒内自动关闭。
|
|
449
|
+
6. 目录树没有打开的标签页时,不会因为刷新而产生任何多余请求(关掉面板后 `listings` 轮询应停止)。
|
|
450
|
+
|
|
442
451
|
## 预览体积、文件标签与刷新(Unreleased)
|
|
443
452
|
|
|
444
453
|
1. 在目录树里点开一个**超过 51.2 万字符**的 Markdown(例如几 MB 的计划文档):面板顶部出现黄色提示「这个文件太大(N 字符,上限 524288),没有生成预览…」,正文退回编辑器(可编辑、可保存),不出现空白预览。
|
|
@@ -447,3 +456,13 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
|
|
|
447
456
|
4. 在**文件标签页**里打开一个 Markdown(例如从聊天里的占位路径链接转交过来的那份):应出现文档面板的工具栏(MARKDOWN 徽标 + 预览 / 导出 PDF / 保存),而不是只有代码编辑器;点「编辑」可改、可保存。
|
|
448
457
|
5. 目录栏标题右侧的可用空间芯片:点「刷新目录」后它的 title(可用 / 已用 / 总量)随之更新,不再永远停在首次打开面板时的数值。
|
|
449
458
|
6. 把窗口最小化或切到别的应用 30 秒再回来:占位目录转交仍在工作(后台不轮询、回到前台立刻补一次),并且这段时间没有产生额外的网络请求。
|
|
459
|
+
|
|
460
|
+
## 预览里的链接(Unreleased)
|
|
461
|
+
|
|
462
|
+
1. 在一份 Markdown 预览里点一个**指向同目录另一个文件**的相对链接(`other.md`、`./sub/a.md`、`../latex/table.tex`):目标文件在同一个文件面板里打开,地址栏不变,页面不跳转;目标已经打开时只切到那个标签,不新开重复标签。
|
|
463
|
+
2. 点一个**绝对路径**链接(`/shared_data_ssd1/…`):只有在当前工作区根目录之内才会打开;越界的(例如 `/etc/passwd`)给出提示「这个链接指向工作区之外,没有打开:…」,页面不动。
|
|
464
|
+
3. 点一个用 `../../..` 跳出工作区的相对链接:同样只给提示,**不会**把整个 DSH 界面导航成白页。
|
|
465
|
+
4. 点 `#section` 锚点:预览在自身内部滚动到对应标题,不触发任何请求。
|
|
466
|
+
5. 点 `http(s)` / `mailto:` 链接:交给系统默认浏览器 / 邮件客户端打开(Host 走 `local.openUrl`),DSH 窗口保持原样;`javascript:`、`file:` 一律拒绝(Host 返回 400)。
|
|
467
|
+
6. 在侧边栏的独立文件标签(`远程文件`)里重复第 1–3 条:越界链接在标签顶部显示黄色横幅,工作区内链接打开同侧的文件标签。
|
|
468
|
+
7. 用真实鼠标(不是脚本合成事件)点第 3 条那种越界链接:地址栏必须仍是 `http://127.0.0.1:<port>/`,界面存活——这是回归白屏 bug 的关键一步。
|
package/lib/client.js
CHANGED
|
@@ -2151,6 +2151,50 @@ function katexStyleViolation(value) {
|
|
|
2151
2151
|
return '';
|
|
2152
2152
|
}
|
|
2153
2153
|
|
|
2154
|
+
// Turns a link found inside a document into an absolute path on the document's
|
|
2155
|
+
// own side. Returns '' for in-page anchors ("#section") and for anything that
|
|
2156
|
+
// is not a path at all (http(s), mailto, tel, protocol-relative), so the caller
|
|
2157
|
+
// can decide between scrolling, the system browser and opening a file.
|
|
2158
|
+
function resolveLinkTarget(baseDir, href) {
|
|
2159
|
+
var raw = String(href == null ? '' : href).trim()
|
|
2160
|
+
// Browsers drop the query and the fragment before asking for a file, and so do
|
|
2161
|
+
// we: neither can be part of a name on either side.
|
|
2162
|
+
var cut = raw.indexOf('#')
|
|
2163
|
+
if (cut >= 0) raw = raw.slice(0, cut)
|
|
2164
|
+
cut = raw.indexOf('?')
|
|
2165
|
+
if (cut >= 0) raw = raw.slice(0, cut)
|
|
2166
|
+
if (raw === '') return ''
|
|
2167
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(raw) && !/^[a-zA-Z]:[\\/]/.test(raw)) return ''
|
|
2168
|
+
if (raw.slice(0, 2) === '//') return ''
|
|
2169
|
+
try { raw = decodeURIComponent(raw) } catch (error) { /* keep the literal text */ }
|
|
2170
|
+
var sep = baseDir && baseDir.indexOf('\\') >= 0 ? '\\' : '/'
|
|
2171
|
+
var text = raw.replace(/[\\/]/g, '/')
|
|
2172
|
+
var parts
|
|
2173
|
+
if (/^[a-zA-Z]:\//.test(text) || text.charAt(0) === '/') {
|
|
2174
|
+
parts = text.split('/')
|
|
2175
|
+
} else {
|
|
2176
|
+
parts = String(baseDir == null ? '' : baseDir).replace(/[\\/]/g, '/').split('/')
|
|
2177
|
+
if (parts.length > 1) parts.pop()
|
|
2178
|
+
text.split('/').forEach(function (part) {
|
|
2179
|
+
if (part === '' || part === '.') return
|
|
2180
|
+
if (part === '..') { if (parts.length > 1) parts.pop(); return }
|
|
2181
|
+
parts.push(part)
|
|
2182
|
+
})
|
|
2183
|
+
}
|
|
2184
|
+
var joined = parts.join('/')
|
|
2185
|
+
return sep === '\\' ? joined.replace(/\//g, '\\') : joined
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
// True when `target` sits inside `root` (or is the root itself). Comparison is
|
|
2189
|
+
// case-sensitive on purpose: both paths come from the same host listing, so the
|
|
2190
|
+
// spelling already agrees, and Linux remotes really do distinguish case.
|
|
2191
|
+
function isInsideRoot(root, target) {
|
|
2192
|
+
var base = String(root == null ? '' : root).replace(/[\\/]+$/, '').replace(/\\/g, '/')
|
|
2193
|
+
var full = String(target == null ? '' : target).replace(/[\\/]+$/, '').replace(/\\/g, '/')
|
|
2194
|
+
if (base === '' || full === '') return false
|
|
2195
|
+
return full === base || full.indexOf(base + '/') === 0
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2154
2198
|
var TREE_TAB_TYPE = 'dsh-linked-workspace';
|
|
2155
2199
|
// Remote workspaces get their own page kind: the two modes show different
|
|
2156
2200
|
// trees (local ⇄ remote pair vs. a plain remote root), so a session must be
|
|
@@ -2315,6 +2359,29 @@ function katexStyleViolation(value) {
|
|
|
2315
2359
|
return undefined;
|
|
2316
2360
|
}
|
|
2317
2361
|
|
|
2362
|
+
// A link inside a remote document has to become an absolute path on the same
|
|
2363
|
+
// host, and the panel that owns the tab does not carry the workspace root.
|
|
2364
|
+
// The two lists change rarely, so one lookup serves every click for 30 s.
|
|
2365
|
+
var scopeRootState = { at: 0, roots: null };
|
|
2366
|
+
function scopeRootOf(scope) {
|
|
2367
|
+
if (!scope || (scope.kind !== 'linked' && scope.kind !== 'remote')) return Promise.resolve('');
|
|
2368
|
+
var key = scope.kind + ':' + (scope.id || '');
|
|
2369
|
+
var now = Date.now();
|
|
2370
|
+
if (scopeRootState.roots && now - scopeRootState.at < 30000) {
|
|
2371
|
+
return Promise.resolve(scopeRootState.roots[key] || '');
|
|
2372
|
+
}
|
|
2373
|
+
return Promise.all([
|
|
2374
|
+
apiCall('linked.list').then(function (result) { return (result && result.links) || []; }, function () { return []; }),
|
|
2375
|
+
apiCall('remote_workspaces.list').then(function (result) { return (result && result.workspaces) || []; }, function () { return []; }),
|
|
2376
|
+
]).then(function (both) {
|
|
2377
|
+
var roots = {};
|
|
2378
|
+
(both[0] || []).forEach(function (item) { if (item && item.id) roots['linked:' + item.id] = String(item.remotePath || ''); });
|
|
2379
|
+
(both[1] || []).forEach(function (item) { if (item && item.id) roots['remote:' + item.id] = String(item.remotePath || ''); });
|
|
2380
|
+
scopeRootState = { at: Date.now(), roots: roots };
|
|
2381
|
+
return roots[key] || '';
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2318
2385
|
function openRemoteFileTab(sidebar, scope, source, filePath) {
|
|
2319
2386
|
if (!sidebar || typeof sidebar.openTab !== 'function') return false;
|
|
2320
2387
|
var key = scopeKeyOf(sourceScopeOf(source)) + ':' + filePath;
|
|
@@ -2659,6 +2726,9 @@ function katexStyleViolation(value) {
|
|
|
2659
2726
|
docPreviewFailed: '预览失败',
|
|
2660
2727
|
previewTooLarge: '这个文件太大({{chars}} 字符,上限 {{limit}}),没有生成预览;可以在编辑器里查看,或下载后用别的工具打开。',
|
|
2661
2728
|
previewTooLargeBytes: '这个文件太大({{bytes}}),没有生成预览;可以在编辑器里查看,或下载后用别的工具打开。',
|
|
2729
|
+
fileGone: '这个文件已不在远端(可能被重命名或删除),已关闭它的标签并刷新目录。',
|
|
2730
|
+
linkOutside: '这个链接指向工作区之外,没有打开:{{path}}',
|
|
2731
|
+
linkFolder: '这是文件夹链接,这里只打开文件:{{path}}',
|
|
2662
2732
|
linkedTitle: '联动工作区',
|
|
2663
2733
|
linkedHint: '本地目录与远端目录成对出现:DSH 会话在该本地目录中工作,并通过 linked_workspace 工具直接编辑远端文件。',
|
|
2664
2734
|
localFlow: '本地目录',
|
|
@@ -3262,6 +3332,9 @@ function katexStyleViolation(value) {
|
|
|
3262
3332
|
docPreviewFailed: 'Preview failed',
|
|
3263
3333
|
previewTooLarge: 'Too large to preview ({{chars}} characters, the ceiling is {{limit}}). Read it in the editor, or download it and open it elsewhere.',
|
|
3264
3334
|
previewTooLargeBytes: 'Too large to preview ({{bytes}}). Read it in the editor, or download it and open it elsewhere.',
|
|
3335
|
+
fileGone: 'That file is gone from the remote side (renamed or deleted). Closed its tab and refreshed the tree.',
|
|
3336
|
+
linkOutside: 'That link points outside the workspace, so it was left alone: {{path}}',
|
|
3337
|
+
linkFolder: 'That link is a folder; only files open here: {{path}}',
|
|
3265
3338
|
linkedTitle: 'Linked workspaces',
|
|
3266
3339
|
linkedHint: 'A local folder paired with a remote folder: DSH sessions work in the local folder and edit remote files through the linked_workspace tool.',
|
|
3267
3340
|
localFlow: 'Local folder',
|
|
@@ -3646,7 +3719,7 @@ function katexStyleViolation(value) {
|
|
|
3646
3719
|
* Host methods the running DSH process does not have yet, the directory
|
|
3647
3720
|
* pane says so instead of surfacing an unrelated error.
|
|
3648
3721
|
*/
|
|
3649
|
-
var HOST_API_REVISION =
|
|
3722
|
+
var HOST_API_REVISION = 16;
|
|
3650
3723
|
var hostInfoProbe = null;
|
|
3651
3724
|
|
|
3652
3725
|
function probeHostInfo() {
|
|
@@ -5875,6 +5948,7 @@ function katexStyleViolation(value) {
|
|
|
5875
5948
|
setSave({ saving: false, conflict: false, error: '', ok: false });
|
|
5876
5949
|
}).catch(function (error) {
|
|
5877
5950
|
setLoad({ loading: false, error: error, file: null });
|
|
5951
|
+
if (error && error.code === 'FS_NOT_FOUND' && typeof props.onMissing === 'function') props.onMissing(props.path);
|
|
5878
5952
|
});
|
|
5879
5953
|
}, [scopeKeyOf(scope), filePath, local]);
|
|
5880
5954
|
|
|
@@ -6430,6 +6504,17 @@ function katexStyleViolation(value) {
|
|
|
6430
6504
|
});
|
|
6431
6505
|
}, [props.refreshTick]);
|
|
6432
6506
|
|
|
6507
|
+
// An explicit refresh (the toolbar button, or a mutation this panel did
|
|
6508
|
+
// not make) must not trust the listing remembered from a previous mount:
|
|
6509
|
+
// the cache is dropped and every expanded directory is read again,
|
|
6510
|
+
// bypassing the REFRESH_MIN_INTERVAL_MS throttle the background tick obeys.
|
|
6511
|
+
useEffect(function () {
|
|
6512
|
+
if (!props.forceTick) return;
|
|
6513
|
+
pending.current.clear();
|
|
6514
|
+
lastRefreshAt.current.clear();
|
|
6515
|
+
setCache({ entries: new Map() });
|
|
6516
|
+
}, [props.forceTick]);
|
|
6517
|
+
|
|
6433
6518
|
function toggle(path) {
|
|
6434
6519
|
setExpanded(function (previous) {
|
|
6435
6520
|
var next = new Set(previous);
|
|
@@ -6476,7 +6561,13 @@ function katexStyleViolation(value) {
|
|
|
6476
6561
|
var freshPaths = new Set(fresh.map(function (entry) { return entry.path; }));
|
|
6477
6562
|
// Keep rows beyond the refreshed page so a silent refresh cannot
|
|
6478
6563
|
// shrink a list the user scrolled many pages into.
|
|
6479
|
-
|
|
6564
|
+
// A silent refresh asks for at least as many rows as were already
|
|
6565
|
+
// loaded, so the page it gets back is authoritative: a row that
|
|
6566
|
+
// disappeared because the file was renamed or deleted elsewhere has
|
|
6567
|
+
// to go, or it lingers as a phantom that fails with ENOENT when the
|
|
6568
|
+
// user clicks it.
|
|
6569
|
+
var previousRaw = Number(existing.raw) || 0;
|
|
6570
|
+
var retained = silent && previousRaw > pageRaw
|
|
6480
6571
|
? (existing.entries || []).filter(function (entry) { return !freshPaths.has(entry.path); })
|
|
6481
6572
|
: [];
|
|
6482
6573
|
var pageRaw = (result.entries || []).length;
|
|
@@ -7714,6 +7805,7 @@ function rememberShowHidden(value) {
|
|
|
7714
7805
|
var path = props.path;
|
|
7715
7806
|
var local = props.local === true;
|
|
7716
7807
|
var onSaved = props.onSaved;
|
|
7808
|
+
var onOpenLink = props.onOpenLink;
|
|
7717
7809
|
var settings = useRuntimeSettings();
|
|
7718
7810
|
var kind = documentKindOf(path);
|
|
7719
7811
|
var viewKey = (local ? 'local' : ((scope && scope.kind ? scope.kind : 'remote') + ':' + ((scope && scope.id) || ''))) + '|' + path;
|
|
@@ -7759,6 +7851,35 @@ function rememberShowHidden(value) {
|
|
|
7759
7851
|
return Object.assign(base, extra || {});
|
|
7760
7852
|
}
|
|
7761
7853
|
|
|
7854
|
+
// A link in the preview used to navigate the whole window: the client is a
|
|
7855
|
+
// single-page app with no route for a file path, so the page went blank and
|
|
7856
|
+
// the reader lost the panel with it. Every anchor is ours to handle now.
|
|
7857
|
+
function previewLink(event) {
|
|
7858
|
+
var node = event && event.target;
|
|
7859
|
+
var anchor = node && typeof node.closest === 'function' ? node.closest('a') : null;
|
|
7860
|
+
if (!anchor) return;
|
|
7861
|
+
event.preventDefault();
|
|
7862
|
+
event.stopPropagation();
|
|
7863
|
+
var href = String(anchor.getAttribute('href') || '').trim();
|
|
7864
|
+
if (href === '') return;
|
|
7865
|
+
if (href.charAt(0) === '#') {
|
|
7866
|
+
var body = docPreviewRef.current;
|
|
7867
|
+
var id = href.slice(1);
|
|
7868
|
+
var target = body && id ? body.querySelector('[id="' + id.replace(/"/g, '\\"') + '"]') : null;
|
|
7869
|
+
if (target && typeof target.scrollIntoView === 'function') target.scrollIntoView({ block: 'nearest' });
|
|
7870
|
+
return;
|
|
7871
|
+
}
|
|
7872
|
+
var scheme = urlSchemeOf(href);
|
|
7873
|
+
if (scheme === 'http' || scheme === 'https' || scheme === 'mailto' || scheme === 'tel') {
|
|
7874
|
+
apiCall('local.openUrl', { url: href }).catch(function (error) {
|
|
7875
|
+
patch({ warn: t('openFailed') + ':' + messageOf(error, t, locale) });
|
|
7876
|
+
});
|
|
7877
|
+
return;
|
|
7878
|
+
}
|
|
7879
|
+
if (scheme !== '' && !/^[a-zA-Z]:[\\/]/.test(href)) return;
|
|
7880
|
+
if (onOpenLink) onOpenLink(href);
|
|
7881
|
+
}
|
|
7882
|
+
|
|
7762
7883
|
function load() {
|
|
7763
7884
|
patch({ loading: true, error: '', notice: '', warn: '' });
|
|
7764
7885
|
apiCall('docs.read', params()).then(function (result) {
|
|
@@ -7775,6 +7896,9 @@ function rememberShowHidden(value) {
|
|
|
7775
7896
|
});
|
|
7776
7897
|
}).catch(function (error) {
|
|
7777
7898
|
patch({ loading: false, error: messageOf(error, t, locale) });
|
|
7899
|
+
// The path no longer exists: say so once and let the panel drop the tab
|
|
7900
|
+
// rather than reopening it on every mount.
|
|
7901
|
+
if (error && error.code === 'FS_NOT_FOUND' && typeof props.onMissing === 'function') props.onMissing(path);
|
|
7778
7902
|
});
|
|
7779
7903
|
}
|
|
7780
7904
|
|
|
@@ -8021,7 +8145,7 @@ function rememberShowHidden(value) {
|
|
|
8021
8145
|
? h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
8022
8146
|
state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
|
|
8023
8147
|
state.html ? h('style', { 'data-rw-katex': '1', dangerouslySetInnerHTML: { __html: state.css || '' } }) : null,
|
|
8024
|
-
state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
8148
|
+
state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, onClick: previewLink, dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
8025
8149
|
: h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
8026
8150
|
state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
|
|
8027
8151
|
h('input', {
|
|
@@ -8444,6 +8568,9 @@ function rememberShowHidden(value) {
|
|
|
8444
8568
|
var localTickState = useState(0);
|
|
8445
8569
|
var localTick = localTickState[0];
|
|
8446
8570
|
var setLocalTick = localTickState[1];
|
|
8571
|
+
var treeForceState = useState(0);
|
|
8572
|
+
var treeForceTick = treeForceState[0];
|
|
8573
|
+
var setTreeForceTick = treeForceState[1];
|
|
8447
8574
|
var fileDirtyState = useState({});
|
|
8448
8575
|
var fileDirty = fileDirtyState[0];
|
|
8449
8576
|
var setFileDirty = fileDirtyState[1];
|
|
@@ -8484,6 +8611,25 @@ function rememberShowHidden(value) {
|
|
|
8484
8611
|
};
|
|
8485
8612
|
}, [directoryOpen, selectedKey]);
|
|
8486
8613
|
|
|
8614
|
+
// A rename or delete made anywhere else (an agent session, another window)
|
|
8615
|
+
// bumps the Host's listings counter. Following it keeps the tree honest
|
|
8616
|
+
// without polling every directory: meta.info answers from memory, no SSH.
|
|
8617
|
+
useEffect(function () {
|
|
8618
|
+
if (!directoryOpen) return undefined;
|
|
8619
|
+
var last = null;
|
|
8620
|
+
var timer = setInterval(function () {
|
|
8621
|
+
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;
|
|
8622
|
+
apiCall('meta.info', {}).then(function (info) {
|
|
8623
|
+
var value = info && typeof info.listings === 'number' ? info.listings : null;
|
|
8624
|
+
if (value === null) return; // older Host without the counter
|
|
8625
|
+
if (last === null) { last = value; return; }
|
|
8626
|
+
if (value !== last) { last = value; forceRefreshTrees(); }
|
|
8627
|
+
}).catch(function () { /* meta.info is best effort */ });
|
|
8628
|
+
}, 5000);
|
|
8629
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
8630
|
+
return function () { clearInterval(timer); };
|
|
8631
|
+
}, [directoryOpen]);
|
|
8632
|
+
|
|
8487
8633
|
function beginResize(event) {
|
|
8488
8634
|
if (event.button !== undefined && event.button !== 0) return;
|
|
8489
8635
|
event.preventDefault();
|
|
@@ -8528,13 +8674,23 @@ function rememberShowHidden(value) {
|
|
|
8528
8674
|
noticeTimer.current = setTimeout(function () { setNotice(null); }, 4200);
|
|
8529
8675
|
}
|
|
8530
8676
|
|
|
8677
|
+
// Everything that changes the tree comes through here: the toolbar button,
|
|
8678
|
+
// every mutation this panel makes, and the listings counter below. Bumping
|
|
8679
|
+
// the tree epoch drops the remembered listings first, so a rename made in
|
|
8680
|
+
// another session cannot leave a phantom row behind.
|
|
8681
|
+
function forceRefreshTrees() {
|
|
8682
|
+
setTreeForceTick(function (value) { return value + 1; });
|
|
8683
|
+
}
|
|
8684
|
+
|
|
8531
8685
|
function refreshAll() {
|
|
8686
|
+
forceRefreshTrees();
|
|
8532
8687
|
bumpVersion(function (value) { return value + 1; });
|
|
8533
8688
|
data.reload();
|
|
8534
8689
|
}
|
|
8535
8690
|
|
|
8536
8691
|
function refreshTree() {
|
|
8537
8692
|
clearStaleError();
|
|
8693
|
+
forceRefreshTrees();
|
|
8538
8694
|
bumpVersion(function (value) { return value + 1; });
|
|
8539
8695
|
data.reload();
|
|
8540
8696
|
}
|
|
@@ -8591,6 +8747,21 @@ function rememberShowHidden(value) {
|
|
|
8591
8747
|
openByMode(side, filePath, { pinned: true, preview: false });
|
|
8592
8748
|
}
|
|
8593
8749
|
|
|
8750
|
+
// A link inside the preview resolves against the file that holds it, and
|
|
8751
|
+
// only opens when it stays inside this workspace.
|
|
8752
|
+
function openPreviewLink(href) {
|
|
8753
|
+
if (!selected) return;
|
|
8754
|
+
var file = openFiles.filter(function (item) { return item.key === activeFileKey; })[0];
|
|
8755
|
+
if (!file) return;
|
|
8756
|
+
var side = file.side;
|
|
8757
|
+
var root = side === 'remote' ? String(selected.remotePath || '') : String(selected.localPath || '');
|
|
8758
|
+
var resolved = resolveLinkTarget(file.path, href);
|
|
8759
|
+
if (!resolved) return;
|
|
8760
|
+
if (/[\\/]$/.test(resolved)) { showNotice('info', t('linkFolder', { path: resolved })); return; }
|
|
8761
|
+
if (!isInsideRoot(root, resolved)) { showNotice('info', t('linkOutside', { path: resolved })); return; }
|
|
8762
|
+
openByMode(side, resolved);
|
|
8763
|
+
}
|
|
8764
|
+
|
|
8594
8765
|
function openByMode(side, filePath, options) {
|
|
8595
8766
|
if (!selected || !filePath) return;
|
|
8596
8767
|
clearStaleError();
|
|
@@ -8650,6 +8821,62 @@ function rememberShowHidden(value) {
|
|
|
8650
8821
|
setDirectoryOpen(true);
|
|
8651
8822
|
}
|
|
8652
8823
|
|
|
8824
|
+
// A file read came back FS_NOT_FOUND: the tab was restored from a listing
|
|
8825
|
+
// that has since changed. Close it and re-read the tree instead of leaving
|
|
8826
|
+
// a tab that can only fail.
|
|
8827
|
+
function dropOpenFile(side, filePath) {
|
|
8828
|
+
var key = side + ':' + (side === 'remote' ? scopeKeyOf(scopeRef) : 'local') + ':' + filePath;
|
|
8829
|
+
setOpenFiles(function (previous) {
|
|
8830
|
+
return previous.filter(function (file) { return file.key !== key; });
|
|
8831
|
+
});
|
|
8832
|
+
setFileDirty(function (dirtyMap) {
|
|
8833
|
+
if (!dirtyMap[key]) return dirtyMap;
|
|
8834
|
+
var copy = Object.assign({}, dirtyMap);
|
|
8835
|
+
delete copy[key];
|
|
8836
|
+
return copy;
|
|
8837
|
+
});
|
|
8838
|
+
showNotice('info', t('fileGone'));
|
|
8839
|
+
forceRefreshTrees();
|
|
8840
|
+
}
|
|
8841
|
+
|
|
8842
|
+
// A pane tab keeps its file open for the whole session, so a rename on the
|
|
8843
|
+
// other side leaves it pointing at a path that no longer exists (the
|
|
8844
|
+
// 0.27.1 report: the tree still listed the old name and clicking it opened
|
|
8845
|
+
// a tab that could only fail with lstat). Re-stat the open pane files
|
|
8846
|
+
// whenever the trees are force-refreshed and drop the ones that are gone,
|
|
8847
|
+
// so the panel heals itself instead of waiting for a read to fail.
|
|
8848
|
+
var openFileKeys = openFiles.map(function (file) { return file.key; }).join('|');
|
|
8849
|
+
var staleProbeRef = useRef(0);
|
|
8850
|
+
function probeOpenFiles() {
|
|
8851
|
+
var cancelled = false;
|
|
8852
|
+
openFiles.forEach(function (file) {
|
|
8853
|
+
var probe = file.side === 'local'
|
|
8854
|
+
? apiCall('local.stat', { path: file.path })
|
|
8855
|
+
: (selected ? apiCall('fs.stat', Object.assign({}, scopeParams(selected), { path: file.path })) : null);
|
|
8856
|
+
if (!probe) return;
|
|
8857
|
+
probe.then(function () { return null; }, function (error) {
|
|
8858
|
+
if (cancelled || !error || error.code !== 'FS_NOT_FOUND') return;
|
|
8859
|
+
dropOpenFile(file.side, file.path);
|
|
8860
|
+
});
|
|
8861
|
+
});
|
|
8862
|
+
return function () { cancelled = true; };
|
|
8863
|
+
}
|
|
8864
|
+
// A mutation made through the plugin (or the refresh button) is worth an
|
|
8865
|
+
// immediate check; an outside change only needs to be caught eventually, so
|
|
8866
|
+
// the periodic tree tick is throttled to keep the host quiet.
|
|
8867
|
+
useEffect(function () {
|
|
8868
|
+
if (!treeForceTick || openFiles.length === 0) return undefined;
|
|
8869
|
+
staleProbeRef.current = Date.now();
|
|
8870
|
+
return probeOpenFiles();
|
|
8871
|
+
}, [treeForceTick, openFileKeys]);
|
|
8872
|
+
useEffect(function () {
|
|
8873
|
+
if (!localTick || openFiles.length === 0) return undefined;
|
|
8874
|
+
var now = Date.now();
|
|
8875
|
+
if (now - staleProbeRef.current < 10000) return undefined;
|
|
8876
|
+
staleProbeRef.current = now;
|
|
8877
|
+
return probeOpenFiles();
|
|
8878
|
+
}, [localTick, openFileKeys]);
|
|
8879
|
+
|
|
8653
8880
|
function closeInternalFile(key) {
|
|
8654
8881
|
setOpenFiles(function (previous) {
|
|
8655
8882
|
var next = previous.filter(function (file) { return file.key !== key; });
|
|
@@ -9911,6 +10138,8 @@ function rememberShowHidden(value) {
|
|
|
9911
10138
|
onDropOnPath: dropOnPath,
|
|
9912
10139
|
onSelect: function (filePath) { openByMode('remote', filePath, { pinned: false, preview: true }); },
|
|
9913
10140
|
onPin: function (filePath) { pinByMode('remote', filePath); },
|
|
10141
|
+
refreshTick: localTick,
|
|
10142
|
+
forceTick: treeForceTick,
|
|
9914
10143
|
onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); openContextMenu('remote', info); },
|
|
9915
10144
|
})),
|
|
9916
10145
|
selected.kind === 'linked'
|
|
@@ -9937,6 +10166,7 @@ function rememberShowHidden(value) {
|
|
|
9937
10166
|
onSelect: function (filePath) { openByMode('local', filePath, { pinned: false, preview: true }); },
|
|
9938
10167
|
onPin: function (filePath) { pinByMode('local', filePath); },
|
|
9939
10168
|
refreshTick: localTick,
|
|
10169
|
+
forceTick: treeForceTick,
|
|
9940
10170
|
onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'local' }, info)); openContextMenu('local', info); },
|
|
9941
10171
|
}))
|
|
9942
10172
|
: null);
|
|
@@ -9970,6 +10200,8 @@ function rememberShowHidden(value) {
|
|
|
9970
10200
|
path: activeFile.path,
|
|
9971
10201
|
local: activeFile.side === 'local',
|
|
9972
10202
|
onSaved: refreshTree,
|
|
10203
|
+
onOpenLink: openPreviewLink,
|
|
10204
|
+
onMissing: function (filePath) { dropOpenFile(activeFile.side, filePath); },
|
|
9973
10205
|
onSaveReady: function (handler) {
|
|
9974
10206
|
if (handler) saveHandlersRef.current[activeFile.key] = handler;
|
|
9975
10207
|
else delete saveHandlersRef.current[activeFile.key];
|
|
@@ -9991,6 +10223,7 @@ function rememberShowHidden(value) {
|
|
|
9991
10223
|
hideHeader: true,
|
|
9992
10224
|
focusLine: activeFile.line || 0,
|
|
9993
10225
|
hitQuery: searchQuery,
|
|
10226
|
+
onMissing: function (filePath) { dropOpenFile(activeFile.side, filePath); },
|
|
9994
10227
|
onSaveReady: function (handler) {
|
|
9995
10228
|
if (handler) saveHandlersRef.current[activeFile.key] = handler;
|
|
9996
10229
|
else delete saveHandlersRef.current[activeFile.key];
|
|
@@ -10256,12 +10489,50 @@ function rememberShowHidden(value) {
|
|
|
10256
10489
|
// opened here (placeholder paths, references) had no preview while the
|
|
10257
10490
|
// very same file opened in the directory panel did. Mirror that dispatch.
|
|
10258
10491
|
var docKind = documentKindOf(filePath);
|
|
10492
|
+
var linkNoteRef = useState('');
|
|
10493
|
+
var linkNote = linkNoteRef[0];
|
|
10494
|
+
var setLinkNote = linkNoteRef[1];
|
|
10495
|
+
function openPreviewLink(href) {
|
|
10496
|
+
scopeRootOf(scope).then(function (root) {
|
|
10497
|
+
var resolved = resolveLinkTarget(filePath, href);
|
|
10498
|
+
if (!resolved) return;
|
|
10499
|
+
if (/[\\/]$/.test(resolved)) { setLinkNote(t('linkFolder', { path: resolved })); return; }
|
|
10500
|
+
if (!isInsideRoot(root, resolved)) { setLinkNote(t('linkOutside', { path: resolved })); return; }
|
|
10501
|
+
var service = sidebarService(ctx);
|
|
10502
|
+
if (!service || typeof service.openTab !== 'function') return;
|
|
10503
|
+
var source = { kind: scope.kind, id: scope.id, name: meta.linkedName || meta.remoteName || '' };
|
|
10504
|
+
openRemoteFileTab(service, props.scope, source, resolved);
|
|
10505
|
+
}, function () { /* a failed lookup leaves the link alone */ });
|
|
10506
|
+
}
|
|
10507
|
+
// A file tab whose target vanished closes itself; the panel that opened it
|
|
10508
|
+
// is gone, so the sidebar is the only thing that can reclaim the tab.
|
|
10509
|
+
function closeSelf() {
|
|
10510
|
+
try {
|
|
10511
|
+
var service = sidebarService(ctx);
|
|
10512
|
+
if (service && typeof service.closeTab === 'function' && tab && tab.id) service.closeTab(tab.id, props.scope);
|
|
10513
|
+
} catch (error) { /* no sidebar attached */ }
|
|
10514
|
+
}
|
|
10515
|
+
// A sidebar tab outlives the panel that opened it, so nothing else ever
|
|
10516
|
+
// re-reads this file: probe it now and then and reclaim the tab once the
|
|
10517
|
+
// path is gone (a rename inside a session is the usual cause).
|
|
10518
|
+
useEffect(function () {
|
|
10519
|
+
var cancelled = false;
|
|
10520
|
+
var timer = setInterval(function () {
|
|
10521
|
+
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;
|
|
10522
|
+
apiCall('fs.stat', Object.assign({ path: filePath }, scopeParams(scope))).then(function () { return null; }, function (error) {
|
|
10523
|
+
if (cancelled || !error || error.code !== 'FS_NOT_FOUND') return;
|
|
10524
|
+
closeSelf();
|
|
10525
|
+
});
|
|
10526
|
+
}, 10000);
|
|
10527
|
+
return function () { cancelled = true; clearInterval(timer); };
|
|
10528
|
+
}, [filePath, scope.kind, scope.id]);
|
|
10529
|
+
|
|
10259
10530
|
var pane = docKind === 'image'
|
|
10260
10531
|
? h(ImagePreview, { ctx: ctx, t: t, locale: locale, scope: scope, path: filePath, local: false })
|
|
10261
10532
|
: docKind === 'html'
|
|
10262
10533
|
? h(HtmlPreview, { ctx: ctx, t: t, locale: locale, scope: scope, path: filePath, local: false })
|
|
10263
10534
|
: docKind && docKind !== 'csv'
|
|
10264
|
-
? h(DocumentPane, { ctx: ctx, t: t, locale: locale, scope: scope, path: filePath, local: false, visible: visible })
|
|
10535
|
+
? h(DocumentPane, { ctx: ctx, t: t, locale: locale, scope: scope, path: filePath, local: false, visible: visible, onMissing: closeSelf, onOpenLink: openPreviewLink })
|
|
10265
10536
|
: h(RemoteFileEditor, {
|
|
10266
10537
|
ctx: ctx, t: t, locale: locale,
|
|
10267
10538
|
scope: scope,
|
|
@@ -10269,8 +10540,11 @@ function rememberShowHidden(value) {
|
|
|
10269
10540
|
visible: visible,
|
|
10270
10541
|
tabId: tab ? tab.id : undefined,
|
|
10271
10542
|
sessionId: props.scope ? props.scope.sessionId : undefined,
|
|
10543
|
+
onMissing: closeSelf,
|
|
10272
10544
|
});
|
|
10273
|
-
return h('div', { className: 'rw-editor-pane' },
|
|
10545
|
+
return h('div', { className: 'rw-editor-pane' },
|
|
10546
|
+
linkNote ? h('div', { style: { padding: '6px 10px 0' } }, h(Banner, { kind: 'warn', onClose: function () { setLinkNote(''); } }, linkNote)) : null,
|
|
10547
|
+
pane);
|
|
10274
10548
|
}
|
|
10275
10549
|
|
|
10276
10550
|
// ── tree ───────────────────────────────────────────────────────────────
|
package/lib/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export const inject = ['webServer', 'tools', 'systemPrompt', 'workingDirectory']
|
|
|
41
41
|
* is still running an older copy of the Host — refreshing the page only swaps
|
|
42
42
|
* the browser bundle, so the two halves can drift by one restart.
|
|
43
43
|
*/
|
|
44
|
-
const API_REVISION =
|
|
44
|
+
const API_REVISION = 16
|
|
45
45
|
|
|
46
46
|
/** When this copy of the Host was loaded; shown by `meta.info`. */
|
|
47
47
|
const STARTED_AT = new Date().toISOString()
|
|
@@ -195,7 +195,14 @@ const rememberListing = (key, listing) => {
|
|
|
195
195
|
listingCache.delete(listingCache.keys().next().value)
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
// Every mutation clears the cache; the counter lets the client notice that a
|
|
199
|
+
// listing changed underneath it (a rename made by an agent session, an upload
|
|
200
|
+
// from another window) without having to poll the tree itself.
|
|
201
|
+
let listingsGeneration = 0
|
|
202
|
+
const forgetListings = () => {
|
|
203
|
+
listingsGeneration += 1
|
|
204
|
+
listingCache.clear()
|
|
205
|
+
}
|
|
199
206
|
|
|
200
207
|
/** Clamp a requested page window to the listing limits. */
|
|
201
208
|
const pageWindow = (params = {}, total = 0) => {
|
|
@@ -325,6 +332,26 @@ function openWithSystem(targetPath) {
|
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
334
|
|
|
335
|
+
// Same idea for a URL: rundll32 hands it to the registered protocol handler
|
|
336
|
+
// without a shell, so nothing re-parses "&" or spaces inside the link.
|
|
337
|
+
function openUrlWithSystem(url) {
|
|
338
|
+
let child
|
|
339
|
+
try {
|
|
340
|
+
if (process.platform === 'win32') {
|
|
341
|
+
child = spawn('rundll32.exe', ['url.dll,FileProtocolHandler', url], { detached: true, stdio: 'ignore', windowsHide: true })
|
|
342
|
+
} else if (process.platform === 'darwin') {
|
|
343
|
+
child = spawn('open', [url], { detached: true, stdio: 'ignore' })
|
|
344
|
+
} else {
|
|
345
|
+
child = spawn('xdg-open', [url], { detached: true, stdio: 'ignore' })
|
|
346
|
+
}
|
|
347
|
+
if (typeof child.unref === 'function') child.unref()
|
|
348
|
+
return true
|
|
349
|
+
} catch (error) {
|
|
350
|
+
log('warn', `cannot open ${url}: ${error && error.message ? error.message : error}`)
|
|
351
|
+
return false
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
328
355
|
/** Spawn a detached console process and report whether the executable started. */
|
|
329
356
|
function launchDetached(command, args, extra = {}) {
|
|
330
357
|
return new Promise((resolveLaunch) => {
|
|
@@ -4300,6 +4327,7 @@ export function apply(ctx) {
|
|
|
4300
4327
|
apiRevision: API_REVISION,
|
|
4301
4328
|
startedAt: STARTED_AT,
|
|
4302
4329
|
execAuditFile: join(dir, EXEC_AUDIT_NAME),
|
|
4330
|
+
listings: listingsGeneration,
|
|
4303
4331
|
}
|
|
4304
4332
|
},
|
|
4305
4333
|
|
|
@@ -4675,6 +4703,16 @@ export function apply(ctx) {
|
|
|
4675
4703
|
return { opened: true, path: target }
|
|
4676
4704
|
},
|
|
4677
4705
|
|
|
4706
|
+
// A link inside a remote document cannot be followed by the window that
|
|
4707
|
+
// shows the preview: the SPA has no route for it and goes blank. External
|
|
4708
|
+
// links are handed to the system browser instead.
|
|
4709
|
+
async 'local.openUrl'(params = {}) {
|
|
4710
|
+
const raw = typeof params.url === 'string' ? params.url.trim() : ''
|
|
4711
|
+
if (!/^(?:https?|mailto|tel):/i.test(raw)) throw new ApiError('BAD_REQUEST', '只支持 http、https、mailto 与 tel 链接')
|
|
4712
|
+
if (!openUrlWithSystem(raw)) throw new ApiError('INTERNAL', '无法启动系统浏览器')
|
|
4713
|
+
return { opened: true, url: raw }
|
|
4714
|
+
},
|
|
4715
|
+
|
|
4678
4716
|
async 'fs.openExternal'(params = {}) {
|
|
4679
4717
|
const scope = await requireScope(params)
|
|
4680
4718
|
const target = scopeTarget(scope, params.path)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
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",
|