Skip to content

fix(client): keep the host workspace explorer for local sessions - #176

Merged
flymysql merged 1 commit into
flymysql:mainfrom
wsmrock:fix/local-native-explorer-main
Nov 19, 2026
Merged

flymysql merged 1 commit into
flymysql:mainfrom
wsmrock:fix/local-native-explorer-main

Conversation

@wsmrock

@wsmrock wsmrock commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

这是什么

纯本地会话的「工作区文件」面板被本插件接管了:routeWorkspaceFiles() 用 remote || localWorkspaceSession(sessionId) 决定是否改道到 NATIVE_EXPLORER,于是本地项目看到的是插件 explorer。插件菜单只有「展开/收起、打开文件、下载到本地镜像、复制相对/绝对地址、重命名、删除」,宿主面板原本的「在文件管理器中显示、在应用中打开、上传到此处、新建文件夹/文件、压缩并下载」全没了。

本 PR 把条件收成 remote:镜像(远程)会话仍走插件 explorer,纯本地项目回到宿主面板。

没有关联 issue:仓库里没搜到同题报告,也没有另开(若需要我先补一个 issue 再挂 Fixes #,说一声)。

自检清单

  • npm test 全绿(含改写后的回归测试,见下)
  • node check.mjs 通过
  • 行尾 LF(git diff --check 干净,两个文件均为 LF)
  • README 双语同步 —— 不适用,本 PR 未改 README
  • 非发布 PR 不改版本号(package.json 仍为 1.2.1)

验证

  • 定向:test/client-lifecycle.test.js + test/local-workspace-client.test.js + test/native-explorer-autoopen.test.js → 37 pass。
  • 全量 npm test(改动基于当前 main a012941 验证):1539 tests / 1516 pass / 23 skipped / 0 fail;node check.mjs → check.mjs OK: no framework-constraint violations.
  • 回归性:把 lib/client.js 那一行改回旧写法,test/client-lifecycle.test.js 立即红 —— AssertionError [ERR_ASSERTION]: a local project keeps the host explorer, so its context menu keeps reveal/upload/create;改回新写法 22/22 绿。
  • 真机(Windows 11 + DSH 桌面版,dsh-remote 1.2.1):应用同一行改动并重启后,右键文件夹出现「在文件管理器中显示」,点击确实在资源管理器里选中该目录;面板徽标仍是「本地工作区」;镜像会话的右键菜单仍是插件那套(展开/下载到本地镜像等)。
  • Agent/工作区验证范围:本 PR 只改 files 面板的路由与一条断言,未触碰 Agent 循环、原生工具、PTC 或会话协议;上述均为脚本模型 + 测试夹具与真机手测,无真实模型结果需要区分,CI 里的 agent 验收矩阵(native/PTC × 0.2.0/0.2.1/0.2.2)只作回归跑,本 PR 全绿。
  • 宿主行为假设出处:原生面板的 reveal 由 dsh-client-ui-file-actions 调 ctx.remote.session.openWorkspacePath({ path, action: 'reveal' })(宿主侧 dsh-host-open-in-app / dsh-native-command 的 revealNativePath),所以只要 files 面板还是宿主那个,菜单项自然回来;NATIVE_EXPLORER = 'dsh-remote/explorer' 见 lib/client.js:6060。

备注

  • 分支基点:提交落在 385fa95(上一发布提交)而不是 a012941,因为我的 token 没有 workflow scope,推同时带上游 .github/workflows/* 提交的分支会被 GitHub 拒。同一 hunk 在该基点 test/client-lifecycle.test.js 22/22 通过,与当前 main 仍 MERGEABLE / CLEAN;需要 rebase 到 a012941 的话我可以另推。
  • 已有旧标签页的用户不受影响(dsh-remote/explorer 仍注册、仍渲染);新开的 files 面板才走宿主面板。如果你更想保留统一 explorer、改为往插件菜单补宿主那几项动作,我可以按那个方向重做本 PR。

routeWorkspaceFiles() sent every session that resolves to a local workspace
to this plugin's explorer as well, not just mirror-backed ones. Only a mirror
path needs that explorer; for a plain local project it is a straight loss:
same rows, but the host's file actions (reveal in file manager, open with,
upload, new folder/file, archive download) are gone from the context menu.

A plugin explorer is only a benefit where the host cannot address the path
at all. Keep the host pane for local projects and leave the mirror routing
untouched.

test/client-lifecycle.test.js asserted the old local behaviour; it now
asserts that the local case keeps kind "files" and its own session.
@flymysql

Copy link
Copy Markdown
Owner

验证通过:CI 与 Agent native/PTC(0.2.0/0.2.1/0.2.2)、macOS、Windows 全绿。

额外做了负对照:把 lib/client.js 换回 main 的版本后,新断言 a local project keeps the host explorer… 会失败(kind 变成 dsh-remote/explorer),换回 PR 版本即通过 —— 说明这条测试真的守住了行为,不是假绿。

方向也认同:本地项目用宿主自己的资源管理器,才能保留 reveal/open-with/upload/create/archive 这些本插件没实现的动作;镜像会话仍走共享 explorer。这同时部分回应了 #172(本地项目不再被插件的文件样式接管)。

感谢 @wsmrock 定位到 routeWorkspaceFiles 里 remote || localWorkspaceSession(sessionId) 这个多余条件。

@flymysql flymysql left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改动最小且方向正确,负对照确认测试有效。approve.

@flymysql
flymysql merged commit 153effb into flymysql:main Nov 19, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants