Skip to content

feat(zoo-gateway): auth callback and multi-profile token sync#347

Open
JamesRobert20 wants to merge 5 commits into
feat/zoo-gateway-settings-uifrom
feat/zoo-gateway-auth-sync
Open

feat(zoo-gateway): auth callback and multi-profile token sync#347
JamesRobert20 wants to merge 5 commits into
feat/zoo-gateway-settings-uifrom
feat/zoo-gateway-auth-sync

Conversation

@JamesRobert20
Copy link
Copy Markdown
Contributor

Summary

  • Propagates OAuth callback token to all ClineProvider instances (sequential writes to avoid profile-store races)
  • Seeds/syncs zoo-gateway profiles, including non-active profiles for model fetch
  • Clears in-memory active profile on sign-out even when disk is already clean

Part 3 of the Zoo Gateway stack. Depends on PR2 (stacked on #344).

Test plan

  • handleUri multi-instance + serialization tests
  • webviewMessageHandler separate-profile lookup test
  • Manual: sign in/out across multiple profiles

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2286aa3a-244c-4087-8d0f-c24e9daecaea

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/zoo-gateway-auth-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JamesRobert20 JamesRobert20 mentioned this pull request May 27, 2026
1 task
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-settings-ui branch from adedf0a to 8634510 Compare May 27, 2026 14:25
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-auth-sync branch from 654117d to 1326a97 Compare May 27, 2026 14:29
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-settings-ui branch from 8634510 to 7bc8c0c Compare May 27, 2026 14:42
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-auth-sync branch 3 times, most recently from f245208 to 078bce0 Compare May 27, 2026 15:10
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

❌ Patch coverage is 88.26087% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/webview/ClineProvider.ts 83.75% 13 Missing ⚠️
src/api/providers/zoo-gateway.ts 91.66% 7 Missing and 1 partial ⚠️
src/core/webview/webviewMessageHandler.ts 88.23% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

JamesRobert20 pushed a commit that referenced this pull request May 27, 2026
Add ClineProvider tests for handleZooCodeCallback, ensureZooGatewayProfileSeeded, and webviewMessageHandler zooCodeSignOut to satisfy codecov patch on PR #347.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@proyectoauraorg proyectoauraorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Auth Callback + Multi-Profile Token Sync

Verdict: ✅ Approved (with security notes for future hardening)

Verified

  • handleUri.spec.ts — 8 tests pass (multi-instance fan-out, sequential serialization)
  • ClineProvider.spec.ts — 82 tests pass (6 new auth profile sync tests)
  • webviewMessageHandler.spec.ts — 44 tests pass (2 new sign-out tests)
  • ✅ Sequential execution of callbacks avoids profile-store race conditions
  • ✅ Sign-out clears tokens from ALL zoo-gateway profiles (correct symmetry)
  • ✅ Model list fetch recovers credentials from non-active profiles

Security Notes (future hardening, not blockers)

  1. Token storage: zooSessionToken is stored in JSON-serialized ProviderSettings on disk. VS Code's globalStorage is OS-protected, but migrating to SecretStorage would add an extra layer of defense.
  2. Base URL validation: zooGatewayBaseUrl is derived from getZooCodeBaseUrl(). In production this is fine, but a misconfigured ZOO_CODE_BASE_URL env var could route tokens to an unintended host. Consider adding domain validation.

Both are hardening improvements for a future iteration, not blockers for this PR.

Dependency

Depends on #345. After #345 merges, this should rebase cleanly.

JamesRobert20 pushed a commit that referenced this pull request May 28, 2026
Add ClineProvider tests for handleZooCodeCallback, ensureZooGatewayProfileSeeded, and webviewMessageHandler zooCodeSignOut to satisfy codecov patch on PR #347.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-auth-sync branch from 65885a8 to 13c98d0 Compare May 28, 2026 20:26
JamesRobert20 pushed a commit that referenced this pull request May 28, 2026
Add ClineProvider tests for handleZooCodeCallback, ensureZooGatewayProfileSeeded, and webviewMessageHandler zooCodeSignOut to satisfy codecov patch on PR #347.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-auth-sync branch from 13c98d0 to d4050f8 Compare May 28, 2026 20:33
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-settings-ui branch from a40f6e9 to 983c133 Compare May 28, 2026 21:19
James Mtendamema and others added 5 commits May 28, 2026 15:19
Co-authored-by: Cursor <cursoragent@cursor.com>
Add ClineProvider tests for handleZooCodeCallback, ensureZooGatewayProfileSeeded, and webviewMessageHandler zooCodeSignOut to satisfy codecov patch on PR #347.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clear the cached token on 401 and offer sign-in. On insufficient credits
or budget limits, open the credits page. On account frozen/banned, open
support. Errors still propagate to the task layer after the toast.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ocales

Adds session_expired, out_of_credits, account_unavailable, budget_exceeded
under zooAuth.errors and a new zooAuth.buttons block (sign_in, add_credits,
contact_support) introduced by the gateway 401/402/403 UX so check-translations
passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ov patch

Adds vscode + i18n mocks and asserts the 401/402/403/429 paths in
surfaceGatewayApiError: token clear + sign-in URL on 401, add-credits
URL on 402 and budget-coded 429, support URL on 403, no-op on 429
without a budget code or on errors without a status. Also verifies the
helper still runs before completePrompt rewraps the upstream error.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JamesRobert20 JamesRobert20 force-pushed the feat/zoo-gateway-auth-sync branch from d3165a0 to 7e54cf1 Compare May 28, 2026 21:29
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.

2 participants