Skip to content

[do not merge] Phase 3 integration: FE-2214 + FE-2223 combined - #17660

Closed
dante01yoon wants to merge 8 commits into
jaewon/fe-2227-phase-3-core-sdk-owned-billing-operation-lifecycle-routingfrom
jaewon/fe-2227-phase3-integration
Closed

dante01yoon wants to merge 8 commits into
jaewon/fe-2227-phase-3-core-sdk-owned-billing-operation-lifecycle-routingfrom
jaewon/fe-2227-phase3-integration

Conversation

@dante01yoon

@dante01yoon dante01yoon commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Do not merge. Phase 3 of the billing SDK ends in two heads — top-up (#17657, FE-2214) and subscription (#17658 → #17659, FE-2223) — that may not depend on each other. Phase 4 (FE-2215) and Phase 5 (FE-2216) need both, so this branch is the merge of the two heads and the base the next stack level sits on. It exists for CI on the combined tree and as a base ref; it is closed once #17657 and #17659 are on main.

How

git merge of the FE-2214 head into the FE-2223 B2 head. The only conflict was the two appended export blocks in packages/account/src/core/billing/index.ts, kept in full. No other change. Package suite 555/555, oxlint and eslint clean on the merged tree.

AS-IS / TO-BE

AS-IS: two Phase 3 heads, nothing can stack on both.
TO-BE: one base ref carrying PR 0 + FE-2214 + FE-2223 for FE-2215 / FE-2216 / core follow-ups. No UI surface, no screenshots.

Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with git rebase --onto origin/main <parent tip> and force-push; GitHub retargets the base. Solid edges are code dependencies, dashed edges are sequencing.

flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104ac3<br/>before 2026-09-30"] -.-> E
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
Loading

@coderabbitai

coderabbitai Bot commented Sep 14, 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: 9275e450-21e5-4385-928b-d5427213493d

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 14, 2026 •

Copy link
Copy Markdown
Contributor

🌐 Website E2E

Tip

All tests passed.

Status ✅ Passed
Report View Report

🎭 Playwright: ✅ 2000 passed, 0 failed

📊 Browser Reports
  • chromium: View Report (✅ 1979 / ❌ 0 / ⚠️ 0 / ⏭️ 13)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/15/2026, 03:44:58 PM UTC

Links

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.8 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 69.2 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 61.4 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 76.6 MB heap
large-graph-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 77.3 MB heap
large-graph-pan: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 74.4 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 70.9 MB heap
legacy-node-drag: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 72.3 MB heap
minimap-idle: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 77.1 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 73.2 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 57.9 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 56.7 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 118ms TBT · 92.4 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 80.0 MB heap
vue-large-graph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 161.6 MB heap
vue-large-graph-pan: · 59.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 2ms TBT · 173.7 MB heap
vue-node-resize-workload: · 58.1 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 8ms TBT · 168.3 MB heap
vue-zoom-out-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 175.7 MB heap
workflow-execution: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 63.6 MB heap

ℹ️ No baseline found — significance unavailable.

Absolute values
Metric Value
canvas-idle: avg frame time 17ms
canvas-idle: p95 frame time 17ms
canvas-idle: layout duration 0ms
canvas-idle: style recalc duration 5ms
canvas-idle: layout count 0
canvas-idle: style recalc count 9
canvas-idle: task duration 327ms
canvas-idle: script duration 8ms
canvas-idle: TBT 0ms
canvas-idle: heap used 70.8 MB
canvas-idle: DOM nodes -261
canvas-idle: event listeners -152
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 3ms
canvas-mouse-sweep: style recalc duration 19ms
canvas-mouse-sweep: layout count 14
canvas-mouse-sweep: style recalc count 74
canvas-mouse-sweep: task duration 595ms
canvas-mouse-sweep: script duration 102ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 69.2 MB
canvas-mouse-sweep: DOM nodes -112
canvas-mouse-sweep: event listeners -89
canvas-zoom-sweep: avg frame time 17ms
canvas-zoom-sweep: p95 frame time 17ms
canvas-zoom-sweep: layout duration 1ms
canvas-zoom-sweep: style recalc duration 12ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 31
canvas-zoom-sweep: task duration 248ms
canvas-zoom-sweep: script duration 11ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 61.4 MB
canvas-zoom-sweep: DOM nodes 76
canvas-zoom-sweep: event listeners 20
dom-widget-clipping: avg frame time 17ms
dom-widget-clipping: p95 frame time 17ms
dom-widget-clipping: layout duration 0ms
dom-widget-clipping: style recalc duration 5ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 12
dom-widget-clipping: task duration 306ms
dom-widget-clipping: script duration 114ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 76.6 MB
dom-widget-clipping: DOM nodes 19
dom-widget-clipping: event listeners 1
large-graph-idle: avg frame time 17ms
large-graph-idle: p95 frame time 17ms
large-graph-idle: layout duration 0ms
large-graph-idle: style recalc duration 5ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 8
large-graph-idle: task duration 440ms
large-graph-idle: script duration 25ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 77.3 MB
large-graph-idle: DOM nodes -244
large-graph-idle: event listeners -166
large-graph-pan: avg frame time 17ms
large-graph-pan: p95 frame time 17ms
large-graph-pan: layout duration 0ms
large-graph-pan: style recalc duration 11ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 66
large-graph-pan: task duration 1119ms
large-graph-pan: script duration 551ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 74.4 MB
large-graph-pan: DOM nodes -125
large-graph-pan: event listeners 4
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 14ms
large-graph-zoom: style recalc duration 13ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 62
large-graph-zoom: task duration 1283ms
large-graph-zoom: script duration 560ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 70.9 MB
large-graph-zoom: DOM nodes 6
large-graph-zoom: event listeners 8
legacy-node-drag: avg frame time 17ms
legacy-node-drag: p95 frame time 17ms
legacy-node-drag: layout duration 0ms
legacy-node-drag: style recalc duration 8ms
legacy-node-drag: layout count 0
legacy-node-drag: style recalc count 46
legacy-node-drag: task duration 1310ms
legacy-node-drag: script duration 650ms
legacy-node-drag: TBT 0ms
legacy-node-drag: heap used 72.3 MB
legacy-node-drag: DOM nodes -106
legacy-node-drag: event listeners 92
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 5ms
minimap-idle: layout count 0
minimap-idle: style recalc count 8
minimap-idle: task duration 462ms
minimap-idle: script duration 34ms
minimap-idle: TBT 0ms
minimap-idle: heap used 77.1 MB
minimap-idle: DOM nodes -248
minimap-idle: event listeners -182
subgraph-dom-widget-clipping: avg frame time 17ms
subgraph-dom-widget-clipping: p95 frame time 17ms
subgraph-dom-widget-clipping: layout duration 0ms
subgraph-dom-widget-clipping: style recalc duration 8ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 48
subgraph-dom-widget-clipping: task duration 288ms
subgraph-dom-widget-clipping: script duration 96ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 73.2 MB
subgraph-dom-widget-clipping: DOM nodes 22
subgraph-dom-widget-clipping: event listeners 7
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 5ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 348ms
subgraph-idle: script duration 7ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 57.9 MB
subgraph-idle: DOM nodes -274
subgraph-idle: event listeners -230
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 4ms
subgraph-mouse-sweep: style recalc duration 19ms
subgraph-mouse-sweep: layout count 18
subgraph-mouse-sweep: style recalc count 78
subgraph-mouse-sweep: task duration 548ms
subgraph-mouse-sweep: script duration 72ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 56.7 MB
subgraph-mouse-sweep: DOM nodes -274
subgraph-mouse-sweep: event listeners -230
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 9ms
subgraph-transition-enter: style recalc duration 24ms
subgraph-transition-enter: layout count 5
subgraph-transition-enter: style recalc count 19
subgraph-transition-enter: task duration 654ms
subgraph-transition-enter: script duration 24ms
subgraph-transition-enter: TBT 118ms
subgraph-transition-enter: heap used 92.4 MB
subgraph-transition-enter: DOM nodes 13587
subgraph-transition-enter: event listeners 2385
viewport-pan-sweep: avg frame time 17ms
viewport-pan-sweep: p95 frame time 17ms
viewport-pan-sweep: layout duration 0ms
viewport-pan-sweep: style recalc duration 41ms
viewport-pan-sweep: layout count 0
viewport-pan-sweep: style recalc count 250
viewport-pan-sweep: task duration 4242ms
viewport-pan-sweep: script duration 1944ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 80.0 MB
viewport-pan-sweep: DOM nodes -247
viewport-pan-sweep: event listeners -151
vue-large-graph-idle: avg frame time 17ms
vue-large-graph-idle: p95 frame time 17ms
vue-large-graph-idle: layout duration 0ms
vue-large-graph-idle: style recalc duration 0ms
vue-large-graph-idle: layout count 0
vue-large-graph-idle: style recalc count 0
vue-large-graph-idle: task duration 11305ms
vue-large-graph-idle: script duration 189ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 161.6 MB
vue-large-graph-idle: DOM nodes -6543
vue-large-graph-idle: event listeners -7482
vue-large-graph-pan: avg frame time 17ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 15ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 72
vue-large-graph-pan: task duration 13815ms
vue-large-graph-pan: script duration 687ms
vue-large-graph-pan: TBT 2ms
vue-large-graph-pan: heap used 173.7 MB
vue-large-graph-pan: DOM nodes -6545
vue-large-graph-pan: event listeners -7482
vue-node-resize-workload: avg frame time 17ms
vue-node-resize-workload: p95 frame time 17ms
vue-node-resize-workload: layout duration 24ms
vue-node-resize-workload: style recalc duration 61ms
vue-node-resize-workload: layout count 20
vue-node-resize-workload: style recalc count 20
vue-node-resize-workload: task duration 4012ms
vue-node-resize-workload: script duration 97ms
vue-node-resize-workload: TBT 8ms
vue-node-resize-workload: heap used 168.3 MB
vue-node-resize-workload: DOM nodes -6543
vue-node-resize-workload: event listeners -7480
vue-zoom-out-idle: avg frame time 17ms
vue-zoom-out-idle: p95 frame time 17ms
vue-zoom-out-idle: layout duration 0ms
vue-zoom-out-idle: style recalc duration 0ms
vue-zoom-out-idle: layout count 0
vue-zoom-out-idle: style recalc count 0
vue-zoom-out-idle: task duration 5563ms
vue-zoom-out-idle: script duration 87ms
vue-zoom-out-idle: TBT 0ms
vue-zoom-out-idle: heap used 175.7 MB
vue-zoom-out-idle: DOM nodes 0
vue-zoom-out-idle: event listeners -9
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 2ms
workflow-execution: style recalc duration 21ms
workflow-execution: layout count 4
workflow-execution: style recalc count 17
workflow-execution: task duration 104ms
workflow-execution: script duration 11ms
workflow-execution: TBT 0ms
workflow-execution: heap used 63.6 MB
workflow-execution: DOM nodes 136
workflow-execution: event listeners 74
Raw data
{
  "timestamp": "2026-09-15T15:53:58.905Z",
  "gitSha": "a13da817298137395f6e223a90c29d3122dcdb4f",
  "branch": "jaewon/fe-2227-phase3-integration",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2006.4950000000294,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 4.943,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 306.977,
      "heapDeltaBytes": 16271792,
      "heapUsedBytes": 78041804,
      "domNodes": -261,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 7.432000000000001,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-idle",
      "durationMs": 1993.1700000000774,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 4.8149999999999995,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 346.10200000000003,
      "heapDeltaBytes": 8424244,
      "heapUsedBytes": 70359936,
      "domNodes": -261,
      "jsHeapTotalBytes": 4448256,
      "scriptDurationMs": 7.998,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1687.1490000000335,
      "styleRecalcs": 73,
      "styleRecalcDurationMs": 18.667999999999996,
      "layouts": 14,
      "layoutDurationMs": 3.299,
      "taskDurationMs": 569.8389999999999,
      "heapDeltaBytes": 22001280,
      "heapUsedBytes": 83834432,
      "domNodes": 35,
      "jsHeapTotalBytes": 5767168,
      "scriptDurationMs": 99.12499999999999,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1710.38800000008,
      "styleRecalcs": 75,
      "styleRecalcDurationMs": 20.026000000000003,
      "layouts": 14,
      "layoutDurationMs": 3.65,
      "taskDurationMs": 620.5780000000001,
      "heapDeltaBytes": -876888,
      "heapUsedBytes": 61329900,
      "domNodes": -258,
      "jsHeapTotalBytes": 5234688,
      "scriptDurationMs": 104.866,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1710.1339999999823,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 11.557999999999998,
      "layouts": 6,
      "layoutDurationMs": 1.3380000000000003,
      "taskDurationMs": 226.67000000000004,
      "heapDeltaBytes": 2181600,
      "heapUsedBytes": 64443444,
      "domNodes": 75,
      "jsHeapTotalBytes": 4456448,
      "scriptDurationMs": 10.651,
      "eventListeners": 21,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1709.754000000089,
      "styleRecalcs": 30,
      "styleRecalcDurationMs": 11.668,
      "layouts": 6,
      "layoutDurationMs": 1.0710000000000002,
      "taskDurationMs": 268.887,
      "heapDeltaBytes": 2144816,
      "heapUsedBytes": 64398116,
      "domNodes": 76,
      "jsHeapTotalBytes": 4980736,
      "scriptDurationMs": 10.955,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 500.0509999999849,
      "styleRecalcs": 11,
      "styleRecalcDurationMs": 4.630000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 308.274,
      "heapDeltaBytes": 17840368,
      "heapUsedBytes": 80253764,
      "domNodes": 18,
      "jsHeapTotalBytes": 5505024,
      "scriptDurationMs": 109.966,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.663333333333338,
      "p95FrameDurationMs": 16.700000000000273
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 483.70299999999133,
      "styleRecalcs": 12,
      "styleRecalcDurationMs": 5.962999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 304.643,
      "heapDeltaBytes": 17939808,
      "heapUsedBytes": 80297632,
      "domNodes": 20,
      "jsHeapTotalBytes": 4718592,
      "scriptDurationMs": 117.65800000000002,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000273
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2021.7910000000074,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 4.692,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 424.19199999999995,
      "heapDeltaBytes": 2525112,
      "heapUsedBytes": 82969224,
      "domNodes": -239,
      "jsHeapTotalBytes": -1544192,
      "scriptDurationMs": 24.98399999999999,
      "eventListeners": -152,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2007.600000000025,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 4.958,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 454.9219999999999,
      "heapDeltaBytes": -1037916,
      "heapUsedBytes": 79075656,
      "domNodes": -248,
      "jsHeapTotalBytes": -8192,
      "scriptDurationMs": 25.859,
      "eventListeners": -180,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2081.2519999999495,
      "styleRecalcs": 66,
      "styleRecalcDurationMs": 11.369,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1146.8319999999999,
      "heapDeltaBytes": 14022652,
      "heapUsedBytes": 78240552,
      "domNodes": -247,
      "jsHeapTotalBytes": 487424,
      "scriptDurationMs": 570.295,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2073.733999999945,
      "styleRecalcs": 66,
      "styleRecalcDurationMs": 9.667000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1091.536,
      "heapDeltaBytes": 13280632,
      "heapUsedBytes": 77758724,
      "domNodes": -3,
      "jsHeapTotalBytes": 487424,
      "scriptDurationMs": 532.291,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3132.4769999999944,
      "styleRecalcs": 62,
      "styleRecalcDurationMs": 12.847000000000001,
      "layouts": 60,
      "layoutDurationMs": 14.573999999999998,
      "taskDurationMs": 1305.5560000000003,
      "heapDeltaBytes": 8107748,
      "heapUsedBytes": 74092000,
      "domNodes": 6,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 566.824,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3100.218000000041,
      "styleRecalcs": 62,
      "styleRecalcDurationMs": 12.16,
      "layouts": 60,
      "layoutDurationMs": 13.85,
      "taskDurationMs": 1260.656,
      "heapDeltaBytes": 9484748,
      "heapUsedBytes": 74630260,
      "domNodes": 6,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 553.058,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 2173.9729999999895,
      "styleRecalcs": 47,
      "styleRecalcDurationMs": 10.144000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1424.1200000000001,
      "heapDeltaBytes": -13145268,
      "heapUsedBytes": 71023000,
      "domNodes": -219,
      "jsHeapTotalBytes": 778240,
      "scriptDurationMs": 672.265,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 2092.4340000000257,
      "styleRecalcs": 44,
      "styleRecalcDurationMs": 6.849999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1195.7649999999999,
      "heapDeltaBytes": 14516904,
      "heapUsedBytes": 80520460,
      "domNodes": 8,
      "jsHeapTotalBytes": 417792,
      "scriptDurationMs": 626.8419999999999,
      "eventListeners": 184,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "minimap-idle",
      "durationMs": 2030.8399999999551,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 4.768000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 457.26900000000006,
      "heapDeltaBytes": -7010956,
      "heapUsedBytes": 81159548,
      "domNodes": -249,
      "jsHeapTotalBytes": -1019904,
      "scriptDurationMs": 34.673,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "minimap-idle",
      "durationMs": 2017.9509999999254,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 5.380000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 466.5619999999999,
      "heapDeltaBytes": -1326340,
      "heapUsedBytes": 80477720,
      "domNodes": -246,
      "jsHeapTotalBytes": -757760,
      "scriptDurationMs": 32.915000000000006,
      "eventListeners": -182,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 447.08700000001045,
      "styleRecalcs": 48,
      "styleRecalcDurationMs": 8.342,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 284.414,
      "heapDeltaBytes": 13220960,
      "heapUsedBytes": 76643832,
      "domNodes": 22,
      "jsHeapTotalBytes": 5767168,
      "scriptDurationMs": 93.976,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999727
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 457.6399999999694,
      "styleRecalcs": 48,
      "styleRecalcDurationMs": 8.126000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 291.955,
      "heapDeltaBytes": 13365136,
      "heapUsedBytes": 76814424,
      "domNodes": 22,
      "jsHeapTotalBytes": 5767168,
      "scriptDurationMs": 97.519,
      "eventListeners": 6,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.663333333333338,
      "p95FrameDurationMs": 16.799999999999727
    },
    {
      "name": "subgraph-idle",
      "durationMs": 1993.5680000000389,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 5.131999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 339.68399999999997,
      "heapDeltaBytes": 26856,
      "heapUsedBytes": 63603552,
      "domNodes": -274,
      "jsHeapTotalBytes": 4448256,
      "scriptDurationMs": 6.823000000000001,
      "eventListeners": -230,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-idle",
      "durationMs": 1992.9260000000113,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 5.557000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 357.108,
      "heapDeltaBytes": -5387052,
      "heapUsedBytes": 57810784,
      "domNodes": -273,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 7.101,
      "eventListeners": -230,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1694.4030000000225,
      "styleRecalcs": 78,
      "styleRecalcDurationMs": 19.817,
      "layouts": 18,
      "layoutDurationMs": 4.348,
      "taskDurationMs": 522.451,
      "heapDeltaBytes": -1457520,
      "heapUsedBytes": 61935104,
      "domNodes": -273,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 72.709,
      "eventListeners": -230,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1675.2779999999348,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 18.354,
      "layouts": 18,
      "layoutDurationMs": 4.434,
      "taskDurationMs": 572.824,
      "heapDeltaBytes": -5856016,
      "heapUsedBytes": 57063708,
      "domNodes": -275,
      "jsHeapTotalBytes": 4710400,
      "scriptDurationMs": 71.991,
      "eventListeners": -230,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 882.9399999999623,
      "styleRecalcs": 19,
      "styleRecalcDurationMs": 23.67899999999999,
      "layouts": 5,
      "layoutDurationMs": 8.938999999999998,
      "taskDurationMs": 653.9409999999999,
      "heapDeltaBytes": 17798164,
      "heapUsedBytes": 96900988,
      "domNodes": 13587,
      "jsHeapTotalBytes": 10485760,
      "scriptDurationMs": 24.217000000000002,
      "eventListeners": 2385,
      "totalBlockingTimeMs": 118,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8137.642999999969,
      "styleRecalcs": 249,
      "styleRecalcDurationMs": 39.338,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 4210.515000000001,
      "heapDeltaBytes": -761224,
      "heapUsedBytes": 79794964,
      "domNodes": -243,
      "jsHeapTotalBytes": 253952,
      "scriptDurationMs": 1936.538,
      "eventListeners": -136,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8139.365999999995,
      "styleRecalcs": 250,
      "styleRecalcDurationMs": 42.623,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 4274.378,
      "heapDeltaBytes": 9020804,
      "heapUsedBytes": 88004984,
      "domNodes": -251,
      "jsHeapTotalBytes": 741376,
      "scriptDurationMs": 1952.0059999999999,
      "eventListeners": -166,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 11989.010000000007,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 11196.563999999998,
      "heapDeltaBytes": -52709536,
      "heapUsedBytes": 166335252,
      "domNodes": -6543,
      "jsHeapTotalBytes": -4030464,
      "scriptDurationMs": 190.89300000000003,
      "eventListeners": -7482,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 12164.138999999977,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 11413.153000000002,
      "heapDeltaBytes": -34000232,
      "heapUsedBytes": 172663860,
      "domNodes": -6542,
      "jsHeapTotalBytes": -4075520,
      "scriptDurationMs": 187.68,
      "eventListeners": -7482,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 14027.026999999976,
      "styleRecalcs": 70,
      "styleRecalcDurationMs": 14.434000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 13473.794999999998,
      "heapDeltaBytes": -42190280,
      "heapUsedBytes": 176490924,
      "domNodes": -6547,
      "jsHeapTotalBytes": -5079040,
      "scriptDurationMs": 663.2070000000001,
      "eventListeners": -7476,
      "totalBlockingTimeMs": 4,
      "frameDurationMs": 16.66333333333338,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 14630.671000000006,
      "styleRecalcs": 74,
      "styleRecalcDurationMs": 15.532000000000018,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 14156.99,
      "heapDeltaBytes": -5054524,
      "heapUsedBytes": 187859972,
      "domNodes": -6543,
      "jsHeapTotalBytes": 1257472,
      "scriptDurationMs": 710.535,
      "eventListeners": -7488,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.223333333333358,
      "p95FrameDurationMs": 16.80000000000291
    },
    {
      "name": "vue-node-resize-workload",
      "durationMs": 4066.832999999974,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 54.93999999999999,
      "layouts": 20,
      "layoutDurationMs": 23.197999999999997,
      "taskDurationMs": 3951.174,
      "heapDeltaBytes": -21264780,
      "heapUsedBytes": 179795524,
      "domNodes": -6543,
      "jsHeapTotalBytes": 19603456,
      "scriptDurationMs": 69.15599999999999,
      "eventListeners": -7480,
      "totalBlockingTimeMs": 3,
      "frameDurationMs": 17.223333333333358,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-node-resize-workload",
      "durationMs": 4215.498000000025,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 67.53999999999999,
      "layouts": 20,
      "layoutDurationMs": 24.52,
      "taskDurationMs": 4073.5499999999993,
      "heapDeltaBytes": -32432892,
      "heapUsedBytes": 173252276,
      "domNodes": -6543,
      "jsHeapTotalBytes": 8118272,
      "scriptDurationMs": 125.453,
      "eventListeners": -7480,
      "totalBlockingTimeMs": 13,
      "frameDurationMs": 17.223333333333358,
      "p95FrameDurationMs": 16.80000000000109
    },
    {
      "name": "vue-zoom-out-idle",
      "durationMs": 6112.541999999962,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 5680.153,
      "heapDeltaBytes": -3752208,
      "heapUsedBytes": 188087120,
      "domNodes": 0,
      "jsHeapTotalBytes": -19136512,
      "scriptDurationMs": 85.61400000000002,
      "eventListeners": -10,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-zoom-out-idle",
      "durationMs": 5919.0549999999575,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 5446.398,
      "heapDeltaBytes": 13518588,
      "heapUsedBytes": 180466536,
      "domNodes": 0,
      "jsHeapTotalBytes": -2883584,
      "scriptDurationMs": 87.75599999999994,
      "eventListeners": -8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.669999999999952,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "workflow-execution",
      "durationMs": 459.6090000000004,
      "styleRecalcs": 20,
      "styleRecalcDurationMs": 22.479999999999997,
      "layouts": 3,
      "layoutDurationMs": 1.943,
      "taskDurationMs": 121.09400000000001,
      "heapDeltaBytes": 5255052,
      "heapUsedBytes": 66900808,
      "domNodes": 153,
      "jsHeapTotalBytes": 0,
      "scriptDurationMs": 14.120000000000001,
      "eventListeners": 81,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66666666666665,
      "p95FrameDurationMs": 16.700000000000273
    },
    {
      "name": "workflow-execution",
      "durationMs": 424.9240000000327,
      "styleRecalcs": 13,
      "styleRecalcDurationMs": 19.054000000000002,
      "layouts": 4,
      "layoutDurationMs": 1.8739999999999999,
      "taskDurationMs": 87.854,
      "heapDeltaBytes": 4720912,
      "heapUsedBytes": 66452068,
      "domNodes": 119,
      "jsHeapTotalBytes": 524288,
      "scriptDurationMs": 7.179999999999999,
      "eventListeners": 67,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    }
  ]
}

