Repository navigation
fix(auth): share OAuth sessions between Desktop and CLI - #218
Merged
Merged
Conversation
Contributor
|
pkg-pr-new preview for commit npx --yes https://pkg.pr.new/zcode-app-cli@404e702This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with |
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.
Desktop and the CLI shared the same Z.AI credential field but wrote different token types, so signing in to one could invalidate the other. The CLI also required its own account identity marker and could not reuse a Desktop-only login.
This change makes both CLI login transports save the business token expected by Desktop, resolves model access before publishing credentials, and derives OAuth account identities from the active shared profile. Explicit manual API keys retain their account selection. Legacy CLI OAuth tokens migrate only after a successful exchange, using the native credential lock and a value comparison to protect newer logins.
Regression coverage exercises the actual 3.15.3 runtime with isolated encrypted credentials and mocked HTTP: polling and macOS callback login, Desktop session reuse, Z.AI and BigModel identities, account switching/logout, legacy migration races, permission failures, and cancellation. The patch is required during runtime sync, checked for completeness and idempotence, and documented in English and Chinese.
Validation on macOS arm64 with Bun 1.4.1 and Node 26.4.0:
bun run release:packpassed, including installation and execution of the packaged CLI.bun run release:buildinitially stopped at the existing fullscreenbel/unfocusedfocus check: the workspace banner reflowed during its text-preservation assertion. That case failed once more, then passed on a subsequent run; the remaining built-TUI focus case also passed. No TUI code was changed.Terminal-detection variables (
TERM_PROGRAM,GHOSTTY_RESOURCES_DIR,KITTY_WINDOW_ID, andWEZTERM_PANE) were unset for validation to avoid the existing notification-test dependence on the host terminal. OAuth integration coverage uses mocked HTTP with the real runtime and isolated encrypted credentials.Closes #216