[gh-8226] Add "Open with <Editor>" item to tab and file-tree menus (flag-gated)#12905
[gh-8226] Add "Open with <Editor>" item to tab and file-tree menus (flag-gated)#129050xBB2B wants to merge 3 commits into
Conversation
… tree menus Adds PRODUCT.md and TECH.md for a feature-flagged "Open with <Editor>" menu item on two existing right-click context menus: - session tab (horizontal and vertical tab bars) - file-tree directory header The label is data-driven from the user's existing `code.editor.open_file_editor` setting; no editor is hardcoded. The Warp Drive workspace picker is explicitly out of scope (cloud entity, no local cwd). Remote/SSH paths and the click-on-output entry point from the original warpdotdev#8226 ask are deferred. Refs warpdotdev#8226.
Wires the spec at `specs/warpdotdevgh-8226-open-with-editor/`: - Adds `FeatureFlag::OpenDirectoryInExternalEditor` (Cargo feature `open_directory_in_external_editor`), default off. - Adds `open_directory_in_external_editor` in `util::file::external_editor` with macOS / Linux / Windows implementations that reuse each platform's existing editor-launch path with a `None` line/column; falls back to `ctx.open_file_path` (Finder / xdg-open / Explorer) when no editor is configured or installed. - Adds the shared label helper `open_with_editor_menu_label*` so both menus render "Open with <Editor>" (External), "Open in editor" (SystemDefault / EnvEditor with `$EDITOR` set), or omit the item (Warp viewer, EnvEditor with empty `$EDITOR`). - Session tab menu (`tab.rs`): new `open_in_editor_menu_items` section inserted between `modify_tab_menu_items` and `close_tab_menu_items`. Wires `WorkspaceAction::OpenTabCwdInExternalEditor` to read the focused session's current cwd and dispatch the platform launcher. - File-tree menu (`code/file_tree/view.rs`): adds the item directly after "Reveal in Finder" for `DirectoryHeader` entries (not files), gated on the flag and on label availability. Threads `&AppContext` into `context_menu_items` to read the editor setting. - Test: 4 new pure tests in `external_editor::mod_tests` covering all four `EditorChoice` variants of the menu label helper. Refs warpdotdev#8226. Spec PR: warpdotdev#12901.
…schemes The first cut of `mac::open_directory` delegated to `Editor::open`, which builds a `<scheme>://file/<path>` URL for VSCode / Cursor / Windsurf / Zed and hands it to `/usr/bin/open`. Those URL schemes only open files; when the path is a directory, macOS LaunchServices routes the request back to Finder. The menu correctly read "Open with VS Code" but the folder opened in Finder. Switch to the macOS-native form `/usr/bin/open -a <app-bundle> <dir>`, which every supported GUI editor interprets as "open this folder as a workspace." Fallback to `ctx.open_file_path` is preserved for the case where the editor's bundle isn't resolvable. Verified locally with VS Code on macOS.
|
Every PR must be linked to a same-repo issue before Oz can review it. Next step: open or find a same-repo issue describing this change, then link it to this PR by adding See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
Next step: open or find a same-repo issue describing this change, then link it to this PR by adding Closes #123 to the PR description (or using the "Development" sidebar on GitHub). A maintainer will mark the issue ready-to-implement when it is ready. Once it is marked, comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
Summary
Adds an "Open with " item to two existing right-click context menus — session tabs and file-tree directory headers — that launches the user's configured external editor on the relevant directory. The menu label is rendered from the existing
code.editor.open_file_editorsetting; no editor is hardcoded. Gated behindFeatureFlag::OpenDirectoryInExternalEditor(Cargo featureopen_directory_in_external_editor), default off.Implements
specs/gh-8226-open-with-editor/(companion spec PR #12901). This PR sits on top of #12901; once #12901 merges tomaster, the diff here will reduce to just the code changes.Motivation
Issue #8226 asks for a way to open a directory in
$EDITORfrom Warp. Today's "Open in editor" plumbing supports files only — there is no fast path from "this tab represents a project" or "this is a folder in the file tree" to "open this folder in my editor." Users currently fall back to typingcode ./cursor .or alt-tabbing into the editor's recent-projects list; both break flow.This PR ships one of three complementary UX entry points discussed on #8226 (the other two — click-on-directory-paths in terminal output, and the prompt-area chip prototyped by @ATERCATES — remain out of scope here and are tracked separately).
What's changed
util::file::external_editor::open_directory_in_external_editor— new entry point. ReadsEditorSettings::open_file_editorand dispatches to per-platform implementations.open_directory—mac.rsuses/usr/bin/open -a <app-bundle> <dir>(the macOS-native form that VSCode / Cursor / Windsurf / Zed / Sublime / Atom / JetBrains all interpret as "open this folder as a workspace");linux.rsandwindows.rsreuse each platform's existing editor-launch path with aNoneline/column.open_with_editor_menu_label*renders "Open with " (ExternalEditor), "Open in editor" (SystemDefault / EnvEditor with$EDITORset), orNone(Warp viewer, or EnvEditor without$EDITOR).tab.rs) — newopen_in_editor_menu_itemssection, inserted betweenmodify_tab_menu_itemsandclose_tab_menu_items. Dispatched viaWorkspaceAction::OpenTabCwdInExternalEditor, which reads the focused session'scurrent_working_directory().code/file_tree/view.rs) — adds the item directly after "Reveal in Finder" forDirectoryHeaderentries only (not files). Dispatched viaFileTreeAction::OpenDirectoryInExternalEditor. Threads&AppContextintocontext_menu_itemsto read the editor setting.OpenDirectoryInExternalEditorregistered incrates/warp_features/src/lib.rsand gated viaapp/Cargo.toml+app/src/features.rs.Out of scope
drive/index.rs render_workspace_picker) — cloud entities, no local cwd.is_remote_itemgate; the tab cwd reader silently no-ops when the focused session has no resolvable local cwd.Validation
external_editor/mod_tests.rs, 4 new):menu_label_external_editor_uses_editor_display_name,menu_label_system_default_falls_back_to_generic_label,menu_label_warp_choice_yields_no_item,menu_label_env_editor_requires_editor_var_to_be_set. All fourEditorChoicevariants covered.cargo check --libandcargo check --lib --features open_directory_in_external_editorboth pass (flag-on and flag-off code paths compile).cargo clippy --lib --features open_directory_in_external_editorclean for the new code.cargo test --lib --features open_directory_in_external_editor external_editor— all 33 external_editor tests pass (29 existing + 4 new).Related issues
\$EDITOR" ask).