Skip to content

fix(install): repair Auth0 and project setup flow - #24

Merged
pitzcarraldo merged 5 commits into
mainfrom
fix/auth0-organization-param
Jul 4, 2026
Merged

fix(install): repair Auth0 and project setup flow#24
pitzcarraldo merged 5 commits into
mainfrom
fix/auth0-organization-param

Conversation

@pitzcarraldo

@pitzcarraldo pitzcarraldo commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes clix install authentication and project setup failures in production.

Details

The bundled production Auth0 client now includes the required Clix organization ID in the PKCE authorization URL, so Auth0 no longer rejects CLI login with parameter organization is required for this client.

Project setup now reads member, organization, and organization project data directly from https://management-api.clix.so, matching the backend split where management routes moved out of internal-api.

Runtime project APIs, including project details and sender config updates, still use the existing Console internal API proxy so runtime setup behavior is unchanged.

Also fixes a CI-only handoff test failure by avoiding process.execve when tests inject a fake spawner, and bumps the package version to 1.1.3 for release.

Related Issues

N/A

How to Validate

  1. Run bun run build.
  2. Run bun run check.
  3. Run bun test.
  4. Run bun test src/lib/auth/__tests__/pkce-flow.test.ts src/lib/api/__tests__/internal-client.test.ts src/lib/services/__tests__/organization-projects.test.ts src/lib/services/__tests__/agent-handoff.test.ts.
  5. Run bun run install:local and confirm clix --version prints 1.1.3.
  6. In samples/BasicApp, run DEBUG=projects-fetch clix install and confirm it reaches the project selection screen.

Pre-Merge Checklist

Code Quality

  • Code builds without errors (bun run build)
  • Types check correctly (bun run typecheck)
  • Linter passes (bun run lint)
  • Tests pass (bun test)
  • Added/updated tests for new functionality (if applicable)

Documentation

  • Updated relevant documentation (if needed)
  • Updated CLAUDE.md if architecture changed (if needed)

Commit Standards

  • Commits follow Conventional Commits format
  • No breaking changes, OR breaking changes are documented

Platform Validation

  • macOS
  • Linux

Summary by CodeRabbit

  • New Features

    • Added support for organization-aware sign-in, including organization selection in the login flow when configured.
    • Expanded API routing so app data can be fetched through the appropriate console or management endpoints.
  • Bug Fixes

    • Improved environment-based configuration handling for Auth0 and API URLs.
    • Updated process handoff behavior to avoid unnecessary execution path changes when custom process spawning is used.
  • Chores

    • Bumped the app version to 1.1.3.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62c193d5-dc80-4b16-897b-9c2cc44ff930

📥 Commits

Reviewing files that changed from the base of the PR and between c57bfd2 and 738f778.

📒 Files selected for processing (4)
  • src/lib/api/__tests__/internal-client.test.ts
  • src/lib/api/internal-client.ts
  • src/lib/auth/config.ts
  • src/lib/auth/index.ts
✅ Files skipped from review due to trivial changes (1)
  • src/lib/auth/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/api/internal-client.ts
  • src/lib/auth/config.ts

Walkthrough

Adds Auth0 organization handling, refactors internal API routing between proxy and management URLs, updates agent handoff execve lookup behavior, and bumps the package version.

Changes

Auth0 Organization ID

Layer / File(s) Summary
Type and config resolution for organizationId
src/lib/auth/types.ts, src/lib/auth/config.ts, src/lib/auth/index.ts
Adds organizationId?: string to Auth0Config, a new AUTH0_ORGANIZATION_ID entry in AUTH_ENV_VARS, a default organizationId, updated getAuth0Config() logic, and re-exports the updated config symbols.
PKCE authorization URL wiring and tests
src/lib/auth/pkce-flow.ts, src/lib/auth/__tests__/pkce-flow.test.ts
startAuthFlow() conditionally adds an organization query parameter, and the new test suite verifies organizationId derivation and URL construction.

Internal API Client Routing

Layer / File(s) Summary
Client base URL split
src/lib/api/internal-client.ts
Introduces separate internal and management API base URL constants and stores both values on InternalApiClient.
Endpoint routing by base URL
src/lib/api/internal-client.ts
Updates the request helper and endpoint methods so management reads use the management base URL while project reads and sender config writes use the internal proxy base URL.
Request destination tests
src/lib/api/__tests__/internal-client.test.ts
Adds fetch-mocking tests that assert management API calls go to the expected endpoints and project reads go through the Console internal proxy.

