Skip to content

fix(auth): share OAuth sessions between Desktop and CLI - #218

Merged
kingsword09 merged 1 commit into
mainfrom
fix/shared-desktop-cli-oauth
Oct 19, 2026
Merged

kingsword09 merged 1 commit into
mainfrom
fix/shared-desktop-cli-oauth

Conversation

@kingsword09

@kingsword09 kingsword09 commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

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:

  • Typecheck, locked 3.15.3 runtime sync, runtime checks, and package metadata checks passed.
  • Full test suite: 1,012 passed, 2 platform skips (858 unit, 60 TUI, 74 runtime, 20 Node tests).
  • Package tree validation and bun run release:pack passed, including installation and execution of the packaged CLI.
  • All TUI smoke cases passed across the initial run and follow-up runs. The aggregate bun run release:build initially stopped at the existing fullscreen bel/unfocused focus 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, and WEZTERM_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

@github-actions

Copy link
Copy Markdown
Contributor

pkg-pr-new preview for commit 404e70261c4b19dc36729ae669a6be5a9ae95e1e.

npx --yes https://pkg.pr.new/zcode-app-cli@404e702

Full repository URL

This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with /pkg-pr-new.

Workflow logs

@kingsword09
kingsword09 merged commit ec6ccfe into main Oct 19, 2026
6 checks passed
@kingsword09
kingsword09 deleted the fix/shared-desktop-cli-oauth branch October 19, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli auth conflicts with desktop app on Mac

1 participant