Skip to content

feat(workshop): credits gate opens the universal Stripe checkout - #17452

Closed
comfydesigner wants to merge 8 commits into
comfydesigner/workshop-account-menufrom
comfydesigner/workshop-stripe-checkout
Closed

comfydesigner wants to merge 8 commits into
comfydesigner/workshop-account-menufrom
comfydesigner/workshop-stripe-checkout

Conversation

@comfydesigner

@comfydesigner comfydesigner commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The same credits gate as #17400, with Add credits opening the universal Stripe checkout instead of linking platform billing. Stacked on comfydesigner/workshop-add-credits-ui.

The flow

  1. The gate's Add credits opens Mar's DES-1013 amount step, returned from the parked prototype (prototype(workshop): the top-up journey after Stripe — reference, not for merge #17039) and stripped of its mocks: four packs ($10/$25/$50/$100) with their credit conversions, a clamped custom stepper ($5–$10,000, the cloud app's own bounds), Cancel, and Continue. The dialog never names Stripe — the leave marker on Continue carries "you are leaving."
  2. Continue POSTs /api/billing/topup/checkout on the session's own Cloud (Bearer session token, { amount_cents, return_url }) and opens the returned hosted Checkout session in a tab claimed synchronously inside the click, so popup blockers stay quiet and the model page keeps its inputs.
  3. return_url stays on Cloud (/?settings=plan-credits) — ingest's return allowlist covers Cloud's own hosts only today. The model page re-reads its balance on refocus.
  4. Per Hunter's thread, topup_checkout_enabled is now rolled out 100% in staging (0% prod). If a caller still 404s — prod, or an environment the flag hasn't reached — the tab carries the platform rail from feat(workshop): credits gate on the real balance, destination unwired #17400 instead, mirroring platform#1019. Other errors keep the dialog open with an inline retry line.

Testing note

Our workshop-test preview talks to test Cloud; Hunter's rollout note says staging. If test Cloud doesn't resolve the flag you'll see the (working) platform fallback rather than Stripe — one line to Hunter settles whether test is covered, or we flip this PR to the workshop label.

Rail decision platform-link vs checkout is Luke's per the Slack thread — this PR exists so both are testable.

Tests: pack selection and stepper clamping; the checkout call carries the token, picked amount and Cloud return address and navigates the claimed tab; the dark-rollout 404 lands on the platform rail; a real error keeps the dialog open with retry. 57 passing across the touched suites.

Base: comfydesigner/workshop-add-credits-ui — merge #17400 first.

@comfydesigner comfydesigner added cursor-review Trigger multi-model Cursor agent review on this PR workshop-test Enable this PR/build to run in the TEST environment. labels Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 545e24c1-aed9-4dbd-b5ef-870d792227bb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🌐 Website E2E

Caution

Some tests failed.

Status ❌ Failed
Report View Report
Screenshot diffs 0
Other failures 1

Warning

1 non-screenshot failure — these require manual review.

📦 Bundle Size

⏳ Size data collection in progress…

🔗 Website Preview

Website Preview: https://comfy-website-preview-pr-17452.vercel.app

Includes the unreleased Workshop feature (workshop-test label), signed in against test Cloud.

This commit: https://website-frontend-6mimh8u77-comfyui.vercel.app

Last updated: 2026-09-11T23:53:15Z for 24d7629

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 11, 2026
@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.13043% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/website/src/config/workshop-credits.ts 14.28% 12 Missing ⚠️
...bsite/src/components/workshop/BuyCreditsDialog.vue 89.39% 4 Missing and 3 partials ⚠️
apps/website/src/lib/workshop/buy-credits.ts 82.35% 1 Missing and 2 partials ⚠️
...ps/website/src/components/workshop/ModelDetail.vue 75.00% 0 Missing and 1 partial ⚠️
apps/website/src/config/credits.ts 85.71% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (79.13%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

@@                           Coverage Diff                           @@
##           comfydesigner/workshop-account-menu   #17452      +/-   ##
=======================================================================
+ Coverage                                82.49%   82.51%   +0.01%     
=======================================================================
  Files                                     2694     2696       +2     
  Lines                                   135626   135735     +109     
  Branches                                 35555    35574      +19     
=======================================================================
+ Hits                                    111886   111996     +110     
+ Misses                                   22814    22806       -8     
- Partials                                   926      933       +7     
Flag Coverage Δ
website-unit 72.69% <79.13%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../website/src/components/workshop/HeaderAccount.vue 91.04% <100.00%> (+0.06%) ⬆️
...ps/website/src/components/workshop/ModelDetail.vue 90.14% <75.00%> (-0.45%) ⬇️
apps/website/src/config/credits.ts 85.71% <85.71%> (ø)
apps/website/src/lib/workshop/buy-credits.ts 86.36% <82.35%> (-13.64%) ⬇️
...bsite/src/components/workshop/BuyCreditsDialog.vue 89.39% <89.39%> (ø)
apps/website/src/config/workshop-credits.ts 73.58% <14.28%> (-21.29%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Cursor Review — Consolidated panel

Triggered by @comfydesigner.

Found 10 finding(s).

Severity Count
🟠 High 2
🟡 Medium 4
🟢 Low 4

Panel: 8/8 reviewers contributed findings.

}
}

const zTopUpCheckout = z.object({ checkout_url: z.string().url() })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — z.string().url() on zod 3 only checks that new URL() parses, so javascript: and data: values pass validation. The parsed string is then handed to tab.location.assign() on an about:blank popup that inherits this page's origin, and to window.location.assign() when the popup is blocked, so a hostile or malfunctioning response body becomes script execution in the site's own origin. Refine the schema to require protocol === 'https:' and ideally an expected checkout host.

Raised by 7 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, gemini-3.1-pro adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).

