Skip to content

feat(app): UI login flow#21291

Open
TamarZanzouri wants to merge 24 commits intoedgefrom
EXEC-2163-fe-add-login-flow
Open

feat(app): UI login flow#21291
TamarZanzouri wants to merge 24 commits intoedgefrom
EXEC-2163-fe-add-login-flow

Conversation

@TamarZanzouri
Copy link
Copy Markdown
Contributor

@TamarZanzouri TamarZanzouri commented Apr 16, 2026

Overview

closes https://opentrons.atlassian.net/browse/EXEC-2163.
Adds ODD Login with a two-step flow (username → password)

Test Plan and Hands on Testing

[ ] ODD Login: enter username → password → confirm; success navigates back; bad credentials show snackbar (with dev-backend-flex or auth-server on 33950 + proxy on 31950).
[ ] Storybook: ODD → Pages → Login renders without provider errors.

Screenshot 2026-04-16 at 1 45 49 PM Screenshot 2026-04-16 at 1 46 08 PM Screenshot 2026-04-16 at 2 02 17 PM Screenshot 2026-04-16 at 2 02 28 PM Screenshot 2026-04-16 at 2 03 01 PM

Changelog

  • Login page component
  • Wire OAuth2 resource-owner password login to POST /auth/oauth2/token using the shared API client.
  • Extrat auth logic into useOAuth2PasswordLogin under app/src/resources/auth/ so ODD and future desktop flows can share the same hook.
  • added Storybook under http://{{hostname}}:6060/?path=/story/odd-pages-login--default

Review requests

am i missing anything?

Risk assessment

low. new logic.

Comment thread app/src/organisms/ODD/Navigation/index.tsx Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 0% with 171 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.50%. Comparing base (dba1e48) to head (498330c).
⚠️ Report is 17 commits behind head on edge.

Files with missing lines Patch % Lines
app/src/pages/ODD/Login/index.tsx 0.00% 132 Missing ⚠️
...src/resources/auth/hooks/useOAuth2PasswordLogin.ts 0.00% 34 Missing ⚠️
app/src/App/OnDeviceDisplayApp.tsx 0.00% 3 Missing ⚠️
app/src/resources/auth/hooks/index.ts 0.00% 1 Missing ⚠️
app/src/resources/auth/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             edge   #21291       +/-   ##
===========================================
- Coverage   57.27%   27.50%   -29.78%     
===========================================
  Files        3991     3995        +4     
  Lines      327285   328010      +725     
  Branches    46564    46507       -57     
