dsh-linked-workspace 0.28.1 → 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 CHANGED
@@ -1,5 +1,27 @@
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
+
11
+ ## 0.29.0 — 2026-11-27
12
+
13
+ - A folder link in a Markdown preview no longer opens a file tab that could only fail. A trailing separator
14
+ settles it immediately; a link without one (say `sub`) is probed with `fs.stat` / `local.stat` first, and a
15
+ directory is revealed in the tree with a short note instead of a dead tab.
16
+ - The same error is no longer printed twice: a folder opened as a file used to say "is a directory: is a
17
+ directory, not something that can be read as a file", and now says it once.
18
+ - Ctrl/⌘-click and a middle click on a preview link open the target in its own tab, so two documents can be
19
+ compared side by side; dragging a link no longer navigates the window.
20
+ - Local file tabs on Windows are keyed case-insensitively, so `pics/note.md` and `PICS/note.md` no longer
21
+ produce two tabs for one file.
22
+ - Theme changes arrive through the host's `theme/change` event instead of a 1.5-second `getTheme()` poll
23
+ (the poll remains only as a fallback when no event is available).
24
+
3
25
  ## 0.28.1 — 2026-11-27
4
26
 
5
27
  - 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:…` 指纹)。
@@ -457,6 +470,14 @@ DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、
457
470
  5. 目录栏标题右侧的可用空间芯片:点「刷新目录」后它的 title(可用 / 已用 / 总量)随之更新,不再永远停在首次打开面板时的数值。
458
471
  6. 把窗口最小化或切到别的应用 30 秒再回来:占位目录转交仍在工作(后台不轮询、回到前台立刻补一次),并且这段时间没有产生额外的网络请求。
459
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
+
460
481
  ## 预览里的链接(Unreleased)
461
482
 
462
483
  1. 在一份 Markdown 预览里点一个**指向同目录另一个文件**的相对链接(`other.md`、`./sub/a.md`、`../latex/table.tex`):目标文件在同一个文件面板里打开,地址栏不变,页面不跳转;目标已经打开时只切到那个标签,不新开重复标签。
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
 
@@ -2363,6 +2368,8 @@ function isInsideRoot(root, target) {
2363
2368
  // host, and the panel that owns the tab does not carry the workspace root.
2364
2369
  // The two lists change rarely, so one lookup serves every click for 30 s.
2365
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 };
2366
2373
  function scopeRootOf(scope) {
2367
2374
  if (!scope || (scope.kind !== 'linked' && scope.kind !== 'remote')) return Promise.resolve('');
2368
2375
  var key = scope.kind + ':' + (scope.id || '');
@@ -2382,11 +2389,48 @@ function isInsideRoot(root, target) {
2382
2389
  });
2383
2390
  }
2384
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
+
2385
2426
  function openRemoteFileTab(sidebar, scope, source, filePath) {
2386
2427
  if (!sidebar || typeof sidebar.openTab !== 'function') return false;
2387
2428
  var key = scopeKeyOf(sourceScopeOf(source)) + ':' + filePath;
2388
2429
  var kind = remoteFileSlotFor(key);
2389
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.
2390
2434
  sidebar.openTab({
2391
2435
  type: kind,
2392
2436
  id: kind,
@@ -2394,6 +2438,7 @@ function isInsideRoot(root, target) {
2394
2438
  path: filePath,
2395
2439
  meta: sourceMetaOf(source),
2396
2440
  }, scope);
2441
+ claimNewNativeTabs(sidebar, known);
2397
2442
  return true;
2398
2443
  }
2399
2444
 
@@ -2409,6 +2454,8 @@ function isInsideRoot(root, target) {
2409
2454
  meta.revealPath = options.relative || '';
2410
2455
  meta.revealSide = options.side === 'local' ? 'local' : 'remote';
2411
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';
2412
2459
  try {
2413
2460
  sidebar.openTab({ type: type, id: type, title: t(remoteOnly ? 'remoteTabTitle' : 'tabTitle'), path: '/', meta: meta }, scope);
2414
2461
  return true;
@@ -3785,6 +3832,10 @@ function isInsideRoot(root, target) {
3785
3832
  // so name the usual cause and the way back whenever this code shows up.
3786
3833
  var hint = error.code === 'FS_PERMISSION' ? t('permissionHint') : '';
3787
3834
  if (!detail || detail === known) return known + hint;
3835
+ // The host often starts its own message with the generic text ("is a
3836
+ // directory; open it as a folder"), so prefixing the code text said the
3837
+ // same thing twice: "is a directory: is a directory, ...".
3838
+ if (detail.indexOf(known) === 0) return detail + hint;
3788
3839
  return known + (locale === 'zh' ? ':' : ': ') + detail + hint;
3789
3840
  }
3790
3841
 
@@ -6515,6 +6566,40 @@ function isInsideRoot(root, target) {
6515
6566
  setCache({ entries: new Map() });
6516
6567
  }, [props.forceTick]);
6517
6568
 
6569
+ // F1: a folder link in a preview should land the reader on that folder, and
6570
+ // a row only exists once its parents are expanded and listed — so expand the
6571
+ // whole chain, ask for every level, then scroll the row into view.
6572
+ useEffect(function () {
6573
+ if (!props.revealDirPath || !props.revealDirTick) return undefined;
6574
+ var base = String(rootPath || '').replace(/[\\/]+$/, '');
6575
+ var wanted = String(props.revealDirPath).replace(/[\\/]+$/, '');
6576
+ if (base === '' || wanted === '') return undefined;
6577
+ var sep = base.indexOf('\\') >= 0 ? '\\' : '/';
6578
+ var baseSlash = base.replace(/\\/g, '/');
6579
+ var wantedSlash = wanted.replace(/\\/g, '/');
6580
+ if (wantedSlash !== baseSlash && wantedSlash.indexOf(baseSlash + '/') !== 0) return undefined;
6581
+ var chain = [baseSlash];
6582
+ if (wantedSlash !== baseSlash) {
6583
+ wantedSlash.slice(baseSlash.length + 1).split('/').forEach(function (part) {
6584
+ if (!part || part === '.' || part === '..') return;
6585
+ chain.push(chain[chain.length - 1] + '/' + part);
6586
+ });
6587
+ }
6588
+ var paths = chain.map(function (item) { return sep === '\\' ? item.replace(/\//g, '\\') : item; });
6589
+ setExpanded(function (previous) {
6590
+ var next = new Set(previous);
6591
+ paths.forEach(function (item) { next.add(item); });
6592
+ return next;
6593
+ });
6594
+ paths.forEach(function (item) { load(item); });
6595
+ var targetPath = paths[paths.length - 1];
6596
+ var timer = setTimeout(function () {
6597
+ var row = document.querySelector('button.rw-row[data-dir-path="' + targetPath.replace(/"/g, '\\"') + '"]');
6598
+ if (row && typeof row.scrollIntoView === 'function') row.scrollIntoView({ block: 'center' });
6599
+ }, 700);
6600
+ return function () { clearTimeout(timer); };
6601
+ }, [props.revealDirTick]);
6602
+
6518
6603
  function toggle(path) {
6519
6604
  setExpanded(function (previous) {
6520
6605
  var next = new Set(previous);
@@ -7853,13 +7938,15 @@ function rememberShowHidden(value) {
7853
7938
 
7854
7939
  // A link in the preview used to navigate the whole window: the client is a
7855
7940
  // 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
- function previewLink(event) {
7941
+ // the reader lost the panel with it. Every anchor is ours to handle now,
7942
+ // including the two gestures that never reach onClick: the middle button
7943
+ // (auxclick) and dragging a link out of the page.
7944
+ function anchorOf(event) {
7858
7945
  var node = event && event.target;
7859
- var anchor = node && typeof node.closest === 'function' ? node.closest('a') : null;
7860
- if (!anchor) return;
7861
- event.preventDefault();
7862
- event.stopPropagation();
7946
+ return node && typeof node.closest === 'function' ? node.closest('a') : null;
7947
+ }
7948
+
7949
+ function followAnchor(anchor, options) {
7863
7950
  var href = String(anchor.getAttribute('href') || '').trim();
7864
7951
  if (href === '') return;
7865
7952
  if (href.charAt(0) === '#') {
@@ -7877,7 +7964,30 @@ function rememberShowHidden(value) {
7877
7964
  return;
7878
7965
  }
7879
7966
  if (scheme !== '' && !/^[a-zA-Z]:[\\/]/.test(href)) return;
7880
- if (onOpenLink) onOpenLink(href);
7967
+ if (onOpenLink) onOpenLink(href, options || {});
7968
+ }
7969
+
7970
+ function previewLink(event) {
7971
+ var anchor = anchorOf(event);
7972
+ if (!anchor) return;
7973
+ event.preventDefault();
7974
+ event.stopPropagation();
7975
+ followAnchor(anchor, { newTab: Boolean(event.ctrlKey || event.metaKey) });
7976
+ }
7977
+
7978
+ // The middle button is the browser's own "open elsewhere" gesture: swallow
7979
+ // it and open the target in its own tab instead of letting the app navigate.
7980
+ function previewAuxClick(event) {
7981
+ if (!event || event.button !== 1) return;
7982
+ var anchor = anchorOf(event);
7983
+ if (!anchor) return;
7984
+ event.preventDefault();
7985
+ event.stopPropagation();
7986
+ followAnchor(anchor, { newTab: true });
7987
+ }
7988
+
7989
+ function previewDragStart(event) {
7990
+ if (anchorOf(event)) event.preventDefault();
7881
7991
  }
7882
7992
 
7883
7993
  function load() {
@@ -8145,7 +8255,7 @@ function rememberShowHidden(value) {
8145
8255
  ? h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
8146
8256
  state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
8147
8257
  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)
8258
+ state.html ? h('div', { ref: docPreviewRef, className: 'rw-doc-preview', onScroll: rememberScroll, onClick: previewLink, onAuxClick: previewAuxClick, onDragStart: previewDragStart, dangerouslySetInnerHTML: { __html: state.html } }) : null)
8149
8259
  : h('div', { className: 'rw-doc-body', ref: docBodyRef, onScroll: rememberScroll },
8150
8260
  state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
8151
8261
  h('input', {
@@ -8476,12 +8586,17 @@ function rememberShowHidden(value) {
8476
8586
  useEffect(function () {
8477
8587
  var wanted = tabMeta.revealPath ? String(tabMeta.revealPath) : '';
8478
8588
  if (!wanted || !selected) return;
8479
- var stamp = String(tabMeta.revealAt || '') + ':' + wanted;
8589
+ var stamp = String(tabMeta.revealAt || '') + ':' + wanted + ':' + String(tabMeta.revealKind || '');
8480
8590
  if (revealedRef.current === stamp) return;
8481
8591
  revealedRef.current = stamp;
8482
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
+ }
8483
8598
  openInternalFile(side, wanted, { pinned: true });
8484
- }, [tabMeta.revealPath, tabMeta.revealAt, tabMeta.revealSide, selected && selected.key]);
8599
+ }, [tabMeta.revealPath, tabMeta.revealAt, tabMeta.revealSide, tabMeta.revealKind, selected && selected.key]);
8485
8600
 
8486
8601
  var scopeRef = selected ? sourceScopeOf(selected) : null;
8487
8602
 
@@ -8571,6 +8686,10 @@ function rememberShowHidden(value) {
8571
8686
  var treeForceState = useState(0);
8572
8687
  var treeForceTick = treeForceState[0];
8573
8688
  var setTreeForceTick = treeForceState[1];
8689
+ // F1: a folder link asks the trees to open the way down to that folder.
8690
+ var revealDirState = useState(null);
8691
+ var revealDir = revealDirState[0];
8692
+ var setRevealDir = revealDirState[1];
8574
8693
  var fileDirtyState = useState({});
8575
8694
  var fileDirty = fileDirtyState[0];
8576
8695
  var setFileDirty = fileDirtyState[1];
@@ -8749,7 +8868,7 @@ function rememberShowHidden(value) {
8749
8868
 
8750
8869
  // A link inside the preview resolves against the file that holds it, and
8751
8870
  // only opens when it stays inside this workspace.
8752
- function openPreviewLink(href) {
8871
+ function openPreviewLink(href, options) {
8753
8872
  if (!selected) return;
8754
8873
  var file = openFiles.filter(function (item) { return item.key === activeFileKey; })[0];
8755
8874
  if (!file) return;
@@ -8757,9 +8876,47 @@ function rememberShowHidden(value) {
8757
8876
  var root = side === 'remote' ? String(selected.remotePath || '') : String(selected.localPath || '');
8758
8877
  var resolved = resolveLinkTarget(file.path, href);
8759
8878
  if (!resolved) return;
8760
- if (/[\\/]$/.test(resolved)) { showNotice('info', t('linkFolder', { path: resolved })); return; }
8879
+ // F1: a folder link is not a failure, it is a place. Expand the tree down
8880
+ // to it and locate the row, then say why nothing was opened.
8881
+ if (/[\\/]$/.test(resolved)) {
8882
+ if (isInsideRoot(root, resolved)) setRevealDir({ side: side, path: resolved, at: Date.now() });
8883
+ showNotice('info', t('linkFolder', { path: resolved }));
8884
+ return;
8885
+ }
8761
8886
  if (!isInsideRoot(root, resolved)) { showNotice('info', t('linkOutside', { path: resolved })); return; }
8762
- openByMode(side, resolved);
8887
+ // "sub" without a trailing slash may still be a folder, and the separator
8888
+ // alone cannot tell. Ask the host before opening a tab that could only
8889
+ // fail with "is a directory".
8890
+ var probe = side === 'local'
8891
+ ? apiCall('local.stat', { path: resolved })
8892
+ : apiCall('fs.stat', Object.assign({}, scopeParams(scopeRef), { path: resolved }));
8893
+ probe.then(function (result) {
8894
+ var type = result && result.type ? String(result.type) : '';
8895
+ if (type === 'dir' || type === 'directory') {
8896
+ setRevealDir({ side: side, path: resolved, at: Date.now() });
8897
+ showNotice('info', t('linkFolder', { path: resolved }));
8898
+ return;
8899
+ }
8900
+ // F2: Ctrl/⌘-click asks for both documents at once, which only a sidebar
8901
+ // tab can give: the pane shows one file at a time.
8902
+ if (options && options.newTab && openInSidebarTab(side, resolved)) return;
8903
+ openByMode(side, resolved);
8904
+ }, function (error) {
8905
+ showNotice('error', t('openFailed') + ':' + messageOf(error, t, locale));
8906
+ });
8907
+ }
8908
+
8909
+ // F2: a second view of the same workspace, opened from a link.
8910
+ function openInSidebarTab(side, filePath) {
8911
+ var service = sidebarService(ctx);
8912
+ if (!service) return false;
8913
+ if (side === 'remote') {
8914
+ return Boolean(selected) && openRemoteFileTab(service, props.scope, selected, filePath);
8915
+ }
8916
+ if (typeof service.openFile === 'function') {
8917
+ try { service.openFile(props.scope, filePath, basename(filePath)); return true; } catch (error) { return false; }
8918
+ }
8919
+ return false;
8763
8920
  }
8764
8921
 
8765
8922
  function openByMode(side, filePath, options) {
@@ -8785,9 +8942,22 @@ function rememberShowHidden(value) {
8785
8942
  openInternalFile(side, filePath, options || { pinned: true });
8786
8943
  }
8787
8944
 
8945
+ // Windows and macOS resolve paths case-insensitively, so one file can reach
8946
+ // us as "pics/note.md" from one link and "PICS/note.md" from another; both
8947
+ // used to become their own tab. Normalise the local side only — the remote
8948
+ // side is POSIX, where case is meaningful.
8949
+ function panelFileKey(side, filePath) {
8950
+ var path = String(filePath || '');
8951
+ if (side !== 'remote') {
8952
+ if (path.indexOf('\\') >= 0 || /^[a-zA-Z]:[\\/]/.test(path)) path = path.replace(/\//g, '\\');
8953
+ path = path.toLowerCase();
8954
+ }
8955
+ return side + ':' + (side === 'remote' ? scopeKeyOf(scopeRef) : 'local') + ':' + path;
8956
+ }
8957
+
8788
8958
  function openInternalFile(side, filePath, options) {
8789
8959
  var opts = options || { pinned: true };
8790
- var key = side + ':' + (side === 'remote' ? scopeKeyOf(scopeRef) : 'local') + ':' + filePath;
8960
+ var key = panelFileKey(side, filePath);
8791
8961
  setOpenFiles(function (previous) {
8792
8962
  var existing = previous.filter(function (file) { return file.key === key; })[0];
8793
8963
  if (existing) {
@@ -8825,7 +8995,7 @@ function rememberShowHidden(value) {
8825
8995
  // that has since changed. Close it and re-read the tree instead of leaving
8826
8996
  // a tab that can only fail.
8827
8997
  function dropOpenFile(side, filePath) {
8828
- var key = side + ':' + (side === 'remote' ? scopeKeyOf(scopeRef) : 'local') + ':' + filePath;
8998
+ var key = panelFileKey(side, filePath);
8829
8999
  setOpenFiles(function (previous) {
8830
9000
  return previous.filter(function (file) { return file.key !== key; });
8831
9001
  });
@@ -10140,6 +10310,8 @@ function rememberShowHidden(value) {
10140
10310
  onPin: function (filePath) { pinByMode('remote', filePath); },
10141
10311
  refreshTick: localTick,
10142
10312
  forceTick: treeForceTick,
10313
+ revealDirPath: revealDir && revealDir.side === 'remote' ? revealDir.path : '',
10314
+ revealDirTick: revealDir && revealDir.side === 'remote' ? revealDir.at : 0,
10143
10315
  onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'remote' }, info)); openContextMenu('remote', info); },
10144
10316
  })),
10145
10317
  selected.kind === 'linked'
@@ -10167,6 +10339,8 @@ function rememberShowHidden(value) {
10167
10339
  onPin: function (filePath) { pinByMode('local', filePath); },
10168
10340
  refreshTick: localTick,
10169
10341
  forceTick: treeForceTick,
10342
+ revealDirPath: revealDir && revealDir.side === 'local' ? revealDir.path : '',
10343
+ revealDirTick: revealDir && revealDir.side === 'local' ? revealDir.at : 0,
10170
10344
  onContextMenu: function (info) { setSelectedEntry(Object.assign({ side: 'local' }, info)); openContextMenu('local', info); },
10171
10345
  }))
10172
10346
  : null);
@@ -13426,10 +13600,94 @@ function rememberShowHidden(value) {
13426
13600
  try { sidebar.closeTab(tab.id, scope); } catch (error) { /* the page is gone already */ }
13427
13601
  }
13428
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
+
13429
13687
  function handOver(tab) {
13430
13688
  var normalized = String(tab && tab.path ? tab.path : '').replace(/\\/g, '/');
13431
13689
  var match = PLACEHOLDER_PATH.exec(normalized);
13432
- if (!match) return;
13690
+ if (!match) { takeRemotePath(tab, normalized); return; }
13433
13691
  var relative = String(match[2] || '').replace(/^\/+/, '');
13434
13692
  // Directories and extension-less names are not ours to render.
13435
13693
  if (relative === '' || /\/$/.test(relative) || !/\.[^./]+$/.test(relative)) return;
@@ -13459,6 +13717,13 @@ function rememberShowHidden(value) {
13459
13717
  scanning = true;
13460
13718
  try {
13461
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
+ }
13462
13727
  for (var index = 0; index < tabs.length; index += 1) handOver(tabs[index]);
13463
13728
  } catch (error) {
13464
13729
  /* a sidebar without path tabs simply never hands over */
@@ -13514,9 +13779,21 @@ function rememberShowHidden(value) {
13514
13779
  } catch (error) { /* theme service unavailable */ }
13515
13780
  };
13516
13781
  sync();
13517
- var timer = setInterval(sync, 1500);
13518
- if (timer && typeof timer.unref === 'function') timer.unref();
13519
- return function () { clearInterval(timer); };
13782
+ // The theme contract asks for event-driven sync ("continuous sync only
13783
+ // through the theme/change event"); a 1.5 s poll was only a stand-in.
13784
+ var off = null;
13785
+ if (typeof ctx.on === 'function') {
13786
+ try { off = ctx.on('theme/change', function () { sync(); }); } catch (error) { off = null; }
13787
+ }
13788
+ if (!off) {
13789
+ var timer = setInterval(sync, 1500);
13790
+ if (timer && typeof timer.unref === 'function') timer.unref();
13791
+ return function () { clearInterval(timer); };
13792
+ }
13793
+ return function () {
13794
+ if (typeof off !== 'function') return;
13795
+ try { off(); } catch (error) { /* already disposed */ }
13796
+ };
13520
13797
  }, 'dsh-linked-workspace: app theme sync');
13521
13798
  ctx.effect(function () {
13522
13799
  if (syncDirectoryTabsRef) syncDirectoryTabsRef();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-linked-workspace",
3
- "version": "0.28.1",
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",