Repository navigation
Ask which editor a changed file opens in, or use the one chosen in Settings - #753
ryanwelcher wants to merge 2 commits into
Conversation
…ttings A file under "Changed files" opened in the first editor detection found, which is Visual Studio Code wherever it is installed. Settings now has an "Open changed files in" choice, kept as the editor's id; with none chosen, or one uninstalled since, a menu beside the file asks which application to use, offering what the site menu's "Open in" does. Fixes #738.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
A pending editor lookup can open the previous site's chooser and file after a site switch, while Settings silently treats editor-detection failures as empty results.
2 open issues
What changed in this PR
Adds a preferred-editor setting for Changed files, addressing #738 without changing the site menu’s existing “Open in” behavior.
Changes:
- Stores and validates an optional editor ID in Settings.
- Opens files in the chosen editor, asks when none is available, or reveals them in the file manager when no editors are detected.
- Adds unit and journey coverage for editor selection and menu behavior.
Review: 2 [fix here] · 0 [follow-up]. GitHub Copilot completed review of the supplied changes, identified as head 588374a against base dc7cfba. Tests and lint were not run during this review.
| File | Description |
|---|---|
| tests/unit/site-menu.test.cjs | Tests shared editor-menu action mapping. |
| tests/unit/settings.test.cjs | Tests editor preference defaults and validation. |
| tests/unit/settings-view.test.cjs | Tests editor dropdown entries and values. |
| tests/unit/ipc-wiring.test.cjs | Tests preference persistence and editor names. |
| tests/unit/affected-files.test.cjs | Covers preferred-editor, chooser, and reveal decisions. |
| tests/e2e/journeys/pr-checkout.spec.js | Updates file-opening flow to choose an editor. |
| tests/e2e/journeys/patch-apply.spec.js | Exercises chooser dismissal, selection, and saved preference. |
| src/settings.cjs | Defines and validates the editor preference. |
| src/renderer/site-menu.cjs | Shares editor-menu action mapping. |
| src/renderer/settings-view.cjs | Builds editor choices and stored values. |
| src/renderer/index.jsx | Connects changed-file clicks to preferences and chooser. |
| src/renderer/components/site-header-actions.jsx | Adds the anchored editor chooser. |
| src/renderer/components/site-details.jsx | Supplies the clicked file’s menu anchor. |
| src/renderer/components/settings-dialog.jsx | Adds the editor preference control. |
| src/renderer/affected-files.cjs | Determines whether to open, ask, or reveal. |
| src/main.js | Validates editor IDs and exposes editor names. |
Review effort: Balanced
| const target = fileOpenTarget({ editors }); | ||
| const target = fileOpenTarget({ editors, preferred: settings?.editor ?? null }); | ||
| if (target.kind === 'editor') await openIn(target.path, relPath); | ||
| else if (target.kind === 'choose') setFileMenu({ relPath, anchor, editors }); |
| setEditors(res?.detected || []); | ||
| setNames(res?.names || null); | ||
| }) | ||
| .catch(() => { if (!cancelled) setEditors([]); }); |
…itors could not be listed A changed file's editor menu no longer opens if the site was left while editor detection answered. Settings now logs a failed editor lookup and says why no editor can be chosen, rather than showing an empty list.


Why
Clicking a file under "Changed files" opened it in the first editor the app detected, which is Visual Studio Code wherever it is installed. A contributor who uses Cursor, PhpStorm or anything else had no way to change that. Reported at WordCamp Canada Contributor Day (#738).
What changes
vscode,cursor, …), not a path, soeditor:openstill checks every launch against a fresh detection.openInItems.Not in this PR: the site menu's "Open in" is unchanged, since it already names an application on every open. An application picked through "Other application…" cannot be saved as the setting, because the setting holds detection ids only. "Remember my choice" in the menu was left out on purpose: Settings is the one place to stop being asked.
How to test this
Platforms: either macOS or Windows. Nothing here touches paths, spawning or signing. Use the Buildkite build for the current head,
588374a.The journey
tests/e2e/journeys/patch-apply.spec.js› "with no editor chosen, a changed file asks which, and the one chosen in the settings is used without asking (#738)" walks this flow with stand-in editors. It fails on the old behaviour (the file opens in Visual Studio Code with no menu). Run it from the repository root withnpm run test:e2e:hidden -- tests/e2e/journeys/patch-apply.spec.js -g "#738".What the journey cannot reach is real editors being detected on a real machine, so the manual pass is about that.
Starting state: a machine with at least two of Visual Studio Code, Cursor, PhpStorm, Sublime Text or Zed installed in their default locations. A site with a ticket linked and a patch applied, so "Changed files" lists at least one file.
What must not have happened:
Risks and limitations
src/main.js(editor:list,settings:set) andsrc/settings.cjschange. The stored shape gains one optional key,preferences.editor, so no migration is needed.tests/e2e/journeys/i18n.spec.jsfails locally on this branch and also on trunk without these changes (a strict-mode locator matching two.log-pane-noteelements). It is not touched here.Related
Fixes #738. Follow-up to #669, which added the changed-files links.
Design decisions and alternatives considered
getFirstInstalledEditor), and its "System" default really means "the first one in our list". That reproduces this bug for anyone whose editor is not first, so it was dropped.preferredEditor, and keeps "which applications may the window ask main to launch" exactly what it was: what detection found, plus what a person picked in a native dialog.Review outcome (required — see AGENTS.md)
3 [fix here] · 0 [follow-up]. All 3 fixed.
index.jsx: an unreachable no-anchor fallback, and the item-to-openInmapping repeated for the two menus. Fixed: the anchor is required, and both menus useopenInEditorPathinsite-menu.cjs, with a test.editor:listreturns the table's names, andeditorItemsuses them.31976b9(trunk at the time). Lint clean,npm test2248 pass / 0 fail.dc7cfba(two commits overlap insrc/main.jsandtests/unit/ipc-wiring.test.cjs, rebased cleanly). Head588374a. The fixes were checked by the author, not re-reviewed by a fresh context. Lint clean,npm test2249 pass / 0 fail, and the patch-apply, pr-checkout, settings and site-header journeys pass (36).Implementation notes
fileOpenTargetinsrc/renderer/affected-files.cjsdecides editor / choose / reveal.OpenFileInMenuinsrc/renderer/components/site-header-actions.jsxis anchored to the file's button and returns focus to it on close.editorinsrc/settings.cjs.settings:setaccepts an id thateditorCandidateshas for the current platform.EditorControlinsettings-dialog.jsx, and its entries come fromeditorItemsinsettings-view.cjs.patch-apply,pr-checkout) now choose it from the menu.Screenshots or recording
Not captured yet: the menu beside a changed file and the new Settings control are both visible changes. To be added from the Buildkite build.
🤖 Generated with Claude Code