Files
huihui-crypto add7f1ef98 feat(studio): after a paid-path sign-in, open the plans dialog directly (stacked on #1187 + #1194) (#1197)
* 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>

* feat(studio): send signed-in upgrade clicks straight to the plans dialog

A signed-in account that clicks header Pricing, the Black Friday banner, the
Explore Black Friday hero, the model hub promo or the upgrade modal now opens
the console plans dialog (/dashboard?billing=plan) instead of public Pricing,
where it had to pick a plan and press subscribe again before reaching the same
dialog. The link keeps the same od_entry_* and utm fields, so attribution is
unchanged. Browser cloud mode goes through /auth/upgrade-handoff bound to the
expected account; desktop and handoff-disabled builds open the console
directly. Guests, dev auth mode and an unknown account keep public Pricing.

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

* feat(studio): open the plans dialog when a guest signs in from an upgrade surface

A guest who signs in from a paid path (blocked generation, Agent media gate,
header Pricing, Black Friday banner/hero/hub) and comes back on Free or Go
now goes straight to the OpenDesign plans dialog (/dashboard?billing=plan)
with the original od_entry_id, utm_source and interval=monthly, instead of
reopening the in-app upgrade modal. The modal stays as the fallback when the
dialog cannot open (popup blocked inside an iframe). Plain sign-ins and paid
plans still show nothing. New event upgrade_resume_open measures it.

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

* fix(studio): report an unsupported plans dialog as unavailable, not popup_blocked

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

* fix(studio): fall back to the upgrade modal when the desktop browser cannot open; allow upgrade_resume_open in cloud tracking

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

* fix(studio): report whether an external page actually opened so the resume can fall back

openExternalUrl now resolves false when neither the desktop host nor the
browser opened the page, and openBillingAndRefreshOnFocus returns that as
opened; the sign-in resume shows the in-app upgrade modal in that case.

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

* fix(studio): open the browser fallback without window features so a successful open is detected

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

* feat(studio): open the plans dialog from model hub View plans and report destination on upgrade clicks

- Model hub availability "View plans": a signed-in (non-dev) account now opens the
  console plans dialog directly (utm_medium=model_hub_plans) instead of Settings ›
  Subscription first. Guests still go to sign-in.
- Every upgrade click reports destination=amr_plans|landing_pricing, derived from the
  address it opens: header Pricing, Black Friday banner/hero/hub pill, MAGI-2 modal,
  upgrade modal, settings subscription links, empty-catalog Upgrade to Plus.

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

* fix(studio): clear the upgrade intent on every plain sign-in and mark checkout only after the plans dialog opens

Plain sign-in starts (header menu, template use, assets, history, session recovery) now build the login
address with plainSignInUrl, which forgets an upgrade intent saved by an earlier upgrade click; a guard
test keeps buildLoginUrl to upgrade surfaces that save their intent. The resumed upgrade sets the
checkout-return marker only when the plans dialog actually opened, so a blocked or unavailable open no
longer reports a checkout refresh on the next focus.

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

* refactor(studio): build every console plans address with one shared builder

campaignPlansHref, campaignPricingHref, buildSubscriptionUrl and the Magi2
modal now share consolePlansUrl / upgradeHandoffHref / consolePlansHref, so the
/auth/upgrade-handoff contract and the console path normalization live in one
place. A consoleUrl ending in /dashboard no longer becomes /dashboard/dashboard,
and a missing consoleUrl falls back to /cloud/dashboard.

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

* fix(studio): keep configured console bases as given when building the plans address

Only the bare production host falls back to /cloud/dashboard; a configured
console such as https://console.example.test keeps /dashboard, as before.

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

* fix(studio): mark the model hub checkout return only after the plans page opened

A blocked window no longer leaves a pending checkout that reports a false
entitlement_refresh_result on the next focus.

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

* test(cloud): raise the allowlist budget to 47 for upgrade_resume_open

main's OpenGame Stage 1 (#1198) filled the 46-event budget; this PR adds
upgrade_resume_open, so the budget moves to 47.

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>
Co-authored-by: zhanghuihua <zhanghuihua@Mac.lan>
2026-12-01 20:57:06 +08:00
..