Skip to content

fix(settings): skip redundant set-password account-status check#20719

Open
vpomerleau wants to merge 1 commit into
mainfrom
FXA-13937-skip-setpassword-check
Open

fix(settings): skip redundant set-password account-status check#20719
vpomerleau wants to merge 1 commit into
mainfrom
FXA-13937-skip-setpassword-check

Conversation

@vpomerleau

Copy link
Copy Markdown
Contributor

Because

  • The post-verify set-password page blocked first paint on a blocking accountStatus round-trip, which intermittently exceeded the stage smoke test's 10s assertion and flaked passkeySetPassword.spec.ts.
  • Every in-app flow that routes to this page (passkey, OTP, third-party) does so only for passwordless accounts, so re-deriving the password state with a network call is redundant.

This pull request

  • Gates the accountStatus check on router state in packages/fxa-settings/src/pages/PostVerify/SetPassword/container.tsx: when the page is reached via a forward flow (location.state.passwordCreationReason is set), it paints immediately without the round-trip.
  • Keeps the check for stateless arrivals (refresh / direct URL / back), where a password may already exist and a redirect to /signin is still wanted.
  • Simplifies the check effect to a flat then/catch, resolves the stale retry TODO, and corrects the inaccurate "third-party may have a password" comment.
  • Adds container tests covering the gating: skip when state-routed, run on stateless arrival, and fail open when the check errors.

Issue that this pull request solves

Closes: FXA-13937

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on:
  • Suggested review order:
  • Risky or complex parts:

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Known pre-existing limitation (out of scope): on a stateless arrival where the accountStatus check itself fails and the account already has a password, the page falls through to the form and /password/create rejects server-side with a "password already set" banner instead of redirecting to /signin. This requires a rare triple-coincidence and is a candidate for a follow-up.

…rward flows

Because:
- The post-verify set-password page blocked first paint on an accountStatus
  round-trip, intermittently exceeding the stage smoke test's 10s assertion
  and flaking passkeySetPassword.spec.ts.
- Every forward flow (passkey/OTP/third-party) only routes here for
  passwordless accounts, so re-deriving the password state is redundant.

This commit:
- Skips the accountStatus check when routed here with router state, running it
  only for stateless arrivals (refresh/direct URL/back) where a password may
  exist and a redirect to /signin is still wanted.
- Simplifies the check effect to a flat then/catch and resolves the stale
  retry TODO; corrects the inaccurate "third-party may have a password" note.
- Adds container tests covering the gating.

Closes #FXA-13937
@vpomerleau vpomerleau marked this pull request as ready for review June 9, 2026 23:36
@vpomerleau vpomerleau requested a review from a team as a code owner June 9, 2026 23:36
Copilot AI review requested due to automatic review settings June 9, 2026 23:36

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

This PR reduces first-paint latency (and stage smoke-test flakes) on the PostVerify Set Password page by skipping a redundant accountStatus round-trip when the page is reached via known forward flows that already imply a passwordless account.

Changes:

  • Gate the blocking accountStatus check based on presence of router state to allow immediate render for forward flows.
  • Simplify the accountStatus effect logic (flat then/catch) and update the related inline comment.
  • Add tests to validate when the accountStatus check is skipped vs executed, including fail-open behavior on errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/fxa-settings/src/pages/PostVerify/SetPassword/container.tsx Skips blocking accountStatus check for state-routed forward flows to improve first paint; keeps redirect behavior for password-present cases.
packages/fxa-settings/src/pages/PostVerify/SetPassword/container.test.tsx Adds unit tests covering the new gating behavior for accountStatus, including skip/run/error paths.

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

Comment on lines +74 to 78
const stateRouted = location.state?.passwordCreationReason !== undefined;

const [passwordStatus, setPasswordStatus] = useState<{
isLoading: boolean;
hasPassword: boolean;
});
expect(mockNavigate).not.toHaveBeenCalled();
});
});
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.

2 participants