Repository navigation
feat(gateway): prefer the hub's auth.json when present - #40
Merged
Merged
Conversation
The CoDev Hub moved its auth file to ~/.codev-hub/auth.json with no fallback to the old shared ~/.codev/auth.json, breaking the shared- session contract. Resolve the auth dir per call: when the hub's auth.json exists, read AND write there (a silent refresh may rotate the refresh_token, so persisting it elsewhere would strand the hub on a dead session); otherwise fall back to ~/.codev as before. The force-login sentinel follows the same resolution. Also fixes a test bug: Bun's os.homedir() ignores runtime HOME changes, so the suite's HOME override silently read and wrote the real ~/.codev/auth.json. Home is now resolved per call via OPENCODE_TEST_HOME (core Global convention) and the tests set that instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
The CoDev Hub moved its auth file to
~/.codev-hub/auth.jsonwith no fallback to the old shared~/.codev/auth.json, so the "one shared SSO session" contract betweencodevandcodevhubwas broken: a hub login no longer made the configure flow silent.All three configure triggers (first-run gate,
codev configure, the/configurecommand) funnel throughsilentSso()/login()into theauthFilePath()/forceLoginPath()helpers, so the fix lives in one place:authDir()resolver inpackages/codev-gateway/src/auth-file.ts: when~/.codev-hub/auth.jsonexists, both the auth file and the force-login sentinel resolve into~/.codev-hub; otherwise fall back to~/.codevexactly as today. Keyed on the file, not the dir, mirroring the hub's own fresh-install check (unrelated code creates the dir).refresh_token, so persisting it anywhere but the hub's file would strand the hub on a dead session. The file shapes are field-for-field identical (hubsrc/lib/auth.tsAuthFileContents), and the read-merge-write pattern preserves hub-only fields likeskillhub_cookie.~/.codev-hub/auth.jsonexists~/.codev-hub/force-login~/.codev/auth.jsonTest bug fixed along the way
Bun's
os.homedir()ignores runtimeHOMEchanges (Node respects them), so the existing suite'sHOME = tempDiroverride silently read and wrote the real~/.codev/auth.jsonon everybun testrun. Home is now resolved per call viaOPENCODE_TEST_HOME(the existingcore/global.tsconvention) and the tests set that instead. If you've run this package's tests locally, your~/.codev/auth.jsonlikely contains fixtures (api_key: "sk-3") — delete it and re-runcodev configure.Testing
bun testfrompackages/codev-gateway: 14 pass, 0 fail (two new tests: path resolution incl. dir-without-file fallback; reading a hub session and mergingapi_keyback into the hub file without creating~/.codev/auth.json)bun typecheckclean🤖 Generated with Claude Code