Skip to content

FE-3019 fix(billing-web): render the server-reported discount term - #19878

Merged
dante01yoon merged 1 commit into
mainfrom
jaewon/fe-3019-discount-term
Oct 2, 2026
Merged

dante01yoon merged 1 commit into
mainfrom
jaewon/fe-3019-discount-term

Conversation

@dante01yoon

@dante01yoon dante01yoon commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

billing-web words a discount's term from the term the server reports on SubscriptionDiscount, instead of picking the copy on the client.

Builds on #19877 (merged).

Why

  • The frontend must not derive copy from server metadata. The summary chose a discount's subline from transition_type, the plan duration and the coupon duration.
  • The summary and the Success card disagreed. A one-time code on a monthly plan change read "This payment only" on the summary and "First month" on Success.

Root cause

  • summaryLedger.ts discountTerm mapped duration: 'once' to "This payment only" when transition_type was not new_subscription and the plan was monthly, otherwise to the plan's first period.
  • The op status has no transition_type, so successBreakdown.ts could only pass the plan duration, and the same code read "First month" there.

How

  • cloud#11446 adds term (this_payment, first_month, first_year, months, ongoing) to SubscriptionDiscount, in both the preview's discounts and the op status charge_breakdown reasons.
  • discountRow looks the subline up in a TERM_LINE table keyed by term. this_payment, first_month and first_year reuse the existing keys, months uses the forMonths plural with duration_in_months, and ongoing or an absent term has no subline. The reads of transition_type, plan duration and discount.duration, DeductionFormat.duration, and BY_DURATION.onceTerm are deleted. The Success card shares discountRow, so it reads the same copy.
  • account-core. SubscriptionDiscountSchema extends the generated zSubscriptionDiscount, which already carries term as an optional strict enum, so the schema is not redeclared. A new subscriptionDiscount.test.ts pins the inferred type to the five values, parses each, and rejects an unknown term.

Testing

  • Unit: billing-web 1344 passed, account-core 1468 passed (rebased on main). The new term table, the Success "This payment only" case, and a guard (same term across new_subscription, upgrade, downgrade and duration_change reads the same copy) fail 8 tests against the previous summaryLedger.ts/successBreakdown.ts.
  • Typecheck: root, billing-web and account-core are clean. oxlint, oxfmt and knip are clean.
  • billing-web e2e with CI=1 and --retries=0 on :4174: 127 passed. Scenario discounts now carry term, and the monthly-change test asserts "This payment only" on Success.

Where this PR sits in Milestone 3

Step PR State
Server display fields, first pass PR 19672 merged
Top-up on full-page checkout PR 19673 merged
Per-month prices for yearly plans cloud 11318 merged
Charge breakdown on succeeded ops cloud 11327 merged
Ingest types sync PR 19526 merged
Render display prices and breakdown PR 19814 merged
Discount term cloud 11446 merged
Ingest types sync (cloud@4b1fa05) PR 19877 merged
Render the server-reported discount term this PR open
flowchart LR
  A["PR 19672 (merged)"] --> F["PR 19814 display prices (merged)"]
  B["PR 19673 (merged)"] --> F
  C["cloud 11318 (merged)"] --> E["PR 19526 ingest types (merged)"]
  D["cloud 11327 (merged)"] --> E
  E --> F
  G["cloud 11446 discount term (merged)"] --> H["PR 19877 ingest types sync (merged)"]
  F --> I["this PR"]
  H --> I
  style I fill:#f9d71c,stroke:#333,stroke-width:3px
Loading

Screenshots

AS IS (main) TO BE (this PR)
Success after a monthly plan change with a one-time code (term: this_payment) asis-success tobe-success

Captured from the local billing-web production build (vite build and vite preview on :4174) against the e2e mock Cloud, with the same scenario on main and on this branch. The summary already read "This payment only" on main; Success read "First month".

@coderabbitai

coderabbitai Bot commented Oct 2, 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: 3657a30e-e548-4a6f-9273-c7a6b0de2852

📥 Commits

Reviewing files that changed from the base of the PR and between 7167840 and 2ebaf3a.

