dsh-linked-workspace 0.32.0 → 0.34.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 +27 -0
- package/docs/API.md +4 -1
- package/docs/VERIFY.md +29 -0
- package/lib/client.js +214 -11
- package/lib/index.js +107 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.0 — 2026-12-01
|
|
4
|
+
|
|
5
|
+
- **工作区外下载不会再点出两份**:下载期间按钮变成「下载中…」并禁用,结束后恢复;下载完成的页脚多一个
|
|
6
|
+
「打开所在文件夹」,直接定位到刚保存的文件(Host 新增 `local.reveal`,Windows 用 `explorer /select,`)。
|
|
7
|
+
- **工作区外图片的内联预览上限收到 8 MB**:超过就提示下载,而不是把 24 MB 的 base64 塞进内存;图片数据解不开时
|
|
8
|
+
面板给出「图片数据无法解码,请下载后查看。」,不再是一片空白。
|
|
9
|
+
- **「只在当前目录搜」对额外根目录也成立**:`fs.grep` 的 `includeOutside` 现在把同一个相对目录套到每个额外根,
|
|
10
|
+
某个根没有这个目录就跳过(不再让整次搜索失败);结果回报扫过几个根、丢了几个(超出 5 个上限时面板会说明)。
|
|
11
|
+
- **槽位满的提示不再只在目录面板里**:面板没打开时(例如直接在会话里点链接)改由框架级 toast 说明
|
|
12
|
+
「文件标签位已满(24 个)」。
|
|
13
|
+
- **目录栏头部折叠按钮有了 `aria-label`**,读屏能念出它。
|
|
14
|
+
- **Host**:新增 `local.reveal { path }`;`media.readOutside` 的内联上限改为 8 MB;`fs.grep` 新增
|
|
15
|
+
`outsideRoots`/`outsideDropped`/`outsideSkipped` 三个回报字段。
|
|
16
|
+
|
|
17
|
+
## 0.33.0 — 2026-11-30
|
|
18
|
+
|
|
19
|
+
- **工作区外的文件终于能拿出来、图片也能看了**:只读标签的工具栏多了「下载到默认文件夹」(落到
|
|
20
|
+
`~/Downloads`,文件名重名自动加序号),工作区外的 PNG/JPEG/GIF/WebP 等直接在面板里内联预览 ——
|
|
21
|
+
这两条正是原先「文件过大请下载」「二进制文件无法预览」两句提示指向、却无处可去的死路。
|
|
22
|
+
- **读取上限与二进制的说明不再指向空气**:到达 4 MB 上限或遇到不支持的类型时,同一排按钮里就有下载。
|
|
23
|
+
- **一页 1 MB**:4.6 MB 的文件从「14 次点击」变成 5 次;上限仍是 4 MB,DOM 不会失控。
|
|
24
|
+
- **标签位排满会说明原因**:24 个位置全被占用时给一条提示,不再让点击无声消失。
|
|
25
|
+
- **内容搜索可以覆盖额外根目录**:搜索栏多一个「+/」开关(最多 5 个前缀),命中行以根目录名作前缀,
|
|
26
|
+
点一下照样落进工作区外的只读标签。默认关闭,不开就不影响原有搜索速度。
|
|
27
|
+
- **Host**:新增 `fs.downloadOutside`、`media.readOutside`;`fs.grep` 新增 `includeOutside`,
|
|
28
|
+
结果条目带 `outsideRoot`。
|
|
29
|
+
|
|
3
30
|
## 0.32.0 — 2026-11-29
|
|
4
31
|
|
|
5
32
|
- **Working outside the workspace is now readable, not truncated**: the read-only tab pages through a file
|
package/docs/API.md
CHANGED
|
@@ -60,6 +60,7 @@ scope root, or absolute inside it.
|
|
|
60
60
|
| `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`) |
|
|
61
61
|
| `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) |
|
|
62
62
|
| `fs.readOutside` | `{ linkedId?, remoteId?, path, maxBytes?, offset? }` | `{ path, size, mtime, binary, offset, returned, truncated, content }` (`offset` pages through a large file; `returned` is how many bytes this call read) |
|
|
63
|
+
| `fs.downloadOutside` | `{ linkedId?/remoteId?, path }` | `{ path, files, bytes, skipped, truncated }` (copies into `~/Downloads`; the same 64 MB per-file limit as the tree) |
|
|
63
64
|
| `fs.writeOutside` | `{ linkedId?, remoteId?, path, content, ifModifiedSince? }` | `{ path, size, mtime, created }` (8 MB limit; only under an `extraRoots` prefix; audited) |
|
|
64
65
|
| `fs.listOutside` | `{ linkedId?, remoteId?, path }` | `{ path, entries }` (only under an `extraRoots` prefix; audited) |
|
|
65
66
|
| `hosts.forward` | `{ hostId, remotePort, remoteHost?, localPort? }` | `{ forward: { id, hostId, hostName, remoteHost, remotePort, localPort, startedAt, url } }` (localhost TCP tunnel; reuses an identical one; the definition is written to `forwards.json`, so a restarted Host re-binds the same port) |
|
|
@@ -77,6 +78,7 @@ scope root, or absolute inside it.
|
|
|
77
78
|
| `fs.list` | `{ linkedId?/remoteId?, path, limit?, offset? }` | `{ path, entries: RemoteEntry[], total, offset, limit, hasMore }` (default 500, max 5000). Listings are cached for 5 s for `offset > 0`; writes, mkdir, rename, move, delete, copy and transfers invalidate the cache. |
|
|
78
79
|
| `fs.read` | `{ linkedId?/remoteId?, path, maxBytes? }` | `FileRead` |
|
|
79
80
|
| `media.read` | `{ linkedId?/remoteId?, path }` | `{ path, size, mtime, mime, base64 }` (PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG, max 24 MB) |
|
|
81
|
+
| `media.readOutside` | `{ linkedId?/remoteId?, path }` | `{ path, size, mtime, mime, base64 }` (same types as `media.read`, inline only up to 8 MB; past that it answers `FS_TOO_LARGE` and the viewer offers the download) |
|
|
80
82
|
| `fs.write` | `{ linkedId?/remoteId?, path, content, expectedMtime?, createOnly? }` | `{ path, size, mtime }` (`createOnly: true`: existing target → 409) |
|
|
81
83
|
| `fs.stat` | `{ linkedId?/remoteId?, path }` | `{ path, relative, type, size, mtime, mode }` |
|
|
82
84
|
| `fs.mkdir` | `{ linkedId?/remoteId?, path, createOnly? }` | `{}` (`createOnly: true`: existing target → 409) |
|
|
@@ -99,6 +101,7 @@ scope root, or absolute inside it.
|
|
|
99
101
|
| `local.list` | `{ path, limit?, offset? }` | `{ path, entries: [{ name, path, type, size, mtime }], total, offset, limit, hasMore }` |
|
|
100
102
|
| `local.openExternal` | `{ path }` | `{ opened, path }` |
|
|
101
103
|
| `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`) |
|
|
104
|
+
| `local.reveal` | `{ path }` | `{ opened, folder }` (absolute local path; opens the file manager with the file selected, or the folder itself) |
|
|
102
105
|
| `terminal.open` | `{ linkedId?/remoteId?, side: 'remote'\|'local', path? }` | `{ opened, side, path, host? }` (`path` must stay inside the workspace; remote workspaces only support `side: 'remote'`) |
|
|
103
106
|
| `fs.openExternal` | `{ linkedId?/remoteId?, path }` | `{ opened, localPath, size }` |
|
|
104
107
|
| `localWorkspace.create` | `{ path, name? }` | `{ workspaceId, title, path }` |
|
|
@@ -107,7 +110,7 @@ scope root, or absolute inside it.
|
|
|
107
110
|
| `skills.read` | `{ linkedId, name }` | `{ name, description, content, path }` |
|
|
108
111
|
| `git.status` | `{ linkedId?/remoteId?, side: 'remote'|'local' }` | `{ ok, repo, root, branch, changes, error? }` (remote workspaces only support `side: 'remote'`) |
|
|
109
112
|
| `fs.search` | `{ linkedId?/remoteId?, side, query, maxResults? }` | `{ ok, query, entries, truncated }` (matches **file names**, not contents; use `fs.grep` for contents) |
|
|
110
|
-
| `fs.grep` | `{ linkedId?/remoteId?, side, query, maxResults?, path?, ignoreCase?, regex?, includeIgnored?, resultMode?, maxFiles?, maxFileBytes?, timeoutMs?, jobId? }` | `{ ok, query, entries: [{ path, relative, size, line, preview, matches }], truncated, truncatedReason, scannedFiles, scannedBytes, skippedFiles }` (searches file **contents**; `path` narrows the scan to a sub-folder; `ignoreCase` defaults to `true`; `regex` treats `query` as a regular expression; `includeIgnored: true` also walks usually ignored folders such as `node_modules`/`.venv`/`dist` (`.git`/`.hg`/`.svn` always stay out); `resultMode: 'files'` lists file names only (`line: 0`, empty `preview`, `matches` = hit count); `maxFiles` (default 2000), `maxFileBytes` (default 1 MB) and `timeoutMs` (default 5 s, max 10 s) raise or lower the sweep; limits are 1 MB per file, 2000 files, 8 MB and 5 s for both sides, and `truncatedReason` is one of `files`, `bytes`, `deadline`, `results`, `cancelled`; max 1000 rows) |
|
|
113
|
+
| `fs.grep` | `{ linkedId?/remoteId?, side, query, maxResults?, path?, ignoreCase?, regex?, includeIgnored?, resultMode?, includeOutside?, maxFiles?, maxFileBytes?, timeoutMs?, jobId? }` | `{ ok, query, entries: [{ path, relative, size, line, preview, matches }], truncated, truncatedReason, scannedFiles, scannedBytes, skippedFiles }` (searches file **contents**; `path` narrows the scan to a sub-folder; `ignoreCase` defaults to `true`; `regex` treats `query` as a regular expression; `includeIgnored: true` also walks usually ignored folders such as `node_modules`/`.venv`/`dist` (`.git`/`.hg`/`.svn` always stay out); `resultMode: 'files'` lists file names only (`line: 0`, empty `preview`, `matches` = hit count); `maxFiles` (default 2000), `maxFileBytes` (default 1 MB) and `timeoutMs` (default 5 s, max 10 s) raise or lower the sweep; limits are 1 MB per file, 2000 files, 8 MB and 5 s for both sides, and `truncatedReason` is one of `files`, `bytes`, `deadline`, `results`, `cancelled`; max 1000 rows; `includeOutside: true` also sweeps the extra roots and marks those hits with `outsideRoot`, and the answer carries `outsideRoots` / `outsideDropped` / `outsideSkipped`) |
|
|
111
114
|
| `fs.grepCancel` | `{ jobId }` | `{ cancelled }` (marks the job started by `fs.grep`'s `jobId`; the Host checks it between files and answers `truncatedReason: 'cancelled'`) |
|
|
112
115
|
| `linked.plan` | `{ id, maxFiles? }` | `{ linkedId, localPath, remotePath, added, changed, conflict, removed, unchanged, pending, truncated, skipped, maxFiles }` (each entry carries `relative`, `size`, `localHash`, `remoteHash`; a file that moved on both sides since the last push lands in `conflict`) |
|
|
113
116
|
| `linked.push` | `{ id, paths?, dryRun?, conflict?, jobId? }` | `{ linkedId, dryRun, conflict, files, pushed, skipped, conflictsLeft, bytes, cancelled }` (`conflict` is `skip` by default; every file is written as a temporary file and renamed into place; `paths` entries may be files or folders — a folder matches everything under it — and every planned entry carries `localMtime` / `remoteMtime`) |
|
package/docs/VERIFY.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Manual verification checklist
|
|
2
2
|
|
|
3
|
+
## 工作区外:下载、图片与额外根目录搜索(未发布)
|
|
4
|
+
|
|
5
|
+
1. 额外根目录里放一个 3 MB 以上的 `big.txt`,点击它的聊天链接,然后连点两次「下载到默认文件夹」:
|
|
6
|
+
按钮立刻变「下载中…」并禁用,`~/Downloads` 里**只出现一份**文件。
|
|
7
|
+
2. 下载完成后页脚出现「打开所在文件夹」,点它应当用资源管理器定位到该文件。
|
|
8
|
+
3. 额外根目录里放一张 **9 MB** 的 PNG:面板显示「图片超过 8 MB,无法内联预览,请下载后查看」,同排有下载按钮。
|
|
9
|
+
4. 放一张 1 MB 的 PNG:正常内联预览;把文件内容改成非图片字节(保留 .png 后缀)后重开,应显示
|
|
10
|
+
「图片数据无法解码,请下载后查看。」而不是空白。
|
|
11
|
+
5. 额外根目录 A 下有 `sub/x.txt`,B 下没有 `sub/`:打开「+/」并在搜索栏限定到 `sub`,结果只来自 A,
|
|
12
|
+
且不报错;若配置了 6 个额外根目录,结果区多一行「还有 N 个额外根目录没有扫(上限 5 个)」。
|
|
13
|
+
6. 关掉目录面板,在会话里连续点开 25 个不同的聊天文件链接:第 25 个应在页面底部弹出
|
|
14
|
+
「文件标签位已满(24 个)。先关掉一个再点。」(框架级 toast,5 秒后消失)。
|
|
15
|
+
7. 目录栏头部的折叠按钮:读屏应念出「开启/关闭联动工作区目录面板」。
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 工作区外的下载、图片与搜索(未发布)
|
|
19
|
+
|
|
20
|
+
1. 联动工作区根目录在 `/shared_data_ssd1/huangjh`,额外根目录里放 `/shared_data_hdd1/huangjh/x/pic.png`(≥ 1 像素真图)
|
|
21
|
+
与 `big.txt`(≥ 4.5 MB),并在设置里允许该前缀。点击两个文件的聊天链接。
|
|
22
|
+
2. `pic.png`:面板里直接显示图片(不是「二进制文件」字样),工具栏有「下载到默认文件夹」。
|
|
23
|
+
3. `big.txt`:首屏约 1 MB,页脚「已显示 1.0 MB,共 4.6 MB」;点「加载更多」5 次左右到 4 MB 后提示已达上限。
|
|
24
|
+
4. 点「下载到默认文件夹」:页脚出现「已下载到 …\\Downloads\\big.txt」,本地文件大小与远端一致。
|
|
25
|
+
5. 内容搜索里打开「+/」(连额外根目录一起搜),搜 `needle-outside`:命中行以根目录名作前缀,
|
|
26
|
+
点一下打开的是带「工作区外」徽标的只读标签,不出现原生「文件不存在」。
|
|
27
|
+
6. 关掉该开关再搜一次:额外根目录里的文件不再出现。
|
|
28
|
+
7. 连续用聊天链接打开 25 个不同的工作区外文件:第 25 个给一条「文件标签位已满(24 个)」提示,
|
|
29
|
+
不出现原生报错页(需要先清掉已有标签再试)。
|
|
30
|
+
|
|
31
|
+
|
|
3
32
|
## 工作区外的只读视图与标签位(未发布)
|
|
4
33
|
|
|
5
34
|
1. 联动工作区根目录在 `/shared_data_ssd1/huangjh`,准备一个 `/shared_data_hdd1/huangjh/big.jsonl`(≥ 300 KB,
|
package/lib/client.js
CHANGED
|
@@ -2357,6 +2357,8 @@ function isInsideRoot(root, target) {
|
|
|
2357
2357
|
// screen). A full table is therefore reported as "full" and the caller
|
|
2358
2358
|
// falls back, instead of showing the wrong file under a new title.
|
|
2359
2359
|
var slotFull = false;
|
|
2360
|
+
// Set by the directory panel so a swallowed click can explain itself.
|
|
2361
|
+
var slotFullNotice = null;
|
|
2360
2362
|
|
|
2361
2363
|
function remoteFileSlotFor(key) {
|
|
2362
2364
|
slotFull = false;
|
|
@@ -2690,6 +2692,7 @@ function isInsideRoot(root, target) {
|
|
|
2690
2692
|
searchScopeHere: '只搜当前目录',
|
|
2691
2693
|
searchIncludeIgnored: '连通常忽略的目录一起搜(.git 仍然排除)',
|
|
2692
2694
|
searchFilesOnly: '只列文件名(不显示命中行)',
|
|
2695
|
+
searchOutside: '连额外根目录一起搜(最多 5 个)',
|
|
2693
2696
|
searchStop: '停止',
|
|
2694
2697
|
searchStats: '扫描 {{files}} 个文件 · {{size}}',
|
|
2695
2698
|
searchStatsSkipped: '跳过 {{count}} 个',
|
|
@@ -2848,6 +2851,13 @@ function isInsideRoot(root, target) {
|
|
|
2848
2851
|
outsideShown: '已显示 {{shown}},共 {{total}}',
|
|
2849
2852
|
outsideMtime: '修改于 {{when}}',
|
|
2850
2853
|
outsideCeiling: '已达到 {{size}} 的读取上限,剩下的内容请下载后查看。',
|
|
2854
|
+
outsideDownload: '下载到默认文件夹',
|
|
2855
|
+
outsideDownloading: '下载中…',
|
|
2856
|
+
outsideReveal: '打开所在文件夹',
|
|
2857
|
+
imageBroken: '图片数据无法解码,请下载后查看。',
|
|
2858
|
+
searchOutsideDropped: '还有 {{count}} 个额外根目录没有扫(上限 5 个)。',
|
|
2859
|
+
outsideDownloaded: '已下载到 {{path}}',
|
|
2860
|
+
tabsFull: '文件标签位已满({{count}} 个)。先关掉一个再点。',
|
|
2851
2861
|
linkOutside: '这个链接指向工作区之外,没有打开:{{path}}',
|
|
2852
2862
|
linkFolder: '这是文件夹链接,这里只打开文件:{{path}}',
|
|
2853
2863
|
linkedTitle: '联动工作区',
|
|
@@ -3306,6 +3316,7 @@ function isInsideRoot(root, target) {
|
|
|
3306
3316
|
searchScopeHere: 'Current folder only',
|
|
3307
3317
|
searchIncludeIgnored: 'Also search usually ignored folders (.git stays out)',
|
|
3308
3318
|
searchFilesOnly: 'List file names only (no matching lines)',
|
|
3319
|
+
searchOutside: 'Also search the extra roots (up to 5)',
|
|
3309
3320
|
searchStop: 'Stop',
|
|
3310
3321
|
searchStats: 'Scanned {{files}} files · {{size}}',
|
|
3311
3322
|
searchStatsSkipped: '{{count}} skipped',
|
|
@@ -3464,6 +3475,13 @@ function isInsideRoot(root, target) {
|
|
|
3464
3475
|
outsideShown: 'Showing {{shown}} of {{total}}',
|
|
3465
3476
|
outsideMtime: 'Modified {{when}}',
|
|
3466
3477
|
outsideCeiling: 'Reached the {{size}} reading ceiling; download the file for the rest.',
|
|
3478
|
+
outsideDownload: 'Download to the default folder',
|
|
3479
|
+
outsideDownloading: 'Downloading…',
|
|
3480
|
+
outsideReveal: 'Open the folder',
|
|
3481
|
+
imageBroken: 'The image data could not be decoded; download it instead.',
|
|
3482
|
+
searchOutsideDropped: '{{count}} more extra roots were left out (the sweep stops at 5).',
|
|
3483
|
+
outsideDownloaded: 'Saved to {{path}}',
|
|
3484
|
+
tabsFull: 'Every file tab is in use ({{count}}). Close one and try again.',
|
|
3467
3485
|
linkOutside: 'That link points outside the workspace, so it was left alone: {{path}}',
|
|
3468
3486
|
linkFolder: 'That link is a folder; only files open here: {{path}}',
|
|
3469
3487
|
linkedTitle: 'Linked workspaces',
|
|
@@ -4451,6 +4469,8 @@ function isInsideRoot(root, target) {
|
|
|
4451
4469
|
'.rw-doc-body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow:auto;padding:10px}',
|
|
4452
4470
|
'.rw-outside-actions{display:flex;flex-direction:column;gap:8px;padding:4px 0}',
|
|
4453
4471
|
'.rw-outside-footer{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:8px 0 2px;border-top:1px solid var(--dsw-alias-border-l1);margin-top:8px;flex:none}',
|
|
4472
|
+
'.rw-toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:70;max-width:70vw;padding:8px 14px;border-radius:8px;background:var(--dsw-alias-bg-layer-3,#2c2c2e);color:var(--dsw-alias-label-primary);box-shadow:0 8px 24px rgba(0,0,0,.28);font-size:12px;line-height:18px}',
|
|
4473
|
+
'.rw-outside-image{display:block;max-width:100%;max-height:100%;margin:0 auto;object-fit:contain}',
|
|
4454
4474
|
'.rw-outside-text{margin:0;font-family:var(--dsw-alias-font-mono,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:1.5;white-space:pre-wrap;word-break:break-word;flex:1 1 auto;min-height:0}',
|
|
4455
4475
|
'.rw-doc-textarea{width:100%;min-height:260px;flex:1 1 auto;resize:none;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:10px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:12.5px/18px ui-monospace,"Cascadia Code",Consolas,monospace;outline:none;box-sizing:border-box}',
|
|
4456
4476
|
'.rw-doc-preview{max-width:920px;margin:0 auto;color:var(--dsw-alias-label-primary);font-size:14px;line-height:1.65;overflow-wrap:anywhere}',
|
|
@@ -7081,6 +7101,9 @@ function isInsideRoot(root, target) {
|
|
|
7081
7101
|
state.loading ? h('div', { className: 'rw-hint-row' }, Spinner(12), t('loading')) : null,
|
|
7082
7102
|
!state.loading && total === 0 ? h('div', { className: 'rw-hint-row' }, t('searchEmpty')) : null,
|
|
7083
7103
|
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t(reasonKey)) : null,
|
|
7104
|
+
!state.loading && Number(state.outsideDropped) > 0
|
|
7105
|
+
? h('div', { className: 'rw-hint-row' }, t('searchOutsideDropped', { count: String(state.outsideDropped) }))
|
|
7106
|
+
: null,
|
|
7084
7107
|
groups.map(function (group) {
|
|
7085
7108
|
if (group.entries.length === 0) return null;
|
|
7086
7109
|
return h('div', { key: group.side, className: 'rw-change-group' },
|
|
@@ -7290,6 +7313,17 @@ function isInsideRoot(root, target) {
|
|
|
7290
7313
|
// F6: the settings page can replay the card, so the flag is cleared and an
|
|
7291
7314
|
// event wakes the overlay instead of the user hunting for local storage.
|
|
7292
7315
|
var WELCOME_EVENT = 'dsh-linked-workspace:welcome-open';
|
|
7316
|
+
var TOAST_EVENT = 'dsh-linked-workspace:toast';
|
|
7317
|
+
|
|
7318
|
+
// A one-line message for things that happen outside any panel (a chat link
|
|
7319
|
+
// with every file slot taken, for instance).
|
|
7320
|
+
function notifyToast(key, vars) {
|
|
7321
|
+
try {
|
|
7322
|
+
window.dispatchEvent(new CustomEvent(TOAST_EVENT, { detail: { key: key, vars: vars || {} } }));
|
|
7323
|
+
} catch (error) {
|
|
7324
|
+
/* no window (tests) */
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7293
7327
|
var SHOW_HIDDEN_KEY = 'dsh-linked-workspace:show-hidden';
|
|
7294
7328
|
|
|
7295
7329
|
function readShowHidden() {
|
|
@@ -7361,7 +7395,34 @@ function rememberShowHidden(value) {
|
|
|
7361
7395
|
h('div', { className: 'rw-welcome-row-where' }, props.where));
|
|
7362
7396
|
}
|
|
7363
7397
|
|
|
7364
|
-
function
|
|
7398
|
+
function ToastHost(props) {
|
|
7399
|
+
var locale = useLocale(props.ctx);
|
|
7400
|
+
var t = useMemo(function () { return makeT(locale); }, [locale]);
|
|
7401
|
+
var stateRef = useState(null);
|
|
7402
|
+
var toast = stateRef[0];
|
|
7403
|
+
var setToast = stateRef[1];
|
|
7404
|
+
|
|
7405
|
+
useEffect(function () {
|
|
7406
|
+
function onToast(event) {
|
|
7407
|
+
var detail = (event && event.detail) || {};
|
|
7408
|
+
if (!detail.key) return;
|
|
7409
|
+
setToast({ text: t(detail.key, detail.vars || {}), at: Date.now() });
|
|
7410
|
+
}
|
|
7411
|
+
window.addEventListener(TOAST_EVENT, onToast);
|
|
7412
|
+
return function () { window.removeEventListener(TOAST_EVENT, onToast); };
|
|
7413
|
+
}, [t]);
|
|
7414
|
+
|
|
7415
|
+
useEffect(function () {
|
|
7416
|
+
if (!toast) return undefined;
|
|
7417
|
+
var timer = setTimeout(function () { setToast(null); }, 5000);
|
|
7418
|
+
return function () { clearTimeout(timer); };
|
|
7419
|
+
}, [toast && toast.at]);
|
|
7420
|
+
|
|
7421
|
+
if (!toast) return null;
|
|
7422
|
+
return h('div', { className: 'rw-toast', role: 'status', 'aria-live': 'polite' }, toast.text);
|
|
7423
|
+
}
|
|
7424
|
+
|
|
7425
|
+
function WelcomeCard(props) {
|
|
7365
7426
|
var locale = useLocale(props.ctx);
|
|
7366
7427
|
var t = useMemo(function () { return makeT(locale); }, [locale]);
|
|
7367
7428
|
var state = useState(function () { return !welcomeSeen(); });
|
|
@@ -8519,6 +8580,9 @@ function rememberShowHidden(value) {
|
|
|
8519
8580
|
var searchFilesOnlyState = useState(false);
|
|
8520
8581
|
var searchFilesOnly = searchFilesOnlyState[0];
|
|
8521
8582
|
var setSearchFilesOnly = searchFilesOnlyState[1];
|
|
8583
|
+
var searchOutsideState = useState(false);
|
|
8584
|
+
var searchOutside = searchOutsideState[0];
|
|
8585
|
+
var setSearchOutside = searchOutsideState[1];
|
|
8522
8586
|
var searchStatsState = useState(null);
|
|
8523
8587
|
var searchStats = searchStatsState[0];
|
|
8524
8588
|
var setSearchStats = searchStatsState[1];
|
|
@@ -9113,6 +9177,13 @@ function rememberShowHidden(value) {
|
|
|
9113
9177
|
// a tab that could only fail with lstat). Re-stat the open pane files
|
|
9114
9178
|
// whenever the trees are force-refreshed and drop the ones that are gone,
|
|
9115
9179
|
// so the panel heals itself instead of waiting for a read to fail.
|
|
9180
|
+
useEffect(function () {
|
|
9181
|
+
slotFullNotice = function () {
|
|
9182
|
+
showNotice('info', t('tabsFull', { count: String(FILE_SLOT_COUNT) }));
|
|
9183
|
+
};
|
|
9184
|
+
return function () { slotFullNotice = null; };
|
|
9185
|
+
}, [t, locale]);
|
|
9186
|
+
|
|
9116
9187
|
var openFileKeys = openFiles.map(function (file) { return file.key; }).join('|');
|
|
9117
9188
|
var staleProbeRef = useRef(0);
|
|
9118
9189
|
function probeOpenFiles() {
|
|
@@ -10296,6 +10367,7 @@ function rememberShowHidden(value) {
|
|
|
10296
10367
|
extra.ignoreCase = !searchCase;
|
|
10297
10368
|
extra.regex = searchRegex;
|
|
10298
10369
|
extra.includeIgnored = searchIncludeIgnored;
|
|
10370
|
+
extra.includeOutside = searchOutside;
|
|
10299
10371
|
extra.resultMode = searchFilesOnly ? 'files' : 'lines';
|
|
10300
10372
|
// One job id per sweep so 「停止」 can cancel it on the Host.
|
|
10301
10373
|
jobId = 'grep-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
@@ -10328,16 +10400,24 @@ function rememberShowHidden(value) {
|
|
|
10328
10400
|
if (contentMode) setSearchStats(stats);
|
|
10329
10401
|
setSearch({
|
|
10330
10402
|
loading: false,
|
|
10331
|
-
|
|
10403
|
+
// A hit outside the workspace gets its root as a prefix: otherwise
|
|
10404
|
+
// two files with the same name are indistinguishable, and the row
|
|
10405
|
+
// is the only place the user can see where it came from.
|
|
10406
|
+
remote: (results[0] && results[0].entries ? results[0].entries : []).map(function (entry) {
|
|
10407
|
+
if (!entry || !entry.outsideRoot) return entry;
|
|
10408
|
+
var tail = String(entry.outsideRoot).replace(/\/+$/, '').split('/').pop() || entry.outsideRoot;
|
|
10409
|
+
return Object.assign({}, entry, { relative: tail + '/' + String(entry.relative || '') });
|
|
10410
|
+
}),
|
|
10332
10411
|
local: results[1] && results[1].entries ? results[1].entries : [],
|
|
10333
10412
|
truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
|
|
10413
|
+
outsideDropped: Number(results[0] && results[0].outsideDropped) || 0,
|
|
10334
10414
|
truncatedReason: (results[0] && results[0].truncatedReason) || (results[1] && results[1].truncatedReason) || '',
|
|
10335
10415
|
error: (results[0] && results[0].error) || (results[1] && results[1].error) || null,
|
|
10336
10416
|
});
|
|
10337
10417
|
});
|
|
10338
10418
|
}, 320);
|
|
10339
10419
|
return function () { alive = false; clearTimeout(timer); };
|
|
10340
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly]);
|
|
10420
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly, searchOutside]);
|
|
10341
10421
|
|
|
10342
10422
|
if (!selected) {
|
|
10343
10423
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -10375,6 +10455,19 @@ function rememberShowHidden(value) {
|
|
|
10375
10455
|
hasLocal: selected.kind === 'linked',
|
|
10376
10456
|
showHidden: showHidden,
|
|
10377
10457
|
onOpen: function (side, filePath, entry) {
|
|
10458
|
+
if (entry && entry.outsideRoot) {
|
|
10459
|
+
// Outside the workspace: the claim turns this into the read-only
|
|
10460
|
+
// outside tab, the only view that can show such a path.
|
|
10461
|
+
var service = sidebarService(ctx);
|
|
10462
|
+
if (service && typeof service.openTab === 'function') {
|
|
10463
|
+
var snapshot = typeof service.getSnapshot === 'function' ? service.getSnapshot() : null;
|
|
10464
|
+
service.openTab(
|
|
10465
|
+
{ type: 'editor', path: filePath, title: basename(filePath) },
|
|
10466
|
+
snapshot && snapshot.sessionId ? { sessionId: snapshot.sessionId } : {},
|
|
10467
|
+
);
|
|
10468
|
+
}
|
|
10469
|
+
return;
|
|
10470
|
+
}
|
|
10378
10471
|
var line = entry && Number(entry.line) ? Number(entry.line) : 0;
|
|
10379
10472
|
openByMode(side, filePath, line > 0 ? { pinned: true, line: line } : undefined);
|
|
10380
10473
|
},
|
|
@@ -10638,6 +10731,13 @@ function rememberShowHidden(value) {
|
|
|
10638
10731
|
'aria-pressed': searchFilesOnly ? 'true' : 'false',
|
|
10639
10732
|
onClick: function () { setSearchFilesOnly(!searchFilesOnly); },
|
|
10640
10733
|
}, IconFile(11)),
|
|
10734
|
+
h('button', {
|
|
10735
|
+
type: 'button',
|
|
10736
|
+
className: 'rw-chip-btn' + (searchOutside ? ' is-on' : ''),
|
|
10737
|
+
title: t('searchOutside'),
|
|
10738
|
+
'aria-pressed': searchOutside ? 'true' : 'false',
|
|
10739
|
+
onClick: function () { setSearchOutside(!searchOutside); },
|
|
10740
|
+
}, '+/'),
|
|
10641
10741
|
search.loading && searchJobRef.current !== ''
|
|
10642
10742
|
? h('button', {
|
|
10643
10743
|
type: 'button',
|
|
@@ -10737,7 +10837,13 @@ function rememberShowHidden(value) {
|
|
|
10737
10837
|
? h('span', { className: 'rw-autopush-when' }, new Date(autoPush.lastPushAt).toLocaleTimeString())
|
|
10738
10838
|
: null)
|
|
10739
10839
|
: null,
|
|
10740
|
-
h('button', {
|
|
10840
|
+
h('button', {
|
|
10841
|
+
type: 'button',
|
|
10842
|
+
className: 'rw-icon-btn',
|
|
10843
|
+
title: t('toggleDirectory'),
|
|
10844
|
+
'aria-label': t('toggleDirectory'),
|
|
10845
|
+
onClick: function () { setDirectoryOpen(false); },
|
|
10846
|
+
}, IconClose(11))),
|
|
10741
10847
|
h('div', { className: 'rw-directory-body' }, body))
|
|
10742
10848
|
: null),
|
|
10743
10849
|
ctxMenu ? h(ContextMenu, { menu: ctxMenu, items: buildContextItems(ctxMenu), t: t, onClose: closeContextMenu }) : null,
|
|
@@ -10758,13 +10864,23 @@ function rememberShowHidden(value) {
|
|
|
10758
10864
|
var busyRef = useState(false);
|
|
10759
10865
|
var busy = busyRef[0];
|
|
10760
10866
|
var setBusy = busyRef[1];
|
|
10867
|
+
var downloadingRef = useState(false);
|
|
10868
|
+
var downloading = downloadingRef[0];
|
|
10869
|
+
var setDownloading = downloadingRef[1];
|
|
10870
|
+
var savedRef = useState('');
|
|
10871
|
+
var savedPath = savedRef[0];
|
|
10872
|
+
var setSavedPath = savedRef[1];
|
|
10761
10873
|
var noteRef = useState('');
|
|
10762
10874
|
var note = noteRef[0];
|
|
10763
10875
|
var setNote = noteRef[1];
|
|
10764
10876
|
// One page per click keeps a 200 MB log from freezing the tab, and the
|
|
10765
10877
|
// ceiling keeps the DOM bounded even if someone keeps clicking.
|
|
10766
|
-
var PAGE_BYTES =
|
|
10878
|
+
var PAGE_BYTES = 1024 * 1024;
|
|
10767
10879
|
var CEILING_BYTES = 4 * 1024 * 1024;
|
|
10880
|
+
var isImage = /\.(?:png|jpe?g|gif|webp|bmp|ico|avif|svg)$/i.test(filePath);
|
|
10881
|
+
var imageState = useState({ loading: isImage, error: null, data: null });
|
|
10882
|
+
var image = imageState[0];
|
|
10883
|
+
var setImage = imageState[1];
|
|
10768
10884
|
|
|
10769
10885
|
function read(from, append) {
|
|
10770
10886
|
var start = Math.max(0, Number(from) || 0);
|
|
@@ -10792,6 +10908,19 @@ function rememberShowHidden(value) {
|
|
|
10792
10908
|
|
|
10793
10909
|
useEffect(function () { read(0, false); }, [filePath, scope.kind, scope.id]);
|
|
10794
10910
|
|
|
10911
|
+
useEffect(function () {
|
|
10912
|
+
if (!isImage) return undefined;
|
|
10913
|
+
var alive = true;
|
|
10914
|
+
setImage({ loading: true, error: null, data: null });
|
|
10915
|
+
apiCall('media.readOutside', Object.assign({ path: filePath }, scopeParams(scope)))
|
|
10916
|
+
.then(function (result) {
|
|
10917
|
+
if (alive) setImage({ loading: false, error: null, data: result });
|
|
10918
|
+
}, function (error) {
|
|
10919
|
+
if (alive) setImage({ loading: false, error: error, data: null });
|
|
10920
|
+
});
|
|
10921
|
+
return function () { alive = false; };
|
|
10922
|
+
}, [filePath, scope.kind, scope.id, isImage]);
|
|
10923
|
+
|
|
10795
10924
|
function loadMore() {
|
|
10796
10925
|
if (!load.data || load.more) return;
|
|
10797
10926
|
read(Number(load.data.next) || 0, true);
|
|
@@ -10808,6 +10937,28 @@ function rememberShowHidden(value) {
|
|
|
10808
10937
|
} catch (error) { /* clipboard unavailable */ }
|
|
10809
10938
|
}
|
|
10810
10939
|
|
|
10940
|
+
function download() {
|
|
10941
|
+
if (downloading) return;
|
|
10942
|
+
setDownloading(true);
|
|
10943
|
+
setNote('');
|
|
10944
|
+
apiCall('fs.downloadOutside', Object.assign({ path: filePath }, scopeParams(scope))).then(function (result) {
|
|
10945
|
+
setDownloading(false);
|
|
10946
|
+
var saved = result && result.path ? String(result.path) : '';
|
|
10947
|
+
setSavedPath(saved);
|
|
10948
|
+
setNote(t('outsideDownloaded', { path: saved }));
|
|
10949
|
+
}, function (error) {
|
|
10950
|
+
setDownloading(false);
|
|
10951
|
+
setLoad(function (previous) {
|
|
10952
|
+
return { loading: false, more: false, error: error, data: previous.data };
|
|
10953
|
+
});
|
|
10954
|
+
});
|
|
10955
|
+
}
|
|
10956
|
+
|
|
10957
|
+
function revealSaved() {
|
|
10958
|
+
if (savedPath === '') return;
|
|
10959
|
+
apiCall('local.reveal', { path: savedPath }).catch(function () { /* the file manager may refuse */ });
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10811
10962
|
function addRoot() {
|
|
10812
10963
|
if (busy) return;
|
|
10813
10964
|
setBusy(true);
|
|
@@ -10835,6 +10986,13 @@ function rememberShowHidden(value) {
|
|
|
10835
10986
|
'aria-label': t('outsideCopyPath'),
|
|
10836
10987
|
onClick: copyPath,
|
|
10837
10988
|
}, t('outsideCopyPath')),
|
|
10989
|
+
h('button', {
|
|
10990
|
+
className: 'rw-btn rw-btn-sm',
|
|
10991
|
+
title: t('outsideDownload'),
|
|
10992
|
+
'aria-label': t('outsideDownload'),
|
|
10993
|
+
disabled: downloading,
|
|
10994
|
+
onClick: download,
|
|
10995
|
+
}, t(downloading ? 'outsideDownloading' : 'outsideDownload')),
|
|
10838
10996
|
h('button', {
|
|
10839
10997
|
className: 'rw-btn rw-btn-sm',
|
|
10840
10998
|
title: t('outsideReload'),
|
|
@@ -10869,6 +11027,12 @@ function rememberShowHidden(value) {
|
|
|
10869
11027
|
? h('span', { className: 'rw-hint' }, t('outsideMtime', { when: new Date(data.mtime).toLocaleString() }))
|
|
10870
11028
|
: null,
|
|
10871
11029
|
note ? h('span', { className: 'rw-hint' }, note) : null,
|
|
11030
|
+
savedPath !== '' ? h('button', {
|
|
11031
|
+
className: 'rw-btn rw-btn-sm rw-btn-ghost',
|
|
11032
|
+
title: t('outsideReveal'),
|
|
11033
|
+
'aria-label': t('outsideReveal'),
|
|
11034
|
+
onClick: revealSaved,
|
|
11035
|
+
}, t('outsideReveal')) : null,
|
|
10872
11036
|
canMore
|
|
10873
11037
|
? h('button', { className: 'rw-btn rw-btn-sm', disabled: load.more, onClick: loadMore },
|
|
10874
11038
|
load.more ? t('loading') : t('outsideLoadMore'))
|
|
@@ -10876,11 +11040,27 @@ function rememberShowHidden(value) {
|
|
|
10876
11040
|
Boolean(data.truncated) && !canMore
|
|
10877
11041
|
? h('span', { className: 'rw-hint' }, t('outsideCeiling', { size: formatBytes(CEILING_BYTES) }))
|
|
10878
11042
|
: null);
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
? h('div', { className: 'rw-outside-actions' }, h(
|
|
10882
|
-
:
|
|
10883
|
-
|
|
11043
|
+
if (isImage) {
|
|
11044
|
+
var picture = image.error
|
|
11045
|
+
? h('div', { className: 'rw-outside-actions' }, h(Banner, { kind: 'warn' }, messageOf(image.error, t, locale)))
|
|
11046
|
+
: image.data
|
|
11047
|
+
? h('img', {
|
|
11048
|
+
className: 'rw-outside-image',
|
|
11049
|
+
alt: basename(filePath),
|
|
11050
|
+
src: 'data:' + String(image.data.mime || 'application/octet-stream') + ';base64,' + String(image.data.base64 || ''),
|
|
11051
|
+
onError: function () {
|
|
11052
|
+
setImage({ loading: false, error: { code: 'FS_DECODE', message: t('imageBroken') }, data: null });
|
|
11053
|
+
},
|
|
11054
|
+
})
|
|
11055
|
+
: h('div', { className: 'rw-doc-loading' }, h('div', { className: 'rw-spinner' }), h('span', null, t('loading')));
|
|
11056
|
+
body = h('div', { className: 'rw-doc-body' }, picture, footer);
|
|
11057
|
+
} else {
|
|
11058
|
+
body = h('div', { className: 'rw-doc-body' },
|
|
11059
|
+
data.binary
|
|
11060
|
+
? h('div', { className: 'rw-outside-actions' }, h('div', { className: 'rw-hint' }, t('outsideBinary', { size: formatBytes(total) })))
|
|
11061
|
+
: h('pre', { className: 'rw-outside-text' }, typeof data.content === 'string' ? data.content : ''),
|
|
11062
|
+
footer);
|
|
11063
|
+
}
|
|
10884
11064
|
}
|
|
10885
11065
|
return h('div', { className: 'rw-editor-pane' }, toolbar, body);
|
|
10886
11066
|
}
|
|
@@ -14089,7 +14269,15 @@ function rememberShowHidden(value) {
|
|
|
14089
14269
|
var scope = sessionId !== '' ? { sessionId: sessionId } : {};
|
|
14090
14270
|
var opened = openOutsideFileTab(sidebar, scope, scoped, absolute) === true;
|
|
14091
14271
|
// With every slot busy the click is claimed but has nowhere to land: the
|
|
14092
|
-
// native viewer would only show "file not found", so report it as handled
|
|
14272
|
+
// native viewer would only show "file not found", so report it as handled
|
|
14273
|
+
// and let the panel say why nothing opened.
|
|
14274
|
+
if (!opened && slotFull === true) {
|
|
14275
|
+
if (typeof slotFullNotice === 'function') {
|
|
14276
|
+
try { slotFullNotice(); } catch (error) { /* the panel may be gone */ }
|
|
14277
|
+
} else {
|
|
14278
|
+
notifyToast('tabsFull', { count: String(FILE_SLOT_COUNT) });
|
|
14279
|
+
}
|
|
14280
|
+
}
|
|
14093
14281
|
return opened || slotFull === true;
|
|
14094
14282
|
}
|
|
14095
14283
|
|
|
@@ -14382,6 +14570,21 @@ function rememberShowHidden(value) {
|
|
|
14382
14570
|
console.error('[dsh-linked-workspace] welcome card registration failed', error && error.message ? error.message : error);
|
|
14383
14571
|
}
|
|
14384
14572
|
|
|
14573
|
+
try {
|
|
14574
|
+
ctx.slots.inject('shell.overlay', function () {
|
|
14575
|
+
return ctx.slots.register({
|
|
14576
|
+
name: 'shell.overlay',
|
|
14577
|
+
id: 'linked-workspace-toast',
|
|
14578
|
+
order: 81,
|
|
14579
|
+
label: function () { return makeT(readLocale(ctx))('tabsFull'); },
|
|
14580
|
+
}, function (props) {
|
|
14581
|
+
return h(ToastHost, Object.assign({}, props, { ctx: ctx }));
|
|
14582
|
+
});
|
|
14583
|
+
});
|
|
14584
|
+
} catch (error) {
|
|
14585
|
+
console.error('[dsh-linked-workspace] toast registration failed', error && error.message ? error.message : error);
|
|
14586
|
+
}
|
|
14587
|
+
|
|
14385
14588
|
try {
|
|
14386
14589
|
ctx.slots.inject('settings.section', function () {
|
|
14387
14590
|
return ctx.slots.register({
|
package/lib/index.js
CHANGED
|
@@ -147,6 +147,9 @@ const PEEK_LIMIT = 512 * 1024
|
|
|
147
147
|
const READ_CAP = 8 * 1024 * 1024
|
|
148
148
|
const MAX_WRITE_BYTES = 8 * 1024 * 1024
|
|
149
149
|
const MAX_MEDIA_BYTES = 24 * 1024 * 1024
|
|
150
|
+
// Inline previews carry a base64 copy inside a JS string, so they are capped
|
|
151
|
+
// well below the hard media limit; past this the viewer points at the download.
|
|
152
|
+
const MAX_INLINE_IMAGE_BYTES = 8 * 1024 * 1024
|
|
150
153
|
// ── remote command execution (0.17.0) ───────────────────────────────────────/** Longest command line accepted; anything longer is almost always a paste error. */
|
|
151
154
|
const EXEC_MAX_COMMAND = 8000
|
|
152
155
|
const EXEC_TIMEOUT_DEFAULT = 60_000
|
|
@@ -2856,7 +2859,9 @@ export function apply(ctx) {
|
|
|
2856
2859
|
const GREP_DEADLINE_MS = 5000
|
|
2857
2860
|
const GREP_DEADLINE_MAX = 10000
|
|
2858
2861
|
const GREP_PREVIEW_CHARS = 120
|
|
2859
|
-
|
|
2862
|
+
// How many extra roots one content search may sweep.
|
|
2863
|
+
const OUTSIDE_GREP_ROOTS = 5
|
|
2864
|
+
const GREP_MAX_QUERY = 200
|
|
2860
2865
|
|
|
2861
2866
|
// Path completion (`fs.references`) is about names, not contents, so it walks
|
|
2862
2867
|
// more entries but reads no files.
|
|
@@ -4265,6 +4270,27 @@ export function apply(ctx) {
|
|
|
4265
4270
|
}
|
|
4266
4271
|
},
|
|
4267
4272
|
|
|
4273
|
+
// Outside files were readable but not retrievable: the viewer says "download
|
|
4274
|
+
// it" at the ceiling and for binary files, so give it the same download the
|
|
4275
|
+
// workspace tree has.
|
|
4276
|
+
async 'fs.downloadOutside'(params = {}) {
|
|
4277
|
+
const { scope, target } = await extraTarget(params, 'downloadOutside')
|
|
4278
|
+
return await downloadRemotePath(scope.remote, target, downloadsFolder())
|
|
4279
|
+
},
|
|
4280
|
+
|
|
4281
|
+
// An image outside the workspace used to fall through to "binary file";
|
|
4282
|
+
// this is the same read the workspace preview uses, through the extra roots.
|
|
4283
|
+
async 'media.readOutside'(params = {}) {
|
|
4284
|
+
const { scope, target } = await extraTarget(params, 'readOutside')
|
|
4285
|
+
const mime = imageMimeOf(target)
|
|
4286
|
+
if (!mime) throw new ApiError('BAD_REQUEST', '该文件不是支持的图片格式')
|
|
4287
|
+
const stat = await scope.remote.stat(target)
|
|
4288
|
+
if (stat.type === 'dir') throw new ApiError('FS_IS_DIR', '目标是目录,无法预览')
|
|
4289
|
+
if (stat.size > MAX_INLINE_IMAGE_BYTES) throw new ApiError('FS_TOO_LARGE', '图片超过 8 MB,无法内联预览,请下载后查看')
|
|
4290
|
+
const read = await scope.remote.readFile(target, { maxBytes: MAX_INLINE_IMAGE_BYTES })
|
|
4291
|
+
return { path: target, size: stat.size, mtime: stat.mtime, mime, base64: read.data.toString('base64') }
|
|
4292
|
+
},
|
|
4293
|
+
|
|
4268
4294
|
async 'fs.writeOutside'(params = {}) {
|
|
4269
4295
|
const { scope, target } = await extraTarget(params, 'writeOutside')
|
|
4270
4296
|
if (typeof params.content !== 'string') throw new ApiError('BAD_REQUEST', 'content is required')
|
|
@@ -4713,6 +4739,31 @@ export function apply(ctx) {
|
|
|
4713
4739
|
// A link inside a remote document cannot be followed by the window that
|
|
4714
4740
|
// shows the preview: the SPA has no route for it and goes blank. External
|
|
4715
4741
|
// links are handed to the system browser instead.
|
|
4742
|
+
async 'local.reveal'(params = {}) {
|
|
4743
|
+
const rawPath = typeof params.path === 'string' ? params.path.trim() : ''
|
|
4744
|
+
if (rawPath === '' || !isAbsolute(rawPath)) throw new ApiError('BAD_REQUEST', '本地路径必须是绝对路径')
|
|
4745
|
+
const target = resolve(rawPath)
|
|
4746
|
+
let info
|
|
4747
|
+
try {
|
|
4748
|
+
info = await fsStat(target)
|
|
4749
|
+
} catch (error) {
|
|
4750
|
+
throw mapLocalFsError(error)
|
|
4751
|
+
}
|
|
4752
|
+
const folder = info.isDirectory() ? target : dirname(target)
|
|
4753
|
+
const command = process.platform === 'win32' ? 'explorer.exe' : process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
4754
|
+
const args = process.platform === 'win32' && !info.isDirectory() ? ['/select,', target] : [info.isDirectory() ? target : folder]
|
|
4755
|
+
let started = false
|
|
4756
|
+
try {
|
|
4757
|
+
const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsHide: true })
|
|
4758
|
+
child.unref()
|
|
4759
|
+
started = true
|
|
4760
|
+
} catch (error) {
|
|
4761
|
+
started = false
|
|
4762
|
+
}
|
|
4763
|
+
if (!started) throw new ApiError('INTERNAL', '无法打开文件管理器')
|
|
4764
|
+
return { opened: true, folder }
|
|
4765
|
+
},
|
|
4766
|
+
|
|
4716
4767
|
async 'local.openUrl'(params = {}) {
|
|
4717
4768
|
const raw = typeof params.url === 'string' ? params.url.trim() : ''
|
|
4718
4769
|
if (!/^(?:https?|mailto|tel):/i.test(raw)) throw new ApiError('BAD_REQUEST', '只支持 http、https、mailto 与 tel 链接')
|
|
@@ -4837,7 +4888,61 @@ export function apply(ctx) {
|
|
|
4837
4888
|
timeoutMs: params.timeoutMs,
|
|
4838
4889
|
job: beginGrepJob(params.jobId),
|
|
4839
4890
|
}
|
|
4840
|
-
if (side === 'remote')
|
|
4891
|
+
if (side === 'remote') {
|
|
4892
|
+
const found = await contentSearchRemote(scope.remote, scope.root, query, maxResults, options)
|
|
4893
|
+
if (params.includeOutside !== true) return found
|
|
4894
|
+
const allRoots = extraRoots()
|
|
4895
|
+
if (allRoots.length === 0) return found
|
|
4896
|
+
// "Only this folder" has to mean the same relative folder under every
|
|
4897
|
+
// extra root; a root that has no such folder is skipped, not failed.
|
|
4898
|
+
const relative = typeof options.path === 'string' ? options.path.trim().replace(/^\/+/, '') : ''
|
|
4899
|
+
const roots = allRoots.slice(0, OUTSIDE_GREP_ROOTS)
|
|
4900
|
+
const merged = found.entries.slice()
|
|
4901
|
+
let truncated = found.truncated
|
|
4902
|
+
let scanned = found.scannedFiles
|
|
4903
|
+
let outsideSkipped = 0
|
|
4904
|
+
for (const root of roots) {
|
|
4905
|
+
if (merged.length >= maxResults) {
|
|
4906
|
+
truncated = true
|
|
4907
|
+
break
|
|
4908
|
+
}
|
|
4909
|
+
if (relative !== '') {
|
|
4910
|
+
let info
|
|
4911
|
+
try {
|
|
4912
|
+
info = await scope.remote.stat(posix.join(root, relative))
|
|
4913
|
+
} catch (error) {
|
|
4914
|
+
outsideSkipped += 1
|
|
4915
|
+
continue
|
|
4916
|
+
}
|
|
4917
|
+
if (info.type !== 'dir') {
|
|
4918
|
+
outsideSkipped += 1
|
|
4919
|
+
continue
|
|
4920
|
+
}
|
|
4921
|
+
}
|
|
4922
|
+
const part = await contentSearchRemote(scope.remote, root, query, maxResults - merged.length, options)
|
|
4923
|
+
scanned += part.scannedFiles
|
|
4924
|
+
if (part.truncated) truncated = true
|
|
4925
|
+
for (const entry of part.entries) {
|
|
4926
|
+
merged.push(Object.assign({}, entry, {
|
|
4927
|
+
relative: entry.path.startsWith(root + '/') ? entry.path.slice(root.length + 1) : entry.relative,
|
|
4928
|
+
outsideRoot: root,
|
|
4929
|
+
}))
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
return {
|
|
4933
|
+
ok: true,
|
|
4934
|
+
query,
|
|
4935
|
+
entries: merged.slice(0, maxResults),
|
|
4936
|
+
truncated,
|
|
4937
|
+
truncatedReason: truncated ? (found.truncatedReason || 'results') : '',
|
|
4938
|
+
scannedFiles: scanned,
|
|
4939
|
+
scannedBytes: found.scannedBytes,
|
|
4940
|
+
skippedFiles: found.skippedFiles,
|
|
4941
|
+
outsideRoots: roots.length,
|
|
4942
|
+
outsideDropped: Math.max(0, allRoots.length - roots.length),
|
|
4943
|
+
outsideSkipped,
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4841
4946
|
if (scope.kind !== 'linked') throw new ApiError('BAD_REQUEST', '只有联动工作区有本地目录')
|
|
4842
4947
|
return contentSearchLocal(scope.record.localPath, query, maxResults, options)
|
|
4843
4948
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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",
|