Skip to content

fix: root redirect should prefer personal workspace (#152)#157

Merged
zacharias-ona merged 1 commit intomainfrom
fix/152-root-redirect-personal-workspace
Apr 17, 2026
Merged

fix: root redirect should prefer personal workspace (#152)#157
zacharias-ona merged 1 commit intomainfrom
fix/152-root-redirect-personal-workspace

Conversation

@zacharias-ona
Copy link
Copy Markdown
Collaborator

Closes #152

What

The root page (/) redirected authenticated users to whichever workspace Supabase returned first from an unfiltered .limit(1).maybeSingle() query on the members table. Depending on row ordering, this could land the user in a team workspace instead of their personal workspace.

How

Changed the redirect query to first look for a membership whose joined workspace has is_personal = true, using a workspaces!inner(slug) join so the filter actually excludes non-matching parent rows. If no personal workspace exists (edge case), a second query falls back to any available workspace. Extracted a shared extractSlug helper to normalise the Supabase join result (object vs array).

Testing

Added src/app/page.test.tsx with four regression tests:

  • Redirects to personal workspace when one exists (verifies !inner join in select)
  • Falls back to any workspace when no personal workspace exists (verifies two queries are made)
  • Renders landing page for unauthenticated users
  • Renders landing page when user has no workspaces at all

All existing tests continue to pass: pnpm lint && pnpm typecheck && pnpm test && pnpm test:e2e (178 unit tests, 42 E2E tests).

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memo Ready Ready Preview, Comment Apr 17, 2026 1:46am

Request Review

@zacharias-ona zacharias-ona merged commit 9ac86b3 into main Apr 17, 2026
6 checks passed
@zacharias-ona zacharias-ona deleted the fix/152-root-redirect-personal-workspace branch April 17, 2026 01:52
@zacharias-ona
Copy link
Copy Markdown
Collaborator Author

✅ UI verification skipped — no visual changes detected.

This PR only modifies server-side redirect logic (extractSlug helper, personal workspace preference) and adds unit tests. The rendered JSX in src/app/page.tsx is unchanged.

@zacharias-ona
Copy link
Copy Markdown
Collaborator Author

✅ Post-merge verification passed.

E2E suite: 41/42 passed. 1 pre-existing failure (not a regression from this PR).

Ad-hoc smoke tests — all passed:

  • ✅ Landing page (/) — loads, has title
  • ✅ Sign-in page (/sign-in) — renders email input
  • ✅ Health endpoint (/api/health) — returns OK
  • ✅ Authenticated login flow — redirects to workspace
  • ✅ Workspace page load — fully rendered
  • ✅ Editor navigation — page button click navigates to editor route
  • ✅ No console errors (unauthenticated or authenticated)

Skipped:

  • /dashboard (route does not exist)

Known pre-existing E2E failure (not from this PR):

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.

fix: root redirect should prefer personal workspace

1 participant