Skip to content

fix(connect): add back button on password prompt and remember field values#727

Open
HexaField wants to merge 1 commit intodevfrom
fix/connect-login-ux
Open

fix(connect): add back button on password prompt and remember field values#727
HexaField wants to merge 1 commit intodevfrom
fix/connect-login-ux

Conversation

@HexaField
Copy link
Contributor

@HexaField HexaField commented Mar 7, 2026

Summary

Fixes two UX issues in the multi-user login flow:

Back button on password prompt (#724)

When logging in via the multi-user flow, entering the wrong email moved to the password prompt with no way to go back. Added a "Use Different Account" button that resets remoteAuthState, clears password/code/email fields, and returns to the email input step. Also appears on the account creation screen.

Remember field values (#726)

Remote URL and email fields now persist to sessionStorage during the session:

  • ad4m-connect-remote-url — restored when returning to connection options
  • ad4m-connect-email — restored when returning to the email input step
  • Password fields intentionally not persisted (security)
  • sessionStorage clears when the tab closes — no credential persistence across sessions

Files changed

  • connect/src/components/views/RemoteAuthentication.ts — back button + email persistence
  • connect/src/components/views/ConnectionOptions.ts — remote URL persistence

Closes #724, Closes #726

Summary by CodeRabbit

Release Notes

  • New Features
    • Remote URL persistence: Your remote URL selection now saves during your session
    • Email prefilling: Your email address automatically populates on return visits within the same session
    • "Use Different Account" button: Quickly switch to a different account or email during authentication

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

📝 Walkthrough

Walkthrough

These changes add sessionStorage-based persistence for remote URL and email inputs across the connection flow, allowing users to revisit previously entered values within a session. Additionally, a "use different account" button is introduced across multiple authentication screens, enabling users to reset and abandon the current account path without requiring a page refresh.

Changes

Cohort / File(s) Summary
Session State Persistence & Multi-Account Flow
connect/src/components/views/ConnectionOptions.ts, connect/src/components/views/RemoteAuthentication.ts
Implements sessionStorage-based persistence for remote URL and email inputs to restore user-entered values across navigations. Adds new useDifferentAccount helper method and wires "Use Different Account" buttons across email-login, password-login, and account-creation flows to reset authentication state and clear stored sensitive data.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit remembers the path it has taken,
Your email and URL now safely awakened,
Should you stumble mid-hop or choose a new way,
A button awaits—start fresh, come what may! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the two main changes: adding a back button on the password prompt and implementing field value persistence.
Linked Issues check ✅ Passed The changes fully address both linked issues: back button added via useDifferentAccount helper (#724), and sessionStorage persistence for remote URL and email (#726).
Out of Scope Changes check ✅ Passed All changes are directly related to the two linked issues; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/connect-login-ux

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
connect/src/components/views/ConnectionOptions.ts (1)

196-202: Consider whether remote URL should be cleared when switching accounts.

The useDifferentAccount() method in RemoteAuthentication.ts (lines 78-84) clears ad4m-connect-email from sessionStorage but does not clear ad4m-connect-remote-url. This may be intentional (user stays on the same remote node), but could also cause confusion if a user expects a complete reset.

Additionally, per context snippet 1 (web.ts:127-150), the authstatechange handler for 'unauthenticated' state doesn't clear these sessionStorage keys, which could leave stale values after token expiration.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@connect/src/components/views/ConnectionOptions.ts` around lines 196 - 202,
The sessionStorage key "ad4m-connect-remote-url" is left uncleared and can
become stale; update RemoteAuthentication.useDifferentAccount() to also remove
"ad4m-connect-remote-url" from sessionStorage (in addition to
"ad4m-connect-email"), and likewise update the authstatechange handler that
processes 'unauthenticated' in web.ts (the authstatechange callback) to clear
"ad4m-connect-remote-url" so the value set by ConnectionOptions (newRemoteUrl /
sessionStorage.setItem("ad4m-connect-remote-url", ...)) is not retained after
switching accounts or when the auth state becomes unauthenticated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@connect/src/components/views/RemoteAuthentication.ts`:
- Around line 78-84: The method useDifferentAccount currently mutates the child
`@property` remoteAuthState directly; instead dispatch a custom event (e.g.,
"reset-remote-auth") from useDifferentAccount to notify the parent (web.ts) to
set its `@state` remoteAuthState = null, then locally clear password,
emailSecurityCode, email and sessionStorage as you already do; update web.ts to
listen for the "reset-remote-auth" event and set remoteAuthState = null (and
stop relying on the child to mutate the prop).

---

Nitpick comments:
In `@connect/src/components/views/ConnectionOptions.ts`:
- Around line 196-202: The sessionStorage key "ad4m-connect-remote-url" is left
uncleared and can become stale; update
RemoteAuthentication.useDifferentAccount() to also remove
"ad4m-connect-remote-url" from sessionStorage (in addition to
"ad4m-connect-email"), and likewise update the authstatechange handler that
processes 'unauthenticated' in web.ts (the authstatechange callback) to clear
"ad4m-connect-remote-url" so the value set by ConnectionOptions (newRemoteUrl /
sessionStorage.setItem("ad4m-connect-remote-url", ...)) is not retained after
switching accounts or when the auth state becomes unauthenticated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 295c260e-d78d-4040-ac7c-1ad2820bd154

📥 Commits

Reviewing files that changed from the base of the PR and between 1d15ef0 and d629e1c.

📒 Files selected for processing (2)
  • connect/src/components/views/ConnectionOptions.ts
  • connect/src/components/views/RemoteAuthentication.ts

Comment on lines +78 to +84
private useDifferentAccount() {
this.remoteAuthState = null;
this.password = "";
this.emailSecurityCode = "";
this.email = "";
sessionStorage.removeItem("ad4m-connect-email");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Property mutation bypasses parent state management.

remoteAuthState is a @property passed from the parent component (web.ts, which owns it as @state). Directly setting this.remoteAuthState = null mutates the child's local property reference but does not update the parent's state, potentially causing state desynchronization.

Consider dispatching an event to the parent to reset remoteAuthState instead:

🛠️ Proposed fix
  private useDifferentAccount() {
-   this.remoteAuthState = null;
+   this.dispatchEvent(new CustomEvent("reset-auth-state", { bubbles: true, composed: true }));
    this.password = "";
    this.emailSecurityCode = "";
    this.email = "";
    sessionStorage.removeItem("ad4m-connect-email");
  }

Then handle the event in the parent (web.ts) to set remoteAuthState = null.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@connect/src/components/views/RemoteAuthentication.ts` around lines 78 - 84,
The method useDifferentAccount currently mutates the child `@property`
remoteAuthState directly; instead dispatch a custom event (e.g.,
"reset-remote-auth") from useDifferentAccount to notify the parent (web.ts) to
set its `@state` remoteAuthState = null, then locally clear password,
emailSecurityCode, email and sessionStorage as you already do; update web.ts to
listen for the "reset-remote-auth" event and set remoteAuthState = null (and
stop relying on the child to mutate the prop).

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

Labels

None yet

Projects

None yet

1 participant