Agent Handoff Execve Gating

Layer / File(s) Summary
Conditional execve lookup in handoff
src/lib/services/agent-handoff.ts
runAgentHandoff and runCommandHandoff pass an allowExecve flag into runHandoffInvocation, which now only calls getExecve() when that flag is true.

Package Version

Layer / File(s) Summary
Manifest version update
package.json
The package version changes from 1.1.2 to 1.1.3.

Suggested reviewers: JeongwooYoo, nyanxyz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: fixing Auth0 login and project setup flow.
Description check ✅ Passed The description follows the required template and includes all major sections with actionable validation steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/auth0-organization-param

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/lib/auth/__tests__/pkce-flow.test.ts (1)

49-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a negative test for the omitted organization param.

Existing tests only cover the case where organizationId is set. Add a case asserting organization is absent from the authorization URL when organizationId is not configured, to guard the conditional in pkce-flow.ts (Line 75-78) against future regressions.

✅ Suggested additional test
+  test('omits organization from authorization URL when not configured', async () => {
+    const service = new PKCEFlowService({
+      domain: 'example.auth0.com',
+      clientId: 'client-id',
+      audience: 'https://example.auth0.com/api/v2/',
+      scope: 'openid profile email offline_access',
+    });
+
+    try {
+      const { authUrl } = await service.startAuthFlow();
+      expect(new URL(authUrl).searchParams.has('organization')).toBe(false);
+    } finally {
+      service.abort();
+    }
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/auth/__tests__/pkce-flow.test.ts` around lines 49 - 64, Add a
negative test for PKCEFlowService authorization URL generation to verify the
conditional organization parameter handling. Extend the existing pkce-flow test
suite with a case that creates PKCEFlowService without organizationId, calls
startAuthFlow(), and asserts that new URL(authUrl).searchParams does not contain
organization. Use PKCEFlowService and startAuthFlow as the key symbols so the
test guards the conditional in pkce-flow.ts against regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/lib/auth/__tests__/pkce-flow.test.ts`:
- Around line 49-64: Add a negative test for PKCEFlowService authorization URL
generation to verify the conditional organization parameter handling. Extend the
existing pkce-flow test suite with a case that creates PKCEFlowService without
organizationId, calls startAuthFlow(), and asserts that new
URL(authUrl).searchParams does not contain organization. Use PKCEFlowService and
startAuthFlow as the key symbols so the test guards the conditional in
pkce-flow.ts against regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c7f8a88-e0ea-4a81-9fcc-bb9c0ded52be

📥 Commits

Reviewing files that changed from the base of the PR and between da855ad and dbd8cb0.

📒 Files selected for processing (4)
  • src/lib/auth/__tests__/pkce-flow.test.ts
  • src/lib/auth/config.ts
  • src/lib/auth/pkce-flow.ts
  • src/lib/auth/types.ts

@coderabbitai
coderabbitai Bot requested a review from nyanxyz July 4, 2026 03:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/api/internal-client.ts`:
- Line 7: The management API URL is still hardcoded to the production default,
which can diverge from the Console environment used by getInternalApiClient().
Update the internal client configuration so managementBaseUrl is derived from
the same environment override as CONSOLE_URL, or is explicitly plumbed through
config at the same call sites; use the existing getInternalApiClient and
DEFAULT_MANAGEMENT_API_URL symbols to locate the fallback and replace it with
the matching environment-aware value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e2f7b08-1c87-421e-acf2-db84ac927191

📥 Commits

Reviewing files that changed from the base of the PR and between 87d657e and c57bfd2.

📒 Files selected for processing (2)
  • src/lib/api/__tests__/internal-client.test.ts
  • src/lib/api/internal-client.ts

Comment thread src/lib/api/internal-client.ts
@pitzcarraldo pitzcarraldo changed the title fix(auth): include Auth0 organization in PKCE flow fix(install): repair Auth0 and project setup flow Jul 4, 2026
@pitzcarraldo pitzcarraldo self-assigned this Jul 4, 2026
@pitzcarraldo
pitzcarraldo merged commit e4cb941 into main Jul 4, 2026
5 checks passed
@pitzcarraldo
pitzcarraldo deleted the fix/auth0-organization-param branch July 4, 2026 04:23
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.

1 participant