Skip to content

feat(website): Cinematic Studio credit estimates and credit gating - #18928

Merged
benjcooley merged 6 commits into
mainfrom
bencooley/cinematic-credit-estimate
Sep 26, 2026
Merged

benjcooley merged 6 commits into
mainfrom
bencooley/cinematic-credit-estimate

Conversation

@benjcooley

Copy link
Copy Markdown
Collaborator

Summary

Cinematic Studio now shows the estimated credits for a shot before Generate, blocks a shot the balance can't cover, gives workspace members their own out-of-credits copy, and summarises takes that weren't run for lack of credits.

Changes

  • What:
    • estimateWorkshopNodePrice takes width, height and reference count; estimateWorkshopRunCredits returns a credit range. Studio prices are precomputed at build time per aspect × resolution × 0–2 references, using the frame size the Router mapping actually sends. Pricing rules don't ship to the browser.
    • "~N credits" (takes × per-take) beside Generate; "Cost varies" for models with no pricing data (Gemini 3 Pro Image, Krea 2 Large, Qwen 3.0 Pro). pricing.creditsPerRun is not used.
    • studioGate blocks when the balance is below the estimate's low end ("4 takes need ~38 credits; you have 20"), offers "Use N takes", and keeps the zero-balance gate for unpriced models. The unused runGate is removed.
    • Members see main's member copy and a switch-to-personal action (shared usePersonalWorkspaceSwitch, extracted from ModelDetail.vue).
    • Credit-failed takes get a warning state and a shot-level summary; after a top-up lands the action becomes "Run them now".
    • Router errors fall back to the body's error_type when X-Comfy-Error-Type is missing.

Review Focus

  • A Flux shot with references prices as a range and the gate uses the low end, so a balance inside the range can still partly fail; the summary covers that case.
  • Studio copy stays in lib/workshop/cinematic-studio/copy.ts (en + zh-CN) to keep it out of other pages' scripts; member copy reuses translations.ts keys.

Validation: eslint, typecheck:website, format:astro:check, knip and the full website unit suite pass; astro build succeeds.

Part of FE-2737.

…r is missing

An insufficient_credits refusal whose bucket arrives only in the JSON body
(no X-Comfy-Error-Type header, not a 402) was classified by status alone and
surfaced as a provider or validation failure instead of noCredits.
…s for

The node-pricing helper only evaluated a rule with the node's default
widgets. It now accepts the run's width, height and reference-image count,
and exposes the same price as a credit range so a caller can compare it
with a balance.
…ate on them

The studio priced nothing before a run and only stopped an empty balance,
so a four-take batch over the balance partly failed.

- Price each studio model at build time for every aspect, resolution and
  reference count, from the frame size the Router mapping sends.
- Show ~N credits (takes x per take) beside Generate, or Cost varies for a
  model without a verified price.
- Block a shot the balance does not cover with the need and the balance,
  offer the number of takes it does cover, and keep the zero-balance gate
  for unpriced models. The unused runGate is retired into studioGate.
- Give members the switch-to-personal action instead of checkout, sharing
  the switch with the model page.
…akes

- A take refused for credits now tells a workspace member what the model
  page tells them (the team is out; ask the owner or run on your personal
  workspace) and offers the switch to personal instead of checkout.
- Takes refused for credits get a yellow warning state in the sequence,
  the take picker and the frame, and a shot with several takes shows how
  many were not run with the same top-up or switch action.