const tab = window.open('about:blank', '_blank')
try {
const url = await createTopUpCheckout(
forWorkspace.token,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — forWorkspace.token is a cached snapshot, and workshop-session-state.ts states that a caller needing a token must await ensureFresh() immediately before use — which run() and the balance reader both honour. A page left open past the JWT's expiry sends a stale token and gets a 401, which is not the 404 the fallback keys on, so the buyer lands in the permanent failed state and re-clicking resends the same expired token. Refresh the credential at click time, and re-check that the uid/workspace still match forWorkspace after the await so a mid-flight workspace switch can't credit the wrong wallet.

Raised by 4 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

token: string,
amountCents: number
): Promise<string> {
const response = await fetch(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — This fetch has no timeout and accepts no AbortSignal, unlike its siblings (the balance read uses AbortSignal.timeout(BALANCE_TIMEOUT_MS), workshop-router.ts aborts on RUN_TIMEOUT_MS). If Cloud stalls, checkout stays 'pending' forever: the Add-credits button is permanently disabled, the blank popup dangles, no error is surfaced, and a page reload is the only recovery. Bound the request and accept a caller signal, which also lets the component cancel on unmount instead of letting a late resolution call window.location.assign() after teardown.

Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, gemini-3.1-pro adversarial, kimi-k3-max adversarial).

if (checkout.value === 'pending' || !session.value) return
const forWorkspace = session.value
checkout.value = 'pending'
const tab = window.open('about:blank', '_blank')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — window.open('about:blank', '_blank') drops the rel="noopener" the replaced anchor carried, so the tab keeps a live window.opener handle after it is navigated to Stripe or the platform rail, letting that document redirect this page (reverse tabnabbing). Passing 'noopener' in the features argument would return null and defeat the pre-await open, so set tab.opener = null while the tab is still about:blank — the handle stays usable for location.assign.

Raised by 7 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, gemini-3.1-pro adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).

)
checkout.value = 'idle'
if (tab) tab.location.assign(url)
else window.location.assign(url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — When the popup is blocked — a common default for a programmatic window.open — this navigates the buyer's current tab away, which the previous target="_blank" link never did. The form snapshot only persists primitives, so selected files and uploaded-URL objects in the playground are lost, and the configured return_url comes back to the cloud credits page rather than this model. Consider surfacing a link for the user to click instead of auto-navigating the page.

Raised by 3 of 8 reviewers (gemini-3.1-pro edge-case, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial).

if (tab) tab.location.assign(url)
else window.location.assign(url)
} catch (error) {
if (error instanceof TopUpCheckoutError && error.status === 404) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — The dark-rollout fallback fires only on a parsed 404, so any transport-level failure against the same unreleased route — a 404 served without CORS headers (which surfaces as a TypeError, not a status), a network blip, a proxy/DNS error — skips it and shows "Checkout could not start" even though the working platform rail is available; with the flag dark for every user today that is the common path. The inverse also holds: a genuine outage or misrouted path on a released endpoint is indistinguishable from dark rollout, so at minimum report the fallback rather than silently taking it.

Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).

