Skip to content

fix(front): defer default home redirect when object metadata is not loaded#20330

Open
charlesBochet wants to merge 1 commit intomainfrom
fix/post-login-redirect-metadata-not-loaded
Open

fix(front): defer default home redirect when object metadata is not loaded#20330
charlesBochet wants to merge 1 commit intomainfrom
fix/post-login-redirect-metadata-not-loaded

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

Summary

Fixes the merge-queue E2E failures introduced after #20308. After login, users were being silently redirected to /settings/profile instead of their workspace home, which broke every dependent E2E test that re-uses the post-login URL (workflow-creation.spec.ts, authentication/signup_invite_email.spec.ts, etc.).

Root cause

useDefaultHomePagePath falls back to /settings/profile when readableNonSystemObjectMetadataItems is empty. That list is empty in two cases:

  1. The user genuinely has no readable objects → /settings/profile is the intended fallback.
  2. Object metadata simply hasn't been loaded yet (transient post-login window).

Before #20308 the frontend always loaded mocked metadata for authenticated users, so case (2) never happened. After #20308 mocked metadata is gone, and during the post-verify window (handleLoadWorkspaceAfterAuthentication finishes, setIsAppEffectRedirectEnabled(true) re-enables redirects, PageChangeEffect fires) the metadata store is still empty. The hook then returns /settings/profile. Because that path is not in ONBOARDING_PATHS / ONGOING_USER_CREATION_PATHS, usePageChangeEffectNavigateLocation doesn't fire a corrective redirect once metadata finally loads — the user is stranded.

login.setup.ts captures process.env.LINK = page.url() after verify, so subsequent tests goto(LINK) end up in Settings looking for app navigation that isn't there → click timeouts.

Fix

Distinguish the two empty cases by reading metadataStoreState('objectMetadataItems').status. If it isn't 'up-to-date' we defer to AppPath.Index instead of /settings/profile. The memo recomputes when the status flips, and the user is then routed to their actual home page.

A regression test is added in useDefaultHomePagePath.test.ts for the not-loaded-yet case.

Test plan

  • Unit: npx jest src/modules/navigation/hooks/__tests__/useDefaultHomePagePath.test.ts (5/5 pass, including new regression case)
  • CI: Playwright E2E (workflow-creation.spec.ts, authentication/signup_invite_email.spec.ts) pass on this branch
  • Manual: log in to a fresh local instance and confirm landing page is the workspace home, not /settings/profile

…oaded

After PR #20308 removed the mocked-metadata placeholder for authenticated
users, useDefaultHomePagePath could observe an empty
readableNonSystemObjectMetadataItems list during the post-login transition
window (token set -> currentUser loaded -> workspace loaded -> metadata
loaded). The empty-fallback then sent the user to /settings/profile, and
because that path is not in ONBOARDING_PATHS / ONGOING_USER_CREATION_PATHS,
the redirect logic never fired again to correct the destination once
metadata finally arrived. The user was stranded on the profile settings
page after every login - which is what was breaking the merge queue E2E
tests (login.setup captured /settings/profile as LINK, then dependent
tests like workflow-creation.spec.ts and signup_invite_email.spec.ts
timed out clicking app navigation that did not exist on the settings
page).

Distinguish "user genuinely has no readable objects" from "object
metadata has not loaded yet" by checking metadataStoreState status. When
metadata is not yet up-to-date, defer to AppPath.Index so the memo
recomputes once metadata loads and the user is redirected to their real
home page.

Add a regression test covering the not-loaded-yet case.
Copilot AI review requested due to automatic review settings May 6, 2026 17:07
@charlesBochet charlesBochet added the run-merge-queue Triggers the merge queue E2E pipeline on a PR label May 6, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

-PR: awaiting author -PR: wip run-merge-queue Triggers the merge queue E2E pipeline on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant