Skip to content

fix(platform): redirect to create-organization instead of auto-creating Default org#1698

Merged
larryro merged 4 commits into
mainfrom
dashboard-no-auto-default-org
May 11, 2026
Merged

fix(platform): redirect to create-organization instead of auto-creating Default org#1698
larryro merged 4 commits into
mainfrom
dashboard-no-auto-default-org

Conversation

@larryro

@larryro larryro commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • When a signed-in user has no organizations, route them to /dashboard/create-organization instead of silently creating a Default org and initializing workflows.
  • Removes the unused initializeDefaultWorkflows action call and the inline createDefaultOrganization helper from the dashboard index route.

Test plan

  • Sign in as a user with zero organizations → lands on /dashboard/create-organization (no Default org auto-created).
  • Sign in as a user with one or more organizations → still resolves to the last-active org as before.
  • bun run check passes.

Summary by CodeRabbit

  • New Features
    • Dashboard now directs users to create an organization when none exists, replacing the previous automatic organization setup.

Review Change Stack

…ng Default org

When a user has no organizations, route them to the create-organization page
rather than silently creating a "Default" org and initializing workflows.
@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR removes automatic default organization creation from the dashboard index route. When the organizations list is empty, the component now redirects users to /dashboard/create-organization rather than automatically creating and initializing a default organization with workflows. The associated action hook setup is removed, import statements are simplified to use only useMutation, and the useEffect dependency array is updated to reflect the simpler behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The description includes a summary of changes and test plan, but the pre-merge checklist is not properly completed with checkboxes marked or N/A justifications provided. Complete the pre-merge checklist by either checking boxes or marking items as N/A with brief reasons for skipping them, per the repository template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: redirecting to create-organization instead of auto-creating a Default org, which aligns with the core objective of the changeset.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dashboard-no-auto-default-org

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
services/platform/app/routes/dashboard/index.tsx (1)

43-55: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t gate the zero-org redirect on lastActiveOrgId loading.

At Line 45, isLastActiveLoading blocks all paths, including the Line 51 zero-organization redirect. Users with no orgs should be redirected as soon as org membership is known; otherwise they can be stuck waiting on an unrelated query.

🔧 Suggested fix
   useEffect(() => {
     if (
       isOrgsLoading ||
-      isLastActiveLoading ||
       !organizations ||
       resolvedRef.current
     )
       return;

     if (organizations.length === 0) {
       resolvedRef.current = true;
       void navigate({ to: '/dashboard/create-organization' });
       return;
     }
+
+    if (isLastActiveLoading) return;

     resolvedRef.current = true;
🤖 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 `@services/platform/app/routes/dashboard/index.tsx` around lines 43 - 55, The
early-return gating currently includes isLastActiveLoading which prevents the
zero-organization redirect from firing; update the condition so the early return
only depends on isOrgsLoading, organizations, and resolvedRef.current (i.e.,
remove isLastActiveLoading from the if that returns early), then keep the
subsequent organizations.length === 0 branch that sets resolvedRef.current =
true and calls navigate('/dashboard/create-organization') so users with no orgs
are redirected immediately even if lastActiveOrgId is still loading.
🤖 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.

Outside diff comments:
In `@services/platform/app/routes/dashboard/index.tsx`:
- Around line 43-55: The early-return gating currently includes
isLastActiveLoading which prevents the zero-organization redirect from firing;
update the condition so the early return only depends on isOrgsLoading,
organizations, and resolvedRef.current (i.e., remove isLastActiveLoading from
the if that returns early), then keep the subsequent organizations.length === 0
branch that sets resolvedRef.current = true and calls
navigate('/dashboard/create-organization') so users with no orgs are redirected
immediately even if lastActiveOrgId is still loading.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a03565d5-8e51-4216-b76a-4ad2f1976fcb

📥 Commits

Reviewing files that changed from the base of the PR and between bd13c99 and 68e531e.

📒 Files selected for processing (1)
  • services/platform/app/routes/dashboard/index.tsx

larryro added 3 commits May 11, 2026 14:15
…ions

When a workflow consumes an OAuth2 integration whose refresh token Google
(or any provider) has revoked, the only signal was a generic "Please
re-authorize" in workflow logs and no indication on the Integrations page —
operators had to grep Convex logs to find the real `invalid_grant` reason.

- decrypt_and_refresh_oauth2.ts: parse the token endpoint's RFC 6749 §5.2
  error body and append `(error_code: description)` to the thrown message
  so it lands in wfExecutions.error. Mark the credential row with
  status='error' + errorMessage + lastErrorAt on every refresh-failure
  path (HTTP non-2xx, missing prerequisites, missing access_token in 200
  response); clear back to status='active' + lastSuccessAt on success.
- IntegrationCard: accept an optional `status` prop and render a
  destructive "Reconnect needed" badge when status === 'error', taking
  precedence over the isActive "Connected" badge.
- integrations.tsx: pass the merged status through to the card.
- en/de/fr: add `integrations.badge.reconnectNeeded` key.
- Test: assert that status='error' beats isActive on the card.

No schema migration: status/errorMessage/lastErrorAt already exist on
integrationCredentials. Re-authorizing the integration flips status back
to 'active' via the existing success path.
Follow-up to a9fe4e6: the list card flips to red "Reconnect needed"
when status='error', but the details drawer still rendered a green
"Active" indicator because IntegrationIconUpload only looked at
isActive (= drawer-is-in-details-mode, not credential health).

Thread the credential row's `status` through IntegrationPanel into
IntegrationIconUpload and make `status === 'error'` win over `isActive`
in the StatusIndicator branch. Adds an `integrations.upload.reconnectNeeded`
key alongside the existing active/inactive labels in en/de/fr.
…solving

On first render of /dashboard/$id/settings/integrations, useOrganization
hasn't resolved yet, so orgSlug falls back to '' and the action fires
with an empty slug. The server-side validateOrgSlug rejects it and
throws "Invalid org slug:" — TanStack Query refetches once the real
slug arrives, so users never notice, but every page load polluted the
Convex log with one bogus error.

Gate the query with `enabled: orgSlug !== ''` so it waits for the
caller to supply a slug. Chat callers pass the literal 'default', so
they keep firing unchanged.
@larryro larryro merged commit 9b92396 into main May 11, 2026
25 checks passed
@larryro larryro deleted the dashboard-no-auto-default-org branch May 11, 2026 06:55
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