Problem #
When a create or update returns SCOPE_INSUFFICIENT, app/islands/AutomationForm.tsx:1299-1301 calls redirectToScopeUpgrade (lib/auth/scope-errors.ts) with a bare location.href. Nothing in the form is persisted first.
returnToonly carries?lexicon=, so after OAuth the user lands on an empty form.savedRefis not set before the redirect, so thebeforeunloadguard (AutomationForm.tsx:652-660) shows a "Leave page?" prompt in the middle of a create. Staying doesn't help; leaving loses the draft.- The login page gives no context for why the user was sent there (
app/routes/auth/login.tsx:62-63).
Seen in the session #
Twice in https://www.youtube.com/watch?v=5MnT-ZgbBIc:
- 0:44:40 to 0:46:00: the whole form is wiped and rebuilt by hand.
- 1:31:00: "It's going to delete all my work."
#5 makes this fire on the first record-writing create after every sign-in.
Fix direction #
- Save the draft (sessionStorage or a server-side draft) before redirecting, and restore it on return.
- Set
savedRef(or otherwise bypass the guard) before the intentional navigation. - Show a short explanation on the login page when it was reached through a scope upgrade.
Details: docs/brainstorms/2026-10-17-graze-conference-automation-feedback.md (B2).
Fixed in f13d049: the form draft is kept across the scope upgrade.