feat: added /auth command to re-authenticate with custom provider#18200
Open
roerohan wants to merge 1 commit intoanomalyco:devfrom
Open
feat: added /auth command to re-authenticate with custom provider#18200roerohan wants to merge 1 commit intoanomalyco:devfrom
roerohan wants to merge 1 commit intoanomalyco:devfrom
Conversation
924154b to
1ebdadf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #
Type of change
What does this PR do?
When a well-known auth token (e.g. a JWT from an enterprise provider like
opencode.example.com) expires mid-session, you currently have to quitopencode, runopencode auth login <url>in your shell, and restart - losing your session context. This adds a/authslash command so you can re-authenticate without leaving the TUI.How it works:
/authwith no args looks up existing well-known entries fromauth.json. If there's one, it re-runs the auth flow automatically. If there are multiple, it shows a picker. If there are none, it tells you to use/auth <url>./auth <url>authenticates with the given well-known URL (new or existing) by fetching its.well-known/opencodeconfig, running the auth command, and storing the token./connect) so the new token takes effect immediately.I also extracted the inline well-known auth logic from the CLI opencode auth login command into a shared
Auth.wellknown()function so both the CLI and TUI use the same code path. The well-known config response is now validated with a Zod schema instead of as any, and stderr is captured on auth command failure for better error messages.How did you verify your code works?
bun run typecheckpasses cleanbun test- 756 pass, 0 fail/authavailable in the command paletteScreenshots / recordings
Checklist