Skip to content

feat(tabs): show in folder from the tab context menu - #498

Open
kiligzzz wants to merge 1 commit into
omdsh-dev:mainfrom
kiligzzz:feat/tab-reveal-in-folder
Open

feat(tabs): show in folder from the tab context menu#498
kiligzzz wants to merge 1 commit into
omdsh-dev:mainfrom
kiligzzz:feat/tab-reveal-in-folder

Conversation

@kiligzzz

@kiligzzz kiligzzz commented Sep 1, 2026

Copy link
Copy Markdown

需求

侧边栏打开一个文件后,没有入口回到它所在的目录 —— 尤其是文件不是自己点开的时候(比如 agent 导出一份 CSV 后直接 sidebar_open 打开),想在 Finder / 资源管理器里看一眼就得回到文件树里一层层找回去。

改动

Tab 右键菜单为「有文件的 tab」新增首项**「在文件夹中显示」**,在系统文件管理器中定位并选中该文件。

能力本身早已存在,只是缺这个入口:文件树的「在应用中打开」菜单一直在用宿主路由 open.externalaction: 'reveal'),revealCommand 在 macOS 走 open -R、Windows 走 explorer /select,、Linux 打开父目录。本 PR 只补 tab 标签条这一处入口,未新增任何宿主能力。

实现

沿用 tab 菜单既有形状,TabBar 保持纯展示:

  • TabBar 新增可选 onRevealPath,经 WorkbenchActions.revealPath 由 shell 注入(与 onFloatTab / onPinTab 同款)
  • 菜单项出现的条件是 tab 带 path回调已接线
    • editor tab 有 path;git / terminal / browser 没有,因此天然不出现
    • pinned virtual tab(跨会话注入)是终端、无 path,其精简菜单不受影响
  • SSH-remote 模式下隐藏:宿主本地的文件管理器打不开远程路径,此时 shell 不注入回调,菜单项直接不出现(而不是给一个点了没反应的项)。判定复用 parseOpenWithConfig + openWithSshActive,与 resolveOpenWithTargets 对文件树菜单的规则一致
  • 失败只记日志 —— 打不开是 OS 的对话框,不是侧边栏错误(与 EditorHostopenWith 同契约)

无新增 i18n keyshowInFolder 已存在于全部 20 个 locale。

验证

  • pnpm typecheck 通过
  • pnpm test:107 文件 / 1140 passed / 9 skipped / 0 failed
  • tests/tab-bar-context-menu.spec.tsx 扩展 3 条用例(该文件共 15 条全过):
    • path 且已接线 → 首项为「在文件夹中显示」,且用右键那个 tab 的路径回调(非当前激活 tab)
    • path 的 tab(git / terminal / browser,以及无 path 的 editor)→ 不出现该项
    • path 但未接线(SSH-remote)→ 菜单回到原本的 5 项

docs/external-plugin-guide.md §4.4 的 editor 行已同步该行为。

备注

Free window(浮窗)标题栏的右键菜单仍是 dock / close 两项,本 PR 未改动,保持改动面最小。

Right-clicking a tab backed by a file now offers "show in folder" as the
leading entry, revealing (and selecting) the file in the OS file manager.

The capability already existed for the file tree's "open with" menu — the
host route `open.external` with `action: 'reveal'` spawns `open -R` on
macOS, `explorer /select,` on Windows and opens the parent directory on
Linux. Only the tab-strip entry point was missing, so a file opened in
the sidebar (e.g. handed over by an agent) had no way back to its folder
without walking the tree to it.

Wiring follows the existing shape of the tab menu: TabBar stays pure
presentation and receives an optional `onRevealPath`, threaded through
`WorkbenchActions.revealPath` from the sidebar shell. The entry surfaces
only when the tab carries a `path` (editor tabs do; git/terminal/browser
do not) and the callback is wired — which is also how SSH-remote mode
suppresses it: a host-local file manager cannot reach a remote path, the
same rule `resolveOpenWithTargets` applies to the tree's own menu.

No new i18n key: `showInFolder` already exists in all 20 locales.
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.

1 participant