===========================================
- Hits       187463    90211    -97252     
- Misses     139603   237780    +98177     
+ Partials      219       19      -200     
Flag Coverage Δ
app 0.88% <0.00%> (-44.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/src/resources/auth/hooks/index.ts 0.00% <0.00%> (ø)
app/src/resources/auth/index.ts 0.00% <0.00%> (ø)
app/src/App/OnDeviceDisplayApp.tsx 0.00% <0.00%> (-80.00%) ⬇️
...src/resources/auth/hooks/useOAuth2PasswordLogin.ts 0.00% <0.00%> (ø)
app/src/pages/ODD/Login/index.tsx 0.00% <0.00%> (ø)

... and 1870 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TamarZanzouri TamarZanzouri marked this pull request as ready for review April 16, 2026 19:04
@TamarZanzouri TamarZanzouri requested a review from mjhuff April 16, 2026 19:07
Copy link
Copy Markdown
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Looks good overall, but don't have time to give a more detailed review. Do you think you're going to put the reason field in here? Should this be the "access control" page rather than the "login" page?

Copy link
Copy Markdown
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Functionally LGTM, just various nitpicks.

Visually, I think there are a couple design mismatches. If those are intentional for prototyping reasons, I'm happy for this to be merged and we can come back to them later, but can we leave // todo comments for them?

Comment thread app/src/resources/auth/hooks/useOAuth2PasswordLogin.ts Outdated
Comment on lines +24 to +26
onSuccess: () => {
navigate(-1)
},
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.

Will navigate(-1) restore the state inside whatever page the user was on previously?

Like, suppose:

  1. The user is on /deck-configuration
  2. They do some work
  3. Their session times out and the "locked" overlay appears
  4. They tap the "locked" overlay, which navigates to this /login page
  5. They log in successfully, we run this navigate(-1), and return them to the /deck-configuration page
  6. But now it's as if they're visiting /deck-configuration for the first time. So all their work is gone? I think?

I haven't tested this, and the react-router-dom docs do say that -1 is "often used to close modals." But I don't see how that can work unless react-router-dom is doing something magical.

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.

using -1 isn't bad (since the component is touchscreen only and the likelihood of any issues occurring is quite low.), however, opentrons repo use it for the wizardflow basically.
so using a specific path would be easy for others.

Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment on lines +135 to +137
data-testid={
showPassword ? 'login-password-hide' : 'login-password-show'
}
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.

Nit: I don't think you need a data-testid here. The <Btn>'s aria-label and role="button" should already be enough for the tests to be able to find it without a data-testid.

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.

yes, please do not use data-testid.
data-testid should be treated as a last resort, so in principle it must not be used for unit tests. it’s only allowed as an exception for e2e.

Comment on lines +43 to +51
useEffect(() => {
if (!showKeyboard) return
const id = window.setTimeout(() => {
keyboardRef.current?.setInput(fieldValue)
}, 0)
return () => {
window.clearTimeout(id)
}
}, [showKeyboard, fieldValue, step])
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.

What's this timeout stuff for?

useEffect(() => {
setShowPassword(false)
if (step === 'password') {
inputRef.current?.focus()
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.

Nit: It'd probably be cleaner to use autoFocus instead.

navigate(-1)
},
onError: message => {
makeSnackbar(message)
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.

The designs don't use snackbars for these errors—they have dedicated error text for "wrong password," "locked out," etc. Is this intentional?

I'm totally fine with using snackbars if it makes it easier to get the demo up and running, just making sure it's intentional.

Comment on lines +102 to +104
<h4 className={styles.field_label}>
{step === 'username' ? 'Username' : 'Password'}
</h4>
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.

Are we intentionally not using StyledText for text styling?

This is a genuine question. I really don't know what the correct way of doing this is, these days.

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.

Generally speaking, using header text is good but this is an Electron app so it’s more important to align with the codebase’s implementation patterns than with general web best practices.
recommend you using StyledText and the design team uses oddStyle for text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i thought we should not use StyledText anymore?

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.

Ideally, yes but unfortunately we don't have a strategy on that change and we are not ready to change our implementation style. (+ the design team has registered desktopStyle and oddStyle on Figma)

We need to discuss whether to create a new CSS Modules–based component for the text, or to use the header text approach you suggested.
I think this transition will be expensive since for the first one we have to replace LegacyStyledText with StyledText first(some components use width/height directly so unfortunately a simple replace won't work) and for the second one, that will increase the review cost significantly.

Comment on lines +102 to +104
<h4 className={styles.field_label}>
{step === 'username' ? 'Username' : 'Password'}
</h4>
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.

Nit: Can we have i18n strings for all of this copy, unless you're intentionally deferring that to another PR?

Comment thread app/src/pages/ODD/Login/index.tsx Outdated
onFocus={() => {
setShowKeyboard(true)
}}
rightElement={
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.

Putting the show/hide icon inside the text field doesn't match the designs—it should be outside.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i know. but that is how we do it in other places in the code. i left a comment for mel

Comment thread app/src/App/OnDeviceDisplayApp.tsx Outdated
Comment thread app/src/pages/ODD/OnDeviceLoginPage/index.tsx
Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment on lines +112 to +117
const next = e.target.value
if (step === 'username') {
setUsername(next)
} else {
setPassword(next)
}
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.

As opentrons' implementation style , when a handler grows beyond two lines, it’s preferable to extract it into a dedicated function like ‎handleChange. The main reason is to keep the JSX easy to scan and read.

Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment thread app/src/pages/ODD/Login/index.tsx Outdated
step === 'password' ? (
<Btn
type="button"
aria-label={showPassword ? 'Hide password' : 'Show password'}
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.

Probably the existing component uses a conditional statement for aria-label but changing ‎aria-label conditionally isn’t inherently wrong, but in this case it’s not ideal.

The current inputfield allows us use aria-*, so the following would be better.

aria-label="Toggle password visibility"
‎aria-pressed={showPassword}

Comment thread app/src/pages/ODD/Login/index.tsx Outdated
Comment on lines +10 to +11
margin: 0 auto;
margin-top: 4.625rem;
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.

can you avoid using margin for a new component?
the design team uses Figma auto layout and it doesn't use margin.

Comment thread app/src/pages/ODD/Login/login.module.css Outdated
@@ -0,0 +1,25 @@
.nav_container {
height: 7.75rem;
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.

i guess this would be for ChildNavigation
if so, please align the styling with app/src/organisms/ODD/CameraSettings/CameraControls/cameracontrols.module.css

Comment thread app/src/pages/ODD/Login/login.module.css Outdated
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.

recommend you creating a mock instead of ApiHostProvider since Storybook is to check the look.
when our Storybook breaks, it’s often because we’re not using mocks and are instead wiring it up with the same providers and other app-level code that’s used in the real application.

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.

the fileName should be useOAuth2PasswordLogin.test.ts.
if you need to use .tsx instead of .ts, probably you will need to check the custom hook.

const detail = data?.errors?.[0]?.detail
if (detail != null && detail !== '') return detail
if (error.response?.status != null) {
return `Login failed (${error.response.status})`
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.

don't need to support i18n?

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.

can you update the test for Login?

Copy link
Copy Markdown
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Just one more thing I noticed while wiring this up to the LoggedOutOverlay.

Comment on lines +107 to +117
<ChildNavigation
header="Login"
buttonText={step === 'username' ? 'next' : 'confirm'}
buttonIsDisabled={primaryDisabled}
secondaryButtonProps={{
buttonText: 'cancel',
buttonType: 'tertiaryLowLight',
onClick: handleCancel,
}}
onClickButton={handleNext}
/>
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.

Another thing for matching the designs: there should be a back arrow up here when the user is on the password step, to return to the username step.

Comment on lines +123 to +127
<Controller
key={activeFieldName}
control={control}
name={activeFieldName}
render={({ field }) => (
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.

For my edification, what does Controller do and when should we use it?

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.

4 participants