if (error instanceof TopUpCheckoutError && error.status === 404) {
checkout.value = 'idle'
const fallback = platformTopUpHref(forWorkspace.workspace.id)
if (tab) tab.location.assign(fallback)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Low — tab.location.assign(fallback) runs inside the catch with no guard of its own, so if the buyer closed the blank tab during the await, touching the detached handle throws and the rejection escapes startTopUpCheckout unhandled — and checkout was already reset to 'idle' on the line above, so nothing is shown either. window.open on line 185 sits outside the try for the same class of reason: if it throws (sandboxed or restrictive embedding), checkout stays 'pending' for the life of the page.

Raised by 3 of 8 reviewers (claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, kimi-k3-max edge-case).

return
}
tab?.close()
checkout.value = 'failed'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Low — checkout is only reset by a subsequent click, and nothing clears it when the session, workspace, or gate changes. After one failed attempt the buyer can top up elsewhere, and when they later re-enter the noCredits branch it renders with "Checkout could not start. Try again." already showing, before they have clicked anything.

Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).


await vi.waitFor(() =>
expect(tab.location.assign).toHaveBeenCalledWith(
platformTopUpHref('workspace-1')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Low — This assertion cannot catch the wrong-workspace regression it appears to cover: the test never stubs PUBLIC_WORKSHOP_CLOUD_ENV, so platformTopUpHref returns WORKSHOP_CREDITS_URL and ignores its argument entirely — it passes just as well if the component forwards undefined or another workspace's id. Stub the prod env as buy-credits.test.ts does, or assert against a literal URL containing workspace=workspace-1.

Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

: 'workshop.error.noCreditsCloud',
locale
).replace('{workspace}', () => session?.workspace.name ?? '')
t('workshop.error.noCreditsCheckout', locale).replace(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Low — The gate copy now unconditionally promises Stripe ("Add credits to {workspace} through Stripe checkout"), but while topup_checkout_enabled is dark — every user until rollout — the button actually lands on platform billing or the cloud credits page. The replaced code selected its wording from TOP_UP_ON_PLATFORM so the text matched the destination; consider keeping a destination-neutral string until the flag is live.

Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).

@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-add-credits-ui branch from 5f2d145 to 4e878f6 Compare September 11, 2026 19:54
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch from 7b2f14b to 8eb18cd Compare September 11, 2026 19:55
@comfydesigner
comfydesigner changed the base branch from comfydesigner/workshop-add-credits-ui to comfydesigner/workshop-account-menu September 11, 2026 21:20
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch from 132cffb to 42396cc Compare September 11, 2026 21:22
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-account-menu branch from c752976 to 6bcdc6d Compare September 11, 2026 21:34
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch from 42396cc to 4c079e8 Compare September 11, 2026 21:34
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-account-menu branch from 6bcdc6d to 26df6cc Compare September 11, 2026 21:43
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch 2 times, most recently from 142b6c3 to e58ced6 Compare September 11, 2026 22:17
@comfydesigner
comfydesigner marked this pull request as ready for review September 11, 2026 22:56
@comfydesigner comfydesigner added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Sep 11, 2026
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch from e85cacb to b4bd578 Compare September 11, 2026 23:09

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Cursor Review — Consolidated panel

Triggered by @comfydesigner.

Round 2 — ledger: 10 prior finding(s) across 1 round(s) (10 never answered).

Found 10 finding(s).

Severity Count
🟠 High 7
🟡 Medium 3

Panel: 8/8 reviewers contributed findings.

}

