Skip to content

[gh-8226] Add "Open with <Editor>" item to tab and file-tree menus (flag-gated)#12905

Open
0xBB2B wants to merge 3 commits into
warpdotdev:masterfrom
0xBB2B:bb/open-with-editor-impl
Open

[gh-8226] Add "Open with <Editor>" item to tab and file-tree menus (flag-gated)#12905
0xBB2B wants to merge 3 commits into
warpdotdev:masterfrom
0xBB2B:bb/open-with-editor-impl

Conversation

@0xBB2B

@0xBB2B 0xBB2B commented Jun 22, 2026

Copy link
Copy Markdown

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_editor setting; no editor is hardcoded. Gated behind FeatureFlag::OpenDirectoryInExternalEditor (Cargo feature open_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 to master, the diff here will reduce to just the code changes.

Motivation

Issue #8226 asks for a way to open a directory in $EDITOR from 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 typing code . / 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. Reads EditorSettings::open_file_editor and dispatches to per-platform implementations.
  • Per-platform open_directorymac.rs uses /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.rs and windows.rs reuse each platform's existing editor-launch path with a None line/column.
  • Shared label helperopen_with_editor_menu_label* renders "Open with " (ExternalEditor), "Open in editor" (SystemDefault / EnvEditor with $EDITOR set), or None (Warp viewer, or EnvEditor without $EDITOR).
  • Session-tab menu (tab.rs) — new open_in_editor_menu_items section, inserted between modify_tab_menu_items and close_tab_menu_items. Dispatched via WorkspaceAction::OpenTabCwdInExternalEditor, which reads the focused session's current_working_directory().
  • File-tree menu (code/file_tree/view.rs) — adds the item directly after "Reveal in Finder" for DirectoryHeader entries only (not files). Dispatched via FileTreeAction::OpenDirectoryInExternalEditor. Threads &AppContext into context_menu_items to read the editor setting.
  • Feature flagOpenDirectoryInExternalEditor registered in crates/warp_features/src/lib.rs and gated via app/Cargo.toml + app/src/features.rs.

Out of scope

  • Hijacking clicks on directory paths printed inside terminal output (the original ask in Add option to open directories in $EDITOR #8226).
  • Prompt-area "Open in IDE" chip (@ATERCATES's prototype on a fork).
  • Warp Drive workspace switcher (drive/index.rs render_workspace_picker) — cloud entities, no local cwd.
  • SSH / remote terminal cwd resolution. File-tree remote entries are already excluded via the existing is_remote_item gate; the tab cwd reader silently no-ops when the focused session has no resolvable local cwd.
  • Line/column positioning (directories have no caret).

Validation

  • Unit tests (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 four EditorChoice variants covered.
  • cargo check --lib and cargo check --lib --features open_directory_in_external_editor both pass (flag-on and flag-off code paths compile).
  • cargo clippy --lib --features open_directory_in_external_editor clean 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).
  • Manual end-to-end on macOS: WarpOss dev build, Settings → Code → External editor → VS Code → right-click tab → "Open with VSCode" → VS Code opens the tab's cwd as a workspace. Same for file-tree directory right-click. With Settings → SystemDefault, label becomes "Open in editor" and clicking falls back to Finder per spec Behavior 4.

Related issues

0xBB2B added 3 commits June 22, 2026 17:16
… 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.
@cla-bot cla-bot Bot added the cla-signed label Jun 22, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@0xBB2B

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

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@0xBB2B

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

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant