dsh-linked-workspace 0.28.1 → 0.29.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 +14 -0
- package/docs/VERIFY.md +13 -0
- package/lib/client.js +155 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.29.0 — 2026-11-27
|
|
4
|
+
|
|
5
|
+
- A folder link in a Markdown preview no longer opens a file tab that could only fail. A trailing separator
|
|
6
|
+
settles it immediately; a link without one (say `sub`) is probed with `fs.stat` / `local.stat` first, and a
|
|
7
|
+
directory is revealed in the tree with a short note instead of a dead tab.
|
|
8
|
+
- The same error is no longer printed twice: a folder opened as a file used to say "is a directory: is a
|
|
9
|
+
directory, not something that can be read as a file", and now says it once.
|
|
10
|
+
- Ctrl/⌘-click and a middle click on a preview link open the target in its own tab, so two documents can be
|
|
11
|
+
compared side by side; dragging a link no longer navigates the window.
|
|
12
|
+
- Local file tabs on Windows are keyed case-insensitively, so `pics/note.md` and `PICS/note.md` no longer
|
|
13
|
+
produce two tabs for one file.
|
|
14
|
+
- Theme changes arrive through the host's `theme/change` event instead of a 1.5-second `getTheme()` poll
|
|
15
|
+
(the poll remains only as a fallback when no event is available).
|
|
16
|
+
|
|
3
17
|
## 0.28.1 — 2026-11-27
|
|
4
18
|
|
|
5
19
|
- Links inside a Markdown preview no longer navigate the window — that navigation is what turned the whole
|
package/docs/VERIFY.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
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
4
|
|
|
5
|
+
## 预览链接的文件夹与并行打开(未发布)
|
|
6
|
+
|
|
7
|
+
1. 在一份 Markdown 里写 `[sub/](sub/)` 与 `[sub](sub)`(`sub` 是真实存在的目录),预览里先后点这两条:都只出
|
|
8
|
+
「这是文件夹链接,这里只打开文件」提示,目录树展开并把该目录滚到视野中,标签条不新增死标签。
|
|
9
|
+
2. 再写 `[gone](gone.md)`(不存在的文件)并点击:给出一次读取失败的提示,不会有悬停不掉的半开标签。
|
|
10
|
+
3. 把一个目录直接开进文件标签(或让某个打开的视图指向目录):错误文案只出现一次「目标是目录」,
|
|
11
|
+
不应出现「目标是目录:目标是目录」。
|
|
12
|
+
4. 预览里 **Ctrl/⌘ + 点击**一个文件链接:右侧栏多出一个「远程文件」标签、面板自身的标签不变,地址栏不变;
|
|
13
|
+
**中键点击**同样开一个标签且不发生导航;**拖拽**链接到页面其它位置不产生导航。
|
|
14
|
+
5. 在 Windows 本地目录里准备 `pics/note.md`,文档里分别写 `[a](pics/note.md)` 与 `[b](PICS/note.md)`,
|
|
15
|
+
先后点击两者:只应存在一个 `note.md` 标签。
|
|
16
|
+
6. 切换系统深浅色主题:界面跟随,控制台无报错(宿主提供 `theme/change` 事件时不依赖 1.5 秒轮询)。
|
|
17
|
+
|
|
5
18
|
## 主机密钥与输出编码(0.20.0)
|
|
6
19
|
|
|
7
20
|
1. 设置 → 联动工作区 → 「SSH 主机密钥与输出编码」应能看到「主机密钥策略」(tofu / strict)、「远端命令输出编码」(utf8 / gbk),以及已记住的主机列表(每行显示 `host:port` 与 `SHA256:…` 指纹)。
|
package/lib/client.js
CHANGED
|
@@ -2181,7 +2181,12 @@ function resolveLinkTarget(baseDir, href) {
|
|
|
2181
2181
|
parts.push(part)
|
|
2182
2182
|
})
|
|
2183
2183
|
}
|
|
2184
|
+
// A trailing separator is information, not noise: the caller tells "docs/"
|
|
2185
|
+
// (a folder) from "docs" (a file) with it, before anything is stat'ed.
|
|
2186
|
+
var trailing = /[\\/]$/.test(raw)
|
|
2184
2187
|
var joined = parts.join('/')
|
|
2188
|
+
// An absolute path already ends with the separator it was written with.
|
|
2189
|
+
if (trailing && joined !== '' && joined.charAt(joined.length - 1) !== '/') joined += '/'
|
|
2185
2190
|
return sep === '\\' ? joined.replace(/\//g, '\\') : joined
|
|
2186
2191
|
}
|
|
2187
2192
|
|
|
@@ -3785,6 +3790,10 @@ function isInsideRoot(root, target) {
|
|
|
3785
3790
|
// so name the usual cause and the way back whenever this code shows up.
|
|
3786
3791
|
var hint = error.code === 'FS_PERMISSION' ? t('permissionHint') : '';
|
|
3787
3792
|
if (!detail || detail === known) return known + hint;
|
|
3793
|
+
// The host often starts its own message with the generic text ("is a
|
|
3794
|
+
// directory; open it as a folder"), so prefixing the code text said the
|
|
3795
|
+
// same thing twice: "is a directory: is a directory, ...".
|
|
3796
|
+
if (detail.indexOf(known) === 0) return detail + hint;
|
|
3788
3797
|
return known + (locale === 'zh' ? ':' : ': ') + detail + hint;
|
|
3789
3798
|
}
|
|
3790
3799
|
|
|
@@ -6515,6 +6524,40 @@ function isInsideRoot(root, target) {
|
|
|
6515
6524
|
setCache({ entries: new Map() });
|
|
6516
6525
|
}, [props.forceTick]);
|
|
6517
6526
|
|
|
6527
|
+
// F1: a folder link in a preview should land the reader on that folder, and
|
|
6528
|
+
// a row only exists once its parents are expanded and listed — so expand the
|
|
6529
|
+
// whole chain, ask for every level, then scroll the row into view.
|
|
6530
|
+
useEffect(function () {
|
|
6531
|
+
if (!props.revealDirPath || !props.revealDirTick) return undefined;
|
|
6532
|
+
var base = String(rootPath || '').replace(/[\\/]+$/, '');
|
|
6533
|
+
var wanted = String(props.revealDirPath).replace(/[\\/]+$/, '');
|
|
6534
|
+
if (base === '' || wanted === '') return undefined;
|
|
6535
|
+
var sep = base.indexOf('\\') >= 0 ? '\\' : '/';
|
|
6536
|
+
var baseSlash = base.replace(/\\/g, '/');
|
|
6537
|
+
var wantedSlash = wanted.replace(/\\/g, '/');
|
|
6538
|
+
if (wantedSlash !== baseSlash && wantedSlash.indexOf(baseSlash + '/') !== 0) return undefined;
|
|
6539
|
+
var chain = [baseSlash];
|
|
6540
|
+
if (wantedSlash !== baseSlash) {
|
|
6541
|
+
wantedSlash.slice(baseSlash.length + 1).split('/').forEach(function (part) {
|
|
6542
|
+
if (!part || part === '.' || part === '..') return;
|
|
6543
|
+
chain.push(chain[chain.length - 1] + '/' + part);
|
|
6544
|
+
});
|
|
6545
|
+
}
|
|
6546
|
+
var paths = chain.map(function (item) { return sep === '\\' ? item.replace(/\//g, '\\') : item; });
|
|
6547
|
+
setExpanded(function (previous) {
|
|
6548
|
+
var next = new Set(previous);
|
|
6549
|
+
paths.forEach(function (item) { next.add(item); });
|
|
6550
|
+
return next;
|
|
6551
|
+
});
|
|
6552
|
+
paths.forEach(function (item) { load(item); });
|
|
6553
|
+
var targetPath = paths[paths.length - 1];
|
|
6554
|
+
var timer = setTimeout(function () {
|
|
6555
|
+
var row = document.querySelector('button.rw-row[data-dir-path="' + targetPath.replace(/"/g, '\\"') + '"]');
|
|
6556
|
+
if (row && typeof row.scrollIntoView === 'function') row.scrollIntoView({ block: 'center' });
|
|
6557
|
+
}, 700);
|
|
6558
|
+
return function () { clearTimeout(timer); };
|
|
6559
|
+
}, [props.revealDirTick]);
|
|
6560
|
+
|
|
6518
6561
|
function toggle(path) {
|
|
6519
6562
|
setExpanded(function (previous) {
|
|
6520
6563
|
var next = new Set(previous);
|
|
@@ -7853,13 +7896,15 @@ function rememberShowHidden(value) {
|
|
|
7853
7896
|
|
|
7854
7897
|
// A link in the preview used to navigate the whole window: the client is a
|
|
7855
7898
|
// single-page app with no route for a file path, so the page went blank and
|
|
7856
|
-
// the reader lost the panel with it. Every anchor is ours to handle now
|
|
7857
|
-
|
|
7899
|
+
// the reader lost the panel with it. Every anchor is ours to handle now,
|
|
7900
|
+
// including the two gestures that never reach onClick: the middle button
|
|
7901
|
+
// (auxclick) and dragging a link out of the page.
|
|
7902
|
+
function anchorOf(event) {
|
|
7858
7903
|
var node = event && event.target;
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7904
|
+
return node && typeof node.closest === 'function' ? node.closest('a') : null;
|
|
7905
|
+
}
|
|
7906
|
+
|
|
7907
|
+
function followAnchor(anchor, options) {
|
|
7863
7908
|
var href = String(anchor.getAttribute('href') || '').trim();
|
|
7864
7909
|
if (href === '') return;
|
|
7865
7910
|
if (href.charAt(0) === '#') {
|
|
@@ -7877,7 +7922,30 @@ function rememberShowHidden(value) {
|
|
|
7877
7922
|
return;
|
|
7878
7923
|
}
|
|
7879
7924
|
if (scheme !== '' && !/^[a-zA-Z]:[\\/]/.test(href)) return;
|
|
7880
|
-
if (onOpenLink) onOpenLink(href);
|
|
7925
|
+
if (onOpenLink) onOpenLink(href, options || {});
|
|
7926
|
+
}
|
|
7927
|
+
|
|
7928
|
+
function previewLink(event) {
|
|
7929
|
+
var anchor = anchorOf(event);
|
|
7930
|
+
if (!anchor) return;
|
|
7931
|
+
event.preventDefault();
|
|
7932
|
+
event.stopPropagation();
|
|
7933
|
+
followAnchor(anchor, { newTab: Boolean(event.ctrlKey || event.metaKey) });
|
|
7934
|
+
}
|
|
7935
|
+
|
|
7936
|
+
// The middle button is the browser's own "open elsewhere" gesture: swallow
|
|
7937
|
+
// it and open the target in its own tab instead of letting the app navigate.
|
|
7938
|
+
function previewAuxClick(event) {
|
|
7939
|
+
if (!event || event.button !== 1) return;
|
|
7940
|
+
var anchor = anchorOf(event);
|
|
7941
|
+
if (!anchor) return;
|
|
7942
|
+
event.preventDefault();
|
|
7943
|
+
event.stopPropagation();
|
|
7944
|
+
followAnchor(anchor, { newTab: true });
|
|
7945
|
+
}
|
|
7946
|
+
|
|
7947
|
+
function previewDragStart(event) {
|
|
7948
|
+
if (anchorOf(event)) event.preventDefault();
|
|
7881
7949
|
}
|
|
7882
7950
|
|
|
7883
7951
|
function load() {
|
|
@@ -8145,7 +8213,7 @@ function rememberShowHidden(value) {
|
|
|
8145
8213
|
? h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
8146
8214
|
state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
|
|
8147
8215
|
state.html ? h('style', { 'data-rw-katex': '1', dangerouslySetInnerHTML: { __html: state.css || '' } }) : null,
|
|
8148
|
-
state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, onClick: previewLink, dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
8216
|
+
state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, onClick: previewLink, onAuxClick: previewAuxClick, onDragStart: previewDragStart, dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
8149
8217
|
: h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
|
|
8150
8218
|
state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
|
|
8151
8219
|
h('input', {
|
|
@@ -8571,6 +8639,10 @@ function rememberShowHidden(value) {
|
|
|
8571
8639
|
var treeForceState = useState(0);
|
|
8572
8640
|
var treeForceTick = treeForceState[0];
|
|
8573
8641
|
var setTreeForceTick = treeForceState[1];
|
|
8642
|
+
// F1: a folder link asks the trees to open the way down to that folder.
|
|
8643
|
+
var revealDirState = useState(null);
|
|
8644
|
+
var revealDir = revealDirState[0];
|
|
8645
|
+
var setRevealDir = revealDirState[1];
|
|
8574
8646
|
var fileDirtyState = useState({});
|
|
8575
8647
|
var fileDirty = fileDirtyState[0];
|
|
8576
8648
|
var setFileDirty = fileDirtyState[1];
|
|
@@ -8749,7 +8821,7 @@ function rememberShowHidden(value) {
|
|
|
8749
8821
|
|
|
8750
8822
|
// A link inside the preview resolves against the file that holds it, and
|
|
8751
8823
|
// only opens when it stays inside this workspace.
|
|
8752
|
-
function openPreviewLink(href) {
|
|
8824
|
+
function openPreviewLink(href, options) {
|
|
8753
8825
|
if (!selected) return;
|
|
8754
8826
|
var file = openFiles.filter(function (item) { return item.key === activeFileKey; })[0];
|
|
8755
8827
|
if (!file) return;
|
|
@@ -8757,9 +8829,47 @@ function rememberShowHidden(value) {
|
|
|
8757
8829
|
var root = side === 'remote' ? String(selected.remotePath || '') : String(selected.localPath || '');
|
|
8758
8830
|
var resolved = resolveLinkTarget(file.path, href);
|
|
8759
8831
|
if (!resolved) return;
|
|
8760
|
-
|
|
8832
|
+
// F1: a folder link is not a failure, it is a place. Expand the tree down
|
|
8833
|
+
// to it and locate the row, then say why nothing was opened.
|
|
8834
|
+
if (/[\\/]$/.test(resolved)) {
|
|
8835
|
+
if (isInsideRoot(root, resolved)) setRevealDir({ side: side, path: resolved, at: Date.now() });
|
|
8836
|
+
showNotice('info', t('linkFolder', { path: resolved }));
|
|
8837
|
+
return;
|
|
8838
|
+
}
|
|
8761
8839
|
if (!isInsideRoot(root, resolved)) { showNotice('info', t('linkOutside', { path: resolved })); return; }
|
|
8762
|
-
|
|
8840
|
+
// "sub" without a trailing slash may still be a folder, and the separator
|
|
8841
|
+
// alone cannot tell. Ask the host before opening a tab that could only
|
|
8842
|
+
// fail with "is a directory".
|
|
8843
|
+
var probe = side === 'local'
|
|
8844
|
+
? apiCall('local.stat', { path: resolved })
|
|
8845
|
+
: apiCall('fs.stat', Object.assign({}, scopeParams(scopeRef), { path: resolved }));
|
|
8846
|
+
probe.then(function (result) {
|
|
8847
|
+
var type = result && result.type ? String(result.type) : '';
|
|
8848
|
+
if (type === 'dir' || type === 'directory') {
|
|
8849
|
+
setRevealDir({ side: side, path: resolved, at: Date.now() });
|
|
8850
|
+
showNotice('info', t('linkFolder', { path: resolved }));
|
|
8851
|
+
return;
|
|
8852
|
+
}
|
|
8853
|
+
// F2: Ctrl/⌘-click asks for both documents at once, which only a sidebar
|
|
8854
|
+
// tab can give: the pane shows one file at a time.
|
|
8855
|
+
if (options && options.newTab && openInSidebarTab(side, resolved)) return;
|
|
8856
|
+
openByMode(side, resolved);
|
|
8857
|
+
}, function (error) {
|
|
8858
|
+
showNotice('error', t('openFailed') + ':' + messageOf(error, t, locale));
|
|
8859
|
+
});
|
|
8860
|
+
}
|
|
8861
|
+
|
|
8862
|
+
// F2: a second view of the same workspace, opened from a link.
|
|
8863
|
+
function openInSidebarTab(side, filePath) {
|
|
8864
|
+
var service = sidebarService(ctx);
|
|
8865
|
+
if (!service) return false;
|
|
8866
|
+
if (side === 'remote') {
|
|
8867
|
+
return Boolean(selected) && openRemoteFileTab(service, props.scope, selected, filePath);
|
|
8868
|
+
}
|
|
8869
|
+
if (typeof service.openFile === 'function') {
|
|
8870
|
+
try { service.openFile(props.scope, filePath, basename(filePath)); return true; } catch (error) { return false; }
|
|
8871
|
+
}
|
|
8872
|
+
return false;
|
|
8763
8873
|
}
|
|
8764
8874
|
|
|
8765
8875
|
function openByMode(side, filePath, options) {
|
|
@@ -8785,9 +8895,22 @@ function rememberShowHidden(value) {
|
|
|
8785
8895
|
openInternalFile(side, filePath, options || { pinned: true });
|
|
8786
8896
|
}
|
|
8787
8897
|
|
|
8898
|
+
// Windows and macOS resolve paths case-insensitively, so one file can reach
|
|
8899
|
+
// us as "pics/note.md" from one link and "PICS/note.md" from another; both
|
|
8900
|
+
// used to become their own tab. Normalise the local side only — the remote
|
|
8901
|
+
// side is POSIX, where case is meaningful.
|
|
8902
|
+
function panelFileKey(side, filePath) {
|
|
8903
|
+
var path = String(filePath || '');
|
|
8904
|
+
if (side !== 'remote') {
|
|
8905
|
+
if (path.indexOf('\\') >= 0 || /^[a-zA-Z]:[\\/]/.test(path)) path = path.replace(/\//g, '\\');
|
|
8906
|
+
path = path.toLowerCase();
|
|
8907
|
+
}
|
|
8908
|
+
return side + ':' + (side === 'remote' ? scopeKeyOf(scopeRef) : 'local') + ':' + path;
|
|
8909
|
+
}
|
|
8910
|
+
|
|
8788
8911
|
function openInternalFile(side, filePath, options) {
|
|
8789
8912
|
var opts = options || { pinned: true };
|
|
8790
|
-
var key =
|
|
8913
|
+
var key = panelFileKey(side, filePath);
|
|
8791
8914
|
setOpenFiles(function (previous) {
|
|
8792
8915
|
var existing = previous.filter(function (file) { return file.key === key; })[0];
|
|
8793
8916
|
if (existing) {
|
|
@@ -8825,7 +8948,7 @@ function rememberShowHidden(value) {
|
|
|
8825
8948
|
// that has since changed. Close it and re-read the tree instead of leaving
|
|
8826
8949
|
// a tab that can only fail.
|
|
8827
8950
|
function dropOpenFile(side, filePath) {
|
|
8828
|
-
var key =
|
|
8951
|
+
var key = panelFileKey(side, filePath);
|
|
8829
8952
|
setOpenFiles(function (previous) {
|
|
8830
8953
|
return previous.filter(function (file) { return file.key !== key; });
|
|
8831
8954
|
});
|
|
@@ -10140,6 +10263,8 @@ function rememberShowHidden(value) {
|
|
|
10140
10263
|
onPin: function (filePath) { pinByMode('remote', filePath); },
|
|
10141
10264
|
refreshTick: localTick,
|
|
10142
10265
|
forceTick: treeForceTick,
|
|
10266
|
+
revealDirPath: revealDir && revealDir.side === 'remote' ? revealDir.path : '',
|
|
10267
|
+
revealDirTick: revealDir && revealDir.side === 'remote' ? revealDir.at : 0,
|
|
10143
10268
|
onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); openContextMenu('remote', info); },
|
|
10144
10269
|
})),
|
|
10145
10270
|
selected.kind === 'linked'
|
|
@@ -10167,6 +10292,8 @@ function rememberShowHidden(value) {
|
|
|
10167
10292
|
onPin: function (filePath) { pinByMode('local', filePath); },
|
|
10168
10293
|
refreshTick: localTick,
|
|
10169
10294
|
forceTick: treeForceTick,
|
|
10295
|
+
revealDirPath: revealDir && revealDir.side === 'local' ? revealDir.path : '',
|
|
10296
|
+
revealDirTick: revealDir && revealDir.side === 'local' ? revealDir.at : 0,
|
|
10170
10297
|
onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'local' }, info)); openContextMenu('local', info); },
|
|
10171
10298
|
}))
|
|
10172
10299
|
: null);
|
|
@@ -13514,9 +13641,21 @@ function rememberShowHidden(value) {
|
|
|
13514
13641
|
} catch (error) { /* theme service unavailable */ }
|
|
13515
13642
|
};
|
|
13516
13643
|
sync();
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13644
|
+
// The theme contract asks for event-driven sync ("continuous sync only
|
|
13645
|
+
// through the theme/change event"); a 1.5 s poll was only a stand-in.
|
|
13646
|
+
var off = null;
|
|
13647
|
+
if (typeof ctx.on === 'function') {
|
|
13648
|
+
try { off = ctx.on('theme/change', function () { sync(); }); } catch (error) { off = null; }
|
|
13649
|
+
}
|
|
13650
|
+
if (!off) {
|
|
13651
|
+
var timer = setInterval(sync, 1500);
|
|
13652
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
13653
|
+
return function () { clearInterval(timer); };
|
|
13654
|
+
}
|
|
13655
|
+
return function () {
|
|
13656
|
+
if (typeof off !== 'function') return;
|
|
13657
|
+
try { off(); } catch (error) { /* already disposed */ }
|
|
13658
|
+
};
|
|
13520
13659
|
}, 'dsh-linked-workspace: app theme sync');
|
|
13521
13660
|
ctx.effect(function () {
|
|
13522
13661
|
if (syncDirectoryTabsRef) syncDirectoryTabsRef();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-linked-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.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",
|