Files
openmotion/shared/entitlement-hooks.ts
huihui-crypto 19ef57d637 feat(studio): resume the upgrade step after a guest signs in from an upgrade surface (#1187)
* feat(studio): resume the upgrade step after a guest signs in from an upgrade surface

A guest who meets an upgrade surface (blocked generation modal, Agent media
gate, header Pricing, Black Friday banner) must sign in first, and the
upgrade step was dropped once they came back signed in.

Save a short-lived upgrade intent (hook id + gate attribution, 30 min TTL)
when the guest starts signing in; when the account comes back on Free or
Go, EntitlementModalHost reopens the upgrade modal once for the same
surface with a fresh entry id. Plus and above drop it. One Tap's own
Free/Go Pricing redirect clears it to avoid a double prompt. Storage is
the source of truth across windows; the in-memory copy is used only when
the latest save could not reach storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio): resume the upgrade step only from upgrade surfaces

- Keep an upgrade intent only for upgrade surfaces (blocked generation and
  plan gates, Agent media gate, header Pricing, Black Friday entries). A plain
  guest sign-in (header/settings sign-in, template use, MCP, assets) now
  replaces any saved intent instead of reopening an upgrade modal.
- Forget the intent when sign-in is cancelled (auth_cancelled), on sign-out,
  and when the account is signed in but the plan cannot be known, so the modal
  never appears later out of context.
- Report the resumed modal with gate_reason=resumed_after_signin instead of
  plan_locked, so it is not counted as a real plan gate or a guest prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio): keep the Agent media sign-in from model settings as an upgrade surface

The Agent media gate opens /settings/models?entry_from=agent_media_*; its sign-in
guide opened the settings_signin guest modal, which no longer keeps an upgrade
intent. Open it as agent_media_gate (guest_signin) instead, and save the intent on
the direct login path too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(studio): forget the upgrade intent on a plain direct sign-in from model settings

The direct-login branch of the model-settings sign-in guide (desktop, or no
guest modal / account page) kept an earlier upgrade intent when the entry was
not an Agent media gate. Clear it there, as the other plain sign-ins do, and
cover the branch in the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: zhanghuihua <zhanghuihua@huihuideMacBook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 21:56:16 +08:00

32 lines
768 B
TypeScript

export const ENTITLEMENT_HOOK_IDS = [
'header_signin',
'settings_signin',
'template_use',
'private_link_gate',
'assets_empty',
'studio_generate',
'cloud_export',
'session_expired_401',
'header_pricing',
'bf_banner',
'bf_hero',
'bf_hub',
'settings_subscription',
'studio_free_gate',
'model_picker_upgrade',
'studio_res_gate',
'failure_card_topup',
'mcp_oauth',
'template_prep_ai_media',
'export_done_upsell',
'agent_media_gate',
] as const;
export type EntitlementHookId = (typeof ENTITLEMENT_HOOK_IDS)[number];
const ENTITLEMENT_HOOK_ID_SET: ReadonlySet<string> = new Set(ENTITLEMENT_HOOK_IDS);
export function isEntitlementHookId(value: string): value is EntitlementHookId {
return ENTITLEMENT_HOOK_ID_SET.has(value);
}