dsh-linked-workspace 0.31.0 → 0.32.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 +18 -0
- package/docs/API.md +1 -1
- package/docs/VERIFY.md +14 -0
- package/lib/client.js +190 -45
- package/lib/index.js +9 -2
- package/lib/ssh.js +14 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.32.0 — 2026-11-29
|
|
4
|
+
|
|
5
|
+
- **Working outside the workspace is now readable, not truncated**: the read-only tab pages through a file
|
|
6
|
+
256 KiB at a time ("Load more" continues where the last window stopped), the footer shows "Showing X of Y"
|
|
7
|
+
plus the remote mtime, and it offers "Reload" and "Copy absolute address". Hitting the 4 MB ceiling says so
|
|
8
|
+
and points at downloading the file. Before this, only the first window was reachable and the banner
|
|
9
|
+
reported the file size as if it were what had been shown.
|
|
10
|
+
- **A full tab table no longer swallows the click**: file slots went from 12 to 24, and once they are all
|
|
11
|
+
taken a chat link is claimed instead of landing on the native "file not found" page (`slotFull`). Slot
|
|
12
|
+
recycling is not possible on this platform: the sidebar binds a tab kind to one tab for good, a closed kind
|
|
13
|
+
cannot be reopened, and `updateTab` repoints the address without re-rendering the plugin view.
|
|
14
|
+
- **Two roots with the same tail no longer steal each other's links**: a chat link is matched against the
|
|
15
|
+
session's own host first, then against the longest prefix.
|
|
16
|
+
- **The directory toolbar reads well with a screen reader**: its 12 icon buttons mirror their `title` into
|
|
17
|
+
`aria-label`.
|
|
18
|
+
- **Host**: `fs.readOutside` accepts `offset` and reports `returned` (paged reads), and `lib/ssh.js`'s
|
|
19
|
+
`readFile` can start anywhere in the file.
|
|
20
|
+
|
|
3
21
|
## 0.31.0 — 2026-11-28
|
|
4
22
|
|
|
5
23
|
- 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,7 @@ 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
63
|
| `fs.writeOutside` | `{ linkedId?, remoteId?, path, content, ifModifiedSince? }` | `{ path, size, mtime, created }` (8 MB limit; only under an `extraRoots` prefix; audited) |
|
|
64
64
|
| `fs.listOutside` | `{ linkedId?, remoteId?, path }` | `{ path, entries }` (only under an `extraRoots` prefix; audited) |
|
|
65
65
|
| `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) |
|
package/docs/VERIFY.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Manual verification checklist
|
|
2
2
|
|
|
3
|
+
## 工作区外的只读视图与标签位(未发布)
|
|
4
|
+
|
|
5
|
+
1. 联动工作区根目录在 `/shared_data_ssd1/huangjh`,准备一个 `/shared_data_hdd1/huangjh/big.jsonl`(≥ 300 KB,
|
|
6
|
+
且已在「额外根目录」里允许):在会话里点它的链接 → 出现「工作区外」只读标签。
|
|
7
|
+
2. 首屏显示 256 KB,页脚为「已显示 256 KB,共 374 KB」+「修改于 …」;点「加载更多」→ 显示全部、
|
|
8
|
+
页脚变成「已显示 374 KB,共 374 KB」且按钮消失。
|
|
9
|
+
3. 点「重新加载」→ 回到首屏;点「复制绝对地址」→ 剪贴板里是完整远端路径,页脚出现「已复制:…」。
|
|
10
|
+
4. 打开超过 4 MB 的工作区外文件:走到底后提示已达读取上限,不再无限追加。
|
|
11
|
+
5. 依次点开 25 条不同的聊天文件链接:前 24 条各占一个文件标签;第 25 条不会出现原生「文件不存在」页
|
|
12
|
+
(点击被接管,但没有空位可放)。
|
|
13
|
+
6. 目录栏悬停任意图标按钮:`aria-label` 与可见提示一致(读屏可念出)。
|
|
14
|
+
7. 两个工作区根目录尾段同名(如都是 `/x/huangjh`)时,点其中一个会话里的链接应落回该会话自己的主机。
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
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
18
|
|
|
5
19
|
## 工作区外的聊天链接(未发布)
|
package/lib/client.js
CHANGED
|
@@ -2351,8 +2351,17 @@ 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
|
+
|
|
2354
2361
|
function remoteFileSlotFor(key) {
|
|
2355
|
-
|
|
2362
|
+
slotFull = false;
|
|
2363
|
+
var taken = fileSlotByKey.get(key);
|
|
2364
|
+
if (taken !== undefined) return taken;
|
|
2356
2365
|
for (var index = 1; index <= FILE_SLOT_COUNT; index += 1) {
|
|
2357
2366
|
var kind = FILE_SLOT_PREFIX + index;
|
|
2358
2367
|
if (!fileSlotByKind.has(kind)) {
|
|
@@ -2361,9 +2370,23 @@ function isInsideRoot(root, target) {
|
|
|
2361
2370
|
return kind;
|
|
2362
2371
|
}
|
|
2363
2372
|
}
|
|
2373
|
+
slotFull = true;
|
|
2364
2374
|
return undefined;
|
|
2365
2375
|
}
|
|
2366
2376
|
|
|
2377
|
+
// Open a file into the slot its key owns. Slots are one-shot (see above), so
|
|
2378
|
+
// there is no recycle branch here: a new key gets a free slot or nothing.
|
|
2379
|
+
function openFileSlotTab(sidebar, scope, kind, seed) {
|
|
2380
|
+
var known = nativeTabKeys(sidebar);
|
|
2381
|
+
try {
|
|
2382
|
+
sidebar.openTab(seed(kind), scope);
|
|
2383
|
+
} catch (error) {
|
|
2384
|
+
return false;
|
|
2385
|
+
}
|
|
2386
|
+
claimNewNativeTabs(sidebar, known);
|
|
2387
|
+
return true;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2367
2390
|
// A link inside a remote document has to become an absolute path on the same
|
|
2368
2391
|
// host, and the panel that owns the tab does not carry the workspace root.
|
|
2369
2392
|
// The two lists change rarely, so one lookup serves every click for 30 s.
|
|
@@ -2431,23 +2454,22 @@ function isInsideRoot(root, target) {
|
|
|
2431
2454
|
}, 0);
|
|
2432
2455
|
}
|
|
2433
2456
|
|
|
2434
|
-
function openRemoteFileTab(sidebar, scope, source, filePath) {
|
|
2457
|
+
function openRemoteFileTab(sidebar, scope, source, filePath, options) {
|
|
2435
2458
|
if (!sidebar || typeof sidebar.openTab !== 'function') return false;
|
|
2436
2459
|
var key = scopeKeyOf(sourceScopeOf(source)) + ':' + filePath;
|
|
2437
2460
|
var kind = remoteFileSlotFor(key);
|
|
2438
2461
|
if (kind === undefined) return false;
|
|
2439
|
-
var known = nativeTabKeys(sidebar);
|
|
2440
2462
|
// The slot id is the identity, so asking for the same file again focuses
|
|
2441
2463
|
// the tab that is already open instead of stacking a second one.
|
|
2442
|
-
sidebar
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2464
|
+
return openFileSlotTab(sidebar, scope, kind, function (kind) {
|
|
2465
|
+
return {
|
|
2466
|
+
type: kind,
|
|
2467
|
+
id: kind,
|
|
2468
|
+
title: basename(filePath),
|
|
2469
|
+
path: filePath,
|
|
2470
|
+
meta: sourceMetaOf(source),
|
|
2471
|
+
};
|
|
2472
|
+
});
|
|
2451
2473
|
}
|
|
2452
2474
|
|
|
2453
2475
|
// The folder that has to be allow-listed before an outside path is readable.
|
|
@@ -2474,10 +2496,9 @@ function isInsideRoot(root, target) {
|
|
|
2474
2496
|
if (kind === undefined) return false;
|
|
2475
2497
|
var meta = sourceMetaOf(source);
|
|
2476
2498
|
meta.outside = true;
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
return true;
|
|
2499
|
+
return openFileSlotTab(sidebar, scope, kind, function (kind) {
|
|
2500
|
+
return { type: kind, id: kind, title: basename(filePath), path: filePath, meta: meta };
|
|
2501
|
+
});
|
|
2481
2502
|
}
|
|
2482
2503
|
|
|
2483
2504
|
// Chat artifacts live outside our tabs, so opening one has to travel
|
|
@@ -2509,7 +2530,7 @@ function isInsideRoot(root, target) {
|
|
|
2509
2530
|
|
|
2510
2531
|
var FILE_TAB_TYPE = 'dsh-linked-workspace:file';
|
|
2511
2532
|
var FILE_SLOT_PREFIX = 'dsh-linked-workspace:file:';
|
|
2512
|
-
var FILE_SLOT_COUNT =
|
|
2533
|
+
var FILE_SLOT_COUNT = 24;
|
|
2513
2534
|
// DSH's native right sidebar deduplicates ordinary page tabs by kind, so a
|
|
2514
2535
|
// second file opened under one kind would focus the first tab. Each file
|
|
2515
2536
|
// slot is its own hidden page kind; this map hands a free slot to a file and
|
|
@@ -2821,7 +2842,12 @@ function isInsideRoot(root, target) {
|
|
|
2821
2842
|
outsideAddRoot: '把 {{dir}} 加入额外根目录并打开',
|
|
2822
2843
|
outsideBadge: '工作区外',
|
|
2823
2844
|
outsideBinary: '二进制文件,无法在这里预览({{size}})。',
|
|
2824
|
-
|
|
2845
|
+
outsideReload: '重新加载',
|
|
2846
|
+
outsideCopyPath: '复制绝对地址',
|
|
2847
|
+
outsideLoadMore: '加载更多',
|
|
2848
|
+
outsideShown: '已显示 {{shown}},共 {{total}}',
|
|
2849
|
+
outsideMtime: '修改于 {{when}}',
|
|
2850
|
+
outsideCeiling: '已达到 {{size}} 的读取上限,剩下的内容请下载后查看。',
|
|
2825
2851
|
linkOutside: '这个链接指向工作区之外,没有打开:{{path}}',
|
|
2826
2852
|
linkFolder: '这是文件夹链接,这里只打开文件:{{path}}',
|
|
2827
2853
|
linkedTitle: '联动工作区',
|
|
@@ -3432,7 +3458,12 @@ function isInsideRoot(root, target) {
|
|
|
3432
3458
|
outsideAddRoot: 'Add {{dir}} to the extra roots and open it',
|
|
3433
3459
|
outsideBadge: 'Outside',
|
|
3434
3460
|
outsideBinary: 'Binary file, so it cannot be previewed here ({{size}}).',
|
|
3435
|
-
|
|
3461
|
+
outsideReload: 'Reload',
|
|
3462
|
+
outsideCopyPath: 'Copy absolute address',
|
|
3463
|
+
outsideLoadMore: 'Load more',
|
|
3464
|
+
outsideShown: 'Showing {{shown}} of {{total}}',
|
|
3465
|
+
outsideMtime: 'Modified {{when}}',
|
|
3466
|
+
outsideCeiling: 'Reached the {{size}} reading ceiling; download the file for the rest.',
|
|
3436
3467
|
linkOutside: 'That link points outside the workspace, so it was left alone: {{path}}',
|
|
3437
3468
|
linkFolder: 'That link is a folder; only files open here: {{path}}',
|
|
3438
3469
|
linkedTitle: 'Linked workspaces',
|
|
@@ -4418,6 +4449,9 @@ function isInsideRoot(root, target) {
|
|
|
4418
4449
|
'.rw-doc{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;min-width:0;background:var(--dsw-alias-bg-base)}',
|
|
4419
4450
|
'.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
4451
|
'.rw-doc-body{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow:auto;padding:10px}',
|
|
4452
|
+
'.rw-outside-actions{display:flex;flex-direction:column;gap:8px;padding:4px 0}',
|
|
4453
|
+
'.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}',
|
|
4454
|
+
'.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
4455
|
'.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
4456
|
'.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
4457
|
'.rw-doc-preview h1,.rw-doc-preview h2,.rw-doc-preview h3{line-height:1.3;margin:1em 0 .5em}',
|
|
@@ -6879,7 +6913,18 @@ function isInsideRoot(root, target) {
|
|
|
6879
6913
|
|
|
6880
6914
|
function close() { setMenu(null); }
|
|
6881
6915
|
|
|
6882
|
-
|
|
6916
|
+
var toolbarRef = useRef(null);
|
|
6917
|
+
useEffect(function () {
|
|
6918
|
+
var node = toolbarRef.current;
|
|
6919
|
+
if (!node || typeof node.querySelectorAll !== 'function') return;
|
|
6920
|
+
var buttons = node.querySelectorAll('button.rw-icon-btn');
|
|
6921
|
+
for (var index = 0; index < buttons.length; index += 1) {
|
|
6922
|
+
if (buttons[index].getAttribute('aria-label')) continue;
|
|
6923
|
+
buttons[index].setAttribute('aria-label', buttons[index].getAttribute('title') || '');
|
|
6924
|
+
}
|
|
6925
|
+
});
|
|
6926
|
+
|
|
6927
|
+
return h('div', { className: 'rw-linked-toolbar', ref: toolbarRef },
|
|
6883
6928
|
h('span', { className: 'rw-tree-toolbar-title' }, props.title || t('tabTitle')),
|
|
6884
6929
|
h('div', { className: 'rw-actions', style: { marginLeft: 'auto', gap: 2 } },
|
|
6885
6930
|
h('button', {
|
|
@@ -10707,24 +10752,61 @@ function rememberShowHidden(value) {
|
|
|
10707
10752
|
var locale = props.locale;
|
|
10708
10753
|
var scope = props.scope;
|
|
10709
10754
|
var filePath = props.filePath;
|
|
10710
|
-
var loadRef = useState({ loading: true, error: null, data: null });
|
|
10755
|
+
var loadRef = useState({ loading: true, more: false, error: null, data: null });
|
|
10711
10756
|
var load = loadRef[0];
|
|
10712
10757
|
var setLoad = loadRef[1];
|
|
10713
10758
|
var busyRef = useState(false);
|
|
10714
10759
|
var busy = busyRef[0];
|
|
10715
10760
|
var setBusy = busyRef[1];
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10761
|
+
var noteRef = useState('');
|
|
10762
|
+
var note = noteRef[0];
|
|
10763
|
+
var setNote = noteRef[1];
|
|
10764
|
+
// One page per click keeps a 200 MB log from freezing the tab, and the
|
|
10765
|
+
// ceiling keeps the DOM bounded even if someone keeps clicking.
|
|
10766
|
+
var PAGE_BYTES = 256 * 1024;
|
|
10767
|
+
var CEILING_BYTES = 4 * 1024 * 1024;
|
|
10768
|
+
|
|
10769
|
+
function read(from, append) {
|
|
10770
|
+
var start = Math.max(0, Number(from) || 0);
|
|
10771
|
+
setLoad(function (previous) {
|
|
10772
|
+
return { loading: !append, more: append, error: null, data: previous.data };
|
|
10773
|
+
});
|
|
10774
|
+
apiCall('fs.readOutside', Object.assign({ path: filePath, maxBytes: PAGE_BYTES, offset: start }, scopeParams(scope)))
|
|
10720
10775
|
.then(function (result) {
|
|
10721
|
-
setLoad(
|
|
10776
|
+
setLoad(function (previous) {
|
|
10777
|
+
var earlier = append && previous.data ? previous.data : null;
|
|
10778
|
+
var text = typeof result.content === 'string' ? result.content : '';
|
|
10779
|
+
var merged = Object.assign({}, result, {
|
|
10780
|
+
content: earlier && typeof earlier.content === 'string' ? earlier.content + text : text,
|
|
10781
|
+
shown: (earlier && Number(earlier.shown) ? Number(earlier.shown) : 0) + (Number(result.returned) || 0),
|
|
10782
|
+
next: (Number(result.offset) || 0) + (Number(result.returned) || 0),
|
|
10783
|
+
});
|
|
10784
|
+
return { loading: false, more: false, error: null, data: merged };
|
|
10785
|
+
});
|
|
10722
10786
|
}, function (error) {
|
|
10723
|
-
setLoad(
|
|
10787
|
+
setLoad(function (previous) {
|
|
10788
|
+
return { loading: false, more: false, error: error, data: previous.data };
|
|
10789
|
+
});
|
|
10724
10790
|
});
|
|
10725
10791
|
}
|
|
10726
10792
|
|
|
10727
|
-
useEffect(function () { read(); }, [filePath, scope.kind, scope.id]);
|
|
10793
|
+
useEffect(function () { read(0, false); }, [filePath, scope.kind, scope.id]);
|
|
10794
|
+
|
|
10795
|
+
function loadMore() {
|
|
10796
|
+
if (!load.data || load.more) return;
|
|
10797
|
+
read(Number(load.data.next) || 0, true);
|
|
10798
|
+
}
|
|
10799
|
+
|
|
10800
|
+
function copyPath() {
|
|
10801
|
+
try {
|
|
10802
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
10803
|
+
navigator.clipboard.writeText(filePath).then(function () {
|
|
10804
|
+
setNote(t('addressCopied', { address: filePath }));
|
|
10805
|
+
setTimeout(function () { setNote(''); }, 2500);
|
|
10806
|
+
}).catch(function () {});
|
|
10807
|
+
}
|
|
10808
|
+
} catch (error) { /* clipboard unavailable */ }
|
|
10809
|
+
}
|
|
10728
10810
|
|
|
10729
10811
|
function addRoot() {
|
|
10730
10812
|
if (busy) return;
|
|
@@ -10736,36 +10818,69 @@ function rememberShowHidden(value) {
|
|
|
10736
10818
|
return apiCall('settings.update', { extraRoots: roots });
|
|
10737
10819
|
}).then(function () {
|
|
10738
10820
|
setBusy(false);
|
|
10739
|
-
read();
|
|
10821
|
+
read(0, false);
|
|
10740
10822
|
}, function (error) {
|
|
10741
10823
|
setBusy(false);
|
|
10742
|
-
setLoad({ loading: false, error: error, data: null });
|
|
10824
|
+
setLoad({ loading: false, more: false, error: error, data: null });
|
|
10743
10825
|
});
|
|
10744
10826
|
}
|
|
10745
10827
|
|
|
10746
10828
|
var toolbar = h('div', { className: 'rw-doc-toolbar' },
|
|
10747
10829
|
h('span', { className: 'rw-doc-badge' }, t('outsideBadge')),
|
|
10748
|
-
h('span', { className: 'rw-editor-path', title: filePath }, filePath)
|
|
10830
|
+
h('span', { className: 'rw-editor-path', title: filePath }, filePath),
|
|
10831
|
+
h('span', { style: { flex: '1 1 auto' } }),
|
|
10832
|
+
h('button', {
|
|
10833
|
+
className: 'rw-btn rw-btn-sm',
|
|
10834
|
+
title: t('outsideCopyPath'),
|
|
10835
|
+
'aria-label': t('outsideCopyPath'),
|
|
10836
|
+
onClick: copyPath,
|
|
10837
|
+
}, t('outsideCopyPath')),
|
|
10838
|
+
h('button', {
|
|
10839
|
+
className: 'rw-btn rw-btn-sm',
|
|
10840
|
+
title: t('outsideReload'),
|
|
10841
|
+
'aria-label': t('outsideReload'),
|
|
10842
|
+
disabled: load.loading || load.more,
|
|
10843
|
+
onClick: function () { read(0, false); },
|
|
10844
|
+
}, t('outsideReload')));
|
|
10749
10845
|
var body;
|
|
10750
10846
|
if (load.loading) {
|
|
10751
10847
|
body = h('div', { className: 'rw-doc-loading' }, h('div', { className: 'rw-spinner' }), h('span', null, t('loading')));
|
|
10752
|
-
} else if (load.error) {
|
|
10848
|
+
} else if (load.error && !load.data) {
|
|
10753
10849
|
// A folder outside the workspace is not a permission problem: nothing
|
|
10754
10850
|
// here can open it, so say so instead of offering an allow-list entry.
|
|
10851
|
+
var blocked = load.error.code === 'BAD_REQUEST';
|
|
10755
10852
|
var isDir = load.error.code === 'FS_IS_DIR' || load.error.code === 'FS_NOT_DIRECTORY';
|
|
10756
10853
|
body = h('div', { className: 'rw-doc-body' },
|
|
10757
10854
|
h(Banner, { kind: 'warn' }, messageOf(load.error, t, locale)),
|
|
10758
10855
|
h('div', { className: 'rw-outside-actions' },
|
|
10759
|
-
|
|
10760
|
-
|
|
10856
|
+
blocked && !isDir
|
|
10857
|
+
? h('button', { className: 'rw-btn rw-btn-sm rw-btn-primary', disabled: busy, onClick: addRoot },
|
|
10858
|
+
t('outsideAddRoot', { dir: outsideDirOf(filePath) }))
|
|
10859
|
+
: null,
|
|
10761
10860
|
h('div', { className: 'rw-hint' }, isDir ? t('linkFolder', { path: filePath }) : t('outsideNote'))));
|
|
10762
10861
|
} else {
|
|
10763
10862
|
var data = load.data || {};
|
|
10863
|
+
var shown = Number(data.shown) || 0;
|
|
10864
|
+
var total = Number(data.size) || 0;
|
|
10865
|
+
var canMore = Boolean(data.truncated) && shown < CEILING_BYTES;
|
|
10866
|
+
var footer = h('div', { className: 'rw-outside-footer' },
|
|
10867
|
+
h('span', { className: 'rw-hint' }, t('outsideShown', { shown: formatBytes(shown), total: formatBytes(total) })),
|
|
10868
|
+
typeof data.mtime === 'number' && data.mtime > 0
|
|
10869
|
+
? h('span', { className: 'rw-hint' }, t('outsideMtime', { when: new Date(data.mtime).toLocaleString() }))
|
|
10870
|
+
: null,
|
|
10871
|
+
note ? h('span', { className: 'rw-hint' }, note) : null,
|
|
10872
|
+
canMore
|
|
10873
|
+
? h('button', { className: 'rw-btn rw-btn-sm', disabled: load.more, onClick: loadMore },
|
|
10874
|
+
load.more ? t('loading') : t('outsideLoadMore'))
|
|
10875
|
+
: null,
|
|
10876
|
+
Boolean(data.truncated) && !canMore
|
|
10877
|
+
? h('span', { className: 'rw-hint' }, t('outsideCeiling', { size: formatBytes(CEILING_BYTES) }))
|
|
10878
|
+
: null);
|
|
10764
10879
|
body = h('div', { className: 'rw-doc-body' },
|
|
10765
|
-
data.truncated ? h(Banner, { kind: 'info' }, t('outsideTruncated', { size: formatBytes(data.size) })) : null,
|
|
10766
10880
|
data.binary
|
|
10767
|
-
? h('div', { className: 'rw-outside-actions' }, h('div', { className: 'rw-hint' }, t('outsideBinary', { size: formatBytes(
|
|
10768
|
-
: h('pre', { className: 'rw-outside-text' }, typeof data.content === 'string' ? data.content : '')
|
|
10881
|
+
? h('div', { className: 'rw-outside-actions' }, h('div', { className: 'rw-hint' }, t('outsideBinary', { size: formatBytes(total) })))
|
|
10882
|
+
: h('pre', { className: 'rw-outside-text' }, typeof data.content === 'string' ? data.content : ''),
|
|
10883
|
+
footer);
|
|
10769
10884
|
}
|
|
10770
10885
|
return h('div', { className: 'rw-editor-pane' }, toolbar, body);
|
|
10771
10886
|
}
|
|
@@ -13884,8 +13999,28 @@ function rememberShowHidden(value) {
|
|
|
13884
13999
|
// found" page first. Claim the tab before it exists: a path that lands
|
|
13885
14000
|
// inside one of our workspaces opens straight in its tree tab, and the
|
|
13886
14001
|
// caller never has a native tab to close.
|
|
13887
|
-
|
|
14002
|
+
// The session's own workspace, matched by its local directory (linked) or
|
|
14003
|
+
// its placeholder (remote). Used to give the right machine priority when
|
|
14004
|
+
// two workspaces live on different hosts but share a path.
|
|
14005
|
+
function sessionWorkspaceOf(index, cwd) {
|
|
14006
|
+
var wanted = String(cwd == null ? '' : cwd).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
14007
|
+
if (wanted === '') return null;
|
|
14008
|
+
var all = (index.linked || []).concat(index.remote || []);
|
|
14009
|
+
var lowered = wanted.toLowerCase();
|
|
14010
|
+
for (var cursor = 0; cursor < all.length; cursor += 1) {
|
|
14011
|
+
var record = all[cursor];
|
|
14012
|
+
if (!record) continue;
|
|
14013
|
+
var local = String(record.localPath || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
14014
|
+
var placeholder = String(record.placeholderPath || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
14015
|
+
if ((local !== '' && local === lowered) || (placeholder !== '' && placeholder === lowered)) return record;
|
|
14016
|
+
}
|
|
14017
|
+
return null;
|
|
14018
|
+
}
|
|
14019
|
+
|
|
14020
|
+
function ownerOfPath(index, normalized, preferredHostId) {
|
|
13888
14021
|
var best = null;
|
|
14022
|
+
var bestHere = null;
|
|
14023
|
+
var host = String(preferredHostId || '');
|
|
13889
14024
|
function consider(list, kind) {
|
|
13890
14025
|
for (var cursor = 0; cursor < list.length; cursor += 1) {
|
|
13891
14026
|
var record = list[cursor];
|
|
@@ -13896,11 +14031,14 @@ function rememberShowHidden(value) {
|
|
|
13896
14031
|
// The deepest root wins, so a workspace nested inside another one
|
|
13897
14032
|
// keeps its own files.
|
|
13898
14033
|
if (!best || root.length > best.root.length) best = { kind: kind, record: record, root: root };
|
|
14034
|
+
if (host !== '' && String(record.hostId || '') === host) {
|
|
14035
|
+
if (!bestHere || root.length > bestHere.root.length) bestHere = { kind: kind, record: record, root: root };
|
|
14036
|
+
}
|
|
13899
14037
|
}
|
|
13900
14038
|
}
|
|
13901
14039
|
consider(index.linked || [], 'linked');
|
|
13902
14040
|
consider(index.remote || [], 'remote');
|
|
13903
|
-
return best;
|
|
14041
|
+
return bestHere || best;
|
|
13904
14042
|
}
|
|
13905
14043
|
|
|
13906
14044
|
// Native path tabs are the only place DSH shows us a session's cwd, so
|
|
@@ -13949,7 +14087,10 @@ function rememberShowHidden(value) {
|
|
|
13949
14087
|
function openOutside(scoped, absolute) {
|
|
13950
14088
|
var sessionId = currentSessionId();
|
|
13951
14089
|
var scope = sessionId !== '' ? { sessionId: sessionId } : {};
|
|
13952
|
-
|
|
14090
|
+
var opened = openOutsideFileTab(sidebar, scope, scoped, absolute) === true;
|
|
14091
|
+
// 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.
|
|
14093
|
+
return opened || slotFull === true;
|
|
13953
14094
|
}
|
|
13954
14095
|
|
|
13955
14096
|
function claimScope(owner) {
|
|
@@ -13966,16 +14107,18 @@ function rememberShowHidden(value) {
|
|
|
13966
14107
|
return scope;
|
|
13967
14108
|
}
|
|
13968
14109
|
|
|
13969
|
-
function takeSeed(normalized) {
|
|
14110
|
+
function takeSeed(normalized, sessionCwd) {
|
|
13970
14111
|
// DSH may keep the drive letter ("D:\data\x.md") or drop it
|
|
13971
14112
|
// ("\data\x.md"); both spellings have to be tried against the roots.
|
|
13972
14113
|
var candidates = [normalized];
|
|
13973
14114
|
var stripped = normalized.replace(/^[A-Za-z]:/, '');
|
|
13974
14115
|
if (stripped !== normalized && stripped.charAt(0) === '/') candidates.push(stripped);
|
|
13975
14116
|
return workspaceIndex().then(function (index) {
|
|
14117
|
+
var here = sessionWorkspaceOf(index, sessionCwd);
|
|
14118
|
+
var preferredHost = here && here.hostId ? String(here.hostId) : '';
|
|
13976
14119
|
var found = null;
|
|
13977
14120
|
for (var cursor = 0; cursor < candidates.length && !found; cursor += 1) {
|
|
13978
|
-
var owner = ownerOfPath(index, candidates[cursor]);
|
|
14121
|
+
var owner = ownerOfPath(index, candidates[cursor], preferredHost);
|
|
13979
14122
|
if (owner) found = { owner: owner, absolute: candidates[cursor] };
|
|
13980
14123
|
}
|
|
13981
14124
|
if (!found) {
|
|
@@ -13984,7 +14127,7 @@ function rememberShowHidden(value) {
|
|
|
13984
14127
|
var outside = candidates[0];
|
|
13985
14128
|
if (!outsideOpenable(outside)) return false;
|
|
13986
14129
|
var sessionId = currentSessionId();
|
|
13987
|
-
var cwd = sessionCwdOf(sessionId);
|
|
14130
|
+
var cwd = String(sessionCwd || '') || sessionCwdOf(sessionId);
|
|
13988
14131
|
if (cwd === '') return false;
|
|
13989
14132
|
return scanReferenceScope(cwd, '').then(function (scoped) {
|
|
13990
14133
|
if (!scoped || !scoped.root) return false;
|
|
@@ -14038,7 +14181,8 @@ function rememberShowHidden(value) {
|
|
|
14038
14181
|
if (normalized.charAt(0) !== '/' && /^[A-Za-z]:\//.test(normalized) === false) {
|
|
14039
14182
|
return original.apply(sidebar, arguments);
|
|
14040
14183
|
}
|
|
14041
|
-
|
|
14184
|
+
var seedCwd = scope && typeof scope.cwd === 'string' ? scope.cwd : '';
|
|
14185
|
+
takeSeed(normalized, seedCwd).then(function (claimed) {
|
|
14042
14186
|
if (!claimed) original.call(sidebar, seed, scope);
|
|
14043
14187
|
}, function () { original.call(sidebar, seed, scope); });
|
|
14044
14188
|
return undefined;
|
|
@@ -14052,7 +14196,8 @@ function rememberShowHidden(value) {
|
|
|
14052
14196
|
var normalizedFile = typeof path === 'string' ? path.split(String.fromCharCode(92)).join('/') : '';
|
|
14053
14197
|
var rooted = normalizedFile !== '' && (normalizedFile.charAt(0) === '/' || /^[A-Za-z]:\//.test(normalizedFile));
|
|
14054
14198
|
if (!rooted) return openFileOriginal.apply(sidebar, args);
|
|
14055
|
-
|
|
14199
|
+
var fileCwd = scope && typeof scope.cwd === 'string' ? scope.cwd : '';
|
|
14200
|
+
takeSeed(normalizedFile, fileCwd).then(function (claimed) {
|
|
14056
14201
|
if (!claimed) openFileOriginal.apply(sidebar, args);
|
|
14057
14202
|
}, function () { openFileOriginal.apply(sidebar, args); });
|
|
14058
14203
|
return undefined;
|
package/lib/index.js
CHANGED
|
@@ -4246,14 +4246,21 @@ 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
|
},
|
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.32.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",
|