dsh-linked-workspace 0.29.0 → 0.30.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 +8 -0
- package/docs/VERIFY.md +8 -0
- package/lib/client.js +141 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.30.0 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
- A file link in a chat message that points into a remote workspace now opens **inside that workspace's tree
|
|
6
|
+
tab**, as one of its file tabs — not as a sibling of the directory tab, and not as a native tab that could
|
|
7
|
+
only report "file not found" (DSH resolves `/data/x.md` against the drive, so the path arrives as
|
|
8
|
+
`\data\x.md`). Asking for the same file again switches to the tab that is already open; a link to a folder
|
|
9
|
+
expands the tree and scrolls to it without opening anything.
|
|
10
|
+
|
|
3
11
|
## 0.29.0 — 2026-11-27
|
|
4
12
|
|
|
5
13
|
- A folder link in a Markdown preview no longer opens a file tab that could only fail. A trailing separator
|
package/docs/VERIFY.md
CHANGED
|
@@ -470,6 +470,14 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
|
|
|
470
470
|
5. 目录栏标题右侧的可用空间芯片:点「刷新目录」后它的 title(可用 / 已用 / 总量)随之更新,不再永远停在首次打开面板时的数值。
|
|
471
471
|
6. 把窗口最小化或切到别的应用 30 秒再回来:占位目录转交仍在工作(后台不轮询、回到前台立刻补一次),并且这段时间没有产生额外的网络请求。
|
|
472
472
|
|
|
473
|
+
## 聊天里的文件链接(Unreleased)
|
|
474
|
+
|
|
475
|
+
1. 在联动工作区的会话里,让模型输出一个**远端绝对路径**(例如 `/shared_data_ssd1/huangjh/docs/note.md`)并点它:右侧栏不应该再出现「文件不存在:\shared_data_ssd1\…」的原生标签,而是右侧栏只多出/聚焦该工作区的**目录树标签**,文件作为它的一个内部文件标签打开并显示内容(不是与目录标签同级的独立标签)。
|
|
476
|
+
2. 同一条链接再点一次:只切到那个已经打开的文件标签,标签数量不变(侧栏仍只有一个目录树标签)。
|
|
477
|
+
3. 让模型输出一个**远端目录**(`/shared_data_ssd1/huangjh/chatdir/`,带不带尾斜杠都试):目录树展开到该目录并滚动定位,**不新建**文件标签。
|
|
478
|
+
4. 点一个**本地**文件链接(`D:\…\note.md`):仍然由原生标签打开,不被接管。
|
|
479
|
+
5. 断开该主机的 SSH 连接后再点远端链接:不崩溃、不白屏;无法认证时保持原样(交接只在路径确实属于某个工作区时发生)。
|
|
480
|
+
|
|
473
481
|
## 预览里的链接(Unreleased)
|
|
474
482
|
|
|
475
483
|
1. 在一份 Markdown 预览里点一个**指向同目录另一个文件**的相对链接(`other.md`、`./sub/a.md`、`../latex/table.tex`):目标文件在同一个文件面板里打开,地址栏不变,页面不跳转;目标已经打开时只切到那个标签,不新开重复标签。
|
package/lib/client.js
CHANGED
|
@@ -2368,6 +2368,8 @@ function isInsideRoot(root, target) {
|
|
|
2368
2368
|
// host, and the panel that owns the tab does not carry the workspace root.
|
|
2369
2369
|
// The two lists change rarely, so one lookup serves every click for 30 s.
|
|
2370
2370
|
var scopeRootState = { at: 0, roots: null };
|
|
2371
|
+
// Same idea, but keeping the records: a hand-over needs the workspace name.
|
|
2372
|
+
var workspaceIndexState = { at: 0, index: null };
|
|
2371
2373
|
function scopeRootOf(scope) {
|
|
2372
2374
|
if (!scope || (scope.kind !== 'linked' && scope.kind !== 'remote')) return Promise.resolve('');
|
|
2373
2375
|
var key = scope.kind + ':' + (scope.id || '');
|
|
@@ -2387,11 +2389,48 @@ function isInsideRoot(root, target) {
|
|
|
2387
2389
|
});
|
|
2388
2390
|
}
|
|
2389
2391
|
|
|
2392
|
+
// Chat links open native tabs inside the sidebar's own adapter, and the tabs
|
|
2393
|
+
// we open land in that very list too. Remember the ids we created so the
|
|
2394
|
+
// hand-over below never mistakes its own work for something to take over.
|
|
2395
|
+
var ownedNativeTabs = new Set();
|
|
2396
|
+
|
|
2397
|
+
function nativeTabKeys(sidebar) {
|
|
2398
|
+
try {
|
|
2399
|
+
var tabs = sidebar.nativePathTabs() || [];
|
|
2400
|
+
var keys = [];
|
|
2401
|
+
for (var index = 0; index < tabs.length; index += 1) {
|
|
2402
|
+
keys.push(String(tabs[index].sessionId || '') + '|' + String(tabs[index].id || ''));
|
|
2403
|
+
}
|
|
2404
|
+
return keys;
|
|
2405
|
+
} catch (error) {
|
|
2406
|
+
return null;
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// The sidebar publishes the tab on its next render, so the diff runs on the
|
|
2411
|
+
// following task rather than inline.
|
|
2412
|
+
function claimNewNativeTabs(sidebar, known) {
|
|
2413
|
+
if (!known) return;
|
|
2414
|
+
setTimeout(function () {
|
|
2415
|
+
var keys = nativeTabKeys(sidebar);
|
|
2416
|
+
if (!keys) return;
|
|
2417
|
+
for (var index = 0; index < keys.length; index += 1) {
|
|
2418
|
+
if (known.indexOf(keys[index]) < 0) {
|
|
2419
|
+
if (ownedNativeTabs.size > 200) ownedNativeTabs.clear();
|
|
2420
|
+
ownedNativeTabs.add(keys[index]);
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
}, 0);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2390
2426
|
function openRemoteFileTab(sidebar, scope, source, filePath) {
|
|
2391
2427
|
if (!sidebar || typeof sidebar.openTab !== 'function') return false;
|
|
2392
2428
|
var key = scopeKeyOf(sourceScopeOf(source)) + ':' + filePath;
|
|
2393
2429
|
var kind = remoteFileSlotFor(key);
|
|
2394
2430
|
if (kind === undefined) return false;
|
|
2431
|
+
var known = nativeTabKeys(sidebar);
|
|
2432
|
+
// The slot id is the identity, so asking for the same file again focuses
|
|
2433
|
+
// the tab that is already open instead of stacking a second one.
|
|
2395
2434
|
sidebar.openTab({
|
|
2396
2435
|
type: kind,
|
|
2397
2436
|
id: kind,
|
|
@@ -2399,6 +2438,7 @@ function isInsideRoot(root, target) {
|
|
|
2399
2438
|
path: filePath,
|
|
2400
2439
|
meta: sourceMetaOf(source),
|
|
2401
2440
|
}, scope);
|
|
2441
|
+
claimNewNativeTabs(sidebar, known);
|
|
2402
2442
|
return true;
|
|
2403
2443
|
}
|
|
2404
2444
|
|
|
@@ -2414,6 +2454,8 @@ function isInsideRoot(root, target) {
|
|
|
2414
2454
|
meta.revealPath = options.relative || '';
|
|
2415
2455
|
meta.revealSide = options.side === 'local' ? 'local' : 'remote';
|
|
2416
2456
|
meta.revealAt = String(Date.now());
|
|
2457
|
+
// A folder has no file to open, so the panel reveals it in the tree.
|
|
2458
|
+
if (options.dir) meta.revealKind = 'dir';
|
|
2417
2459
|
try {
|
|
2418
2460
|
sidebar.openTab({ type: type, id: type, title: t(remoteOnly ? 'remoteTabTitle' : 'tabTitle'), path: '/', meta: meta }, scope);
|
|
2419
2461
|
return true;
|
|
@@ -8544,12 +8586,17 @@ function rememberShowHidden(value) {
|
|
|
8544
8586
|
useEffect(function () {
|
|
8545
8587
|
var wanted = tabMeta.revealPath ? String(tabMeta.revealPath) : '';
|
|
8546
8588
|
if (!wanted || !selected) return;
|
|
8547
|
-
var stamp = String(tabMeta.revealAt || '') + ':' + wanted;
|
|
8589
|
+
var stamp = String(tabMeta.revealAt || '') + ':' + wanted + ':' + String(tabMeta.revealKind || '');
|
|
8548
8590
|
if (revealedRef.current === stamp) return;
|
|
8549
8591
|
revealedRef.current = stamp;
|
|
8550
8592
|
var side = tabMeta.revealSide === 'local' && !remoteOnly ? 'local' : 'remote';
|
|
8593
|
+
if (tabMeta.revealKind === 'dir') {
|
|
8594
|
+
// Nothing to open: land the reader on the folder in the tree.
|
|
8595
|
+
setRevealDir({ side: side, path: wanted, at: Date.now() });
|
|
8596
|
+
return;
|
|
8597
|
+
}
|
|
8551
8598
|
openInternalFile(side, wanted, { pinned: true });
|
|
8552
|
-
}, [tabMeta.revealPath, tabMeta.revealAt, tabMeta.revealSide, selected && selected.key]);
|
|
8599
|
+
}, [tabMeta.revealPath, tabMeta.revealAt, tabMeta.revealSide, tabMeta.revealKind, selected && selected.key]);
|
|
8553
8600
|
|
|
8554
8601
|
var scopeRef = selected ? sourceScopeOf(selected) : null;
|
|
8555
8602
|
|
|
@@ -13553,10 +13600,94 @@ function rememberShowHidden(value) {
|
|
|
13553
13600
|
try { sidebar.closeTab(tab.id, scope); } catch (error) { /* the page is gone already */ }
|
|
13554
13601
|
}
|
|
13555
13602
|
|
|
13603
|
+
// A chat link to a remote file reaches the sidebar as a native tab whose
|
|
13604
|
+
// path DSH resolved against the drive ("\data\x.md"), and the native
|
|
13605
|
+
// viewer can only report "file not found". Paths that land inside one of
|
|
13606
|
+
// our workspaces are ours: open the file in our own tab, or reveal the
|
|
13607
|
+
// folder in the tree when the link points at one.
|
|
13608
|
+
var probing = new Set();
|
|
13609
|
+
|
|
13610
|
+
function workspaceIndex() {
|
|
13611
|
+
if (workspaceIndexState.index && Date.now() - workspaceIndexState.at < 30000) {
|
|
13612
|
+
return Promise.resolve(workspaceIndexState.index);
|
|
13613
|
+
}
|
|
13614
|
+
return Promise.all([
|
|
13615
|
+
apiCall('linked.list').then(function (result) { return (result && result.links) || []; }, function () { return []; }),
|
|
13616
|
+
apiCall('remote_workspaces.list').then(function (result) { return (result && result.workspaces) || []; }, function () { return []; }),
|
|
13617
|
+
]).then(function (both) {
|
|
13618
|
+
var index = { linked: both[0] || [], remote: both[1] || [] };
|
|
13619
|
+
workspaceIndexState = { at: Date.now(), index: index };
|
|
13620
|
+
return index;
|
|
13621
|
+
});
|
|
13622
|
+
}
|
|
13623
|
+
|
|
13624
|
+
function recordOf(index, scoped) {
|
|
13625
|
+
var list = scoped.linkedId ? index.linked : index.remote;
|
|
13626
|
+
var id = scoped.linkedId || scoped.remoteId;
|
|
13627
|
+
for (var cursor = 0; cursor < list.length; cursor += 1) {
|
|
13628
|
+
if (list[cursor] && list[cursor].id === id) return list[cursor];
|
|
13629
|
+
}
|
|
13630
|
+
return null;
|
|
13631
|
+
}
|
|
13632
|
+
|
|
13633
|
+
function takeRemotePath(tab, normalized) {
|
|
13634
|
+
if (normalized === '') return;
|
|
13635
|
+
// A drive path is the user's own disk. Only root-relative paths can be
|
|
13636
|
+
// the remote file DSH mangled into "\data\x.md".
|
|
13637
|
+
if (/^[A-Za-z]:[\\/]/.test(normalized)) return;
|
|
13638
|
+
var candidate = normalized;
|
|
13639
|
+
var key = String(tab.sessionId || '') + '|' + String(tab.id || '');
|
|
13640
|
+
if (ownedNativeTabs.has(key)) return;
|
|
13641
|
+
if (handled.has(key) || probing.has(key)) return;
|
|
13642
|
+
var scope = { sessionId: tab.sessionId };
|
|
13643
|
+
if (tab.cwd) scope.cwd = tab.cwd;
|
|
13644
|
+
if (probing.size > 50) probing.clear();
|
|
13645
|
+
probing.add(key);
|
|
13646
|
+
scanReferenceScope(String(tab.cwd || ''), '')
|
|
13647
|
+
.then(function (scoped) {
|
|
13648
|
+
if (!scoped || !scoped.root) return undefined;
|
|
13649
|
+
return workspaceIndex().then(function (index) {
|
|
13650
|
+
var owner = recordOf(index, scoped);
|
|
13651
|
+
if (!owner) return undefined;
|
|
13652
|
+
var root = String(scoped.root);
|
|
13653
|
+
var absolute;
|
|
13654
|
+
if (candidate.charAt(0) === '/') {
|
|
13655
|
+
absolute = root.charAt(0) === '/' ? candidate : candidate.replace(/\//g, '\\');
|
|
13656
|
+
} else {
|
|
13657
|
+
// The sidebar may have stored a workspace-relative path.
|
|
13658
|
+
absolute = root.replace(/[\/]+$/, '') + (root.charAt(0) === '/' ? '/' : '\\') + candidate.replace(/^[\/]+/, '');
|
|
13659
|
+
}
|
|
13660
|
+
if (!isInsideRoot(root, absolute)) return undefined;
|
|
13661
|
+
if (handled.size > 200) handled.clear();
|
|
13662
|
+
handled.add(key);
|
|
13663
|
+
var kind = scoped.linkedId ? 'linked' : 'remote';
|
|
13664
|
+
var stat = apiCall('fs.stat', scoped.linkedId
|
|
13665
|
+
? { linkedId: scoped.linkedId, path: absolute }
|
|
13666
|
+
: { remoteId: scoped.remoteId, path: absolute });
|
|
13667
|
+
return stat.then(function (result) {
|
|
13668
|
+
return result && result.type ? String(result.type) : '';
|
|
13669
|
+
}, function () { return ''; }).then(function (type) {
|
|
13670
|
+
if (type === 'dir' || type === 'directory') {
|
|
13671
|
+
var opened = openTreeTabAt(ctx, { kind: kind, id: owner.id, side: 'remote', relative: absolute, dir: true }, scope);
|
|
13672
|
+
if (!opened) return;
|
|
13673
|
+
} else {
|
|
13674
|
+
// A file belongs under the workspace's own tree tab, as one of
|
|
13675
|
+
// its file tabs — not as a sibling of the directory tab.
|
|
13676
|
+
var shown = openTreeTabAt(ctx, { kind: kind, id: owner.id, side: 'remote', relative: absolute }, scope);
|
|
13677
|
+
if (!shown) return;
|
|
13678
|
+
}
|
|
13679
|
+
try { sidebar.closeTab(tab.id, scope); } catch (error) { /* the page is gone already */ }
|
|
13680
|
+
});
|
|
13681
|
+
});
|
|
13682
|
+
})
|
|
13683
|
+
.catch(function () { /* not ours after all */ })
|
|
13684
|
+
.then(function () { probing.delete(key); }, function () { probing.delete(key); });
|
|
13685
|
+
}
|
|
13686
|
+
|
|
13556
13687
|
function handOver(tab) {
|
|
13557
13688
|
var normalized = String(tab && tab.path ? tab.path : '').replace(/\\/g, '/');
|
|
13558
13689
|
var match = PLACEHOLDER_PATH.exec(normalized);
|
|
13559
|
-
if (!match) return;
|
|
13690
|
+
if (!match) { takeRemotePath(tab, normalized); return; }
|
|
13560
13691
|
var relative = String(match[2] || '').replace(/^\/+/, '');
|
|
13561
13692
|
// Directories and extension-less names are not ours to render.
|
|
13562
13693
|
if (relative === '' || /\/$/.test(relative) || !/\.[^./]+$/.test(relative)) return;
|
|
@@ -13586,6 +13717,13 @@ function rememberShowHidden(value) {
|
|
|
13586
13717
|
scanning = true;
|
|
13587
13718
|
try {
|
|
13588
13719
|
var tabs = sidebar.nativePathTabs() || [];
|
|
13720
|
+
if (ownedNativeTabs.size > 0) {
|
|
13721
|
+
var live = new Set();
|
|
13722
|
+
for (var cursor = 0; cursor < tabs.length; cursor += 1) {
|
|
13723
|
+
live.add(String(tabs[cursor].sessionId || '') + '|' + String(tabs[cursor].id || ''));
|
|
13724
|
+
}
|
|
13725
|
+
ownedNativeTabs.forEach(function (item) { if (!live.has(item)) ownedNativeTabs.delete(item); });
|
|
13726
|
+
}
|
|
13589
13727
|
for (var index = 0; index < tabs.length; index += 1) handOver(tabs[index]);
|
|
13590
13728
|
} catch (error) {
|
|
13591
13729
|
/* a sidebar without path tabs simply never hands over */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.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",
|