Skip to content

feat: prefer canonical awaiting-input contract#20

Open
masnwilliams wants to merge 2 commits into
mainfrom
hypeship/canonical-awaiting-input
Open

feat: prefer canonical awaiting-input contract#20
masnwilliams wants to merge 2 commits into
mainfrom
hypeship/canonical-awaiting-input

Conversation

@masnwilliams

Copy link
Copy Markdown
Contributor

Summary

  • Adds protocol types for canonical managed-auth awaiting input: top-level fields and choices.
  • Normalizes canonical state into the existing UI rendering model, preferring canonical values when present.
  • Keeps falling back to legacy discovered_fields, pending_sso_buttons, mfa_options, and sign_in_options so old API responses keep working during the deprecation window.
  • Adds a patch changeset.

Notes

This PR is forward-compatible with the API dual-contract migration. It does not remove legacy support and it still submits through the existing legacy submit helpers until the API accepts canonical submit payloads.

Test plan

  • bun run typecheck
  • bun run build

Made with Cursor

Read top-level fields/choices from managed-auth state events and responses when
present, mapping them into the existing form rendering model. Keep falling back
to legacy discovered_fields/pending_sso_buttons/mfa_options/sign_in_options so
older API responses remain supported during the deprecation window.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
managed-auth-react-demo Ready Ready Preview, Comment Jun 25, 2026 8:35pm

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bc9b0a0. Configure here.

flow_step: ev.flow_step,
flow_type: ev.flow_type ?? base.flow_type ?? null,
fields: ev.fields ?? null,
choices: ev.choices ?? null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SSE drops stored canonical fields

High Severity

The mergeStateEvent function incorrectly sets fields and choices to null when an incoming SSE managed_auth_state event omits these properties. This differs from other fields that correctly fall back to prior state. This behavior causes normalizeManagedAuthState to lose essential data, leading to UI elements like login forms or other awaiting-input components being unexpectedly wiped or disappearing after a partial state update.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bc9b0a0. Configure here.

discovered_fields: fieldsFromCanonical(state.fields) ?? state.discovered_fields,
pending_sso_buttons: ssoButtonsFromCanonical(state.choices) ?? state.pending_sso_buttons,
mfa_options: mfaOptionsFromCanonical(state.choices) ?? state.mfa_options,
sign_in_options: signInOptionsFromCanonical(state.choices) ?? state.sign_in_options,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Empty canonical slices hide legacy

Medium Severity

The normalizeManagedAuthState function's use of ?? for canonical field preference doesn't account for *FromCanonical helpers returning empty arrays ([]). This prevents the intended fallback to populated legacy fields (like discovered_fields, pending_sso_buttons, mfa_options, sign_in_options), causing their values to be dropped instead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bc9b0a0. Configure here.

When canonical fields/choices are present, submit field_values by canonical field
ID and selected_choice_id by canonical choice ID. Continue supporting legacy
fields, SSO selectors, MFA option IDs, and sign-in option IDs when canonical data
is absent.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant