Skip to content

Conversation

ameer2468
Copy link
Collaborator

@ameer2468 ameer2468 commented Oct 20, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Onboarding "Skip to Dashboard" now ensures a user without an organization gets a properly created organization and is associated with it so dashboard access works reliably.
  • New Features

    • Buttons now support customizable spinner color and spinner border color.
    • The onboarding "Skip to Dashboard" button shows its spinner consistently while the action is in progress.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The Onboarding.skipToDashboard flow now conditionally creates a new organization and owner/member only when the current user's activeOrganizationId has no matching organization; it then updates the user's activeOrganizationId and defaultOrgId on the users row. UI changes expose spinner color props and make one button spinner always visible.

Changes

Cohort / File(s) Summary
Onboarding backend flow
packages/web-backend/src/Users/UsersOnboarding.ts
Adjusted skipToDashboard to: read for an existing organization by the user's activeOrganizationId; when none exists, insert a new organization and owner member, then update the Db.users row to set activeOrganizationId and defaultOrgId (removed prior update-to-organizations logic and dependency on organization setup step).
Button / Spinner props & defaults
packages/ui/src/components/Button.tsx, packages/ui/src/components/LoadingSpinner.tsx
Added spinnerColor and spinnerBorderColor props to Button (defaults: spinnerColor: "white", spinnerBorderColor: "rgba(255, 255, 255, 0.2)") and a borderColor prop to LoadingSpinner (default rgba(255, 255, 255, 0.2)); Button forwards the new props to LoadingSpinner.
Onboarding UI: skip button spinner
apps/web/app/(org)/onboarding/components/Bottom.tsx
Changed Skip to Dashboard button to always render the spinner (spinner={true}) and supply spinnerColor="black" and spinnerBorderColor="rgba(0, 0, 0, 0.2)"; button remains disabled while mutation is pending or succeeded.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant Frontend
    participant Backend
    participant DB

    User->>Frontend: Click "Skip to Dashboard"
    Frontend->>Backend: POST /onboarding/skipToDashboard
    Backend->>DB: SELECT organization WHERE id = user.activeOrganizationId
    alt organization exists
        DB-->>Backend: organization row
        Backend->>DB: UPDATE users SET activeOrganizationId/defaultOrgId = existingOrg.id
        DB-->>Backend: OK
        Backend-->>Frontend: 200 (redirect to dashboard)
    else no organization found
        Backend->>DB: INSERT INTO organizations (ownerId, ...) -> newOrg.id
        DB-->>Backend: newOrg.id
        Backend->>DB: INSERT INTO organization_members (orgId, userId, role=owner)
        DB-->>Backend: OK
        Backend->>DB: UPDATE users SET activeOrganizationId = newOrg.id, defaultOrgId = newOrg.id
        DB-->>Backend: OK
        Backend-->>Frontend: 200 (redirect to dashboard)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through code with ears held high,
If no home exists, a new one I try,
I stitch the user to org with a gentle thump,
Spinners spin black while buttons stay plump,
A little rabbit patch — quick, neat, and spry. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "web: fix org setup when skipping to dashboard during onboarding" is fully related to the main change in the changeset. According to the raw summary, the change fixes how organization setup works in the Onboarding.skipToDashboard function when no existing organization exists or organizationSetup is incomplete—specifically by creating a new organization and updating the user's organization references via the correct database table. The title accurately captures both the primary fix (organization setup) and the context (skipping to dashboard during onboarding) in concise, clear language that a teammate could easily understand when scanning the commit history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4519ee and 449f8f9.

📒 Files selected for processing (4)
  • apps/web/app/(org)/onboarding/components/Bottom.tsx (1 hunks)
  • packages/ui/src/components/Button.tsx (3 hunks)
  • packages/ui/src/components/LoadingSpinner.tsx (2 hunks)
  • packages/web-backend/src/Users/UsersOnboarding.ts (1 hunks)

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/web-backend/src/Users/UsersOnboarding.ts (1)

283-288: Consider checking defaultOrgId as a fallback for consistency.

The organizationSetup method checks both user.activeOrganizationId and user.defaultOrgId as a fallback (line 90), but skipToDashboard only queries using currentUser.activeOrganizationId. If a user has no activeOrganizationId but has a defaultOrgId, this could lead to creating a duplicate organization instead of using the existing one.

For consistency with the organizationSetup method, consider:

+const orgIdToCheck = user.activeOrganizationId ?? user.defaultOrgId;
+
 const [existingOrg] = await tx
   .select()
   .from(Db.organizations)
   .where(
-    Dz.eq(Db.organizations.id, currentUser.activeOrganizationId),
+    Dz.eq(Db.organizations.id, orgIdToCheck),
   );

Note: You may also want to add a null check before the query if orgIdToCheck could be null, or structure it as:

let existingOrg = null;
const orgIdToCheck = user.activeOrganizationId ?? user.defaultOrgId;

if (orgIdToCheck) {
  [existingOrg] = await tx
    .select()
    .from(Db.organizations)
    .where(Dz.eq(Db.organizations.id, orgIdToCheck));
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4262364 and f4519ee.

📒 Files selected for processing (1)
  • packages/web-backend/src/Users/UsersOnboarding.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Use strict TypeScript and avoid any; leverage shared types

Files:

  • packages/web-backend/src/Users/UsersOnboarding.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • packages/web-backend/src/Users/UsersOnboarding.ts
🧬 Code graph analysis (1)
packages/web-backend/src/Users/UsersOnboarding.ts (2)
packages/web-domain/src/Organisation.ts (1)
  • Organisation (8-11)
packages/database/helpers.ts (1)
  • nanoId (6-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)

@ameer2468 ameer2468 merged commit a193e84 into main Oct 20, 2025
13 of 14 checks passed
@ameer2468 ameer2468 deleted the fix-skip-dashboard branch October 20, 2025 20:37
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