Skip to content

fix(cli): stop remote targets from logging in again on every command - #54

Open
postoso wants to merge 1 commit into
beeper:mainfrom
postoso:fix/remote-target-token
Open

postoso wants to merge 1 commit into
beeper:mainfrom
postoso:fix/remote-target-token

Conversation

@postoso

@postoso postoso commented Oct 26, 2026

Copy link
Copy Markdown

Problem

After beeper setup --remote <url>, every command started a new OAuth login, and each one registered another "Beeper CLI" client in Desktop. I ended up with 8 of them before I noticed.

Two things caused it:

  • setupRemote wrote the target again after setupOAuthTarget (or email setup) had saved it with its token, so the saved token was dropped.
  • With no token on the target, createClient and requireToken fell back to a fresh login and saved it to config.json. Only desktop targets read auth from there, so remote and Server targets never saw it.

Change

  • Remove the extra writeTarget in setupRemote. Both setup paths already save the target with its auth.
  • Pass the resolved target to ensureDesktopToken. For a remote or Server target, the fallback login is saved on that target with saveTargetAuth, but only when the login ran against the target's own URL. Desktop targets keep saving to config.json as before.

Validation

  • Added test/remote-auth.test.ts. It runs the CLI against a local mock OAuth server with a stub browser opener. It covers setup, the createClient and requireToken fallbacks on remote and Server targets across two processes, and controls for built-in and managed Desktop.
  • On main, 5 of the 7 tests fail. With this change, all 7 pass.
  • bun run check passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant