Repository navigation
FE-2216 feat(billing): cancel, resubscribe and the payment portal on the SDK rail behind billing_sdk_subscription_enabled - #17853
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 2022 passed, 0 failed · 2 flaky📊 Browser Reports
📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-09-16T21:14:51.777Z",
"gitSha": "62fd084eb7a198523994c6b2382f9c62b639b4ea",
"branch": "jaewon/fe-2216-subscription-rail",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 1993.6870000000226,
"styleRecalcs": 7,
"styleRecalcDurationMs": 6.4639999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 334.84099999999995,
"heapDeltaBytes": 25251484,
"heapUsedBytes": 86688828,
"domNodes": 14,
"jsHeapTotalBytes": 4718592,
"scriptDurationMs": 8.412000000000003,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2002.7330000000347,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.810000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 358.143,
"heapDeltaBytes": 2749420,
"heapUsedBytes": 65340872,
"domNodes": -262,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 8.236,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1824.0779999999859,
"styleRecalcs": 78,
"styleRecalcDurationMs": 26.964000000000002,
"layouts": 14,
"layoutDurationMs": 4.22,
"taskDurationMs": 836.9720000000001,
"heapDeltaBytes": -1783612,
"heapUsedBytes": 60936492,
"domNodes": -263,
"jsHeapTotalBytes": 4448256,
"scriptDurationMs": 160.95,
"eventListeners": -186,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1883.3579999999301,
"styleRecalcs": 77,
"styleRecalcDurationMs": 27.197000000000003,
"layouts": 14,
"layoutDurationMs": 4.473,
"taskDurationMs": 845.6720000000001,
"heapDeltaBytes": 8858032,
"heapUsedBytes": 71372388,
"domNodes": -262,
"jsHeapTotalBytes": 5758976,
"scriptDurationMs": 166.481,
"eventListeners": -156,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1665.1679999999942,
"styleRecalcs": 32,
"styleRecalcDurationMs": 14.646999999999998,
"layouts": 6,
"layoutDurationMs": 1.1170000000000002,
"taskDurationMs": 259.819,
"heapDeltaBytes": 2191148,
"heapUsedBytes": 64633152,
"domNodes": 77,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 9.995000000000001,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1707.9029999999875,
"styleRecalcs": 31,
"styleRecalcDurationMs": 14.955000000000002,
"layouts": 6,
"layoutDurationMs": 1.9709999999999996,
"taskDurationMs": 332.813,
"heapDeltaBytes": 2119288,
"heapUsedBytes": 64816332,
"domNodes": 74,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 10.632000000000003,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 615.6760000000077,
"styleRecalcs": 12,
"styleRecalcDurationMs": 8.693,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 443.72299999999996,
"heapDeltaBytes": 18291952,
"heapUsedBytes": 80224680,
"domNodes": 20,
"jsHeapTotalBytes": 5767168,
"scriptDurationMs": 163.92499999999998,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 645.9210000000439,
"styleRecalcs": 12,
"styleRecalcDurationMs": 8.023000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 449.68699999999995,
"heapDeltaBytes": 17810108,
"heapUsedBytes": 80561584,
"domNodes": 20,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 171.47400000000002,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2037.778000000003,
"styleRecalcs": 6,
"styleRecalcDurationMs": 5.297,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 565.027,
"heapDeltaBytes": 2863640,
"heapUsedBytes": 83038396,
"domNodes": -248,
"jsHeapTotalBytes": -1843200,
"scriptDurationMs": 31.17199999999999,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2017.9620000000114,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.568999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 543.3730000000002,
"heapDeltaBytes": 3138620,
"heapUsedBytes": 83491684,
"domNodes": -252,
"jsHeapTotalBytes": -1843200,
"scriptDurationMs": 30.540000000000013,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2152.8749999999945,
"styleRecalcs": 65,
"styleRecalcDurationMs": 9.714000000000004,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1563.6910000000003,
"heapDeltaBytes": 18832976,
"heapUsedBytes": 83462872,
"domNodes": 6,
"jsHeapTotalBytes": 487424,
"scriptDurationMs": 817.1,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-pan",
"durationMs": 2246.66000000002,
"styleRecalcs": 68,
"styleRecalcDurationMs": 15.630999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1672.6970000000001,
"heapDeltaBytes": -5132772,
"heapUsedBytes": 75617288,
"domNodes": -224,
"jsHeapTotalBytes": 2052096,
"scriptDurationMs": 852.9409999999999,
"eventListeners": -182,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-zoom",
"durationMs": 3547.02599999996,
"styleRecalcs": 62,
"styleRecalcDurationMs": 10.837,
"layouts": 60,
"layoutDurationMs": 12.711,
"taskDurationMs": 1694.3799999999999,
"heapDeltaBytes": 8718400,
"heapUsedBytes": 74781756,
"domNodes": 4,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 809.2729999999999,
"eventListeners": 10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "large-graph-zoom",
"durationMs": 3560.6160000000955,
"styleRecalcs": 63,
"styleRecalcDurationMs": 12.437000000000003,
"layouts": 60,
"layoutDurationMs": 12.785000000000002,
"taskDurationMs": 1719.8639999999998,
"heapDeltaBytes": -16752444,
"heapUsedBytes": 65677316,
"domNodes": -267,
"jsHeapTotalBytes": 5234688,
"scriptDurationMs": 790.8729999999999,
"eventListeners": -188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "legacy-node-drag",
"durationMs": 3169.308000000001,
"styleRecalcs": 44,
"styleRecalcDurationMs": 11.34,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1949.446,
"heapDeltaBytes": -12588676,
"heapUsedBytes": 71163644,
"domNodes": -232,
"jsHeapTotalBytes": 1564672,
"scriptDurationMs": 1003.501,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3036.091000000056,
"styleRecalcs": 40,
"styleRecalcDurationMs": 4.740999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1868.884,
"heapDeltaBytes": 20817956,
"heapUsedBytes": 86974284,
"domNodes": 0,
"jsHeapTotalBytes": 679936,
"scriptDurationMs": 958.8760000000001,
"eventListeners": 188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2015.0350000000117,
"styleRecalcs": 5,
"styleRecalcDurationMs": 7.84,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 567.223,
"heapDeltaBytes": -3822212,
"heapUsedBytes": 83986548,
"domNodes": -248,
"jsHeapTotalBytes": -495616,
"scriptDurationMs": 33.944,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2018.9619999999877,
"styleRecalcs": 5,
"styleRecalcDurationMs": 3.937999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 551.206,
"heapDeltaBytes": -4072348,
"heapUsedBytes": 83645108,
"domNodes": -251,
"jsHeapTotalBytes": -1806336,
"scriptDurationMs": 33.937999999999995,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 560.0369999999657,
"styleRecalcs": 47,
"styleRecalcDurationMs": 10.491999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 387.74399999999997,
"heapDeltaBytes": 13530508,
"heapUsedBytes": 77341924,
"domNodes": 20,
"jsHeapTotalBytes": 6029312,
"scriptDurationMs": 137.382,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 576.6760000000204,
"styleRecalcs": 47,
"styleRecalcDurationMs": 11.061,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 397.32800000000003,
"heapDeltaBytes": 14072760,
"heapUsedBytes": 77448184,
"domNodes": 20,
"jsHeapTotalBytes": 5767168,
"scriptDurationMs": 142.68499999999997,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 2007.3600000000056,
"styleRecalcs": 10,
"styleRecalcDurationMs": 8.603000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 454.63199999999995,
"heapDeltaBytes": 3469248,
"heapUsedBytes": 66838860,
"domNodes": -276,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 7.341999999999998,
"eventListeners": -200,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 1996.7649999999821,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.394999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 450.56600000000003,
"heapDeltaBytes": -5841136,
"heapUsedBytes": 58086920,
"domNodes": -276,
"jsHeapTotalBytes": 5234688,
"scriptDurationMs": 7.210000000000001,
"eventListeners": -230,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1691.7119999999954,
"styleRecalcs": 78,
"styleRecalcDurationMs": 25.526,
"layouts": 18,
"layoutDurationMs": 5.202,
"taskDurationMs": 762.814,
"heapDeltaBytes": -5278088,
"heapUsedBytes": 58512340,
"domNodes": -275,
"jsHeapTotalBytes": 5758976,
"scriptDurationMs": 105.35300000000001,
"eventListeners": -200,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1713.5530000000472,
"styleRecalcs": 77,
"styleRecalcDurationMs": 26.317999999999998,
"layouts": 18,
"layoutDurationMs": 4.898,
"taskDurationMs": 773.8620000000001,
"heapDeltaBytes": 8054972,
"heapUsedBytes": 71963504,
"domNodes": -276,
"jsHeapTotalBytes": 5758976,
"scriptDurationMs": 112.40299999999999,
"eventListeners": -202,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-transition-enter",
"durationMs": 1367.4060000000168,
"styleRecalcs": 16,
"styleRecalcDurationMs": 28.970999999999997,
"layouts": 5,
"layoutDurationMs": 12.847000000000001,
"taskDurationMs": 883.9530000000002,
"heapDeltaBytes": 17882884,
"heapUsedBytes": 96198624,
"domNodes": 13587,
"jsHeapTotalBytes": 11010048,
"scriptDurationMs": 37.919999999999995,
"eventListeners": 2387,
"totalBlockingTimeMs": 136,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8437.729999999989,
"styleRecalcs": 248,
"styleRecalcDurationMs": 34.806000000000004,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 5771.523,
"heapDeltaBytes": -3454672,
"heapUsedBytes": 76250356,
"domNodes": -248,
"jsHeapTotalBytes": 217088,
"scriptDurationMs": 2764.063,
"eventListeners": -138,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.669999999999952,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8307.332999999971,
"styleRecalcs": 248,
"styleRecalcDurationMs": 34.099,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 5678.873,
"heapDeltaBytes": -3714632,
"heapUsedBytes": 75632784,
"domNodes": -245,
"jsHeapTotalBytes": -831488,
"scriptDurationMs": 2737.1100000000006,
"eventListeners": -138,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 16789.58499999999,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16280.463999999998,
"heapDeltaBytes": -44498360,
"heapUsedBytes": 178155076,
"domNodes": -8061,
"jsHeapTotalBytes": -16191488,
"scriptDurationMs": 259.18,
"eventListeners": -14924,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.779999999999927,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 16619.995000000017,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16047.594999999998,
"heapDeltaBytes": -47265540,
"heapUsedBytes": 184014520,
"domNodes": -8061,
"jsHeapTotalBytes": -11341824,
"scriptDurationMs": 276.43899999999996,
"eventListeners": -14926,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.77333333333336,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 20100.092999999957,
"styleRecalcs": 159,
"styleRecalcDurationMs": 16.16199999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 19747.324,
"heapDeltaBytes": -40485008,
"heapUsedBytes": 190027564,
"domNodes": -8061,
"jsHeapTotalBytes": -11673600,
"scriptDurationMs": 877.9749999999999,
"eventListeners": -14922,
"totalBlockingTimeMs": 83,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 20130.890999999905,
"styleRecalcs": 171,
"styleRecalcDurationMs": 16.352000000000004,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 19819.521,
"heapDeltaBytes": -48691540,
"heapUsedBytes": 167802480,
"domNodes": -8061,
"jsHeapTotalBytes": -12886016,
"scriptDurationMs": 868.907,
"eventListeners": -14920,
"totalBlockingTimeMs": 104,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-node-resize-workload",
"durationMs": 6053.2590000000255,
"styleRecalcs": 20,
"styleRecalcDurationMs": 85.13800000000002,
"layouts": 20,
"layoutDurationMs": 23.416000000000007,
"taskDurationMs": 5923.554,
"heapDeltaBytes": -38094960,
"heapUsedBytes": 194451976,
"domNodes": -8061,
"jsHeapTotalBytes": 16142336,
"scriptDurationMs": 108.61299999999999,
"eventListeners": -14923,
"totalBlockingTimeMs": 475,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-node-resize-workload",
"durationMs": 6069.210999999996,
"styleRecalcs": 20,
"styleRecalcDurationMs": 77.00299999999999,
"layouts": 20,
"layoutDurationMs": 21.936999999999998,
"taskDurationMs": 5955.098999999999,
"heapDeltaBytes": -35699864,
"heapUsedBytes": 175412044,
"domNodes": -8061,
"jsHeapTotalBytes": 17756160,
"scriptDurationMs": 112.85000000000001,
"eventListeners": -14924,
"totalBlockingTimeMs": 405,
"frameDurationMs": 18.886666666666617,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8442.389999999989,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8223.273,
"heapDeltaBytes": -3012816,
"heapUsedBytes": 170865028,
"domNodes": 0,
"jsHeapTotalBytes": -25165824,
"scriptDurationMs": 132.96099999999998,
"eventListeners": -14,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.220000000000073,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8364.962999999989,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8127.913000000001,
"heapDeltaBytes": 22598072,
"heapUsedBytes": 180704480,
"domNodes": 0,
"jsHeapTotalBytes": -7602176,
"scriptDurationMs": 131.27799999999996,
"eventListeners": -12,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.219999999999953,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "workflow-execution",
"durationMs": 117.21399999998994,
"styleRecalcs": 8,
"styleRecalcDurationMs": 20.770999999999997,
"layouts": 4,
"layoutDurationMs": 2.236,
"taskDurationMs": 98.577,
"heapDeltaBytes": 3220036,
"heapUsedBytes": 65390528,
"domNodes": 136,
"jsHeapTotalBytes": 524288,
"scriptDurationMs": 9.228,
"eventListeners": 33,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 105.8540000000221,
"styleRecalcs": 8,
"styleRecalcDurationMs": 13.127,
"layouts": 2,
"layoutDurationMs": 0.7050000000000001,
"taskDurationMs": 78.72900000000003,
"heapDeltaBytes": 3031488,
"heapUsedBytes": 65081636,
"domNodes": 108,
"jsHeapTotalBytes": 262144,
"scriptDurationMs": 6.251999999999999,
"eventListeners": 33,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
}
]
}🔬 E2E Coverage
Top 10 files by uncovered lines
|
Playwright videos for new testsDownload the recorded videos and HTML report Recorded projects: cloud Recorded test titles:
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## jaewon/fe-2210-hosted-destination-port #17853 +/- ##
==========================================================================
+ Coverage 82.61% 83.65% +1.03%
==========================================================================
Files 2876 2195 -681
Lines 142573 126223 -16350
Branches 38491 33956 -4535
==========================================================================
- Hits 117793 105588 -12205
+ Misses 23552 20346 -3206
+ Partials 1228 289 -939
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 696 files with indirect coverage changes 🚀 New features to boost your workflow:
|
christian-byrne
left a comment
There was a problem hiding this comment.
Two things I came to check, one clean and one that becomes a real gap the moment this rebases.
The 401 path is right
openPaymentPortal is still the non-idempotent POST with no idempotency key, so the transport leaves it alone and codeForHttpStatus takes the authenticationRetrySkipped branch to REQUEST_FAILED. That is the #17658 fix doing its job on the route that opened the seam in the first place.
Worth noting it now has a sibling it does not take: authenticationNotRenewable → NOT_AUTHENTICATED is for the credentialed transport, and the cloud app is on the session transport, so the two stay properly distinct rather than collapsing into one 401 rule.
Nothing tells the saved-cards list that the portal changed it
This branch predates #17798 — packages/account/src/core/billing/paymentMethods.ts is not in its tree, and 17798's merge is not in its history. So this is not something you could have wired here, and I am not reporting it as a defect in the diff as it stands.
But this PR has to rebase onto main to land, and on main that reader exists with this on it:
Drops the published list without a scope change. A payment-portal round trip adds or removes a card outside this reader, so the host that sent the user there is the only thing that knows the list it holds is now wrong.
billingSdkStore.openPaymentPortal is now exactly that host. It hands back a URL, the user goes off and adds or deletes a card, and comes back to an app still holding the pre-portal list. invalidate() was built for this case and named it explicitly, and after the rebase there will be a caller that sends the user to the portal and never calls it.
I would not try to detect the return — there is no reliable signal, and the same problem on the top-up side is what #17771 is about. Invalidating when the portal URL is handed out is the cheap and honest version: the list is possibly stale from that moment, and the next read refetches. Slightly eager, never wrong.
Worth deciding deliberately rather than on the rebase, because a rebase is exactly where this kind of cross-PR obligation gets lost — the file appears, nothing references it, and no test fails.
Also checked
projectPaymentPortalResultreturnsresult.value.urland routes failures throughprojectFailure, so no server text reaches the rail.subscriptionRouteAvailablelatching tofalseon anunavailableoutcome means a 404 rollout answer is remembered rather than re-probed on every click. Good.- The flag is conjunctive with the rail, consistent with how
billing_sdk_topup_enabledwas handled on #17665.
Holding approval on the invalidation question only. CI is green.
…mands (FE-2216) Adds the billing_sdk_subscription_enabled server flag and the rail switch that pairs it with unified cloud auth, and wires createBillingCommands into the app's one SDK composition so the host can reach cancel, resubscribe and the payment portal.
|
Confirmed, and checked rather than taken on faith: it is real, and it is not fixable on this head.
Agreed on the shape: invalidate when the URL is handed out, in I'll land it in the rebase commit itself rather than as a follow-up, so the case you describe — the file appears, nothing references it, no test fails — cannot pass silently. No code change on this head. |
…rail (FE-2216) The SDK store gains the three subscription actions, projected onto what the workspace adapter already does with the legacy calls. A 404 means the backend gate is still closed, so that route is handed back once and stays handed back for the tab. The lifecycle now owns telemetry for a cancel or resubscribe, which no dialog reports on this rail.
…rail (FE-2216) cancel, resubscribe and manageSubscription read the rail once, before their first await, and hold it for the whole action. With the flag off the legacy bodies run unchanged; a rail that declines an action falls through to them.
Both rails POST the same route, so the recorded request is what separates them: only the SDK transport sends an Idempotency-Key header. Covers flag off, flag on, and the 404 that sends the action back to the legacy call.
0fa33aa to
6d037db
Compare
4bc331e to
659194e
Compare
…2216) The payment portal adds or removes a card outside the reader, and nothing tells this tab which. Invalidate the saved-card list when the portal URL is handed out, which is the last moment the list is known good.
|
Landed in 4dd35a7, now that the rebase onto main brought the reader in.
Two tests in |
christian-byrne
left a comment
There was a problem hiding this comment.
The finding is closed, and the comment says it better than my review did:
// The portal may add or remove a card and says nothing on the way back, so
// handing the URL out is the last moment this tab's list is known good.
if (outcome.status === 'ok') sdk.paymentMethods.invalidate()I argued for invalidating at hand-out on the grounds that it is eager but never wrong. "The last moment this tab's list is known good" is the actual reason, and it generalises — anyone adding a third surface that sends the user somewhere it cannot observe now has the rule rather than the instance.
Gating on outcome.status === 'ok' is a refinement I did not suggest and should have: a portal that failed to open changed nothing, so dropping the list there would be a free refetch for no reason.
Also confirmed the rebase landed you on post-#17798 main, which is what made sdk.paymentMethods reachable at all — the thing I flagged as most likely to be lost in exactly that rebase.
Not approving only because test is still in progress. Given this PR adds the new invalidate() wiring and a new end-to-end cancel spec, that is the one check I would not approve around. Nothing outstanding from me otherwise — ping me or just let it go green and I will pick it up next pass.
|
Test got passed, merge into stacked parent PR |
c8ab581
into
jaewon/fe-2210-hosted-destination-port
|
Green on 4dd35a7 — 84 pass, 14 skipped, nothing failing or in flight. Pinging as offered — it is yours whenever you get to it. |
…the SDK rail behind billing_sdk_subscription_enabled (#17853) Stacked on #17783 (base branch `jaewon/fe-2210-hosted-destination-port`); merge that first. Phase 5 slice 1 (#17665) moved top-up onto the Billing SDK behind `billing_sdk_topup_enabled`. The subscription actions the host already owns — cancel, resubscribe, and opening the payment portal — still call the workspace API directly and rely on the legacy poller for settlement and telemetry. This slice moves those three onto the SDK's commands behind their own server flag, `billing_sdk_subscription_enabled` (already on `/api/features` via Comfy-Org/cloud#9248, PostHog at 0%), so the eight-state lifecycle, idempotency, recovery and telemetry come from one implementation. Subscribe and plan change are slice 2b, stacked on this PR. - **Rail switch.** `billingSdkSubscriptionRailEnabled` = `billing_sdk_subscription_enabled` AND `unified_cloud_auth`, exactly like the top-up rail. `useSubscriptionRail()` reads it once, synchronously, at the start of an action, so a flag flip mid-flow cannot issue on one rail and observe on the other. - **Three actions, one adapter.** `useWorkspaceBilling.cancelSubscription / resubscribe / manageSubscription` try the rail first; the store runs `sdk.commands.cancelSubscription()`, `resubscribe()`, `openPaymentPortal({ returnUrl })` and projects the result onto what the adapter already does with the legacy calls: settle, or throw a `WorkspaceApiError` (message is the host's, since the SDK never carries server text; `serverCode` lands in `.code`). A command that settles in any phase but `succeeded` is a failure, matching the poller. The refresh after success mirrors the poller's: cancel → status + balance + capabilities; resubscribe → `reconcileSubscriptionSuccess` + capabilities. - **Fallback.** A 404 (backend gate closed while the client flag is on) projects to `unavailable`: the adapter runs its legacy body for that action, and the store latches the route as unavailable for the tab so later actions go straight to legacy without another failed round trip. Every other failure — including `SUPERSEDED` — is thrown, never retried on legacy, so a late or superseded result cannot double-issue. - **Telemetry.** Lifecycle events are now reported for non-topup operations (top-up keeps its resumed-only filter because its dialog reports). `toBillingTelemetryEvent` already emits the poller's payload shape, so dashboards cannot tell the rails apart. - **No client-derived server state.** Eligibility and already-held answers come from the SDK and the server, as for top-up. `subscribe`, `previewSubscribe`, `useSubscriptionCheckout` and `useLegacyBilling` are untouched. | State | AS-IS (flag off) | TO-BE (flag on) | | --- | --- | --- | | Cancel dialog at rest | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-dialog.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-dialog.png"> | | Cancel in flight | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-in-flight.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-in-flight.png"> | | Cancel settled (success toast) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-settled.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-settled.png"> | | Cancel failed (error toast) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-failed.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-failed.png"> | | User popover after cancel (cancelled state) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-panel-after-cancel.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-panel-after-cancel.png"> | | Cancel request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-network.png"> | | Settings billing panel | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-billing-panel.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-billing-panel.png"> | | Resubscribe (Resume Pro) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-resubscribe.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-resubscribe.png"> | | Resubscribe request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-resubscribe-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-resubscribe-network.png"> | | Payment-portal request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-portal-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-portal-network.png"> | - AS-IS (flag off): cancel / resubscribe / portal POST the workspace API directly; settlement and telemetry come from the legacy poller. - TO-BE (flag on): the same dialogs and toasts, the POSTs go through the SDK transport (`Idempotency-Key` on the request), settlement through the operation lifecycle; a 404 falls back to the legacy call. | Gate | Result | | --- | --- | | `vitest run src/platform/workspace/billing src/composables/billing src/platform/workspace/composables src/platform/workspace/stores src/composables/useFeatureFlags` | 41 files, 1138 tests (12 new projection tests, 13 new adapter rail tests, +5 store tests) | | `pnpm typecheck`, `pnpm typecheck:browser`, `lint`, `format:check`, `knip` | exit 0 | | `fallow audit --changed-since origin/jaewon/fe-2210-hosted-destination-port` | no issues in 11 changed files, complexity 0, duplication 0 | | Playwright `browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts` (cloud project) | **3 passed** against a served cloud dev build — `PLAYWRIGHT_TEST_URL=http://localhost:5173 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts --reporter=list`. Flag off → legacy request, flow unchanged; flag on → SDK request (`Idempotency-Key`), same dialog outcome; flag on + 404 → legacy fallback. | Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 1-2 | Session core, transport, readers | FE-2211/2212/2213 | merged | | 3 | Operation lifecycle, commands, eight-state projection | FE-2227/2214/2223 | merged (#17655) | | 4 | `@comfyorg/account-ui` composables + `CheckoutSteps` | FE-2215 | merged (#17662, #17663) | | 5 slice 1 | Top-up through the SDK behind `billing_sdk_topup_enabled` | FE-2216 | merged (#17665) | | rollout C | `hosted_billing_destination` server flag read by the host | FE-2218 | merged (#17716) | | rollout C | `hostedDestination` port on the lifecycle, value on operation state | FE-2210/2218 | #17783 (review; parent of this PR) | | 7 prep | Scope-source port + credentialed transport (BFF / cookie hosts) | FE-2218 | merged (#17782) | | 7 prep | `@comfyorg/account` → `@comfyorg/account-core` rename | FE-2218 | #17851 (review) | | 7 prep | `billing-contract` route builder + `return_to` registry | FE-2218 | merged (#17795) | | 3A-3 | Workshop adapter over `createHostedTopupCheckout` | FE-2214 | merged (#17793) | | 8 core | `previewSubscribe` command | FE-2331 | merged (#17797) | | 8 core | Plans + saved payment-methods readers | FE-2331 | #17798 (queued) | | 8 ui | account-ui composables (`usePlans`, `usePaymentMethods`, `usePreviewSubscribe`) | FE-2331 | #17798 (queued) | | 7 | billing-web own-origin session, sign-in, SDK composition | FE-2218 | #17798 (queued) | | 7 | billing-web unit tests in CI (`ci-billing-web-unit.yaml`) | FE-2218 | merged (#17827); #17844 (queued) | | 7 | ingest CORS + top-up return hosts for billing.comfy.org and its previews (Comfy-Org/cloud) | FE-2218 | merged (Comfy-Org/cloud#9512) | | 8 ui | billing-web `/v1` entry routing + subscription / payment-method surfaces | FE-2331 | #17798 (queued) | | 7 | npm publish (`ingest-types`, `account-core`, `billing-contract`), Platform install, billing-web live top-up | FE-2218 | todo | | 6 | Contract tests per generated schema (package layer) | FE-2217 | | 6 | Live E2E per flow × consumer + evidence table | FE-2217 | todo (needs staging flags) | | 5 slice 2a | Cancel, resubscribe and payment portal through the SDK behind `billing_sdk_subscription_enabled` | FE-2216 | **this PR** | | 5 slice 2b | Subscribe / plan change through the SDK (`previewSubscribe` quote, then subscribe; the SDK stops short-circuiting an active plan) | FE-2216 | next, stacked on this PR | | follow-up | One `needsCustomerAttention` predicate (from the #17665 review) | FE-2216 | merged (#17792) | | follow-up | Opaque `BillingServerCode` (from the #17656 review) | FE-2227 | merged (#17794) | | follow-up | `useCredits` clears on `SUPERSEDED` (from the #17799 review) | FE-2215 | merged (#17824) | | follow-up | credits / status / capabilities readers fence a late failure as `SUPERSEDED` (from the #17798 review) | FE-2331 | merged (#17828) | ```mermaid flowchart LR P3["Phase 3 core lifecycle (merged)"] P4["Phase 4 account-ui (merged)"] P5["Phase 5 slice 1 top-up flag (merged)"] FC["PR 17716 hosted_billing_destination flag (merged)"] HD["PR 17783 hostedDestination port"] SS["PR 17782 scope-source port + credentialed transport"] RN["account-core rename"] RB["billing-contract route builder + return_to"] WS["Workshop adapter"] P8PV["previewSubscribe command"] P8RD["plans + payment-methods readers"] P8["account-ui hosted composables"] BWS["billing-web session + sign-in"] BWV["billing-web /v1 surfaces"] CORS["cloud PR 9512 ingest CORS + return hosts"] PUB["npm publish account-core / billing-contract"] P7["Phase 7 host proof: Platform + billing-web live"] P6C["Phase 6 contract tests"] P6["Phase 6 live evidence"] S2A["Phase 5 slice 2a cancel / resubscribe / portal rail"] S2B["Phase 5 slice 2b subscribe + plan change"] FU9["customer-attention predicate"] FU11["opaque BillingServerCode"] FU12["useCredits clears on SUPERSEDED"] FU13["reader late-failure fence"] P3 --> HD FC --> HD HD --> RB P3 --> SS SS --> P7 RB --> P7 P3 --> RN RN --> PUB RB --> PUB PUB --> P7 P3 --> P8PV P3 --> P8RD P8PV --> P8 P8RD --> P8 P4 --> P8 P8 --> S2B HD --> S2A S2A --> S2B P8 --> BWS BWS --> BWV RB --> BWV BWV --> P7 CORS --> P7 P5 --> P6 P3 --> P6C P5 --> WS P5 --> FU9 P3 --> FU11 P4 --> FU12 P3 --> FU13 style P3 fill:#d4edda,stroke:#155724 style P4 fill:#d4edda,stroke:#155724 style P5 fill:#d4edda,stroke:#155724 style FC fill:#d4edda,stroke:#155724 style SS fill:#d4edda,stroke:#155724 style RB fill:#d4edda,stroke:#155724 style WS fill:#d4edda,stroke:#155724 style FU9 fill:#d4edda,stroke:#155724 style FU11 fill:#d4edda,stroke:#155724 style FU12 fill:#d4edda,stroke:#155724 style FU13 fill:#d4edda,stroke:#155724 style CORS fill:#d4edda,stroke:#155724 style P8PV fill:#d4edda,stroke:#155724 style S2A stroke:#0366d6,stroke-width:4px ```
…the SDK rail behind billing_sdk_subscription_enabled (#17853) Stacked on #17783 (base branch `jaewon/fe-2210-hosted-destination-port`); merge that first. Phase 5 slice 1 (#17665) moved top-up onto the Billing SDK behind `billing_sdk_topup_enabled`. The subscription actions the host already owns — cancel, resubscribe, and opening the payment portal — still call the workspace API directly and rely on the legacy poller for settlement and telemetry. This slice moves those three onto the SDK's commands behind their own server flag, `billing_sdk_subscription_enabled` (already on `/api/features` via Comfy-Org/cloud#9248, PostHog at 0%), so the eight-state lifecycle, idempotency, recovery and telemetry come from one implementation. Subscribe and plan change are slice 2b, stacked on this PR. - **Rail switch.** `billingSdkSubscriptionRailEnabled` = `billing_sdk_subscription_enabled` AND `unified_cloud_auth`, exactly like the top-up rail. `useSubscriptionRail()` reads it once, synchronously, at the start of an action, so a flag flip mid-flow cannot issue on one rail and observe on the other. - **Three actions, one adapter.** `useWorkspaceBilling.cancelSubscription / resubscribe / manageSubscription` try the rail first; the store runs `sdk.commands.cancelSubscription()`, `resubscribe()`, `openPaymentPortal({ returnUrl })` and projects the result onto what the adapter already does with the legacy calls: settle, or throw a `WorkspaceApiError` (message is the host's, since the SDK never carries server text; `serverCode` lands in `.code`). A command that settles in any phase but `succeeded` is a failure, matching the poller. The refresh after success mirrors the poller's: cancel → status + balance + capabilities; resubscribe → `reconcileSubscriptionSuccess` + capabilities. - **Fallback.** A 404 (backend gate closed while the client flag is on) projects to `unavailable`: the adapter runs its legacy body for that action, and the store latches the route as unavailable for the tab so later actions go straight to legacy without another failed round trip. Every other failure — including `SUPERSEDED` — is thrown, never retried on legacy, so a late or superseded result cannot double-issue. - **Telemetry.** Lifecycle events are now reported for non-topup operations (top-up keeps its resumed-only filter because its dialog reports). `toBillingTelemetryEvent` already emits the poller's payload shape, so dashboards cannot tell the rails apart. - **No client-derived server state.** Eligibility and already-held answers come from the SDK and the server, as for top-up. `subscribe`, `previewSubscribe`, `useSubscriptionCheckout` and `useLegacyBilling` are untouched. | State | AS-IS (flag off) | TO-BE (flag on) | | --- | --- | --- | | Cancel dialog at rest | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-dialog.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-dialog.png"> | | Cancel in flight | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-in-flight.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-in-flight.png"> | | Cancel settled (success toast) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-settled.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-settled.png"> | | Cancel failed (error toast) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-cancel-failed.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-cancel-failed.png"> | | User popover after cancel (cancelled state) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-panel-after-cancel.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-panel-after-cancel.png"> | | Cancel request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-network.png"> | | Settings billing panel | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-billing-panel.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-billing-panel.png"> | | Resubscribe (Resume Pro) | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-resubscribe.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-resubscribe.png"> | | Resubscribe request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-resubscribe-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-resubscribe-network.png"> | | Payment-portal request recorded | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/as-is-portal-network.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17853-screenshots/screenshots/to-be-portal-network.png"> | - AS-IS (flag off): cancel / resubscribe / portal POST the workspace API directly; settlement and telemetry come from the legacy poller. - TO-BE (flag on): the same dialogs and toasts, the POSTs go through the SDK transport (`Idempotency-Key` on the request), settlement through the operation lifecycle; a 404 falls back to the legacy call. | Gate | Result | | --- | --- | | `vitest run src/platform/workspace/billing src/composables/billing src/platform/workspace/composables src/platform/workspace/stores src/composables/useFeatureFlags` | 41 files, 1138 tests (12 new projection tests, 13 new adapter rail tests, +5 store tests) | | `pnpm typecheck`, `pnpm typecheck:browser`, `lint`, `format:check`, `knip` | exit 0 | | `fallow audit --changed-since origin/jaewon/fe-2210-hosted-destination-port` | no issues in 11 changed files, complexity 0, duplication 0 | | Playwright `browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts` (cloud project) | **3 passed** against a served cloud dev build — `PLAYWRIGHT_TEST_URL=http://localhost:5173 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts --reporter=list`. Flag off → legacy request, flow unchanged; flag on → SDK request (`Idempotency-Key`), same dialog outcome; flag on + 404 → legacy fallback. | Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 1-2 | Session core, transport, readers | FE-2211/2212/2213 | merged | | 3 | Operation lifecycle, commands, eight-state projection | FE-2227/2214/2223 | merged (#17655) | | 4 | `@comfyorg/account-ui` composables + `CheckoutSteps` | FE-2215 | merged (#17662, #17663) | | 5 slice 1 | Top-up through the SDK behind `billing_sdk_topup_enabled` | FE-2216 | merged (#17665) | | rollout C | `hosted_billing_destination` server flag read by the host | FE-2218 | merged (#17716) | | rollout C | `hostedDestination` port on the lifecycle, value on operation state | FE-2210/2218 | #17783 (review; parent of this PR) | | 7 prep | Scope-source port + credentialed transport (BFF / cookie hosts) | FE-2218 | merged (#17782) | | 7 prep | `@comfyorg/account` → `@comfyorg/account-core` rename | FE-2218 | #17851 (review) | | 7 prep | `billing-contract` route builder + `return_to` registry | FE-2218 | merged (#17795) | | 3A-3 | Workshop adapter over `createHostedTopupCheckout` | FE-2214 | merged (#17793) | | 8 core | `previewSubscribe` command | FE-2331 | merged (#17797) | | 8 core | Plans + saved payment-methods readers | FE-2331 | #17798 (queued) | | 8 ui | account-ui composables (`usePlans`, `usePaymentMethods`, `usePreviewSubscribe`) | FE-2331 | #17798 (queued) | | 7 | billing-web own-origin session, sign-in, SDK composition | FE-2218 | #17798 (queued) | | 7 | billing-web unit tests in CI (`ci-billing-web-unit.yaml`) | FE-2218 | merged (#17827); #17844 (queued) | | 7 | ingest CORS + top-up return hosts for billing.comfy.org and its previews (Comfy-Org/cloud) | FE-2218 | merged (Comfy-Org/cloud#9512) | | 8 ui | billing-web `/v1` entry routing + subscription / payment-method surfaces | FE-2331 | #17798 (queued) | | 7 | npm publish (`ingest-types`, `account-core`, `billing-contract`), Platform install, billing-web live top-up | FE-2218 | todo | | 6 | Contract tests per generated schema (package layer) | FE-2217 | | 6 | Live E2E per flow × consumer + evidence table | FE-2217 | todo (needs staging flags) | | 5 slice 2a | Cancel, resubscribe and payment portal through the SDK behind `billing_sdk_subscription_enabled` | FE-2216 | **this PR** | | 5 slice 2b | Subscribe / plan change through the SDK (`previewSubscribe` quote, then subscribe; the SDK stops short-circuiting an active plan) | FE-2216 | next, stacked on this PR | | follow-up | One `needsCustomerAttention` predicate (from the #17665 review) | FE-2216 | merged (#17792) | | follow-up | Opaque `BillingServerCode` (from the #17656 review) | FE-2227 | merged (#17794) | | follow-up | `useCredits` clears on `SUPERSEDED` (from the #17799 review) | FE-2215 | merged (#17824) | | follow-up | credits / status / capabilities readers fence a late failure as `SUPERSEDED` (from the #17798 review) | FE-2331 | merged (#17828) | ```mermaid flowchart LR P3["Phase 3 core lifecycle (merged)"] P4["Phase 4 account-ui (merged)"] P5["Phase 5 slice 1 top-up flag (merged)"] FC["PR 17716 hosted_billing_destination flag (merged)"] HD["PR 17783 hostedDestination port"] SS["PR 17782 scope-source port + credentialed transport"] RN["account-core rename"] RB["billing-contract route builder + return_to"] WS["Workshop adapter"] P8PV["previewSubscribe command"] P8RD["plans + payment-methods readers"] P8["account-ui hosted composables"] BWS["billing-web session + sign-in"] BWV["billing-web /v1 surfaces"] CORS["cloud PR 9512 ingest CORS + return hosts"] PUB["npm publish account-core / billing-contract"] P7["Phase 7 host proof: Platform + billing-web live"] P6C["Phase 6 contract tests"] P6["Phase 6 live evidence"] S2A["Phase 5 slice 2a cancel / resubscribe / portal rail"] S2B["Phase 5 slice 2b subscribe + plan change"] FU9["customer-attention predicate"] FU11["opaque BillingServerCode"] FU12["useCredits clears on SUPERSEDED"] FU13["reader late-failure fence"] P3 --> HD FC --> HD HD --> RB P3 --> SS SS --> P7 RB --> P7 P3 --> RN RN --> PUB RB --> PUB PUB --> P7 P3 --> P8PV P3 --> P8RD P8PV --> P8 P8RD --> P8 P4 --> P8 P8 --> S2B HD --> S2A S2A --> S2B P8 --> BWS BWS --> BWV RB --> BWV BWV --> P7 CORS --> P7 P5 --> P6 P3 --> P6C P5 --> WS P5 --> FU9 P3 --> FU11 P4 --> FU12 P3 --> FU13 style P3 fill:#d4edda,stroke:#155724 style P4 fill:#d4edda,stroke:#155724 style P5 fill:#d4edda,stroke:#155724 style FC fill:#d4edda,stroke:#155724 style SS fill:#d4edda,stroke:#155724 style RB fill:#d4edda,stroke:#155724 style WS fill:#d4edda,stroke:#155724 style FU9 fill:#d4edda,stroke:#155724 style FU11 fill:#d4edda,stroke:#155724 style FU12 fill:#d4edda,stroke:#155724 style FU13 fill:#d4edda,stroke:#155724 style CORS fill:#d4edda,stroke:#155724 style P8PV fill:#d4edda,stroke:#155724 style S2A stroke:#0366d6,stroke-width:4px ```
…act when the hosted destination says billing_web (#17860) Stacked on #17856 (base branch `jaewon/fe-2216-plan-change`) → #17853 → #17783; merge those first. ## Why Rollout layer C (`hosted_billing_destination`, `stripe` | `billing_web`, PostHog at 100% `stripe`) decides where a hosted billing action lands. The plan says the host reads the flag, hands it to the SDK (#17783) and, when it says `billing_web`, mints a `/v1/<intent>` entry with `return_to` from `@comfyorg/billing-contract`, the one definition of that route surface (#17795); when it says `stripe`, the backend's URL is opened unchanged. Today the host only opens the bare billing-web origin from the user popover (#17716) with no intent and no `return_to`, and "Billing & invoices" in the settings panel always goes to the Stripe portal. This is the last un-opened code item before the Phase 7 host proof. ## How - `src/platform/workspace/billing/hostedBillingRoutes.ts`: `hostedBillingRoute(destination, intent)` returns `{ kind: 'billing_web', url }` built by `buildBillingEntryUrl({ billingOrigin, intent, product: 'comfyui', returnTo: 'comfyui_workspace' })`, or `{ kind: 'provider' }` meaning "use the server's URL". The environment is derived, not hardcoded: the cloud base URL's hostname through the existing `resolveDeployEnv` map (`prod-v2 | stg-v2 | test-v2` → `production | staging | test`), which also classifies a local dev session by the backend it talks to. Fails closed to the provider on: no configured origin, an unknown backend family, a return target with no destination in that family, or an entry the contract refuses. A path-prefixed `VITE_BILLING_WEB_URL` keeps its prefix under the minted route. - Consumers: the popover's "Plans and pricing" mints the `pricing` intent (billing-web routes it to the subscription view; the in-app dialog stays the `stripe` behaviour and the popup-blocked fallback); `useWorkspaceBilling.manageSubscription()` mints `payment-methods` **before** either rail is consulted, so on `billing_web` no portal URL is requested on the SDK rail or the legacy one, and `openPortalWindow` + `refreshOnPortalReturn` still run so the return re-reads status, balance and capabilities. - Also fixed on the way: the popover treated a falsy `window.open(…, "noopener,noreferrer")` result as a blocked popup and showed the in-app pricing dialog as a fallback. Per the HTML spec `noopener` always returns `null`, so on `billing_web` the tab and the dialog opened together — a latent defect inherited from #17370 on `main`, caught by this PR's evidence run. The fallback is gone; the E2E `window.open` stub now returns `null` for `noopener` like a browser does, and a popover case covers both destinations. - Left on the provider on purpose: `useSubscriptionCheckout.recoverOutstandingPayment` and the `payment_method_url` steps inside an operation are mid-checkout provider steps, not hosted management; `invoices` and `result` are not served by billing-web yet (`ComingSoonView`), so nothing mints them; the legacy `/customers` rail's `accessBillingPortal` is being retired by the personal-billing flip and is not touched. - `@comfyorg/billing-contract` becomes a root `workspace:*` dependency. The CI cloud build for E2E (`.github/actions/build-cloud-frontend`, used only by `ci-tests-e2e.yaml` and `pr-update-playwright-expectations.yaml`, never by a deploy) gets `VITE_BILLING_WEB_URL=https://billing-web.example`, a reserved origin the spec stubs, reachable only when the server flag says `billing_web`. - No frontend-derived server state: the destination is the flag as-is; the host chooses only the URL shape. ## AS-IS / TO-BE | AS-IS — `hosted_billing_destination: stripe` | TO-BE — `hosted_billing_destination: billing_web` | | --- | --- | | **1. User popover, "Plans and pricing" hovered**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-popover-plans.png"><br>Same menu item, unchanged by the flag. | **1. User popover, "Plans and pricing" hovered**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-popover-plans.png"><br>Same menu item, unchanged by the flag. | | **2. After clicking "Plans and pricing"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-plans-result.png"><br>In-app "Choose a Plan" dialog, no tab opened. | **2. After clicking "Plans and pricing"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-plans-result.png"><br>`billing-web.example/v1/pricing?product=comfyui&return_to=comfyui_workspace` tab opens and nothing else: `window.open` returns `null` under `noopener` as the spec requires, and no in-app dialog is left behind. | | **3. Settings ▸ Workspace ▸ Plan & Credits, before clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-settings-billing.png"><br>Identical panel; the destination is only read on click. | **3. Settings ▸ Workspace ▸ Plan & Credits, before clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-settings-billing.png"><br>Identical panel; the destination is only read on click. | | **4. After clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-manage-result.png"><br>`POST /api/billing/payment-portal` recorded, and the URL it returned (`https://billing.example/portal`) opened. | **4. After clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-manage-result.png"><br>No request to `/api/billing/payment-portal` on either rail; `billing-web.example/v1/payment-methods?product=comfyui&return_to=comfyui_workspace` minted and opened. | | **5. Return trip — refocusing the app tab after the hosted tab opened**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-return-refresh.png"><br>`/api/billing/status`, `/balance` and `/capabilities` re-read. | **5. Return trip — refocusing the app tab after the hosted tab opened**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-return-refresh.png"><br>Same three reads; `openPortalWindow` + `refreshOnPortalReturn` still run on the minted route. | - AS-IS (`stripe`, today's default): popover → in-app pricing dialog; settings → Stripe portal via `POST /billing/payment-portal`. - TO-BE (`billing_web`): popover → `<billing-web>/v1/pricing?product=comfyui&return_to=comfyui_workspace`; settings → `<billing-web>/v1/payment-methods?…`, no portal request on either rail; the app re-reads billing state on return. ## Testing | Gate | Result | | --- | --- | | `vitest run src/platform/workspace src/composables/billing src/composables/useFeatureFlags src/config` | 91 files, 1890 tests (19 new route cases: intent × destination × env × prefix × each fail-closed branch; 3 new adapter cases; 3 popover cases re-pointed) | | `packages/billing-contract` vitest | 3 files, 62 tests | | `pnpm typecheck`, `typecheck:browser`, `lint`, `format`, `knip` | exit 0 | | `fallow audit --changed-since origin/jaewon/fe-2216-plan-change` | no issues in 10 changed files | | `PLAYWRIGHT_TEST_URL=http://localhost:5431 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/hostedBillingDestination.spec.ts --reporter=list`, against `VITE_BILLING_WEB_URL=https://billing-web.example pnpm dev:cloud` | `4 passed (4.6s)` — settings on both destinations, plus the two new avatar-menu cases: `opens the in-app pricing table from the avatar menu while the destination is stripe` and `opens the billing-web pricing entry alone from the avatar menu while the destination is billing_web` | ## Where this sits in the plan Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 1-2 | Session core, transport, readers | FE-2211/2212/2213 | merged | | 3 | Operation lifecycle, commands, eight-state projection | FE-2227/2214/2223 | merged (#17655) | | 4 | `@comfyorg/account-ui` composables + `CheckoutSteps` | FE-2215 | merged (#17662, #17663) | | 5 slice 1 | Top-up through the SDK behind `billing_sdk_topup_enabled` | FE-2216 | merged (#17665) | | rollout C | `hosted_billing_destination` server flag read by the host | FE-2218 | merged (#17716) | | rollout C | `hostedDestination` port on the lifecycle, value on operation state | FE-2210/2218 | #17783 (review) | | 7 prep | Scope-source port + credentialed transport (BFF / cookie hosts) | FE-2218 | merged (#17782) | | 7 prep | `@comfyorg/account` → `@comfyorg/account-core` rename | FE-2218 | #17851 (review) | | 7 prep | `billing-contract` route builder + `return_to` registry | FE-2218 | merged (#17795) | | 3A-3 | Workshop adapter over `createHostedTopupCheckout` | FE-2214 | merged (#17793) | | 8 core | `previewSubscribe` command | FE-2331 | merged (#17797) | | 8 core | Plans + saved payment-methods readers | FE-2331 | merged (#17798) | | 8 ui | account-ui composables (`usePlans`, `usePaymentMethods`, `usePreviewSubscribe`) | FE-2331 | merged (#17798) | | 7 | billing-web own-origin session, sign-in, SDK composition | FE-2218 | merged (#17798) | | 7 | billing-web unit tests in CI (`ci-billing-web-unit.yaml`) | FE-2218 | merged (#17827, #17844) | | 7 | ingest CORS + top-up return hosts for billing.comfy.org and its previews (Comfy-Org/cloud) | FE-2218 | merged (Comfy-Org/cloud#9512) | | 8 ui | billing-web `/v1` entry routing + subscription / payment-method surfaces | FE-2331 | merged (#17798) | | 7 | npm publish (`ingest-types`, `account-core`, `billing-contract`), Platform install, billing-web live top-up | FE-2218 | todo | | 6 | Contract tests per generated schema (package layer) | FE-2217 | #17829 (review) | | 6 | Live E2E per flow × consumer + evidence table | FE-2217 | todo (needs staging flags) | | 5 slice 2a | Cancel, resubscribe and payment portal through the SDK behind `billing_sdk_subscription_enabled` | FE-2216 | #17853 (review) | | 5 slice 2b | Subscribe and plan change through the SDK, priced by the server | FE-2216 | #17856 (review; parent of this PR) | | 7 / rollout C | Host mints billing-web `/v1/<intent>` entries with `return_to` when `hosted_billing_destination` is `billing_web` | FE-2218 | **this PR** | | follow-up | One `needsCustomerAttention` predicate (from the #17665 review) | FE-2216 | merged (#17792) | | follow-up | Opaque `BillingServerCode` (from the #17656 review) | FE-2227 | merged (#17794) | | follow-up | `useCredits` clears on `SUPERSEDED` (from the #17799 review) | FE-2215 | merged (#17824) | | follow-up | credits / status / capabilities readers fence a late failure as `SUPERSEDED` (from the #17798 review) | FE-2331 | merged (#17828) | ```mermaid flowchart LR P3["Phase 3 core lifecycle (merged)"] P4["Phase 4 account-ui (merged)"] P5["Phase 5 slice 1 top-up flag (merged)"] FC["PR 17716 hosted_billing_destination flag (merged)"] HD["PR 17783 hostedDestination port"] SS["PR 17782 scope-source port + credentialed transport"] RN["account-core rename"] RB["billing-contract route builder + return_to"] WS["Workshop adapter"] P8PV["previewSubscribe command"] P8RD["plans + payment-methods readers"] P8["account-ui hosted composables"] BWS["billing-web session + sign-in"] BWV["billing-web /v1 surfaces"] CORS["cloud PR 9512 ingest CORS + return hosts"] PUB["npm publish account-core / billing-contract"] P7["Phase 7 host proof: Platform + billing-web live"] P6C["Phase 6 contract tests"] P6["Phase 6 live evidence"] S2A["PR 17853 slice 2a cancel / resubscribe / portal rail"] S2B["PR 17856 slice 2b subscribe + plan change"] LC["Layer C: host mints billing-web entries"] FU9["customer-attention predicate"] FU11["opaque BillingServerCode"] FU12["useCredits clears on SUPERSEDED"] FU13["reader late-failure fence"] P3 --> HD FC --> HD HD --> RB P3 --> SS SS --> P7 RB --> P7 P3 --> RN RN --> PUB RB --> PUB PUB --> P7 P3 --> P8PV P3 --> P8RD P8PV --> P8 P8RD --> P8 P4 --> P8 P8 --> S2B HD --> S2A S2A --> S2B S2B --> LC RB --> LC HD --> LC LC --> P7 P8 --> BWS BWS --> BWV RB --> BWV BWV --> P7 CORS --> P7 P5 --> P6 P3 --> P6C P5 --> WS P5 --> FU9 P3 --> FU11 P4 --> FU12 P3 --> FU13 style P3 fill:#d4edda,stroke:#155724 style P4 fill:#d4edda,stroke:#155724 style P5 fill:#d4edda,stroke:#155724 style FC fill:#d4edda,stroke:#155724 style SS fill:#d4edda,stroke:#155724 style RB fill:#d4edda,stroke:#155724 style WS fill:#d4edda,stroke:#155724 style FU9 fill:#d4edda,stroke:#155724 style BWV fill:#d4edda,stroke:#155724 style BWS fill:#d4edda,stroke:#155724 style P8 fill:#d4edda,stroke:#155724 style P8RD fill:#d4edda,stroke:#155724 style CORS fill:#d4edda,stroke:#155724 style FU13 fill:#d4edda,stroke:#155724 style FU12 fill:#d4edda,stroke:#155724 style FU11 fill:#d4edda,stroke:#155724 style P8PV fill:#d4edda,stroke:#155724 style LC stroke:#0366d6,stroke-width:4px ```
…act when the hosted destination says billing_web (#17860) Stacked on #17856 (base branch `jaewon/fe-2216-plan-change`) → #17853 → Rollout layer C (`hosted_billing_destination`, `stripe` | `billing_web`, PostHog at 100% `stripe`) decides where a hosted billing action lands. The plan says the host reads the flag, hands it to the SDK (#17783) and, when it says `billing_web`, mints a `/v1/<intent>` entry with `return_to` from `@comfyorg/billing-contract`, the one definition of that route surface (#17795); when it says `stripe`, the backend's URL is opened unchanged. Today the host only opens the bare billing-web origin from the user popover (#17716) with no intent and no `return_to`, and "Billing & invoices" in the settings panel always goes to the Stripe portal. This is the last un-opened code item before the Phase 7 host proof. - `src/platform/workspace/billing/hostedBillingRoutes.ts`: `hostedBillingRoute(destination, intent)` returns `{ kind: 'billing_web', url }` built by `buildBillingEntryUrl({ billingOrigin, intent, product: 'comfyui', returnTo: 'comfyui_workspace' })`, or `{ kind: 'provider' }` meaning "use the server's URL". The environment is derived, not hardcoded: the cloud base URL's hostname through the existing `resolveDeployEnv` map (`prod-v2 | stg-v2 | test-v2` → `production | staging | test`), which also classifies a local dev session by the backend it talks to. Fails closed to the provider on: no configured origin, an unknown backend family, a return target with no destination in that family, or an entry the contract refuses. A path-prefixed `VITE_BILLING_WEB_URL` keeps its prefix under the minted route. - Consumers: the popover's "Plans and pricing" mints the `pricing` intent (billing-web routes it to the subscription view; the in-app dialog stays the `stripe` behaviour and the popup-blocked fallback); `useWorkspaceBilling.manageSubscription()` mints `payment-methods` **before** either rail is consulted, so on `billing_web` no portal URL is requested on the SDK rail or the legacy one, and `openPortalWindow` + `refreshOnPortalReturn` still run so the return re-reads status, balance and capabilities. - Also fixed on the way: the popover treated a falsy `window.open(…, "noopener,noreferrer")` result as a blocked popup and showed the in-app pricing dialog as a fallback. Per the HTML spec `noopener` always returns `null`, so on `billing_web` the tab and the dialog opened together — a latent defect inherited from #17370 on `main`, caught by this PR's evidence run. The fallback is gone; the E2E `window.open` stub now returns `null` for `noopener` like a browser does, and a popover case covers both destinations. - Left on the provider on purpose: `useSubscriptionCheckout.recoverOutstandingPayment` and the `payment_method_url` steps inside an operation are mid-checkout provider steps, not hosted management; `invoices` and `result` are not served by billing-web yet (`ComingSoonView`), so nothing mints them; the legacy `/customers` rail's `accessBillingPortal` is being retired by the personal-billing flip and is not touched. - `@comfyorg/billing-contract` becomes a root `workspace:*` dependency. The CI cloud build for E2E (`.github/actions/build-cloud-frontend`, used only by `ci-tests-e2e.yaml` and `pr-update-playwright-expectations.yaml`, never by a deploy) gets `VITE_BILLING_WEB_URL=https://billing-web.example`, a reserved origin the spec stubs, reachable only when the server flag says `billing_web`. - No frontend-derived server state: the destination is the flag as-is; the host chooses only the URL shape. | AS-IS — `hosted_billing_destination: stripe` | TO-BE — `hosted_billing_destination: billing_web` | | --- | --- | | **1. User popover, "Plans and pricing" hovered**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-popover-plans.png"><br>Same menu item, unchanged by the flag. | **1. User popover, "Plans and pricing" hovered**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-popover-plans.png"><br>Same menu item, unchanged by the flag. | | **2. After clicking "Plans and pricing"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-plans-result.png"><br>In-app "Choose a Plan" dialog, no tab opened. | **2. After clicking "Plans and pricing"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-plans-result.png"><br>`billing-web.example/v1/pricing?product=comfyui&return_to=comfyui_workspace` tab opens and nothing else: `window.open` returns `null` under `noopener` as the spec requires, and no in-app dialog is left behind. | | **3. Settings ▸ Workspace ▸ Plan & Credits, before clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-settings-billing.png"><br>Identical panel; the destination is only read on click. | **3. Settings ▸ Workspace ▸ Plan & Credits, before clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-settings-billing.png"><br>Identical panel; the destination is only read on click. | | **4. After clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-manage-result.png"><br>`POST /api/billing/payment-portal` recorded, and the URL it returned (`https://billing.example/portal`) opened. | **4. After clicking "Billing & invoices"**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-manage-result.png"><br>No request to `/api/billing/payment-portal` on either rail; `billing-web.example/v1/payment-methods?product=comfyui&return_to=comfyui_workspace` minted and opened. | | **5. Return trip — refocusing the app tab after the hosted tab opened**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/as-is-return-refresh.png"><br>`/api/billing/status`, `/balance` and `/capabilities` re-read. | **5. Return trip — refocusing the app tab after the hosted tab opened**<br><img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17860-screenshots/screenshots/to-be-return-refresh.png"><br>Same three reads; `openPortalWindow` + `refreshOnPortalReturn` still run on the minted route. | - AS-IS (`stripe`, today's default): popover → in-app pricing dialog; settings → Stripe portal via `POST /billing/payment-portal`. - TO-BE (`billing_web`): popover → `<billing-web>/v1/pricing?product=comfyui&return_to=comfyui_workspace`; settings → `<billing-web>/v1/payment-methods?…`, no portal request on either rail; the app re-reads billing state on return. | Gate | Result | | --- | --- | | `vitest run src/platform/workspace src/composables/billing src/composables/useFeatureFlags src/config` | 91 files, 1890 tests (19 new route cases: intent × destination × env × prefix × each fail-closed branch; 3 new adapter cases; 3 popover cases re-pointed) | | `packages/billing-contract` vitest | 3 files, 62 tests | | `pnpm typecheck`, `typecheck:browser`, `lint`, `format`, `knip` | exit 0 | | `fallow audit --changed-since origin/jaewon/fe-2216-plan-change` | no issues in 10 changed files | | `PLAYWRIGHT_TEST_URL=http://localhost:5431 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/hostedBillingDestination.spec.ts --reporter=list`, against `VITE_BILLING_WEB_URL=https://billing-web.example pnpm dev:cloud` | `4 passed (4.6s)` — settings on both destinations, plus the two new avatar-menu cases: `opens the in-app pricing table from the avatar menu while the destination is stripe` and `opens the billing-web pricing entry alone from the avatar menu while the destination is billing_web` | Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 1-2 | Session core, transport, readers | FE-2211/2212/2213 | merged | | 3 | Operation lifecycle, commands, eight-state projection | FE-2227/2214/2223 | merged (#17655) | | 4 | `@comfyorg/account-ui` composables + `CheckoutSteps` | FE-2215 | merged (#17662, #17663) | | 5 slice 1 | Top-up through the SDK behind `billing_sdk_topup_enabled` | FE-2216 | merged (#17665) | | rollout C | `hosted_billing_destination` server flag read by the host | FE-2218 | merged (#17716) | | rollout C | `hostedDestination` port on the lifecycle, value on operation state | FE-2210/2218 | #17783 (review) | | 7 prep | Scope-source port + credentialed transport (BFF / cookie hosts) | FE-2218 | merged (#17782) | | 7 prep | `@comfyorg/account` → `@comfyorg/account-core` rename | FE-2218 | #17851 (review) | | 7 prep | `billing-contract` route builder + `return_to` registry | FE-2218 | merged (#17795) | | 3A-3 | Workshop adapter over `createHostedTopupCheckout` | FE-2214 | merged (#17793) | | 8 core | `previewSubscribe` command | FE-2331 | merged (#17797) | | 8 core | Plans + saved payment-methods readers | FE-2331 | merged (#17798) | | 8 ui | account-ui composables (`usePlans`, `usePaymentMethods`, `usePreviewSubscribe`) | FE-2331 | merged (#17798) | | 7 | billing-web own-origin session, sign-in, SDK composition | FE-2218 | merged (#17798) | | 7 | billing-web unit tests in CI (`ci-billing-web-unit.yaml`) | FE-2218 | merged (#17827, #17844) | | 7 | ingest CORS + top-up return hosts for billing.comfy.org and its previews (Comfy-Org/cloud) | FE-2218 | merged (Comfy-Org/cloud#9512) | | 8 ui | billing-web `/v1` entry routing + subscription / payment-method surfaces | FE-2331 | merged (#17798) | | 7 | npm publish (`ingest-types`, `account-core`, `billing-contract`), Platform install, billing-web live top-up | FE-2218 | todo | | 6 | Contract tests per generated schema (package layer) | FE-2217 | | 6 | Live E2E per flow × consumer + evidence table | FE-2217 | todo (needs staging flags) | | 5 slice 2a | Cancel, resubscribe and payment portal through the SDK behind `billing_sdk_subscription_enabled` | FE-2216 | #17853 (review) | | 5 slice 2b | Subscribe and plan change through the SDK, priced by the server | FE-2216 | #17856 (review; parent of this PR) | | 7 / rollout C | Host mints billing-web `/v1/<intent>` entries with `return_to` when `hosted_billing_destination` is `billing_web` | FE-2218 | **this PR** | | follow-up | One `needsCustomerAttention` predicate (from the #17665 review) | FE-2216 | merged (#17792) | | follow-up | Opaque `BillingServerCode` (from the #17656 review) | FE-2227 | merged (#17794) | | follow-up | `useCredits` clears on `SUPERSEDED` (from the #17799 review) | FE-2215 | merged (#17824) | | follow-up | credits / status / capabilities readers fence a late failure as `SUPERSEDED` (from the #17798 review) | FE-2331 | merged (#17828) | ```mermaid flowchart LR P3["Phase 3 core lifecycle (merged)"] P4["Phase 4 account-ui (merged)"] P5["Phase 5 slice 1 top-up flag (merged)"] FC["PR 17716 hosted_billing_destination flag (merged)"] HD["PR 17783 hostedDestination port"] SS["PR 17782 scope-source port + credentialed transport"] RN["account-core rename"] RB["billing-contract route builder + return_to"] WS["Workshop adapter"] P8PV["previewSubscribe command"] P8RD["plans + payment-methods readers"] P8["account-ui hosted composables"] BWS["billing-web session + sign-in"] BWV["billing-web /v1 surfaces"] CORS["cloud PR 9512 ingest CORS + return hosts"] PUB["npm publish account-core / billing-contract"] P7["Phase 7 host proof: Platform + billing-web live"] P6C["Phase 6 contract tests"] P6["Phase 6 live evidence"] S2A["PR 17853 slice 2a cancel / resubscribe / portal rail"] S2B["PR 17856 slice 2b subscribe + plan change"] LC["Layer C: host mints billing-web entries"] FU9["customer-attention predicate"] FU11["opaque BillingServerCode"] FU12["useCredits clears on SUPERSEDED"] FU13["reader late-failure fence"] P3 --> HD FC --> HD HD --> RB P3 --> SS SS --> P7 RB --> P7 P3 --> RN RN --> PUB RB --> PUB PUB --> P7 P3 --> P8PV P3 --> P8RD P8PV --> P8 P8RD --> P8 P4 --> P8 P8 --> S2B HD --> S2A S2A --> S2B S2B --> LC RB --> LC HD --> LC LC --> P7 P8 --> BWS BWS --> BWV RB --> BWV BWV --> P7 CORS --> P7 P5 --> P6 P3 --> P6C P5 --> WS P5 --> FU9 P3 --> FU11 P4 --> FU12 P3 --> FU13 style P3 fill:#d4edda,stroke:#155724 style P4 fill:#d4edda,stroke:#155724 style P5 fill:#d4edda,stroke:#155724 style FC fill:#d4edda,stroke:#155724 style SS fill:#d4edda,stroke:#155724 style RB fill:#d4edda,stroke:#155724 style WS fill:#d4edda,stroke:#155724 style FU9 fill:#d4edda,stroke:#155724 style BWV fill:#d4edda,stroke:#155724 style BWS fill:#d4edda,stroke:#155724 style P8 fill:#d4edda,stroke:#155724 style P8RD fill:#d4edda,stroke:#155724 style CORS fill:#d4edda,stroke:#155724 style FU13 fill:#d4edda,stroke:#155724 style FU12 fill:#d4edda,stroke:#155724 style FU11 fill:#d4edda,stroke:#155724 style P8PV fill:#d4edda,stroke:#155724 style LC stroke:#0366d6,stroke-width:4px ```
…ced by the server (Comfy-Org#17856) Stacked on Comfy-Org#17853 (base branch `jaewon/fe-2216-subscription-rail`), which stacks on Comfy-Org#17783; merge those first. ## Why Slice 2a (Comfy-Org#17853) put cancel, resubscribe and the payment portal on the SDK rail. Subscribe — new subscriptions and plan changes — was left on the legacy call because the SDK's `subscribe` refused an active subscription on the client (`active → ALREADY_HELD`) and routed a scheduled cancel to `resubscribe()`, which carries no plan. Both contradict what the host already does: `useWorkspaceBilling.subscribe` posts `/billing/subscribe` whatever the subscription state, `useSubscriptionCheckout` quotes the change first with `previewSubscribe`, and the server prices the change, reactivates or refuses (`REACTIVATION_CONFIRMATION_REQUIRED` exists for exactly that). Decision (2026-09-16): mirror the host; no product change. ## How - **Core.** `subscribe()` issues `POST /billing/subscribe` for every subscription state and never short-circuits; the client-side eligibility switch, `eligibilityOf` and its type are gone (nothing else read them). `resubscribe()` stays the explicit "resume" command. `docs/billing-command-eligibility.md` (the path the module doc already referenced) now records the route per command and that the status read decides nothing for subscribe. - **Core, quote decoding.** The generated zod for the preview coerces every int64 to `bigint` while the generated TS type for the same fields is `number`, so the SDK's quote was not assignable to the host's `PreviewSubscribeResponse`. The cents fields are decoded as `z.number()` via `.extend` on the generated schemas (the precedent `capabilities.ts` sets for `revision`; money on this route is bounded to cents well inside the safe range). The two types are now structurally identical and `pnpm typecheck` proves the assignment with no hand-written projection. - **Host.** On the rail (read once per action, as in 2a) `useWorkspaceBilling.subscribe` maps `SubscribeOptions → SubscribeInput` field for field (`confirmationToken` / `savedPaymentMethodId` empty → dropped, as the workspace client does; nothing dropped otherwise) and runs `sdk.commands.subscribe`; `previewSubscribe` runs `sdk.commands.previewSubscribe`. Both share 2a's route latch (404 → legacy once), and every other failure is thrown as a `WorkspaceApiError` whose `.code` carries the server code verbatim, so `useSubscriptionCheckout` and `useDowngradeToPersonal` keep branching on `REACTIVATION_CONFIRMATION_REQUIRED`, `SUBSCRIPTION_PAYMENT_REQUIRED`, `OUTSTANDING_PAYMENT_REQUIRED`, `TRANSITION_NOT_ALLOWED`, `PRORATION_QUOTE_EXPIRED`, `SUBSCRIPTION_QUOTE_STALE` unchanged. - **Customer steps.** The SDK settles the operation inside `subscribe()`, so nothing else watches it: the store's lifecycle subscriber now handles non-topup pending states — the existing in-page challenge driver, and a once-per-operation `window.open(actionUrl)` with the same popup-blocked toast the checkout shows. Without both, a 3DS plan change or a `needs_payment_method` answer would time out with nothing on screen. - **Settled response.** A settled subscribe projects to the `{ billing_op_id, status: 'subscribed' }` body `handleSubscribeResponse` already handles; `needs_payment_method` / `pending_payment` never reach the host because the lifecycle drove them first. - Not on the rail: `teamSubscriptionCheckoutUtil.ts` calls `workspaceApi.subscribe` directly and stays legacy on both rails; `savePendingSubscriptionCheckout` and checkout-journey `billing_op_id` linking run after settlement rather than at issue, because the SDK does not surface the issued operation (recovery across reloads is the lifecycle's `recover()`). ## AS-IS / TO-BE Same journey on both: `?pricing=creator&cycle=yearly` against an active `standard-annual` subscription on the `stripe` rail, 1280×800, every endpoint mocked. | State | AS-IS — `billing_sdk_subscription_enabled: false` | TO-BE — `billing_sdk_subscription_enabled: true` | | --- | --- | --- | | "Confirm your upgrade" with the quote | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/as-is-confirm-upgrade.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/to-be-confirm-upgrade.png"> | | "You're all set" after confirming | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/as-is-all-set.png"> | <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/to-be-all-set.png"> | | Recorded `subscribe` request (quote above it carries no key on either rail) | no `Idempotency-Key` <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/as-is-subscribe-headers.png"> | `Idempotency-Key` present and echoed as `idempotency_key` <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/to-be-subscribe-headers.png"> | | `POST /billing/subscribe` answers 404 | one POST, the click fails ("Request failed with status code 404") <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/as-is-404-fallback.png"> | two POSTs from one click — first with the key → 404, second without → 200, "You're all set" <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/to-be-404-fallback.png"> | | Server answers `REACTIVATION_CONFIRMATION_REQUIRED` | re-quotes, shows the reactivation panel and the coded toast <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/as-is-reactivation-required.png"> | identical panel, toast and CTA on the rail <br> <img width="480" src="https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/assets/pr-17856-screenshots/screenshots/to-be-reactivation-required.png"> | - AS-IS (flag off): quote and subscribe go through the workspace API; a 3DS or payment-method step is driven by the checkout composable off the raw response. - TO-BE (flag on): the same screens and copy; quote and subscribe go through the SDK transport (`Idempotency-Key` on the subscribe POST), settlement through the operation lifecycle; a 404 falls back to the legacy call. ## Testing | Gate | Result | | --- | --- | | `packages/account` vitest | 39 files, 634 tests (new: active plan change issues the request; canceled carries `plan_slug` + `confirm_reactivation`; `REACTIVATION_CONFIRMATION_REQUIRED` surfaces coded) | | host vitest (billing sdk, composables/billing, workspace composables + stores, feature flags) | 41 files, 1151 tests | | `pnpm typecheck`, `typecheck:browser`, `lint`, `format`, `knip` | exit 0 | | `fallow audit --changed-since origin/jaewon/fe-2216-subscription-rail` | no issues in 10 changed files, complexity 0, duplication 0 | | Playwright cloud: `planChangeSdkRail.spec.ts` (3) + `cancelSubscriptionSdkRail.spec.ts` (3) | `6 passed (11.5s)` — `PLAYWRIGHT_TEST_URL=http://localhost:5173 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/planChangeSdkRail.spec.ts browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts --reporter=list` against a `pnpm dev:cloud` vite server, all endpoints mocked | ## Where this sits in the plan Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 1-2 | Session core, transport, readers | FE-2211/2212/2213 | merged | | 3 | Operation lifecycle, commands, eight-state projection | FE-2227/2214/2223 | merged (Comfy-Org#17655) | | 4 | `@comfyorg/account-ui` composables + `CheckoutSteps` | FE-2215 | merged (Comfy-Org#17662, Comfy-Org#17663) | | 5 slice 1 | Top-up through the SDK behind `billing_sdk_topup_enabled` | FE-2216 | merged (Comfy-Org#17665) | | rollout C | `hosted_billing_destination` server flag read by the host | FE-2218 | merged (Comfy-Org#17716) | | rollout C | `hostedDestination` port on the lifecycle, value on operation state | FE-2210/2218 | Comfy-Org#17783 (review) | | 7 prep | Scope-source port + credentialed transport (BFF / cookie hosts) | FE-2218 | merged (Comfy-Org#17782) | | 7 prep | `@comfyorg/account` → `@comfyorg/account-core` rename | FE-2218 | Comfy-Org#17851 (review) | | 7 prep | `billing-contract` route builder + `return_to` registry | FE-2218 | merged (Comfy-Org#17795) | | 3A-3 | Workshop adapter over `createHostedTopupCheckout` | FE-2214 | merged (Comfy-Org#17793) | | 8 core | `previewSubscribe` command | FE-2331 | merged (Comfy-Org#17797) | | 8 core | Plans + saved payment-methods readers | FE-2331 | merged (Comfy-Org#17798) | | 8 ui | account-ui composables (`usePlans`, `usePaymentMethods`, `usePreviewSubscribe`) | FE-2331 | merged (Comfy-Org#17798) | | 7 | billing-web own-origin session, sign-in, SDK composition | FE-2218 | merged (Comfy-Org#17798) | | 7 | billing-web unit tests in CI (`ci-billing-web-unit.yaml`) | FE-2218 | merged (Comfy-Org#17827, Comfy-Org#17844) | | 7 | ingest CORS + top-up return hosts for billing.comfy.org and its previews (Comfy-Org/cloud) | FE-2218 | merged (Comfy-Org/cloud#9512) | | 8 ui | billing-web `/v1` entry routing + subscription / payment-method surfaces | FE-2331 | merged (Comfy-Org#17798) | | 7 | npm publish (`ingest-types`, `account-core`, `billing-contract`), Platform install, billing-web live top-up | FE-2218 | todo | | 6 | Contract tests per generated schema (package layer) | FE-2217 | Comfy-Org#17829 (review) | | 6 | Live E2E per flow × consumer + evidence table | FE-2217 | todo (needs staging flags) | | 5 slice 2a | Cancel, resubscribe and payment portal through the SDK behind `billing_sdk_subscription_enabled` | FE-2216 | Comfy-Org#17853 (review; parent of this PR) | | 5 slice 2b | Subscribe and plan change through the SDK: quote, then subscribe; the SDK never short-circuits on the client | FE-2216 | **this PR** | | follow-up | One `needsCustomerAttention` predicate (from the Comfy-Org#17665 review) | FE-2216 | merged (Comfy-Org#17792) | | follow-up | Opaque `BillingServerCode` (from the Comfy-Org#17656 review) | FE-2227 | merged (Comfy-Org#17794) | | follow-up | `useCredits` clears on `SUPERSEDED` (from the Comfy-Org#17799 review) | FE-2215 | merged (Comfy-Org#17824) | | follow-up | credits / status / capabilities readers fence a late failure as `SUPERSEDED` (from the Comfy-Org#17798 review) | FE-2331 | merged (Comfy-Org#17828) | ```mermaid flowchart LR P3["Phase 3 core lifecycle (merged)"] P4["Phase 4 account-ui (merged)"] P5["Phase 5 slice 1 top-up flag (merged)"] FC["PR 17716 hosted_billing_destination flag (merged)"] HD["PR 17783 hostedDestination port"] SS["PR 17782 scope-source port + credentialed transport"] RN["account-core rename"] RB["billing-contract route builder + return_to"] WS["Workshop adapter"] P8PV["previewSubscribe command"] P8RD["plans + payment-methods readers"] P8["account-ui hosted composables"] BWS["billing-web session + sign-in"] BWV["billing-web /v1 surfaces"] CORS["cloud PR 9512 ingest CORS + return hosts"] PUB["npm publish account-core / billing-contract"] P7["Phase 7 host proof: Platform + billing-web live"] P6C["Phase 6 contract tests"] P6["Phase 6 live evidence"] S2A["PR 17853 slice 2a cancel / resubscribe / portal rail"] S2B["Phase 5 slice 2b subscribe + plan change"] FU9["customer-attention predicate"] FU11["opaque BillingServerCode"] FU12["useCredits clears on SUPERSEDED"] FU13["reader late-failure fence"] P3 --> HD FC --> HD HD --> RB P3 --> SS SS --> P7 RB --> P7 P3 --> RN RN --> PUB RB --> PUB PUB --> P7 P3 --> P8PV P3 --> P8RD P8PV --> P8 P8RD --> P8 P4 --> P8 P8 --> S2B HD --> S2A S2A --> S2B P8 --> BWS BWS --> BWV RB --> BWV BWV --> P7 CORS --> P7 P5 --> P6 P3 --> P6C P5 --> WS P5 --> FU9 P3 --> FU11 P4 --> FU12 P3 --> FU13 style P3 fill:#d4edda,stroke:#155724 style P4 fill:#d4edda,stroke:#155724 style P5 fill:#d4edda,stroke:#155724 style FC fill:#d4edda,stroke:#155724 style SS fill:#d4edda,stroke:#155724 style RB fill:#d4edda,stroke:#155724 style WS fill:#d4edda,stroke:#155724 style FU9 fill:#d4edda,stroke:#155724 style BWV fill:#d4edda,stroke:#155724 style BWS fill:#d4edda,stroke:#155724 style P8 fill:#d4edda,stroke:#155724 style P8RD fill:#d4edda,stroke:#155724 style CORS fill:#d4edda,stroke:#155724 style FU13 fill:#d4edda,stroke:#155724 style FU12 fill:#d4edda,stroke:#155724 style FU11 fill:#d4edda,stroke:#155724 style P8PV fill:#d4edda,stroke:#155724 style S2B stroke:#0366d6,stroke-width:4px ```
…s when a rail is on (Comfy-Org#17940) Linear FE-2216. Independent of the billing-web stack; based on `main`. ## Why Since Comfy-Org#17665 and Comfy-Org#17853 the cloud app's billing *writes* run on the SDK rail behind the two flags, but its *reads* never moved: `useWorkspaceBilling.fetchStatus` and `fetchBalance` still call `workspaceApi` directly. `createBillingSdk` builds the status, credits, capabilities, plans and payment-methods readers and disposes them, and nothing in the app reads through them — `sdk.paymentMethods.invalidate()` is called with no reader behind it. That is a real inconsistency, not a tidiness gap. After a subscribe on the rail, `refreshAfterSubscriptionChange` reads through the SDK's `credits` and `status` readers (the commands refresh them on success), then `reconcileBillingStateAfterSubscribe` re-reads the same two things through the workspace client. The panels render the second read. Two clients, two caches, one screen. ## How **A read rail, chosen like the write rails.** `useBillingReadRail()` returns the SDK store when *either* `billingSdkTopupRailEnabled` or `billingSdkSubscriptionRailEnabled` is on, null otherwise, and is read once per fetch and held — a flag flip mid-read must not start on one client and publish through the other. Either write rail turns the reads on because a status the SDK's lifecycle recovers from, or a balance its top-up refreshed, should be the state the panels read, or the rail settles one thing and the screen shows another. **Two reads on the store.** `readStatus()` and `readBalance()` wrap `sdk.status.read()` / `sdk.credits.read()` and return `BillingResult<…>` in the host's own response types. **One projection, because the generated types disagree with each other.** `zBillingStatusResponse` coerces the credit stop's `credits_monthly` and `stop_usd` (int64) to `bigint`, while the generated TypeScript type the host reads them through says `number`. `projectBillingStatus` reads the two back as numbers — whole units bounded far inside the safe range, the way the core already reads cents and the capability revision — on both `team_credit_stop` and `scheduled_change.team_credit_stop`. Balance needs no projection; its micros are plain numbers in both. **`fetchStatus` / `fetchBalance`** pick the rail, then run exactly as before: the same stale-read guards, the same `resumePendingOperation`, the same `isLoading` / `error` handling. On the rail a `SUPERSEDED` result is treated as a stale read — nothing published, nothing reported, which is what a legacy read that lost a workspace race already does. Any other failure throws a `WorkspaceApiError` carrying the code, so `initialize`, `retryBillingRead` and `reconcileBillingStateAfterSubscribe` keep their contract (they expect a rejection) and `error.value` carries the code. `fetchPlans` is deliberately not on this PR: the plans catalog is bigint-heavy (`price_cents`, `credits_cents`, `max_seats`, the seat summary) and the app's `Plan` type is consumed across the pricing surfaces, so that projection deserves its own review. ## Review focus **Turning on the top-up rail now also moves status reads to the SDK.** Two existing tests in `useWorkspaceBilling.sdk.test.ts` asserted the SDK was *not* built when only a subscription operation was pending; that premise no longer holds, since the read itself builds the store. They now assert what they were really guarding — that `lifecycle.recover` does not run for a subscription — and stub the SDK status reader instead of the workspace client. **The thrown error is a `WorkspaceApiError`, not a bare `Error`.** `comfy/no-new-error-throw` forbids the latter in production code, and the class is what the legacy client throws on the same path, so `error.value` and `isAlreadyInRequestedState` see the shape they already handle. ## Verification ``` pnpm vitest run useWorkspaceBilling.{,sdk.,subscriptionRail.}test.ts \ billingSdkStore.test.ts billingStatusView.test.ts useTopupOperation.test.ts -> 6 files, 173 tests pnpm typecheck / eslint / oxlint / knip # clean ``` New: `billingStatusView.test.ts` (2) pins the bigint projection and the null pass-through; five read-rail scenarios in `useWorkspaceBilling.sdk.test.ts` — legacy path with the flag off, status and balance through the readers, `SUPERSEDED` leaves state and error untouched, a failed read surfaces the code and rejects. ## AS IS / TO BE No UI change. Both flags are at 0% in staging and prod, so nothing reads differently until they move. - **AS IS** — flag on: writes through the SDK, reads through the workspace client; a subscribe refreshes the SDK's readers, then the panels re-read and render the legacy client's answer. - **TO BE** — flag on: writes and the two reads on the same readers; the refresh a command performs is the read the panels render. Flag off: byte-for-byte the legacy path. ## Where this sits in the plan Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)); remaining work on FE-2216 / FE-2217 / FE-2218 / FE-2331. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 7 | What belongs in `@comfyorg/account-ui` (ADR-0034) | FE-2218 | merged (Comfy-Org#17927) | | 7 | billing-web Vercel deployment config | FE-2218 | merged (Comfy-Org#17788) | | 7 | Package release workflows + versioning ADR | FE-2218 | merged (Comfy-Org#17881) | | 7 | Publish report through a `workflow_run` consumer | FE-2218 | open (Comfy-Org#17952) | | 7 | `account-ui` builds to dist and packs clean | FE-2218 | open (Comfy-Org#17929) | | 7 | `account-ui` drops its unpublished dependencies, joins `smoke:pack` | FE-2218 | open (Comfy-Org#17932) | | 7 | billing-web report-only CSP and framing denial | FE-2218 | merged (Comfy-Org#17941) | | 8 ui | Promote the Stripe payment UI into `account-ui` | FE-2331 | open (Comfy-Org#17934) | | 8 ui | billing-web checkout, result page, invoices through the portal | FE-2331 | open (Comfy-Org#17936) | | 8 ui | billing-web cancel / resubscribe on the subscription surface | FE-2331 | open (Comfy-Org#17937) | | 8 ui | billing-web reactivation confirmation, refused subscribe surfaced | FE-2331 | open (Comfy-Org#17943) | | 8 ui | billing-web Playwright harness against a mocked Cloud | FE-2218 | open (Comfy-Org#17947) | | 9 | **Status and balance reads on the rail** | FE-2216 | **this PR** | | 9 | Plan catalog read on the rail | FE-2216 | open (Comfy-Org#17942) | | 9 | Capabilities and saved payment methods on the rail | FE-2216 | open (Comfy-Org#17946) | | 9 | Legacy `billingOperationStore` removal | FE-2216 | after the flags flip | | 7 | First publish (`private` off), Platform install | FE-2218 | unblocked: Comfy-Org#17881 is on main | | 7 | Phase 7 host proof: live top-up on billing.comfy.org | FE-2218 | gated (flags, CNAME, key) | | 6 | Phase 6 live E2E evidence table | FE-2217 | gated (staging flags) | ```mermaid flowchart LR ADR["ADR-0034 (merged)"] REL["release workflows + ADR-0033 (merged Comfy-Org#17881)"] PUBREP["publish report via workflow_run (Comfy-Org#17952)"] UIB["account-ui dist build (Comfy-Org#17929)"] DEPS["drop unpublished deps (Comfy-Org#17932)"] CSP["billing-web CSP (merged Comfy-Org#17941)"] PROMO["Stripe payment form in account-ui (Comfy-Org#17934)"] CHK["billing-web checkout + result + invoices (Comfy-Org#17936)"] SUBW["billing-web cancel / resubscribe (Comfy-Org#17937)"] REACT["reactivation confirmation (Comfy-Org#17943)"] E2E["billing-web Playwright harness (Comfy-Org#17947)"] RD1["status + balance on the rail (Comfy-Org#17940)"] RD2["plans on the rail (Comfy-Org#17942)"] RD3["capabilities + payment methods on the rail (Comfy-Org#17946)"] LEG(["legacy store removal, after the flags"]) PUB(["first publish: workflows are on main, awaiting go"]) H(["Phase 7 host proof"]) E(["Phase 6 evidence"]) OW{{"OWNER staging flags, CNAME, Stripe key"}} ADR --> PROMO UIB --> DEPS --> PROMO --> CHK --> SUBW --> REACT --> E2E REL --> PUBREP REL --> PUB DEPS --> PUB RD1 --> RD2 --> RD3 --> LEG CHK --> H CSP --> H OW -.-> H OW -.-> E OW -.-> LEG style ADR fill:#d4edda,stroke:#155724 style REL fill:#d4edda,stroke:#155724 style CSP fill:#d4edda,stroke:#155724 style RD1 stroke:#0366d6,stroke-width:4px ```
… surface, gated by the server's capabilities (Comfy-Org#17937) Linear FE-2331. Stacked on Comfy-Org#17936 → Comfy-Org#17934 → Comfy-Org#17932 → Comfy-Org#17929. The last write action `apps/billing-web` was missing. ## Why After Comfy-Org#17936 the hosted app could subscribe, pay and recover, but a customer on `/v1/subscription` still had no way to leave a plan or come back to one: the surface listed plans and quoted a change, nothing else. Cancel and resubscribe exist on the SDK (`commands.cancelSubscription`, `useCheckout().resubscribe`) and ride the cloud app's rail since Comfy-Org#17853; this gives the hosted surface the same two actions. ## How `SubscriptionActions.vue`, rendered under the current-plan line: - **Gated by the server, not by local state.** On mount it reads `capabilities` and offers *Cancel subscription* only for `can_cancel`, *Resubscribe* only for `can_reactivate`. Neither button exists for a workspace the server says cannot do it, which is the same rule the cloud app's popover follows. - **Cancel confirms first.** One click shows "Cancel your subscription? You can resubscribe at any time." with *Confirm cancellation* / *Keep my plan*; only the confirmation calls `commands.cancelSubscription()`. Cancel is not a checkout, so it goes straight to the command, as `useCheckout`'s own docstring says it should. - **Resubscribe runs on `useCheckout`**, because the server may answer with a payment step; the composable's continuation redirects this tab to the hosted page (or drives 3DS through `createStripeChallengePort` when a key is configured), and `/v1/result` recovers on the way back — the path Comfy-Org#17936 built. - **After either succeeds**, the panel invalidates and re-reads capabilities with `forceRefresh` (so the buttons flip immediately) and emits `changed`, on which the panel refreshes the plan catalog (so the current-plan line follows). A non-`succeeded` terminal phase and every coded failure render our own copy: new `hosted.outcome.*` lines for `failed` / `timed_out` / `reconciliation_needed` / `superseded`, and three `hosted.failure` codes the subscription commands can return that had no line yet (`REACTIVATION_CONFIRMATION_REQUIRED`, `CONFLICTING_PAYMENT_METHOD`, `MISSING_PAYMENT_METHOD_URL`). ## Review focus **`REACTIVATION_CONFIRMATION_REQUIRED` is surfaced, not handled.** The server asks the host to re-preview and resend with `confirm_reactivation`; here it reads as "Confirm the reactivation charge before continuing" and stops. Wiring the confirm loop is a follow-up — the cloud app's equivalent lives in `useSubscriptionCheckout` and is not small. **The fake client now answers `capabilities.read`** with every capability denied unless a test grants one, and scripts `cancelSubscription` / `resubscribe` like `subscribe`. That is what lets the existing `SubscriptionView` tests keep passing unchanged (no buttons appear for them) while the five new ones exercise the gate, the confirm step, the back-out, resubscribe, and a refused cancel. ## Verification ``` pnpm -C apps/billing-web typecheck # clean pnpm -C apps/billing-web test:unit # 13 files, 108 tests (+5) pnpm -C apps/billing-web lint # clean ``` ## Why the regression coverage is not under `browser_tests/` `browser_tests/` is the ComfyUI graph editor's suite: the root `playwright.config.ts` points `testDir` at it, and `ci-tests-e2e.yaml` runs it inside `comfyui-ci-container` with a live ComfyUI Python server started per job. `apps/billing-web` is a separate Vite entry with no ComfyUI backend behind it, so a spec placed under `browser_tests/` cannot load the surface this PR changes. The equivalent end-to-end coverage lives in `apps/billing-web/e2e`, against a Cloud and identity the suite mocks in-process, and runs on this PR through `ci-billing-web-e2e.yaml`: `subscription.spec.ts` covers *cancels after a confirmation step and then offers to resubscribe* and *shows only the actions the server allows*. The capability-refresh hold that `fix(billing-web): hold the subscription actions through the capability refresh` addressed is pinned by *keeps the action disabled until the capability refresh lands* in `SubscriptionView.test.ts`. ## AS IS / TO BE - **AS IS** — `/v1/subscription` shows the catalog and a quote; the only write reachable from the hosted app is the payment portal. - **TO BE** — the surface offers cancel (with confirmation) and resubscribe exactly when the server permits them, runs both on the SDK commands, and refreshes what the change touched. No UI reaches production until `hosted_billing_destination` says `billing_web`. ## Where this sits in the plan Billing SDK track FE-2210 ([implementation plan V2](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8)); remaining work on FE-2216 / FE-2217 / FE-2218 / FE-2331. | Phase | Item | Ticket | Status | | --- | --- | --- | --- | | 7 | What belongs in `@comfyorg/account-ui` (ADR-0034) | FE-2218 | merged (Comfy-Org#17927) | | 7 | billing-web Vercel deployment config | FE-2218 | merged (Comfy-Org#17788) | | 7 | Package release workflows + versioning ADR | FE-2218 | merged (Comfy-Org#17881) | | 7 | Publish report through a `workflow_run` consumer | FE-2218 | merged (Comfy-Org#17952) | | 7 | `account-ui` builds to dist and packs clean | FE-2218 | merged (Comfy-Org#17929) | | 7 | `account-ui` drops its unpublished dependencies, joins `smoke:pack` | FE-2218 | merged (Comfy-Org#17932) | | 7 | billing-web report-only CSP and framing denial | FE-2218 | merged (Comfy-Org#17941) | | 8 ui | Promote the Stripe payment UI into `account-ui` | FE-2331 | merged (Comfy-Org#17934) | | 8 ui | billing-web checkout, result page, invoices through the portal | FE-2331 | merged (Comfy-Org#17936) | | 8 ui | **billing-web cancel / resubscribe on the subscription surface** | FE-2331 | **this PR** | | 8 ui | billing-web reactivation confirmation, refused subscribe surfaced | FE-2331 | squashed into Comfy-Org#17937 — **not on `main`** | | 8 ui | billing-web Playwright harness against a mocked Cloud | FE-2218 | merged (Comfy-Org#17947) | | 9 | Status and balance reads on the rail | FE-2216 | merged (Comfy-Org#17940) | | 9 | Plan catalog read on the rail | FE-2216 | merged (Comfy-Org#17942) | | 9 | Capabilities and saved payment methods on the rail | FE-2216 | merged (Comfy-Org#17946) | | 9 | Legacy `billingOperationStore` removal | FE-2216 | after the flags flip | | 7 | First publish of `account-core`, `billing-contract`, `ingest-types` | FE-2218 | published on `next` | | 7 | `account-ui` joins the release tables | FE-2218 | merged (Comfy-Org#17989) | | 7 | Phase 7 host proof: live top-up on billing.comfy.org | FE-2218 | gated (flags, CNAME, key) | | 6 | Phase 6 live E2E evidence table | FE-2217 | gated (staging flags) | ```mermaid flowchart LR ADR["ADR-0034 (merged)"] REL["release workflows + ADR-0033 (merged Comfy-Org#17881)"] PUBREP["publish report via workflow_run (merged Comfy-Org#17952)"] UIB["account-ui dist build (merged Comfy-Org#17929)"] DEPS["drop unpublished deps (merged Comfy-Org#17932)"] CSP["billing-web CSP (merged Comfy-Org#17941)"] PROMO["Stripe payment form in account-ui (merged Comfy-Org#17934)"] CHK["billing-web checkout + result + invoices (merged Comfy-Org#17936)"] SUBW["cancel / resubscribe + reactivation (Comfy-Org#17937)"] REACT["reactivation confirmation (Comfy-Org#17943, inside Comfy-Org#17937)"] E2E["billing-web Playwright harness (Comfy-Org#17947)"] RD1["status + balance on the rail (Comfy-Org#17940)"] RD2["plans on the rail (Comfy-Org#17942)"] RD3["capabilities + payment methods on the rail (merged Comfy-Org#17946)"] LEG(["legacy store removal, after the flags"]) PUB["first publish: three packages on next"] UIPUB["account-ui release tables (merged Comfy-Org#17989)"] H(["Phase 7 host proof"]) E(["Phase 6 evidence"]) OW{{"OWNER staging flags, CNAME, Stripe key"}} ADR --> PROMO UIB --> DEPS --> PROMO --> CHK --> SUBW --> REACT --> E2E REL --> PUBREP REL --> PUB DEPS --> UIPUB PUB --> UIPUB RD1 --> RD2 --> RD3 --> LEG CHK --> H CSP --> H OW -.-> H OW -.-> E OW -.-> LEG style ADR fill:#d4edda,stroke:#155724 style REL fill:#d4edda,stroke:#155724 style CSP fill:#d4edda,stroke:#155724 style SUBW stroke:#0366d6,stroke-width:4px ```
…owns it (Comfy-Org#18134) ## Why `useSubscriptionCheckout` decides what the checkout dialog shows about the operation in flight by reading `billingOperationStore` at `:197`–`:199`, with no rail branch. Six things hang off that one read: the parked-checkout recovery prompt, the authentication state, the declined-attempt message, the reconciliation prompt, the busy state that keeps the pay button locked, and the hosted-step URL. With `billing_sdk_subscription_enabled` on, the operation is owned by the SDK lifecycle and the legacy store has no record of it. So the dialog's answer to all six is "there is no operation" — the pay button unlocks mid-checkout, a parked checkout offers no way to supply a card, and a declined attempt shows no reason. `activeCheckoutActionUrl` is the one that was already patched: `:209` falls back to `subscriptionRail?.subscriptionActionUrl`. That fallback is the shape of the fix; this PR gives the other five the same thing properly. ## Root cause `billingOperationStore` was the poller *and* the view-model. Comfy-Org#17853 and Comfy-Org#17665 railed the commands, so a subscribe already issues through the SDK — but the projections the checkout reads had no counterpart on the SDK store, so the reads could not follow the writes. FE-2469 (Comfy-Org#18036) added them; this is the switch. ## How **`SubscriptionRail` gains the two operation reads** (`subscriptionOperationView.ts`) — `subscriptionActionOperation` and `getOperation(opId)` — next to `subscriptionActionUrl`, which was already a read on that interface. `useSubscriptionRail()` then answers everything the checkout needs from one place, rather than the checkout holding a command rail and a second reader. **`useSubscriptionCheckout` reads `subscriptionRail ?? billingOperationStore`,** captured once at setup for the same reason the rail itself is: a flip mid-checkout must not have the dialog observe on a rail the operation was not issued on. The workspace comparison at `:203` stays where it is — both sides hand back an unscoped record on purpose. **`projectOperationRecord` gains `errorMessage`** (`operationRecordView.ts`), projected from a `failed_retryable` attempt's decline reason through the same `declineDetail` the top-up projection uses. Without it `authenticationError` reads `undefined` on the rail, which is the declined-card message going missing. ### The write half is deliberately unchanged, and that is a correction to both tickets FE-2480 asks to "skip `startOperation` when the rail is on" at `:1542` / `:1548`, and FE-2481 asks the same of `useDowngradeToPersonal.ts:335` / `:355`. **Implementing that would strand a customer.** Those four registrations sit behind `response.status === 'needs_payment_method'` or `'pending_payment'`. The rail's own subscribe settles before it returns — `projectSubscribeResult` maps a settled command to `status: 'subscribed'` and everything else to an error — so those two statuses are shapes only `workspaceApi.subscribe` produces. And `workspaceApi.subscribe` still runs with the flag on: `useWorkspaceBilling.ts:445` falls through to it when the SDK route answers 404, which is the whole point of the `NOT_AVAILABLE` latch. So the flag is the wrong predicate. On the 404 fallback it is on while the response came off the legacy transport, and skipping the registration would leave that operation with no poller at all — the customer opens the hosted page and nothing ever settles it. There is no double-poll to remove here: the adapter shape Comfy-Org#17665 chose already prevents it, which FE-2480's own description says. The invariant is now pinned by test at both call sites instead, so a later change cannot reintroduce the second registration the tickets were guarding against. ## AS IS / TO BE With `billing_sdk_subscription_enabled` on and a subscribe parked on the customer: | | AS IS | TO BE | | --- | --- | --- | | Pay button during the operation | unlocks — `isPolling` reads no operation | stays busy until the operation settles | | Checkout parked awaiting a card | no recovery prompt | recovery prompt, as on the legacy rail | | Declined attempt | no reason shown | the decline reason, as on the legacy rail | | Reconciliation needed | no prompt | the reconciliation prompt | No capture is attached: reaching this state needs an authenticated unified-cloud session with the flag on and a live subscribe parked on a hosted step, which is not reproducible from a local checkout — `operations` is a private ref inside `billingSdkStore`, written only by the lifecycle, and there is no dev harness for it. Reviewers should exercise it in a preview environment with the flag on by starting a subscribe that lands on a verification step and watching the dialog before completing it. Flag off, every one of these reads is the legacy store exactly as today. ## Testing - `useSubscriptionCheckout.test.ts` — a parked operation read off the lifecycle on the rail and off the poller when the rail is null, asserting `parkedCheckoutRecovery`, `authenticationState` and `authenticationError` on each; plus a two-row table over the flag proving a legacy-transport `pending_payment` registers exactly one poller, with the second row being the 404-fallback case the section above turns on. - `useDowngradeToPersonal.test.ts` — the pending-payment registration tightened from "called with" to "called once", so a rail branch that added a second registration at that site fails. - `operationRecordView.test.ts` and the store suite pass unchanged with `errorMessage` added. `pnpm test:unit src/platform/workspace src/composables/billing` (91 files, 1956 tests), `pnpm typecheck` and `pnpm lint` pass. Note for whoever merges second: this touches `operationRecordView.ts` alongside PR 8 (Comfy-Org#18133), which adds `actionUrl` validation to the same projection. Different lines, trivial rebase. ## Plan position Milestone 1, Step 1 — [PR plan](https://linear.app/comfyorg/document/milestone-1-pr-plan-605f42c5e709). This is **PR 7**, one of the three switches PR 1 unblocked. Parallel to PRs 8 and 9. FE-2481's other half — the single `proration_at` rule — stays in PR 11, which waits on the backend answer. | PR | Tickets | What | Status | | --- | --- | --- | --- | | 1 | FE-2469 | operation-state projections on the SDK store | merged — Comfy-Org#18036 | | 2 | FE-2467 | billing events reader in `account-core` | open — Comfy-Org#18042 | | 3 | FE-2479 | usage log reads on the SDK rail | open — Comfy-Org#18047, needs 2 | | 4 | FE-2468 | payment recovery reads on the rail | open — Comfy-Org#18060 | | 5 | FE-2470 | team checkout on the SDK subscribe command | independent | | 6 | FE-2471 | one status reader for the cloud subscription store | open — Comfy-Org#18092 | | **7** | **FE-2480 + FE-2481 (poller half)** | **checkout reads its operation off the rail** | **this PR** | | 8 | FE-2482 | subscription panel reads the SDK store | open — Comfy-Org#18133 | | 9 | FE-2484 + FE-2483 + FE-2485 | recovery through the SDK lifecycle | needs 1 | | 10 | FE-2474 | top-up dialog reads through its adapter | open — Comfy-Org#18132 | | 11 | FE-2481 | one `proration_at` rule | backend answer | | 12 | FE-2472 | table-driven safety net | independent | ```mermaid flowchart LR PR1["PR 1 · FE-2469<br/>merged"] --> PR7["PR 7 · FE-2480 + FE-2481<br/>checkout reads on the rail"]:::here PR1 --> PR8["PR 8 · FE-2482"] PR1 --> PR9["PR 9 · FE-2484 + FE-2483 + FE-2485"] PR2["PR 2 · FE-2467"] --> PR3["PR 3 · FE-2479"] IND["PR 4, 5, 6, 10, 11, 12<br/>independent"] PR7 --> BAKE["Step 3 · staging bake"] PR8 --> BAKE PR9 --> BAKE PR3 --> BAKE IND --> BAKE BAKE --> RAMP["Step 4 · production ramp"] --> REMOVE["Step 5 · legacy removal"] classDef here fill:#f2994a,stroke:#b35c00,color:#1a1a1a,font-weight:bold ``` - Part of FE-2480 - Part of FE-2481
…cycle (Comfy-Org#18135) ## Why Recovery is the path a customer takes after a redirect checkout, a reload mid-payment, or a flag flip while an operation is pending. It has two entry points, and with `billing_sdk_subscription_enabled` on both of them hand the operation to the wrong driver. - `useWorkspaceBilling.resumePendingOperation` (`:304`) gives a pending operation to the SDK **only** when the server calls it a top-up. A pending `subscription` at load starts the legacy poller, for an operation whose writes went through the SDK. - `useSubscriptionDialog.resumePendingCheckout` (`:293`) has no rail branch at all. That is the path a customer takes when they return to a parked checkout, so on the rail it starts a legacy poller for an operation the lifecycle already owns. Shipping either alone leaves recovery half-railed, which is the exact ambiguity FE-2484 exists to remove — so the two ship together, with the browser proof FE-2485 asks for. ## Root cause Comfy-Org#17665 railed top-up and railed its recovery with it, because top-up was the flow being moved. The subscription commands were railed later (Comfy-Org#17853, and the checkout in Comfy-Org#18036's follow-ups) and nothing went back to the resume paths. `pending_billing_op_type === 'topup'` was never a rule — it was the shape of the one flow that had a rail at the time, left in place as the condition. ## How **`railOwnsResume(type)`** replaces that condition in `useWorkspaceBilling`. Each kind of pending operation follows the rail that issues it: `topup` on `billingSdkTopupRailEnabled`, everything else on `billingSdkSubscriptionRailEnabled`. A server predating `pending_billing_op_type` only ever had subscriptions to hand back, so an absent field follows the subscription rail — the same reading `resumeModeFor` already takes of it. `'cancel'` is named in the ticket but is not a value this field can hold: the response type is `'topup' | 'subscription' | undefined`, and `resumeModeFor`'s `never` branch is what holds that. A cancel pending at load is reported as a subscription operation and is covered by the same branch. **`billingSdkStore.recoverPendingOperation(opId)`** is new, for the caller that has something to decide on the outcome. `lifecycle.recover()` resolves at *adoption*, not at settlement, and the dialog needs the terminal status to know whether to reopen the pricing table. So this awaits the projection settling, and returns `undefined` when there is nothing to adopt — either the read failed, or the server named a different operation, which means the pointer this caller held is stale. **`useSubscriptionDialog.resumePendingCheckout` branches on the rail** and gets one new behaviour out of it: an `undefined` result clears the stale pointer instead of leaving it parked. The owner/workspace guard above it is untouched, and so is the host pointer `comfy:pending-subscription-checkout` — it carries the tier/cycle selection the pricing dialog restores, which the SDK's scope-keyed pointer deliberately does not. Only who drives the operation moves. ## AS IS / TO BE With `billing_sdk_subscription_enabled` on and a subscription operation pending at load: | | AS IS | TO BE | | --- | --- | --- | | Server reports a pending subscription | legacy poller starts on an SDK-owned operation | `lifecycle.recover()` adopts it; no legacy poller | | Customer returns to a parked checkout | legacy poller starts | `recoverPendingOperation` adopts it | | Pointer left by a pre-flip session | polled on the rail it was not issued on | adopted by the lifecycle | | Recovery finds nothing to adopt | pointer stays parked indefinitely | pointer cleared | No still capture is attached: there is no visual difference to photograph — both rails render the same checkout dialog, and what changed is which transport polls the operation behind it. `operationRecoverySdkRail.spec.ts` is the evidence, and it asserts exactly that discriminator. Flag off, both entry points behave as they do today, which the spec's first row holds. ## Testing - `operationRecoverySdkRail.spec.ts` (new, `@cloud`) — three browser rows against the same mocked pending operation. Both rails poll `GET /api/billing/ops/{id}`, so the request body cannot separate them; the transport can, as in `planChangeSdkRail`: the SDK runs on `fetch`, the legacy workspace client on axios' XHR. Rail off, no poll is a `fetch`. Rail on, the operation is adopted **exactly once, on one rail** — see the race note below for why this row cannot assert *which* rail without flaking. And a failed recovery still reopens the checkout on the Creator annual plan the host pointer recorded, then clears it. - `useWorkspaceBilling.sdk.test.ts` — a five-row table over (op type × topup rail × subscription rail) pinning which side adopts, including the two rows that prove the rails do not cross: a pending top-up with only the subscription rail on stays on the poller, and a pending subscription with only the top-up rail on stays on the poller. - `useSubscriptionDialog.test.ts` — a two-row table over the rail: each adopts through its own driver and neither through the other's, and the pricing dialog reopens on the recorded tier/cycle either way. Plus the stale-pointer row, which is the new behaviour. - `billingSdkStore.test.ts` — `recoverPendingOperation` resolving with the settled record, and returning `undefined` both when the server names another operation and when the recovery read fails. `pnpm test:unit src/platform/workspace src/composables/billing src/platform/cloud` (145 files, 2607 tests), `pnpm typecheck`, `pnpm typecheck:browser` and `pnpm lint` pass. ## Plan position Milestone 1, Step 1 — [PR plan](https://linear.app/comfyorg/document/milestone-1-pr-plan-605f42c5e709). This is **PR 9**, the last of the three switches PR 1 unblocked. It carries FE-2485 rather than leaving it for Step 1b, because it proves new code: E1–E3 stay separate PRs because they backfill code already on `main`. | PR | Tickets | What | Status | | --- | --- | --- | --- | | 1 | FE-2469 | operation-state projections on the SDK store | merged — Comfy-Org#18036 | | 2 | FE-2467 | billing events reader in `account-core` | open — Comfy-Org#18042 | | 3 | FE-2479 | usage log reads on the SDK rail | open — Comfy-Org#18047, needs 2 | | 4 | FE-2468 | payment recovery reads on the rail | open — Comfy-Org#18060 | | 5 | FE-2470 | team checkout on the SDK subscribe command | independent | | 6 | FE-2471 | one status reader for the cloud subscription store | open — Comfy-Org#18092 | | 7 | FE-2480 + FE-2481 | checkout reads its operation off the rail | open — Comfy-Org#18134 | | 8 | FE-2482 | subscription panel reads the SDK store | open — Comfy-Org#18133 | | **9** | **FE-2484 + FE-2483 + FE-2485** | **recovery through the SDK lifecycle** | **this PR** | | 10 | FE-2474 | top-up dialog reads through its adapter | open — Comfy-Org#18132 | | 11 | FE-2481 | one `proration_at` rule | backend answer | | 12 | FE-2472 | table-driven safety net | independent | ```mermaid flowchart LR PR1["PR 1 · FE-2469<br/>merged"] --> PR9["PR 9 · FE-2484 + 2483 + 2485<br/>recovery on the rail"]:::here PR1 --> PR7["PR 7 · FE-2480 + FE-2481"] PR1 --> PR8["PR 8 · FE-2482"] PR2["PR 2 · FE-2467"] --> PR3["PR 3 · FE-2479"] IND["PR 4, 5, 6, 10, 11, 12<br/>independent"] PR9 --> BAKE["Step 3 · staging bake"] PR7 --> BAKE PR8 --> BAKE PR3 --> BAKE IND --> BAKE BAKE --> RAMP["Step 4 · production ramp"] --> REMOVE["Step 5 · legacy removal"] classDef here fill:#f2994a,stroke:#b35c00,color:#1a1a1a,font-weight:bold ``` - Part of FE-2484 - Part of FE-2483 - Part of FE-2485
…rg#18133) ## Why `SubscriptionPanelContentWorkspace.vue` decides whether to show the "setting up your subscription" banner, and whether to offer the Complete verification button inside it, by reading `billingOperationStore` — `:445` for `isSettingUp`, `:447` for `subscriptionActionOperation?.actionUrl`. Neither read has a rail branch. With `billing_sdk_subscription_enabled` on, the operation those two values describe is owned by the SDK lifecycle. The legacy store has no record of it, so the panel renders the plan tile as though nothing were in flight: no banner while the subscription is being set up, and no way through when the customer still owes a hosted verification step. ## Root cause FE-2469 named this the last half of `billingOperationStore` to move: the store was the poller *and* the view-model, and the SDK replaced the poller only. The commands were railed by Comfy-Org#17853 and Comfy-Org#17665, so a subscribe already issues through the SDK — but the two predicates the panel reads had no counterpart on the SDK store, so they could not follow. PR 1 (Comfy-Org#18036) added them. This PR is the switch they were added for. ## How **`useSubscriptionOperationView()`** joins `useSubscriptionRail()` in `useSubscriptionRail.ts` — the same flag, read once, for the same reason the commands read it once: a flip mid-operation must not have the panel observe on a rail the operation was not issued on. It answers the two questions the panel asks and nothing else, from `billingSdkStore` when the rail is on and from `billingOperationStore` when it is off. It is a read-side sibling rather than a widening of `SubscriptionRail`, because `SubscriptionRail` is the command interface `useSubscriptionCheckout` holds; the panel issues nothing. **The panel loses its `useBillingOperationStore` import and both computeds** for one destructure. `openSubscriptionVerification` and the template are untouched. **`projectOperationRecord` now validates `actionUrl`** (`operationRecordView.ts`). This is a parity gap PR 1 left: the legacy store validates the URL at registration (`billingOperationStore.ts:253`), so a legacy record's `actionUrl` is https-or-null by the time a surface reads it, while the projection carried the SDK's value through raw. Both this panel and `useSubscriptionCheckout` hand that value to `window.open`, so the projection has to make the same guarantee the record it mirrors makes. `account-core` exports the same `validateActionUrl` the SDK store already uses for `subscriptionActionUrl`, so this is one predicate, not a second copy. ## AS IS / TO BE No screenshot — the state this PR changes is not reachable on a local build. `billingSdkSubscriptionRailEnabled` is `billingSdkSubscriptionEnabled && unifiedCloudAuthEnabled`, so the rail is only on inside an authenticated unified-cloud session, and `isSettingUp` / `subscriptionActionOperation` are computed off `billingSdkStore`'s private `operations`, which only the SDK lifecycle's poll of a live backend operation writes. There is no story for `SubscriptionPanelContentWorkspace`, no dev harness for the lifecycle, and no writable surface on the store, so nothing short of a real subscribe parked on a hosted verification step renders the banner. Rather than stage a fake, the two frames are described: | | | | --- | --- | | **AS IS** | The plan tile as normal while an SDK-owned subscribe is in flight: no "setting up your subscription" spinner banner and no **Complete verification** button, because the legacy store holds no record of the operation. | | **TO BE** | The spinner banner (`billingOperation.subscriptionProcessing`), and inside it the **Complete verification** button for a role with `canManageSubscription`, opening the hosted step. | To exercise it in a preview environment: with `billing_sdk_subscription_enabled` on, start a subscribe that lands on a hosted verification/3DS step, then open the subscription panel before completing it. On this branch the banner and the button are there; on `main` the panel shows the plan tile as though nothing were pending. Flag off, the panel is unchanged — the legacy store answers both reads exactly as it does today. ## Testing - `useSubscriptionOperationView.test.ts` — the poller answers both reads with the rail off and the SDK is never constructed; the lifecycle answers both with the rail on while the poller holds nothing; a two-row table over the rail proving neither rail offers another workspace's hosted step (the lifecycle keeps operations from a scope it has left, so the filter is load-bearing, not incidental); and a non-https step refused on the SDK rail. - `operationRecordView.test.ts` — a row for the `javascript:` step the projection now refuses, alongside the https step it carries. `pnpm test:unit src/platform/workspace src/composables/billing` (92 files, 1958 tests), `pnpm typecheck` and `pnpm lint` pass. ## Plan position Milestone 1, Step 1 — [PR plan](https://linear.app/comfyorg/document/milestone-1-pr-plan-605f42c5e709). This is **PR 8**, one of the three switches PR 1 unblocked. Parallel to PRs 7 and 9; no ordering between them. | PR | Tickets | What | Status | | --- | --- | --- | --- | | 1 | FE-2469 | operation-state projections on the SDK store | merged — Comfy-Org#18036 | | 2 | FE-2467 | billing events reader in `account-core` | open — Comfy-Org#18042 | | 3 | FE-2479 | usage log reads on the SDK rail | open — Comfy-Org#18047, needs 2 | | 4 | FE-2468 | payment recovery reads on the rail | open — Comfy-Org#18060 | | 5 | FE-2470 | team checkout on the SDK subscribe command | independent | | 6 | FE-2471 | one status reader for the cloud subscription store | open — Comfy-Org#18092 | | 7 | FE-2480 + FE-2481 | stop registering a second poller | needs 1 | | **8** | **FE-2482** | **subscription panel reads the SDK store** | **this PR** | | 9 | FE-2484 + FE-2483 + FE-2485 | recovery through the SDK lifecycle | needs 1 | | 10 | FE-2474 | top-up dialog reads through its adapter | open — Comfy-Org#18132 | | 11 | FE-2481 | one `proration_at` rule | backend answer | | 12 | FE-2472 | table-driven safety net | independent | ```mermaid flowchart LR PR1["PR 1 · FE-2469<br/>merged"] --> PR8["PR 8 · FE-2482<br/>panel on the rail"]:::here PR1 --> PR7["PR 7 · FE-2480 + FE-2481"] PR1 --> PR9["PR 9 · FE-2484 + FE-2483 + FE-2485"] PR2["PR 2 · FE-2467"] --> PR3["PR 3 · FE-2479"] IND["PR 4, 5, 6, 10, 11, 12<br/>independent"] PR8 --> BAKE["Step 3 · staging bake"] PR7 --> BAKE PR9 --> BAKE PR3 --> BAKE IND --> BAKE BAKE --> RAMP["Step 4 · production ramp"] --> REMOVE["Step 5 · legacy removal"] classDef here fill:#f2994a,stroke:#b35c00,color:#1a1a1a,font-weight:bold ``` - Part of FE-2482
…rtal (Comfy-Org#18139) ## Why Comfy-Org#17853 put cancel, resubscribe **and** the payment portal on the subscription rail. `cancelSubscriptionSdkRail.spec.ts` covered cancel only, so two of the three shipped with no browser case on either rail — and the portal is the one with the most branching, because Comfy-Org#17922 added a three-destination cascade behind it. ## How `browser_tests/tests/dialogs/subscriptionLifecycleSdkRail.spec.ts`, a sibling of the cancel spec rather than an extension of it: both actions need a cancelled subscription and a populated plan catalog, which the cancel spec's active-subscription fixture does not have. Six rows plus the cascade. **Resubscribe — off / on / 404.** Same discriminator as cancel: the SDK transport runs on `fetch` and sends an `Idempotency-Key` matching the body's `idempotency_key`; the legacy workspace client runs on axios' XHR and sends neither. The 404 row proves the fallback fires once and the second attempt is the legacy one. **The six-row `/api/billing/plans` fixture** is the gap Comfy-Org#17853's evidence run recorded. The Reactivate plan button reads the catalog to name the plan being resumed, so an empty or one-row `plans` response never renders it — which is why resubscribe had no browser case to extend in the first place. **Payment portal — off / on / 404,** with one assertion that is deliberately a non-defect: `openPaymentPortal` carries **no** idempotency key on either rail, because it is a plain POST outside the operation lifecycle. The spec asserts its absence rather than treating it as missing, so a later change that adds one is noticed rather than assumed correct. **The blocked-popup cascade.** `manageSubscription` tries three destinations in order — the hosted billing-web page, then the rail, then the legacy call — and each opens a different page, so a browser refusing one says nothing about the next. The last row refuses every `window.open` and asserts the rail is still asked and the legacy call still runs after it. A refused tab must not be read as "the portal is handled", which is the regression Comfy-Org#17922 fixed. The `window.open` stand-in is the one from `hostedBillingDestination.spec.ts` — a proxy that records the destination instead of navigating, so a disowned-tab open cannot steer the test page — extended to record more than one destination, since the cascade opens several. ## AS IS / TO BE **No product change** — this PR adds a spec file and touches no source. There is nothing to capture; what changes is what CI proves about code already on `main`. ## Testing - `subscriptionLifecycleSdkRail.spec.ts` (new, `@cloud`) — 7 rows as above. - `pnpm typecheck`, `pnpm typecheck:browser` and `pnpm lint` pass. **This spec has not been executed locally.** It needs a cloud backend on `:8188`, which this checkout has no access to, so CI is its first run. Reviewers should treat a red `@cloud` shard here as the spec's own problem rather than a regression, and I will chase it. ## Plan position Milestone 1, Step 1b — [PR plan](https://linear.app/comfyorg/document/milestone-1-pr-plan-605f42c5e709). This is **PR 15**, backfill for code already on `main` (Comfy-Org#17853, Comfy-Org#17922), independent of every Step 1 PR and of the other two Step 1b PRs. | PR | Step | Tickets | What | Status | | --- | --- | --- | --- | --- | | 1 | 1 | FE-2469 | operation-state projections | merged — Comfy-Org#18036 | | 2 | 1 | FE-2467 | billing events reader | open — Comfy-Org#18042 | | 3 | 1 | FE-2479 | usage log on the rail | open — Comfy-Org#18047 | | 4 | 1 | FE-2468 | payment recovery on the rail | open — Comfy-Org#18060 | | 5 | 1 | FE-2470 | team checkout on the rail | open — Comfy-Org#18136 | | 6 | 1 | FE-2471 | one status reader | open — Comfy-Org#18092 | | 7 | 1 | FE-2480 + FE-2481 | checkout reads on the rail | open — Comfy-Org#18134 | | 8 | 1 | FE-2482 | subscription panel on the rail | open — Comfy-Org#18133 | | 9 | 1 | FE-2484 + FE-2483 + FE-2485 | recovery on the rail | open — Comfy-Org#18135 | | 10 | 1 | FE-2474 | top-up dialog adapter | open — Comfy-Org#18132 | | 11 | 1 | FE-2481 | one `proration_at` rule | backend answer | | 12 | 1 | FE-2472 | table-driven safety net | open — Comfy-Org#18137 | | 13 | 1b | FE-2475 | top-up rail E2E | open — Comfy-Org#18138 | | 14 | 1b | FE-2476 | six reads E2E | needs 3 | | **15** | **1b** | **FE-2477** | **resubscribe + portal E2E** | **this PR** | ```mermaid flowchart LR PR15["PR 15 · FE-2477<br/>resubscribe + portal E2E"]:::here STEP1["Step 1 · PRs 1-12"] PR13["PR 13 · FE-2475"] PR3["PR 3 · FE-2479"] --> PR14["PR 14 · FE-2476"] STEP1 --> BAKE["Step 3 · staging bake"] PR13 --> BAKE PR14 --> BAKE PR15 --> BAKE BAKE --> RAMP["Step 4 · production ramp"] --> REMOVE["Step 5 · legacy removal"] classDef here fill:#f2994a,stroke:#b35c00,color:#1a1a1a,font-weight:bold ``` - Part of FE-2477
Stacked on #17783 (base branch
jaewon/fe-2210-hosted-destination-port); merge that first.Why
Phase 5 slice 1 (#17665) moved top-up onto the Billing SDK behind
billing_sdk_topup_enabled. The subscription actions the host already owns — cancel, resubscribe, and opening the payment portal — still call the workspace API directly and rely on the legacy poller for settlement and telemetry. This slice moves those three onto the SDK's commands behind their own server flag,billing_sdk_subscription_enabled(already on/api/featuresvia Comfy-Org/cloud#9248, PostHog at 0%), so the eight-state lifecycle, idempotency, recovery and telemetry come from one implementation. Subscribe and plan change are slice 2b, stacked on this PR.How
billingSdkSubscriptionRailEnabled=billing_sdk_subscription_enabledANDunified_cloud_auth, exactly like the top-up rail.useSubscriptionRail()reads it once, synchronously, at the start of an action, so a flag flip mid-flow cannot issue on one rail and observe on the other.useWorkspaceBilling.cancelSubscription / resubscribe / manageSubscriptiontry the rail first; the store runssdk.commands.cancelSubscription(),resubscribe(),openPaymentPortal({ returnUrl })and projects the result onto what the adapter already does with the legacy calls: settle, or throw aWorkspaceApiError(message is the host's, since the SDK never carries server text;serverCodelands in.code). A command that settles in any phase butsucceededis a failure, matching the poller. The refresh after success mirrors the poller's: cancel → status + balance + capabilities; resubscribe →reconcileSubscriptionSuccess+ capabilities.unavailable: the adapter runs its legacy body for that action, and the store latches the route as unavailable for the tab so later actions go straight to legacy without another failed round trip. Every other failure — includingSUPERSEDED— is thrown, never retried on legacy, so a late or superseded result cannot double-issue.toBillingTelemetryEventalready emits the poller's payload shape, so dashboards cannot tell the rails apart.subscribe,previewSubscribe,useSubscriptionCheckoutanduseLegacyBillingare untouched.AS-IS / TO-BE
Idempotency-Keyon the request), settlement through the operation lifecycle; a 404 falls back to the legacy call.Testing
vitest run src/platform/workspace/billing src/composables/billing src/platform/workspace/composables src/platform/workspace/stores src/composables/useFeatureFlagspnpm typecheck,pnpm typecheck:browser,lint,format:check,knipfallow audit --changed-since origin/jaewon/fe-2210-hosted-destination-portbrowser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts(cloud project)PLAYWRIGHT_TEST_URL=http://localhost:5173 pnpm exec playwright test --project=cloud browser_tests/tests/dialogs/cancelSubscriptionSdkRail.spec.ts --reporter=list. Flag off → legacy request, flow unchanged; flag on → SDK request (Idempotency-Key), same dialog outcome; flag on + 404 → legacy fallback.Where this sits in the plan
Billing SDK track FE-2210 (implementation plan V2). Hybrid model: top-up in-app, subscription management / invoices / payment methods on the hosted billing app.
@comfyorg/account-uicomposables +CheckoutStepsbilling_sdk_topup_enabledhosted_billing_destinationserver flag read by the hosthostedDestinationport on the lifecycle, value on operation state@comfyorg/account→@comfyorg/account-corerenamebilling-contractroute builder +return_toregistrycreateHostedTopupCheckoutpreviewSubscribecommandusePlans,usePaymentMethods,usePreviewSubscribe)ci-billing-web-unit.yaml)/v1entry routing + subscription / payment-method surfacesingest-types,account-core,billing-contract), Platform install, billing-web live top-upbilling_sdk_subscription_enabledpreviewSubscribequote, then subscribe; the SDK stops short-circuiting an active plan)needsCustomerAttentionpredicate (from the #17665 review)BillingServerCode(from the #17656 review)useCreditsclears onSUPERSEDED(from the #17799 review)SUPERSEDED(from the #17798 review)