🔬 E2E Coverage

Metric Covered Total Pct
Lines 50793 76112 66.7% 🟡
Functions 0 0 — —
Branches 0 0 — —
Top 10 files by uncovered lines
File Coverage Missed
src/LGraphCanvas.ts 67.6% 1160
src/LGraphNode.ts 69.9% 388
src/extensions/core/cameraInfo/CameraInfoViewport.ts 2.0% 343
src/renderer/extensions/layerEditor/composables/useLayerEditorSession.ts 40.1% 332
src/platform/workspace/stores/workspaceAuthStore.ts 33.4% 327
src/platform/workspace/stores/billingOperationStore.ts 8.0% 311
src/LGraph.ts 79.1% 263
src/platform/workspace/stores/teamWorkspaceStore.ts 38.9% 256
src/scripts/app.ts 71.8% 251
src/scripts/pnginfo.ts 21.4% 221

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

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.80564% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/account/src/core/billing/topup.ts 96.87% 3 Missing ⚠️
...ages/account/src/core/billing/paymentProjection.ts 94.59% 1 Missing and 1 partial ⚠️
...s/account/src/core/billing/subscriptionCommands.ts 98.26% 2 Missing ⚠️
@@                                              Coverage Diff                                              @@
##           jaewon/fe-2227-phase-3-core-sdk-owned-billing-operation-lifecycle-routing   #17660      +/-   ##
=============================================================================================================
+ Coverage                                                                      82.46%   82.74%   +0.27%     
=============================================================================================================
  Files                                                                           2792     2792              
  Lines                                                                         140049   140729     +680     
  Branches                                                                       37571    36002    -1569     
