Skip to content

Keep a ready login form when the prime step is dismissed - #34

Closed
ehfeng wants to merge 2 commits into
mainfrom
hypeship/fix-prime-ready-state
Closed

ehfeng wants to merge 2 commits into
mainfrom
hypeship/fix-prime-ready-state

Conversation

@ehfeng

@ehfeng ehfeng commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

startFlow hardcoded the UI state to discovering, discarding the session state already fetched at init. When the backend login agent finished field discovery while the consent (prime) screen was on screen, clicking Continue replaced a ready form with a spinner that nothing ever cleared.

Now derives the UI state from the session state we hold, falling back to discovering only when nothing has been fetched. connectStream still runs unconditionally — the stream is needed for later transitions regardless of what is currently rendered.

Why nothing recovered it

  • connectStream only opens the SSE stream; it does not re-read state.
  • The backend was already at AWAITING_INPUT, so it had no further transition to publish and emitted no state event.
  • The only other path that re-reads state is resyncAndConnect, which fires solely off stream onError/onClose, so the connection had to drop first.

Result: an indefinitely frozen spinner on a session that was ready to accept input.

Scope

Affects the appearance.layout.skipPrimeStep: false path (the default), which is the only path that renders the prime screen and therefore the only one that can reach startFlow. The automatic-start path never renders that screen.

Validation

  • New regression test keeps a ready form when the prime step is dismissed — confirmed failing on main at 620f3db and passing with this change.
  • bun test: 34 pass, 0 fail (main is 33; the new test is the delta).
  • bun run build, bun run typecheck, bun run format:check, git diff --check: clean.
  • bun run lint still unsupported — no workspace package defines a lint script.

Related

#33 fixes the same bug class in the automatic-start initialization branch of the same hook. Independent: different code path, different skipPrimeStep value, no overlapping lines. Either can merge first; whichever lands second needs a trivial rebase of useManagedAuthSession.ts.


Note

Low Risk
Narrow UI-state fix on the consent-screen path; no changes to auth, submission, or stream protocol handling.

Overview
Fixes a stuck discovering spinner when users dismiss the prime/consent step after the backend has already reached AWAITING_INPUT.

startFlow in useManagedAuthSession no longer forces discovering on Continue. It sets UI from the session snapshot in stateRef via deriveUIState, using discovering only when no state exists yet. The SSE transport still starts unconditionally so later transitions keep working.

Adds regression test keeps a ready form when the prime step is dismissed for the default skipPrimeStep: false path (unrelated to the autoStart fix in #33).

Reviewed by Cursor Bugbot for commit 3bab778. Bugbot is set up for automated code reviews on this repo. Configure here.

startFlow assumed discovery was still running and forced the UI into a
loading state. When the session had already reached AWAITING_INPUT while
the consent step was on screen, that hid a ready form behind a spinner
the backend had no further transition to clear. Derive the UI state from
the session state we already hold.
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
managed-auth-react-demo Ready Ready Preview Sep 22, 2026 11:17pm UTC

@ehfeng
ehfeng requested a review from aylee855 September 16, 2026 00:07

@aylee855 aylee855 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.

this fixes the ready snapshot being replaced with a spinner when the user clicks continue. a couple of scope clarifications before merging:

  • please clarify that the fix preserves readiness already fetched by the SDK. if the initial GET returns DISCOVERING and the backend becomes ready before continue opens the stream, the cached snapshot is still discovering; this change alone does not recover that missed transition.
  • please update the related-PR section: #33 also adds recovery for silent discovery after manual start, so the fixes should be validated together, not described as behaviorally independent.

keeping this PR focused on the continue-path fix makes sense. i am addressing the shared recovery and response-ordering changes in #33, including the initial-discovering / ready-before-continue case. no need to duplicate that recovery logic here.

@ehfeng
ehfeng marked this pull request as ready for review September 16, 2026 01:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T01:28:17.998011Z 573ea07 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

# Conflicts:
#	packages/managed-auth-react/src/session/useManagedAuthSession.ts
@ehfeng

ehfeng commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

#33 landed first and already carries everything from this branch — the startFlow fix, the keeps a ready form when the prime step is dismissed test, and the changeset are all byte-identical on main (released in 0.5.4). Merging main in to resolve the conflict leaves a 0-file diff, and keeping the changeset would re-trigger a patch release for something already shipped. Closing as superseded.

@ehfeng ehfeng closed this Sep 22, 2026

This branch was successfully deployed

1 active deployment
Preview — 3bab7789 Deployed Sep 22, 2026 by vercel[bot]
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