Open in editor: prefer an IDE running Revue Companion #68
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Open in editor (the PR header's button,
open_in_editor_here,PrView::open_in, and links that open a pull request in an editor) uses the default editor from Settings → Behavior. Today a running JetBrains IDE is only asked (jetbrains::openover/api/revue-*onjetbrains::PORTS) when the default editor is that JetBrains IDE. If you're working in an IDE that runs Revue Companion (the plugin,dev.cleangame.revue.companion, formerly "Revue") but your default editor is something else, the pull request opens there instead of in the IDE you have open.Revue Companion will come to more editors over time (VS Code and others, not only JetBrains IDEs), so this is about any editor running a companion, not JetBrains only.
What it should do
When opening a pull request (or a file or line of it) in an editor, without an editor named explicitly (the button's menu still opens the one picked):
Within a chosen IDE, what happens is unchanged: the window that has the PR's branch comes forward, else the folder opens in a new window of that IDE.
Picking among several (case 4)
Sort the running companions in a stable order and take the first:
Instance::has(slug, Some(branch))), since that's where the work is.Instance::focused).jetbrains::IDES(or a futureeditors::COMPANIONSlist), then by port, so the choice never flips between two equal ones.Steps 1–3 also break ties within case 3: when the default editor runs twice (two instances of the same IDE, on two ports), take its instance that has the branch, else the focused one, else the first.
Implementation notes
jetbrainsalready scansPORTSfor instances (GET /api/revue-projects→Instance { ide, product, projects, port }). Add arunning() -> Vec<Instance>that every open asks first (it already has short timeouts,SCAN), so the choice is known before launching anything.apps::App(Settings' default editor) to an instance withjetbrains::ide_of(program, name)andIde::is(ide, product).fn choose(default: Option<&App>, running: &[Companion], repo, branch) -> Choice, withCompaniona small enum or trait over JetBrains instances (and later VS Code etc.), so a new companion only adds a finder.Tests
chooseon generic fixtures, one test per case:Plus one UI test with the mock
/api/revue-projectsserver (as the existing jetbrains tests do): Open in editor goes to the running companion when the default editor is another app.Docs
docs/editors.md: how Revue chooses the editor when Revue Companion is running, and the plugin's new name (Marketplace search Revue Companion, source atjetbrains-plugins/revue-companion).Done in
738fa92(docs in1940b53).src/companion.rs, holdsCompanion, an enum with aJetBrainsvariant today, plusrunning()andchoose(default, running, repo, branch). If the default editor's instances are running, the choice is among them; otherwise it's among all running companions. They're ranked by having the PR's branch, then the repository, then a focused window, then IDE order and port.choose, plus a test against the mock/api/revue-projectswith a VS Code default.docs/editors.mdhas a new section, "Which editor opens", and uses the plugin's new name.revuecommand, so Open in editor can reach them #80