=============================================================================================================
+ Hits                                                                          115496   116448     +952     
+ Misses                                                                         23377    23193     -184     
+ Partials                                                                        1176     1088      -88     
Flag Coverage Δ
e2e 66.73% <ø> (-0.05%) ⬇️
unit 78.88% <97.80%> (+0.54%) ⬆️
website-unit 74.28% <ø> (-0.05%) ⬇️

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

Files with missing lines Coverage Δ
packages/account/src/core/billing/balanceWatch.ts 100.00% <100.00%> (ø)
packages/account/src/core/billing/httpStatus.ts 100.00% <100.00%> (ø)
packages/account/src/core/billing/paymentCopy.ts 100.00% <100.00%> (ø)
packages/account/src/core/billing/sharedRead.ts 90.90% <ø> (-1.40%) ⬇️
...ages/account/src/core/billing/paymentProjection.ts 94.59% <94.59%> (ø)
...s/account/src/core/billing/subscriptionCommands.ts 98.26% <98.26%> (ø)
packages/account/src/core/billing/topup.ts 96.87% <96.87%> (ø)

... and 87 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.

@dante01yoon
dante01yoon force-pushed the jaewon/fe-2227-core-error-codes-and-challenge-driver branch from 4e6ff48 to 8c24dbc Compare September 15, 2026 01:29
@dante01yoon
dante01yoon force-pushed the jaewon/fe-2227-phase3-integration branch from 4c7a54c to 79217c1 Compare September 15, 2026 01:30
dante01yoon added a commit that referenced this pull request Sep 15, 2026
…FE-2214) (#17689)

## Why

FE-2214's done-when says all three current top-up hosts can integrate
the top-up command. #17657 covers ComfyUI_frontend's route (`POST
/api/billing/topup`, an operation to poll). Workshop (`apps/website`)
and Platform ship on the other route, `POST
/api/billing/topup/checkout`: a provider-hosted Checkout session with no
`billing_op_id`, credits landing through a webhook. That route could not
be decoded with generated schemas until the ingest-types regen #17396
merged; it now carries `CreateTopupCheckoutRequest` /
`CreateTopupCheckoutResponse`, so this is the 3A-2 follow-up recorded on
FE-2214.

Stacked on #17657 (FE-2214 top-up command); merge after it.

## How

`createTopupCommand` gains a second method on the same surface,
`createHostedTopupCheckout({ amountCents, returnUrl, signal? })`:

- input is validated by the generated `zCreateTopupCheckoutRequest`;
`INVALID_AMOUNT` / `INVALID_RETURN_URL` are returned before anything is
sent
- the same capability gate as the in-app command (`ACCESS_DENIED`
carrying the server's denial), then the pre-purchase balance is read
- one idempotency key per attempt, in the body and on the request; a 404
maps to `NOT_AVAILABLE` so a host keeps its legacy path while
`topup_checkout_enabled` is off
- `checkout_url` must be https (`validateActionUrl`, the same rule every
lifecycle continuation obeys), otherwise `MALFORMED_RESPONSE`;
`session_id` passes through when present
- nothing is adopted on the lifecycle and no operation id is invented
(FE-2214 invariant): the result is `{ url, sessionId?, baselineMicros?
}`. The host executes its `OpenUrlMode` on `url` (Workshop pre-opens a
tab, Platform redirects) and on return arms the existing
`createBalanceWatch` with `baselineMicros`, which is how the test proves
completion

`readTopupEligibility` (from the fallow split on #17657) now returns the
two failures it can actually produce, which is what lets the hosted
result union exclude `NO_PAYMENT_METHOD`.

## AS-IS / TO-BE

AS-IS: `TopupCommand` exposes `createTopupCheckout` only; Workshop keeps
its own `createTopUpCheckout` fetch with a hand-written `zTopUpCheckout`
schema, and Platform its own.
TO-BE: `TopupCommand` exposes `createHostedTopupCheckout` over the
generated contract; a host adapter is a thin wrapper (validate → gate →
POST → open → balance watch). No UI in this PR, so no screenshots; the
consumer cutover for Workshop is a separate slice.

## Testing

Eight new tests under `createHostedTopupCheckout` in `topup.test.ts`:
success shape, request body and idempotency key, and no lifecycle
operation; `can_top_up` false without a POST; amount and return-URL
rejection without a request; 404 → `NOT_AVAILABLE`; missing or non-https
URL → `MALFORMED_RESPONSE`; optional session id and baseline omitted
when unknown; baseline handed to a balance watch that reconciles on
return; no server or provider text on the failure path. Billing core
suite 187 passing; oxlint, eslint, oxfmt, `vue-tsc` clean.

## Stack (2026-09-15)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442 · ingest-types regen #17396"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  A --> A2["FE-2214 3A-2 hosted top-up checkout<br/>this PR"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  A2 -.-> WS["Workshop adapter over createHostedTopupCheckout<br/>later slice"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe (FE-2331)"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  H --> H8["FE-2331 Phase 8 hosted surfaces"]
```

Design: [Billing SDK implementation plan
(V2)](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8).
Linear: FE-2214.
dante01yoon added a commit that referenced this pull request Sep 15, 2026
…river (FE-2227) (#17656)

## Why

Stacked on #17655 (FE-2227); merge after it. The two Phase 3 command PRs
— top-up ([FE-2214](https://linear.app/comfyorg/issue/FE-2214)) and
subscription ([FE-2223](https://linear.app/comfyorg/issue/FE-2223)) —
both need to act on the server's coded error (`NO_PAYMENT_METHOD`,
`ALREADY_CANCELED`, …) and both need to drive an embedded 3DS challenge
through the lifecycle. FE-2223 may not depend on FE-2214, so the shared
pieces land here, on the core, and each command PR stacks on this one.

## How

- `BillingFailure.serverCode` (additive, optional):
`readValidatedBillingResponse` decodes a non-2xx body with the generated
`zErrorResponse` and carries only its `code`. The `message` is read by
the schema and dropped in `billingErrorBody.ts`, so server text still
cannot travel into the SDK. The codes are `z.string()` in the generated
contract, so each command owns a closed allowlist of the codes it acts
on.
- `driveEmbeddedChallenge(lifecycle, operationId, port)`:
`reportChallengeStarted` → `port.handleNextAction(clientSecret)` →
`reportChallengeSettled`. The port is Stripe's `handleNextAction` shape;
no provider SDK is imported in core, the host injects the object. The
unmoved-intent denylist (`requires_payment_method | requires_action |
canceled` → failed) is ported from
`billingOperationStore.runPaymentIntentAction` on this repo's `main`
(`src/platform/workspace/stores/billingOperationStore.ts:51-55`, `:555`;
landed in `a39b1ce9fa3`, 2026-09-03 — it is not in `cf-main`), and fails
toward the server: an unknown status reports completed and the next poll
corrects it.

## AS-IS / TO-BE

AS-IS: a command sees only `REQUEST_FAILED` + `httpStatus` for a 4xx and
cannot tell "no payment method" from "declined"; each command PR would
re-implement the 3DS drive over `reportChallenge*`.
TO-BE: `result.serverCode === 'NO_PAYMENT_METHOD'` is one comparison;
the challenge drive is one call. No UI surface, so no screenshots.

## Testing

`packages/account` 473/473. Named tests: coded error carried without its
message; non-contract error body yields no code; moved intent →
completed; error / unmoved intent / throw → failed; nothing driven
without a required embedded challenge.

## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
Base automatically changed from jaewon/fe-2227-core-error-codes-and-challenge-driver to jaewon/fe-2227-phase-3-core-sdk-owned-billing-operation-lifecycle-routing September 15, 2026 14:38
…upCheckout (FE-2214)

The capability read, its error return, and the can_top_up refusal move into a private readTopupEligibility helper so createTopupCheckout drops below the fallow cyclomatic threshold. Nothing about the command's inputs, outputs, ordering, or failure mapping changes; the existing topup tests pass unchanged.
…FE-2214) (#17689)

## Why

FE-2214's done-when says all three current top-up hosts can integrate
the top-up command. #17657 covers ComfyUI_frontend's route (`POST
/api/billing/topup`, an operation to poll). Workshop (`apps/website`)
and Platform ship on the other route, `POST
/api/billing/topup/checkout`: a provider-hosted Checkout session with no
`billing_op_id`, credits landing through a webhook. That route could not
be decoded with generated schemas until the ingest-types regen #17396
merged; it now carries `CreateTopupCheckoutRequest` /
`CreateTopupCheckoutResponse`, so this is the 3A-2 follow-up recorded on
FE-2214.

Stacked on #17657 (FE-2214 top-up command); merge after it.

## How

`createTopupCommand` gains a second method on the same surface,
`createHostedTopupCheckout({ amountCents, returnUrl, signal? })`:

- input is validated by the generated `zCreateTopupCheckoutRequest`;
`INVALID_AMOUNT` / `INVALID_RETURN_URL` are returned before anything is
sent
- the same capability gate as the in-app command (`ACCESS_DENIED`
carrying the server's denial), then the pre-purchase balance is read
- one idempotency key per attempt, in the body and on the request; a 404
maps to `NOT_AVAILABLE` so a host keeps its legacy path while
`topup_checkout_enabled` is off
- `checkout_url` must be https (`validateActionUrl`, the same rule every
lifecycle continuation obeys), otherwise `MALFORMED_RESPONSE`;
`session_id` passes through when present
- nothing is adopted on the lifecycle and no operation id is invented
(FE-2214 invariant): the result is `{ url, sessionId?, baselineMicros?
}`. The host executes its `OpenUrlMode` on `url` (Workshop pre-opens a
tab, Platform redirects) and on return arms the existing
`createBalanceWatch` with `baselineMicros`, which is how the test proves
completion

`readTopupEligibility` (from the fallow split on #17657) now returns the
two failures it can actually produce, which is what lets the hosted
result union exclude `NO_PAYMENT_METHOD`.

## AS-IS / TO-BE

AS-IS: `TopupCommand` exposes `createTopupCheckout` only; Workshop keeps
its own `createTopUpCheckout` fetch with a hand-written `zTopUpCheckout`
schema, and Platform its own.
TO-BE: `TopupCommand` exposes `createHostedTopupCheckout` over the
generated contract; a host adapter is a thin wrapper (validate → gate →
POST → open → balance watch). No UI in this PR, so no screenshots; the
consumer cutover for Workshop is a separate slice.

## Testing

Eight new tests under `createHostedTopupCheckout` in `topup.test.ts`:
success shape, request body and idempotency key, and no lifecycle
operation; `can_top_up` false without a POST; amount and return-URL
rejection without a request; 404 → `NOT_AVAILABLE`; missing or non-https
URL → `MALFORMED_RESPONSE`; optional session id and baseline omitted
when unknown; baseline handed to a balance watch that reconciles on
return; no server or provider text on the failure path. Billing core
suite 187 passing; oxlint, eslint, oxfmt, `vue-tsc` clean.

## Stack (2026-09-15)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442 · ingest-types regen #17396"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  A --> A2["FE-2214 3A-2 hosted top-up checkout<br/>this PR"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  A2 -.-> WS["Workshop adapter over createHostedTopupCheckout<br/>later slice"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe (FE-2331)"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  H --> H8["FE-2331 Phase 8 hosted surfaces"]
```

Design: [Billing SDK implementation plan
(V2)](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8).
Linear: FE-2214.
…al (FE-2223)

The transport marks a 401 it could not retry with authenticationRetrySkipped, but the response reader dropped the flag and mapped the status to ACCESS_DENIED. openPaymentPortal is the first non-replayable POST, so an expired token on the way to fix a payment method read as a permission refusal. Map that case to REQUEST_FAILED with the status kept, and name the server codes the subscription commands match on.
…hared-billing' into jaewon/fe-2227-phase3-integration
@dante01yoon
dante01yoon force-pushed the jaewon/fe-2227-phase3-integration branch from d16fadc to 5ced366 Compare September 15, 2026 15:43
dante01yoon added a commit that referenced this pull request Sep 15, 2026
)

## Why

Stacked on B1
(`jaewon/fe-2223-phase-3b-subscription-commands-and-eight-state-payment`,
#17658) → PR 0 (`jaewon/fe-2227-core-error-codes-and-challenge-driver`,
#17656) → #17655 (FE-2227); independent of FE-2214; merge after all
parents.

Phase 3B, part 2 of 2: the eight public payment states as a pure
projection of one lifecycle operation, plus the copy keys behind them.
Split out of B1 to keep each PR under the source budget.

- Linear: https://linear.app/comfyorg/issue/FE-2223

## How

New `packages/account/src/core/billing/paymentProjection.ts` and
`paymentCopy.ts` (+ tests), export lines appended to `index.ts`. No
other core file is touched.

`projectPaymentStep(operation | undefined, hostStep: 'select' |
'preview' | 'canceled')` → `{ step, reasonKey?, recoveryAction?,
operationId?, noChargeConfirmed }` over the eight states `select |
preview | verifying | canceled | declined | processing_error |
payment_received_hold | success`.

- No operation → the host's step. Pending: parked on the customer
(`challenge` or `actionUrl`) → `verifying`; a retryable decline
(`declineReason`, or this tab's failed challenge →
`authentication_failed`) → `declined`; otherwise `preview`. `succeeded`
→ `success`; `failed` → `declined`, except `processing_error` /
`generic` → `processing_error`; `timed_out` → `processing_error`
(`generic`); `superseded` → `select`.
- Reason keys are the generated `decline_reason` enum plus
`checkout_expired` and `generic`; copy keys are `billing.reason.<key>`.
No raw text can become a key.
- `paymentCopy.ts` ports the PoC `copy.ts` semantics:
`DEFAULT_PAYMENT_COPY`, `createPaymentCopy(overrides)` where the safety
line `billing.safety.nothing_was_charged` is not host-overridable, and
`paymentCopyKeys(projection)` which names the safety key only for
`canceled` with `noChargeConfirmed`.
- `noChargeConfirmed` is always `false`: the generated contract has no
field that lets a terminal backend result guarantee no current or later
charge (one short comment in code says so). Relates to the BE cancel
endpoint work (BE-10064).

Tests: every projection row (24 via `it.for`, including the host-cancel
precedence rows and a sweep asserting `noChargeConfirmed` is never true
and `payment_received_hold` is never produced) and the copy gate (3,
including the PoC TP-12 port).

## Review focus

Two decisions the plan left open, made here:

1. Lifecycle `reconciliation_needed` projects to `processing_error`
(`generic`) with `operationId` surfaced, not to `payment_received_hold`.
The contract cannot tell "paid, entitlement pending" from "needs a
human"; the id is what support acts on. `payment_received_hold` stays in
the public union and copy table but has no producing row until the
backend distinguishes the two.
2. `canceled` is reached only through the host: `hostStep` accepts
`'canceled'` for a cancel the host observed (closed page, dismissed
challenge). A server verdict (`succeeded`, `failed`,
`reconciliation_needed`) outranks it — a customer who backs out after
the charge went through still sees the result — while pending,
`timed_out`, and `superseded` yield to it.

Ticket vs generated contract:
- `checkout_expired` has no producing row:
`BillingOpStatusResponse.status` has no `expired` value. The key and its
copy are kept for the host and for the backend adding one.
- `noChargeConfirmed` has no source field, so it is a `boolean` that is
always `false` (a literal `false` type makes the copy gate dead by type
and fails `no-unnecessary-condition`).

## AS-IS / TO-BE

No UI surface, no screenshots.

AS-IS: the PoC reducer derived these states from an invented operation
status set (`expired`, `canceled`, `payment_received_hold`) and matched
raw `error_message` text for reasons.

TO-BE: a pure projection over the real `BillingOperationState`; hosts
render `step`/`reasonKey`/`operationId` and localize by copy key.

## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
dante01yoon added a commit that referenced this pull request Sep 15, 2026
…(FE-2223) (#17658)

## Why

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```


Stacked on PR 0 (`jaewon/fe-2227-core-error-codes-and-challenge-driver`,
#17656) → #17655 (FE-2227); independent of FE-2214; merge after both
parents.

Phase 3B, part 1 of 2: the subscription commands ported onto the
SDK-owned billing operation lifecycle. Part 2 (the eight-state payment
projection and copy) is stacked on this PR so each stays under the
source budget.

- Linear: https://linear.app/comfyorg/issue/FE-2223

## How

New `packages/account/src/core/billing/subscriptionCommands.ts` (+
test), export lines appended to `index.ts`. No other core file is
touched.

`createBillingCommands({ transport, lifecycle, statusReader,
capabilities, credits, idempotencyKey? })` returns `subscribe`,
`resubscribe`, `cancelSubscription`, `openPaymentPortal`.

- Every command encodes against the generated contract
(`zSubscribeRequest/Response`, `zResubscribeResponse`,
`zCancelSubscriptionResponse2` = the generated union of
`zCancelSubscriptionResponse | zCancelSubscriptionAcceptedResponse`,
`zPaymentPortalResponse`), reads through `readValidatedBillingResponse`,
and issues through `lifecycle.begin` — single-flight, the status gate,
backend-pending adoption, polling, routing, pointer, recovery, and
telemetry all stay in core. The command then awaits
`lifecycle.settled(id)` and returns the terminal state.
- Eligibility comes from the Phase 2 status snapshot's server fields
only (`is_active`, `subscription_tier`, `subscription_status`): FREE →
subscribe issues; PRO active → subscribe is a no-op success with no
request; PRO canceled → subscribe routes to the resubscribe endpoint.
- Saved payment method: `saved_payment_method_id` XOR
`confirmation_token`, empty strings dropped, both present →
`CONFLICTING_PAYMENT_METHOD` before any request (before the status read
too); a request the generated schema refuses (e.g. an id without the
`pm_` prefix) → `INVALID_REQUEST`, also before any request.
- Response mapping: `subscribed` and resubscribe `active` still adopt
the id so the first poll settles it and invalidation/telemetry are
uniform; `needs_payment_method` hands `payment_method_url` to the
lifecycle as the hosted `actionUrl` (missing →
`MISSING_PAYMENT_METHOD_URL`); `pending_payment` / `pending` / both
cancel shapes → observed to a terminal state. 3DS is driven by the host
through the existing `driveEmbeddedChallenge` while the command awaits
settlement (tested end to end through the real lifecycle).
- Server codes (via `BillingFailure.serverCode`):
`REACTIVATION_CONFIRMATION_REQUIRED` → coded result for the host to
re-preview and resend with `confirm_reactivation`; `ALREADY_CANCELED` /
`NOT_SCHEDULED_FOR_CANCELLATION` from a 4xx → already-in-requested-state
success after a status re-read (a 5xx echoing the code stays a failure,
as in `useWorkspaceBilling.isAlreadyInRequestedState`);
`NO_ACTIVE_SUBSCRIPTION` → coded error. Command-level codes live in
`SubscriptionCommandCode`; `BillingErrorCode` is untouched.
- Every succeeded outcome (settled operation or already-in-state)
invalidates the capabilities read and re-reads credits and status (so
`cancel_at` is available after a cancel). A failed credits read never
turns a success into a failure.
- `idempotency_key` goes in every subscribe/resubscribe/cancel body and
as `idempotencyKey` on the `BillingRequest` (the transport's 401 replay
gate), one key per attempt. The portal request carries neither (the
contract has no key; a portal session is not a mutation).
- `openPaymentPortal` returns `{ url }` after `validateActionUrl` (https
only); the SDK never opens it and does not refresh anything on it.
- Raw server / provider text (`message`, `error_message`) never reaches
a result; asserted in the decline, 5xx, coded-error, and resubscribe
(`message` field) tests.

Tests (32, one per ticket row): the {FREE, PRO active, PRO canceled} ×
{subscribe, resubscribe, cancel, portal} matrix including
subscribe→resubscribe routing; saved payment method (4); 3DS through
`driveEmbeddedChallenge`, hosted page, missing page; declines and
reactivation; both cancel response shapes and the 5xx echo; transport
failure, malformed 2xx, 5xx, failed eligibility read; reconciliation;
and reload/resume, poll timeout, and workspace supersession through the
real lifecycle with fake timers.

## Review focus

- Subscribe reads status once for eligibility and `lifecycle.begin`
reads it again for its own pending gate: two `GET /billing/status` per
subscribe. Avoiding it would need a core change (letting `begin` accept
a status), which this PR deliberately does not make.
- Per the eligibility doc, a PRO-active subscribe is a no-op regardless
of `plan_slug`; a plan change on an active subscription (the app's
`checkoutType: 'change'`) is therefore not reachable through this
command yet. Flagged, not silently decided.
- A `needs_payment_method` without a URL is refused without adopting the
id; the backend still reports it as pending, so the next
`begin`/`recover` adopts it rather than reissuing.

Ticket vs generated contract:
- The ticket's resubscribe "`active` → sync success without an id" is
unreachable: `zResubscribeResponse.billing_op_id` is required, so the id
is adopted uniformly.
- `zPaymentPortalRequest` has no `idempotency_key`; the portal POST is
sent without one.

## AS-IS / TO-BE

No UI surface, no screenshots.

AS-IS: subscription commands live in the cloud app (`workspaceApi`,
`useSubscriptionCheckout`, `useWorkspaceBilling`) with their own
polling, pending-checkout storage, and error-string handling.

TO-BE: `@comfyorg/account/billing` exports `createBillingCommands`;
hosts issue commands and render the lifecycle state, never own the
machine, and never see server text.

## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
dante01yoon added a commit that referenced this pull request Sep 15, 2026
…FE-2214) (#17689)

FE-2214's done-when says all three current top-up hosts can integrate
the top-up command. #17657 covers ComfyUI_frontend's route (`POST
/api/billing/topup`, an operation to poll). Workshop (`apps/website`)
and Platform ship on the other route, `POST
/api/billing/topup/checkout`: a provider-hosted Checkout session with no
`billing_op_id`, credits landing through a webhook. That route could not
be decoded with generated schemas until the ingest-types regen #17396
merged; it now carries `CreateTopupCheckoutRequest` /
`CreateTopupCheckoutResponse`, so this is the 3A-2 follow-up recorded on
FE-2214.

Stacked on #17657 (FE-2214 top-up command); merge after it.

`createTopupCommand` gains a second method on the same surface,
`createHostedTopupCheckout({ amountCents, returnUrl, signal? })`:

- input is validated by the generated `zCreateTopupCheckoutRequest`;
`INVALID_AMOUNT` / `INVALID_RETURN_URL` are returned before anything is
sent
- the same capability gate as the in-app command (`ACCESS_DENIED`
carrying the server's denial), then the pre-purchase balance is read
- one idempotency key per attempt, in the body and on the request; a 404
maps to `NOT_AVAILABLE` so a host keeps its legacy path while
`topup_checkout_enabled` is off
- `checkout_url` must be https (`validateActionUrl`, the same rule every
lifecycle continuation obeys), otherwise `MALFORMED_RESPONSE`;
`session_id` passes through when present
- nothing is adopted on the lifecycle and no operation id is invented
(FE-2214 invariant): the result is `{ url, sessionId?, baselineMicros?
}`. The host executes its `OpenUrlMode` on `url` (Workshop pre-opens a
tab, Platform redirects) and on return arms the existing
`createBalanceWatch` with `baselineMicros`, which is how the test proves
completion

`readTopupEligibility` (from the fallow split on #17657) now returns the
two failures it can actually produce, which is what lets the hosted
result union exclude `NO_PAYMENT_METHOD`.

AS-IS: `TopupCommand` exposes `createTopupCheckout` only; Workshop keeps
its own `createTopUpCheckout` fetch with a hand-written `zTopUpCheckout`
schema, and Platform its own.
TO-BE: `TopupCommand` exposes `createHostedTopupCheckout` over the
generated contract; a host adapter is a thin wrapper (validate → gate →
POST → open → balance watch). No UI in this PR, so no screenshots; the
consumer cutover for Workshop is a separate slice.

Eight new tests under `createHostedTopupCheckout` in `topup.test.ts`:
success shape, request body and idempotency key, and no lifecycle
operation; `can_top_up` false without a POST; amount and return-URL
rejection without a request; 404 → `NOT_AVAILABLE`; missing or non-https
URL → `MALFORMED_RESPONSE`; optional session id and baseline omitted
when unknown; baseline handed to a balance watch that reconciles on
return; no server or provider text on the failure path. Billing core
suite 187 passing; oxlint, eslint, oxfmt, `vue-tsc` clean.

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442 · ingest-types regen #17396"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up command<br/>#17657"]
  A --> A2["FE-2214 3A-2 hosted top-up checkout<br/>this PR"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  A2 -.-> WS["Workshop adapter over createHostedTopupCheckout<br/>later slice"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe (FE-2331)"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  H --> H8["FE-2331 Phase 8 hosted surfaces"]
```

Design: [Billing SDK implementation plan
(V2)](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8).
Linear: FE-2214.
@dante01yoon

Copy link
Copy Markdown
Collaborator Author

Closing: #17658 (with #17659 squashed into it) merged into the Phase 3 core branch, so #17657 rebased onto that core now carries the full Phase 3 content and this merge ref has nothing left to hold. #17662 and #17664 are retargeted onto #17657's branch.

dante01yoon added a commit that referenced this pull request Sep 15, 2026
…4) (#17657)

## Why

Stacked on PR 0 (`jaewon/fe-2227-core-error-codes-and-challenge-driver`,
#17656) → #17655 (FE-2227); merge after both.

Phase 3A of the billing SDK: the top-up command mapped onto the shared
operation lifecycle, covering both routes cloud exposes today. Only
request/response mapping lives here — the status-read gate,
single-flight, polling, routing, the pointer, failure meaning, and
telemetry all come from the lifecycle in #17655/#17656 and are not
duplicated.

- Linear: https://linear.app/comfyorg/issue/FE-2214

## How

`packages/account/src/core/billing/topup.ts` — `createTopupCommand({
transport, lifecycle, capabilities, credits, idempotencyKey? })`
returning two commands on one surface:

**`createTopupCheckout({ amountCents, signal? })`** — the in-app route
ComfyUI_frontend uses (`POST /billing/topup`, an operation to observe):

1. `capabilities.read()` → `can_top_up === false` ⇒ `{ status: 'error',
code: 'ACCESS_DENIED', denial? }` without a POST. The server flag is the
only gate; nothing is derived.
2. Amount validated with `zCreateTopupRequest`; the plain input object
is what travels (the schema coerces to bigint, which the transport
cannot serialize).
3. One fresh key per POST attempt, in the body (`idempotency_key`) and
as `idempotencyKey` on the `BillingRequest`. Supplying that key is what
makes the POST replayable at the transport's 401 gate (`replayable =
method === 'GET' || idempotencyKey !== undefined`): the single 401
replay is safe *because* the same key travels in both places for the
backend to deduplicate on. Backend dedup is load-bearing on this route,
not incidental. A fresh key is minted per attempt, so two user-initiated
top-ups never collide.
4. POST through `lifecycle.begin('topup', issue)`; the response is
decoded with `zCreateTopupResponse` and its `billing_op_id` adopted
regardless of `status`, so the first poll settles synchronous results
and carries the coded decline.
5. Command-level `TopupResult` union: `ok` (terminal `succeeded` state
embedded + `creditsReconciled`), `declined` (terminal `failed` state
embedded: `declineReason`, `recoveryAction`, `retryable`), `unsettled`
(`timed_out` / `reconciliation_needed` embedded), plus `error` codes —
the core `BillingErrorCode`s untouched, and `NOT_AVAILABLE` (404 on the
POST), `NO_PAYMENT_METHOD` (`serverCode`, with `recoveryAction:
'replace_payment_method'`), `INVALID_AMOUNT` (below the generated
minimum; nothing sent). A `superseded` operation passes through as
`SUPERSEDED`.
6. On `succeeded`: `capabilities.invalidate()` and a credits re-read;
`creditsReconciled` compares it with the read taken before the POST.

**`createHostedTopupCheckout({ amountCents, returnUrl, signal? })`** —
the hosted route Workshop (`apps/website`) and Platform ship on (`POST
/billing/topup/checkout`, a provider-hosted Checkout session with no
operation; credits land through a webhook). Decodable since the
ingest-types regen #17396 merged:

1. Input validated by the generated `zCreateTopupCheckoutRequest`;
`INVALID_AMOUNT` / `INVALID_RETURN_URL` before anything is sent.
2. The same capability gate, then the pre-purchase balance is read.
3. One idempotency key per attempt, in the body and on the request; 404
→ `NOT_AVAILABLE` so a host keeps its legacy path while
`topup_checkout_enabled` is off.
4. `checkout_url` must be https (`validateActionUrl`, the rule every
lifecycle continuation obeys), otherwise `MALFORMED_RESPONSE`;
`session_id` passes through when present.
5. Nothing is adopted on the lifecycle and no operation id is invented:
the result is `{ url, sessionId?, baselineMicros? }`. The host executes
its `OpenUrlMode` on `url` (Workshop pre-opens a tab, Platform
redirects) and on return arms `createBalanceWatch` with
`baselineMicros`.

`packages/account/src/core/billing/balanceWatch.ts` —
`createBalanceWatch({ credits, baselineMicros? })`, the framework-free
port of `src/composables/billing/topupBalanceRefresh.ts` (gaps `[0, 2,
5, 10, 20]s`, 15-minute lifetime, 5 scheduled runs, a single read per
wake past the cap). No document listeners: the host calls `wake()` from
its own focus/visibility signals. This is the completion path for the
hosted command and the explicit fallback when no `billing_op_id` can be
observed on the in-app one; the SDK never invents one.

Raw server / Stripe text never reaches a result (asserted in the tests).

Contract findings (generated contract wins; for FE-2211's TDD-correction
list):

- The ticket's `returnUrl` and "no `billing_op_id`" rows describe the
hosted route, not `zCreateTopupRequest` (which has only `amount_cents`,
`checkout_attempt_id`, `idempotency_key`). They are served by
`createHostedTopupCheckout`.
- `zCreateTopupResponse.billing_op_id` is required, so the in-app
command's balance-watch fallback is tested against a
`MALFORMED_RESPONSE` on the POST, not an invented id.
- The plan's `credits.read({ forceRefresh })` does not exist:
`CreditsReader.read` always requests, so it is called plainly.
- `amount_cents` is `z.coerce.bigint()` on both request schemas;
validated with `safeParse`, sent as the number.
- `ErrorResponse.code` is `z.string()`, not an enum, so
`NO_PAYMENT_METHOD` is an SDK-owned allowlist entry.

Tests (`topup.test.ts`, `balanceWatch.test.ts`), one per ticket row for
the in-app command: `can_top_up` false, saved payment method, needs 3DS
(driven through PR 0's `driveEmbeddedChallenge`), no payment method,
declined, unexpected error, payment received with credits pending, 404 →
`NOT_AVAILABLE` (and a 404 while polling left to the lifecycle), fresh
idempotency key per attempt, in the body and on the request,
generated-schema rejection, invalidation on success, scope supersession
passthrough, no-`billing_op_id` balance-watch fallback. For the hosted
command: success shape with request body, idempotency key, and no
lifecycle operation; `can_top_up` false without a POST; amount and
return-URL rejection without a request; 404 → `NOT_AVAILABLE`; missing
or non-https URL → `MALFORMED_RESPONSE`; optional session id and
baseline omitted when unknown; baseline handed to a balance watch that
reconciles on return; no server text on the failure path. Reload/resume,
routing, timeout, and duplicate-poll coverage stays in the core suite.

## AS-IS / TO-BE

No UI surface, no screenshots.

- AS-IS: the SDK exposes the lifecycle but no command issues a top-up on
it; the cloud app's `workspaceApi.createTopup` + `topupBalanceRefresh`,
Workshop's `createTopUpCheckout` fetch with a hand-written schema, and
Platform's own call remain the only paths.
- TO-BE: `@comfyorg/account/billing` exports `createTopupCommand`
(in-app and hosted top-up over the generated contract) and
`createBalanceWatch`; each host adapter is a thin wrapper that reads a
coded, text-free result. Consumer cutovers are separate slices
(ComfyUI_frontend: #17665; Workshop and Platform: later).

## Stack (2026-09-15)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing. The hosted command (formerly #17689) is squashed into this
PR.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>#17436 · #17442 · ingest-types regen #17396"] --> C["FE-2227 Phase 3 core<br/>#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>#17656"]
  P0 --> A["FE-2214 top-up commands, in-app + hosted<br/>#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>#17659"]
  A --> I["Integration, do not merge<br/>#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>#17663"]
  I --> SES["core: narrowed BillingSession type<br/>#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>#17665"]
  A -.-> WS["Workshop adapter over createHostedTopupCheckout<br/>consumer slice"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe (FE-2331)"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  BW["billing-web #17370 → #17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  H --> H8["FE-2331 Phase 8 hosted surfaces"]
```
pull Bot pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Sep 15, 2026
…nt (FE-2227) (Comfy-Org#17655)

## Why

Phase 3 Core of the billing half of `@comfyorg/account`
([FE-2210](https://linear.app/comfyorg/issue/FE-2210) /
[FE-2227](https://linear.app/comfyorg/issue/FE-2227/phase-3-core-sdk-owned-billing-operation-lifecycle-routing-recovery)):
the one operation lifecycle the top-up (FE-2214) and subscription
(FE-2223) commands sit on, so neither implements its own poller,
reducer, routing, or recovery.

## Where this sits in the plan

Plan: [Billing SDK implementation plan
(V2)](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8). Layer
TDD: [Centralized Hosted Billing
Application](https://app.notion.com/p/3d76d73d36508181951dfaa4f71dc8e5).

| Phase | Issue | Deliverable | State |
| --- | --- | --- | --- |
| 1 | [FE-2212](https://linear.app/comfyorg/issue/FE-2212) | Billing
ports and transport on the merged session client | Merged — Comfy-Org#17436 |
| 2 | [FE-2213](https://linear.app/comfyorg/issue/FE-2213) | Read path:
status, capabilities, credits | Merged — Comfy-Org#17442 |
| 3 Core | [FE-2227](https://linear.app/comfyorg/issue/FE-2227) |
Operation lifecycle, routing, recovery, fallback | **this PR** |
| 3A | [FE-2214](https://linear.app/comfyorg/issue/FE-2214) | Top-up
command on the lifecycle | Open — Comfy-Org#17657 |
| 3B | [FE-2223](https://linear.app/comfyorg/issue/FE-2223) |
Subscription commands and the eight-state projection | Open — Comfy-Org#17658 →
Comfy-Org#17659 |

No consumer and no flag: nothing in the app imports this yet.

## How

- `operationState.ts`: `BillingOperationState`, a discriminated union
over one `billing_op_id` (`pending | succeeded | failed | timed_out |
reconciliation_needed | superseded`), and the pure
`reduceBillingOperation` transition. The identity, including
`presentation`, is fixed at adoption; switching embedded ↔ hosted is an
event on the same operation, never a replacement. The transition decodes
the generated `zBillingOpStatusResponse` and reads only the coded
`decline_reason` / `recovery_action` — `error_message` is never read, so
no Stripe or server text can reach a consumer.
- `operationPolicy.ts`: the cadence (1s × 1.5 → 8s cap; 30s flat once
parked on the customer) and the poll budgets (120s; 5 min for
subscription discovery; 23h once the customer is involved), ported from
`billingOperationStore`.
- `operationPointer.ts`: the tab-local pointer, keyed by `(userId,
workspaceId)`, over a host-supplied storage port. The Comfy-Org#16120 rule
survives: a client timeout keeps the pointer, settlement clears it.
- `presentation.ts`: `selectBillingPresentation`, the single routing
decision. Embedded only when the host reports it can drive a challenge
and `billing_rail === 'stripe'`; a command response that carries a page
and no challenge is hosted regardless.
- `operationLifecycle.ts`: `createBillingOperationLifecycle` — `begin`
(single-flight per kind; the Phase 2 status read gates every start and a
backend-pending operation of the same kind is adopted instead of issued
again), `recover` (server pending op first, then the pointer), `wake`,
`switchPresentation`, `reportChallengeStarted/Settled`, `settled`, and
the `billing.operation.*` telemetry.

## Review focus

1. **Effects are declared, not performed.** The core never opens a URL,
drives 3DS, or listens to a document. A host renders `actionUrl` /
`challenge`, performs the effect, and reports back; visibility and focus
arrive as `wake()`. This is what keeps the ticket's "no host framework
or navigation side effect" true by construction rather than by import
guard.
2. **Fail closed toward hosted, and toward not charging.** Routing falls
to hosted on every unknown (no rail, legacy rail, host cannot embed).
`begin` refuses to issue when the status read fails; `recover` falls
back to the pointer only on `REQUEST_FAILED`, since an unreachable
server is not "nothing pending".
3. **No-operation-id reconciliation.** When the status reports nothing
pending but a pointer exists, one read decides: `404` drops the pointer
without observing; a settled answer terminalizes from that single read;
a still-pending answer (a `cancel`, which status cannot report) is
observed from it rather than fetched twice.
4. **Supersession is a terminal state.** A workspace or session change
marks every pending operation `superseded`, and a response landing after
the change is discarded rather than applied. `ACCESS_DENIED` /
`NOT_AUTHENTICATED` mid-poll land there too. The pointer stays under the
old scope's key so a return recovers it.
5. **Departures from the app store, deliberately.** The "nothing was
charged" safety copy is not modelled: the generated contract has no
`no_charge_confirmed`, so the SDK cannot claim it. The eight public
states are not projected here; 3A/3B own that. The transport is the
Phase 1 `BillingTransport`, so the Layer TDD's HttpOnly-cookie transport
swaps in underneath without touching this file.

## AS-IS / TO-BE

AS-IS: no shared lifecycle — `billingOperationStore` owns polling,
recovery, and routing inside the app, and each Phase 3 command would
have to reimplement them.
TO-BE: one exported `createBillingOperationLifecycle` in
`@comfyorg/account/billing` that commands adopt an id into. No UI
surface, so no screenshots.

## Testing

`packages/account` suite 468/468 (this PR adds 44). Typecheck, oxlint,
eslint, oxfmt, knip clean.

Named tests per the ticket's done-when: resume (`recover` × server
pending / pointer / unreachable status), duplicate-poll prevention
(`wake` joins the poll in flight), scope and session supersession
(workspace change with a late response; sign-out), timeout (budget kept
with pointer; budget widened once the customer is involved),
terminalization (coded decline reason, no server text; reconciliation on
`404`), presentation switching with a stable `billing_op_id` (challenge
fails → hosted → rollback, one `issue` call), hosted fallback refused
without a URL, no-operation-id reconciliation, and telemetry (`started`
/ terminal with `presentation`, `resumed`, `failure_category`).

Manual: none, and none is meaningful — no consumer, no UI surface.

## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>Comfy-Org#17436 · Comfy-Org#17442"] --> C["FE-2227 Phase 3 core<br/>Comfy-Org#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>Comfy-Org#17656"]
  P0 --> A["FE-2214 top-up command<br/>Comfy-Org#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>Comfy-Org#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>Comfy-Org#17659"]
  A --> I["Integration, do not merge<br/>Comfy-Org#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>Comfy-Org#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>Comfy-Org#17663"]
  I --> SES["core: narrowed BillingSession type<br/>Comfy-Org#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>Comfy-Org#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web Comfy-Org#17370 → Comfy-Org#17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
pull Bot pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Sep 15, 2026
…y-Org#17664)

## Why

Stacked on the Phase 3 integration ref
(`jaewon/fe-2227-phase3-integration`, Comfy-Org#17660); merge after Phase 3.
Found while wiring the first in-app consumer (FE-2216): the app's
session client is `SessionClient<TUser>` for its own user type, and the
identity seam is contravariant in that user, so every billing factory
that demanded the full base `SessionClient` rejected the host's client.
Without this, Phase 5 cannot hand the merged session client to the SDK
at all.

## How

One type, `BillingSession = Pick<SessionClient, 'getSnapshot' |
'subscribe' | 'ensureFresh' | 'remint'>`, names the four members the
billing core actually reaches for. The transport, the scope tracker, the
three readers, and the lifecycle take `BillingSession` instead of
`SessionClient`. Type-only; no runtime change, no test change needed
(the existing fakes already satisfy the narrower type). Pulled out of
the FE-2216 branch so the core change is reviewed on its own and the
consumer PR stays app-only.

## AS-IS / TO-BE

AS-IS: `createSessionBillingTransport({ session:
workspaceAuthStore.getUnifiedSessionClient() })` fails to typecheck for
a host whose user type is narrower than `AccountUser`.
TO-BE: any client exposing the four members is accepted. No UI surface,
no screenshots.

## Testing

`packages/account` suite unchanged and green; typecheck, oxlint, eslint,
oxfmt clean.



## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>Comfy-Org#17436 · Comfy-Org#17442"] --> C["FE-2227 Phase 3 core<br/>Comfy-Org#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>Comfy-Org#17656"]
  P0 --> A["FE-2214 top-up command<br/>Comfy-Org#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>Comfy-Org#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>Comfy-Org#17659"]
  A --> I["Integration, do not merge<br/>Comfy-Org#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>Comfy-Org#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>Comfy-Org#17663"]
  I --> SES["core: narrowed BillingSession type<br/>Comfy-Org#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>Comfy-Org#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web Comfy-Org#17370 → Comfy-Org#17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
pull Bot pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Sep 15, 2026
…ience (FE-2215) (Comfy-Org#17662)

## Why

Stacked on the Phase 3 integration branch
(`jaewon/fe-2227-phase3-integration`, PR 0 + Comfy-Org#17657 + Comfy-Org#17659); retarget
`main` once Phase 3 lands.

Phase 4 of the billing SDK track: the core in
`@comfyorg/account/billing` is framework-free by construction, so the
Vue composables that present it need a package of their own. This PR
scaffolds it and ships the composables; the unstyled `CheckoutSteps`
component follows in the stacked PR
Comfy-Org#17663 to keep this
one reviewable.

- Linear: https://linear.app/comfyorg/issue/FE-2215
- Name decision: the ticket left `@comfyorg/account-ui` vs
`@comfyorg/billing-ui` open. Picked **`@comfyorg/account-ui`** — it is
the view half of `@comfyorg/account` and will also be the natural home
for the sign-in pieces if they ever leave `@comfyorg/account/vue`
(explicitly out of scope here).

## How

New package `packages/account-ui` (`@comfyorg/account-ui`, private,
`workspace:*`), entry `./billing` only. Modelled on `packages/account`:
same tsconfig, `lint`/`typecheck` scripts, `vue` + `@vueuse/core` as
peers, `@comfyorg/account` as a real dependency. `@comfyorg/account`
gains no Vue dependency and is not modified.

Registration: `knip.config.ts` workspace, root
`lint`/`lint:no-cache`/`typecheck` scripts (`typecheck:account-ui`), and
the license workflow's `--excludePackages` list (a private package
reports as UNLICENSED, same as `@comfyorg/account`). Root
`tsconfig.json` has no `references` array; the eslint resolver already
globs `./packages/*/tsconfig.json`, and vitest already globs
`packages/**`.

Contents (`src/billing/`), ported from the PoC `vue/billing.ts` and
re-seated on the merged core API:

- `billingClient.ts` — `BillingClient` (lifecycle + capabilities +
credits + topup command + subscription commands), `BILLING_CLIENT_KEY`,
`provideBillingClient`, `useBillingClient`. Every composable takes an
explicit client or falls back to the injected one.
- `useBillingOperation(selector, client?)` — subscribes to
`BillingOperationLifecycle` once, selects by `{ id }` or `{ kind }`
(newest of that kind, so a resumed operation is picked up from the
snapshot), unsubscribes on scope end via `tryOnScopeDispose`.
- `useTopUp(options)` — the headless top-up over `createTopupCommand` +
`driveEmbeddedChallenge` + `projectPaymentStep`. Exposes
`canTopUp`/`denial` read from the server's capabilities snapshot
(undefined until read, never derived locally), host-owned
`presetsCents`/`minAmountCents`/`maxAmountCents`/`creditsPerDollar` (an
amount outside the host bounds returns `INVALID_AMOUNT` without reaching
the core), `amountCents`, `submitting`, `result`, the eight-state
`projection`,
`submit`/`retry`/`preview`/`cancel`/`reset`/`continueVerification`. A
hosted continuation goes to the host's `openUrl(url, mode)` with `mode:
'new_tab' | 'redirect' | 'preopened'` (host picks the mode via
`navigationMode`); an embedded challenge is driven through the host's
`challengePort`. No router, no window, no Stripe here.
- `useCheckout(options)` — the same attempt machinery over
`createBillingCommands`: `subscribe`, `resubscribe`, `retry` (resends
the last request), `openPaymentPortal` (resolves the URL and hands it to
`openUrl`). `cancelSubscription` is not a checkout and stays on
`client.commands`.
- `useCredits(options)` — balance in micros as the core reports it,
`loading`, `failure` (a failed refresh keeps the last balance),
`refresh`.
- `usePaymentAttempt` (internal) — what top-up and checkout share: the
followed operation, the projection over it, the host-reported step, the
once-per-continuation effect. A host-reported cancel outranks a pending
operation; `reset` drops only a settled one from view, never a live one.

Copy: nothing here renders text. The projection carries coded keys only;
`CheckoutSteps` (next PR) resolves them through
`createPaymentCopy`/`paymentCopyKeys`.

Tests (vitest + @testing-library/vue, 12 tests) run the real core over a
scripted transport (`__fixtures__/billingHarness.ts`): `can_top_up`
gating with the coded denial and no POST, host bounds outside the core,
hosted continuation opened once in the configured mode and again on
`continueVerification`, embedded challenge driven through the port with
a capabilities re-read after settlement, coded decline with no provider
text in result/projection/operation, cancel/reset semantics,
provide/inject resolution, scope-end unsubscribe.

## AS-IS / TO-BE

No UI surface, no screenshots.

- AS-IS: the billing core has no Vue consumer; every host would
re-derive operation tracking, projection, continuation, and gating.
- TO-BE: `@comfyorg/account-ui/billing` exposes the headless top-up and
checkout experiences; hosts supply navigation, the challenge port,
presets, bounds, and copy.

## Notes for review

- Non-test source is ~556 lines; `CheckoutSteps` is split into the
stacked PR to stay under the ~600 guard.
- `useCredits` reads once on setup by default (`immediate: false` to opt
out).
- `useTopUp` does not gate `submit` on the cached `canTopUp`; the core
re-reads capabilities itself, and the cached value exists to disable the
CTA.



## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>Comfy-Org#17436 · Comfy-Org#17442"] --> C["FE-2227 Phase 3 core<br/>Comfy-Org#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>Comfy-Org#17656"]
  P0 --> A["FE-2214 top-up command<br/>Comfy-Org#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>Comfy-Org#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>Comfy-Org#17659"]
  A --> I["Integration, do not merge<br/>Comfy-Org#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>Comfy-Org#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>Comfy-Org#17663"]
  I --> SES["core: narrowed BillingSession type<br/>Comfy-Org#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>Comfy-Org#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web Comfy-Org#17370 → Comfy-Org#17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
pull Bot pushed a commit to Mu-L/ComfyUI_frontend that referenced this pull request Sep 15, 2026
…flag (FE-2216) (Comfy-Org#17665)

## Why

Stacked on Comfy-Org#17664 (the type-only `BillingSession` core change this
consumer surfaced, split out of this PR) on top of the Phase 3
integration branch (`jaewon/fe-2227-phase3-integration`); slice 1 of
FE-2216, top-up only; flag default off, so an unflagged build sees no
behavior change.

First in-app consumer of `@comfyorg/account/billing`: with
`billing_sdk_topup_enabled` on, top-up creation, hosted/in-page
verification, resume, and the balance/capability refresh run on the
SDK's operation lifecycle instead of `billingOperationStore`'s poller.
Existing billing test suites are untouched and pass.

Linear: https://linear.app/comfyorg/issue/FE-2216

## How

- `billing_sdk_topup_enabled`: server flag resolved fail-closed,
declared exactly like `embeddedCheckoutEnabled` (enum, getter, telemetry
evaluation).
- Composition root
`src/platform/workspace/billing/sdk/createBillingSdk.ts` (ports in, SDK
out): `createSessionBillingTransport` over the auth store's one
`SessionClient` with `resolveUrl = workspaceApiUrl` and the store's own
mint target, the three Phase 2 readers,
`createBillingOperationLifecycle` with `pointerStorage: sessionStorage`,
`embeddedCheckoutAvailable = embeddedCheckoutEnabled &&
VITE_STRIPE_PUBLISHABLE_KEY`, the top-up command, and `driveChallenge`
over a lazily loaded `loadStripe` port.
- `useBillingSdkStore` (Pinia, once per app) wires it: one
`visibilitychange`/`focus` handler calling `lifecycle.wake()`, the SDK
telemetry mapped onto `trackBillingEvent`'s `operation` shape
(`billingSdkTelemetry.ts`), progress toast, one auto-driven in-page
challenge per operation, and, for an operation this tab reattached to,
the refresh / dialog close / settings open / toast the poller performs
today.
- `topupOperationView.ts` projects SDK state onto the operation record
the dialog reads and `TopupResult` onto the `CreateTopupResponse` it
handles (`ok` → `completed`, `declined` → `failed`, refusals →
`WorkspaceApiError` with the code, so the dialog's `NO_PAYMENT_METHOD`
copy still fires).
- `useWorkspaceBilling.topup()` and its pending-op recovery in
`fetchStatus()` branch on the flag; the flag-off body is unchanged. The
dialog consults `useTopupOperation()` for `isAddingCredits` /
`topupActionOperation` / retry / dismiss (6 lines in the script;
`handleBuy` untouched) — projecting into the poller's store would have
started its own polling loop on the same id.
- `workspaceAuthStore` exposes `getUnifiedSessionClient()` and
`getUnifiedMintWorkspaceId()`; no second session client.
- Package (type-only): `BillingSession = Pick<SessionClient,
'getSnapshot' | 'subscribe' | 'ensureFresh' | 'remint'>` replaces
`SessionClient` in the billing option types. The app's client is
`SessionClient<User>` and `attachIdentity` is contravariant in the user,
so the first real consumer could not be typed against the full client.
- Tests: dual-path suites for the wrapper
(`useWorkspaceBilling.sdk.test.ts`), the dialog adapter, the store, the
projections, the telemetry mapping, and the composition root over a fake
session + `fetch` (bearer, idempotency key, mint target, pointer
storage, port-driven challenge). Flag test mirrors
`embeddedCheckoutEnabled`.

Not routed through the SDK without touching call sites (listed, not
faked):

- `topup_id`: the SDK surfaces only `billing_op_id`; the projected
response carries `topup_id: ''`. Nothing reads it.
- Unsettled outcomes (`timed_out`, `reconciliation_needed`): the wrapper
resolves `undefined`, which the dialog reports as `failure_category:
'unknown'` rather than the poller's `operation.timeout` /
`reconciliation_needed`. The timeout toast still shows and the
reconciliation id stays visible through the operation view.
- Refusals without an HTTP status (`NO_PAYMENT_METHOD` — the SDK drops
the status; capability denial; invalid amount; route absent) are
bucketed `network` by `categorizeBillingApiError` instead of
`api_rejected`. Follow-up for 3C: carry `httpStatus` on
`TopupNoPaymentMethod`.
- Telemetry for a dialog-issued top-up is emitted by the dialog exactly
as before; the SDK's events are forwarded only for `resumed` operations.
If `begin` adopts a backend-pending top-up under a dialog click, both
report it.
- Resume is triggered from `fetchStatus()` only when the server reports
a pending top-up; the tab pointer alone (server unreachable) is not
probed on load.
- The rail is fixed when the dialog opens; a flag flip mid-operation
does not move a live operation between observers.
- Failure toast detail for SDK refusals is the generic
`credits.topUp.unknownError` copy (no server text, by design); an
unloadable Stripe port fails the challenge with the generic
authentication copy rather than `authenticationUnavailable`.
- The wrapper does not hold `isLoading` on the SDK path (it resolves at
settlement); the dialog locks itself.

Size: ~560 new non-test lines + ~115 modified (27 in the package). The
composition root is 115 lines; the Pinia wiring is the bulk. Splitting
root + package narrowing + auth accessors + flag into a flag-less parent
PR is possible if preferred.

## AS-IS / TO-BE

No UI surface change, no screenshots.

- AS-IS: `topup()` posts through `workspaceApi`, the dialog hands a
`pending` id to `billingOperationStore`, which polls, drives Stripe, and
refreshes.
- TO-BE (flag on): `topup()` runs
`createTopupCommand(...).createTopupCheckout` on the SDK lifecycle; the
dialog reads the same operation shape from `useTopupOperation()`; the
SDK store owns wake, challenge, toast, and resumed-operation effects.
Flag off: byte-identical call path.



## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>Comfy-Org#17436 · Comfy-Org#17442"] --> C["FE-2227 Phase 3 core<br/>Comfy-Org#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>Comfy-Org#17656"]
  P0 --> A["FE-2214 top-up command<br/>Comfy-Org#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>Comfy-Org#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>Comfy-Org#17659"]
  A --> I["Integration, do not merge<br/>Comfy-Org#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>Comfy-Org#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>Comfy-Org#17663"]
  I --> SES["core: narrowed BillingSession type<br/>Comfy-Org#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>Comfy-Org#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web Comfy-Org#17370 → Comfy-Org#17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
pull Bot pushed a commit to Mu-L/ComfyUI_frontend that referenced this pull request Sep 15, 2026
…(FE-2215) (Comfy-Org#17663)

## Why

Stacked on the FE-2215 composables PR
(`jaewon/fe-2215-phase-4-new-view-package-for-billing-composables-and`),
itself stacked on the Phase 3 integration branch
(`jaewon/fe-2227-phase3-integration`, PR 0 + Comfy-Org#17657 + Comfy-Org#17659); retarget
once each parent lands.

Second half of Phase 4: the unstyled `CheckoutSteps` component, split
out of the composables PR to keep both under the size guard.

- Linear: https://linear.app/comfyorg/issue/FE-2215

## How

`packages/account-ui/src/billing/CheckoutSteps.vue`, ported from the PoC
`vue/CheckoutSteps.ts` onto the merged `PaymentProjection` +
`paymentCopyKeys`/`createPaymentCopy`:

- Takes the `projection` (eight-state, from `useTopUp`/`useCheckout`), a
`copy` prop of host-localized overrides by approved `PaymentCopyKey`,
`disabled`, and class props (`rootClass`, `headerClass`, `bodyClass`,
`reasonClass`, `safetyClass`, `actionsClass`, `actionClass`) the way
`PasswordRules`/`SocialAuthButtons` do.
- Renders header, body, the coded reason when the projection carries
one, and the safety line only when the projection's `noChargeConfirmed`
unlocks it (a host override of that line is ignored by
`createPaymentCopy`).
- Default actions per step from the approved copy: `verifying` →
continue verification, `declined`/`processing_error`/`canceled` → retry.
Emits `retry`, `cancel`, `continue-verification`;
`header`/`body`/`actions` slots receive the projection, copy key/text,
and the callbacks so a host lays out its own controls.
- Raw backend or provider text can never reach the template: every
string is looked up by key in the copy table.

Adds `@testing-library/user-event` to the package devDependencies
(lockfile updated) and the two index exports.

Tests (6): approved copy with host overrides and class props, safety
line gated by the projection only, default actions and their emits, no
action on success / nothing while disabled, slot scope and callbacks.

## AS-IS / TO-BE

No styled UI surface, no screenshots (the component is unstyled by
design; `data-billing-step` and `data-copy-key` attributes are the only
markers).

- AS-IS: hosts render the projection themselves.
- TO-BE: one shared unstyled section per projection state with the
approved coded copy, styled and laid out by each host.



## Stack (2026-09-14)

Merge top-down. After a parent is squash-merged, rebase each child with
`git rebase --onto origin/main <parent tip>` and force-push; GitHub
retargets the base. Solid edges are code dependencies, dashed edges are
sequencing.

```mermaid
flowchart TD
  P12["Phase 1 + 2 merged<br/>Comfy-Org#17436 · Comfy-Org#17442"] --> C["FE-2227 Phase 3 core<br/>Comfy-Org#17655 · base main"]
  C --> P0["PR 0 coded error bodies + 3DS driver<br/>Comfy-Org#17656"]
  P0 --> A["FE-2214 top-up command<br/>Comfy-Org#17657"]
  P0 --> B1["FE-2223 B1 subscription commands<br/>Comfy-Org#17658"]
  B1 --> B2["FE-2223 B2 eight-state projection<br/>Comfy-Org#17659"]
  A --> I["Integration, do not merge<br/>Comfy-Org#17660"]
  B2 --> I
  I --> V1["FE-2215 @comfyorg/account-ui composables<br/>Comfy-Org#17662"]
  V1 --> V2["FE-2215 CheckoutSteps<br/>Comfy-Org#17663"]
  I --> SES["core: narrowed BillingSession type<br/>Comfy-Org#17664"]
  SES --> AD1["FE-2216 slice 1 top-up behind a flag<br/>Comfy-Org#17665"]
  AD1 -.-> AD2["FE-2216 slice 2 subscription<br/>needs previewSubscribe + plan-change decision"]
  AD1 --> E["FE-2217 Phase 6 evidence"]
  S["FE-2211 salvage tag d059104<br/>before 2026-09-30"] -.-> E
  BW["billing-web Comfy-Org#17370 → Comfy-Org#17574"] --> H["FE-2218 Phase 7 separate origin"]
  AD1 --> H
  V2 -.-> H
  AD1 -.-> SPLIT["account-core / account-ui rename PR"]
  SPLIT -.-> H
```
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