📒 Files selected for processing (26)
  • apps/billing-web/e2e/fixtures/scenario.ts
  • apps/billing-web/e2e/full-page-endings.spec.ts
  • apps/billing-web/e2e/full-page-summary.spec.ts
  • apps/billing-web/src/checkout/successBreakdown.test.ts
  • apps/billing-web/src/checkout/successBreakdown.ts
  • apps/billing-web/src/checkout/summaryLedger.test.ts
  • apps/billing-web/src/checkout/summaryLedger.ts
  • apps/billing-web/src/test/fakeBillingClient.ts
  • apps/website/e2e/fixtures/buyCredits.ts
  • apps/website/src/config/workshop-billing-sdk.test.ts
  • browser_tests/fixtures/data/billingCapabilities.ts
  • packages/account-core/src/core/billing/capabilities.test.ts
  • packages/account-core/src/core/billing/contracts/billingCapabilities.contract.test.ts
  • packages/account-core/src/core/billing/scopedReader.test.ts
  • packages/account-core/src/core/billing/subscriptionDiscount.test.ts
  • packages/account-core/src/core/billing/topup.test.ts
  • packages/account-ui/src/billing/__fixtures__/billingHarness.ts
  • packages/ingest-types/src/index.ts
  • packages/ingest-types/src/types.gen.ts
  • packages/ingest-types/src/zod.gen.ts
  • src/platform/auth/webSessionFlagOn.test.ts
  • src/platform/workspace/api/__mocks__/workspaceApi.ts
  • src/platform/workspace/billing/sdk/billingCapabilitiesView.test.ts
  • src/platform/workspace/billing/sdk/billingSdkTelemetryOwnership.test.ts
  • src/platform/workspace/billing/sdk/createBillingSdk.test.ts
  • src/platform/workspace/composables/useBillingCapabilities.test.ts

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


📝 Walkthrough

Walkthrough

Checkout discount summaries now use server-reported terms. Generated ingest contracts add scheduled-change revert and task-cancellation operations, cancelled task statuses, and a billing capability. The member email schema now accepts any string.

Changes

Discount term summaries