const zTopUpCheckout = z.object({
checkout_url: z.string().url(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — z.string().url() on zod 3 only requires that new URL() parse, so javascript: and data: values validate. The parsed string is then handed to tab.location.assign() on a popup sitting on the same-origin /checkout-opening, to window.location.assign() when the popup is blocked, and to the reopen anchor's :href, so a hostile or malfunctioning response body becomes script execution in this site's own origin. Refine the schema to require protocol === 'https:' and ideally an expected checkout host; raised in round 1 and never answered.

Raised by 8 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, kimi-k3-max adversarial, kimi-k3-max edge-case).

const tab = window.open('/checkout-opening', '_blank')
try {
const checkout = await createTopUpCheckout(
forWorkspace.token,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — forWorkspace.token is a cached snapshot, and workshop-session-state.ts requires a caller needing a token to await ensureFresh() immediately before use (as run() and the balance reader do). A page left open past the JWT's expiry POSTs a stale token and gets a 401 — which matches neither the 404 nor the 400 branch — so the buyer lands in the permanent failed state and re-clicking resends the same expired token. Refresh the credential at click time and re-check that uid/workspace still match forWorkspace after the await so a mid-flight switch cannot credit the wrong wallet; raised in round 1 and never answered.

Raised by 8 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, kimi-k3-max adversarial, kimi-k3-max edge-case).

if (typeof window === 'undefined') return
clearTopUpWatch()
const previousCredits =
balance.value.status === 'ok' ? balance.value.credits : 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — previousCredits silently falls back to 0 whenever the balance is not ok, and canTopUp in HeaderAccount.vue gates on role alone, so a buyer whose balance read is still unknown or errored arms the watch with a zero baseline: the first successful poll reports their entire existing balance as "credits added", auto-closes that fabricated receipt after 3.6s, and clears the watch so the real grant is never observed. The watch is also bound to no uid or workspace while balance follows the live session, so a mid-poll workspace switch can satisfy credits > previousCredits for another wallet. Require an ok baseline before arming, and key the watch to the identity it started from.

Raised by 8 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, kimi-k3-max adversarial, kimi-k3-max edge-case).

topUpWatch.value = { status: 'landed', previousCredits, newCredits }
return
}
if (ticks > TOP_UP_POLL_LIMIT) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — The 24-tick × 5s budget starts when the checkout session is created rather than when payment completes, so an ordinary buyer still entering card details or clearing a 3DS challenge is moved to unresolved — whose card asserts "Payment received … You will not be charged again", equally false for a cancelled or declined checkout, and reached after the platform-rail fallback where no Stripe session exists at all. The interval is cleared at that point, so a grant that lands at t=3min is never observed. Gate the claim on an actual completion signal and measure patience from the return rather than from session creation.

Raised by 4 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

// A checkout opened with window.open returns here when it finishes; the
// tab may close itself and hand focus back. Everywhere else close() is
// silently refused and the page reads as the ordinary landing it is.
if (window.opener) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — Closing the tab whenever an opener exists means a buyer whose card was declined never sees the failure page or a retry path, and nothing tells the opener that payment failed: the dialog keeps polling and ~2 minutes later renders "Payment received — your payment went through … You will not be charged again" for a charge that does not exist, inviting a support ticket. Signal the failure back to the opener (postMessage/BroadcastChannel) so the watch is cleared and the amount card restored, instead of treating the failure return like the success return.

Raised by 5 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max adversarial).

} catch (error) {
if (error instanceof TopUpCheckoutError && error.status === 404) {
state.value = 'amount'
open.value = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — This branch dismisses the dialog and then arms watchForTopUp(), so on the dark-rollout path — the default for every caller today — the buyer gets no waiting card and no receipt, and finish() never runs to clear the watch. Since step prefers any non-idle topUp.status and the watch(open) handler on line 59 resets only usd/state, the amount picker is unreachable for ~2 minutes and a stale receipt greets the next Add-credits click; the same holds for dismissing via the X, Escape, or the overlay. (state.value = 'amount' is also assigned twice here, lines 141 and 144.)

Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max edge-case).

<dd
class="flex items-center gap-1.5 font-bold text-primary-warm-white tabular-nums"
>
<Coins class="size-4" aria-hidden="true" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 High — Coins is rendered in the landed receipt's new-balance row but is missing from the @​lucide/vue import on line 2 (Check, Clock, ExternalLink, Loader2, Minus, Plus), and this app registers no global components — so template type-checking fails on the unknown name and at runtime the row renders an unresolved element with a resolve warning. The new test exercises this card but only asserts the ledger's textContent, so it masks the break.

Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case, kimi-k3-max edge-case).

if (state.value === 'pending' || !session.value) return
const forWorkspace = session.value
state.value = 'pending'
const tab = window.open('/checkout-opening', '_blank')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — The tab is opened without noopener and then navigated cross-origin to checkout.url, so that document keeps a live window.opener handle and can redirect this page (reverse tabnabbing). Passing 'noopener' in the features argument would return null and defeat the pre-await open, but the placeholder is same-origin, so tab.opener = null works here and keeps the handle usable for location.assign — note that severing it also disables the window.opener-dependent self-close added to the return pages, so that signal needs another mechanism (a marker on the return URL, or BroadcastChannel). Raised in round 1 and never answered.

