Editors: answer without the app running, and sign in to a Revue account from the command line #66
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?
Editor plugins (the JetBrains one in jetbrains-plugins) ask Revue through the
revuecommand:--pulls,--branch-pull,--pending,--comment,--pull,--worktree,--fetch-branch. Today every one of them needs the desktop app running: without it they exit with 3, "Revue isn't running", and the plugin can only offer to start it.Goal: the
revuecommand answers by itself when no app is running, with this computer's sign-ins or a Revue account signed in from the command line. Revue must still be installed, but not running.Why this way
The alternatives were weighed and rejected:
revue serveanswers no editor questions today. It would need the same core work as this, plus a port and a process to manage.This way, no tokens enter the IDE, and drafts stay in the same files the app uses. Every editor feature keeps working: lists, branch status, pending comments, details, worktrees, fetching branches, and markers in files.
Phase 1: answers without the window
src/ide_answer.rs.App::answer's handlers (answer_pulls,answer_branch_pull,answer_pending,answer_comment,answer_pull,answer_worktree,answer_fetch_branch) move behind atrait IdeHost.repos_for(remotes),account_for(&PrKey) -> Option<Provider>,viewer_login,link_rules,loaded_pr,drafts(key),add_draft(key, d).Appimplements it with its tabs and globals.store::load_*, building providers likeserve::proxy::Accounts::load.print_answer(src/lib.rs): with--headless, whenurl_handler::askgivesNotRunning, answer in-process instead of exiting with 3.account::Remote::restore(.., auto=false)), thensync(), so renewals made by other computers are picked up.sync()again, so tokens renewed here are pushed before exiting.answer_comment's write to disk takes the same lock, so an app starting up can't lose a draft written at that moment.ide::EDITOR_INTERFACEgoes to 2, whichrevue --versionprints aseditor 2.{"error":…,"sign_in":true}.docs/command-line.md, "What editors can ask".Phase 2: account commands
revue --accountprints{"signed_in":bool,"email":…,"server":…,"sign_ins":[{"service":"github","account":"alice","where":"account|computer"}]}.wherematches the docs' "In your Revue account" and "This computer only".revue --account-sign-in [--server URL] [--device NAME]uses the browser sign-in the app uses (account::browser::start/finish, loopback on 47392).{"url":…}, so an editor can offer "Open the browser again", then prints the--accountJSON. Exit 1 when cancelled or expired; the editor cancels by ending the process.Phase 3: the JetBrains plugin
whenNotRunning: answer anyway (the default witheditor 2or later), offer to start Revue, or start it. The plugin adds--headlessto match.--account, and Sign in to Revue…, which runs--account-sign-inwith Cancel and opens the URL in the browser.Tests
IdeHost: each answer's JSON is the same as today's.--account-sign-inagainst the fake server, likesrc/account/browser_tests.rs.--headlessarguments, reading exit 4 and the--accountJSON, and the settings round trip.Decided
Later, maybe
Also covered: opening a Slack thread from an editor,
revue --open-slack <slack://…> --web <permalink>.It already works without the app: the
revueprocess itself opens the thread as Open in Slack does, in Slack's app or the browser per Settings → Apps → Slack, falling back to the browser when the app doesn't start. For the browser it hands the address back to the editor ({"opened":"browser","url":…}) instead of opening one itself.It must keep working in the command-only mode this issue adds, and in any later headless setup:
store::load_settings) and finds the Slack app (apps::find_slack).slack://link comes from--pull.ide_answer.rs,--open-slackstays a local command, not a question to anIdeHost.--open-slackwith no app running answersopenedand exits 0.Phase 1 is done in
11bd65a(the refactor),83e2fbb(the feature) and8c29f3e(docs).src/ide_answer.rshastrait IdeHost. The app implements it withAppHost; theHeadlesshost loads accounts, Jira, Slack and link rules from disk.--headless, when no app answers,revueanswers in-process. It restores the account and syncs before answering, and syncs again after.editor.lockin the data folder, usingstd::fs::File::try_lock, held for the whole headless answer. An app that starts during an answer waits for it (up to 90 s) before writinginstance-port. The app's own disk draft write takes the lock too.{"error":…,"sign_in":true}. The running app's answers carrysign_intoo.EDITOR_INTERFACEis 2.--open-slack: stays local, with a test.Choices that differ from the plan:
--headlessis opt-in, so the plugin has to pass it.Left: phase 2 (
--account,--account-sign-in), and phase 3 in the plugin's repository. Not yet tried against live services.Phase 2 is done in
e16d7ecand80c10c6.revue --accountprints{"signed_in":…,"email":…,"server":…,"device":…,"sign_ins":[{"service","account","where":"account|computer"}]}. The running app answers it, or else the command itself does.revue --account-sign-in [--server URL] [--device NAME]:{"url":…}and opens the browser, the same browser sign-in the app uses. After approval it prints the--accountJSON. Otherwise it prints{"error":…}and exits 1: cancelled, the 10-minute wait ran out, or a bad server."app_running":true.DataLock, and the command checks again that no app has started.The commands are
editor 6;editor 5is the resolve and submit options fromdb1b19d. Both are indocs/command-line.md.Phase 3: the plugin already passes
--headlessand handles exit 4 (revue-companion 2806a19). The plugin's Revue account section in its settings is in progress.Phase 3 is done in revue-companion 0142ed1 (headless answers and exit 4 were already in 2806a19).
editor >= 6. It shows the status from--account: the email, server, device, and each sign-in marked "In your Revue account" or "This computer only".--account-sign-in. While it waits, it offers Open the browser again and Cancel.AccountTest.Not yet tried in a running IDE (
runIde,verifyPlugin) against a realeditor 6Revue.Every phase is done, so I'm closing this.