Skip to content

fix: redirect new users to onboarding from plugin connect page#908

Open
vorflux[bot] wants to merge 1 commit intomainfrom
vorflux/fix-connect-page-no-org-redirect-v2
Open

fix: redirect new users to onboarding from plugin connect page#908
vorflux[bot] wants to merge 1 commit intomainfrom
vorflux/fix-connect-page-no-org-redirect-v2

Conversation

@vorflux
Copy link
Copy Markdown
Contributor

@vorflux vorflux Bot commented May 7, 2026

Problem

New users arriving at /auth/connect (e.g. from the OpenCode CLI plugin) have no organization yet. The "Approve Connection" button's handleConnect function had a silent guard:

if (!session || !org) return  // silent return -- no error, no feedback

This caused the button to do absolutely nothing for new users. PostHog session recordings show users rage-clicking "Approve Connection" 8+ times across 5+ minutes with zero feedback, eventually giving up or stumbling into onboarding by accident.

Evidence from PostHog:

  • Session 019dcf46 (ramonpg91@gmail.com): 110 clicks, 8 rage-click events on "Approve Connection" over 5 minutes. User only discovered onboarding after navigating away.
  • Session 019de4cd (zongsi@wherobots.com): Same pattern -- 54 clicks, 2 rage-click events, 22-minute session for what should be a 30-second flow.
  • 5 connect-related sessions in the last 10 days, multiple showing 0 clicks (likely abandoned).

Root cause: The /auth/connect page sits outside the (app) route group, so it doesn't have the EnsureWorkspace wrapper that redirects org-less users to onboarding on all other pages.

Supersedes #895 (fresh branch from latest main).

Solution

  1. Detect new users on the connect page and automatically redirect them to onboarding, stashing the full connect URL in sessionStorage.

  2. After onboarding completes, skip and completion paths check sessionStorage for a pending connect URL and redirect back to it instead of "/". This covers:

    • handleSkip() in the new onboarding page (creates org then redirects)
    • goHomeOrPendingConnect() for the "Go to home" button
    • InitialHeader.handleSkip() (still used in login page)
  3. Show a proper error message instead of silently returning when session or org is missing and the user clicks "Approve Connection".

  4. Wait for full auth state (isRestoring, organizations) before showing the connect card, preventing existing users from seeing a false error while their org is still being restored.

Changes

  • apps/web/app/auth/connect/page.tsx -- Added redirect-to-onboarding useEffect, isAuthLoading guard, error message for missing org
  • apps/web/app/(app)/onboarding/page.tsx -- handleSkip() and "Go to home" button use consumePendingConnectUrl() to redirect back to the connect page if pending
  • apps/web/components/initial-header.tsx -- handleSkip() checks for pending connect URL
  • apps/web/lib/constants.ts -- New shared PENDING_CONNECT_URL_KEY constant and consumePendingConnectUrl() helper
  • apps/web/lib/__tests__/constants.test.ts -- 7 unit tests for the helper

Testing

Unit Tests

Command: bunx vitest run apps/web/lib/__tests__/constants.test.ts
Result: 7/7 PASS

✓ returns null when no pending URL is stored
✓ returns the relative path + query when a full URL is stored
✓ includes the hash fragment if present
✓ removes the stored key after consumption
✓ returns null and logs a warning when sessionStorage throws
✓ returns null when the stored value is not a valid URL
✓ returns only pathname when URL has no query or hash

Type Checking

Command: npx tsc --noEmit (in apps/web)
Result: PASS -- no new type errors (pre-existing errors in unrelated files confirmed present on main)

Lint / Format

Command: bunx biome check on all changed files
Result: PASS -- no issues

Browser Testing

Test Description Method Result
TC1 New-user redirect to onboarding Code inspection VERIFIED
TC2 consumePendingConnectUrl returns correct relative path Browser PASS
TC2b All onboarding exit paths call consumePendingConnectUrl Code inspection VERIFIED
TC3 Existing user sees connect card with Approve button Browser PASS
TC4 No-org error shows "not fully set up" message Browser PASS
TC5 sessionStorage key absent after first consume Browser PASS
TC6 No-session guard: stays on connect page, no redirect Browser PASS

Session Details

New users arriving at /auth/connect (e.g. from OpenCode CLI) had no
organization yet, causing the 'Approve Connection' button to silently
fail. The handleConnect guard 'if (!session || !org) return' would
fire with no feedback, leading to rage-clicking.

Changes:
- Detect logged-in users with no org on the connect page and redirect
  them to onboarding, stashing the connect URL in sessionStorage.
- After onboarding completes (skip or finish), redirect back to the
  connect page so the plugin auth flow finishes automatically.
- Show an error message instead of silently returning when session/org
  is missing and the user clicks 'Approve Connection'.
- Wait for full auth state before showing the connect card.
- Extract PENDING_CONNECT_URL_KEY and consumePendingConnectUrl() to a
  shared constants file with 7 unit tests.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp 88f9fb2 May 07 2026, 10:56 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app 88f9fb2 Commit Preview URL

Branch Preview URL
May 07 2026, 10:57 PM

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.

0 participants