Repository navigation
[backport core/1.50] FE-1585 fix(billing): refresh stale Run entitlement on app return - #15340
Closed
comfy-pr-bot wants to merge 1 commit into
Closed
comfy-pr-bot wants to merge 1 commit into
comfy-pr-bot wants to merge 1 commit into
Conversation
…5207) ## Why FE-1540 is only partially fixed by #14965. The Run surface no longer shows a paywall before billing initializes, but a successful `inactive` response remains cached when the authoritative subscription changes outside the open app—for example after returning from Stripe Portal, another tab, a delayed webhook, or a support action. `CloudRunButtonWrapper` previously refreshed on focus only when its own paused-payment recovery flow set `refreshBillingOnFocus`. A plain `Subscribe to Run` state had no focus/visibility recovery, so the user needed a manual page reload even after the server became `active`. ## AS IS ```mermaid sequenceDiagram participant FE as Open editor participant API as Billing API participant Provider as Stripe / webhook FE->>API: Fetch billing status API-->>FE: inactive Note over FE: Show Subscribe to Run Provider->>API: Subscription becomes active Note over FE,API: No pending BillingOp and no general refetch Note over FE: Cached inactive state remains until reload ``` ## TO BE ```mermaid sequenceDiagram participant User participant FE as CloudRunButtonWrapper participant Context as useBillingContext participant API as Authoritative billing API User->>FE: Return to app (focus / visible) FE->>FE: Confirm Subscribe to Run is displayed FE->>Context: fetchStatus + fetchBalance alt legacy billing rail Context->>API: Legacy billing reads else workspace billing rail Context->>API: Workspace billing reads end API-->>Context: active + current balance Context-->>FE: Reactive billing state updates Note over FE: Subscribe to Run becomes Run ``` ## Change - Revalidate status and balance when an app showing `Subscribe to Run` regains focus or becomes visible. - Route through `useBillingContext`, so the active legacy or workspace billing adapter remains authoritative. - Deduplicate overlapping `focus` and `visibilitychange` refreshes. - Preserve the existing paused-payment portal recovery behavior. - Do not add continuous polling: known new-billing checkouts retain BillingOp polling, while this is a bounded recovery trigger for changes outside that flow. ## Scope This PR does **not** infer subscription state in the frontend and does not attempt to prevent or resolve duplicate Stripe subscriptions. Provider subscription integrity remains a backend responsibility; the frontend only re-reads the server-authored state. ## Testing - `pnpm test:unit src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts` — 15 passed - `pnpm typecheck` — passed - changed-file ESLint, type-aware oxlint, and formatting checks — passed - `pnpm knip` — blocked by two existing unused devDependencies on `main` (`@storybook/addon-mcp`, `lint-staged`); this PR does not change package or knip configuration The component regression covers the observable AS IS → TO BE transition: stale `inactive`/Subscribe state, app focus, authoritative refresh, and restored Run button. No visual styling changes. Linear: FE-1540 --------- Co-authored-by: Amp <amp@ampcode.com>
comfy-pr-bot
enabled auto-merge (squash)
August 16, 2026 12:17
Contributor
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: 🕵🏻 0 passed, 0 failed📊 Browser Reports
📦 Bundle Size
⚡ Performance
|
This was referenced Aug 19, 2026
auto-merge was automatically disabled
August 27, 2026 02:13
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #15207 to
core/1.50Automatically created by backport workflow.