Raised by 7 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).

amountCents: number,
returnUrl: string
): Promise<TopUpCheckoutSession> {
const response = await fetch(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — This fetch has no timeout and accepts no AbortSignal, unlike the sibling balance read (AbortSignal.timeout(BALANCE_TIMEOUT_MS)). If Cloud stalls, state stays 'pending' indefinitely: both Continue and Cancel are disabled on that state, the hand-off tab dangles on /checkout-opening, no error is surfaced, and only a reload recovers. Bounding the request and accepting a caller signal would also stop a late resolution from calling window.location.assign() after the dialog is gone; raised in round 1 and never answered.

Raised by 7 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).

if (tab) tab.location.assign(checkout.url)
else window.location.assign(checkout.url)
} catch (error) {
if (error instanceof TopUpCheckoutError && error.status === 404) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium — The fallback fires only on a parsed TopUpCheckoutError with status 404, so transport-level failures against the same unreleased route skip it — a 404 served without CORS headers surfaces as a TypeError, as do DNS, proxy and offline errors — and the buyer sees "Checkout could not start" even though the platform rail works; with the flag dark for everyone that is the common path. The converse also holds: a genuine outage on a released endpoint is indistinguishable from dark rollout, so the fallback should at least be reported rather than taken silently.

Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, kimi-k3-max adversarial, gpt-5.6-sol-max edge-case).

Hunter's POST /api/billing/topup/checkout on the session's Cloud creates
a hosted Stripe Checkout session; Add credits opens it in a tab that is
claimed inside the click so the popup blocker stays quiet. The endpoint
ships dark behind topup_checkout_enabled - a 404 means the flag has not
reached this caller, and the button falls back to the platform rail
instead of erroring. The return address stays on Cloud, the only host in
ingest's return allowlist today; the model page re-reads its balance on
refocus. Copy names Stripe as the destination.
The DES-1013 amount step returns from the parked prototype, stripped of
its mocks: four packs with their credit conversions, a clamped custom
stepper, Cancel, and Continue carrying the leave marker - the dialog
never names Stripe, the arrow says you are leaving. Continue creates
the hosted checkout session for the picked amount in a tab claimed
inside the click; the dark-rollout 404 still falls back to the platform
rail. The gate note goes destination-neutral since the dialog now owns
the hand-off. Packs and bounds mirror the cloud app's own numbers.
Re-stacked on the account-menu branch so the checkout rail rides Mar's
menu. Her checkout-rail variant of the credits row arrives with it: the
row opens the amount dialog instead of linking out, and the dialog owns
the hand-off from there - same flow the gate uses.
…looking

Two seams around the Stripe hand-off. The return address becomes this
site's own /models/checkout-complete, a page that hands focus back and
closes the tab it came in on - ingest's return allowlist admits only
Cloud today, so a 400 falls back to Cloud's credits page until this
origin joins the list. And since Stripe grants the credits through its
webhook seconds after payment, the single refocus read usually raced
the grant and lost; a checkout hand-off now starts a two-minute poll
that stops the moment the balance moves.
Mar's 4a/4b/4c cards arrive on real rails. The hand-off leaves the
dialog open on 4a - closing is safe and says so - while the top-up
watch, now reactive, keeps re-reading the balance. The moment it moves,
4b shows the receipt: the real delta and the previous/added/new ledger,
auto-closing after 3.6 seconds only while the tab is watched and never
mid-interaction. If two minutes pass with nothing, 4c holds, grey by
design, naming the Stripe session id as the support handle beside a
real Contact support link.

Around the hand-off itself: the claimed tab opens on a gate-injected
/checkout-opening interstitial instead of about:blank, and the return
address becomes the existing /payment/success page, which now hands
focus back and closes itself when a checkout opened it and stays the
ordinary thank-you page everywhere else. The bespoke checkout-complete
page goes - it was never a routable page on this tree anyway.
… flag

