Repository navigation
FE-2900 feat(account-core): lazy workspace-token mint from the web session - #18870
Conversation
readWebSession, createWebSession, deleteWebSession and revokeAllWebSessions for the shared __Host-comfy_session cookie on ingest. Every call sends credentials, failures are coded (six session codes plus a transient and a refused bucket), and 429/5xx/network never read as a sign-out. Nothing imports it yet; importing it starts no timer, listener or request.
authorize decides the credential headers for one request: a cookie session on ingest sends the workspace header, the CSRF token on unsafe methods, the SDK client header, and credentials include; a resource target gets a Bearer workspace token from an injected source; Firebase and API-key principals keep today's single header. createCredentialedBillingTransport opts in through webSession: headers come from authorize, and csrf_invalid is retried once after re-reading the session for the same user. A changed user abandons the request; origin_not_allowed, cross_site_request and workspace_access_denied are never retried. Hosts that do not pass webSession are unchanged.
…/api/auth/session schema
… until its contract exists An error body that does not parse now lets the status decide: 4xx is SESSION_REQUEST_REFUSED (not retryable), 429/5xx stay SESSION_UNAVAILABLE. revokeAllWebSessions is removed until cloud#10589 adds the route and its generated schema. createWebSession can check the read-back user.
…client' into dante01yoon/fe-2895-request-auth
…client' into dante01yoon/fe-2895-request-auth
…equest-auth # Conflicts: # packages/account-core/package.json # packages/account-core/scripts/smokePack.ts # packages/account-core/src/webSessionInertImport.test.ts
Services other than ingest cannot read the web session cookie. A session host now mints a short-lived workspace token at POST /auth/token from the cookie on first use, reuses it per (session user, workspace) until it nears expiry, shares one request among concurrent callers, drops its cache when the session user changes or the session is dead, and holds off until a 429's Retry-After passes. Failures are web-session codes, never thrown; the getWorkspaceToken adapter for createRequestAuthorizer rejects with them.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe account-core package adds a public session-token minting API. It sends session-based token requests, maps failures, and caches credentials by workspace and session user. Tests cover request behavior, caching, and the published package entry point. ChangesSession token minting
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant CredentialConsumer
participant SessionTokenMint
participant getSession
participant AuthTokenEndpoint
CredentialConsumer->>SessionTokenMint: mint(workspaceId)
SessionTokenMint->>getSession: Read current session
getSession-->>SessionTokenMint: Session and user
SessionTokenMint->>AuthTokenEndpoint: POST /auth/token with session headers and optional workspace
AuthTokenEndpoint-->>SessionTokenMint: Token response or error
SessionTokenMint-->>CredentialConsumer: Credential result or failure
Merge Risk: 🟡 Moderate · up to An earlier session’s token can reach a caller after the session switches away and back. Reject stale request results and assert that outcome in the test before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The new token API has two security-relevant gaps: it does not reliably discard credentials across every sign-out and sign-in sequence, and it does not check that a returned token belongs to the requested workspace. No production application is wired to it in this PR, and the server-side protections have not been verified here. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🎨 Storybook: ✅ Built — View Storybook🌐 Website E2ETip All tests passed.
🎭 Playwright: ✅ 2131 passed, 0 failed📊 Browser Reports
🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 13178fc240961c0d98be9055401838058c1085ff
Full docs: ADR-DEVEX-LINT-0015 🧩 Custom Nodes Ecosystem Matrix: ✅ PassedExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff. Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 📦 Bundle: 10 MB gzip ⚪ 0 BDetailsSummary
Category Glance App Entry Points — 3.77 kB (baseline 3.77 kB) • ⚪ 0 BMain entry bundles and manifests Status: 1 unchanged Graph Workspace — 1.45 MB (baseline 1.45 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration Status: 3 unchanged Views & Navigation — 134 kB (baseline 134 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces Status: 18 unchanged Panels & Settings — 639 kB (baseline 639 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens Status: 28 unchanged User & Accounts — 39.4 kB (baseline 39.4 kB) • ⚪ 0 BAuthentication, profile, and account management bundles Status: 11 unchanged Editors & Dialogs — 126 kB (baseline 126 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors Status: 8 unchanged UI Components — 125 kB (baseline 125 kB) • ⚪ 0 BReusable component library chunks Status: 16 unchanged Data & Services — 3.98 MB (baseline 3.98 MB) • ⚪ 0 BStores, services, APIs, and repositories Status: 15 unchanged Utilities & Hooks — 576 kB (baseline 576 kB) • ⚪ 0 BHelpers, composables, and utility bundles Status: 36 unchanged Vendor & Third-Party — 17.4 MB (baseline 17.4 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 18 unchanged Other — 17.9 MB (baseline 17.9 MB) • ⚪ 0 BBundles that do not match a named category Status: 301 unchanged ⚡ Performance Report
Show regressions
All metrics
Historical variance (last 15 runs)
Trend (last 15 commits on main)
Raw data{
"timestamp": "2026-09-26T02:26:47.557Z",
"gitSha": "2bb59e476815a435400191c846376843a901c865",
"branch": "dante01yoon/fe-2900-session-token-mint",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 1989.5460000000185,
"styleRecalcs": 9,
"styleRecalcDurationMs": 4.442999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 438.624,
"heapDeltaBytes": 3938512,
"heapUsedBytes": 66351252,
"domNodes": -228,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 8.186000000000002,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2039.2180000000053,
"styleRecalcs": 10,
"styleRecalcDurationMs": 4.505999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 458.083,
"heapDeltaBytes": -2350612,
"heapUsedBytes": 60069008,
"domNodes": -228,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 9.727000000000004,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1767.5910000000385,
"styleRecalcs": 69,
"styleRecalcDurationMs": 16.931,
"layouts": 12,
"layoutDurationMs": 3.9390000000000005,
"taskDurationMs": 805.3950000000001,
"heapDeltaBytes": 9446812,
"heapUsedBytes": 70683728,
"domNodes": -228,
"jsHeapTotalBytes": 5234688,
"scriptDurationMs": 161.73,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1826.2059999999565,
"styleRecalcs": 71,
"styleRecalcDurationMs": 18.606,
"layouts": 12,
"layoutDurationMs": 4.518000000000001,
"taskDurationMs": 868.401,
"heapDeltaBytes": -4716512,
"heapUsedBytes": 57857336,
"domNodes": -228,
"jsHeapTotalBytes": 5496832,
"scriptDurationMs": 169.14499999999998,
"eventListeners": -164,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1709.549999999922,
"styleRecalcs": 31,
"styleRecalcDurationMs": 10.823,
"layouts": 6,
"layoutDurationMs": 1.1990000000000003,
"taskDurationMs": 347.422,
"heapDeltaBytes": 2137396,
"heapUsedBytes": 64542024,
"domNodes": 53,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 13.506999999999998,
"eventListeners": 15,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1739.0890000000354,
"styleRecalcs": 32,
"styleRecalcDurationMs": 10.09,
"layouts": 6,
"layoutDurationMs": 1.1740000000000002,
"taskDurationMs": 338.99,
"heapDeltaBytes": 2162312,
"heapUsedBytes": 64636568,
"domNodes": 53,
"jsHeapTotalBytes": 5242880,
"scriptDurationMs": 13.033,
"eventListeners": 15,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 682.0519999999988,
"styleRecalcs": 11,
"styleRecalcDurationMs": 3.772999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 449.0729999999999,
"heapDeltaBytes": 18747920,
"heapUsedBytes": 81378140,
"domNodes": 0,
"jsHeapTotalBytes": 5242880,
"scriptDurationMs": 168.25699999999998,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 696.0350000000517,
"styleRecalcs": 11,
"styleRecalcDurationMs": 3.6990000000000007,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 451.04,
"heapDeltaBytes": 18470672,
"heapUsedBytes": 80867976,
"domNodes": 0,
"jsHeapTotalBytes": 5505024,
"scriptDurationMs": 171.154,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-order-dense-n200-w200-i120",
"durationMs": 1255.072000000041,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 960.456,
"heapDeltaBytes": -14181344,
"heapUsedBytes": 73504640,
"domNodes": -259,
"jsHeapTotalBytes": 19267584,
"scriptDurationMs": 69.39200000000001,
"eventListeners": -207,
"totalBlockingTimeMs": 578,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-order-dense-n200-w200-i120",
"durationMs": 1245.6379999999854,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 926.9929999999998,
"heapDeltaBytes": -15351504,
"heapUsedBytes": 72389336,
"domNodes": -259,
"jsHeapTotalBytes": 19791872,
"scriptDurationMs": 74.152,
"eventListeners": -185,
"totalBlockingTimeMs": 569,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-order-sparse-n1000-w20-i120",
"durationMs": 877.8670000000375,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 504.9860000000006,
"heapDeltaBytes": 14913984,
"heapUsedBytes": 89985216,
"domNodes": 0,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 175.064,
"eventListeners": 0,
"totalBlockingTimeMs": 241,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "dom-widget-order-sparse-n1000-w20-i120",
"durationMs": 844.2420000000084,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 463.79000000000036,
"heapDeltaBytes": 14418468,
"heapUsedBytes": 91093504,
"domNodes": 0,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 159.981,
"eventListeners": 0,
"totalBlockingTimeMs": 228,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "extension-clean-combined-draw",
"durationMs": 10333.889,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 9531.571,
"heapDeltaBytes": -1059564,
"heapUsedBytes": 82411864,
"domNodes": 0,
"jsHeapTotalBytes": 7077888,
"scriptDurationMs": 8127.926,
"eventListeners": 0,
"totalBlockingTimeMs": 1710,
"frameDurationMs": 18.890000000000025,
"p95FrameDurationMs": 50
},
{
"name": "extension-clean-combined-draw",
"durationMs": 9391.782000000036,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8716.793,
"heapDeltaBytes": 10007612,
"heapUsedBytes": 92455956,
"domNodes": 0,
"jsHeapTotalBytes": 5242880,
"scriptDurationMs": 7413.008,
"eventListeners": 0,
"totalBlockingTimeMs": 1099,
"frameDurationMs": 18.890000000000025,
"p95FrameDurationMs": 50
},
{
"name": "extension-rgthree-prototype-draw",
"durationMs": 10688.29699999992,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 9773.271,
"heapDeltaBytes": 11097056,
"heapUsedBytes": 87371084,
"domNodes": 0,
"jsHeapTotalBytes": 6291456,
"scriptDurationMs": 8098.614999999999,
"eventListeners": 0,
"totalBlockingTimeMs": 1131,
"frameDurationMs": 19.99999999999994,
"p95FrameDurationMs": 50
},
{
"name": "extension-rgthree-prototype-draw",
"durationMs": 11442.969000000063,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 10404.008000000002,
"heapDeltaBytes": -9245828,
"heapUsedBytes": 73585996,
"domNodes": 0,
"jsHeapTotalBytes": 8126464,
"scriptDurationMs": 8636.319,
"eventListeners": 0,
"totalBlockingTimeMs": 1485,
"frameDurationMs": 20,
"p95FrameDurationMs": 50
},
{
"name": "large-graph-idle",
"durationMs": 2037.733000000003,
"styleRecalcs": 9,
"styleRecalcDurationMs": 4.242000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 611.6550000000001,
"heapDeltaBytes": -13809960,
"heapUsedBytes": 72903272,
"domNodes": -228,
"jsHeapTotalBytes": 4222976,
"scriptDurationMs": 33.657999999999994,
"eventListeners": -164,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2022.6319999999305,
"styleRecalcs": 8,
"styleRecalcDurationMs": 3.526999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 586.5740000000001,
"heapDeltaBytes": 1458220,
"heapUsedBytes": 83194132,
"domNodes": -228,
"jsHeapTotalBytes": -495616,
"scriptDurationMs": 37.62500000000001,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-pan",
"durationMs": 2573.127999999997,
"styleRecalcs": 67,
"styleRecalcDurationMs": 9.282000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1690.3670000000002,
"heapDeltaBytes": 20317420,
"heapUsedBytes": 84976504,
"domNodes": -228,
"jsHeapTotalBytes": 1536000,
"scriptDurationMs": 875.536,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2365.8140000000003,
"styleRecalcs": 67,
"styleRecalcDurationMs": 9.311999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1638.5810000000004,
"heapDeltaBytes": 24080872,
"heapUsedBytes": 88525316,
"domNodes": -228,
"jsHeapTotalBytes": 749568,
"scriptDurationMs": 833.434,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 3676.148000000012,
"styleRecalcs": 63,
"styleRecalcDurationMs": 10.615,
"layouts": 60,
"layoutDurationMs": 13.361,
"taskDurationMs": 1693.743,
"heapDeltaBytes": 8470292,
"heapUsedBytes": 74281224,
"domNodes": 0,
"jsHeapTotalBytes": 262144,
"scriptDurationMs": 789.745,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.669999999999952,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-zoom",
"durationMs": 3659.163999999919,
"styleRecalcs": 63,
"styleRecalcDurationMs": 11.411000000000001,
"layouts": 60,
"layoutDurationMs": 13.600999999999999,
"taskDurationMs": 1714.4810000000002,
"heapDeltaBytes": 10208208,
"heapUsedBytes": 75698056,
"domNodes": 0,
"jsHeapTotalBytes": 524288,
"scriptDurationMs": 799.3670000000001,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3172.8819999999587,
"styleRecalcs": 45,
"styleRecalcDurationMs": 6.4670000000000005,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1985.634,
"heapDeltaBytes": -4203992,
"heapUsedBytes": 80970644,
"domNodes": 0,
"jsHeapTotalBytes": 6737920,
"scriptDurationMs": 980.5769999999999,
"eventListeners": -163,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "legacy-node-drag",
"durationMs": 3209.865000000036,
"styleRecalcs": 47,
"styleRecalcDurationMs": 6.983,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2008.9420000000002,
"heapDeltaBytes": -3674420,
"heapUsedBytes": 81866820,
"domNodes": -228,
"jsHeapTotalBytes": 6213632,
"scriptDurationMs": 1001.465,
"eventListeners": -163,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "minimap-idle",
"durationMs": 2017.400000000066,
"styleRecalcs": 7,
"styleRecalcDurationMs": 2.6510000000000007,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 562.1100000000001,
"heapDeltaBytes": 20404880,
"heapUsedBytes": 84998956,
"domNodes": -228,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 40.784,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2052.8739999999743,
"styleRecalcs": 7,
"styleRecalcDurationMs": 7.052,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 624.3349999999999,
"heapDeltaBytes": -5985040,
"heapUsedBytes": 82187424,
"domNodes": -228,
"jsHeapTotalBytes": 552960,
"scriptDurationMs": 35.504999999999995,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 599.8349999999846,
"styleRecalcs": 47,
"styleRecalcDurationMs": 5.953999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 400.66200000000003,
"heapDeltaBytes": 13860856,
"heapUsedBytes": 76548876,
"domNodes": 0,
"jsHeapTotalBytes": 5242880,
"scriptDurationMs": 147.93900000000002,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 607.4639999999363,
"styleRecalcs": 48,
"styleRecalcDurationMs": 6.469999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 396.219,
"heapDeltaBytes": 13841212,
"heapUsedBytes": 83739740,
"domNodes": 0,
"jsHeapTotalBytes": 5242880,
"scriptDurationMs": 143.59000000000003,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 1992.3270000000457,
"styleRecalcs": 11,
"styleRecalcDurationMs": 4.747,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 371.21000000000004,
"heapDeltaBytes": 2306976,
"heapUsedBytes": 64997840,
"domNodes": -244,
"jsHeapTotalBytes": 4972544,
"scriptDurationMs": 9.131,
"eventListeners": -188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 2005.3269999999657,
"styleRecalcs": 11,
"styleRecalcDurationMs": 4.097000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 471.356,
"heapDeltaBytes": 12775668,
"heapUsedBytes": 76326756,
"domNodes": -244,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 9.101,
"eventListeners": -188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1689.3110000000888,
"styleRecalcs": 73,
"styleRecalcDurationMs": 17.306,
"layouts": 16,
"layoutDurationMs": 5.535,
"taskDurationMs": 797.798,
"heapDeltaBytes": 16615264,
"heapUsedBytes": 80006668,
"domNodes": -244,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 110.673,
"eventListeners": -188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1724.2420000000038,
"styleRecalcs": 59,
"styleRecalcDurationMs": 18.669999999999998,
"layouts": 16,
"layoutDurationMs": 6.680999999999999,
"taskDurationMs": 815.449,
"heapDeltaBytes": 11138464,
"heapUsedBytes": 73675856,
"domNodes": -244,
"jsHeapTotalBytes": 4972544,
"scriptDurationMs": 117.782,
"eventListeners": -188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-transition-enter",
"durationMs": 1418.1780000000117,
"styleRecalcs": 18,
"styleRecalcDurationMs": 30.263000000000005,
"layouts": 5,
"layoutDurationMs": 13.208999999999998,
"taskDurationMs": 962.1889999999997,
"heapDeltaBytes": -6272708,
"heapUsedBytes": 81887440,
"domNodes": 13667,
"jsHeapTotalBytes": 11272192,
"scriptDurationMs": 32.199999999999996,
"eventListeners": 2383,
"totalBlockingTimeMs": 146,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8829.249000000003,
"styleRecalcs": 250,
"styleRecalcDurationMs": 32.387,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6106.683999999999,
"heapDeltaBytes": 8830732,
"heapUsedBytes": 90405112,
"domNodes": -228,
"jsHeapTotalBytes": 221184,
"scriptDurationMs": 2965.0999999999995,
"eventListeners": -142,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 8623.051000000032,
"styleRecalcs": 251,
"styleRecalcDurationMs": 33.90899999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 5921.253,
"heapDeltaBytes": 10425916,
"heapUsedBytes": 89581584,
"domNodes": -228,
"jsHeapTotalBytes": 4902912,
"scriptDurationMs": 2801.9420000000005,
"eventListeners": -164,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 16877.88599999999,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16482.875,
"heapDeltaBytes": -38490364,
"heapUsedBytes": 183298684,
"domNodes": -8049,
"jsHeapTotalBytes": -18427904,
"scriptDurationMs": 253.26100000000002,
"eventListeners": -14923,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.773333333333238,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-idle",
"durationMs": 16779.06000000007,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16374.672,
"heapDeltaBytes": -42090960,
"heapUsedBytes": 195537140,
"domNodes": -8049,
"jsHeapTotalBytes": -18284544,
"scriptDurationMs": 284.70399999999995,
"eventListeners": -14923,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 20212.733000000073,
"styleRecalcs": 148,
"styleRecalcDurationMs": 16.716000000000008,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 20039.181,
"heapDeltaBytes": -45569036,
"heapUsedBytes": 191922736,
"domNodes": -8049,
"jsHeapTotalBytes": -18092032,
"scriptDurationMs": 853.8779999999999,
"eventListeners": -14923,
"totalBlockingTimeMs": 35,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 20640.02900000014,
"styleRecalcs": 146,
"styleRecalcDurationMs": 18.469999999999985,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 20451.477,
"heapDeltaBytes": -48817956,
"heapUsedBytes": 191409592,
"domNodes": -8049,
"jsHeapTotalBytes": -19623936,
"scriptDurationMs": 926.944,
"eventListeners": -14923,
"totalBlockingTimeMs": 48,
"frameDurationMs": 17.77333333333336,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-node-resize-workload",
"durationMs": 4736.65399999993,
"styleRecalcs": 20,
"styleRecalcDurationMs": 79.71899999999998,
"layouts": 20,
"layoutDurationMs": 23.295999999999996,
"taskDurationMs": 4636.373,
"heapDeltaBytes": -44182536,
"heapUsedBytes": 181098964,
"domNodes": -8049,
"jsHeapTotalBytes": 20963328,
"scriptDurationMs": 90.026,
"eventListeners": -14923,
"totalBlockingTimeMs": 88,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-node-resize-workload",
"durationMs": 6025.220999999874,
"styleRecalcs": 20,
"styleRecalcDurationMs": 76.10599999999998,
"layouts": 20,
"layoutDurationMs": 22.839,
"taskDurationMs": 5979.571,
"heapDeltaBytes": -27500576,
"heapUsedBytes": 197562928,
"domNodes": -8048,
"jsHeapTotalBytes": 17817600,
"scriptDurationMs": 110.997,
"eventListeners": -14923,
"totalBlockingTimeMs": 359,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8598.165999999992,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8461.315999999999,
"heapDeltaBytes": -10859748,
"heapUsedBytes": 176108000,
"domNodes": 0,
"jsHeapTotalBytes": -29622272,
"scriptDurationMs": 161.4279999999999,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 18.330000000000048,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8448.758999999882,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8336.157,
"heapDeltaBytes": 7831332,
"heapUsedBytes": 186747124,
"domNodes": 0,
"jsHeapTotalBytes": -9437184,
"scriptDurationMs": 132.085,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.77333333333336,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 461.4840000000413,
"styleRecalcs": 12,
"styleRecalcDurationMs": 17.686,
"layouts": 3,
"layoutDurationMs": 1.055,
"taskDurationMs": 110.431,
"heapDeltaBytes": 5012096,
"heapUsedBytes": 66901608,
"domNodes": 104,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 11.008999999999999,
"eventListeners": 81,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "workflow-execution",
"durationMs": 449.2419999999129,
"styleRecalcs": 13,
"styleRecalcDurationMs": 16.531,
"layouts": 4,
"layoutDurationMs": 1.778,
"taskDurationMs": 106.69400000000002,
"heapDeltaBytes": 4764752,
"heapUsedBytes": 66777976,
"domNodes": 99,
"jsHeapTotalBytes": 524288,
"scriptDurationMs": 10.424000000000001,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
}
]
}🔬 E2E Coverage
Top 10 files by uncovered lines
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #18870 +/- ##
=========================================
Coverage 84.00% 84.01%
=========================================
Files 3157 3158 +1
Lines 154134 154218 +84
Branches 39635 41985 +2350
=========================================
+ Hits 129486 129571 +85
+ Misses 23049 23047 -2
- Partials 1599 1600 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 12 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
|
… mint from the web session (#19000) Backport of #18870 to `core/1.55` (cherry-pick -x of 70ce571). ## Why Ships the lazy workspace-token mint (`@comfyorg/account-core/sessionTokenMint`) on the 1.55 line, next to `authorize()` from #18716 (already backported as #18940/#18941). ## Root cause The backport bot hit conflicts in `packages/account-core/package.json` (exports), `scripts/smokePack.ts`, `src/core/importGuard.test.ts` and `src/webSessionInertImport.test.ts`. On main these lists also carry `webSessionIdentity` from #18715 (FE-2894), which is not on 1.55. ## How Kept the release branch's code and added only #18870's own entries: the `./sessionTokenMint` export (source + dist), its smoke-pack import/value/type, its inert-import case, and the Firebase import-guard case (`it.for(['webSession.ts', 'sessionTokenMint.ts'])`). Dropped every `webSessionIdentity` entry. `sessionTokenMint.ts` and its test apply unchanged; they import only `requestAuth`, `credentialCache`, `sessionContracts`, `testing` and `@comfyorg/ingest-types/zod`, all present on 1.55. Verified with `pnpm typecheck:account-core` and the sessionTokenMint, importGuard, webSessionInertImport and requestAuth vitest files (73 passed). ## AS IS / TO BE No UI change (inert behind `unified_web_session`). Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com>
…ssion (#18870) > **Stacked on #18716 (FE-2895). Do not merge** until #18716 merges and C8 (BE-17069, cloud#10585 + #10697: `POST /api/auth/token` accepts the cookie) is on testcloud. ## Why comfy-api and the other services cannot read the session cookie. A site that arrived by session has no Firebase login to hand them. TDD §7/§12 has the site mint a short-lived workspace token from the session, lazily and only when a non-ingest call needs one. This is the token source `authorize()` (#18716) takes for its `resource` target. ## How New entry `@comfyorg/account-core/sessionTokenMint`: `createSessionTokenMint({ apiBaseUrl, fetchImpl, getSession, now?, refreshBufferMs? })` returns: - `mint(workspaceId?)`, which returns a coded result; - `getWorkspaceToken(workspaceId?)`, which plugs into `createRequestAuthorizer({ getWorkspaceToken })` and rejects with `SessionTokenError` on failure. Details: - **Request.** `POST /auth/token` with `credentials: 'include'`, `X-Comfy-Client`, `X-CSRF-Token` and `X-Comfy-Workspace-ID`. The body is `{}` for the personal workspace or `{ workspace_id }`. No `Authorization` header is sent. The response is parsed with the generated `zExchangeTokenResponse`, since C8 leaves the 200 shape unchanged. - **Lazy.** Nothing is sent until the first call. - **Cache.** Tokens are cached per workspace and owned by the current session user, and reused until 60 s before expiry. Concurrent callers for one workspace share a single request. A user change or sign-out drops the cache and anything in flight, and a token that arrives after the user changed is not cached. - **Failure codes.** A 401 is the session's code (and clears the cache). 403 `csrf_invalid` is `CSRF_STALE` and 403 `workspace_access_denied` is `WORKSPACE_ACCESS_DENIED`. Other 403s, 400 and 404 are refused. 5xx and network errors are transient. A 429 carries `retryAfterMs` and holds further requests until then. - **Inert on import.** It is added to the importGuard closure, the inert-import test, package exports and smokePack. No app wires it yet, and the flag-off harness is unchanged (4/4). - **For review:** - It sends `X-Comfy-Workspace-ID` equal to the body's `workspace_id`. C8 only rejects a header that names a different workspace; if you'd rather send none, it's a one-line removal. - It has its own classifier because C8 defines a code-less 401 as a dead session, where `webSession.ts` refuses it. ## AS IS / TO BE No UI; the evidence is tests. - AS IS: a session-only site has no token for comfy-api. - TO BE: tests cover zero requests before the first call, headers and credentials, cache hit, re-mint at expiry, single-flight, the cache dropping on a user change, per-workspace keys, a late token not cached across users, 401/403/404/429/5xx mapping, and Retry-After. Eight mutations, each reverted with the full suite rerun, all go red: cache key, user-change drop, expiry buffer, credentials, single-flight, Retry-After, stale-owner guard, and 401 cache clear. Checks: account-core 1139 tests pass; typecheck, lint, knip, fallow and smoke:pack are clean. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b (sections 7, 9, 12, F6) - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2900 - Contract: Comfy-Org/cloud#10585, Comfy-Org/cloud#10697 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + probe switch (readers) | #18708 merged; readers in progress | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | #18710 merged; revoke-all #18869, do not merge | | FE-2893 | ADR | none | #18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | #18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | #18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | #18719, do not merge | | **FE-2900 (this PR)** | lazy token mint from the session | FE-2895, C8 cloud#10585 | #18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | #18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | #18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | in progress | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | FE-2896 / 2899 / 2898 | website header, website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | #18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2900 thisPr ``` - Blocked by: #18716 (FE-2895) and C8 cloud#10585 on testcloud. - Unblocks: comfy-api callers on session sites (FE-2904 host wiring, FE-2898 billing-web). --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> (cherry picked from commit 70ce571)
…n mint from the web session (#19001) Backport of #18870 to `cloud/1.55` (cherry-pick -x of 70ce571). ## Why Ships the lazy workspace-token mint (`@comfyorg/account-core/sessionTokenMint`) on the 1.55 line, next to `authorize()` from #18716 (already backported as #18940/#18941). ## Root cause The backport bot hit conflicts in `packages/account-core/package.json` (exports), `scripts/smokePack.ts`, `src/core/importGuard.test.ts` and `src/webSessionInertImport.test.ts`. On main these lists also carry `webSessionIdentity` from #18715 (FE-2894), which is not on 1.55. ## How Kept the release branch's code and added only #18870's own entries: the `./sessionTokenMint` export (source + dist), its smoke-pack import/value/type, its inert-import case, and the Firebase import-guard case (`it.for(['webSession.ts', 'sessionTokenMint.ts'])`). Dropped every `webSessionIdentity` entry. `sessionTokenMint.ts` and its test apply unchanged; they import only `requestAuth`, `credentialCache`, `sessionContracts`, `testing` and `@comfyorg/ingest-types/zod`, all present on 1.55. Verified with `pnpm typecheck:account-core` and the sessionTokenMint, importGuard, webSessionInertImport and requestAuth vitest files (73 passed). ## AS IS / TO BE No UI change (inert behind `unified_web_session`). Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com>
…omfy-Org#19002) ## Why The web session PRs merged with four non-blocking review notes from Christian, and CodeRabbit found one real defect after Comfy-Org#18719 merged. All of this code is on main now, so the fixes land together here. ## Root cause (the defect) `signedIn()` awaited `createWebSession` (a POST, then a GET) and then always dispatched `session_created` and published `sign_in`. It never checked whether `signOut()` had run in the meantime. - The cloud store starts the interactive session without awaiting it, so a user who logs out quickly hits exactly this window. - The tab went back to `signed_in`, and every signed-out sibling tab adopted the published `sign_in`. - If the POST reached the server after the DELETE, a live session cookie also stayed behind. The epoch alone can't catch this: a sign-out from a settling or idle state emits no `account_changed`, so the epoch never moves. ## How - **Sign-out wins over an in-flight sign-in** (CodeRabbit on Comfy-Org#18871, Major). `signOut()` bumps a sign-out counter, and `signedIn()` captures it before the POST. If the counter changed, the new session is: - not dispatched and not published; - deleted again, so no live cookie is left, unless a newer sign-in has started since (that sign-in owns the cookie now); - answered as `SESSION_REVOKED`, or with the cleanup's failure if the DELETE fails. - **FE-2894: adopt a live session when the remembered-login lookup throws** (Christian on Comfy-Org#18715). A failed `currentUserId()` used to discard a successful session read and retry. Now it only matters when there is no live session. With one, the lookup can skip nothing but the different-user sign-out, so the session is adopted. - **CSRF replay re-checks scope after the re-read** (Christian on Comfy-Org#18716). `stillInScope()` is checked again between the re-read and the replay, so a request superseded during that round trip is abandoned rather than replayed. - **Comments Christian asked for:** - on `zSharedMessage` (Comfy-Org#18719): the shared host-only cookie is what licenses trusting a sibling tab's answer; - in `mint()` (Comfy-Org#18870): the cache check deliberately precedes the backoff. ## Tests - **Sign-out during sign-in:** a lifecycle test holds the POST, signs out, then releases it. It checks that both the tab and its sibling stay `signed_out`, and that the late session is deleted (`DELETE, POST, GET, DELETE`). - **Lookup throws with a live session:** a boot test checks for `signed_in` with no retry and no local sign-out. The existing test for a failed lookup with no session (retry) still passes. - **Overlapping sign-ins:** a stale sign-in released after a newer one has succeeded sends no DELETE, and the tab stays signed in. - **Failed cleanup:** when the cleanup DELETE fails, the call answers `SESSION_UNAVAILABLE` instead of a clean revocation. - **Scope changes during the re-read:** a transport test checks for `SUPERSEDED` with no second send. - **Mutation check:** reverting any of the three fixes turns exactly its own test red. - `pnpm --filter @comfyorg/account-core` suite: 1199 passed. - The cloud auth tests pass, including the flag-off harness `src/platform/auth/webSessionFlagOff.test.ts`. - `fallow audit`: no issues in the changed files. ## Flag-off parity Every change sits on the web session path, which only runs with `unified_web_session` on. Flag-off behaviour is unchanged, and the flag-off harness passes. ## AS IS / TO BE | Case | AS IS | TO BE | | --- | --- | --- | | Sign out while an interactive sign-in is in flight | the tab and its siblings go back to `signed_in`; a cookie may remain | stays signed out; the late session is deleted | | Session live, remembered-login lookup throws | discards the session and retries | adopts the session | | Scope changes during the CSRF re-read | replays into the old scope | `SUPERSEDED`, no replay | This is library logic with no UI of its own; the tests above are the evidence. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2894 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | **FE-2894 (this PR)** | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715 merged; review follow-ups in this PR | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716 merged | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719 merged | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870 merged | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 merged (Desktop checks open) | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | Comfy-Org#18878, do not merge | | FE-2896 | website header | FE-2891 readers, FE-2894, C11 | Comfy-Org#18877, do not merge | | FE-2899 | website credits | FE-2896, FE-2895, C5 | Comfy-Org#18882, do not merge | | FE-2898 | billing-web on the session (A identity, B transport) | FE-2891 readers, FE-2894, FE-2895, C5 | Comfy-Org#18880 + Comfy-Org#18881, do not merge | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2894 thisPr ``` - Blocked by: none: all the code is on main - Unblocks: none; closes the review notes on Comfy-Org#18715, Comfy-Org#18716, Comfy-Org#18719 and Comfy-Org#18870, and a CodeRabbit finding on Comfy-Org#18871
…or website and billing-web (#18874) > **Do not merge until [BE-17276](https://linear.app/comfyorg/issue/BE-17276) (C11b) settles the `web_session_probe` contract.** Until the server sends the key, every reader resolves to off. Nothing calls these readers yet, so merging changes no request; the hold is only so the contract can't drift under them. ## Why The website and billing-web learn a session visitor's `unified_web_session` only through C11 (cloud#10689). That means `GET /api/features` with `credentials: 'include'` and `X-Comfy-Client`, sent before the site knows the flag. We agreed to gate that request on a global runtime switch served to anonymous callers, `web_session_probe` (BE-17276, Maanil). Then the request and its CORS preflight don't exist until rollout, and turning them off needs no deploy. This PR adds the readers the website header (FE-2896), website credits (FE-2899) and billing-web (FE-2898) will use. ## How - **New entry `@comfyorg/account-core/webSessionFlag`.** - `readWebSessionProbe`: a plain anonymous `GET /api/features` with no credentials and no custom headers, so there is no preflight. It is on only for `web_session_probe === true`. - `resolveUnifiedWebSession({ probe, … })`: sends the credentialed read (`credentials: 'include'`, `cache: 'no-store'`, `X-Comfy-Client`) only when the probe resolves `true`. It returns on only for `unified_web_session === true`. - The probe never feeds into the result: it decides whether to ask, and the per-user answer decides behaviour, so no server state is assembled on the client. - Any failure (network, non-2xx, bad body, timeout) is off, and nothing throws into the apps. Importing the entry is inert, and there are no browser globals in core. - **billing-web.** It reads `web_session_probe` from the anonymous `/api/features` it already fetches for the Firebase config. - `fetchCloudFeatures` / `resolveWebSessionProbe` in `@comfyorg/account-core/firebase` share that memoized request; the timeout must stay 4000 ms to share it. - With the probe absent or false, billing-web's requests are identical to main. `readBillingWebUnifiedWebSession()` is cached per page load. - **website.** It has no anonymous features read today, only the signed-in Bearer read in `workshop-features.ts`. So its probe is one plain anonymous GET. - This is the one accepted flag-off request difference. It is cached per page load, lazy, and never blocks render. - The request is only sent once FE-2896 calls `readUnifiedWebSessionEnabled()`; until then the website is unchanged. - **`X-Comfy-Client`.** `COMFY_CLIENT` is not on main (it lives in #18716), so the value is defined once in this module with the same shape (`name/version`), and a note says it converges with #18716. - The cloud app is unchanged, and `src/platform/auth/webSessionFlagOff.test.ts` passes. ## AS IS / TO BE No UI yet; the evidence is the request tables pinned with `it.for`. | State | billing-web vs main | website vs main | | --- | --- | --- | | probe absent / false / `"true"` | identical | + one plain anonymous GET | | probe true, flag false | + one credentialed GET, result off | + anonymous GET + one credentialed GET, result off | | probe true, flag true | + one credentialed GET, result on | + anonymous GET + one credentialed GET, result on | These rows describe what happens once a consumer calls a reader; nothing calls one in this PR. The `"true"` string row is covered in the account-core tests. A second call sends nothing new. Mutations (each reverted, full suites rerun): | Mutation | Tests red | | --- | --- | | remove the probe gate | core 3, billing-web 3, website 4 | | add credentials to the probe | core 1, website 4 | | OR the probe into the result | core 1 | | drop the cache | billing-web 2, website 4 | | probe timeout ≠ 4000 on billing-web (breaks the shared fetch) | 5 | | truthy comparison in `configSource` | 1 | Checks: vitest passes for account-core 1101, billing-web 198, website 8924 and the flag-off harness 4. Typecheck, oxlint, eslint, oxfmt, knip, fallow (no issues in 12 files) and `checkPublishable` are all clean. For review: - Does ingest check the `X-Comfy-Client` value or only that the header is present? The value carries the package version. - If an anonymous features document ever carried the probe but no Firebase or Stripe fields, the memo would be evicted and refetched. The eviction rule is unchanged from main. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b (§14 OQ17, §15 C11, §18) - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2891 ; backend switch https://linear.app/comfyorg/issue/BE-17276 - Contract: Comfy-Org/cloud#10689 (C11), BE-17276 (C11b, not yet built) ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | **FE-2891 (this PR)** | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | #18708 merged; readers #18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | #18710 merged; revoke-all #18869, do not merge | | FE-2893 | ADR | none | #18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | #18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | #18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | #18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | #18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | #18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | #18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | in progress | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | FE-2896 / 2899 / 2898 | website header, website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | #18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2891 thisPr ``` - Blocked by: BE-17276 (probe switch) for the contract; C11 cloud#10689. - Unblocks: FE-2896 (website header), FE-2899 (website credits), FE-2898 (billing-web). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ified_web_session (1/2) (Comfy-Org#18880) > **Do not merge.** Part 1 of 2 for FE-2898 (part 2, the transport, is Comfy-Org#18881, stacked on this). Gated on BE-17276 via the readers (Comfy-Org#18874), on FE-2894 (Comfy-Org#18715), FE-2895 (Comfy-Org#18716) and C5 cloud#10555. Base is the readers branch; the diff also shows the FE-2894/FE-2895 merges. This PR's own change: 9 files, 299 non-test lines. ## Why billing-web signs in on its own Firebase login and mints a workspace token. With `unified_web_session` on, a visitor already signed in on Cloud should be recognised from the shared session without starting Firebase or signing in again. This part adds the one decision point and the session-backed identity and sign-in. Part 2 adds the workspace scope and the credentialed billing transport. ## How - **`billingWebAuth.ts`: one decision per page load.** It chooses `session-client` (today's path) or `web-session`. - The router guard starts the decision but never waits for it. Until the decision lands, every phase reads `pending`, which is exactly what main shows while Firebase hasn't answered. - A probe that is absent or false settles it as soon as the `/api/features` document arrives. That is the same document Firebase's config comes from, so Firebase starts at the same moment as on main. - The session path gets **800 ms**. After that, the page load stays on today's path, and a late `true` is ignored. - **`unifiedBillingSession.ts`** boots the FE-2894 identity (`@comfyorg/account-core/webSessionIdentity`). Firebase is only a lazy RememberedLogin proof, consulted after the server says there is no session. - **Sign-in controller port:** `SignInView` gets a port that follows the decision. If a Cloud session is found in time, the page is left the same way a restored login leaves it. - The router, `App` and `SignInView` are rewired to the decision point. Entry-workspace rebinding still mints on today's path only. ### Decisions for review 1. **Flag-on first paint.** A visitor with a live Cloud session briefly sees main's pre-config sign-in screen: disabled buttons and the "unavailable" notice. It lasts until the decision lands, at most 800 ms, and then the page leaves it. This is the price of never delaying the flag-off path. 2. **A different remembered Firebase user is not signed out.** While the session is live, nothing on billing-web asks Firebase for a token or mints from `/auth/token`. Identity, scope and every billing request come only from the session cookie. So a different remembered user has no path to any request. It is consulted only after the server reports no session, and a restore goes through the server's silent-restore rules. ## Flag-off parity `billingWebAuth.flagOff.test.ts` renders `App` with the real router: - **Features read hangs:** the page is on `/sign-in`, the notice is shown, and Firebase is not initialised. Same as main. - **Credentialed flag read hangs:** Firebase is not started at 799 ms and is started at 800 ms. A late `true` sends no `/api/auth/session` and doesn't re-initialise Firebase. - **Probe false:** Firebase is initialised well before the cap. The request tables are identical to main with the probe absent or false, and `src/platform/auth/webSessionFlagOff.test.ts` passes. Timing mutations each go red: no cap, cap at 5000 ms, the guard awaits the decision, a late `true` swaps the mode, a false probe waits for the cap. ## AS IS / TO BE | | AS IS | TO BE | | --- | --- | --- | | Flag off | Firebase sign-in | unchanged, same first render and notice | | Flag on, live Cloud session | Firebase sign-in form | recognised from the session in ≤ 800 ms, no Firebase | Screenshots will be added by editing this description once testcloud serves the probe. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2898 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | Comfy-Org#18878, do not merge | | FE-2896 | website header | FE-2891 readers, FE-2894, C11 | Comfy-Org#18877, do not merge | | FE-2899 | website credits | FE-2896, FE-2895, C5 | in progress | | **FE-2898 (this PR)** | billing-web on the session (A identity, B transport) | FE-2891 readers, FE-2894, FE-2895, C5 | A + B, do not merge | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2898 thisPr ``` - Blocked by: FE-2891 readers Comfy-Org#18874, FE-2894 Comfy-Org#18715, FE-2895 Comfy-Org#18716, C5 cloud#10555 - Unblocks: M2 billing-web checkout on the shared session --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ession (Comfy-Org#18877) > **Do not merge.** Gated on BE-17276 (`web_session_probe`) through the readers in Comfy-Org#18874, and on the FE-2894 identity in Comfy-Org#18715. Base is the readers branch; the diff also shows the FE-2894 merge. This PR's own change is 5 files: 154 non-test lines and 390 test lines. ## Why On the website, a visitor who is already signed in to Cloud through the shared web session should see that account in the header, without starting Firebase. Today the header always loads the Firebase account island. FE-2896 lets the header take the account from the web session when `unified_web_session` is on for that visitor, and changes nothing when it is off. ## How - **`resolveWorkshopAccountSource()`** (`apps/website/src/config/workshop-web-session-identity.ts`) settles once per page load to `'session'` or `'firebase'`. - The probe (Comfy-Org#18874) is absent or false, or the per-user flag is off: `'firebase'` at once. No session read is sent. - The flag is on: the FE-2894 identity boots. A live session gives `'session'` and a signed-out answer gives `'firebase'`. - **Cap: at most 800 ms.** If the cap fires first, the answer is `'firebase'` for the page load and the identity is disposed. A late answer never swaps a mounted header, and a session read is never sent after the cap. - **`HeaderMain.vue`**: the async loaders for `HeaderAccount` and `BuyCreditsDialog` wait for the source. On `'session'` they mount `HeaderSessionAccount` (an initials chip labelled with the email) and an empty dialog, so no Firebase island starts. - **RememberedLogin port**: the proof comes from Firebase only if Firebase is already loaded. The website never force-loads Firebase to build a proof. - **User id**: the Comfy user id is the Firebase uid today (`token.UID` in cloud `firebase_auth.go`). This holds until Phase 2.5. ### Kept out of this PR - **Session-mode header**: no menu, sign-out, credits or workspace switcher. Sign-out is FE-2897. Credits (FE-2899) and the workspace come next. Asking to buy credits in session mode does nothing until FE-2899. - **Playground and `/login`**: these still start Firebase. A stale Firebase login for a different user is signed out only if Firebase was already loaded when the session answered. - **SDK follow-up**: `readWebSession` sends no `X-Comfy-Client`. If C5 requires it on `/api/auth/session`, the fix belongs in account-core. ### /models/ script budget `e2e/models-performance.spec.ts` caps the JavaScript that `/models/` loads. This PR raises that ceiling from 1,810,000 to 1,815,000 bytes. - main measures 1,808,088 bytes, 1.9 KB under the old ceiling. - The header's once-per-page-load session decision ships even with the flag off: the probe read, the flag read and the 800 ms cap. - Two changes already moved code behind the flag: - the session boot now loads lazily; - `COMFY_CLIENT`, which inlines the package manifest, now loads only for the credentialed read. - With both, this branch measures 1,811,181 bytes in CI (an extra ~3 KB, down from ~8 KB). - The catalogue-only delta check (900,000) is unchanged. ## Flag-off parity - Probe absent or false: the same islands mount, and no `/api/auth/session` request is sent (`HeaderMain.webSession.test.ts`). - The header's only new wait is the probe read. It ends when the probe answers, and it never lasts past 800 ms. - `src/platform/auth/webSessionFlagOff.test.ts` passes. The cloud app is not touched. - Mutation checks: 10 mutations, all red. They include: the cap never decides, the session boots after the cap, the flag-off path waits for the cap, the header is ungated, and the boot ignores the flag. ## AS IS / TO BE | | AS IS | TO BE | | --- | --- | --- | | Flag off | Firebase header | Firebase header, unchanged | | Flag on, live session | Firebase header | Session chip (screenshot to follow once testcloud serves the probe) | Screenshots will be added by editing this description. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2896 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | **FE-2896 (this PR)** / 2899 / 2898 | website header (this PR), website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2896 thisPr ``` - Blocked by: FE-2891 readers Comfy-Org#18874 (BE-17276 probe), FE-2894 Comfy-Org#18715, BE-17063 on testcloud - Unblocks: FE-2899 website credits (next, stacked on this branch) --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…mfy-Org#18871) > **Stacked on Comfy-Org#18719 (FE-2897) → Comfy-Org#18715 (FE-2894). Do not merge** until those merge and C1/C3 are on testcloud. ## Why With `unified_web_session` on, the cloud app must join the shared session. It creates the session only on a real sign-in, deletes it on sign-out, boots and heartbeats from it, and resets a tab whose account changed. It must also stop re-creating the old cookie on every token refresh, which would undo a sign-out made on another site (TDD §12, §18, F2). With the flag off, nothing may change. ## How - New `useCloudWebSessionStore` (`src/platform/auth/session/cloudWebSessionStore.ts`) wraps account-core's `createWebSessionIdentity`. Its host adapters: - `RememberedLogin`, backed by the Firebase identity; - `createWebVisibilityPort()` for the heartbeat; - `createWebCrossTabRefreshPort<WebSessionResult>()` for the cross-tab leader. - **`start()` is the only place that reads the flag.** It reads it once per page load, on the first call, and returns whether the session is on. - The first call comes from the workspace gate or the extension's `onAuthUserResolved`, both of which run after the signed-in `/api/features` read. So the flag is never read in its anonymous default. - A later flag change applies on the next page load. - **Flag on**, the existing `useSessionCookie` entry points switch over: - `createSession` (called on user-resolved and on token refresh) starts the lifecycle and sends nothing, so the re-create-on-refresh behaviour is gone. - `ensureSessionCookie` waits for the lifecycle to be ready. - `deleteSession` does nothing, because sign-out is owned by `authStore.logout` → `signOut()` → DELETE. - `createSessionOrThrow` (OAuth resume, consent redirect) waits only if the lifecycle is already active. - `login`, `register`, `loginWithGoogle` and `loginWithGithub` call `signedInInteractively`, the only thing that creates a session. - **Account change.** The store clears the workspace selection, resets the team workspace store and the socket, and, only when the account became a different user, shows the `auth.accountChanged` notice (a notice, not a confirm, per open question 11). - Until FE-2904 moves the API client onto the session, the app still needs a Firebase login. So a different user ends in a signed-out page, not an in-place switch, and the copy does not promise a switch. - **Flag off.** `start()` returns false, every entry point falls through to today's code, and `webSessionFlagOff.test.ts` is unchanged and passes (4/4). - **For review: user id equality.** `currentUserId` returns the Firebase uid, which equals `comfy_user_id` today (cloud's Phase 2 invariant in `identity_resolution.go`). Cloud names a Phase 2.5 where they can diverge; the boot rule would then sign out a valid login, so the adapter must change before that phase. ## AS IS / TO BE No UI change with the flag off. With the flag on, the evidence is `webSessionFlagOn.test.ts`: | Scenario | Result | | --- | --- | | interactive sign-in | one session POST | | token refresh | no session request | | sign-out | one DELETE | | boot, 200 same user | GET only | | boot, 200 different user | local Firebase sign-out | | boot, 401 `session_revoked` | signed out, no restore | | boot, 401 `no_session` | one restore | | heartbeat sees a different user | socket and workspace reset, plus the notice | Nine mutations, each reverted with the full suite rerun, all go red, including "ignore the flag", which turns 4 flag-off rows red. Checks: - vitest over auth, stores, extensions, cloud and workspace: 5172 tests pass. - account-core: 1114 tests pass. - typecheck, knip, lint and fallow are clean. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b (sections 12, 15 F2, 18) - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2903 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + probe switch (readers) | Comfy-Org#18708 merged; readers in progress | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | **FE-2903 (this PR)** | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | in progress | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | FE-2896 / 2899 / 2898 | website header, website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2903 thisPr ``` - Blocked by: Comfy-Org#18719 (FE-2897), Comfy-Org#18715 (FE-2894), C1/C3 on testcloud. - Unblocks: FE-2904 (API client on the session), then FE-2905; FE-2906 rows E2E-02/05. --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com>
…e shared web session (2/2) (Comfy-Org#18881) > **Do not merge.** Part 2 of 2 for FE-2898, stacked on part 1 Comfy-Org#18880 (identity and sign-in gating). Gated on C5 cloud#10555. 11 files, 224 non-test lines. ## Why Part 1 recognises a Cloud session on billing-web. This part gives that session a workspace scope and sends billing requests on the cookie, so the flag-on path never mints a workspace token. ## How - **Workspace lookup:** `GET /workspaces/current` is authorized with `authorize()` from FE-2895. - The request uses `credentials: 'include'`, `X-Comfy-Client`, and `X-Comfy-Workspace-ID` from the entry link's bound workspace. Absent means personal. - The phase is `authenticated` only once that lookup succeeds. - **Refusals from C5:** - `workspace_access_denied` → `ACCESS_DENIED` - `workspace_id_invalid` → `WORKSPACE_NOT_FOUND` - 401 → `NOT_AUTHENTICATED` - Anything else maps to the existing `TOKEN_EXCHANGE_FAILED`. - **Billing client:** `createWebSessionBillingClient` uses `createCredentialedBillingTransport` (`@comfyorg/account-core/billing`, opt-in `webSession` from Comfy-Org#18716). Its `getWorkspaceToken` rejects: billing-web never mints on this path. - **UI:** `BillingShell`, `HostedSurface` and `useBilledWorkspace` read the scope from the decision point. On a refusal, `SignInView` shows the refusal copy. ### Decisions for review 1. **A refused workspace hides the sign-in form.** The visitor is signed in, but the entry names a workspace they can't use. Signing in again wouldn't fix that, so the page shows only the refusal. 2. **The role defaults to `member`** when `/workspaces/current` omits it. That is the least privilege; the server still enforces every write. 3. **The transport may re-read the session.** When the credentialed transport has a request refused, it re-reads the session (`readWebSession` with `expectedUserId`) before failing. That can add a `GET /api/auth/session` on a refusal. ## Flag-off parity The flag-off path doesn't reach any of this: the mode is `session-client` and the existing token client is unchanged. The part 1 flag-off pin, including its timing tests, passes here unchanged, and so does `src/platform/auth/webSessionFlagOff.test.ts`. The flag-on tests (SS1, SS6, SO4) cover: - the exact headers and credentials on the workspace lookup and on billing requests; - no `Authorization` header and no `/api/auth/token`; - refusal copy per code. ## AS IS / TO BE | Flag on | AS IS | TO BE | | --- | --- | --- | | Billing requests | `Authorization: Bearer <workspace token>` | cookie + `X-Comfy-Workspace-ID`, no token | | Entry workspace refused | sign-in form | refusal copy, no form | Screenshots will be added by editing this description once testcloud serves C5. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2898 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | Comfy-Org#18878, do not merge | | FE-2896 | website header | FE-2891 readers, FE-2894, C11 | Comfy-Org#18877, do not merge | | FE-2899 | website credits | FE-2896, FE-2895, C5 | in progress | | **FE-2898 (this PR: B)** | billing-web on the session (A identity, B transport) | FE-2891 readers, FE-2894, FE-2895, C5 | A + B, do not merge | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2898 thisPr ``` - Blocked by: FE-2891 readers Comfy-Org#18874, FE-2894 Comfy-Org#18715, FE-2895 Comfy-Org#18716, C5 cloud#10555 - Unblocks: M2 billing-web checkout on the shared session --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…fy-Org#18882) > **Do not merge.** Stacked on FE-2896 (Comfy-Org#18877) with the FE-2895 (Comfy-Org#18716) merge, and gated on C5 cloud#10555. The diff also shows the fe-2895 merge. This PR's own change is 7 files, about 160 non-test lines. ## Why In FE-2896's session mode, the website header shows the account but no credit balance, because the balance read needs a minted workspace token. This is the first consumer of `authorize()` on the session. It proves the cookie path end to end on a read, with no workspace token in page memory. ## How - **`workshop-session-balance.ts`**: `readSessionBalance(session, fetchImpl)` sends `GET /api/billing/balance` through `createRequestAuthorizer(...)` → `authorize({ kind: 'session', session }, { target: 'ingest', method: 'GET' })`. - The request carries `credentials: 'include'` and `X-Comfy-Client`. It has no `Authorization` and no workspace header, which means personal. - The authorizer's `getWorkspaceToken` always rejects, so this path can never mint a token. - The result is one of `ok`, `unavailable`, `session_ended` or `unknown`. - **`useWorkshopSessionBalance`**: one shared state per page. It reads once, again on window focus, and never again after a 401. The header mounts twice (desktop and mobile) but sends one request. - **`HeaderSessionAccount.vue`** shows a credits chip, styled like the Firebase one, only when the state is `ok`. - **The decision is FE-2896's.** `useWorkshopWebSession()` keeps the whole `WebSession`, and this module is loaded only when `resolveWorkshopAccountSource()` answered `'session'`. There is no new flag read. - **`X-Comfy-Client` is converged:** `webSessionFlag` (readers, Comfy-Org#18874) now imports `COMFY_CLIENT` from requestAuth instead of keeping its own copy. - The Firebase balance reader (`workshop-balance.ts`) is untouched. The session module keeps its own short copy of the balance-body parse, so the Firebase path's code and requests are identical to main. ### Decisions for review 1. **Workspace.** Session mode reads the personal workspace. The session header has no workspace picker, and the Firebase selection lives in a minted token that doesn't exist here. Nothing is derived from other server data. 2. **Refusals.** C5 403s (`origin_not_allowed`, `workspace_access_denied`, `csrf_invalid`, `cross_site_request`), a 400 `workspace_id_invalid`, 5xx, and network or body errors all hide the balance. It is read again on the next focus. A 401 hides it and stops reading. Neither case signs anyone out; sign-out stays with the identity module. 3. **Out of scope:** - Buying credits and the top-up watch: `BuyCreditsDialog` is still empty in session mode. - Workspace switching. - Refreshing the balance after a run. - The balance on `ModelDetail`, which still calls `useWorkshopCredits` and can start Firebase session state in session mode. That is a follow-up, and it also touches FE-2896's "no Firebase on comfy.org" criterion. ## Flag-off parity - The request-table test (`it.for`) pins both sources: - Firebase: exactly `{ authorization: 'Bearer …' }`, with no `credentials`. - Session: exactly `{ x-comfy-client }`, with `credentials: 'include'`, one request and no workspace header. - The HeaderMain request list now records `Authorization` and `X-Comfy-Client` on every request. The flag-off rows are unchanged. The live-session row adds only the balance read, with no `Authorization` and no `/api/auth/token`. - `src/platform/auth/webSessionFlagOff.test.ts` passes. - Mutations, each red: - always use the session header; - drop `credentials`; - add `Authorization`; - mint a token; - send `X-Comfy-Workspace-ID`; - treat a 403 as a 401; - keep reading after a 401. ## End-to-end coverage No `apps/website/e2e/` spec is added. The credits balance only renders when `unified_web_session` is on and a real `__Host-comfy_session` cookie from Cloud ingest is present. The website Playwright suite serves a static build with no Cloud backend and blocks cross-origin requests, so it cannot hold that session. The cross-origin session flow is covered by the `playwright.session.config.ts` harness (Comfy-Org#18718), which runs against staging. The flag-off path, which is what every visitor sees today, is unchanged, and the existing website e2e suite covers it. The balance behaviour itself (read on sign-in, clear on sign-out, stale reads ignored across a same-user sign-out and sign-in) is pinned in `workshop-session-balance.test.ts`. ## AS IS / TO BE | Session mode | AS IS | TO BE | | --- | --- | --- | | Header | account chip, no balance | account chip + credits chip from the cookie read | | Flag off | Firebase header + balance | unchanged | Screenshots will be added by editing this description once testcloud serves C5. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2899 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | Comfy-Org#18878, do not merge | | FE-2896 | website header | FE-2891 readers, FE-2894, C11 | Comfy-Org#18877, do not merge | | **FE-2899 (this PR)** | website credits | FE-2896, FE-2895, C5 | this PR, do not merge | | FE-2898 | billing-web on the session (A identity, B transport) | FE-2891 readers, FE-2894, FE-2895, C5 | Comfy-Org#18880 + Comfy-Org#18881, do not merge | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2899 thisPr ``` - Blocked by: FE-2896 Comfy-Org#18877, FE-2895 Comfy-Org#18716, C5 cloud#10555 - Unblocks: Session-mode buy credits and workspace picker (follow-up) --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…itch without a mint (Comfy-Org#18875) > **Stacked on Comfy-Org#18871 (FE-2903) and includes a merge of Comfy-Org#18716 (FE-2895, `authorize()`). Do not merge** until those merge and C5 (BE-17066, cloud#10555) is on testcloud. My change is the last commit (`e7085c16e7`); the diff also shows the FE-2895 merge until Comfy-Org#18716 lands. ## Why With `unified_web_session` on, the cloud app should call ingest on the session cookie instead of a token (TDD §9, §12, F4). That means the headers come from `authorize()`, switching workspace changes a header instead of minting a token, and the one automatic retry is tied to the user and workspace the request started for. With the flag off, nothing may change. ## How - **One decision point.** `src/platform/auth/session/webSessionFetch.ts` is a registration slot the cloud session store (FE-2903) fills in `start()` when the session is on, and clears on dispose. - `api.ts`, `workspaceAuthStore` and `authStore` check it synchronously. When the slot is empty the code runs exactly as today. - A slot rather than importing the store avoids two import cycles that fallow flagged. - **`api.fetchApi`.** When the session is on and signed in, the request goes through `fetchOnWebSession`, which takes its headers from `authorize()`: - `X-Comfy-Client` on every request. - `X-Comfy-Workspace-ID` only for a team workspace (absent means personal). - `X-CSRF-Token` on POST, PUT, PATCH and DELETE. - `credentials: 'include'` and no `Authorization` header. Otherwise the unchanged token path runs; it is moved verbatim into `addCloudAuthHeader` to keep `fetchApi` under fallow's complexity limit. - **Retries.** - `csrf_invalid`: one re-read of the session, pinned to the same user, then one retry in the same workspace, only if the user and session epoch are unchanged. Otherwise the original 403 is returned. Later requests reuse the fresh token, and a streaming body is never replayed. - `workspace_access_denied`: the selection is dropped through the existing revoked-workspace path, and the request is never replayed in another workspace. - **Workspace switch.** With the session on, the switch calls `GET /api/workspaces/current` with the workspace header and stores id, name, type and role. It mints no token. With no signed-in session it falls back to today's switch. - **`authStore.getAuthHeader`.** With the session on, it returns the user's Firebase or API-key header instead of minting a workspace token, so the router's check on every navigation no longer mints. - **Not in this PR:** - Other ingest callers: `workspaceApi` (axios), remote widgets and agent consent stay on today's tokens. - With the flag on, remote widgets resolve to the personal workspace. This is a flag-on-only gap; moving the axios clients onto `authorize()` is a proposed follow-up. - WebSocket and media URLs are FE-2905. The comfy-api session mint is FE-2900. - `permissions` are not stored, since nothing reads them yet. ## AS IS / TO BE Flag off: `src/platform/auth/webSessionFlagOff.test.ts` is byte-identical to the base and passes. The full `src` and account-core vitest run is 1620 files, 23152 tests. Flag on: `webSessionFlagOn.test.ts` gains five cases. - **Boot into a remembered team workspace.** The GET carries the client and workspace headers with `include` and no `Authorization`. The POST adds CSRF. `getAuthHeader` returns the Firebase header. Switching to personal changes only the header, and `/api/auth/token` is never called. - **`csrf_invalid`, same user.** One re-read, then one retry, and later requests use the fresh token. - **`csrf_invalid` after the user changed.** The request is abandoned. - **`workspace_access_denied`.** The selection is dropped, and the request is not replayed. - **A switch into a refused workspace** throws. Eleven mutations were each reverted with the full suites rerun, and all went red: | Mutation | | --- | | no CSRF retry | | the re-read ignores the user | | denied workspace not dropped | | workspace header sent for the personal workspace | | `fetchApi` ignores the session | | request method dropped | | fresh CSRF token not reused | | the switch mints a token | | `getAuthHeader` mints a token | | session never registered | | denied request replayed in another workspace | Checks: typecheck, eslint, oxlint, oxfmt and knip are clean, and fallow reports 0 new findings against the FE-2903 branch. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b (sections 9, 12, F4) - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2904 - Contract: Comfy-Org/cloud#10555 (C5) ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | **FE-2904 (this PR)** | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | FE-2896 / 2899 / 2898 | website header, website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2904 thisPr ``` - Blocked by: Comfy-Org#18871 (FE-2903) and Comfy-Org#18716 (FE-2895); C5 cloud#10555 on testcloud. - Unblocks: FE-2905 (socket and media), FE-2906 rows E2E-03/06 and FS-13/14. --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
…space (Comfy-Org#18878) > **Do not merge.** Stacked on FE-2904 (Comfy-Org#18875) and gated on C6 cloud#10583 (+Comfy-Org#10699) and C7 cloud#10584 (+Comfy-Org#10698). The diff is 6 files: about 125 non-test lines. ## Why With `unified_web_session` on, API requests already travel on the session cookie with `X-Comfy-Workspace-ID` (FE-2904). Two surfaces can't carry that header: - the WebSocket handshake; - media URLs loaded by `<img>` / `<video>` tags. Without this PR they would still need a minted token in the URL, and they would read the personal workspace in a team. C6 and C7 let both accept the cookie and a `?workspace_id=` query parameter instead. ## How Everything hangs off the single registration slot `webSessionRequests()` from FE-2904. There is no second flag read. - **`WebSessionRequests.workspaceId()`** returns the team workspace id only while the tab is signed in on the session. Otherwise it returns nothing, which means personal. - **Socket (`api.ts`):** the auth params come from a private `addSocketAuth(params)`. - Signed in on the session: no `token`. `workspace_id` is set for a team and left out for personal. - No session: today's token code, moved as is. - With the flag on, no session and no token, no socket opens. - **Reconnect:** - `api.reconnectSocket()` re-handshakes and keeps the client id. `resetSocket()` still clears the ids, and both share `replaceSocket()`. - `cloudWebSessionStore` watches the signed-in user and the team workspace, and reconnects on any change while signed in. There is no token mint. - **Media URLs:** `apiURL()` passes the media routes through `scopeMediaRoute`, which adds `workspace_id` for a team and never duplicates it. The routes are `/view`, `/viewvideo`, `/vhs/viewvideo`, `/vhs/viewaudio` and `/assets/:id/content`, with or without an `/api` prefix. ### Decisions for review 1. **Flag on and signed out: no socket.** Today a tokenless `/ws` keeps reopening. One gap is covered only by a reload: the flag is on, the session was never created, and Firebase signs in again in the same page. 2. **A removed team member's socket retries every 300 ms.** It stops when the next API call gets `workspace_access_denied`, which drops the workspace and reconnects in personal. That matches today's token-socket loop, and no probe request is added. 3. **A Cloud workspace switch may open one extra short-lived socket** before the reload. The newer socket wins and the older one is closed. 4. **Not scoped:** literal `api/view` strings that don't go through `apiURL` (`useWidgetSelectItems.getMediaUrl`, `LoaderManager`, `BackgroundImageUpload`), and server-supplied `preview_url`s. These fall back to C7's cross-workspace lookup. Moving them onto `apiURL` would change the flag-off output, so it is left for a follow-up. 5. **Header or query, never both.** `fetchApi` names the workspace only in `X-Comfy-Workspace-ID`, and its URL skips `scopeMediaRoute`. The query is only for URLs that tags load without headers. A test pins that a session media fetch sends the header and a bare URL, and it goes red if `fetchApi` goes back to the scoped URL. ## Flag-off parity - With the slot empty, `apiURL` returns the route unchanged, and the socket runs today's token code. `addSocketAuth` returns true, as before. - The shared harness `src/platform/auth/webSessionFlagOff.test.ts` is extended, not loosened. It now also pins `/api/viewvideo…`, `/api/vhs/viewaudio…` and `/api/assets/:id/content`, because `apiURL` is on their path. - Mutation checks, all red: drop `workspace_id` from the socket, keep the token on the session, open a socket while signed out, remove the workspace reconnect, leave media unscoped. ## AS IS / TO BE | Flag on, team workspace | AS IS | TO BE | | --- | --- | --- | | Socket | `/ws?token=<minted>` | `/ws?workspace_id=<team>` on the cookie | | Media URL | `/api/view?filename=…` (personal) | `/api/view?filename=…&workspace_id=<team>` | | Flag off | unchanged | unchanged | Network screenshots will be added by editing this description once testcloud serves C6/C7. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2905 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + BE-17276 probe (readers) | Comfy-Org#18708 merged; readers Comfy-Org#18874, do not merge | | FE-2892 | web session client (+ revoke-all follow-up) | C2a cloud#10589 for revoke-all | Comfy-Org#18710 merged; revoke-all Comfy-Org#18869, do not merge | | FE-2893 | ADR | none | Comfy-Org#18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | Comfy-Org#18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | Comfy-Org#18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | Comfy-Org#18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | Comfy-Org#18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | Comfy-Org#18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | Comfy-Org#18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | Comfy-Org#18875, do not merge | | **FE-2905 (this PR)** | socket + media carry workspace | FE-2904, C6, C7 | this PR, do not merge | | FE-2896 | website header | FE-2891 readers, FE-2894, C11 | Comfy-Org#18877, do not merge | | FE-2899 / 2898 | website credits, billing-web | FE-2896, FE-2895, C5 | next | | FE-2906 | cross-origin E2E harness | — | Comfy-Org#18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2905 thisPr ``` - Blocked by: FE-2904 Comfy-Org#18875, C6 cloud#10583 (+Comfy-Org#10699), C7 cloud#10584 (+Comfy-Org#10698) - Unblocks: FE-2907 rollout: the cloud app's socket and media are covered --------- Co-authored-by: mattmillerai <7741082+mattmillerai@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
…e-all contract (#18869) > cloud#10589 (BE-17064 C2a, `POST /api/auth/sessions/revoke-all`) is merged and #18926 synced its generated schema; this PR validates against it. ## Why `revokeAllWebSessions` was held out of #18710 in review: the route had no contract, and the old version accepted any 2xx, which is the worst lie this client could tell (the caller would believe every device is signed out). cloud#10589 now defines the route and its response, so it comes back validated. ## How - `revokeAllWebSessions(options, csrfToken, getIdentityProof)`: `POST /auth/sessions/revoke-all` with `credentials: 'include'`, `Authorization: Bearer <proof>` and `X-CSRF-Token`. - The contract authenticates this route with the Firebase ID token only (`security: BearerAuth`). Accepting the cookie is a listed backend follow-up in cloud#10696. - The CSRF header and credentials are sent now so the cookie path works when that follow-up lands. - The 200 body is validated against `RevokeAllSessionsResponse` (`{ revoked: integer }`), the generated `zRevokeAllSessionsResponse` from `@comfyorg/ingest-types/zod` (cloud#10589, synced by #18926). - A 2xx that fails the schema (empty 204, `{}`, wrong types, HTML) is `SESSION_UNAVAILABLE` and retryable; it is never reported as ok. - Non-2xx goes through the existing classifier. - The testing fake serves the route. It checks the bearer, then a dead session, then CSRF; a successful call revokes the session. - Nothing in any app calls it yet, so the flag-off request harness is unchanged (4/4). ## AS IS / TO BE No UI; the evidence is tests. - AS IS: no revoke-all client. - TO BE: status-mapping rows, credentials, bearer and CSRF headers, six schema-failing 2xx bodies (all transient), a stale CSRF token → `CSRF_STALE`, and a successful revoke followed by `SESSION_REVOKED` on the next read. Mutations (each reverted, full suite rerun): | Mutation | Tests red | | --- | --- | | accept any 2xx without validation | 6 | | drop CSRF | 2 | | drop credentials | 4 | | drop Bearer | 3 | account-core 1083 tests pass; typecheck, lint, knip and fallow are clean. ## Links - TDD: https://app.notion.com/p/3de6d73d365081d7a4c8f808c0a0384b (sections 7, 9) - Action items: https://app.notion.com/p/3e56d73d3650812d962decc97fbd9ea3 - Linear: https://linear.app/comfyorg/issue/FE-2892 - Contract: Comfy-Org/cloud#10589, Comfy-Org/cloud#10696 ## Where this PR sits in the plan | Ticket | Scope | Blocked by | State | | --- | --- | --- | --- | | FE-2891 | flag (cloud) + website/billing-web readers | C11 cloud#10689 + probe switch (readers) | #18708 merged; readers in progress | | **FE-2892 (this PR)** | web session client (+ revoke-all follow-up) | C2a cloud#10589 (merged) | #18710 merged; revoke-all #18869 ready for review | | FE-2893 | ADR | none | #18707 merged | | FE-2894 | identity + boot rules | BE-17063 on testcloud | #18715, do not merge | | FE-2895 | `authorize()` | C5 cloud#10555 | #18716, do not merge | | FE-2897 | lifecycle, heartbeat | FE-2894, C1 | #18719, do not merge | | FE-2900 | lazy token mint from the session | FE-2895, C8 cloud#10585 | #18870, do not merge | | FE-2901 | non-web clients stay on tokens | — | #18711 | | FE-2903 | cloud app joins the lifecycle | FE-2897 | #18871, do not merge | | FE-2904 | cloud API client on `authorize()` | FE-2903, FE-2895, C5 | in progress | | FE-2905 | socket + media carry workspace | FE-2904, C6, C7 | next | | FE-2896 / 2899 / 2898 | website header, website credits, billing-web | FE-2891 readers, FE-2894/2895, C5, C11 | next | | FE-2906 | cross-origin E2E harness | — | #18718 (harness only) | | FE-2902 / 2907 / 2908 | platform, rollout, cleanup | other repo / ops / after ramp | not started | ```mermaid flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2892 thisPr ``` - Blocked by: none (cloud#10589 and #18926 merged). - Unblocks: FE-2897 host wiring for "sign out of all devices"; FE-2906 E2E-07.
…rom the web session (Comfy-Org#19378) ## Why With `unified_web_session` on, the cloud app reaches ingest with the session cookie. comfy-api can't read that cookie, so three calls still needed a Firebase ID token: - subscription checkout - tier checkout - `/customers/events` A tab that arrived by session had nothing to authorize them with. This is the part of FE-2900 that Comfy-Org#18870 left open ("No app wires it yet"). ## How - `cloudWebSessionStore.start()` builds a `createSessionTokenMint` and a `createRequestAuthorizer`, only after the flag check. It wires them into the ingest fetch ports and gives the request slot an `authorizeResource`. - `webSessionResourceHeader()` returns a Bearer header only when the session is on and this tab is signed in on it. Otherwise it returns `undefined`. - The three comfy-api callers use `(await webSessionResourceHeader()) ?? <legacy header>`. - `getMyEvents` wraps the header lookup, so a mint failure clears `isLoading` and sets `error`. - Minting is lazy: - Nothing is sent at boot or on ingest-only pages. - `getAuthHeader` / `getUserAuthHeader`, which the router calls on every navigation, never mint. - In account-core, a cached token's expiry is clamped to the session's expiry. ## AS IS / TO BE No UI change. Requests: | Scenario | AS IS | TO BE | |---|---|---| | Flag off, any page | Firebase / user header | Unchanged, no extra requests | | Flag on, ingest-only page | No mint | No mint | | Flag on, first checkout or `/customers/events` | `Bearer <firebase-id-token>` (missing for session-only tabs) | One `POST /api/auth/token` (cookie, CSRF, `X-Comfy-Client`, no workspace header), then `Bearer <session-jwt>` | | Flag on, later comfy-api calls | Firebase header | Cached `session-jwt`, reused until 60 s before the earlier of the token's and the session's expiry | | Flag on, session revoked | n/a | `SessionTokenError` `SESSION_REVOKED`; no checkout request; the events view stops loading and shows the error | ## Decisions - **The mint is for the personal workspace.** It omits `workspace_id` even while a team workspace is selected, which matches today's user-scoped Firebase behaviour on `/customers/*`. comfy-api validates session-minted tokens like Firebase-exchanged ones (C8, Comfy-Org/cloud#10585). - **Clamp.** The cached expiry is `min(token expires_at, session expiresAt)`, so a token never outlives the session that minted it. ## Tests - `webSessionFlagOn.test.ts`, through the real session store: - A session-only tab mints once and reuses the token. - A selected team workspace doesn't change the mint. - No mint at boot or on ingest-only pages. The mint counter is never reset, so a mint at boot or on an ingest request is still counted. - `SESSION_REVOKED` rejects. - The token is re-minted after it expires. - `useSubscription`, `subscriptionCheckoutUtil` and `customerEventsService` each have an `it.for` table: session header, Firebase fallback, and a rejected mint. - account-core: a token that outlives the session is re-minted. - `webSessionFlagOff.test.ts` is unchanged. - Each of these mutations turns a test red: minting on an ingest send, on sign-in, or in `getUserAuthHeader`; passing `workspaceId`; removing the clamp; dropping a fallback; dropping the try/catch. ## Out of scope / follow-ups - Session-only users can't see subscription status yet: - `useSubscription`'s watch and recovery are gated on `useCurrentUser().isLoggedIn`, which needs Firebase or an API key. - The status read goes through `workspaceApi` with the Firebase header. - `authStore.fetchBalance`, `addCredits`, `accessBillingPortal` and the 409 `createCustomer` recovery still use Firebase. - A revoked mint shows raw toast copy ("Workspace token mint failed: SESSION_REVOKED"). An i18n message is a follow-up. ## Where this sits | PR | Scope | |---|---| | Comfy-Org#18870 (merged) | Lazy workspace-token mint in account-core | | **this PR** | **The cloud app's comfy-api callers use it** | | follow-up | Subscription status and the remaining `/customers/*` calls for session-only users | ```mermaid graph LR A[Comfy-Org#18870 mint] --> B[this PR: comfy-api callers] B -.-> C[follow-up: subscription status, balance/credit/portal] style B fill:#f9f,stroke:Comfy-Org#333 ``` - Part of FE-2900
Why
comfy-api and the other services cannot read the session cookie. A site that arrived by session has no Firebase login to hand them. TDD §7/§12 has the site mint a short-lived workspace token from the session, lazily and only when a non-ingest call needs one. This is the token source
authorize()(#18716) takes for itsresourcetarget.How
New entry
@comfyorg/account-core/sessionTokenMint:createSessionTokenMint({ apiBaseUrl, fetchImpl, getSession, now?, refreshBufferMs? })returns:mint(workspaceId?), which returns a coded result;getWorkspaceToken(workspaceId?), which plugs intocreateRequestAuthorizer({ getWorkspaceToken })and rejects withSessionTokenErroron failure.Details:
POST /auth/tokenwithcredentials: 'include',X-Comfy-Client,X-CSRF-TokenandX-Comfy-Workspace-ID. The body is{}for the personal workspace or{ workspace_id }. NoAuthorizationheader is sent. The response is parsed with the generatedzExchangeTokenResponse, since C8 leaves the 200 shape unchanged.csrf_invalidisCSRF_STALEand 403workspace_access_deniedisWORKSPACE_ACCESS_DENIED. Other 403s, 400 and 404 are refused. 5xx and network errors are transient. A 429 carriesretryAfterMsand holds further requests until then.X-Comfy-Workspace-IDequal to the body'sworkspace_id. C8 only rejects a header that names a different workspace; if you'd rather send none, it's a one-line removal.webSession.tsrefuses it.AS IS / TO BE
No UI; the evidence is tests.
Eight mutations, each reverted with the full suite rerun, all go red: cache key, user-change drop, expiry buffer, credentials, single-flight, Retry-After, stale-owner guard, and 401 cache clear.
Checks: account-core 1139 tests pass; typecheck, lint, knip, fallow and smoke:pack are clean.
Links
Where this PR sits in the plan
authorize()authorize()flowchart LR subgraph BE["BE · cloud ingest and infra"] C0["BE-17071 C0 preview CORS gate"] C1["BE-17061 C1 sessions table + revocable cookie"] C3["BE-17063 C3 GET /session, trusted origins, flag"] C4["BE-17062 C4 shared workspace resolution"] C5["BE-17066 C5 cookie on API: CSRF, Origin, workspace header"] C2["BE-17064 C2 revoke-all, purge, caps"] C6["BE-17067 C6 WebSocket on session"] C7["BE-17068 C7 scoped media"] C8["BE-17069 C8 token mint from session"] C9["BE-17065 C9 Redis cache + load test"] C10["BE-17072 C10 prod config, cleanup"] C11["C11 flag before sign-in (OQ17)"] B135["BE-17135 serve unified_web_session (server AND)"] I2["BE-17070 I2 edge limit, log + DNS audit"] end subgraph SDK["FE · account-core"] F2891["FE-2891 flag"] F2892["FE-2892 web session client"] F2894["FE-2894 identity + boot rules"] F2897["FE-2897 lifecycle, heartbeat"] F2895["FE-2895 authorize()"] F2900["FE-2900 lazy token mint"] F2901["FE-2901 non-web stay on tokens"] end subgraph APPS["FE · apps"] F2896["FE-2896 website header"] F2903["FE-2903 cloud lifecycle"] F2899["FE-2899 website credits"] F2904["FE-2904 cloud API client"] F2905["FE-2905 socket + media"] F2898["FE-2898 billing-web joins session"] F2902["FE-2902 platform"] end subgraph QA["QA · rollout · docs"] F2906["FE-2906 cross-origin E2E"] F2893["FE-2893 ADR + docs"] F2907["FE-2907 ramp + rollback"] F2908["FE-2908 cleanup"] end C0 --> C1 --> C3 --> C5 C3 --> C11 --> F2891 B135 --> F2891 C4 --> C5 C1 --> C2 C1 --> C9 C5 --> C6 & C7 & C8 C3 --> F2892 C1 --> F2892 F2891 --> F2894 C3 --> F2894 F2892 --> F2894 --> F2896 F2894 --> F2897 --> F2903 C1 --> F2897 F2892 --> F2895 C5 --> F2895 F2895 --> F2899 & F2904 & F2900 & F2901 & F2902 C5 --> F2899 & F2904 F2903 --> F2904 --> F2905 C6 --> F2905 C7 --> F2905 C8 --> F2900 F2894 --> F2898 F2895 --> F2898 C3 --> F2898 C5 --> F2898 F2903 & F2904 & F2905 & F2898 --> F2906 C3 & C2 --> F2906 F2906 --> F2907 C9 & C10 & I2 --> F2907 F2907 --> F2908 C10 --> F2908 classDef thisPr fill:#ffe08a,stroke:#b8860b,stroke-width:4px,color:#000 class F2900 thisPr