feat(tabs): show in folder from the tab context menu - #498
Open
kiligzzz wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
需求
侧边栏打开一个文件后,没有入口回到它所在的目录 —— 尤其是文件不是自己点开的时候(比如 agent 导出一份 CSV 后直接
sidebar_open打开),想在 Finder / 资源管理器里看一眼就得回到文件树里一层层找回去。改动
Tab 右键菜单为「有文件的 tab」新增首项**「在文件夹中显示」**,在系统文件管理器中定位并选中该文件。
能力本身早已存在,只是缺这个入口:文件树的「在应用中打开」菜单一直在用宿主路由
open.external(action: 'reveal'),revealCommand在 macOS 走open -R、Windows 走explorer /select,、Linux 打开父目录。本 PR 只补 tab 标签条这一处入口,未新增任何宿主能力。实现
沿用 tab 菜单既有形状,
TabBar保持纯展示:TabBar新增可选onRevealPath,经WorkbenchActions.revealPath由 shell 注入(与onFloatTab/onPinTab同款)path且 回调已接线path;git / terminal / browser 没有,因此天然不出现path,其精简菜单不受影响parseOpenWithConfig+openWithSshActive,与resolveOpenWithTargets对文件树菜单的规则一致EditorHost的openWith同契约)无新增 i18n key:
showInFolder已存在于全部 20 个 locale。验证
pnpm typecheck通过pnpm test:107 文件 / 1140 passed / 9 skipped / 0 failedtests/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 未改动,保持改动面最小。