Skip to content

fix: enable organization creation from project selector#392

Open
akashcorex wants to merge 1 commit into
Openpanel-dev:mainfrom
akashcorex:fix/self-hosted-creating-org
Open

fix: enable organization creation from project selector#392
akashcorex wants to merge 1 commit into
Openpanel-dev:mainfrom
akashcorex:fix/self-hosted-creating-org

Conversation

@akashcorex

@akashcorex akashcorex commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Fixed a dashboard issue preventing self-hosted users from creating additional organizations.

Multi-organization support is already available in self-hosted deployments and does not require any extra environment flags beyond the standard self-hosted configuration (SELF_HOSTED=true, DASHBOARD_URL, API_URL). The backend onboarding flow already supports creating new organizations and automatically assigns the creator the org:admin role.

The issue was in the UI flow. The "New organization" option in the organization selector redirected users to the onboarding page, which defaulted to "Use existing workspace" when an organization already existed. This change updates the flow to open the workspace creation mode directly.

Changes

  • Updated organization selector navigation

    • project-selector.tsx
  • Updated onboarding page initialization

    • _steps.onboarding.project.tsx

Notes

The POST https://api.openpanel.dev/track 401 error is unrelated to organization creation. It comes from the dashboard telemetry client attempting to send analytics to hosted OpenPanel when VITE_OP_CLIENT_ID is present or misconfigured.

Fixes #388

Summary by CodeRabbit

  • Bug Fixes
    • Fixed the organization creation flow to properly preserve the intent to create a new organization when navigating to the project onboarding step, ensuring the correct initial state is maintained throughout the setup process.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Navigation to create a new organization now passes a createNewOrg query parameter. The onboarding project route validates this optional boolean parameter and uses it to initialize the component's UI state, replacing the prior unconditional default.

Changes

Organization Creation State via Query Parameter

Layer / File(s) Summary
Route query validation and state initialization
apps/start/src/routes/_steps.onboarding.project.tsx
The route search validation schema is extended with an optional createNewOrg field coerced to boolean. The component retrieves validated search parameters and initializes the createNewOrg state using the parameter value instead of always defaulting to false.
Project selector navigation
apps/start/src/components/project-selector.tsx
The "New organization" dropdown item is updated to include createNewOrg: true as a search parameter when navigating to /onboarding/project.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A hop and a bound, through query strings we've found,
New orgs spawn with a flag so true,
State blooms from the search, no defaults in sight,
The onboarding path now knows what to do! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling organization creation from the project selector, which matches the PR's core objective of fixing the dashboard UI flow for self-hosted users.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@apps/start/src/routes/_steps.onboarding.project.tsx`:
- Around line 33-35: The current preprocess for createNewOrg coerces any
non-true input to false, hiding invalid values; change the preprocess to return
true only when value === true or value === 'true', and otherwise return the
original value so z.boolean() will reject malformed inputs (e.g. use preprocess:
(v) => (v === true || v === 'true' ? true : v) with the existing z.boolean() and
.optional()). This keeps the symbol createNewOrg and its surrounding schema but
ensures invalid query values fail validation instead of becoming false.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea8cfbb8-8cdf-4fc0-9107-f692b6130d04

📥 Commits

Reviewing files that changed from the base of the PR and between 3139211 and 0bcc7e9.

📒 Files selected for processing (2)
  • apps/start/src/components/project-selector.tsx
  • apps/start/src/routes/_steps.onboarding.project.tsx

Comment on lines +33 to +35
createNewOrg: z
.preprocess((value) => value === true || value === 'true', z.boolean())
.optional(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Harden createNewOrg parsing to reject malformed values instead of coercing them to false.

Line 34 currently maps any non-true input to false (e.g. 'tru', 'yes'), which silently masks invalid query values.

Suggested fix
 const validateSearch = z.object({
   inviteId: z.string().optional(),
-  createNewOrg: z
-    .preprocess((value) => value === true || value === 'true', z.boolean())
-    .optional(),
+  createNewOrg: z
+    .preprocess((value) => {
+      if (value === undefined) return undefined;
+      if (value === true || value === 'true') return true;
+      if (value === false || value === 'false') return false;
+      return value;
+    }, z.boolean())
+    .optional(),
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
createNewOrg: z
.preprocess((value) => value === true || value === 'true', z.boolean())
.optional(),
createNewOrg: z
.preprocess((value) => {
if (value === undefined) return undefined;
if (value === true || value === 'true') return true;
if (value === false || value === 'false') return false;
return value;
}, z.boolean())
.optional(),
🤖 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 `@apps/start/src/routes/_steps.onboarding.project.tsx` around lines 33 - 35,
The current preprocess for createNewOrg coerces any non-true input to false,
hiding invalid values; change the preprocess to return true only when value ===
true or value === 'true', and otherwise return the original value so z.boolean()
will reject malformed inputs (e.g. use preprocess: (v) => (v === true || v ===
'true' ? true : v) with the existing z.boolean() and .optional()). This keeps
the symbol createNewOrg and its surrounding schema but ensures invalid query
values fail validation instead of becoming false.

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.

Orgs limits on Selfhosted Instance

2 participants