GeezerVison is showing github.com — fix(tui): prevent the local plugin to break the built-in openai auth plugin by cynicalight · Pull Request #22026 · anomalyco/opencode
Conversation
Issue for this PR
Closes #18582
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
This PR fixes a regression where the built-in OpenAI ChatGPT subscription auth flow could be silently replaced by another openai auth plugin(many people in that issue may have different plugins installed, in my case it seems that the non-auth plugin would also break down the built-in auth method, pretty weird). That caused providers login and the TUI connect flow to skip the ChatGPT Pro/Plus options and fall straight to manual API key entry. The change updates provider auth resolution to preserve the built-in openai auth hook instead of letting later plugins overwrite it, and adds a regression test proving that external OpenAI auth hooks no longer hide the built-in ChatGPT login methods.
How did you verify your code works?
I verified it in two ways:
- I added a regression test in packages/opencode/test/plugin/auth-override.test.ts that reproduces the bug by installing a local plugin with auth.provider = "openai". Before the fix, that test failed because the built-in ChatGPT Pro/Plus methods disappeared. After the fix, it passes and confirms the built-in OpenAI auth methods are preserved.
- I re-ran the nearby auth-related tests:
bun test test/plugin/auth-override.test.ts, bun test test/cli/tui/sync-provider.test.tsx.
- final test: i test my own gpt subscription. It works with the same local config which broke the auth before.
Screenshots / recordings
NO UI CHANGE.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes a regression in provider auth resolution where an externally loaded (e.g., local) plugin declaring auth.provider = "openai" could override the built-in OpenAI (ChatGPT subscription) auth hook, causing the login flow to skip ChatGPT Pro/Plus options.
Changes:
- Adjust provider auth hook resolution to preserve the first registered OpenAI auth hook instead of allowing later plugins to overwrite it.
- Add a regression test ensuring a user plugin with
provider: "openai" cannot hide the built-in ChatGPT Pro/Plus auth methods.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File |
Description |
| packages/opencode/src/provider/auth.ts |
Changes auth hook mapping to prevent external OpenAI auth hooks from overwriting the built-in one. |
| packages/opencode/test/plugin/auth-override.test.ts |
Adds regression coverage for OpenAI auth override behavior via a local plugin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
120
to
+131
|
|
const plugins = yield* plugin.list()
|
|
|
|
|
|
const hooks: Record<ProviderID, Hook> = {}
|
|
|
|
|
|
for (const item of plugins) {
|
|
|
const auth = item.auth
|
|
|
if (!auth?.provider) continue
|
|
|
|
|
|
const id = ProviderID.make(auth.provider)
|
|
|
if (id === "openai" && hooks[id]) continue
|
|
|
hooks[id] = auth
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new hook-resolution loop no longer uses Arr or Result, but packages/opencode/src/provider/auth.ts still imports them from effect. Please remove the unused imports to avoid TS/lint failures and keep the module tidy.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cynicalight
changed the title
fix: prevent the local plugin to break the built-in openai auth plugin
fix(tui): prevent the local plugin to break the built-in openai auth plugin
Apr 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|