Alex's preview report: every checkout suddenly landed on testcloud. The
self-origin return attempt assumed a rejected return host answers 400,
but ingest can answer 404 - indistinguishable from the dark feature
flag, so the platform fallback swallowed the whole rail. The Cloud
retry now covers both statuses; only a second 404 means the flag is
genuinely dark.
Alex's preview report: the receipt sometimes appeared the moment the
dialog opened, carrying another workspace's numbers. The watch captured
its baseline in one workspace and compared it against whichever balance
was live by the next tick; it now records the workspace it was started
for, ignores every other, and retires itself on a switch. And a landed
receipt nobody acknowledged within a minute is treated as read off the
chip - greeting the next visit with it looked like a fresh grant.
…states

Alex's preview report: waiting blinked to the amount card for a beat on
its way to the receipt. Two causes closed: the watch's workspace guard
treated a snapshot mid-remint - which has no session for a moment - as
a switch and killed the checkout in flight; it now only retires on a
definitely different workspace. And the dialog latches its return-flow
step, so even a transient idle from the watch cannot surface the amount
card between waiting and landed.
@comfydesigner
comfydesigner force-pushed the comfydesigner/workshop-stripe-checkout branch from b4bd578 to 24d7629 Compare September 11, 2026 23:51
benjcooley added a commit that referenced this pull request Sep 13, 2026
## Summary

Combines the reviewed Models catalogue and account/checkout work from
Alex Tov and Mar on top of the performance fixes already merged in
#17604.

- carries Mar's current production UX passes from #17569 and #17582,
plus the production port of her catalogue design in #17379
- adds Alex's catalogue sizing, variant labels, provider documentation
links, account/workspace menu, real credit gate, and Stripe checkout
flow
- resolves the cumulative review findings across the source PRs,
including session and credit race handling, checkout URL validation,
paid-run navigation protection, mobile sheet behavior, featured
ordering, and catalogue regressions
- keeps the retired `/workshop` routes out of builds and uses `/models`
as the released surface

## Source PRs

This PR supersedes #17379, #17381, #17387, #17394, #17408, #17452,
#17569, and #17582. It also includes the applicable substrate from
closed #17400.

The branch preserves the original source commits and authors: 33 commits
by @comfydesigner and 20 commits by @mariana953, followed by one
cumulative review-fix commit.

## Verification

- repository pre-commit pipeline: lint, root typecheck, and website
typecheck pass
- website typecheck: 0 errors
- focused Models/account/checkout regression tests: 198 passing
- Models Playwright suite: 19/19 desktop and 1/1 mobile
- feature-enabled static build: passes and emits the Models catalogue;
retired Workshop pages are removed
- feature-disabled static build: passes with no Models catalogue on the
regular homepage
- three independent adversarial review passes completed; no code
findings remain

The complete website unit run reached 4,587 passing tests. Its sole
failure was the existing load-sensitive `VideoMaskScene` timer test,
which passed immediately in isolation (5/5); CI is the final clean-room
run.

## External preview dependency

The frontend checkout flow is complete, but Cloud non-production
currently rejects the actual preview hostname format
(`comfy-website-preview-pr-<number>.vercel.app`) in
`TOPUP_CHECKOUT_RETURN_HOSTS`. Cloud must add that exact bounded
preview-host pattern before Stripe return can be exercised from a Vercel
preview. This does not require a broader `*.vercel.app` allowlist.

---------

Co-authored-by: Mariana Martinho <mariana@comfy.org>
Co-authored-by: comfydesigner <alextov@comfy.org>
@benjcooley

Copy link
Copy Markdown
Collaborator

Superseded by #17614, which combined this reviewed work with the rest of the Alex Tov and Mar Models stack and has now merged to main. The remaining post-merge review repairs are tracked in #17616.

@benjcooley benjcooley closed this Sep 13, 2026
benjcooley added a commit that referenced this pull request Sep 15, 2026
## Summary

Restore the intended top-up checkout handoff and return behavior from
#17452 while retaining the merged workspace, idempotency, abort, and
checkout URL validation safeguards.

## Changes

- **What**: Auto-close untouched visible receipts after 3.6 seconds;
claim a contextual `/checkout-opening` tab; return Stripe to
`/payment/success`, with a one-shot Cloud return retry on 400/404; close
and refocus checkout return tabs; remove obsolete model-page attempt
signaling.

## Review Focus

Confirm that the claimed checkout tab intentionally retains
`window.opener` so the same-origin payment return can refocus the
original page and close itself. Popup-blocked and direct landings still
render the normal payment result page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor agent review on this PR risk:high PR risk grade (advisory shadow check; grader-owned) workshop-test Enable this PR/build to run in the TEST environment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants