dsh-linked-workspace 0.31.0 → 0.33.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 +31 -0
- package/docs/API.md +4 -2
- package/docs/VERIFY.md +28 -0
- package/lib/client.js +298 -48
- package/lib/index.js +64 -3
- package/lib/ssh.js +14 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.33.0 — 2026-11-30
|
|
4
|
+
|
|
5
|
+
- **工作区外的文件终于能拿出来、图片也能看了**:只读标签的工具栏多了「下载到默认文件夹」(落到
|
|
6
|
+
`~/Downloads`,文件名重名自动加序号),工作区外的 PNG/JPEG/GIF/WebP 等直接在面板里内联预览 ——
|
|
7
|
+
这两条正是原先「文件过大请下载」「二进制文件无法预览」两句提示指向、却无处可去的死路。
|
|
8
|
+
- **读取上限与二进制的说明不再指向空气**:到达 4 MB 上限或遇到不支持的类型时,同一排按钮里就有下载。
|
|
9
|
+
- **一页 1 MB**:4.6 MB 的文件从「14 次点击」变成 5 次;上限仍是 4 MB,DOM 不会失控。
|
|
10
|
+
- **标签位排满会说明原因**:24 个位置全被占用时给一条提示,不再让点击无声消失。
|
|
11
|
+
- **内容搜索可以覆盖额外根目录**:搜索栏多一个「+/」开关(最多 5 个前缀),命中行以根目录名作前缀,
|
|
12
|
+
点一下照样落进工作区外的只读标签。默认关闭,不开就不影响原有搜索速度。
|
|
13
|
+
- **Host**:新增 `fs.downloadOutside`、`media.readOutside`;`fs.grep` 新增 `includeOutside`,
|
|
14
|
+
结果条目带 `outsideRoot`。
|
|
15
|
+
|
|
16
|
+
## 0.32.0 — 2026-11-29
|
|
17
|
+
|
|
18
|
+
- **Working outside the workspace is now readable, not truncated**: the read-only tab pages through a file
|
|
19
|
+
256 KiB at a time ("Load more" continues where the last window stopped), the footer shows "Showing X of Y"
|
|
20
|
+
plus the remote mtime, and it offers "Reload" and "Copy absolute address". Hitting the 4 MB ceiling says so
|
|
21
|
+
and points at downloading the file. Before this, only the first window was reachable and the banner
|
|
22
|
+
reported the file size as if it were what had been shown.
|
|
23
|
+
- **A full tab table no longer swallows the click**: file slots went from 12 to 24, and once they are all
|
|
24
|
+
taken a chat link is claimed instead of landing on the native "file not found" page (`slotFull`). Slot
|
|
25
|
+
recycling is not possible on this platform: the sidebar binds a tab kind to one tab for good, a closed kind
|
|
26
|
+
cannot be reopened, and `updateTab` repoints the address without re-rendering the plugin view.
|
|
27
|
+
- **Two roots with the same tail no longer steal each other's links**: a chat link is matched against the
|
|
28
|
+
session's own host first, then against the longest prefix.
|
|
29
|
+
- **The directory toolbar reads well with a screen reader**: its 12 icon buttons mirror their `title` into
|
|
30
|
+
`aria-label`.
|
|
31
|
+
- **Host**: `fs.readOutside` accepts `offset` and reports `returned` (paged reads), and `lib/ssh.js`'s
|
|
32
|
+
`readFile` can start anywhere in the file.
|
|
33
|
+
|
|
3
34
|
## 0.31.0 — 2026-11-28
|
|
4
35
|
|
|
5
36
|
- Closing a chat-linked tab no longer brings it back, and activating another native tab no longer
|
package/docs/API.md
CHANGED
|
@@ -59,7 +59,8 @@ scope root, or absolute inside it.
|
|
|
59
59
|
| `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 |
|
|
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
|
-
| `fs.readOutside` | `{ linkedId?, remoteId?, path, maxBytes? }` | `{ path, size, mtime, binary, truncated, content }` (
|
|
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 and 24 MB cap as `media.read`, read through the extra-roots gate) |
|
|
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) |
|
|
@@ -107,7 +109,7 @@ scope root, or absolute inside it.
|
|
|
107
109
|
| `skills.read` | `{ linkedId, name }` | `{ name, description, content, path }` |
|
|
108
110
|
| `git.status` | `{ linkedId?/remoteId?, side: 'remote'|'local' }` | `{ ok, repo, root, branch, changes, error? }` (remote workspaces only support `side: 'remote'`) |
|
|
109
111
|
| `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) |
|
|
112
|
+
| `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`) |
|
|
111
113
|
| `fs.grepCancel` | `{ jobId }` | `{ cancelled }` (marks the job started by `fs.grep`'s `jobId`; the Host checks it between files and answers `truncatedReason: 'cancelled'`) |
|
|
112
114
|
| `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
115
|
| `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,33 @@
|
|
|
1
1
|
# Manual verification checklist
|
|
2
2
|
|
|
3
|
+
## 工作区外的下载、图片与搜索(未发布)
|
|
4
|
+
|
|
5
|
+
1. 联动工作区根目录在 `/shared_data_ssd1/huangjh`,额外根目录里放 `/shared_data_hdd1/huangjh/x/pic.png`(≥ 1 像素真图)
|
|
6
|
+
与 `big.txt`(≥ 4.5 MB),并在设置里允许该前缀。点击两个文件的聊天链接。
|
|
7
|
+
2. `pic.png`:面板里直接显示图片(不是「二进制文件」字样),工具栏有「下载到默认文件夹」。
|
|
8
|
+
3. `big.txt`:首屏约 1 MB,页脚「已显示 1.0 MB,共 4.6 MB」;点「加载更多」5 次左右到 4 MB 后提示已达上限。
|
|
9
|
+
4. 点「下载到默认文件夹」:页脚出现「已下载到 …\\Downloads\\big.txt」,本地文件大小与远端一致。
|
|
10
|
+
5. 内容搜索里打开「+/」(连额外根目录一起搜),搜 `needle-outside`:命中行以根目录名作前缀,
|
|
11
|
+
点一下打开的是带「工作区外」徽标的只读标签,不出现原生「文件不存在」。
|
|
12
|
+
6. 关掉该开关再搜一次:额外根目录里的文件不再出现。
|
|
13
|
+
7. 连续用聊天链接打开 25 个不同的工作区外文件:第 25 个给一条「文件标签位已满(24 个)」提示,
|
|
14
|
+
不出现原生报错页(需要先清掉已有标签再试)。
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 工作区外的只读视图与标签位(未发布)
|
|
18
|
+
|
|
19
|
+
1. 联动工作区根目录在 `/shared_data_ssd1/huangjh`,准备一个 `/shared_data_hdd1/huangjh/big.jsonl`(≥ 300 KB,
|
|
20
|
+
且已在「额外根目录」里允许):在会话里点它的链接 → 出现「工作区外」只读标签。
|
|
21
|
+
2. 首屏显示 256 KB,页脚为「已显示 256 KB,共 374 KB」+「修改于 …」;点「加载更多」→ 显示全部、
|
|
22
|
+
页脚变成「已显示 374 KB,共 374 KB」且按钮消失。
|
|
23
|
+
3. 点「重新加载」→ 回到首屏;点「复制绝对地址」→ 剪贴板里是完整远端路径,页脚出现「已复制:…」。
|
|
24
|
+
4. 打开超过 4 MB 的工作区外文件:走到底后提示已达读取上限,不再无限追加。
|
|
25
|
+
5. 依次点开 25 条不同的聊天文件链接:前 24 条各占一个文件标签;第 25 条不会出现原生「文件不存在」页
|
|
26
|
+
(点击被接管,但没有空位可放)。
|
|
27
|
+
6. 目录栏悬停任意图标按钮:`aria-label` 与可见提示一致(读屏可念出)。
|
|
28
|
+
7. 两个工作区根目录尾段同名(如都是 `/x/huangjh`)时,点其中一个会话里的链接应落回该会话自己的主机。
|
|
29
|
+
|
|
30
|
+
|
|
3
31
|
Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-workspace-ui`; client changes load with **应用 → 重新加载界面** (a full restart is only needed after re-installing the package). Then verify:
|
|
4
32
|
|
|
5
33
|
## 工作区外的聊天链接(未发布)
|
package/lib/client.js
CHANGED
|
@@ -2351,8 +2351,19 @@ function isInsideRoot(root, target) {
|
|
|
2351
2351
|
fileSlotByKind.delete(kind);
|
|
2352
2352
|
}
|
|
2353
2353
|
|
|
2354
|
+
// A slot is a one-shot slot: better-sidebar binds a tab kind to its one tab,
|
|
2355
|
+
// a closed kind can never be reopened, and updateTab repoints the address
|
|
2356
|
+
// without re-rendering the plugin view (so the previous file would stay on
|
|
2357
|
+
// screen). A full table is therefore reported as "full" and the caller
|
|
2358
|
+
// falls back, instead of showing the wrong file under a new title.
|
|
2359
|
+
var slotFull = false;
|
|
2360
|
+
// Set by the directory panel so a swallowed click can explain itself.
|
|
2361
|
+
var slotFullNotice = null;
|
|
2362
|
+
|
|
2354
2363
|
function remoteFileSlotFor(key) {
|
|
2355
|
-
|
|
2364
|
+
slotFull = false;
|
|
2365
|
+
var taken = fileSlotByKey.get(key);
|
|
2366
|
+
if (taken !== undefined) return taken;
|
|
2356
2367
|
for (var index = 1; index <= FILE_SLOT_COUNT; index += 1) {
|
|
2357
2368
|
var kind = FILE_SLOT_PREFIX + index;
|
|
2358
2369
|
if (!fileSlotByKind.has(kind)) {
|
|
@@ -2361,9 +2372,23 @@ function isInsideRoot(root, target) {
|
|
|
2361
2372
|
return kind;
|
|
2362
2373
|
}
|
|
2363
2374
|
}
|
|
2375
|
+
slotFull = true;
|
|
2364
2376
|
return undefined;
|
|
2365
2377
|
}
|
|
2366
2378
|
|
|
2379
|
+
// Open a file into the slot its key owns. Slots are one-shot (see above), so
|
|
2380
|
+
// there is no recycle branch here: a new key gets a free slot or nothing.
|
|
2381
|
+
function openFileSlotTab(sidebar, scope, kind, seed) {
|
|
2382
|
+
var known = nativeTabKeys(sidebar);
|
|
2383
|
+
try {
|
|
2384
|
+
sidebar.openTab(seed(kind), scope);
|
|
2385
|
+
} catch (error) {
|
|
2386
|
+
return false;
|
|
2387
|
+
}
|
|
2388
|
+
claimNewNativeTabs(sidebar, known);
|
|
2389
|
+
return true;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2367
2392
|
// A link inside a remote document has to become an absolute path on the same
|
|
2368
2393
|
// host, and the panel that owns the tab does not carry the workspace root.
|
|
2369
2394
|
// The two lists change rarely, so one lookup serves every click for 30 s.
|
|
@@ -2431,23 +2456,22 @@ function isInsideRoot(root, target) {
|
|
|
2431
2456
|
}, 0);
|
|
2432
2457
|
}
|
|
2433
2458
|
|
|
2434
|
-
function openRemoteFileTab(sidebar, scope, source, filePath) {
|
|
2459
|
+
function openRemoteFileTab(sidebar, scope, source, filePath, options) {
|
|
2435
2460
|
if (!sidebar || typeof sidebar.openTab !== 'function') return false;
|
|
2436
2461
|
var key = scopeKeyOf(sourceScopeOf(source)) + ':' + filePath;
|
|
2437
2462
|
var kind = remoteFileSlotFor(key);
|
|
2438
2463
|
if (kind === undefined) return false;
|
|
2439
|
-
var known = nativeTabKeys(sidebar);
|
|
2440
2464
|
// The slot id is the identity, so asking for the same file again focuses
|
|
2441
2465
|
// the tab that is already open instead of stacking a second one.
|
|
2442
|
-
sidebar
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2466
|
+
return openFileSlotTab(sidebar, scope, kind, function (kind) {
|
|
2467
|
+
return {
|
|
2468
|
+
type: kind,
|
|
2469
|
+
id: kind,
|
|
2470
|
+
title: basename(filePath),
|
|
2471
|
+
path: filePath,
|
|
2472
|
+
meta: sourceMetaOf(source),
|
|
2473
|
+
};
|
|
2474
|
+
});
|
|
2451
2475
|
}
|
|
2452
2476
|
|
|
2453
2477
|
// The folder that has to be allow-listed before an outside path is readable.
|
|
@@ -2474,10 +2498,9 @@ function isInsideRoot(root, target) {
|
|
|
2474
2498
|
if (kind === undefined) return false;
|
|
2475
2499
|
var meta = sourceMetaOf(source);
|
|
2476
2500
|
meta.outside = true;
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
return true;
|
|
2501
|
+
return openFileSlotTab(sidebar, scope, kind, function (kind) {
|
|
2502
|
+
return { type: kind, id: kind, title: basename(filePath), path: filePath, meta: meta };
|
|
2503
|
+
});
|
|
2481
2504
|
}
|
|
2482
2505
|
|
|
2483
2506
|
// Chat artifacts live outside our tabs, so opening one has to travel
|
|
@@ -2509,7 +2532,7 @@ function isInsideRoot(root, target) {
|
|
|
2509
2532
|
|
|
2510
2533
|
var FILE_TAB_TYPE = 'dsh-linked-workspace:file';
|
|
2511
2534
|
var FILE_SLOT_PREFIX = 'dsh-linked-workspace:file:';
|
|
2512
|
-
var FILE_SLOT_COUNT =
|
|
2535
|
+
var FILE_SLOT_COUNT = 24;
|
|
2513
2536
|
// DSH's native right sidebar deduplicates ordinary page tabs by kind, so a
|
|
2514
2537
|
// second file opened under one kind would focus the first tab. Each file
|
|
2515
2538
|
// slot is its own hidden page kind; this map hands a free slot to a file and
|
|
@@ -2669,6 +2692,7 @@ function isInsideRoot(root, target) {
|
|
|
2669
2692
|
searchScopeHere: '只搜当前目录',
|
|
2670
2693
|
searchIncludeIgnored: '连通常忽略的目录一起搜(.git 仍然排除)',
|
|
2671
2694
|
searchFilesOnly: '只列文件名(不显示命中行)',
|
|
2695
|
+
searchOutside: '连额外根目录一起搜(最多 5 个)',
|
|
2672
2696
|
searchStop: '停止',
|
|
2673
2697
|
searchStats: '扫描 {{files}} 个文件 · {{size}}',
|
|
2674
2698
|
searchStatsSkipped: '跳过 {{count}} 个',
|
|
@@ -2821,7 +2845,15 @@ function isInsideRoot(root, target) {
|
|
|
2821
2845
|
outsideAddRoot: '把 {{dir}} 加入额外根目录并打开',
|
|
2822
2846
|
outsideBadge: '工作区外',
|
|
2823
2847
|
outsideBinary: '二进制文件,无法在这里预览({{size}})。',
|
|
2824
|
-
|
|
2848
|
+
outsideReload: '重新加载',
|
|
2849
|
+
outsideCopyPath: '复制绝对地址',
|
|
2850
|
+
outsideLoadMore: '加载更多',
|
|
2851
|
+
outsideShown: '已显示 {{shown}},共 {{total}}',
|
|
2852
|
+
outsideMtime: '修改于 {{when}}',
|
|
2853
|
+
outsideCeiling: '已达到 {{size}} 的读取上限,剩下的内容请下载后查看。',
|
|
2854
|
+
outsideDownload: '下载到默认文件夹',
|
|
2855
|
+
outsideDownloaded: '已下载到 {{path}}',
|
|
2856
|
+
tabsFull: '文件标签位已满({{count}} 个)。先关掉一个再点。',
|
|
2825
2857
|
linkOutside: '这个链接指向工作区之外,没有打开:{{path}}',
|
|
2826
2858
|
linkFolder: '这是文件夹链接,这里只打开文件:{{path}}',
|
|
2827
2859
|
linkedTitle: '联动工作区',
|
|
@@ -3280,6 +3312,7 @@ function isInsideRoot(root, target) {
|
|
|
3280
3312
|
searchScopeHere: 'Current folder only',
|
|
3281
3313
|
searchIncludeIgnored: 'Also search usually ignored folders (.git stays out)',
|
|
3282
3314
|
searchFilesOnly: 'List file names only (no matching lines)',
|
|
3315
|
+
searchOutside: 'Also search the extra roots (up to 5)',
|
|
3283
3316
|
searchStop: 'Stop',
|
|
3284
3317
|
searchStats: 'Scanned {{files}} files · {{size}}',
|
|
3285
3318
|
searchStatsSkipped: '{{count}} skipped',
|
|
@@ -3432,7 +3465,15 @@ function isInsideRoot(root, target) {
|
|
|
3432
3465
|
outsideAddRoot: 'Add {{dir}} to the extra roots and open it',
|
|
3433
3466
|
outsideBadge: 'Outside',
|
|
3434
3467
|
outsideBinary: 'Binary file, so it cannot be previewed here ({{size}}).',
|
|
3435
|
-
|
|
3468
|
+
outsideReload: 'Reload',
|
|
3469
|
+
outsideCopyPath: 'Copy absolute address',
|
|
3470
|
+
outsideLoadMore: 'Load more',
|
|
3471
|
+
outsideShown: 'Showing {{shown}} of {{total}}',
|
|
3472
|
+
outsideMtime: 'Modified {{when}}',
|
|
3473
|
+
outsideCeiling: 'Reached the {{size}} reading ceiling; download the file for the rest.',
|
|
3474
|
+
outsideDownload: 'Download to the default folder',
|
|
3475
|
+
outsideDownloaded: 'Saved to {{path}}',
|
|
3476
|
+
tabsFull: 'Every file tab is in use ({{count}}). Close one and try again.',
|
|
3436
3477
|
linkOutside: 'That link points outside the workspace, so it was left alone: {{path}}',
|
|
3437
3478
|
linkFolder: 'That link is a folder; only files open here: {{path}}',
|
|
3438
3479
|
linkedTitle: 'Linked workspaces',
|
|
@@ -4418,6 +4459,10 @@ function isInsideRoot(root, target) {
|
|
|
4418
4459
|
'.rw-doc{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;min-width:0;background:var(--dsw-alias-bg-base)}',
|
|
4419
4460
|
'.rw-doc-toolbar{display:flex;align-items:center;gap:6px;padding:6px 8px;border-bottom:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);flex:none;flex-wrap:wrap}',
|
|
4420
4461
|
'.rw-doc-body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow:auto;padding:10px}',
|
|
4462
|
+
'.rw-outside-actions{display:flex;flex-direction:column;gap:8px;padding:4px 0}',
|
|
4463
|
+
'.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}',
|
|
4464
|
+
'.rw-outside-image{display:block;max-width:100%;max-height:100%;margin:0 auto;object-fit:contain}',
|
|
4465
|
+
'.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}',
|
|
4421
4466
|
'.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}',
|
|
4422
4467
|
'.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}',
|
|
4423
4468
|
'.rw-doc-preview h1,.rw-doc-preview h2,.rw-doc-preview h3{line-height:1.3;margin:1em 0 .5em}',
|
|
@@ -6879,7 +6924,18 @@ function isInsideRoot(root, target) {
|
|
|
6879
6924
|
|
|
6880
6925
|
function close() { setMenu(null); }
|
|
6881
6926
|
|
|
6882
|
-
|
|
6927
|
+
var toolbarRef = useRef(null);
|
|
6928
|
+
useEffect(function () {
|
|
6929
|
+
var node = toolbarRef.current;
|
|
6930
|
+
if (!node || typeof node.querySelectorAll !== 'function') return;
|
|
6931
|
+
var buttons = node.querySelectorAll('button.rw-icon-btn');
|
|
6932
|
+
for (var index = 0; index < buttons.length; index += 1) {
|
|
6933
|
+
if (buttons[index].getAttribute('aria-label')) continue;
|
|
6934
|
+
buttons[index].setAttribute('aria-label', buttons[index].getAttribute('title') || '');
|
|
6935
|
+
}
|
|
6936
|
+
});
|
|
6937
|
+
|
|
6938
|
+
return h('div', { className: 'rw-linked-toolbar', ref: toolbarRef },
|
|
6883
6939
|
h('span', { className: 'rw-tree-toolbar-title' }, props.title || t('tabTitle')),
|
|
6884
6940
|
h('div', { className: 'rw-actions', style: { marginLeft: 'auto', gap: 2 } },
|
|
6885
6941
|
h('button', {
|
|
@@ -8474,6 +8530,9 @@ function rememberShowHidden(value) {
|
|
|
8474
8530
|
var searchFilesOnlyState = useState(false);
|
|
8475
8531
|
var searchFilesOnly = searchFilesOnlyState[0];
|
|
8476
8532
|
var setSearchFilesOnly = searchFilesOnlyState[1];
|
|
8533
|
+
var searchOutsideState = useState(false);
|
|
8534
|
+
var searchOutside = searchOutsideState[0];
|
|
8535
|
+
var setSearchOutside = searchOutsideState[1];
|
|
8477
8536
|
var searchStatsState = useState(null);
|
|
8478
8537
|
var searchStats = searchStatsState[0];
|
|
8479
8538
|
var setSearchStats = searchStatsState[1];
|
|
@@ -9068,6 +9127,13 @@ function rememberShowHidden(value) {
|
|
|
9068
9127
|
// a tab that could only fail with lstat). Re-stat the open pane files
|
|
9069
9128
|
// whenever the trees are force-refreshed and drop the ones that are gone,
|
|
9070
9129
|
// so the panel heals itself instead of waiting for a read to fail.
|
|
9130
|
+
useEffect(function () {
|
|
9131
|
+
slotFullNotice = function () {
|
|
9132
|
+
showNotice('info', t('tabsFull', { count: String(FILE_SLOT_COUNT) }));
|
|
9133
|
+
};
|
|
9134
|
+
return function () { slotFullNotice = null; };
|
|
9135
|
+
}, [t, locale]);
|
|
9136
|
+
|
|
9071
9137
|
var openFileKeys = openFiles.map(function (file) { return file.key; }).join('|');
|
|
9072
9138
|
var staleProbeRef = useRef(0);
|
|
9073
9139
|
function probeOpenFiles() {
|
|
@@ -10251,6 +10317,7 @@ function rememberShowHidden(value) {
|
|
|
10251
10317
|
extra.ignoreCase = !searchCase;
|
|
10252
10318
|
extra.regex = searchRegex;
|
|
10253
10319
|
extra.includeIgnored = searchIncludeIgnored;
|
|
10320
|
+
extra.includeOutside = searchOutside;
|
|
10254
10321
|
extra.resultMode = searchFilesOnly ? 'files' : 'lines';
|
|
10255
10322
|
// One job id per sweep so 「停止」 can cancel it on the Host.
|
|
10256
10323
|
jobId = 'grep-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
|
|
@@ -10283,7 +10350,14 @@ function rememberShowHidden(value) {
|
|
|
10283
10350
|
if (contentMode) setSearchStats(stats);
|
|
10284
10351
|
setSearch({
|
|
10285
10352
|
loading: false,
|
|
10286
|
-
|
|
10353
|
+
// A hit outside the workspace gets its root as a prefix: otherwise
|
|
10354
|
+
// two files with the same name are indistinguishable, and the row
|
|
10355
|
+
// is the only place the user can see where it came from.
|
|
10356
|
+
remote: (results[0] && results[0].entries ? results[0].entries : []).map(function (entry) {
|
|
10357
|
+
if (!entry || !entry.outsideRoot) return entry;
|
|
10358
|
+
var tail = String(entry.outsideRoot).replace(/\/+$/, '').split('/').pop() || entry.outsideRoot;
|
|
10359
|
+
return Object.assign({}, entry, { relative: tail + '/' + String(entry.relative || '') });
|
|
10360
|
+
}),
|
|
10287
10361
|
local: results[1] && results[1].entries ? results[1].entries : [],
|
|
10288
10362
|
truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
|
|
10289
10363
|
truncatedReason: (results[0] && results[0].truncatedReason) || (results[1] && results[1].truncatedReason) || '',
|
|
@@ -10292,7 +10366,7 @@ function rememberShowHidden(value) {
|
|
|
10292
10366
|
});
|
|
10293
10367
|
}, 320);
|
|
10294
10368
|
return function () { alive = false; clearTimeout(timer); };
|
|
10295
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly]);
|
|
10369
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere, searchIncludeIgnored, searchFilesOnly, searchOutside]);
|
|
10296
10370
|
|
|
10297
10371
|
if (!selected) {
|
|
10298
10372
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -10330,6 +10404,19 @@ function rememberShowHidden(value) {
|
|
|
10330
10404
|
hasLocal: selected.kind === 'linked',
|
|
10331
10405
|
showHidden: showHidden,
|
|
10332
10406
|
onOpen: function (side, filePath, entry) {
|
|
10407
|
+
if (entry && entry.outsideRoot) {
|
|
10408
|
+
// Outside the workspace: the claim turns this into the read-only
|
|
10409
|
+
// outside tab, the only view that can show such a path.
|
|
10410
|
+
var service = sidebarService(ctx);
|
|
10411
|
+
if (service && typeof service.openTab === 'function') {
|
|
10412
|
+
var snapshot = typeof service.getSnapshot === 'function' ? service.getSnapshot() : null;
|
|
10413
|
+
service.openTab(
|
|
10414
|
+
{ type: 'editor', path: filePath, title: basename(filePath) },
|
|
10415
|
+
snapshot && snapshot.sessionId ? { sessionId: snapshot.sessionId } : {},
|
|
10416
|
+
);
|
|
10417
|
+
}
|
|
10418
|
+
return;
|
|
10419
|
+
}
|
|
10333
10420
|
var line = entry && Number(entry.line) ? Number(entry.line) : 0;
|
|
10334
10421
|
openByMode(side, filePath, line > 0 ? { pinned: true, line: line } : undefined);
|
|
10335
10422
|
},
|
|
@@ -10593,6 +10680,13 @@ function rememberShowHidden(value) {
|
|
|
10593
10680
|
'aria-pressed': searchFilesOnly ? 'true' : 'false',
|
|
10594
10681
|
onClick: function () { setSearchFilesOnly(!searchFilesOnly); },
|
|
10595
10682
|
}, IconFile(11)),
|
|
10683
|
+
h('button', {
|
|
10684
|
+
type: 'button',
|
|
10685
|
+
className: 'rw-chip-btn' + (searchOutside ? ' is-on' : ''),
|
|
10686
|
+
title: t('searchOutside'),
|
|
10687
|
+
'aria-pressed': searchOutside ? 'true' : 'false',
|
|
10688
|
+
onClick: function () { setSearchOutside(!searchOutside); },
|
|
10689
|
+
}, '+/'),
|
|
10596
10690
|
search.loading && searchJobRef.current !== ''
|
|
10597
10691
|
? h('button', {
|
|
10598
10692
|
type: 'button',
|
|
@@ -10707,24 +10801,94 @@ function rememberShowHidden(value) {
|
|
|
10707
10801
|
var locale = props.locale;
|
|
10708
10802
|
var scope = props.scope;
|
|
10709
10803
|
var filePath = props.filePath;
|
|
10710
|
-
var loadRef = useState({ loading: true, error: null, data: null });
|
|
10804
|
+
var loadRef = useState({ loading: true, more: false, error: null, data: null });
|
|
10711
10805
|
var load = loadRef[0];
|
|
10712
10806
|
var setLoad = loadRef[1];
|
|
10713
10807
|
var busyRef = useState(false);
|
|
10714
10808
|
var busy = busyRef[0];
|
|
10715
10809
|
var setBusy = busyRef[1];
|
|
10810
|
+
var noteRef = useState('');
|
|
10811
|
+
var note = noteRef[0];
|
|
10812
|
+
var setNote = noteRef[1];
|
|
10813
|
+
// One page per click keeps a 200 MB log from freezing the tab, and the
|
|
10814
|
+
// ceiling keeps the DOM bounded even if someone keeps clicking.
|
|
10815
|
+
var PAGE_BYTES = 1024 * 1024;
|
|
10816
|
+
var CEILING_BYTES = 4 * 1024 * 1024;
|
|
10817
|
+
var isImage = /\.(?:png|jpe?g|gif|webp|bmp|ico|avif|svg)$/i.test(filePath);
|
|
10818
|
+
var imageState = useState({ loading: isImage, error: null, data: null });
|
|
10819
|
+
var image = imageState[0];
|
|
10820
|
+
var setImage = imageState[1];
|
|
10821
|
+
|
|
10822
|
+
function read(from, append) {
|
|
10823
|
+
var start = Math.max(0, Number(from) || 0);
|
|
10824
|
+
setLoad(function (previous) {
|
|
10825
|
+
return { loading: !append, more: append, error: null, data: previous.data };
|
|
10826
|
+
});
|
|
10827
|
+
apiCall('fs.readOutside', Object.assign({ path: filePath, maxBytes: PAGE_BYTES, offset: start }, scopeParams(scope)))
|
|
10828
|
+
.then(function (result) {
|
|
10829
|
+
setLoad(function (previous) {
|
|
10830
|
+
var earlier = append && previous.data ? previous.data : null;
|
|
10831
|
+
var text = typeof result.content === 'string' ? result.content : '';
|
|
10832
|
+
var merged = Object.assign({}, result, {
|
|
10833
|
+
content: earlier && typeof earlier.content === 'string' ? earlier.content + text : text,
|
|
10834
|
+
shown: (earlier && Number(earlier.shown) ? Number(earlier.shown) : 0) + (Number(result.returned) || 0),
|
|
10835
|
+
next: (Number(result.offset) || 0) + (Number(result.returned) || 0),
|
|
10836
|
+
});
|
|
10837
|
+
return { loading: false, more: false, error: null, data: merged };
|
|
10838
|
+
});
|
|
10839
|
+
}, function (error) {
|
|
10840
|
+
setLoad(function (previous) {
|
|
10841
|
+
return { loading: false, more: false, error: error, data: previous.data };
|
|
10842
|
+
});
|
|
10843
|
+
});
|
|
10844
|
+
}
|
|
10845
|
+
|
|
10846
|
+
useEffect(function () { read(0, false); }, [filePath, scope.kind, scope.id]);
|
|
10716
10847
|
|
|
10717
|
-
function
|
|
10718
|
-
|
|
10719
|
-
|
|
10848
|
+
useEffect(function () {
|
|
10849
|
+
if (!isImage) return undefined;
|
|
10850
|
+
var alive = true;
|
|
10851
|
+
setImage({ loading: true, error: null, data: null });
|
|
10852
|
+
apiCall('media.readOutside', Object.assign({ path: filePath }, scopeParams(scope)))
|
|
10720
10853
|
.then(function (result) {
|
|
10721
|
-
|
|
10854
|
+
if (alive) setImage({ loading: false, error: null, data: result });
|
|
10722
10855
|
}, function (error) {
|
|
10723
|
-
|
|
10856
|
+
if (alive) setImage({ loading: false, error: error, data: null });
|
|
10724
10857
|
});
|
|
10858
|
+
return function () { alive = false; };
|
|
10859
|
+
}, [filePath, scope.kind, scope.id, isImage]);
|
|
10860
|
+
|
|
10861
|
+
function loadMore() {
|
|
10862
|
+
if (!load.data || load.more) return;
|
|
10863
|
+
read(Number(load.data.next) || 0, true);
|
|
10864
|
+
}
|
|
10865
|
+
|
|
10866
|
+
function copyPath() {
|
|
10867
|
+
try {
|
|
10868
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
10869
|
+
navigator.clipboard.writeText(filePath).then(function () {
|
|
10870
|
+
setNote(t('addressCopied', { address: filePath }));
|
|
10871
|
+
setTimeout(function () { setNote(''); }, 2500);
|
|
10872
|
+
}).catch(function () {});
|
|
10873
|
+
}
|
|
10874
|
+
} catch (error) { /* clipboard unavailable */ }
|
|
10725
10875
|
}
|
|
10726
10876
|
|
|
10727
|
-
|
|
10877
|
+
function download() {
|
|
10878
|
+
if (busy) return;
|
|
10879
|
+
setBusy(true);
|
|
10880
|
+
setNote('');
|
|
10881
|
+
apiCall('fs.downloadOutside', Object.assign({ path: filePath }, scopeParams(scope))).then(function (result) {
|
|
10882
|
+
setBusy(false);
|
|
10883
|
+
var saved = result && result.path ? String(result.path) : '';
|
|
10884
|
+
setNote(t('outsideDownloaded', { path: saved }));
|
|
10885
|
+
}, function (error) {
|
|
10886
|
+
setBusy(false);
|
|
10887
|
+
setLoad(function (previous) {
|
|
10888
|
+
return { loading: false, more: false, error: error, data: previous.data };
|
|
10889
|
+
});
|
|
10890
|
+
});
|
|
10891
|
+
}
|
|
10728
10892
|
|
|
10729
10893
|
function addRoot() {
|
|
10730
10894
|
if (busy) return;
|
|
@@ -10736,36 +10900,88 @@ function rememberShowHidden(value) {
|
|
|
10736
10900
|
return apiCall('settings.update', { extraRoots: roots });
|
|
10737
10901
|
}).then(function () {
|
|
10738
10902
|
setBusy(false);
|
|
10739
|
-
read();
|
|
10903
|
+
read(0, false);
|
|
10740
10904
|
}, function (error) {
|
|
10741
10905
|
setBusy(false);
|
|
10742
|
-
setLoad({ loading: false, error: error, data: null });
|
|
10906
|
+
setLoad({ loading: false, more: false, error: error, data: null });
|
|
10743
10907
|
});
|
|
10744
10908
|
}
|
|
10745
10909
|
|
|
10746
10910
|
var toolbar = h('div', { className: 'rw-doc-toolbar' },
|
|
10747
10911
|
h('span', { className: 'rw-doc-badge' }, t('outsideBadge')),
|
|
10748
|
-
h('span', { className: 'rw-editor-path', title: filePath }, filePath)
|
|
10912
|
+
h('span', { className: 'rw-editor-path', title: filePath }, filePath),
|
|
10913
|
+
h('span', { style: { flex: '1 1 auto' } }),
|
|
10914
|
+
h('button', {
|
|
10915
|
+
className: 'rw-btn rw-btn-sm',
|
|
10916
|
+
title: t('outsideCopyPath'),
|
|
10917
|
+
'aria-label': t('outsideCopyPath'),
|
|
10918
|
+
onClick: copyPath,
|
|
10919
|
+
}, t('outsideCopyPath')),
|
|
10920
|
+
h('button', {
|
|
10921
|
+
className: 'rw-btn rw-btn-sm',
|
|
10922
|
+
title: t('outsideDownload'),
|
|
10923
|
+
'aria-label': t('outsideDownload'),
|
|
10924
|
+
onClick: download,
|
|
10925
|
+
}, t('outsideDownload')),
|
|
10926
|
+
h('button', {
|
|
10927
|
+
className: 'rw-btn rw-btn-sm',
|
|
10928
|
+
title: t('outsideReload'),
|
|
10929
|
+
'aria-label': t('outsideReload'),
|
|
10930
|
+
disabled: load.loading || load.more,
|
|
10931
|
+
onClick: function () { read(0, false); },
|
|
10932
|
+
}, t('outsideReload')));
|
|
10749
10933
|
var body;
|
|
10750
10934
|
if (load.loading) {
|
|
10751
10935
|
body = h('div', { className: 'rw-doc-loading' }, h('div', { className: 'rw-spinner' }), h('span', null, t('loading')));
|
|
10752
|
-
} else if (load.error) {
|
|
10936
|
+
} else if (load.error && !load.data) {
|
|
10753
10937
|
// A folder outside the workspace is not a permission problem: nothing
|
|
10754
10938
|
// here can open it, so say so instead of offering an allow-list entry.
|
|
10939
|
+
var blocked = load.error.code === 'BAD_REQUEST';
|
|
10755
10940
|
var isDir = load.error.code === 'FS_IS_DIR' || load.error.code === 'FS_NOT_DIRECTORY';
|
|
10756
10941
|
body = h('div', { className: 'rw-doc-body' },
|
|
10757
10942
|
h(Banner, { kind: 'warn' }, messageOf(load.error, t, locale)),
|
|
10758
10943
|
h('div', { className: 'rw-outside-actions' },
|
|
10759
|
-
|
|
10760
|
-
|
|
10944
|
+
blocked && !isDir
|
|
10945
|
+
? h('button', { className: 'rw-btn rw-btn-sm rw-btn-primary', disabled: busy, onClick: addRoot },
|
|
10946
|
+
t('outsideAddRoot', { dir: outsideDirOf(filePath) }))
|
|
10947
|
+
: null,
|
|
10761
10948
|
h('div', { className: 'rw-hint' }, isDir ? t('linkFolder', { path: filePath }) : t('outsideNote'))));
|
|
10762
10949
|
} else {
|
|
10763
10950
|
var data = load.data || {};
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10951
|
+
var shown = Number(data.shown) || 0;
|
|
10952
|
+
var total = Number(data.size) || 0;
|
|
10953
|
+
var canMore = Boolean(data.truncated) && shown < CEILING_BYTES;
|
|
10954
|
+
var footer = h('div', { className: 'rw-outside-footer' },
|
|
10955
|
+
h('span', { className: 'rw-hint' }, t('outsideShown', { shown: formatBytes(shown), total: formatBytes(total) })),
|
|
10956
|
+
typeof data.mtime === 'number' && data.mtime > 0
|
|
10957
|
+
? h('span', { className: 'rw-hint' }, t('outsideMtime', { when: new Date(data.mtime).toLocaleString() }))
|
|
10958
|
+
: null,
|
|
10959
|
+
note ? h('span', { className: 'rw-hint' }, note) : null,
|
|
10960
|
+
canMore
|
|
10961
|
+
? h('button', { className: 'rw-btn rw-btn-sm', disabled: load.more, onClick: loadMore },
|
|
10962
|
+
load.more ? t('loading') : t('outsideLoadMore'))
|
|
10963
|
+
: null,
|
|
10964
|
+
Boolean(data.truncated) && !canMore
|
|
10965
|
+
? h('span', { className: 'rw-hint' }, t('outsideCeiling', { size: formatBytes(CEILING_BYTES) }))
|
|
10966
|
+
: null);
|
|
10967
|
+
if (isImage) {
|
|
10968
|
+
var picture = image.error
|
|
10969
|
+
? h('div', { className: 'rw-outside-actions' }, h(Banner, { kind: 'warn' }, messageOf(image.error, t, locale)))
|
|
10970
|
+
: image.data
|
|
10971
|
+
? h('img', {
|
|
10972
|
+
className: 'rw-outside-image',
|
|
10973
|
+
alt: basename(filePath),
|
|
10974
|
+
src: 'data:' + String(image.data.mime || 'application/octet-stream') + ';base64,' + String(image.data.base64 || ''),
|
|
10975
|
+
})
|
|
10976
|
+
: h('div', { className: 'rw-doc-loading' }, h('div', { className: 'rw-spinner' }), h('span', null, t('loading')));
|
|
10977
|
+
body = h('div', { className: 'rw-doc-body' }, picture, footer);
|
|
10978
|
+
} else {
|
|
10979
|
+
body = h('div', { className: 'rw-doc-body' },
|
|
10980
|
+
data.binary
|
|
10981
|
+
? h('div', { className: 'rw-outside-actions' }, h('div', { className: 'rw-hint' }, t('outsideBinary', { size: formatBytes(total) })))
|
|
10982
|
+
: h('pre', { className: 'rw-outside-text' }, typeof data.content === 'string' ? data.content : ''),
|
|
10983
|
+
footer);
|
|
10984
|
+
}
|
|
10769
10985
|
}
|
|
10770
10986
|
return h('div', { className: 'rw-editor-pane' }, toolbar, body);
|
|
10771
10987
|
}
|
|
@@ -13884,8 +14100,28 @@ function rememberShowHidden(value) {
|
|
|
13884
14100
|
// found" page first. Claim the tab before it exists: a path that lands
|
|
13885
14101
|
// inside one of our workspaces opens straight in its tree tab, and the
|
|
13886
14102
|
// caller never has a native tab to close.
|
|
13887
|
-
|
|
14103
|
+
// The session's own workspace, matched by its local directory (linked) or
|
|
14104
|
+
// its placeholder (remote). Used to give the right machine priority when
|
|
14105
|
+
// two workspaces live on different hosts but share a path.
|
|
14106
|
+
function sessionWorkspaceOf(index, cwd) {
|
|
14107
|
+
var wanted = String(cwd == null ? '' : cwd).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
14108
|
+
if (wanted === '') return null;
|
|
14109
|
+
var all = (index.linked || []).concat(index.remote || []);
|
|
14110
|
+
var lowered = wanted.toLowerCase();
|
|
14111
|
+
for (var cursor = 0; cursor < all.length; cursor += 1) {
|
|
14112
|
+
var record = all[cursor];
|
|
14113
|
+
if (!record) continue;
|
|
14114
|
+
var local = String(record.localPath || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
14115
|
+
var placeholder = String(record.placeholderPath || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
14116
|
+
if ((local !== '' && local === lowered) || (placeholder !== '' && placeholder === lowered)) return record;
|
|
14117
|
+
}
|
|
14118
|
+
return null;
|
|
14119
|
+
}
|
|
14120
|
+
|
|
14121
|
+
function ownerOfPath(index, normalized, preferredHostId) {
|
|
13888
14122
|
var best = null;
|
|
14123
|
+
var bestHere = null;
|
|
14124
|
+
var host = String(preferredHostId || '');
|
|
13889
14125
|
function consider(list, kind) {
|
|
13890
14126
|
for (var cursor = 0; cursor < list.length; cursor += 1) {
|
|
13891
14127
|
var record = list[cursor];
|
|
@@ -13896,11 +14132,14 @@ function rememberShowHidden(value) {
|
|
|
13896
14132
|
// The deepest root wins, so a workspace nested inside another one
|
|
13897
14133
|
// keeps its own files.
|
|
13898
14134
|
if (!best || root.length > best.root.length) best = { kind: kind, record: record, root: root };
|
|
14135
|
+
if (host !== '' && String(record.hostId || '') === host) {
|
|
14136
|
+
if (!bestHere || root.length > bestHere.root.length) bestHere = { kind: kind, record: record, root: root };
|
|
14137
|
+
}
|
|
13899
14138
|
}
|
|
13900
14139
|
}
|
|
13901
14140
|
consider(index.linked || [], 'linked');
|
|
13902
14141
|
consider(index.remote || [], 'remote');
|
|
13903
|
-
return best;
|
|
14142
|
+
return bestHere || best;
|
|
13904
14143
|
}
|
|
13905
14144
|
|
|
13906
14145
|
// Native path tabs are the only place DSH shows us a session's cwd, so
|
|
@@ -13949,7 +14188,14 @@ function rememberShowHidden(value) {
|
|
|
13949
14188
|
function openOutside(scoped, absolute) {
|
|
13950
14189
|
var sessionId = currentSessionId();
|
|
13951
14190
|
var scope = sessionId !== '' ? { sessionId: sessionId } : {};
|
|
13952
|
-
|
|
14191
|
+
var opened = openOutsideFileTab(sidebar, scope, scoped, absolute) === true;
|
|
14192
|
+
// With every slot busy the click is claimed but has nowhere to land: the
|
|
14193
|
+
// native viewer would only show "file not found", so report it as handled
|
|
14194
|
+
// and let the panel say why nothing opened.
|
|
14195
|
+
if (!opened && slotFull === true && typeof slotFullNotice === 'function') {
|
|
14196
|
+
try { slotFullNotice(); } catch (error) { /* the panel may be gone */ }
|
|
14197
|
+
}
|
|
14198
|
+
return opened || slotFull === true;
|
|
13953
14199
|
}
|
|
13954
14200
|
|
|
13955
14201
|
function claimScope(owner) {
|
|
@@ -13966,16 +14212,18 @@ function rememberShowHidden(value) {
|
|
|
13966
14212
|
return scope;
|
|
13967
14213
|
}
|
|
13968
14214
|
|
|
13969
|
-
function takeSeed(normalized) {
|
|
14215
|
+
function takeSeed(normalized, sessionCwd) {
|
|
13970
14216
|
// DSH may keep the drive letter ("D:\data\x.md") or drop it
|
|
13971
14217
|
// ("\data\x.md"); both spellings have to be tried against the roots.
|
|
13972
14218
|
var candidates = [normalized];
|
|
13973
14219
|
var stripped = normalized.replace(/^[A-Za-z]:/, '');
|
|
13974
14220
|
if (stripped !== normalized && stripped.charAt(0) === '/') candidates.push(stripped);
|
|
13975
14221
|
return workspaceIndex().then(function (index) {
|
|
14222
|
+
var here = sessionWorkspaceOf(index, sessionCwd);
|
|
14223
|
+
var preferredHost = here && here.hostId ? String(here.hostId) : '';
|
|
13976
14224
|
var found = null;
|
|
13977
14225
|
for (var cursor = 0; cursor < candidates.length && !found; cursor += 1) {
|
|
13978
|
-
var owner = ownerOfPath(index, candidates[cursor]);
|
|
14226
|
+
var owner = ownerOfPath(index, candidates[cursor], preferredHost);
|
|
13979
14227
|
if (owner) found = { owner: owner, absolute: candidates[cursor] };
|
|
13980
14228
|
}
|
|
13981
14229
|
if (!found) {
|
|
@@ -13984,7 +14232,7 @@ function rememberShowHidden(value) {
|
|
|
13984
14232
|
var outside = candidates[0];
|
|
13985
14233
|
if (!outsideOpenable(outside)) return false;
|
|
13986
14234
|
var sessionId = currentSessionId();
|
|
13987
|
-
var cwd = sessionCwdOf(sessionId);
|
|
14235
|
+
var cwd = String(sessionCwd || '') || sessionCwdOf(sessionId);
|
|
13988
14236
|
if (cwd === '') return false;
|
|
13989
14237
|
return scanReferenceScope(cwd, '').then(function (scoped) {
|
|
13990
14238
|
if (!scoped || !scoped.root) return false;
|
|
@@ -14038,7 +14286,8 @@ function rememberShowHidden(value) {
|
|
|
14038
14286
|
if (normalized.charAt(0) !== '/' && /^[A-Za-z]:\//.test(normalized) === false) {
|
|
14039
14287
|
return original.apply(sidebar, arguments);
|
|
14040
14288
|
}
|
|
14041
|
-
|
|
14289
|
+
var seedCwd = scope && typeof scope.cwd === 'string' ? scope.cwd : '';
|
|
14290
|
+
takeSeed(normalized, seedCwd).then(function (claimed) {
|
|
14042
14291
|
if (!claimed) original.call(sidebar, seed, scope);
|
|
14043
14292
|
}, function () { original.call(sidebar, seed, scope); });
|
|
14044
14293
|
return undefined;
|
|
@@ -14052,7 +14301,8 @@ function rememberShowHidden(value) {
|
|
|
14052
14301
|
var normalizedFile = typeof path === 'string' ? path.split(String.fromCharCode(92)).join('/') : '';
|
|
14053
14302
|
var rooted = normalizedFile !== '' && (normalizedFile.charAt(0) === '/' || /^[A-Za-z]:\//.test(normalizedFile));
|
|
14054
14303
|
if (!rooted) return openFileOriginal.apply(sidebar, args);
|
|
14055
|
-
|
|
14304
|
+
var fileCwd = scope && typeof scope.cwd === 'string' ? scope.cwd : '';
|
|
14305
|
+
takeSeed(normalizedFile, fileCwd).then(function (claimed) {
|
|
14056
14306
|
if (!claimed) openFileOriginal.apply(sidebar, args);
|
|
14057
14307
|
}, function () { openFileOriginal.apply(sidebar, args); });
|
|
14058
14308
|
return undefined;
|
package/lib/index.js
CHANGED
|
@@ -4246,18 +4246,46 @@ export function apply(ctx) {
|
|
|
4246
4246
|
const stat = await scope.remote.stat(target)
|
|
4247
4247
|
if (stat.type === 'dir') throw new ApiError('FS_IS_DIR', '目标是目录,请用 list_outside')
|
|
4248
4248
|
const limit = clampInt(params.maxBytes, 1024, READ_CAP, 262144)
|
|
4249
|
-
|
|
4249
|
+
// Paging: the caller passes the byte it stopped at, so a big artefact can
|
|
4250
|
+
// be read in pieces instead of being cut off at one window.
|
|
4251
|
+
const offset = clampInt(params.offset, 0, Number.MAX_SAFE_INTEGER, 0)
|
|
4252
|
+
const start = Math.min(offset, stat.size)
|
|
4253
|
+
const read = await scope.remote.readFile(target, { maxBytes: limit, offset: start })
|
|
4250
4254
|
const binary = looksBinary(read.data)
|
|
4255
|
+
const returned = read.data.length
|
|
4251
4256
|
return {
|
|
4252
4257
|
path: target,
|
|
4253
4258
|
size: stat.size,
|
|
4254
4259
|
mtime: stat.mtime,
|
|
4255
4260
|
binary,
|
|
4256
|
-
|
|
4261
|
+
offset: start,
|
|
4262
|
+
returned,
|
|
4263
|
+
truncated: start + returned < stat.size,
|
|
4257
4264
|
content: binary ? '' : decodeUtf8(read.data),
|
|
4258
4265
|
}
|
|
4259
4266
|
},
|
|
4260
4267
|
|
|
4268
|
+
// Outside files were readable but not retrievable: the viewer says "download
|
|
4269
|
+
// it" at the ceiling and for binary files, so give it the same download the
|
|
4270
|
+
// workspace tree has.
|
|
4271
|
+
async 'fs.downloadOutside'(params = {}) {
|
|
4272
|
+
const { scope, target } = await extraTarget(params, 'downloadOutside')
|
|
4273
|
+
return await downloadRemotePath(scope.remote, target, downloadsFolder())
|
|
4274
|
+
},
|
|
4275
|
+
|
|
4276
|
+
// An image outside the workspace used to fall through to "binary file";
|
|
4277
|
+
// this is the same read the workspace preview uses, through the extra roots.
|
|
4278
|
+
async 'media.readOutside'(params = {}) {
|
|
4279
|
+
const { scope, target } = await extraTarget(params, 'readOutside')
|
|
4280
|
+
const mime = imageMimeOf(target)
|
|
4281
|
+
if (!mime) throw new ApiError('BAD_REQUEST', '该文件不是支持的图片格式')
|
|
4282
|
+
const stat = await scope.remote.stat(target)
|
|
4283
|
+
if (stat.type === 'dir') throw new ApiError('FS_IS_DIR', '目标是目录,无法预览')
|
|
4284
|
+
if (stat.size > MAX_MEDIA_BYTES) throw new ApiError('FS_TOO_LARGE', '图片超过 24 MB,无法预览')
|
|
4285
|
+
const read = await scope.remote.readFile(target, { maxBytes: MAX_MEDIA_BYTES })
|
|
4286
|
+
return { path: target, size: stat.size, mtime: stat.mtime, mime, base64: read.data.toString('base64') }
|
|
4287
|
+
},
|
|
4288
|
+
|
|
4261
4289
|
async 'fs.writeOutside'(params = {}) {
|
|
4262
4290
|
const { scope, target } = await extraTarget(params, 'writeOutside')
|
|
4263
4291
|
if (typeof params.content !== 'string') throw new ApiError('BAD_REQUEST', 'content is required')
|
|
@@ -4830,7 +4858,40 @@ export function apply(ctx) {
|
|
|
4830
4858
|
timeoutMs: params.timeoutMs,
|
|
4831
4859
|
job: beginGrepJob(params.jobId),
|
|
4832
4860
|
}
|
|
4833
|
-
if (side === 'remote')
|
|
4861
|
+
if (side === 'remote') {
|
|
4862
|
+
const found = await contentSearchRemote(scope.remote, scope.root, query, maxResults, options)
|
|
4863
|
+
if (params.includeOutside !== true) return found
|
|
4864
|
+
const roots = extraRoots().slice(0, 5)
|
|
4865
|
+
if (roots.length === 0) return found
|
|
4866
|
+
const merged = found.entries.slice()
|
|
4867
|
+
let truncated = found.truncated
|
|
4868
|
+
let scanned = found.scannedFiles
|
|
4869
|
+
for (const root of roots) {
|
|
4870
|
+
if (merged.length >= maxResults) {
|
|
4871
|
+
truncated = true
|
|
4872
|
+
break
|
|
4873
|
+
}
|
|
4874
|
+
const part = await contentSearchRemote(scope.remote, root, query, maxResults - merged.length, options)
|
|
4875
|
+
scanned += part.scannedFiles
|
|
4876
|
+
if (part.truncated) truncated = true
|
|
4877
|
+
for (const entry of part.entries) {
|
|
4878
|
+
merged.push(Object.assign({}, entry, {
|
|
4879
|
+
relative: entry.path.startsWith(root + '/') ? entry.path.slice(root.length + 1) : entry.relative,
|
|
4880
|
+
outsideRoot: root,
|
|
4881
|
+
}))
|
|
4882
|
+
}
|
|
4883
|
+
}
|
|
4884
|
+
return {
|
|
4885
|
+
ok: true,
|
|
4886
|
+
query,
|
|
4887
|
+
entries: merged.slice(0, maxResults),
|
|
4888
|
+
truncated,
|
|
4889
|
+
truncatedReason: truncated ? (found.truncatedReason || 'results') : '',
|
|
4890
|
+
scannedFiles: scanned,
|
|
4891
|
+
scannedBytes: found.scannedBytes,
|
|
4892
|
+
skippedFiles: found.skippedFiles,
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4834
4895
|
if (scope.kind !== 'linked') throw new ApiError('BAD_REQUEST', '只有联动工作区有本地目录')
|
|
4835
4896
|
return contentSearchLocal(scope.record.localPath, query, maxResults, options)
|
|
4836
4897
|
},
|
package/lib/ssh.js
CHANGED
|
@@ -1808,23 +1808,31 @@ export class RemoteHost {
|
|
|
1808
1808
|
if (stat.type === 'dir') throw new SshError('FS_IS_DIR', `Cannot read "${target}": it is a directory`);
|
|
1809
1809
|
|
|
1810
1810
|
const size = stat.size;
|
|
1811
|
-
|
|
1812
|
-
|
|
1811
|
+
// Callers that page through a big file pass an offset; everything else
|
|
1812
|
+
// starts at the beginning, exactly as before.
|
|
1813
|
+
const requestedOffset = Number(options && options.offset);
|
|
1814
|
+
const offset = Number.isFinite(requestedOffset) && requestedOffset > 0
|
|
1815
|
+
? Math.min(Math.floor(requestedOffset), size)
|
|
1816
|
+
: 0;
|
|
1817
|
+
const remaining = size - offset;
|
|
1818
|
+
const truncated = remaining > maxBytes;
|
|
1819
|
+
const limit = truncated ? maxBytes : remaining;
|
|
1813
1820
|
|
|
1814
1821
|
const data = await this.#sftpOp(label, async (sftp) => {
|
|
1815
1822
|
const handle = await callSftp(sftp, 'open', target, 'r');
|
|
1816
1823
|
try {
|
|
1817
1824
|
const chunks = [];
|
|
1818
|
-
let position =
|
|
1819
|
-
|
|
1820
|
-
|
|
1825
|
+
let position = offset;
|
|
1826
|
+
const end = offset + limit;
|
|
1827
|
+
while (position < end) {
|
|
1828
|
+
const want = Math.min(SFTP_READ_CHUNK, end - position);
|
|
1821
1829
|
const buffer = Buffer.allocUnsafe(want);
|
|
1822
1830
|
const bytesRead = await callSftp(sftp, 'read', handle, buffer, 0, want, position);
|
|
1823
1831
|
if (!bytesRead) break;
|
|
1824
1832
|
chunks.push(buffer.subarray(0, bytesRead));
|
|
1825
1833
|
position += bytesRead;
|
|
1826
1834
|
}
|
|
1827
|
-
return Buffer.concat(chunks, position);
|
|
1835
|
+
return Buffer.concat(chunks, position - offset);
|
|
1828
1836
|
} finally {
|
|
1829
1837
|
try {
|
|
1830
1838
|
await callSftp(sftp, 'close', handle);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.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",
|