Fix skip-prime discovery state recovery - #33
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I reviewed, seems good, but ultimately not my call. removed myself from reviewer |
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.
masnwilliams
left a comment
There was a problem hiding this comment.
the root-cause fix is directionally right and the regression coverage is strong, but two deterministic state-ordering bugs remain. both targeted reproductions fail against this head. the new recovery flow also needs one transport-level reconciliation path rather than another nested timer/request state machine.
validation: 57 existing tests pass; build, typecheck, formatting, and diff checks pass.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4812aa5. Configure here.
masnwilliams
left a comment
There was a problem hiding this comment.
the latest rewrite addresses all three original blockers: manual start preserves ready state, conflicting remote updates converge, and transport recovery now has one canonical controller. i resolved those threads.
one deterministic reconnect-backoff bug remains: a pending snapshot can reopen a failed replacement stream immediately, bypassing the scheduled delay. the existing 81 tests and all build/type/format checks pass; the targeted reproduction for this overlap fails.
masnwilliams
left a comment
There was a problem hiding this comment.
re-reviewed latest head. the original blockers are fixed: ready state survives both start modes, overlapping updates converge through the shared transport, and recovery ownership is cleanly extracted. the reconnect/snapshot overlap noted in my follow-up can skip one delay, but backoff state is preserved and the behavior is bounded, so I am treating it as non-blocking. 81 tests plus build, typecheck, formatting, and diff checks pass.

Summary
Preserve already-ready login fields in the React SDK and recover from missing or overlapping state updates without waiting for the event stream to disconnect.
appearance.layout.skipPrimeStep=true.skipPrimeStep=false; Keep a ready login form when the prime step is dismissed #34 itself is unchanged by this branch.Expected behavior
skipPrimeStep=trueskips the initial consent/start screen.falseshows that screen until the user clicks continue. Both paths preserve readiness already fetched by the SDK. If the initial snapshot still says discovering and readiness occurs before the stream connects, the silent-discovery refresh recovers it.Setting
skipPrimeStep=falseavoids the original automatic-start reset, but is not a universal workaround: the separate continue-path reset is fixed by #34.Recovery and scope
Affected released code
Prior package inspection found the initial-state overwrite in 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2, and 0.5.3. The first three use polling, which normally corrects the reset; the prolonged event-stream stall is established as a code risk for the checked 0.4.x and 0.5.x releases. This is not evidence of observed impact in every version.
Validation
bun test: 81 passed, 0 failed at5954737, including combined Keep a ready login form when the prime step is dismissed #34 coverage, newer and older overlapping snapshots, repeated conflicts, transient recovery failures, coalesced reconnects, active submissions, session changes, expiry, and cleanup.bun run build,bun run typecheck,bun run format:check, andgit diff --check: passed.4812aa5on September 16, 2026, exercising the rewritten transport in bothskipPrimeStep=trueandfalsemodes. In both cases the backend was already awaiting OTP input before opening the hosted UI. The automatic path showed the field; the manual path showed Continue and then allowed OTP submission. Both reached UI and backend success without a manual refresh.5954737have automated regression coverage and full validation above; the live OTP tests were not repeated after those two fixes.Release status
Open for review; not merged or published.
bun run lintremains unsupported because no workspace package defines a lint script.Note
Medium Risk
Changes client-side auth session state machine and timing around SSE, snapshots, and submissions; mistakes could cause stuck spinners, wrong UI, or missed expiry, but scope is limited to the React SDK with heavy test coverage.
Overview
Refactors managed-auth session sync into a new
createSessionTransportlayer that owns the event stream, timed discovery snapshots, reconnect backoff, and GET reconciliation—withretrieveManagedAuthnow accepting anAbortSignalso stale reads can be cancelled.useManagedAuthSessiondelegates streaming/recovery to that transport instead of inline reconnect logic.startFlowsets UI from the latest server state (so a form already atAWAITING_INPUTstays visible after the prime/consent step) and no longer forcesdiscovering. Stale-interaction submits go throughtransport.resync(); submissions abort in-flight snapshot work so UI is not rolled back mid-submit.Discovery still silently re-fetches after 15s while discovering; overlapping live SSE events vs snapshots trigger another read with backoff instead of applying an older GET over newer UI. Extensive discovery/recovery tests were added.
Reviewed by Cursor Bugbot for commit 5954737. Bugbot is set up for automated code reviews on this repo. Configure here.