feat(cli): default relayfile login to cloud browser flow#125
Conversation
When `relayfile login` is invoked without `--token` (and no `RELAYFILE_TOKEN`), it now runs the same browser-based cloud sign-in flow that `relayfile setup` uses, instead of dropping into a blocking "API key:" stdin prompt. The legacy interactive prompt is still available behind `--api-key` for self-hosted users targeting `--server`. New flags mirror those on `relayfile setup`: `--cloud-api-url`, `--cloud-token`, `--no-open`, `--login-timeout`. Existing scriptable paths (`--token` / `RELAYFILE_TOKEN`) keep their previous behavior of validating against `/health` and writing `~/.relayfile/credentials.json`. Adds three unit tests covering the explicit-token path, the new cloud default, and the `--api-key` opt-in. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe ChangesLogin Control Flow Refactoring
Sequence DiagramsequenceDiagram
participant User
participant CLI as login CLI
participant Server
participant Cloud as Cloud API
User->>CLI: login --token abc123
CLI->>Server: GET /health (Bearer abc123)
Server-->>CLI: 200 OK
CLI->>CLI: saveCredentials (server)
User->>CLI: login (no flags)
CLI->>Cloud: ensureCloudCredentials
Cloud-->>CLI: cloud sign-in flow
CLI->>CLI: saveCredentials (cloud)
User->>CLI: login --api-key --server myhost
CLI->>User: [prompt] API Key:
User-->>CLI: key123
CLI->>Server: GET /health (Bearer key123)
Server-->>CLI: 200 OK
CLI->>CLI: saveCredentials (server)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
relayfile loginwith no--token(and noRELAYFILE_TOKEN) now runs the cloud browser sign-in flow instead of blocking on anAPI key:stdin prompt — same flowrelayfile setupalready uses.--token(or setRELAYFILE_TOKEN) for the scriptable, non-interactive flow, or pass--api-keyto opt back into the interactive prompt for self-hosted servers.--cloud-api-url,--cloud-token,--no-open,--login-timeoutflags mirroringsetupso the two commands behave consistently.Why
A user expected
relayfile loginto "just log me in" via the browser, the waysetupdoes. Today it forces the user to find and paste an API key, which is awkward for cloud users (they don't routinely have one) and surprising given that the cloud OAuth-style flow already exists in the binary — it just wasn't wired intologin.Behavior matrix
relayfile loginrelayfile login --token X --server YXagainstY/health, save server creds (unchanged)RELAYFILE_TOKEN=X relayfile loginRELAYFILE_SERVER(unchanged)relayfile login --api-key --server Yrelayfile login --cloud-token XX(parity withsetup --cloud-token)Test plan
go test ./cmd/relayfile-cli/— full suite passesTestLoginWithExplicitTokenPersistsServerCreds—--tokenstill hits/healthand writes~/.relayfile/credentials.json, no cloud creds touchedTestLoginDefaultsToCloudBrowserFlow— barerelayfile login(with--cloud-tokento bypass the browser in CI) writes cloud creds and prints "Signed in to Relayfile Cloud"TestLoginAPIKeyFlagPromptsForToken—--api-keyopt-in still drops into the interactive promptrelayfile loginagainst staging cloud and confirm the browser opens and cloud creds land at~/.relayfile/cloud_credentials.json🤖 Generated with Claude Code