Automations and webhooks for the AT Protocol airglow.run

Scope-upgrade redirect discards the automation draft and shows a "Leave page?" prompt #6

Closed there-hugo.dev
Closed opened by there-hugo.dev

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.

  • returnTo only carries ?lexicon=, so after OAuth the user lands on an empty form.
  • savedRef is not set before the redirect, so the beforeunload guard (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.

Sign up or Sign in to add to the discussion.