Repository navigation
fix: recover cloud sessions whose auth token the provider rejected - #14207
CodeJuggernaut wants to merge 18 commits into
Conversation
…ssion A cloud session whose token had expired left the app on a bare canvas with no chrome and no way out, while pollers re-issued 401s indefinitely. Nothing converted a rejected token into a logout. A 401 is now a trigger, never a verdict. It opens one investigation: force-refresh the Firebase identity, then re-establish the session cookie with that fresh identity. Only those two authoritative oracles may conclude the session is dead, so an endpoint-specific 401 cannot sign anyone out, and neither can an unreachable oracle. On a dead verdict the session cookie and Firebase state are cleared and the app redirects to /cloud/login. Concurrent 401s share one investigation and termination latches, so a poll loop firing hundreds of 401s produces exactly one logout. Requests short-circuit once terminated, so no further traffic is generated before the redirect. Reporting lives in fetchWithUnifiedRemint and the axios interceptor, the two seams every authenticated cloud request already passes through, rather than in each caller. Only requests that carried a Bearer report, so the anonymous first-load path is untouched.
The synthetic 401 returned by a terminated session still reached fetchJobsRaw, which logs on any non-ok response. So the console kept emitting "[Jobs API] Failed to fetch jobs: 401" between the verdict and the redirect, even though no network request was being made. Guard queueStore.update instead. It is the entry point for both the queue and history fetches, so one check silences the loudest offender and stops it re-polling, rather than editing each poll site.
What - run the redirect in a finally so a throwing teardown cannot latch the kill switch with no way out - memoize and guard the lazy imports so reportUnauthorized never rejects - trigger on "signed in yet 401" instead of "carried a bearer token" - treat only 401 from the session mint as a revoked session, not 403 - guard fetchJobsRaw rather than one of its four callers - race the investigation against a timeout - give the synthetic 401 a parseable body and a statusText - skip the cooldown when no user is signed in yet - drop the toast and its strings, and cover the report seam with tests Why - a revoked identity stops producing bearer tokens, so gating the report on one went blind in exactly the case this fix exists for - 403 from the session mint means the identity was accepted and the authorization refused, which this repo already decodes that way - terminate() latched before three unguarded statements, so a chunk-load failure would strand the app worse than the original bug - the queueStore guard covered one of four callers reaching the log line Notes - reporting is deliberately not behind unified_cloud_auth; the dead-end predates that flag and reproduces with it off. Both stale contract comments now say so. - the concurrent-import dedupe also fixed a test failure where 10+ parallel reports raced module mock resolution
What - back off exponentially on consecutive healthy verdicts, capped at 15m - reset the backoff as soon as a verdict stops being healthy - log a warning when a session is ended, so the event is observable Why - widening the trigger to "signed in yet 401" means an endpoint that 401s for its own reasons keeps reporting forever while the session is fine - a flat 60s cooldown made that ~480 probes of the auth endpoint per day, and each probe is another chance for a transient 401 to read as a revoked identity - detection speed is unaffected: a dying session returns dead on its first probe, and the first probe is never delayed - the redirect is otherwise silent, so a false positive would be both indistinguishable from a real expiry and invisible in telemetry
… 401s What - replace the 401-triggered investigation with two expiry-driven triggers: Firebase's own involuntary sign-out, and a permanent failure of the scheduled Cloud JWT refresh - delete the investigation, single-flight, tri-state verdict, cooldown, backoff, probe timeout and memoized loaders they required - restore remintRetry.ts and useSessionCookie.ts to their prior contracts - keep the terminated-session short-circuit in fetchApi and fetchJobsRaw Why - a 401 is per-endpoint and overloaded: missing entitlement, a resource outside the workspace, a feature the account lacks. Inferring session death from one is a guess, and a wrong guess signs out a working user - @firebase/auth _logoutIfInvalidated already signs the user out on exactly auth/user-disabled and auth/user-token-expired, and on nothing else; ProactiveRefresh runs that check at expiry minus five minutes - POST /api/auth/token is the single identity-exchange endpoint per the cloud service docs, and workspaceAuthStore already refreshes against it on an expiresAt timer; its permanent-failure branch cleared the token but left the app running, which is the dead-end being fixed - both signals are driven by a known expiry, so nothing polls, and no endpoint's 401 can end a session Notes - the false-positive class is now designed out rather than bounded: no per-endpoint response participates in the decision
What - narrow the Cloud JWT refresh trigger from every permanent auth error to INVALID_FIREBASE_TOKEN alone Why - PERMANENT_AUTH_ERROR_CODES also covers ACCESS_DENIED and WORKSPACE_NOT_FOUND, which /api/auth/token returns as 403 and 404 for a denied or deleted workspace - both leave the user's credential valid, so treating them as a dead session would sign out a working user whose workspace changed - clearing the unified token on those codes is still correct; only the redirect is now withheld
What - bracket the three in-process sign-outs so they cannot read as an expiry: the deliberate logout, the requires-recent-login recovery, and the signup rollback that deletes a half-created Firebase user - share one public-route list between the router and the expiry redirect - corroborate a rejected identity with a forced refresh before ending the session, instead of trusting one un-retried 401 from our own backend - release the terminated latch if the browser refuses to navigate - assert the redirect in the workspace refresh tests, which previously drove all three status codes without checking it Why - user.delete() and the reauth recovery both call signOut(), so a failed signup or a password change hard-redirected a user whose credential was never expired - the guard listed /cloud/oauth/consent, a legacy redirect stub; the live consent screen is /oauth/consent, so an OAuth flow was unprotected while the test asserting it passed - /api/auth/token answering 401 means our backend disagrees with an identity provider that just issued a token; one disagreement is the same overloaded-401 inference this design removes - a cancelled beforeunload left the latch set for the life of the tab, failing every cloud call silently Notes - reverting the identity-only narrowing now fails two tests; it previously passed all 91
What - read the deliberate-sign-out flag synchronously at the logout hook, before the awaited deleteSession, instead of inside endExpiredSession - stop the cloud-JWT refresh from ending a session at all; it now only asks the identity provider to re-issue, and Firebase decides - route the router's public-path check through the shared predicate - cover the hook with a test that models the real async interleaving Why - the flag was released when authStore.logout() resolved, which has no network call, while the hook only read it after a DELETE round-trip, so it was always back to zero: every deliberate sign-out still redirected, and the requires-recent-login recovery was destroyed mid-dialog - a 401 from our own backend is not a verdict on the credential; requestToken collapses every 401 into INVALID_FIREBASE_TOKEN, so acting on it re-introduced the overloaded-401 inference this design removes - the router matched the shared list exactly while the redirect matched by prefix, so one list carried two semantics Notes - the old bracket tests called endExpiredSession synchronously inside the bracket, a sequence no caller produces; they passed against inert code
What - ask the identity provider to revalidate when the reactive re-mint hits an identity rejection, mirroring the scheduled refresh - gate it on the identity code so a denied or missing workspace does not trigger a refresh Why - clearUnifiedContext nulls the unified token, and getAuthHeader returns null rather than falling back, so getIdToken is never called again - Firebase's check is lazy-on-read in this app, so with nothing calling getIdToken a revoked credential is never noticed and the session never ends: the original dead-end, reproduced through the reactive path - asking is not deciding; this adds no terminator, and endExpiredSession still has exactly one caller Notes - when the provider says the identity is alive the app is left token-less with no re-mint, since unifiedTarget is already cleared. That is existing clearUnifiedContext behaviour, not introduced here.
What - keep the session terminated when the browser refuses to navigate, and re-attempt instead of releasing the latch - guard fetchJobDetail, and correct the claim about which fetchers the chokepoint covers - log when identity revalidation fails, rather than swallowing it - cover both traffic-stopping seams, and the non-cloud guard, with tests - correct the docstring that still named a second caller Why - the release restored the 401 storm in a default configuration: unsaved workflows arm the unload prompt, and a user who stays kept a dead session with both guards inert and no second redirect possible - fetchJobDetail bypasses fetchJobsRaw, so it kept logging a wrong reason - revalidation is the only thing left that can ask the provider once the unified context is cleared; a silent failure there is invisible - the two guards that stop the traffic had no tests at all, and the non-cloud guard survived mutation because its suite pins isCloud true Notes - the query-string public-route case was vacuous; location.pathname never carries a query. Replaced with the prefix case that motivated startsWith.
What - assert the guard is held for the whole sign-out and released after, at the real call site rather than through a mocked collaborator - cover fetchJobDetail's terminated-session early return - pin the revalidation warning so a silent failure cannot return - reattach the endExpiredSession docstring to its own function Why - the guard could be deleted from its call sites with the suite fully green, so the property the change exists to protect was undefended - terminated is now permanent, so a silent regression of that guard costs a dead tab rather than a ten second window - the warning is the only observability on the path that decides whether a session is dead Notes - dropping the arming call now fails the new test; it previously passed
What - retry the redirect on an interval rather than attempting it once - cover the reauthentication recovery, which had no tests at all - teach the error-handling test double to honour recovery strategies Why - a user with unsaved workflows gets the browser unload prompt; cancelling it left a tab with all traffic stopped and no further attempt, which looks exactly like the silent breakage this change removes - the latch still never releases: the session is dead, so resuming cloud traffic would bring back the 401 storm - the recovery signs out only to re-prompt in place, so it is the path where a stray redirect does the most damage, and nothing tested it - the test double ignored the recovery argument, so that whole branch was unreachable from the suite
What - suspend the session rather than navigating away, so the canvas and any unsaved work survive; resume it when a user signs back in - show a banner warning the user to export unsaved changes, with an action that re-authenticates through the provider they originally used - remember the signed-in identity while the session is healthy, since an expiry clears it before anything can read it - keep persisted drafts across an expiry, and clear them only when a different account signs in on the machine - retire the redirect, its retry timer and the shared public-route list Why - redirecting destroyed the unsaved graph, which survives on main today; the drafts were already being cleared the moment Firebase signed the user out, so the previous behaviour lost both - the OAuth providers already sign in through a popup that returns to its opener, so re-authenticating never has to leave the page - email has no popup, and an uncaptured provider must not be guessed, so both fall back to the existing in-app sign-in dialog - a false positive now costs a banner rather than a destroyed page Notes - deliberate sign-out still clears drafts, so the shared-machine property the wipe was written for is preserved
What - gate the logout wipe on the deliberate-sign-out flag, which is readable synchronously, instead of a suspension set behind an awaited network call - persist the last signed-in uid, and treat "nothing recorded" as the same user rather than a stranger - suspend before the awaited teardown, and resume only once the session cookie is back - make the deliberate-sign-out signal cross-tab - keep the banner clear of the menubar, and mount it only on cloud - cover all five draft outcomes, and drop assertions that could not fail Why - the suspension guard could never be true at the point it was read, so an expiry wiped the drafts it was meant to keep - remembered identity is module state, null on every load, so an ordinary refresh read the returning user as a stranger and cleared their work - Firebase propagates a sign-out to every tab, but a per-tab counter does not, so a deliberate sign-out suspended sibling tabs - the banner sat over the export menu its own copy points the user at - the persistence hooks were stubbed inert, which is why both defects passed a green suite Notes - the workspace-auth assertions referenced symbols that no longer exist on a store that never imported them; they could not fail and are removed
What - remove the cross-tab marker once the outermost sign-out completes - forget the remembered identity on a deliberate sign-out - assert the counter's nesting behaviour instead of a storage key that nothing ever removed - assert the reactive mirror the banner actually binds to - reset the session singleton between persistence tests Why - the marker was written but never cleared, so the guard stayed armed for ten seconds after every sign-out; a genuine expiry in that window was read as deliberate, which skipped the banner, left cloud traffic flowing, and wiped the drafts the previous commit set out to protect - the nesting test asserted a key that could not be absent, so the entire counter was mutation-uncovered - suspend and resume could each skip the ref with no test failing, which is the difference between the banner appearing and not - one test's unbalanced bracket leaked into the next, so the suite failed under shuffle and the cold-start case passed for the wrong reason Notes - these tests only fail where localStorage exists. Node 26 has none unless --localstorage-file is passed, so the earlier runs silently skipped every storage path; verified against a browser-like run.
An expired cloud token left the app dead-ended: bare canvas, no chrome, no login prompt, and the Jobs poller retrying 401 once per poll. Suspension is driven only by Firebase signing the user out, which it does on exactly user-disabled and user-token-expired. A 401 is per-endpoint and overloaded, so inferring session death from one would disrupt users whose credential is fine. Suspending never navigates. A banner on the shared notification surface warns the user to export unsaved changes and offers to sign in again through the provider they originally used, in a popup, resuming in place. Request seams short-circuit while suspended, ending the 401 storm. Drafts survive an expiry so re-authenticating restores the user's work, and are cleared only on a deliberate sign-out or when a different account signs in. That decision and the identity record are one atomic call, and both live in the auth hook rather than a canvas-scoped composable, whose watchers are disposed on the first navigation. The cloud route guard no longer redirects a suspended session to login, which would unmount the canvas and destroy the work the banner just told the user to export. Minting the session cookie now gates the resume, and the banner drives its own restore: the auth-state observer only reports a uid change, so a retry by the same user after a failed mint would otherwise never clear.
🎭 Playwright: ✅ 1755 passed, 0 failed · 2 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle: 8.15 MB gzip 🔴 +7.2 kBDetailsSummary
Category Glance App Entry Points — 3.74 kB (baseline 3.63 kB) • 🔴 +108 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.28 MB (baseline 1.28 MB) • 🟢 -3.28 kBGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed / 1 unchanged Views & Navigation — 112 kB (baseline 112 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 12 added / 12 removed / 4 unchanged Panels & Settings — 551 kB (baseline 551 kB) • 🔴 +346 BConfiguration panels, inspectors, and settings screens
Status: 11 added / 11 removed / 15 unchanged User & Accounts — 29.1 kB (baseline 29.1 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 7 added / 7 removed / 3 unchanged Editors & Dialogs — 121 kB (baseline 121 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 5 added / 5 removed / 1 unchanged UI Components — 64.8 kB (baseline 64.8 kB) • ⚪ 0 BReusable component library chunks
Status: 6 added / 6 removed / 8 unchanged Data & Services — 3.43 MB (baseline 3.42 MB) • 🔴 +3.49 kBStores, services, APIs, and repositories
Status: 14 added / 14 removed / 3 unchanged Utilities & Hooks — 372 kB (baseline 369 kB) • 🔴 +3.31 kBHelpers, composables, and utility bundles
Status: 18 added / 18 removed / 17 unchanged Vendor & Third-Party — 15.7 MB (baseline 15.7 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 16 unchanged Other — 12.5 MB (baseline 12.5 MB) • 🔴 +13.6 kBBundles that do not match a named category
Status: 78 added / 76 removed / 199 unchanged ⚡ Performance Report
Show regressions
All metrics
Historical variance (last 15 runs)
Trend (last 15 commits on main)
Raw data{
"timestamp": "2026-07-29T15:42:06.728Z",
"gitSha": "ee30d8dd8f8996b958f1bc4c1bdf50dd5a6f03c6",
"branch": "fix/cloud-session-expiry-401",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2078.2740000000217,
"styleRecalcs": 8,
"styleRecalcDurationMs": 11.303,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 635.357,
"heapDeltaBytes": 4111472,
"heapUsedBytes": 71980136,
"domNodes": 16,
"jsHeapTotalBytes": 20578304,
"scriptDurationMs": 24.846000000000004,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-idle",
"durationMs": 2020.7889999999225,
"styleRecalcs": 9,
"styleRecalcDurationMs": 9.738999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 559.133,
"heapDeltaBytes": 4395632,
"heapUsedBytes": 72398608,
"domNodes": 18,
"jsHeapTotalBytes": 20054016,
"scriptDurationMs": 24.042,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2022.8950000000054,
"styleRecalcs": 82,
"styleRecalcDurationMs": 51.039,
"layouts": 12,
"layoutDurationMs": 4.0440000000000005,
"taskDurationMs": 1045.747,
"heapDeltaBytes": -22037852,
"heapUsedBytes": 45973656,
"domNodes": 64,
"jsHeapTotalBytes": 20705280,
"scriptDurationMs": 140.61700000000002,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1966.3620000000037,
"styleRecalcs": 78,
"styleRecalcDurationMs": 47.312,
"layouts": 12,
"layoutDurationMs": 3.9760000000000004,
"taskDurationMs": 1037.381,
"heapDeltaBytes": -16522368,
"heapUsedBytes": 51316424,
"domNodes": -275,
"jsHeapTotalBytes": 21491712,
"scriptDurationMs": 144.926,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1756.0939999999619,
"styleRecalcs": 32,
"styleRecalcDurationMs": 21.273,
"layouts": 6,
"layoutDurationMs": 0.644,
"taskDurationMs": 460.6480000000001,
"heapDeltaBytes": 7315404,
"heapUsedBytes": 75378496,
"domNodes": 77,
"jsHeapTotalBytes": 20316160,
"scriptDurationMs": 27.006000000000004,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1772.322000000031,
"styleRecalcs": 31,
"styleRecalcDurationMs": 20.206999999999997,
"layouts": 6,
"layoutDurationMs": 0.662,
"taskDurationMs": 474.56399999999996,
"heapDeltaBytes": 7362140,
"heapUsedBytes": 75296876,
"domNodes": 78,
"jsHeapTotalBytes": 20054016,
"scriptDurationMs": 27.253,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "dom-widget-clipping",
"durationMs": 607.6810000000137,
"styleRecalcs": 10,
"styleRecalcDurationMs": 7.151000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 414.553,
"heapDeltaBytes": -12005984,
"heapUsedBytes": 55877520,
"domNodes": 16,
"jsHeapTotalBytes": 20840448,
"scriptDurationMs": 64.108,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "dom-widget-clipping",
"durationMs": 642.6559999999881,
"styleRecalcs": 10,
"styleRecalcDurationMs": 7.2669999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 430.8109999999999,
"heapDeltaBytes": -12248068,
"heapUsedBytes": 55691076,
"domNodes": 16,
"jsHeapTotalBytes": 21626880,
"scriptDurationMs": 65.729,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2037.5870000000305,
"styleRecalcs": 7,
"styleRecalcDurationMs": 7.711000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 828.9720000000001,
"heapDeltaBytes": 7376712,
"heapUsedBytes": 66526992,
"domNodes": -274,
"jsHeapTotalBytes": 4521984,
"scriptDurationMs": 135.036,
"eventListeners": -144,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2050.8139999999457,
"styleRecalcs": 7,
"styleRecalcDurationMs": 9.371,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 856.7539999999999,
"heapDeltaBytes": 7529148,
"heapUsedBytes": 66276076,
"domNodes": -276,
"jsHeapTotalBytes": 4784128,
"scriptDurationMs": 145.551,
"eventListeners": -144,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2288.0400000000236,
"styleRecalcs": 67,
"styleRecalcDurationMs": 12.356999999999996,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1422.642,
"heapDeltaBytes": -4832180,
"heapUsedBytes": 55971972,
"domNodes": -279,
"jsHeapTotalBytes": 5308416,
"scriptDurationMs": 468.69,
"eventListeners": -144,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2469.6910000000116,
"styleRecalcs": 69,
"styleRecalcDurationMs": 17.456000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1592.099,
"heapDeltaBytes": 5368072,
"heapUsedBytes": 65487760,
"domNodes": -279,
"jsHeapTotalBytes": 5251072,
"scriptDurationMs": 561.827,
"eventListeners": -144,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-zoom",
"durationMs": 3421.1310000000026,
"styleRecalcs": 63,
"styleRecalcDurationMs": 14.826000000000002,
"layouts": 60,
"layoutDurationMs": 8.650000000000002,
"taskDurationMs": 1711.89,
"heapDeltaBytes": 25381256,
"heapUsedBytes": 87031080,
"domNodes": 8,
"jsHeapTotalBytes": 7340032,
"scriptDurationMs": 632.522,
"eventListeners": 10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-zoom",
"durationMs": 3659.6210000000156,
"styleRecalcs": 63,
"styleRecalcDurationMs": 16.102,
"layouts": 60,
"layoutDurationMs": 8.485999999999999,
"taskDurationMs": 1826.824,
"heapDeltaBytes": -4201696,
"heapUsedBytes": 57748800,
"domNodes": -283,
"jsHeapTotalBytes": 7143424,
"scriptDurationMs": 657.894,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2063.623000000007,
"styleRecalcs": 8,
"styleRecalcDurationMs": 9.473000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 834.299,
"heapDeltaBytes": 7713828,
"heapUsedBytes": 68787216,
"domNodes": -278,
"jsHeapTotalBytes": 4521984,
"scriptDurationMs": 145.156,
"eventListeners": -146,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2081.613999999945,
"styleRecalcs": 7,
"styleRecalcDurationMs": 10.044999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 876.196,
"heapDeltaBytes": 7882036,
"heapUsedBytes": 68476212,
"domNodes": -279,
"jsHeapTotalBytes": 4259840,
"scriptDurationMs": 145.707,
"eventListeners": -144,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 657.8719999999976,
"styleRecalcs": 46,
"styleRecalcDurationMs": 11.624999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 460.56600000000003,
"heapDeltaBytes": -12022380,
"heapUsedBytes": 55939132,
"domNodes": 18,
"jsHeapTotalBytes": 22937600,
"scriptDurationMs": 132.34300000000002,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 637.6619999999775,
"styleRecalcs": 44,
"styleRecalcDurationMs": 9.953,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 421.986,
"heapDeltaBytes": -11414116,
"heapUsedBytes": 56599640,
"domNodes": 14,
"jsHeapTotalBytes": 21626880,
"scriptDurationMs": 124.14599999999999,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-idle",
"durationMs": 2005.9219999999982,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.597000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 540.8040000000001,
"heapDeltaBytes": 3964848,
"heapUsedBytes": 71925484,
"domNodes": 18,
"jsHeapTotalBytes": 20578304,
"scriptDurationMs": 19.857999999999997,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 2055.547000000047,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.696,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 620.6,
"heapDeltaBytes": -21635684,
"heapUsedBytes": 46345800,
"domNodes": -273,
"jsHeapTotalBytes": 19656704,
"scriptDurationMs": 22.208999999999996,
"eventListeners": -148,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1741.5829999999914,
"styleRecalcs": 76,
"styleRecalcDurationMs": 41.166000000000004,
"layouts": 16,
"layoutDurationMs": 5.102,
"taskDurationMs": 867.13,
"heapDeltaBytes": -5256060,
"heapUsedBytes": 62658924,
"domNodes": 62,
"jsHeapTotalBytes": 20578304,
"scriptDurationMs": 105.23599999999999,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1789.4770000000335,
"styleRecalcs": 75,
"styleRecalcDurationMs": 46.638,
"layouts": 16,
"layoutDurationMs": 5.472,
"taskDurationMs": 961.811,
"heapDeltaBytes": -5126012,
"heapUsedBytes": 63035628,
"domNodes": 61,
"jsHeapTotalBytes": 20578304,
"scriptDurationMs": 114.02400000000002,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-transition-enter",
"durationMs": 1509.3879999999444,
"styleRecalcs": 19,
"styleRecalcDurationMs": 34.80899999999999,
"layouts": 15,
"layoutDurationMs": 13.664,
"taskDurationMs": 1157.71,
"heapDeltaBytes": -2274672,
"heapUsedBytes": 81940856,
"domNodes": 13673,
"jsHeapTotalBytes": 9961472,
"scriptDurationMs": 50.96500000000001,
"eventListeners": 2371,
"totalBlockingTimeMs": 162,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 9066.227999999966,
"styleRecalcs": 249,
"styleRecalcDurationMs": 42.363,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 5273.497,
"heapDeltaBytes": 18833376,
"heapUsedBytes": 77625840,
"domNodes": -275,
"jsHeapTotalBytes": 6270976,
"scriptDurationMs": 1679.844,
"eventListeners": -128,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 9284.344000000034,
"styleRecalcs": 249,
"styleRecalcDurationMs": 42.751999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 5372.648,
"heapDeltaBytes": 18545156,
"heapUsedBytes": 77371980,
"domNodes": -276,
"jsHeapTotalBytes": 7057408,
"scriptDurationMs": 1699.269,
"eventListeners": -126,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 18102.057,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 18074.594,
"heapDeltaBytes": -63394504,
"heapUsedBytes": 167705252,
"domNodes": -8312,
"jsHeapTotalBytes": -13045760,
"scriptDurationMs": 603.143,
"eventListeners": -16387,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.780000000000047,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 18866.01899999994,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 18839.463,
"heapDeltaBytes": -56234272,
"heapUsedBytes": 168247388,
"domNodes": -8312,
"jsHeapTotalBytes": -11993088,
"scriptDurationMs": 636.512,
"eventListeners": -16385,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.780000000000047,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 23252.65399999995,
"styleRecalcs": 167,
"styleRecalcDurationMs": 26.466999999999963,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 23204.766,
"heapDeltaBytes": -50021536,
"heapUsedBytes": 176893420,
"domNodes": -8312,
"jsHeapTotalBytes": -14180352,
"scriptDurationMs": 1012.6070000000001,
"eventListeners": -16379,
"totalBlockingTimeMs": 806,
"frameDurationMs": 17.779999999999927,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 22707.447,
"styleRecalcs": 159,
"styleRecalcDurationMs": 25.436000000000014,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 22681.772,
"heapDeltaBytes": -23307752,
"heapUsedBytes": 176909728,
"domNodes": -8312,
"jsHeapTotalBytes": -15753216,
"scriptDurationMs": 1017.754,
"eventListeners": -16379,
"totalBlockingTimeMs": 588,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 469.9120000000221,
"styleRecalcs": 15,
"styleRecalcDurationMs": 22.319,
"layouts": 2,
"layoutDurationMs": 0.42899999999999994,
"taskDurationMs": 128.295,
"heapDeltaBytes": -15766708,
"heapUsedBytes": 51540572,
"domNodes": 130,
"jsHeapTotalBytes": 7995392,
"scriptDurationMs": 12.414,
"eventListeners": 67,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 466.90399999999954,
"styleRecalcs": 12,
"styleRecalcDurationMs": 17.595,
"layouts": 2,
"layoutDurationMs": 0.3370000000000001,
"taskDurationMs": 117.52099999999999,
"heapDeltaBytes": -16003740,
"heapUsedBytes": 51060328,
"domNodes": 117,
"jsHeapTotalBytes": 7471104,
"scriptDurationMs": 11.601,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
}
]
} |
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR adds cloud-session suspension and restoration, identity-aware draft ownership, provider-specific reauthentication, voluntary sign-out sequencing, suspended-session request gating, identity revalidation, and related tests and documentation. ChangesCloud Session Lifecycle
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant WorkspaceAuthStore
participant Firebase
participant SessionExpiry
participant SessionExpiredBanner
participant useSessionReauth
participant restoreCloudSession
WorkspaceAuthStore->>Firebase: getIdToken(true) after identity revocation
Firebase-->>WorkspaceAuthStore: refreshed or rejected credential
WorkspaceAuthStore->>SessionExpiry: update suspended session state
SessionExpiry-->>SessionExpiredBanner: reactive suspension state
SessionExpiredBanner->>useSessionReauth: reauthenticate()
useSessionReauth->>restoreCloudSession: restoreCloudSession()
restoreCloudSession->>SessionExpiry: resume session after cookie validation
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #14207 +/- ##
==========================================
- Coverage 80.05% 79.83% -0.23%
==========================================
Files 1699 1760 +61
Lines 117937 122774 +4837
Branches 40381 42122 +1741
==========================================
+ Hits 94411 98012 +3601
- Misses 22888 24072 +1184
- Partials 638 690 +52
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 171 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/auth/SessionExpiredBanner.test.ts`:
- Around line 45-79: Update the SessionExpiredBanner tests to query the banner
by its accessible alert role and query the action using getByRole('button', {
name: 'auth.sessionExpired.action' }). Replace all session-expired-banner test
ID lookups and the unnamed button query while preserving the existing assertions
and test behavior.
In `@src/composables/auth/useAuthActions.ts`:
- Around line 118-123: Extract the repeated voluntary sign-out bracket into an
exported asVoluntarySignOut helper in sessionExpiry.ts, preserving
beginVoluntarySignOut before the callback and endVoluntarySignOut in a finally
block. In src/composables/auth/useAuthActions.ts lines 118-123 and 261-266,
replace each manual bracket with the helper; in src/stores/authStore.ts lines
499-508, wrap credential.user.delete() with the helper while preserving the
existing best-effort catch and warning.
In `@src/locales/en/main.json`:
- Around line 2451-2455: Update the sessionExpired localization copy to use
neutral, reason-agnostic wording that also fits auth/user-disabled cases;
replace the title and action text that specifically imply expiration or signing
in again, while preserving the existing detail and resumeFailed entries unless
corresponding wording also implies an expired session.
In `@src/platform/workspace/stores/workspaceAuthStore.ts`:
- Around line 82-94: Extend identity revalidation to the legacy refreshToken()
path, including its related error-handling branches, so INVALID_FIREBASE_TOKEN
is confirmed with Firebase before clearWorkspaceContext() is called. Reuse
isIdentityRevoked and askProviderToRevalidate, preserving existing behavior for
confirmed revocation and non-identity workspace errors; ensure the same parity
applies to the referenced legacy refresh flows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3e5ccbca-0aac-440e-a96c-4b8bb31a4495
📒 Files selected for processing (31)
docs/adr/0011-derived-credential-lifecycle.mdsrc/App.vuesrc/components/auth/SessionExpiredBanner.test.tssrc/components/auth/SessionExpiredBanner.vuesrc/composables/auth/signOutSeam.test.tssrc/composables/auth/useAuthActions.test.tssrc/composables/auth/useAuthActions.tssrc/composables/auth/useCurrentUser.tssrc/composables/auth/useSessionReauth.test.tssrc/composables/auth/useSessionReauth.tssrc/extensions/core/cloudSessionCookie.test.tssrc/extensions/core/cloudSessionCookie.tssrc/locales/en/main.jsonsrc/platform/auth/authProvider.test.tssrc/platform/auth/authProvider.tssrc/platform/auth/session/restoreCloudSession.test.tssrc/platform/auth/session/restoreCloudSession.tssrc/platform/auth/session/sessionExpiry.test.tssrc/platform/auth/session/sessionExpiry.tssrc/platform/remote/comfyui/jobs/fetchJobs.test.tssrc/platform/remote/comfyui/jobs/fetchJobs.tssrc/platform/workflow/persistence/composables/useWorkflowPersistenceV2.test.tssrc/platform/workflow/persistence/composables/useWorkflowPersistenceV2.tssrc/platform/workspace/stores/useWorkspaceAuth.test.tssrc/platform/workspace/stores/workspaceAuthStore.tssrc/router.test.tssrc/router.tssrc/scripts/api.suspendedSession.test.tssrc/scripts/api.tssrc/stores/authStore.test.tssrc/stores/authStore.ts
💤 Files with no reviewable changes (1)
- src/platform/workflow/persistence/composables/useWorkflowPersistenceV2.ts
| it('stays out of the way while the session is healthy', () => { | ||
| render(SessionExpiredBanner) | ||
|
|
||
| expect(screen.queryByTestId('session-expired-banner')).toBeNull() | ||
| }) | ||
|
|
||
| it('warns about unsaved work when the session is suspended', () => { | ||
| mocks.suspended.value = true | ||
|
|
||
| render(SessionExpiredBanner) | ||
|
|
||
| expect(screen.getByTestId('session-expired-banner')).toBeTruthy() | ||
| // The warning is the point: the user must know to export before acting. | ||
| expect(screen.getByText('auth.sessionExpired.detail')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('re-authenticates in place when the action is used', async () => { | ||
| mocks.suspended.value = true | ||
| render(SessionExpiredBanner) | ||
|
|
||
| await userEvent.click(screen.getByRole('button')) | ||
|
|
||
| expect(mocks.reauthenticate).toHaveBeenCalledTimes(1) | ||
| }) | ||
|
|
||
| it('announces itself assertively, since it blocks all cloud work', () => { | ||
| mocks.suspended.value = true | ||
|
|
||
| render(SessionExpiredBanner) | ||
|
|
||
| // The shared popup is a polite status by default; this one interrupts, | ||
| // because the user has unsaved work and every cloud request is failing. | ||
| const banner = screen.getByTestId('session-expired-banner') | ||
| expect(banner.getAttribute('role')).toBe('alert') | ||
| expect(banner.getAttribute('aria-live')).toBe('assertive') |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Query the banner through accessible roles and names.
Use queryByRole('alert'), getByRole('alert'), and
getByRole('button', { name: 'auth.sessionExpired.action' }) instead of
test IDs or an unnamed button query. This validates the accessibility contract
rather than root markup.
Suggested test changes
- expect(screen.queryByTestId('session-expired-banner')).toBeNull()
+ expect(screen.queryByRole('alert')).toBeNull()
- expect(screen.getByTestId('session-expired-banner')).toBeTruthy()
+ expect(screen.getByRole('alert')).toBeTruthy()
- await userEvent.click(screen.getByRole('button'))
+ await userEvent.click(
+ screen.getByRole('button', { name: 'auth.sessionExpired.action' })
+ )
- const banner = screen.getByTestId('session-expired-banner')
+ const banner = screen.getByRole('alert')Based on learnings, tests should prefer roles and accessible names over
data-testid selectors.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('stays out of the way while the session is healthy', () => { | |
| render(SessionExpiredBanner) | |
| expect(screen.queryByTestId('session-expired-banner')).toBeNull() | |
| }) | |
| it('warns about unsaved work when the session is suspended', () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| expect(screen.getByTestId('session-expired-banner')).toBeTruthy() | |
| // The warning is the point: the user must know to export before acting. | |
| expect(screen.getByText('auth.sessionExpired.detail')).toBeTruthy() | |
| }) | |
| it('re-authenticates in place when the action is used', async () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| await userEvent.click(screen.getByRole('button')) | |
| expect(mocks.reauthenticate).toHaveBeenCalledTimes(1) | |
| }) | |
| it('announces itself assertively, since it blocks all cloud work', () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| // The shared popup is a polite status by default; this one interrupts, | |
| // because the user has unsaved work and every cloud request is failing. | |
| const banner = screen.getByTestId('session-expired-banner') | |
| expect(banner.getAttribute('role')).toBe('alert') | |
| expect(banner.getAttribute('aria-live')).toBe('assertive') | |
| it('stays out of the way while the session is healthy', () => { | |
| render(SessionExpiredBanner) | |
| expect(screen.queryByRole('alert')).toBeNull() | |
| }) | |
| it('warns about unsaved work when the session is suspended', () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| expect(screen.getByRole('alert')).toBeTruthy() | |
| // The warning is the point: the user must know to export before acting. | |
| expect(screen.getByText('auth.sessionExpired.detail')).toBeTruthy() | |
| }) | |
| it('re-authenticates in place when the action is used', async () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| await userEvent.click( | |
| screen.getByRole('button', { name: 'auth.sessionExpired.action' }) | |
| ) | |
| expect(mocks.reauthenticate).toHaveBeenCalledTimes(1) | |
| }) | |
| it('announces itself assertively, since it blocks all cloud work', () => { | |
| mocks.suspended.value = true | |
| render(SessionExpiredBanner) | |
| // The shared popup is a polite status by default; this one interrupts, | |
| // because the user has unsaved work and every cloud request is failing. | |
| const banner = screen.getByRole('alert') | |
| expect(banner.getAttribute('role')).toBe('alert') | |
| expect(banner.getAttribute('aria-live')).toBe('assertive') |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/auth/SessionExpiredBanner.test.ts` around lines 45 - 79,
Update the SessionExpiredBanner tests to query the banner by its accessible
alert role and query the action using getByRole('button', { name:
'auth.sessionExpired.action' }). Replace all session-expired-banner test ID
lookups and the unnamed button query while preserving the existing assertions
and test behavior.
Sources: Path instructions, Learnings
| beginVoluntarySignOut() | ||
| try { | ||
| await authStore.logout() | ||
| } finally { | ||
| endVoluntarySignOut() | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Extract the repeated voluntary-sign-out bracket into a shared helper. The same beginVoluntarySignOut(); try { ... } finally { endVoluntarySignOut() } idiom is hand-rolled three times across two files. Since a missing bracket at any future sign-out call site would misclassify a deliberate sign-out as a credential-rejection expiry (or vice versa), centralizing it in sessionExpiry.ts (e.g. export async function asVoluntarySignOut<T>(fn: () => Promise<T>): Promise<T> { beginVoluntarySignOut(); try { return await fn() } finally { endVoluntarySignOut() } }) removes the duplication and the risk that a new call site forgets it.
src/composables/auth/useAuthActions.ts#L118-L123: replace the bracket inlogout()withawait asVoluntarySignOut(() => authStore.logout()).src/composables/auth/useAuthActions.ts#L261-L266: replace the bracket increateReauthenticationRecovery'srecover()with the same helper call.src/stores/authStore.ts#L499-L508: replace the bracket aroundcredential.user.delete()with the same helper call (keeping the existing catch/warn for the best-effort delete).
📍 Affects 2 files
src/composables/auth/useAuthActions.ts#L118-L123(this comment)src/composables/auth/useAuthActions.ts#L261-L266src/stores/authStore.ts#L499-L508
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/composables/auth/useAuthActions.ts` around lines 118 - 123, Extract the
repeated voluntary sign-out bracket into an exported asVoluntarySignOut helper
in sessionExpiry.ts, preserving beginVoluntarySignOut before the callback and
endVoluntarySignOut in a finally block. In
src/composables/auth/useAuthActions.ts lines 118-123 and 261-266, replace each
manual bracket with the helper; in src/stores/authStore.ts lines 499-508, wrap
credential.user.delete() with the helper while preserving the existing
best-effort catch and warning.
| "sessionExpired": { | ||
| "title": "Your session expired", | ||
| "detail": "Export any unsaved changes before continuing, or you may lose them.", | ||
| "action": "Sign in again", | ||
| "resumeFailed": "We couldn't restore your session. Please try signing in again." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use neutral copy for disabled-account suspension.
This banner also handles auth/user-disabled, so “Your session expired” and
“Sign in again” misstate the cause for users who must contact support. Use
reason-aware messaging or neutral “session ended” copy.
Suggested neutral copy
- "title": "Your session expired",
+ "title": "Your session has ended",
"detail": "Export any unsaved changes before continuing, or you may lose them.",
- "action": "Sign in again",
+ "action": "Sign in",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "sessionExpired": { | |
| "title": "Your session expired", | |
| "detail": "Export any unsaved changes before continuing, or you may lose them.", | |
| "action": "Sign in again", | |
| "resumeFailed": "We couldn't restore your session. Please try signing in again." | |
| "sessionExpired": { | |
| "title": "Your session has ended", | |
| "detail": "Export any unsaved changes before continuing, or you may lose them.", | |
| "action": "Sign in", | |
| "resumeFailed": "We couldn't restore your session. Please try signing in again." |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/locales/en/main.json` around lines 2451 - 2455, Update the sessionExpired
localization copy to use neutral, reason-agnostic wording that also fits
auth/user-disabled cases; replace the title and action text that specifically
imply expiration or signing in again, while preserving the existing detail and
resumeFailed entries unless corresponding wording also implies an expired
session.
| /** | ||
| * The subset of permanent failures that mean the IDENTITY was rejected, rather | ||
| * than that this workspace is gone or off-limits. `/api/auth/token` answers 401 | ||
| * for a bad Firebase token but 403 for a denied workspace and 404 for a missing | ||
| * one — the latter two leave the user's credential perfectly valid, so they must | ||
| * never end the session. | ||
| */ | ||
| function isIdentityRevoked(err: unknown): boolean { | ||
| return ( | ||
| err instanceof WorkspaceAuthError && err.code === 'INVALID_FIREBASE_TOKEN' | ||
| ) | ||
| } | ||
|
|
There was a problem hiding this comment.
🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win
Identity-revalidation fix is unified-only; legacy refreshToken() still has the same overloaded-401 problem.
isIdentityRevoked/askProviderToRevalidate are wired into refreshUnified() and remintUnifiedOnce(), but the pre-existing legacy refreshToken() (used when unified_cloud_auth is off) still treats a backend INVALID_FIREBASE_TOKEN (401) as authoritative and calls clearWorkspaceContext() without ever asking Firebase to confirm the credential is actually dead — exactly the "requestToken collapses every 401 into INVALID_FIREBASE_TOKEN regardless of why" problem this PR's own comment calls out. A transient backend 401 on the legacy path can still tear down a valid workspace context.
The existing TODO(unified) note a few lines above (forgetRevokedActiveWorkspace parity) suggests legacy/unified parity gaps are being deferred deliberately, so this may be intentional — please confirm whether the same revalidation should also apply to refreshToken(), or if it's out of scope until the legacy path is retired.
Also applies to: 842-863, 887-889, 940-951
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platform/workspace/stores/workspaceAuthStore.ts` around lines 82 - 94,
Extend identity revalidation to the legacy refreshToken() path, including its
related error-handling branches, so INVALID_FIREBASE_TOKEN is confirmed with
Firebase before clearWorkspaceContext() is called. Reuse isIdentityRevoked and
askProviderToRevalidate, preserving existing behavior for confirmed revocation
and non-identity workspace errors; ensure the same parity applies to the
referenced legacy refresh flows.
Corrects a claim in 04891fe's message, which is pushed and cannot be amended. That message said the auth-state observer "only reports a uid change, so a retry by the same user after a failed mint would otherwise never clear". That is wrong. The hook rides whenever(resolvedUserInfo), a plain watch over a computed that rebuilds its object, so the sign-out's null and the re-sign-in's value are two transitions and it does fire. The banner still drives the restore itself because a re-sign-in that never cleared currentUser raises no transition at all; restoreCloudSession is single-flight, so both firing is harmless. Scope before connect. The socket's handshake token fixes its scope, and nothing re-handshakes on a workspace change: everywhere else the app changes workspace by reloading. Connecting first left a recovered team user on a personal-scoped stream for the life of the page. The wait is bounded above what the workspace initializer can spend on its own retries, so a stalled workspace list costs the scope rather than realtime too. The socket guard is re-checked after the token await. Suspension normally lands during that await, because the auth store resets the socket before it assigns currentUser and the watcher that suspends runs off that assignment, so an entry-only check was always already past. Suspension no longer answers an empty list where the user has data. The queue, the job history and the outputs gallery hold their last snapshot instead of reporting nothing, and the ten-minute feature-flag poll stops wiping the flags that carry the export affordances the banner points at. A revalidation re-checks that its captured scope is still current before minting, using the request generation rather than the target, which a workspace switch clears for its whole duration. Run while suspended now surfaces the expiry instead of rendering nothing and reporting success. Fixes the draft-ownership reload decision, which read a different collection than the loop that disarms the unload prompt, so a saved but open document belonging to the previous user did not trigger the bounce. Tests cover the release of the deliberate-sign-out bracket on every failure path. Skipping it once arms the marker for the tab's life, after which a real expiry reads as deliberate and wipes the drafts.
|
Correction to an earlier commit message on this branch.
The hook rides That commit is pushed and cannot be amended, so the correction lives in |
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/composables/auth/useAuthActions.test.ts (1)
100-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftThe mock now reimplements the real wrapper's recovery semantics.
Recovery matching, swallow-on-recovery-failure, and fall-through to the error handler are duplicated here, so the reauthentication tests below can keep passing while
useErrorHandlingdrifts. Since this module is owned by the repo, consider exercising the real wrapper and mocking only its outward-facing collaborators.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/composables/auth/useAuthActions.test.ts` around lines 100 - 129, Update the test mock around the async action wrapper to use the real useErrorHandling wrapper instead of duplicating recovery matching, swallowing, and error-handler fallback behavior. Mock only the wrapper’s outward-facing collaborators, and preserve the existing reauthentication test coverage through the real implementation.Source: Path instructions
src/extensions/core/cloudSessionCookie.ts (1)
57-62: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winStop restoration after scheduling the account-mismatch reload.
window.location.reload()does not terminate this async hook.restoreCloudSession()can resume authenticated traffic while the previous account’s canvas remains mounted, allowing persistence to recreate data just cleared for the new account. Return immediately after requesting the reload.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/extensions/core/cloudSessionCookie.ts` around lines 57 - 62, Update the account-mismatch branch in the cloud session restoration hook to return immediately after calling window.location.reload(). Ensure restoreCloudSession() is not reached once a reload is scheduled, while preserving the existing restoration flow when no open workflows require reloading.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/adr/0011-derived-credential-lifecycle.md`:
- Around line 88-90: Correct the broken sentence in the FE-1390 paragraph by
adding the missing relative pronoun so it clearly states that recovery restores
the workspace context that the sign-out reset restores. Preserve the surrounding
meaning and wording.
In `@src/composables/auth/useAuthActions.test.ts`:
- Around line 461-465: Update the beforeEach setup in the auth action tests to
install createTestingPinia instead of createPinia, configuring stubActions:
false so the tests execute real Pinia action logic while preserving the existing
mock reset and cloud-state initialization.
In `@src/composables/auth/useSessionReauth.ts`:
- Around line 49-56: Gate restoreCloudSession in useSessionReauth on an explicit
successful reauthentication result rather than authStore.currentUser, preserving
the same-user behavior while skipping canceled popups. In
src/composables/auth/useSessionReauth.test.ts lines 99-108, add coverage for a
resolved canceled sign-in with the original currentUser still present and assert
restoration is not called.
In `@src/extensions/core/cloudSessionCookie.test.ts`:
- Around line 315-424: Extract the repeated window.location descriptor setup and
restoration into shared test lifecycle logic or a helper that returns the reload
spy. Update the affected tests around onAuthUserResolved to use this utility,
preserving configurable restoration after each test and each test’s existing
reload assertions.
In `@src/platform/auth/session/restoreCloudSession.test.ts`:
- Around line 131-138: Move the console.warn spy setup from individual tests
into the restoreCloudSession test suite’s beforeEach lifecycle hook, and restore
it in afterEach (or use vi.restoreAllMocks()). Remove each test’s local spy
creation and manual mockRestore calls while preserving the existing
warning-suppression behavior.
In `@src/platform/auth/session/restoreCloudSession.ts`:
- Around line 111-113: Handle rejections from api.reconnectSocket in the
wasSuspended recovery path instead of discarding its promise. Update the finally
callback around restoreWorkspaceScope so reconnectSocket’s failure is explicitly
caught or otherwise consumed, while preserving the existing reconnect attempt
after workspace restoration.
- Around line 90-95: Update the recovery logic around mintAtLogin so the
non-unified path still invokes the existing getAuthHeader flow, including
ensureWorkspaceAuthHeader/Firebase token retrieval. Limit mintAtLogin to
unifiedCloudAuthEnabled, and preserve the current mintReportedFailure handling
without replacing the legacy credential recovery path.
In `@src/platform/remoteConfig/refreshRemoteConfig.ts`:
- Around line 49-53: Recheck suspension after awaited requests and before
mutating retained state: in
src/platform/remoteConfig/refreshRemoteConfig.ts#L49-L53, skip
unauthorized-response handling and config clearing when suspension began in
flight; in src/stores/assetsStore.ts#L156-L160, defer destructive initial-load
reset until a valid result exists and discard in-flight results after
suspension; in src/stores/queueStore.ts#L525-L529, recheck after
Promise.allSettled() before applying either result; add a regression test in
src/stores/queueStore.test.ts#L1145-L1170 that suspends after requests start but
before they settle.
In `@src/stores/authStore.test.ts`:
- Around line 536-543: Ensure the console.warn spy created in this registration
test is restored on every exit path by wrapping the awaited registration
assertion and related checks in a try/finally block, with warn.mockRestore() in
finally. Keep the existing rejection and sign-out assertions unchanged.
---
Outside diff comments:
In `@src/composables/auth/useAuthActions.test.ts`:
- Around line 100-129: Update the test mock around the async action wrapper to
use the real useErrorHandling wrapper instead of duplicating recovery matching,
swallowing, and error-handler fallback behavior. Mock only the wrapper’s
outward-facing collaborators, and preserve the existing reauthentication test
coverage through the real implementation.
In `@src/extensions/core/cloudSessionCookie.ts`:
- Around line 57-62: Update the account-mismatch branch in the cloud session
restoration hook to return immediately after calling window.location.reload().
Ensure restoreCloudSession() is not reached once a reload is scheduled, while
preserving the existing restoration flow when no open workflows require
reloading.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: ee5c8024-39aa-43e8-aa05-4217b18c4caf
📒 Files selected for processing (33)
docs/adr/0011-derived-credential-lifecycle.mdsrc/components/auth/SessionExpiredBanner.test.tssrc/components/auth/SessionExpiredBanner.vuesrc/composables/auth/signOutSeam.test.tssrc/composables/auth/useAuthActions.test.tssrc/composables/auth/useSessionReauth.test.tssrc/composables/auth/useSessionReauth.tssrc/extensions/core/cloudSessionCookie.test.tssrc/extensions/core/cloudSessionCookie.tssrc/platform/auth/authProvider.tssrc/platform/auth/session/publicRoutes.test.tssrc/platform/auth/session/publicRoutes.tssrc/platform/auth/session/restoreCloudSession.test.tssrc/platform/auth/session/restoreCloudSession.tssrc/platform/auth/session/sessionExpiry.test.tssrc/platform/auth/session/sessionExpiry.tssrc/platform/remote/comfyui/jobs/fetchJobs.test.tssrc/platform/remote/comfyui/jobs/fetchJobs.tssrc/platform/remoteConfig/refreshRemoteConfig.test.tssrc/platform/remoteConfig/refreshRemoteConfig.tssrc/platform/workflow/persistence/composables/useWorkflowPersistenceV2.test.tssrc/platform/workspace/stores/teamWorkspaceStore.tssrc/platform/workspace/stores/useWorkspaceAuth.test.tssrc/platform/workspace/stores/workspaceAuthStore.tssrc/router.test.tssrc/router.tssrc/scripts/api.suspendedSession.test.tssrc/scripts/api.tssrc/stores/assetsStore.test.tssrc/stores/assetsStore.tssrc/stores/authStore.test.tssrc/stores/queueStore.test.tssrc/stores/queueStore.ts
| it('disarms a closed-but-dirty document without bouncing an empty page', async () => { | ||
| const original = Object.getOwnPropertyDescriptor(window, 'location') | ||
| const reload = vi.fn() | ||
| Object.defineProperty(window, 'location', { | ||
| value: { reload }, | ||
| writable: true, | ||
| configurable: true | ||
| }) | ||
|
|
||
| try { | ||
| const closedButDirty = { isModified: true } | ||
| const { onAuthUserResolved } = await loadHook() | ||
| await onAuthUserResolved({ id: 'uid-a' }) | ||
| mocks.openWorkflows = [] | ||
| mocks.modifiedWorkflows = [closedButDirty] | ||
|
|
||
| await onAuthUserResolved({ id: 'uid-b' }) | ||
|
|
||
| // Nothing is on screen to inherit, so no bounce; but the stale mark would | ||
| // arm the unload prompt against the new user for a document that is not | ||
| // theirs and is already gone from storage. | ||
| expect(reload).not.toHaveBeenCalled() | ||
| expect(closedButDirty.isModified).toBe(false) | ||
| } finally { | ||
| if (original) Object.defineProperty(window, 'location', original) | ||
| } | ||
| }) | ||
|
|
||
| it('bounces even when the open document has no unsaved changes', async () => { | ||
| const original = Object.getOwnPropertyDescriptor(window, 'location') | ||
| const reload = vi.fn() | ||
| Object.defineProperty(window, 'location', { | ||
| value: { reload }, | ||
| writable: true, | ||
| configurable: true | ||
| }) | ||
|
|
||
| try { | ||
| const { onAuthUserResolved } = await loadHook() | ||
| await onAuthUserResolved({ id: 'uid-a' }) | ||
| // Saved, so it is open but absent from `modifiedWorkflows`. Deciding the | ||
| // reload off that collection leaves uid-a's canvas mounted for uid-b. | ||
| mocks.openWorkflows = [{ isModified: false }] | ||
| mocks.modifiedWorkflows = [] | ||
|
|
||
| await onAuthUserResolved({ id: 'uid-b' }) | ||
|
|
||
| expect(reload).toHaveBeenCalledTimes(1) | ||
| } finally { | ||
| if (original) Object.defineProperty(window, 'location', original) | ||
| } | ||
| }) | ||
|
|
||
| it('clears every modified workflow, including ones already closed', async () => { | ||
| const original = Object.getOwnPropertyDescriptor(window, 'location') | ||
| const reload = vi.fn() | ||
| Object.defineProperty(window, 'location', { | ||
| value: { reload }, | ||
| writable: true, | ||
| configurable: true | ||
| }) | ||
|
|
||
| try { | ||
| const openA = { isModified: true } | ||
| const openB = { isModified: true } | ||
| // Closed earlier with "close anyway", so unload() left it modified. The | ||
| // unload prompt reads this collection, so it alone can veto the reload. | ||
| const closedButDirty = { isModified: true } | ||
|
|
||
| const { onAuthUserResolved } = await loadHook() | ||
| await onAuthUserResolved({ id: 'uid-a' }) | ||
| mocks.openWorkflows = [openA, openB] | ||
| mocks.modifiedWorkflows = [openA, openB, closedButDirty] | ||
|
|
||
| await onAuthUserResolved({ id: 'uid-b' }) | ||
|
|
||
| expect(openA.isModified).toBe(false) | ||
| expect(openB.isModified).toBe(false) | ||
| expect(closedButDirty.isModified).toBe(false) | ||
| expect(reload).toHaveBeenCalledTimes(1) | ||
| } finally { | ||
| if (original) Object.defineProperty(window, 'location', original) | ||
| } | ||
| }) | ||
|
|
||
| it('does not close anything, so the persistence writers stay quiet', async () => { | ||
| const original = Object.getOwnPropertyDescriptor(window, 'location') | ||
| Object.defineProperty(window, 'location', { | ||
| value: { reload: vi.fn() }, | ||
| writable: true, | ||
| configurable: true | ||
| }) | ||
|
|
||
| try { | ||
| const open = { isModified: true } | ||
| const { onAuthUserResolved } = await loadHook() | ||
| await onAuthUserResolved({ id: 'uid-a' }) | ||
| mocks.openWorkflows = [open] | ||
| mocks.modifiedWorkflows = [open] | ||
|
|
||
| await onAuthUserResolved({ id: 'uid-b' }) | ||
|
|
||
| // Closing re-activates other documents, which re-arms the persistence | ||
| // watchers against the storage cleared one line earlier. The reload | ||
| // discards the canvas anyway. | ||
| expect(mocks.closeWorkflow).not.toHaveBeenCalled() | ||
| } finally { | ||
| if (original) Object.defineProperty(window, 'location', original) | ||
| } | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Extract the window.location stub/restore boilerplate.
The same descriptor save → defineProperty({ reload }) → restore-in-finally block is repeated in five tests. A helper (or beforeEach/afterEach pair returning the reload spy) keeps each test to its actual behavior.
♻️ Sketch
+let reload: ReturnType<typeof vi.fn>
+let originalLocation: PropertyDescriptor | undefined
+
+beforeEach(() => {
+ originalLocation = Object.getOwnPropertyDescriptor(window, 'location')
+ reload = vi.fn()
+ Object.defineProperty(window, 'location', {
+ value: { reload },
+ writable: true,
+ configurable: true
+ })
+})
+
+afterEach(() => {
+ if (originalLocation)
+ Object.defineProperty(window, 'location', originalLocation)
+})🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/extensions/core/cloudSessionCookie.test.ts` around lines 315 - 424,
Extract the repeated window.location descriptor setup and restoration into
shared test lifecycle logic or a helper that returns the reload spy. Update the
affected tests around onAuthUserResolved to use this utility, preserving
configurable restoration after each test and each test’s existing reload
assertions.
| const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) | ||
| suspendSession() | ||
|
|
||
| await restoreCloudSession() | ||
|
|
||
| expect(isSessionSuspended()).toBe(true) | ||
| expect(mocks.addToast).toHaveBeenCalledTimes(1) | ||
| warn.mockRestore() |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Hoist the console.warn silencing into the suite lifecycle.
The spy is re-created and manually restored in roughly a dozen tests; when an assertion fails before mockRestore(), the spy leaks into later tests. A single beforeEach/afterEach pair (or vi.restoreAllMocks() in afterEach) removes both the duplication and the leak.
♻️ Sketch
+let warn: ReturnType<typeof vi.spyOn>
+
+beforeEach(() => {
+ warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
+})
+
+afterEach(() => {
+ warn.mockRestore()
+})🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platform/auth/session/restoreCloudSession.test.ts` around lines 131 -
138, Move the console.warn spy setup from individual tests into the
restoreCloudSession test suite’s beforeEach lifecycle hook, and restore it in
afterEach (or use vi.restoreAllMocks()). Remove each test’s local spy creation
and manual mockRestore calls while preserving the existing warning-suppression
behavior.
| // `mintAtLogin` returns false without saying anything when the flag is off, | ||
| // so reading the bare boolean as "it already told them" silences the only | ||
| // failure message the whole non-unified path has. | ||
| mintReportedFailure = | ||
| useFeatureFlags().flags.unifiedCloudAuthEnabled && | ||
| !(await useWorkspaceAuthStore().mintAtLogin()) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
ast-grep outline src/platform/workspace/stores/workspaceAuthStore.ts --items all
rg -nP -C4 '\bmintAtLogin\s*\(' src --type=tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 26864
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== restoreCloudSession.ts relevant section =="
sed -n '1,140p' src/platform/auth/session/restoreCloudSession.ts
echo
echo "== workspaceAuthStore.ts relevant sections =="
sed -n '620,680p' src/platform/workspace/stores/workspaceAuthStore.ts
sed -n '800,855p' src/platform/workspace/stores/workspaceAuthStore.ts
echo
echo "== tests around restore and non-unified mint =="
rg -n -C 6 "still reports a failed recovery when unified auth is off|mints the request credential|unifiedCloudAuthEnabled|mintAtLogin" src/platform --type=tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 50382
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== all callers of restoreCloudSession =="
rg -n -C 4 '\brestoreCloudSession\s*\(' src tests --type=ts --type=vue || true
echo
echo "== authStore login hook section =="
sed -n '140,190p' src/stores/authStore.ts
echo
echo "== authStore request credential helpers and auth header sections =="
sed -n '200,290p' src/stores/authStore.ts
echo
echo "== workspaceAuthStore unified vs non-unified header/token sections =="
sed -n '936,1018p' src/platform/workspace/stores/workspaceAuthStore.tsRepository: Comfy-Org/ComfyUI_frontend
Length of output: 27536
Preserve the existing non-unified credential path during recovery.
mintAtLogin() only mints the unified Cloud JWT and skips minting workspace tokens, while the non-unified getAuthHeader() chain can still need ensureWorkspaceAuthHeader()/Firebase tokens. This changes the recovery behavior compared with the previous path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platform/auth/session/restoreCloudSession.ts` around lines 90 - 95,
Update the recovery logic around mintAtLogin so the non-unified path still
invokes the existing getAuthHeader flow, including
ensureWorkspaceAuthHeader/Firebase token retrieval. Limit mintAtLogin to
unifiedCloudAuthEnabled, and preserve the current mintReportedFailure handling
without replacing the legacy credential recovery path.
| if (wasSuspended) { | ||
| void restoreWorkspaceScope().finally(() => void api.reconnectSocket()) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
void api.reconnectSocket() leaves a rejection unhandled.
restoreWorkspaceScope swallows its own errors, but a rejecting reconnectSocket here escapes as an unhandled rejection on the recovery path.
🛡️ Proposed fix
if (wasSuspended) {
- void restoreWorkspaceScope().finally(() => void api.reconnectSocket())
+ void restoreWorkspaceScope().finally(() =>
+ void Promise.resolve(api.reconnectSocket()).catch((error) => {
+ console.warn('Realtime could not be reconnected:', error)
+ })
+ )
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (wasSuspended) { | |
| void restoreWorkspaceScope().finally(() => void api.reconnectSocket()) | |
| } | |
| if (wasSuspended) { | |
| void restoreWorkspaceScope().finally(() => | |
| void Promise.resolve(api.reconnectSocket()).catch((error) => { | |
| console.warn('Realtime could not be reconnected:', error) | |
| }) | |
| ) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platform/auth/session/restoreCloudSession.ts` around lines 111 - 113,
Handle rejections from api.reconnectSocket in the wasSuspended recovery path
instead of discarding its promise. Update the finally callback around
restoreWorkspaceScope so reconnectSocket’s failure is explicitly caught or
otherwise consumed, while preserving the existing reconnect attempt after
workspace restoration.
| // A suspended session answers this with a synthetic 401, and the handler | ||
| // below reads a 401 as "the server disowned these flags" and wipes them. The | ||
| // 10-minute poller would then strip the export affordances out from under a | ||
| // banner telling the user to go export their work. | ||
| if (useAuth && isSessionSuspended()) return |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Recheck suspension after awaited requests before mutating retained state. These guards only protect calls that begin after suspension. If suspension starts while a request is in flight, synthetic/failed results can still clear remote config, gallery history, or job history.
src/platform/remoteConfig/refreshRemoteConfig.ts#L49-L53: recheck before processing an unauthorized response or clearing config.src/stores/assetsStore.ts#L156-L160: defer destructive initial-load reset until a valid result is ready, and discard results when suspension begins in flight.src/stores/queueStore.ts#L525-L529: recheck afterPromise.allSettled()and before applying either result.src/stores/queueStore.test.ts#L1145-L1170: add a regression case that suspends after requests begin but before their promises settle.
📍 Affects 4 files
src/platform/remoteConfig/refreshRemoteConfig.ts#L49-L53(this comment)src/stores/assetsStore.ts#L156-L160src/stores/queueStore.ts#L525-L529src/stores/queueStore.test.ts#L1145-L1170
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/platform/remoteConfig/refreshRemoteConfig.ts` around lines 49 - 53,
Recheck suspension after awaited requests and before mutating retained state: in
src/platform/remoteConfig/refreshRemoteConfig.ts#L49-L53, skip
unauthorized-response handling and config clearing when suspension began in
flight; in src/stores/assetsStore.ts#L156-L160, defer destructive initial-load
reset until a valid result exists and discard in-flight results after
suspension; in src/stores/queueStore.ts#L525-L529, recheck after
Promise.allSettled() before applying either result; add a regression test in
src/stores/queueStore.test.ts#L1145-L1170 that suspends after requests start but
before they settle.
| const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) | ||
|
|
||
| await expect( | ||
| store.register('new@example.com', 'password', 'turnstile-bad') | ||
| ).rejects.toThrow() | ||
|
|
||
| expect(isVoluntarySignOutInProgress()).toBe(false) | ||
| warn.mockRestore() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate and inspect the referenced test file and nearby teardown/setup context.
if [ -f "src/stores/authStore.test.ts" ]; then
echo "## file exists"
wc -l src/stores/authStore.test.ts
echo "## outline"
ast-grep outline src/stores/authStore.test.ts --view expanded || true
echo "## relevant lines 500-560"
cat -n -s src/stores/authStore.test.ts | sed -n '500,560p'
echo "## beforeEach/reset occurrences"
rg -n "beforeEach|resetAllMocks|restoreAllMocks|mockRestore|console\s*\.\s*warn|warn\s*=" src/stores/authStore.test.ts
else
echo "file missing"
git ls-files | rg 'authStore\.test\.ts$' || true
fiRepository: Comfy-Org/ComfyUI_frontend
Length of output: 4103
Restore the console spy on every exit path.
If registration or an assertion fails, warn.mockRestore() is skipped and console.warn can remain mocked for subsequent tests. Wrap the test body or expected assertions in try/finally.
Proposed fix
- await expect(
- store.register('new@example.com', 'password', 'turnstile-bad')
- ).rejects.toThrow()
-
- expect(isVoluntarySignOutInProgress()).toBe(false)
- warn.mockRestore()
+ try {
+ await expect(
+ store.register('new@example.com', 'password', 'turnstile-bad')
+ ).rejects.toThrow()
+
+ expect(isVoluntarySignOutInProgress()).toBe(false)
+ } finally {
+ warn.mockRestore()
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) | |
| await expect( | |
| store.register('new@example.com', 'password', 'turnstile-bad') | |
| ).rejects.toThrow() | |
| expect(isVoluntarySignOutInProgress()).toBe(false) | |
| warn.mockRestore() | |
| const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) | |
| try { | |
| await expect( | |
| store.register('new@example.com', 'password', 'turnstile-bad') | |
| ).rejects.toThrow() | |
| expect(isVoluntarySignOutInProgress()).toBe(false) | |
| } finally { | |
| warn.mockRestore() | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/stores/authStore.test.ts` around lines 536 - 543, Ensure the console.warn
spy created in this registration test is restored on every exit path by wrapping
the awaited registration assertion and related checks in a try/finally block,
with warn.mockRestore() in finally. Keep the existing rejection and sign-out
assertions unchanged.
Source: Path instructions
A populated currentUser does not prove the popup signed anyone in. A restore that fails after a successful sign-in leaves one behind, so the next cancelled popup passed the guard and reported a failure the user never triggered. The shared actions already return a credential on success and nothing when they reported a failure, which is the only honest signal available here. Also uses createTestingPinia in the re-auth suite, per the documented Vitest pattern, and repairs a dropped relative pronoun and a stray line break in the ADR paragraph.
|
Addressed in Gating the restore on the sign-in result. You were right that a populated
ADR wording. Fixed the dropped relative pronoun and a stray line break my in-place edit left behind. Not taking two, with reasons rather than silence:
Local: typecheck, lint, format, knip clean; 13574 passing. |
|
@coderabbitai review The three points from the last review are addressed in |
|
✅ Action performedReview finished.
|
christian-byrne
left a comment
There was a problem hiding this comment.
Current-main lint preflight at this exact head has nine redundant Vitest cleanup findings plus two production throw new Error(...) findings. Because this PR is authored outside the fleet identities, branch policy permits review comments but not a direct push.
| })) | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove this vi.clearAllMocks()? Current main enables automatic Vitest cleanup, so the new comfy/no-redundant-vitest-cleanup rule rejects this per-test reset.
| describe('reauthentication recovery', () => { | ||
| beforeEach(() => { | ||
| setActivePinia(createTestingPinia({ stubActions: false })) | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove the vi.clearAllMocks() calls in each beforeEach in this file (146, 308, 387, and 464)? Current main performs that cleanup centrally and flags these as redundant.
| })) | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you drop this vi.clearAllMocks() now that current main provides automatic mock cleanup? The merged-tree lint rejects it via comfy/no-redundant-vitest-cleanup.
| } | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove this vi.clearAllMocks()? It duplicates current main's global Vitest cleanup and fails comfy/no-redundant-vitest-cleanup.
| } | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove this vi.clearAllMocks()? Current main clears mocks centrally, and the merged-tree lint flags this reset as redundant.
| } | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you drop this vi.clearAllMocks() under the current-main Vitest setup? The automatic cleanup makes this redundant and the new lint rule rejects it.
| }, 60_000) | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove this vi.clearAllMocks()? Current main supplies automatic mock cleanup, so this fails comfy/no-redundant-vitest-cleanup.
| // Call history too, not just implementations: the entry-guard assertion | ||
| // below is `not.toHaveBeenCalled()`, which any earlier case that reaches | ||
| // the token lookup would otherwise decide. | ||
| vi.clearAllMocks() |
There was a problem hiding this comment.
would you remove only this global vi.clearAllMocks() while retaining the targeted fetch reset and wsConstructed reset below? Current main handles mock cleanup centrally, but those two local state resets still carry behavior.
| await Promise.race([ | ||
| workspaceStore.initialize(), | ||
| promiseTimeout(WORKSPACE_SCOPE_TIMEOUT_MS).then(() => { | ||
| throw new Error('Workspace scope restore timed out') |
There was a problem hiding this comment.
would it be cleaner to race workspaceStore.initialize() directly against promiseTimeout(WORKSPACE_SCOPE_TIMEOUT_MS)? promiseTimeout already rejects on expiry, so the extra throw new Error(...) is unnecessary and current main rejects it via comfy/no-new-error-throw.
| !(await useWorkspaceAuthStore().mintAtLogin()) | ||
|
|
||
| if (!(await useAuthStore().getAuthHeader())) { | ||
| throw new Error('Session restored without a usable request credential') |
There was a problem hiding this comment.
could this missing-credential case return an explicit failed restore result that the existing recovery boundary reports, instead of using throw new Error(...) for recoverable control flow? Current main's comfy/no-new-error-throw rule points this path to ADR-0019's explicit failure contract.
|
Sentry confirms the expired-session path is still live on
Full context for agent readersSentry CLOUD-FRONTEND-PROD-1GG recorded No duplicate program or Linear bug was created. The program carrier remains |
Summary
An expired cloud auth token left the app dead-ended: bare canvas, no chrome, no login prompt, and the Jobs poller spamming
401once per poll. This converts a provider-rejected credential into a suspended session with an in-place recovery banner, so the user keeps their unsaved work instead of losing it.Changes
sessionExpirymodule owns suspend/resume state. Suspension is driven solely by Firebase's own sign-out (_logoutIfInvalidated, which fires on exactlyuser-disabled/user-token-expired), never by observing401s — a401is per-endpoint and overloaded, so inferring session death from one would disrupt working users.SessionExpiredBanner(rendered through the sharedNotificationPopup) warns the user to export unsaved changes and offers "Sign in again", which re-authenticates through the same provider they originally used, in a popup, and resumes in place.api.fetchApi, the Jobs poller) short-circuit while suspended, ending the401storm.Review Focus
docs/adr/0011-derived-credential-lifecycle.mdis edited. It stated that recovery is lazy and a backgrounded tab waits for the next read; terminal rejection is now identity-driven, so that is no longer accurate. Worth an architect's eye — this is a factual currency update, not a new architectural decision.createSession()→createSessionOrThrow()in the resolve hook. This gates the resume on the cookie actually minting (previously it resumed unconditionally, sincecreateSessionswallows every error). Note it also means the Firebase ID token mints the cookie on that path; two existing login paths already do the same, but whoever owns/auth/sessionmay want to confirm the scope is identical on aunified_cloud_authdeployment.src/router.ts's guards. Rather than fabricate coverage, flagging it: an E2E test is the natural home.Screenshots (if applicable)
Not included — real-browser verification could not be completed in this environment.