-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix(TUI): complete auth fix for TUI with server password (HTTP mode) #9095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
fix(TUI): complete auth fix for TUI with server password (HTTP mode) #9095
Conversation
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
|
Heads up - #9706 was just opened which identifies the same auth header issue but specifically for the plugin client in This PR fixes the TUI HTTP mode auth, but the plugin client at Could we extend this PR to also add auth headers to the plugin client fetch wrapper? The fix would be similar to what you've done for the TUI worker. |
|
@R44VC0RP This PR now also includes the same authorization-header fix for the plugin client in packages/opencode/src/plugin/index.ts 👍 |
|
@0xRichardH Thank you, that makes sense. I added another commit that resembles your patch to this PR |
|
@0xRichardH I have reverted the changes done by this patch, since the windows-test (the github action) is not passing anymore after applying it. Not sure if this is a reproducible issue and/or a flaky windows test build. Sadly I have no windows computer to investigate. A separate pull request would be good for this in my opinion. |
|
Okay, even after revertig the windows check does not pass. Since it passed in the commit before, I am pretty sure this I either an error in the current dev branch and/or a flaky test. Does a maintainer/collaborator have more insights regarding this? |
… started and has a password set
4185f24 to
8fe1af4
Compare


Summary
Completes the TUI authentication fix for when
OPENCODE_SERVER_PASSWORDis set and TUI starts an HTTP server, due to the--portflag being set.Problem
PR #8179 fixed TUI authentication when using direct RPC communication, but didn't handle the case where TUI starts an HTTP server (when
--portflag is used). In this scenario, the TUI would fail to authenticate against its own server.Solution
Extracted
getAuthorizationHeader()to a shared modulepackages/opencode/src/flag/auth.tsModified
packages/opencode/src/cli/cmd/tui/thread.tsto use a custom fetch function that includes the Authorization header when an HTTP server is started with password protectionModified
packages/opencode/src/cli/cmd/tui/attach.tsto use a custom fetch function too (if needed)Modified
packages/opencode/src/plugin/index.tsto use a custom fetch function too (if needed)The fix ensures the TUI can authenticate to the HTTP server it spawns when password is set. For plugins, the base TUI command itself and the attach TUI command.
Testing
Verified with:
Previously this would fail with
Unauthorizederrors. Now the TUI successfully authenticates and works as expected.Related
This PR completes the authentication flow that was partially addressed in #8179. The previous PR only fixed the RPC communication path, while this PR fixes the HTTP server path.