- Once a top-up lands (the header's top-up watch), that action becomes a
  retry of the unpaid takes.
@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
billing-web Ignored Ignored Sep 26, 2026 12:34am UTC
billing-web-test Skipped Skipped Sep 26, 2026 12:34am UTC

Request Review

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🌐 Website E2E

Tip

All tests passed.

Status ✅ Passed
Report View Report

🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

This candidate changes nothing the matrix measures, so every expensive stage was skipped.

Reproduce locally
# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
  npx vitest run --config vitest.matrix.config.mts

Full docs: scripts/registry-census/README.md

🌾 Fallow: ✅ Passed

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

Fallow gates on new findings in changed files only, so everything below was introduced or moved by this PR (44 changed files).

Kind Finding Where Usual remedy
Complexity failureFor() — cyclomatic 15, CRAP 63.6 apps/website/src/config/workshop-router.ts:90 Extract a branch, or raise branch coverage — CRAP is CC² × (1−cov)³ + CC, so either moves it.

Pre-existing findings are baselined in .fallow-baselines/ and are not your
responsibility — see ADR-DEVEX-LINT-0015.

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since ca35810a393789af3389b4e4681ea98bba677e49

Full docs: ADR-DEVEX-LINT-0015

🔗 Website Preview

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

Models is built and gated by PostHog (workshop-enabled), using staging Cloud.

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

Last updated: 2026-09-26T00:36:28Z for 8e7111d

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 013209fd-9af2-47ec-af81-b20819a5aa11

📥 Commits

Reviewing files that changed from the base of the PR and between 335e318 and 8e7111d.

📒 Files selected for processing (2)
  • apps/website/src/components/workshop/cinematic-studio/CinematicCreditAction.vue
  • apps/website/src/components/workshop/cinematic-studio/CinematicStudio.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Cinematic Studio now estimates credit costs for supported models and uses the estimate and current balance in generation controls. The changes also add localized unpaid-take status, workspace-aware credit actions, and retries for multiple eligible takes. Shared workshop pricing and workspace-switch helpers support these flows.

Changes

Cinematic Studio credits

Layer / File(s) Summary
Workshop pricing context
apps/website/src/config/workshop-node-pricing-context*, apps/website/src/config/workshop-node-pricing*, apps/website/src/config/workshop-run*
Pricing APIs build evaluation contexts from run settings and return estimated credit ranges. The former runGate API and its tests are removed.
Cinematic model price estimates
apps/website/src/lib/workshop/cinematic-studio/estimate.ts, apps/website/src/lib/workshop/cinematic-studio/models.ts, apps/website/src/lib/workshop/cinematic-studio/pricing*, apps/website/src/routes/models/cinematic-studio.astro
The cinematic route adds per-model prices across supported shot settings. Shot estimates calculate total ranges from per-take prices and take counts.
Credit-aware generation controls
apps/website/src/lib/workshop/cinematic-studio/gate*, apps/website/src/composables/useCinematicShot.ts, apps/website/src/composables/useCinematicStudioRun.ts, apps/website/src/components/workshop/cinematic-studio/Cinematic{Composer,CostLabel,CreditAction,GateButton,GenerateAction,Panel,Studio,StudioPanel}.vue, apps/website/src/components/workshop/ModelDetail.vue, apps/website/src/composables/usePersonalWorkspaceSwitch.ts, apps/website/src/config/workshop-router*, apps/website/src/lib/workshop/cinematic-studio/copy.ts, apps/website/src/components/workshop/cinematic-studio/CinematicStudio.test.ts
Generation controls receive estimates and balances, show costs and shortfall messages, and can lower the take count to fit the balance. Router error parsing reads body error_type values when the header is absent. Workspace switching uses a shared composable.
Unpaid take status and retry
apps/website/src/lib/workshop/cinematic-studio/reel*, apps/website/src/components/workshop/cinematic-studio/Cinematic{Sequence,Stage,StageCard,TakeBar,TakeFrame,TakeNotice,CreditSummary}.vue, apps/website/src/composables/useCinematic{DemoRun,StudioRun}.ts, apps/website/src/components/workshop/cinematic-studio/CinematicStudio.test.ts
Take views identify unpaid failures and show credit actions and skipped-take summaries. Retry events carry multiple IDs, and eligible failed or cancelled takes are retried together.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CinematicStudio
  participant useCinematicShot
  participant shotEstimate
  participant useCinematicStudioRun
  participant studioGate
  participant CinematicGenerateAction
  CinematicStudio->>useCinematicShot: Read shot settings and model prices
  useCinematicShot->>shotEstimate: Calculate per-take and total credit ranges
  useCinematicShot->>useCinematicStudioRun: Supply minimum total as shotCost
  useCinematicStudioRun->>studioGate: Check credits against shot cost
  CinematicStudio->>CinematicGenerateAction: Pass estimate and current credits
Loading

Suggested reviewers: dante01yoon

Merge Risk: ⚪ Minimal · up to 8e711

No new merge-blocking risk is established by this review; the previously reported skipped-take retry concern remains a separate follow-up.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 8e711

The new controls limit retries to failed takes tracked by the studio, and rendering requests use a session-bound credential. No introduced security bypass was established. The server’s independent credit and workspace checks could not be verified, so the risk is not rated minimal.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly visible retry action reaches paid model rendering through the current studio session, rather than constructing a request or choosing credentials in the credit-action component. Server-side authorization limits cannot be established from this client path.

Trust Boundaries and Controls

  • observed — The balance and estimate govern client presentation and admission. A Router response classified as insufficient credits can still fail a take; the available client code does not prove how the server validates or charges it.

Resilience and Maintainability Implications

  • observed — Render attempts retain an idempotency key for requests that may still settle, suppress results after cancellation, and release outputs returned after an abort.

Hardening Proposals

  • proposed — Verify that the Router independently enforces workspace authorization, available credits, and idempotent charging for every original and retried render; client estimates and retry eligibility should remain advisory.

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore (reviewers only)

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Website End-To-End Regression Coverage ❌ Error The PR changes observable website runtime behavior, including Cinematic Studio generation gating, credit actions, retry flows, and router error handling under apps/website/src/. The changed-file lis… Add or update a Playwright regression test under apps/website/e2e/ for the changed Cinematic Studio flow, or record in the PR description why an end-to-end test is not practical.
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
End-To-End Regression Coverage For Fixes ✅ Passed All changed files listed in the review context are under apps/website. The check explicitly exempts PRs whose changes are exclusively in apps/website, even though several commit subjects use fix…
Adr Compliance For Entity/Litegraph Changes ✅ Passed PASS: The changed-file list contains no files under src/lib/litegraph/ or src/ecs/, and no files related to graph entities. The ADR compliance check is not applicable.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Cinematic Studio credit estimates and credit gating.
Description check ✅ Passed The description includes the required Summary, Changes, and Review Focus sections. It explains the main behavior, edge cases, validation results, and related work item. Breaking changes, dependencies,…
Full details: Website End-To-End Regression Coverage

Explanation

The PR changes observable website runtime behavior, including Cinematic Studio generation gating, credit actions, retry flows, and router error handling under apps/website/src/. The changed-file list contains no apps/website/e2e/**/*.spec.ts assertion that exercises these flows. The PR description does not explain why an end-to-end regression test was not added.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.67925% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...pps/website/src/composables/useCinematicDemoRun.ts 14.28% 6 Missing ⚠️
...s/website/src/composables/useCinematicStudioRun.ts 68.75% 1 Missing and 4 partials ⚠️
...orkshop/cinematic-studio/CinematicCreditAction.vue 85.00% 0 Missing and 3 partials ⚠️
apps/website/src/config/workshop-node-pricing.ts 90.32% 1 Missing and 2 partials ⚠️
.../workshop/cinematic-studio/CinematicGateButton.vue 93.10% 1 Missing and 1 partial ⚠️
...kshop/cinematic-studio/CinematicGenerateAction.vue 94.59% 0 Missing and 2 partials ⚠️
...site/src/composables/usePersonalWorkspaceSwitch.ts 84.61% 1 Missing and 1 partial ⚠️
apps/website/src/config/workshop-router-errors.ts 71.42% 1 Missing and 1 partial ⚠️
...site/src/lib/workshop/cinematic-studio/estimate.ts 80.00% 0 Missing and 2 partials ⚠️
...ts/workshop/cinematic-studio/CinematicSequence.vue 92.85% 1 Missing ⚠️
... and 2 more
@@            Coverage Diff             @@
##             main   #18928      +/-   ##
==========================================
- Coverage   83.98%   83.98%   -0.01%     
==========================================
  Files        3148     3121      -27     
  Lines      153824   153220     -604     
  Branches    39521    39385     -136     
==========================================
- Hits       129195   128679     -516     
+ Misses      23038    22996      -42     
+ Partials     1591     1545      -46     
Flag Coverage Δ
billing-web-unit ?
website-unit 77.95% <88.67%> (+0.16%) ⬆️

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

Files with missing lines Coverage Δ
...ps/website/src/components/workshop/ModelDetail.vue 90.05% <100.00%> (+0.53%) ⬆️
...ts/workshop/cinematic-studio/CinematicComposer.vue 87.50% <100.00%> (+0.54%) ⬆️
...s/workshop/cinematic-studio/CinematicCostLabel.vue 100.00% <100.00%> (ø)
...rkshop/cinematic-studio/CinematicCreditSummary.vue 100.00% <100.00%> (ø)
...nents/workshop/cinematic-studio/CinematicPanel.vue 95.00% <100.00%> (+0.08%) ⬆️
...nents/workshop/cinematic-studio/CinematicStage.vue 91.66% <100.00%> (+0.36%) ⬆️
...s/workshop/cinematic-studio/CinematicStageCard.vue 88.88% <100.00%> (+0.65%) ⬆️
...ents/workshop/cinematic-studio/CinematicStudio.vue 87.75% <100.00%> (+0.25%) ⬆️
...workshop/cinematic-studio/CinematicStudioPanel.vue 88.88% <ø> (ø)
...s/workshop/cinematic-studio/CinematicTakeFrame.vue 100.00% <100.00%> (+4.34%) ⬆️
... and 21 more

... and 36 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 added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 25, 2026
coderabbitai[bot]
coderabbitai Bot previously requested changes Sep 25, 2026

@coderabbitai coderabbitai 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.

Pre-merge checks failed. Please resolve the failing checks before merging.

@benjcooley
benjcooley dismissed coderabbitai[bot]’s stale review September 25, 2026 23:47

The pre-merge review is superseded: all current checks pass and there are no actionable review threads.

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🧐 TED — review of 335e318

Verdict: the estimates and the gate are correct. One should-fix in the retry path for skipped takes.

Severity Count
BLOCKER 0
SHOULD FIX 1
TRIVIAL 0

Estimates: I dumped the build-time table and the frame each Router mapping produces, for every aspect × resolution × reference count.

  • Flux 2 Pro: priced on the width × height the mapping actually sends (1:1 1K = 1024², 6.33; 1:1 2K = 2048², 15.825; 21:9 clamps to 2048×878 at both resolutions, so 9.495 for both). References widen the range to the node rule's +$0.015…$0.12. That matches Flux2ImageNode's own expression.
  • Seedream 4.5: a flat 8.44 in all 30 cells, which is correct for a per-image price.
  • Gemini 3 Pro, Krea 2 and Qwen 3 Pro: no price, so they fall back to the zero-balance gate as intended.
  • Rules stay off the client: only pricing.ts (build time, from the .astro frontmatter) and model-page.ts import workshop-node-pricing. estimate.ts imports a type only, so the browser gets the price table and never the rules.

Gate: it blocks when credits < total.min; offers "Use N takes" with min(floor(credits / perTake.min), takes − 1) and hides it when N would be 0; keeps credits > 0 for unpriced models and for retries. Members get the member copy and "Switch to personal", never "Add credits". The body-only error_type fallback in workshop-router-errors.ts is only used when the header is missing, and a truncated body parses to null. All correct.

Outside this PR (pre-existing Router mappings, worth a ticket):

  • Seedream 4.5 sends 2560×1440 (16:9) for 21:9 1K and 4:3 1K, and 2304×1728 (4:3) for 1:1 1K, so the user doesn't get the aspect they picked.
  • Krea 2 sends resolution: 1K for 2K.
  • The price is flat, so the estimates aren't affected.

Merge order: removing outOfCredits from StudioGateInput breaks #18917's useReshoot.ts (TS2353; I verified this by merging the two locally).

Tests (local): 227 pass across cinematic-studio, node pricing, router and run. pnpm typecheck is clean.

@vercel
vercel Bot temporarily deployed to Preview – billing-web-test September 26, 2026 00:34 Inactive
coderabbitai[bot]
coderabbitai Bot previously requested changes Sep 26, 2026

@coderabbitai coderabbitai 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.

Pre-merge checks failed. Please resolve the failing checks before merging.

@benjcooley
benjcooley marked this pull request as ready for review September 26, 2026 00:46
@benjcooley
benjcooley requested review from a team September 26, 2026 00:46
@benjcooley
benjcooley merged commit 769b00c into main Sep 26, 2026
90 checks passed
@benjcooley
benjcooley deleted the bencooley/cinematic-credit-estimate branch September 26, 2026 00:47

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🧐 TED — re-review of 8e7111d

Verdict: my should-fix is fixed. I have nothing blocking, and this is ready from my side (see the note below on who can approve).

Severity Count
BLOCKER 0
SHOULD FIX 0
TRIVIAL 1

Fixed: CinematicCreditAction now offers the skipped takes again when the balance goes above its earlier value, and also when a watched top-up lands. That covers switching to the personal workspace and credits added in another tab. I restored the old component and ran the new test ("offers the skipped takes again once the balance rises another way"): it fails without the fix and passes with it.

Checked: only CinematicCreditAction.vue and one test changed since 335e318, so the earlier estimate and gate review still stands.

Tests (local): 133 cinematic-studio tests pass and pnpm typecheck is clean. CI on 8e7111d is 53 passed, 37 skipped, none failed.

Merge order: land this before #18917. Its useReshoot.ts still passes outOfCredits and will need the rebase its author has planned.

About "review of record": these TED reviews are posted from the author's own account (@benjcooley). GitHub can't count them as an approval, and they don't satisfy the requirement for a second reviewer. Merging on them alone is what got #18763 flagged in Comfy-Org/unreviewed-merges#343. Someone from comfy_website_devs still needs to approve.

const credits = computed(() =>
balance.value.status === 'ok' ? balance.value.credits : undefined
)
const creditsWhenSkipped = ref(credits.value)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TRIVIAL — the baseline is the balance when this component mounts, not when the takes were skipped. The take notice mounts only while its take is selected. So if the balance rises while another take is on screen (for example, after switching to personal from the Generate button), coming back to the skipped take sets the baseline to the new balance, and the notice offers "Add credits" instead of a retry. The summary usually stays mounted, so this is minor. Recording the balance on the take when the Router refuses it would make the comparison exact.

benjcooley added a commit that referenced this pull request Sep 26, 2026
## Summary

Gates Cinematic Studio and its Re-shoot app on the
`workshop-apps-enabled` PostHog flag instead of
`workshop-workflows-enabled`, so apps and Cloud workflows roll out
independently. Follow-up to #18695.

## Changes

- **What**:
- `useWorkshopAppsEnabled()` in `scripts/posthog.ts`, resolved alongside
the other Workshop flags and cleared on identity change;
`PUBLIC_WORKSHOP_APPS_ENABLED=1` forces it on in local dev.
- The `/cinematic-studio` page gate, the Cinematic Studio featured slide
on `/models`, and a model page's Open in Studio link read the apps flag.
Cloud workflow pages keep `workshop-workflows-enabled`.
  - README documents the flag.
- New e2e `workshop-apps.spec.ts`: `/cinematic-studio` opens on the apps
flag alone and stays closed when only the workflows flag is on.
- Rebased onto #18928, whose Cinematic Studio tests now mock the apps
flag.

## Review Focus

- `workshop-apps-enabled` exists in PostHog: 100% for `comfy_staff =
true`, 0% otherwise. `identifyInPostHog` sets `comfy_staff: true`, which
that condition matches.
- New `posthog.test.ts` case: the apps flag resolves independently of
the workflows flag and resets on a caller change.

Validation: website unit tests for posthog, ModelDetail,
WorkshopModelsGrid, CinematicStudio, ModelsPage and WorkflowPlayground
pass; the new e2e spec passes against a production build;
`typecheck:website`, eslint, oxlint, oxfmt and fallow clean.

This branch was previously deployed

1 inactive deployment
Preview – billing-web-test — 8e7111d9 Deployed Sep 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant