Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.

fix: prevent premature route resolution before initial auth check completes#45

Merged
RMCampos merged 5 commits into
mainfrom
copilot/bugfix-home-page-loading-issue
May 7, 2026
Merged

fix: prevent premature route resolution before initial auth check completes#45
RMCampos merged 5 commits into
mainfrom
copilot/bugfix-home-page-loading-issue

Conversation

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor

On page load/refresh, AuthProvider initializes with signed: false while the async session check runs in App's useEffect. The router renders immediately with the unauthenticated config, redirecting logged-in users away from /home before the check resolves.

Changes

  • AuthContext.ts: Added loading: boolean to AuthContextData interface
  • AuthProvider.tsx: Added loading state (default true); moved the initial checkCurrentAuthUser call here (from App.tsx) in a mount-only useEffect; sets loading = false via .catch().finally() after the check settles
  • App.tsx: Reads loading from context; suppresses RouterProvider until loading is false; removes the now-redundant checkCurrentAuthUser useEffect
  • authContextMock.ts: Added loading: false to the test mock
  • AuthProvider.test.tsx: Added tests asserting loading transitions to false after mount (both with and without a valid token)
// AuthProvider — loading cleared regardless of auth outcome
useEffect(() => {
  checkCurrentAuthUser(window.location.pathname)
    .catch(e => console.error(e))
    .finally(() => setLoading(false));
}, []);

// App — router withheld until auth state is known
{!loading && <RouterProvider router={browserRouter} />}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node dist/index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 3 commits May 7, 2026 13:47
Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix home page loading issue when reopening tab with valid session fix: prevent premature route resolution before initial auth check completes May 7, 2026
Copilot AI requested a review from RMCampos May 7, 2026 13:51
@RMCampos RMCampos marked this pull request as ready for review May 7, 2026 14:20
@RMCampos RMCampos merged commit 02fae25 into main May 7, 2026
2 checks passed
@RMCampos RMCampos deleted the copilot/bugfix-home-page-loading-issue branch May 7, 2026 14:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Home page not loading after closing and reopening the tab while logged in

2 participants