Skip to content

FE-1097: Fix post-signup loop possibility#8918

Merged
CiaranMn merged 4 commits into
mainfrom
cm/fix-signup-render-loop
Jun 30, 2026
Merged

FE-1097: Fix post-signup loop possibility#8918
CiaranMn merged 4 commits into
mainfrom
cm/fix-signup-render-loop

Conversation

@CiaranMn

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

Fixes an issue where the user could get stuck in a loop post-signup.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jun 30, 2026 2:12am
hash (staging) Ready Ready Preview, Comment Jun 30, 2026 2:12am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jun 30, 2026 2:12am
petrinaut Skipped Skipped Jun 30, 2026 2:12am

@vercel vercel Bot temporarily deployed to Preview – petrinaut June 30, 2026 01:34 Inactive
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 30, 2026 01:36 Inactive
@CiaranMn CiaranMn marked this pull request as ready for review June 30, 2026 01:36
Copilot AI review requested due to automatic review settings June 30, 2026 01:36
@cursor

cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches core auth bootstrap, global redirects, and post-signup navigation; regressions could mis-route users or briefly show wrong workspace, but changes are narrowly scoped to known loop/stale-state bugs.

Overview
Fixes cases where users could spin on a loading screen or get stuck in navigation loops after signup or org invite acceptance.

In _app, client redirects from getInitialProps now use pendingRedirect: a redirectTo that matches router.asPath is ignored so same-URL router.replace does not re-trigger getInitialProps in a loop (e.g. stale redirectTo: "/" on home). The loading gate follows the same rule so the app renders when already on the target path.

index sends incomplete-signup users to /signup via useEffect instead of calling push during render.

AuthInfoProvider merges initialAuthenticatedUserSubgraph from each navigation when it carries a newer user edition (transaction time), so server-fetched auth stays ahead of stale client state.

workspace-context resets invalid activeWorkspaceWebId in a useEffect rather than inside useMemo.

After signup or invite acceptance, signup uses window.location.assign("/") instead of client-side router.push/replace so / mounts cleanly with fresh auth when getInitialProps-driven transitions mis-resolve the route.

Reviewed by Cursor Bugbot for commit 86076bd. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI 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.

Pull request overview

Fixes a post-signup / post-navigation redirect loop by making client-side redirects idempotent (no-op when already on the target route) and by ensuring client auth/workspace state stays consistent with newer server-provided user data.

Changes:

  • Prevent infinite same-URL redirects by ignoring redirectTo values that match the current route.
  • Ensure users with access but incomplete signup are redirected to /signup via an effect (instead of during render).
  • Keep client auth user subgraph in sync with newer server-provided user data and reset invalid workspace selections to a default.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
apps/hash-frontend/src/pages/shared/workspace-context.tsx Derives activeWorkspace explicitly and resets invalid activeWorkspaceWebId to a default workspace.
apps/hash-frontend/src/pages/shared/auth-info-context.tsx Adopts newer server-provided authenticated-user subgraph based on transaction time comparisons.
apps/hash-frontend/src/pages/index.page.tsx Redirects incomplete-signup users to /signup using useEffect to avoid render-time navigation.
apps/hash-frontend/src/pages/_app.page.tsx Avoids same-path redirectTo handling to prevent replace -> getInitialProps -> replace loops and avoids stalling UI when the redirect is a no-op.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/hash-frontend/src/pages/shared/workspace-context.tsx Outdated
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 30, 2026 02:04 Inactive
Comment thread apps/hash-frontend/src/pages/shared/auth-info-context.tsx
@CiaranMn CiaranMn enabled auto-merge June 30, 2026 02:17
@CiaranMn CiaranMn added this pull request to the merge queue Jun 30, 2026
Merged via the queue into main with commit a162311 Jun 30, 2026
44 checks passed
@CiaranMn CiaranMn deleted the cm/fix-signup-render-loop branch June 30, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

3 participants