Editors: companions other than JetBrains register through the revue command, so Open in editor can reach them #80

Closed
opened 2026-11-13 10:28:13 +01:00 by thatrichan · 0 comments
Owner

The VS Code (thatrichan/revue-companion#1), Neovim (thatrichan/revue-companion#2) and Zed (thatrichan/revue-companion#5) companions need a way back: Revue opening a pull request in the running editor window that has its branch, as it does today for JetBrains IDEs through their built-in server. None of them has a server Revue can scan for, so each tells Revue it's there.

Ask

Companions register by running the revue command, so none of them writes into Revue's data folder or needs to know where it is:

  • revue --companion <kind> --pid <pid> [--socket <path>] [--port <port> --token <token>] [--app <name>] [--version <v>]: records a running companion. kind is vscode, nvim or zed. Neovim gives its RPC --socket (v:servername). VS Code and Zed give a 127.0.0.1 --port and a --token that every request carries. --app is the editor's own name ("Visual Studio Code", "Cursor", "Zed Preview"…).
  • revue --companion-gone --pid <pid>: removes it, run on the editor's shutdown.
  • Revue ignores a registration whose pid isn't running or whose socket/port refuses, so a crashed editor never leaves a stale entry that matters.
  • A new editor N level in revue --version, so companions only register when Revue understands it.

In Revue

  • src/companion.rs: Companion::VsCode, Companion::Zed and Companion::Nvim variants beside JetBrains, with their finders in running_on. choose stays as it is (as the module's doc says).
  • Two requests, matching JetBrains' /api/revue-projects and /api/revue-open:
    • VS Code, Zed: GET /revue-projects and GET /revue-open?path=&repo=&branch=&file=&line= on the registered port, with the token.
    • Neovim: msgpack-RPC over the socket (a Unix socket, or a named pipe on Windows), calling require("revue_companion").projects() and require("revue_companion").open({ path, repo, branch, file, line }).
  • Zed can't focus a window from its language server, so Revue opens with zed --existing <repo>/<file>:<line> once /revue-projects names the window.
  • Neovim in a terminal: Revue focuses the terminal it runs in where it can, and says so when it can't.
  • The editor chooser (#68) treats each one like any other companion.
  • docs/command-line.md → "What editors can ask" documents both flags.

Tests

Registering and removing, a stale entry (pid gone), a refused port, a wrong token, and an nvim client round trip against a headless Neovim.

The VS Code (thatrichan/revue-companion#1), Neovim (thatrichan/revue-companion#2) and Zed (thatrichan/revue-companion#5) companions need a way back: Revue opening a pull request in the running editor window that has its branch, as it does today for JetBrains IDEs through their built-in server. None of them has a server Revue can scan for, so each tells Revue it's there. ## Ask Companions register by running the `revue` command, so none of them writes into Revue's data folder or needs to know where it is: - `revue --companion <kind> --pid <pid> [--socket <path>] [--port <port> --token <token>] [--app <name>] [--version <v>]`: records a running companion. `kind` is `vscode`, `nvim` or `zed`. Neovim gives its RPC `--socket` (`v:servername`). VS Code and Zed give a `127.0.0.1` `--port` and a `--token` that every request carries. `--app` is the editor's own name ("Visual Studio Code", "Cursor", "Zed Preview"…). - `revue --companion-gone --pid <pid>`: removes it, run on the editor's shutdown. - Revue ignores a registration whose pid isn't running or whose socket/port refuses, so a crashed editor never leaves a stale entry that matters. - A new `editor N` level in `revue --version`, so companions only register when Revue understands it. ## In Revue - `src/companion.rs`: `Companion::VsCode`, `Companion::Zed` and `Companion::Nvim` variants beside `JetBrains`, with their finders in `running_on`. `choose` stays as it is (as the module's doc says). - Two requests, matching JetBrains' `/api/revue-projects` and `/api/revue-open`: - **VS Code, Zed:** `GET /revue-projects` and `GET /revue-open?path=&repo=&branch=&file=&line=` on the registered port, with the token. - **Neovim:** msgpack-RPC over the socket (a Unix socket, or a named pipe on Windows), calling `require("revue_companion").projects()` and `require("revue_companion").open({ path, repo, branch, file, line })`. - Zed can't focus a window from its language server, so Revue opens with `zed --existing <repo>/<file>:<line>` once `/revue-projects` names the window. - Neovim in a terminal: Revue focuses the terminal it runs in where it can, and says so when it can't. - The editor chooser (#68) treats each one like any other companion. - `docs/command-line.md` → "What editors can ask" documents both flags. ## Tests Registering and removing, a stale entry (pid gone), a refused port, a wrong token, and an `nvim` client round trip against a headless Neovim.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thatrichan/revue#80
No description provided.