Layer / File(s) Summary
Discount term contract
packages/ingest-types/src/types.gen.ts, packages/ingest-types/src/zod.gen.ts, packages/account-core/src/core/billing/subscriptionDiscount.test.ts
The discount contract adds an optional term with five allowed values. Tests cover valid terms, an absent term, and an unsupported term.
Discount summary formatting and coverage
apps/billing-web/src/checkout/summaryLedger.ts, apps/billing-web/src/checkout/successBreakdown.ts, apps/billing-web/src/checkout/*.test.ts, apps/billing-web/e2e/full-page-*.spec.ts
Discount sublines now use the reported term. Fixed labels apply to this_payment, first_month, and first_year; months shows a duration only when supplied, while ongoing and missing terms show no subline. Tests cover subscription transitions and checkout summaries.

Scheduled-change billing contracts

Layer / File(s) Summary
Billing capability and revert contracts
packages/ingest-types/src/types.gen.ts, packages/ingest-types/src/zod.gen.ts, packages/ingest-types/src/index.ts
The generated contracts add can_revert_scheduled_change and types and schemas for the scheduled-change revert operation. Its request accepts an optional idempotency key; its response includes a billing operation ID and a reverted or pending status.
Capability fixture defaults
apps/billing-web/e2e/fixtures/scenario.ts, apps/billing-web/src/test/fakeBillingClient.ts, apps/website/e2e/fixtures/buyCredits.ts, apps/website/src/config/workshop-billing-sdk.test.ts, browser_tests/fixtures/data/billingCapabilities.ts, packages/account-core/src/core/billing/*test.ts, packages/account-ui/src/billing/__fixtures__/billingHarness.ts, src/platform/auth/webSessionFlagOn.test.ts, src/platform/workspace/api/__mocks__/workspaceApi.ts, src/platform/workspace/billing/sdk/*.test.ts, src/platform/workspace/composables/useBillingCapabilities.test.ts
Capability fixtures include can_revert_scheduled_change: false. The compile-time capability shape assertion includes the field. Caller overrides remain available where the fixture supports them.

Task and member ingest contracts

Layer / File(s) Summary
Task cancellation and member schemas
packages/ingest-types/src/types.gen.ts, packages/ingest-types/src/zod.gen.ts, packages/ingest-types/src/index.ts
Generated contracts add task-cancellation request and response types and schemas, and include cancelled in task status types. The member email schema accepts any string, and its description allows an empty string when no email is on file.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2ebaf

The discount wording and contract updates appear ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 2ebaf

The checkout change uses a validated server field for discount wording. The additional operations are contract declarations, not newly implemented requests. No introduced vulnerability was established, but server-side authorization and recovery behavior remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The declared sensitive outcomes are cancellation of an identified task and reversal of a scheduled subscription change. The added declarations do not themselves execute either mutation; maximum cross-workspace or cross-user exposure cannot be determined without backend ownership and authorization evidence.

Trust Boundaries and Controls

  • observed — The inspected task-service caller URL-encodes the task identity before sending DELETE and handles 404 or 409 as a terminal race with no accepted cancellation. Encoding protects request-path construction, but does not establish permission to cancel the task.

Resilience and Maintainability Implications

  • observed — Reversion distinguishes pending from reverted and directs pending consumers to poll the billing operation. Cancellation success is described as accepted, not necessarily completed. These outcome contracts do not establish atomicity, idempotent replay, cleanup or recovery after interruption and partial failure.
🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 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 The PR uses bug-fix language in its title and commit subjects, but it changes browser_tests/fixtures/data/billingCapabilities.ts. Therefore, the required absence of a browser_tests/ change is fals…
Website End-To-End Regression Coverage ✅ Passed No website runtime file changed. The only apps/website/src/ change is config/workshop-billing-sdk.test.ts, which is a test file. The other website change is under apps/website/e2e/fixtures/, whi…
Adr Compliance For Entity/Litegraph Changes ✅ Passed The changed-file list contains no files under src/lib/litegraph/, src/ecs/, or files related to graph entities. This check is not applicable.
Title check ✅ Passed The title clearly and concisely identifies the main change: billing-web now renders the server-reported discount term.
Description check ✅ Passed The description is detailed and relevant. It explains the motivation, root cause, implementation, dependencies, testing, and visual impact. It does not use the exact Changes or Review Focus headings, …
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 10/02/2026, 05:16:57 PM UTC

Links

🌐 Website E2E

Tip

All tests passed.

Status ✅ Passed
Report View Report

🌾 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.

No new findings in the changed files.

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

Full docs: ADR-DEVEX-LINT-0015

🧩 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

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main   #19878      +/-   ##
==========================================
- Coverage   84.81%   84.81%   -0.01%     
==========================================
  Files        3431     3431              
  Lines      164481   164476       -5     
  Branches    44912    42977    -1935     
==========================================
- Hits       139512   139500      -12     
- Misses      23014    23022       +8     
+ Partials     1955     1954       -1     
Flag Coverage Δ
billing-web-unit 92.05% <100.00%> (+0.02%) ⬆️
unit 82.29% <ø> (ø)
website-unit 79.93% <ø> (ø)

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

Files with missing lines Coverage Δ
apps/billing-web/src/checkout/successBreakdown.ts 87.50% <100.00%> (-0.74%) ⬇️
apps/billing-web/src/checkout/summaryLedger.ts 96.49% <100.00%> (+0.72%) ⬆️

... 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 added the risk:high PR risk grade (advisory shadow check; grader-owned) label Oct 2, 2026
@datadog-official

This comment has been minimized.

@dante01yoon
dante01yoon requested review from christian-byrne and removed request for christian-byrne October 2, 2026 06:45
Base automatically changed from jaewon/ingest-types-sync-cloud-4b1fa05 to main October 2, 2026 17:03
@dante01yoon
dante01yoon requested a review from a team October 2, 2026 17:03
The summary and the Success card word a discount's term from
SubscriptionDiscount.term instead of picking copy from transition_type,
the plan duration and the coupon duration. A one-time code on a monthly
plan change now reads "This payment only" on Success too.
@dante01yoon
dante01yoon force-pushed the jaewon/fe-3019-discount-term branch from 2ebaf3a to 3dcfbcb Compare October 2, 2026 17:14
@dante01yoon
dante01yoon requested review from christian-byrne and removed request for christian-byrne October 2, 2026 17:15

@christian-byrne christian-byrne 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.

Approved at exact head 3dcfbcbab129e38bc61ab49288a8eb8bdd463f8b.

  • The UI now renders the server-reported discount term consistently in the summary and success receipt.
  • Unknown and ongoing terms remain deliberately unqualified; plural month copy is driven only by the server count.
  • The schema, unit, and end-to-end coverage pin the five accepted values and the plan-change mismatch this fixes.
Full context for agent readers

I read the current seven-file diff, PR body, existing reviews, and review threads. There are no unresolved threads, the head is mergeable, and exact-head CI is settled green. The implementation removes the client-side inference from transition type and billing cadence rather than layering the server term on top of it.

@dante01yoon
dante01yoon added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit f679689 Oct 2, 2026
103 checks passed
@dante01yoon
dante01yoon deleted the jaewon/fe-3019-discount-term branch October 2, 2026 17:48
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.

2 participants