Repository navigation
feat: unified auth for comfy.org and cloud.comfy.org - #17283
Merged
Merged
Conversation
…on this endpoint The website reads cloud.comfy.org/api/billing/balance, which cloud never wraps in customer recovery and which answers an unprovisioned workspace with a zero balance rather than the missing-customer 409. The wiring could not fire.
…lt action ceiling AUTH_FIELD_CLASS and AUTH_LINK_BUTTON_CLASS move in from the cloud app's onboarding constants so both hosts style the same controls from one place. The identity entry no longer bounds email sign-in, sign-up and reset by default: the cloud app runs them unbounded, and a host that wants a ceiling still asks for one.
…om @comfyorg/account Same strings, same DOM; the local constants file goes.
…l-sign-up The website's field class now composes the shared @comfyorg/account class with the PrimeVue tokens this host spells out; the link-button class comes from the package on every page. A TODO marks the Turnstile sitekey's missing live source (E7).
The shared auth class strings go: the TDD leaves layout, colours, type and tokens to each surface. PasswordRules takes its root, list and unmet classes from the host the way SocialAuthButtons does.
…asses from @comfyorg/account" This reverts commit 35f0438.
…account" This reverts commit d11e6d7.
…l-sign-up Presentation stays with the host: the website keeps its own class strings and passes PasswordRules its classes.
…fter the mint promise The session client publishes the credential to subscribers before the ensureFresh promise resolves, so the session watcher moved the state to signedIn first and runMint then bailed out without redirecting: a fresh sign-in showed nothing, and a returning visitor sat on the skeleton. The redirect now belongs to the minting -> signedIn transition itself.
…fter the pop-up The two modes are one page: the links push a history entry and remount the panel instead of reloading, so the shell, the hero and the settled session stay put, as behind cloud's router; Back and Forward follow the path. While a pop-up is open or the session is minting the page shows a spinner with 'Signing you in…' or 'Creating your account…' and holds the other options.
…e-core # Conflicts: # apps/website/scripts/compare-build-to-main.sh # apps/website/scripts/compare-build-to-main.test.ts # apps/website/scripts/generate-workshop-catalog.test.ts # apps/website/scripts/generate-workshop-catalog.ts # apps/website/src/components/home/WorkshopSection.test.ts # apps/website/src/components/home/WorkshopSection.vue # apps/website/src/components/workshop/WorkshopCatalog.test.ts # apps/website/src/components/workshop/WorkshopCatalog.vue # apps/website/src/components/workshop/WorkshopField.test.ts # apps/website/src/components/workshop/WorkshopField.vue # apps/website/src/components/workshop/WorkshopForm.test.ts # apps/website/src/components/workshop/WorkshopPlayground.test.ts # apps/website/src/components/workshop/WorkshopPlayground.vue # apps/website/src/config/__snapshots__/workshop-snippets.test.ts.snap # apps/website/src/config/workshop-detail.test.ts # apps/website/src/config/workshop-featured.test.ts # apps/website/src/config/workshop-featured.ts # apps/website/src/config/workshop-fields.test.ts # apps/website/src/config/workshop-fields.ts # apps/website/src/config/workshop-release.test.ts # apps/website/src/config/workshop-snippets.test.ts # apps/website/src/config/workshop-snippets.ts # apps/website/src/config/workshop.test.ts # apps/website/src/config/workshop.ts # apps/website/src/content/workshop-models.schema.test.ts # apps/website/src/content/workshop-models.schema.ts # apps/website/src/i18n/translations.ts # apps/website/src/integrations/workshop-release-gate.ts # apps/website/src/pages/index.astro # apps/website/src/pages/workshop/index.astro # apps/website/src/pages/workshop/models/[slug].astro
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 13, 2026
## Summary Closes four correctness gaps in the account package's session client, all raised in review of the merged unified-auth PR. A synchronous token read could hand back an already-expired bearer, the credential cache trusted empty tokens and immortal expiries off untrusted boundaries, an explicit remint could commit after the user had signed out, and a reactive caller could publish the same authenticated snapshot a second time. Fixes FE-2173 Fixes FE-2174 Fixes FE-2175 ## Changes - `getToken()` now checks freshness at read time with a zero margin, so a token past its expiry is withheld from synchronous consumers instead of surfacing when timer refresh is throttled. - `CachedCredentialSchema` now requires a non-empty token and a finite expiry, so a stored empty token can no longer suppress a mint and a broadcast credential with an infinite expiry can no longer replace a good one. - An explicit-user `remint()` no longer commits once the identity port has settled signed out. The popup bypass is now limited to the window before the port's first event; a settled null identity blocks the commit. - Each mint now has one commit owner. A caller that joins a mint the scheduler already committed returns that committed result instead of running the commit and publication path again. - `attachIdentity` carries a `@deprecated` note marking it as the transitional Pinia-adapter seam, tracking removal against package-owned identity (FE-2171). ## Review Focus - `session.ts` `refreshWith`: the join short-circuit is gated on `joined` so a cache-hit read still re-persists the live credential (the `stale storage` suite depends on that); only a true joiner of an in-flight mint defers to the owner's commit. - `session.ts` the settled-signed-out guard: confirm the popup path (an explicit mint before the port ever fires) still commits, while a mint after a delivered null does not. ## QA - [x] Unit: 314 passing across the 19 account suites, including 5 new red-green regression tests (one per finding, plus the empty-token and non-finite-expiry boundary cases). - [x] Each new test was proven red against current main (the expired token was served, the empty/infinite credential was trusted, the stale remint committed, the joiner published twice) then green with the fix. - [x] Gates: typecheck, eslint, oxfmt, knip, and comment hygiene all pass. - Not covered: no browser or manual QA; this is a pure-logic change in the account package with no user-facing surface of its own. Resolves review comments on Comfy-Org#17283 from @DrJKL — [r3984130751](Comfy-Org#17283 (comment)), [r3984130755](Comfy-Org#17283 (comment)), [r3984130761](Comfy-Org#17283 (comment)), [r3984130766](Comfy-Org#17283 (comment)) — and from @christian-byrne — [r3983918513](Comfy-Org#17283 (comment)). Linear: [FE-2173](https://linear.app/comfyorg/issue/FE-2173/bug-reject-expired-and-malformed-cached-account-credentials), [FE-2174](https://linear.app/comfyorg/issue/FE-2174/bug-reject-stale-user-remint-after-settled-sign-out), [FE-2175](https://linear.app/comfyorg/issue/FE-2175/bug-give-each-account-session-mint-one-commit-owner)
jaeone94
pushed a commit
to jaeone94/ComfyUI_frontend
that referenced
this pull request
Sep 14, 2026
…E-2212) (Comfy-Org#17436) Phase 1 of the billing half of `@comfyorg/account` ([FE-2210](https://linear.app/comfyorg/issue/FE-2210/track-billing-half-of-comfyorgaccount-session-sdk-merged-billing-not) / [FE-2212](https://linear.app/comfyorg/issue/FE-2212/phase-1-seat-billing-ports-and-transport-on-the-merged-session-client)). The session half merged in Comfy-Org#17283 with billing explicitly out of scope; this is the host boundary the credits reads, the capabilities read, and the payment commands all sit on. ## Where this sits in the plan Plan: [Billing SDK implementation plan (V2)](https://app.notion.com/p/3d86d73d36508152b92cdbdfdfe83ac8), a subpage of [TDD: Account Layer Refactor](https://app.notion.com/p/3cf6d73d365081beb187cb5b82d916d0). Track: [FE-2210](https://linear.app/comfyorg/issue/FE-2210). | Phase | Issue | Deliverable | State | | --- | --- | --- | --- | | 0 | [FE-2211](https://linear.app/comfyorg/issue/FE-2211) | Salvage the PoC billing subtree before the 2026-09-30 teardown, reconcile the TDD | Not started | | 1 | [FE-2212](https://linear.app/comfyorg/issue/FE-2212) | Billing ports and the transport seated on the merged session client | **this PR ([Comfy-Org#17436](Comfy-Org#17436 | | 2 | [FE-2213](https://linear.app/comfyorg/issue/FE-2213) | Read path: credits and the server-authoritative capabilities read | In review — [Comfy-Org#17442](Comfy-Org#17442), stacked on this | | 3 | [FE-2214](https://linear.app/comfyorg/issue/FE-2214) | Write path: commands, poller, and the eight-state payment machine | Not started | | 4 | [FE-2215](https://linear.app/comfyorg/issue/FE-2215) | Separate view package for composables and unstyled components | Not started | | 5 | [FE-2216](https://linear.app/comfyorg/issue/FE-2216) | First consumer: ComfyUI_frontend behind a flag, absorbing ~4.4k lines | Not started | | 6 | [FE-2217](https://linear.app/comfyorg/issue/FE-2217) | Evidence: contract tests, live e2e, and a stated coverage boundary | Not started | | 7 | [FE-2218](https://linear.app/comfyorg/issue/FE-2218) | A second consumer on its own origin: identity and CORS, not distribution | Not started | Phases 1 through 3 merge with no consumer and no flag, so they carry no user-visible risk on their own. Risk concentrates in Phase 5, where the flag flips real payment flows onto the SDK. ## Summary - `packages/account/src/core/billing/billingContracts.ts`: the request/response contracts and the coded failure taxonomy. Billing reports failures as results, never as thrown errors carrying server text, so no caller can leak raw payment-provider copy into a UI. - `packages/account/src/core/billing/transport.ts`: `createSessionBillingTransport`, which mints through the merged `SessionClient` (`ensureFresh` / `remint`) and returns an HTTP answer of any status as `ok` — only a request that produced no response at all (no session, network, abort, timeout) is an `error`, so the typed operations above it own status mapping in one place. - New `./billing` export. No consumer yet: nothing in the app imports this. Behavior is taken from the cloud app's billing client (`attachUnifiedRemintInterceptor`) rather than invented: one re-mint and one retry on a 401, a persistent 401 surfaced unchanged, and response headers exposed so the capability revision a mutation reports (`X-Capability-Revision`) stays readable by the capabilities cache in Phase 2. ## Review focus: two deliberate departures from both the PoC and the interceptor 1. **The 401 retry is gated on an idempotency key, not a replayable body.** The interceptor's gate is replayability; that is the wrong gate for billing, because a write the backend does not deduplicate must never be replayed by the client even when its body replays fine. Reads retry; writes retry only with a key. 2. **Workspace scope comes from the minted credential, not a header.** The TDD's 2026-09-10 update describes `X-Comfy-Workspace-ID`, but neither `cloud` nor this repo implements that header today, so sending it would be unverified. Scope is the workspace the JWT was minted for, and a response that arrives after the host changed workspace or signed out is reported `SUPERSEDED` rather than attributed to the wrong account. FE-2211 tracks reconciling the TDD. Also worth a look: the PoC (Comfy-Org#16639) hand-wrote its billing request and response types, but `@comfyorg/ingest-types` already generates them (`zCreateTopupRequest`, `zBillingOpStatusResponse` with its `decline_reason` enum, `zBillingCapabilitiesResponse`, `zBillingBalanceResponse` in micros). Phase 2 decodes the generated contracts instead of porting the PoC's copies, the way `exchange.ts` uses `zExchangeTokenResponse`. The one gap: the capabilities `denied_reasons` field now on the cloud side is not in the generated output yet and needs a regen. ## Testing 13 new tests, `packages/account` suite 322/322, typecheck and lint clean. Each guard has a deletion proof — removing it fails a named test: the no-session short circuit, the session-failure code mapping, the single re-mint, the idempotency gate on writes, the no-retry-loop on a persistent 401, and both `SUPERSEDED` arms (workspace changed, signed out). Manual: none, and none is meaningful — nothing imports this yet and the transport has no UI surface. Made with [Cursor](https://cursor.com) --------- Co-authored-by: Amp <amp@ampcode.com>
This was referenced Sep 14, 2026
pull Bot
pushed a commit
to Mu-L/ComfyUI_frontend
that referenced
this pull request
Sep 14, 2026
…g variants exclusive (Comfy-Org#17561) ## Summary Two fixes to the package's Firebase identity entry, both from reviews on Comfy-Org#17283. The state-changing calls no longer impose an artificial timeout, and the two config shapes can no longer be represented together. Fixes FE-2172 ## Changes - Removed the action-timeout wrapper (`boundedRunner`, `ActionCeiling`, and the `actionTimeoutMs` config field) from `packages/account/src/firebase/index.ts`. The state-changing calls (email sign-in, password reset) now await their SDK op and settle (resolve or reject) with it. The caller is never released early. - `apps/website/src/config/workshop-firebase.ts` stops passing `actionTimeoutMs`; the package no longer accepts it. - `FirebaseIdentityAppConfig` and `FirebaseIdentityAuthConfig` keep the `never`-typed opposite keys, so a value carrying both `auth` and `options` no longer compiles, and `authResolver` discriminates on the `auth` value. This is the r869 config-exclusivity fix, unchanged. ## Review Focus On dante01yoon's CHANGES_REQUESTED about the action timeout: - The old wrapper released the caller (rejecting at the deadline) while the non-cancellable Firebase op kept running, so a retry could overlap the still-running op. That does not satisfy FE-2172. - Took the "keep the caller pending until the SDK op settles" path: the package no longer imposes an artificial timeout on the state-changing calls. The caller stays busy until the SDK op settles, which prevents a retry from overlapping the still-running op (FE-2172 acceptance). - The website no longer passes `actionTimeoutMs`. - The r869 config-exclusivity fix (the `never`-typed opposite keys plus `authResolver` discriminating on `auth`) is unchanged. ## Testing - New red-green acceptance test in `index.test.ts`: with the underlying SDK deferred, it advances timers well past the old deadline and asserts the caller is still pending (neither resolved nor rejected), then settles the SDK and asserts the caller settles with it. It also asserts a second sign-in cannot start while the first is pending, and that the returned promise is the SDK promise itself with no wrapper that could settle it early. - Proven red against the previous branch tip (the timeout wrapper configured with the shipped consumer's 15s ceiling): the caller was rejected at the deadline with `Error: Firebase auth action timed out`, failing the "must not be released on any deadline" assertion. Green after removing the timeout. - Removed the superseded timeout tests (the deadline-rejection and late-resolution-suppression tests), since the timeout is gone. - Compile-time exclusivity test kept: a config carrying both `auth` and `options` fails to typecheck via `@ts-expect-error`. - Full `@comfyorg/account` vitest suite: 318 passed. Website `workshop-firebase.test.ts`: 12 passed. `pnpm typecheck` (account), eslint (changed files), oxfmt, and knip all clean. Resolves review comments on Comfy-Org#17283 from @DrJKL — [r3984130746](Comfy-Org#17283 (comment)), [r3984130869](Comfy-Org#17283 (comment)). Linear: [FE-2172](https://linear.app/comfyorg/issue/FE-2172/bug-stop-late-firebase-auth-operations-after-caller-timeout)
pull Bot
pushed a commit
to Mu-L/ComfyUI_frontend
that referenced
this pull request
Sep 14, 2026
…k exclusion (Comfy-Org#17566) ## Summary Declare a license on the `@comfyorg/account` package and record why the OSS-assets license check excludes it, so the excluded first-party packages are documented rather than silently skipped. ## Changes Add `license: MIT` to `packages/account/package.json`, matching the published sibling `@comfyorg/design-system`. Rewrite the NOTE above the license-checker step to explain the exclusion policy. `license-checker-rseidelsohn` reports a `private: true` package as UNLICENSED no matter what its `license` field says, and a package with no license field reads as UNKNOWN, so first-party `@comfyorg` packages are excluded on that consistent basis. Each exclusion is load-bearing until the package is published with `private` unset. ## Review Focus This is license-only. It does not touch `private: true`, workspace deps, or npm publishing. The reviewer asked to add the license metadata and drop the one-off exemption unless a documented consistent policy justified it. The metadata is added, and the exemption is kept and documented, because dropping it while `account` stays `private: true` fails the check: license-checker still reads a private package as UNLICENSED regardless of the declared license. I verified this locally three ways (allowlist, exact-version clarification, and `@*` clarification all still fail), and confirmed the check passes exit 0 with the license added and the exclusion kept. The exclusion drops in the separate publish work (FE-2171) that unsets `private` and ships `account` publicly on the alpha dist-tag, the same path as `@comfyorg/design-system`; that check-passes-honestly step belongs there, not here. No LICENSE file was added, matching the sibling convention: `design-system` ships the `license` field only, with no package-local LICENSE file. Fixes FE-2186 Resolves review comment on Comfy-Org#17283 from @DrJKL — [r3984130889](Comfy-Org#17283 (comment)). Linear: [FE-2186](https://linear.app/comfyorg/issue/FE-2186/chore-add-account-package-license-metadata-and-restore-validation)
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 14, 2026
… result (Comfy-Org#17648) ## Summary The scheduled-refresh outcome callback took an outcome string and an optional failure, which let impossible pairs exist: a permanent failure with no error, or a success carrying one. It now takes a single discriminated result whose failure variants require the failure payload. Fixes FE-2185 ## Changes - `sessionContracts.ts` replaces the `(outcome, failure?)` callback pair with one tagged `ScheduledRefreshReport`. The `permanent_failure` and `expired` variants require `failure: SessionFailure`; `succeeded`, `retry_scheduled`, and `retries_exhausted` carry none. - `SessionRefreshOutcome` stays as the telemetry property type but is now derived from the union, so the discriminants live in one place. - `refreshScheduler.ts` constructs the tagged object at all six report sites; `session.ts` re-exports the type; `workspaceAuthStore.ts` narrows on `report.outcome` and reads `report.failure.code` directly. ## Review Focus - `retries_exhausted` carries no failure on purpose. It commits nothing and the credential stays valid until expiry, so only `permanent_failure` and `expired` carry the committed failure. This matches the existing doc comment. ## QA - [x] Red then green at runtime and at the type level: the new success-report test failed against the old two-argument shape, and the account typecheck failed without the union. Both pass with the fix. - [x] The two `@ts-expect-error` directives in the illegal-pair test are load-bearing. The typecheck passes only because the compiler rejects a `permanent_failure` without a failure and a `succeeded` with one. - [x] Suites pass: account 431, host consumers 119. Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves review comment from @DrJKL on Comfy-Org#17283: [r3984130877](Comfy-Org#17283 (comment)). Linear: [FE-2185](https://linear.app/comfyorg/issue/FE-2185/refactor-make-account-package-contracts-represent-only-valid-states)
karatarassul4-max
pushed a commit
to karatarassul4-max/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…omfy-Org#17446) ## Summary Stop the website sign-in controller from redirecting, provisioning, or minting for an attempt that is no longer live, and roll the Firebase identity back when an attempt is abandoned after it has already signed in. ## Changes The controller now bumps its `signInGeneration` on unmount as well as on a flag flip, so authentication, provisioning, and minting all halt after teardown instead of continuing to publish and redirect a page that has left. Mint completion is guarded on liveness, not just reducer state, so a flag-off or unmount during the mint no longer sends the visitor away. When an attempt is abandoned after Firebase auth has persisted an identity, the controller signs that identity out once so it is not left silently signed in, and that best-effort sign-out swallows its own rejection so an offline failure never surfaces as an unhandled rejection. Each non-interactive step (chunk load, provisioning, mint) runs against a deadline that restores a retryable state and discards a late resolve; the user-driven popup wait stays cancellable rather than being timed out. No breaking changes and no new dependencies. ## Review Focus The rollback fires only after `authenticate` has resolved (tracked by an `authenticated` flag), so a load-phase abandon does not call sign-out and a post-auth abandon calls it exactly once. The deadline bounds the three non-interactive steps but deliberately leaves the popup await unbounded, matching the reviewer's ask to keep the user-driven wait cancellable. `withinOperationDeadline` discards a late resolve but the underlying request keeps running, so a provisioning timeout followed by a user retry can call `provisionWorkshopCustomer` twice; this is harmless only if backend provisioning is idempotent, which a backend owner should confirm. ## Testing No Playwright test is added here. The changed behavior is teardown, flag-flip, and deadline-race timing that the unit suite drives deterministically with fake timers and deferred promises; a real browser cannot reproduce those races reliably. The website end-to-end auth harness lands separately in Comfy-Org#17435. Fixes FE-2179 Resolves review comments on Comfy-Org#17283 from @DrJKL — [r3984130792](Comfy-Org#17283 (comment)), [r3984130796](Comfy-Org#17283 (comment)), [r3984130802](Comfy-Org#17283 (comment)), [r3984130806](Comfy-Org#17283 (comment)). Linear: [FE-2179](https://linear.app/comfyorg/issue/FE-2179/bug-make-website-sign-in-attempts-cancellable-and-rollback-safe)
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
Comfy-Org#17642) ## Summary The account package's tests ran through the root Vitest config, whose setup pulls in Pinia and the litegraph library. That is cloud-app state bleeding into a framework-agnostic package. This gives every workspace package its own Vitest config and CI step so package tests run standalone, which is the prerequisite for extracting and publishing the account package. Fixes FE-2189 ## Changes - Added `packages/account/vitest.config.ts` with two projects. `account-core` covers `core/**`, `web/**`, and the top-level specs (`src/*.{test,spec}.ts`: `provisioning`, `redirect`, `webviewDetection`, `firebaseAuthError`, `turnstile`, `turnstileScript`, `signInSchemas`, `vueBoundary`) under the `node` environment. `account-vue` covers `vue/**` and `firebase/**` under happy-dom with `@vitejs/plugin-vue`. Both load only `vitest.timer.setup.ts`. The two account-core tests that touch the DOM (`turnstileScript`, `billing/transport`) opt back into happy-dom with a per-file `// @vitest-environment` pragma. - Added `packages/design-system/vitest.config.ts` and `packages/shared-frontend-utils/vitest.config.ts` (both `node`) plus a `test` script to each, so those packages run standalone too. `object-info-parser` already had its own config. - Removed `packages/**` from the root `vite.config.mts` `test.include`, so the cloud-app setup no longer runs against any package. - Added four per-package CI steps in `ci-tests-unit.yaml` (account, object-info-parser, shared-frontend-utils, design-system) and allowlisted the two new configs in `eslint.config.ts`. ## Review Focus - Every package now runs via its own CI step, so the root `pnpm test:coverage` collects zero `packages/` files. Dropping the root include without these steps would have removed the object-info-parser, shared-frontend-utils, and design-system suites from CI silently. ## QA - [x] The root config reports "No test files found" for `packages/`, so nothing under packages runs there. - [x] Each package suite runs via its own step, matching the origin/main baseline of 34 files: account 429, object-info-parser 35, shared-frontend-utils 144, design-system 3. - [x] account-core's 377 tests pass under node; the two DOM-dependent tests keep a DOM via the per-file pragma. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves the test-worlds finding from @DrJKL's Comfy-Org#17283 review: [full review](Comfy-Org#17283 (review)). Linear: [FE-2189](https://linear.app/comfyorg/issue/FE-2189/refactor-split-unified-auth-test-worlds-by-owned-contract)
jaeone94
pushed a commit
to jaeone94/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…#17641) ## Summary Four call sites in the Workshop auth flow each hand-rolled the same generation-counter guard for work that outlives an await. This adds one shared primitive for that pattern so the migrations that follow can drop their copies. It is the first of the A3 stack for FE-2192. Fixes FE-2192 ## Changes - Added `createBoundedOperation()` in `packages/account/src/core/boundedOperation.ts`, a framework-free generation guard. `capture()` snapshots the current generation and returns a handle whose `live()` holds until `abandon()` bumps it. It imports nothing, so it stays within the core import guard. - Added `useGenerationGuard()` and `createLifecycleScope()` in `packages/account/src/vue/`, the Vue-bound halves that wire `onScopeDispose` and a reopenable `effectScope`. They live under `vue/`, the only place the boundary guard allows `vue` imports. - Exposed `./boundedOperation` as a package export subpath; the Vue helpers flow through the existing `./vue` entry. ## Review Focus - The semantic the migrations rely on: `capture()` never invalidates a prior handle, only `abandon()` does. Supersession is always an explicit `abandon()` then `capture()`. Worth a look before reviewing A3b through A3e, which adopt it. ## QA - [x] Red then green: with the tests written and the modules absent, all three suites failed at import resolution, then passed once the modules were added. - [x] 12 tests across the three suites cover generation bumps, liveness after abandon, repeated capture and abandon cycles, liveness across an await, and scope disposal both before and during an await. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. The boundary guards (importGuard, vueBoundary) pass with the new files. Resolves the Workshop-lifecycle consolidation finding from @DrJKL's Comfy-Org#17283 review: [r3976008874](Comfy-Org#17283 (comment)). Linear: [FE-2192](https://linear.app/comfyorg/issue/FE-2192/refactor-consolidate-workshop-auth-lifecycle-and-state-ownership)
jaeone94
pushed a commit
to jaeone94/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…session state (Comfy-Org#17645) ## Summary The Workshop session-state module hand-rolled a started latch, a detached effect scope, and a generation counter. It now uses `createLifecycleScope()` and `createBoundedOperation()`, with no change in behavior. Part of the A3 stack for FE-2192. Fixes FE-2192 ## Changes - `apps/website/src/config/workshop-session-state.ts` replaces the `started` flag, the manual `effectScope`, and the `typeof window` guard with `createLifecycleScope()`, and replaces the `generation` counter with `createBoundedOperation()`. - The flag watch now calls `operation.abandon()` then `operation.capture()`; `begin` and the remembered-workspace restore guard on `attempt.live()`; the error path calls `lifecycle.stop()`. ## Review Focus - This PR stacks on the A3a primitive (Comfy-Org#17641) and merges after it. - `holdsForRestore` passes its own `operation.capture()`, which is safe because `capture()` never invalidates the coexisting `begin` attempt. ## QA - [x] The existing session-state suites stay green, going from 21 to 22 after adding one regression test. - [x] Red then green: the new test proves a restore that resolves after the flag turns off no longer republishes the boot session. Neutralizing the three `live()` guards leaves the old suite green, so the new test is what pins the invariant. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves the Workshop-lifecycle consolidation finding from @DrJKL's Comfy-Org#17283 review: [r3976008874](Comfy-Org#17283 (comment)). Linear: [FE-2192](https://linear.app/comfyorg/issue/FE-2192/refactor-consolidate-workshop-auth-lifecycle-and-state-ownership)
MaanilVerma
added a commit
that referenced
this pull request
Sep 15, 2026
…ate subpaths The vue barrel coupled five unrelated public modules. Give each a per-module subpath export and rewire consumers to import directly, matching the package's established one-file-per-subpath convention. The generic lifecycle hooks stay on @comfyorg/account/vue. Addresses DrJKL's #17283 review (5172958399).
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…balance (Comfy-Org#17646) ## Summary The Workshop balance module hand-rolled a generation counter to discard stale refreshes. It now uses `createBoundedOperation()`, with no change in behavior. Part of the A3 stack for FE-2192. Fixes FE-2192 ## Changes - `apps/website/src/config/workshop-balance.ts` replaces `let generation` with `createBoundedOperation()`. `runRefresh` captures a handle and guards its publish on `attempt.live() && live?.uid === uid && live.token === token`; the queued forced refresh captures its own handle; `reset()` calls `operation.abandon()`. ## Review Focus - This PR stacks on the A3a primitive (Comfy-Org#17641) and merges after it. - The mapping is one-for-one because `capture()` mirrors the old snapshot-and-compare and `abandon()` mirrors the old `generation++`. ## QA - [x] The balance suite is green at 13 passing: the migration, plus a queued-forced-refresh reset case added for CodeRabbit. - [x] Sabotage check: forcing the handle live turns the read-after-reset test red, which proves the guard is load-bearing. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Part of FE-2192: adopts the shared bounded-operation primitive in workshop balance. The broader single Workshop-account service that [r3976008874](Comfy-Org#17283 (comment)) describes is not fully landed here. Linear: [FE-2192](https://linear.app/comfyorg/issue/FE-2192/refactor-consolidate-workshop-auth-lifecycle-and-state-ownership)
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…ssword (Comfy-Org#17647) ## Summary The forgot-password component hand-rolled a generation counter to abandon an in-flight reset on flag-off or unmount. It now uses `useGenerationGuard()`, with no change in behavior. Part of the A3 stack for FE-2192. Fixes FE-2192 ## Changes - `apps/website/src/components/auth/AuthForgotPassword.vue` replaces `let resetGeneration` with `useGenerationGuard()`. The enabled watch and the bound timeout call `operation.abandon()`; `beginBoundedSend` captures a handle and returns `() => attempt.live() && enabled.value`. - The `resetGeneration++` line in `onBeforeUnmount` is gone, replaced by the guard's `onScopeDispose(abandon)`. The rest of that handler stays, since it also clears the return, flag, and bound timers. ## Review Focus - This PR stacks on the A3a primitive (Comfy-Org#17641) and merges after it. - Kept `onBeforeUnmount` for the timer cleanup rather than deleting it wholesale, because it does more than bump the counter. ## QA - [x] The forgot-password suites are green at 21 passing: the migration, plus a guard-isolating flag-flicker case and a strengthened bound-timeout case added for CodeRabbit. - [x] Sabotage check: forcing the handle live turns exactly 2 tests red (the late-resolve and late-reject unmount cases), which proves the guard is load-bearing. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves the Workshop-lifecycle consolidation finding from @DrJKL's Comfy-Org#17283 review: [r3976008874](Comfy-Org#17283 (comment)). Linear: [FE-2192](https://linear.app/comfyorg/issue/FE-2192/refactor-consolidate-workshop-auth-lifecycle-and-state-ownership)
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…ate subpaths (Comfy-Org#17649) ## Summary The package's `vue` entry was a barrel re-exporting several modules. Every module now has its own export subpath and `src/vue/index.ts` is deleted, so no barrel remains under `src/vue` (engineering.md rule 6). This completes the Vue-surface half of FE-2190; the public-error-class half landed in Comfy-Org#17565. Fixes FE-2190 ## Changes - `packages/account/package.json` adds per-module subpaths for the three components (`PasswordRules`, `SocialAuthButtons`, `TurnstileWidget`) and the two gates (`regionGate`, `turnstileGate`). - Deleted `packages/account/src/vue/index.ts`. The three lifecycle hooks (`useGenerationGuard`, `createLifecycleScope`, `LifecycleScope`) now ship from `./vue/useGenerationGuard` and `./vue/lifecycleScope`, and their three consumers (workshop-session-state, AuthForgotPassword, the sign-in controller) import from those subpaths. - Ten consumers across the cloud app and the website import from the new subpaths; the component consumers switch from named to default imports. ## Review Focus - This PR stacks on the A3a primitive (Comfy-Org#17641) and merges after it. - `AuthEmailForm.vue` (Comfy-Org#17643) and `useAuthSignInController.ts` (Comfy-Org#17644) are also edited by open PRs, so expect a trivial import-line conflict at merge. - Grouping choice: per-module subpaths rather than one components group and one gates group. This matches the package's existing one-file-per-subpath convention and decouples all five. ## QA - [x] Consumer and package Vue suites pass unchanged: 75 across the cloud app plus package vue, 16 for the website AuthEmailForm, 3 for the boundary guards. - [x] Load-bearing check: deleting one subpath while leaving its import in place fails typecheck with a module-not-found error, then passes when restored. - [x] Gates pass: typecheck, eslint, oxfmt, knip. Resolves the Vue-barrel finding from @DrJKL's Comfy-Org#17283 review: [full review](Comfy-Org#17283 (review)). Linear: [FE-2190](https://linear.app/comfyorg/issue/FE-2190/refactor-narrow-the-account-package-public-surface)
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 15, 2026
…in controller (Comfy-Org#17644) ## Summary The sign-in controller carried its own generation counter for abandoning in-flight sign-in work on flag-off or unmount. It now uses the shared `useGenerationGuard()` primitive, with no change in behavior. Part of the A3 stack for FE-2192. Fixes FE-2192 ## Changes - `apps/website/src/components/auth/useAuthSignInController.ts` replaces `let signInGeneration` and its manual bumps with `useGenerationGuard()`. The enabled watch calls `signIn.abandon`, each attempt calls `signIn.capture()`, and liveness becomes `attempt.live() && enabled.value`. - The manual `onUnmounted` bump is gone; the guard's built-in `onScopeDispose(abandon)` covers unmount. ## Review Focus - This PR stacks on both Comfy-Org#17446 (the sign-in controller lifecycle rewrite) and the A3a primitive (Comfy-Org#17641). It merges after both. Until Comfy-Org#17446 lands, its controller changes appear in this diff. - The swap is one-for-one: `capture()` reads the generation exactly as the old `const attempt = signInGeneration` did, and only `abandon()` bumps it. ## QA - [x] The Comfy-Org#17446 controller suite stays green through the swap: 71 passing, no assertion changed. - [x] Sabotage check: forcing the liveness handle to true turns exactly 4 tests red (the flag-flicker case and all three unmount cases), which proves the guard is load-bearing. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves the sign-in controller concentration finding from @DrJKL's Comfy-Org#17283 review: [r3976008876](Comfy-Org#17283 (comment)). Linear: [FE-2192](https://linear.app/comfyorg/issue/FE-2192/refactor-consolidate-workshop-auth-lifecycle-and-state-ownership)
This was referenced Sep 16, 2026
Merged
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 17, 2026
…rg#17643) ## Summary Auth error copy lived in three places at once: package constant tables, cloud locale JSON, and website translations, all kept in sync by hand. The package now ships classification and resolution rules only, and each host resolves the strings from its own i18n. Fixes FE-2188 ## Changes - `authErrorMessage` in the account package now takes host-provided copy and owns no localized strings. The zh-CN and ja tables in `firebaseAuthError.ts` and `turnstile.ts` are gone, along with `SESSION_ERROR_MESSAGES`. - `SESSION_ERROR_MESSAGES` became `SESSION_ERROR_CODES`, a keys-only record that stays exhaustive by type, so a new session error code is a compile error until a host adds copy for it. - Cloud resolves auth copy from `src/locales/en/main.json` and the other 14 locales; the website resolves from `apps/website/src/i18n/translations.ts`. - Deleted the two value-pinning tests, `src/locales/authCopy.package.test.ts` and `workspaceAuthStore.copy.test.ts`, which existed only to keep the duplicated copies aligned. - Reworded the `auth/email-already-in-use` copy across all 15 cloud locales and the three website entries to drop the account-existence wording (the old "if you already have one" clause was an enumeration oracle on the sign-up path, CWE-204). The new copy keeps neutral recovery guidance. ## Review Focus - This supersedes Comfy-Org#17562. That PR reworded the sign-up and provider copy in the package tables; the same neutral, non-enumerating strings now live in the host sources instead. Close Comfy-Org#17562 as superseded once this lands. - Confirm no host renders a bare i18n key after the deletion. The website's `t(key, locale)` throws on a wholly missing key, and the auth suites exercise every resolution path. ## QA - [x] Red then green: the website auth-copy test failed against the old package-owned copy because it received the enumerating string, then passed once host resolution was wired. - [x] New cloud enumeration guard test in `src/composables/auth/authErrorEnumeration.test.ts`: it fails if any enumeration-sensitive code resolves copy that confirms an account exists. Proven red by reverting one cloud string to the old wording, then green. - [x] Suites pass: account 413, cloud auth 163, website auth components and i18n 207, plus the 4 new enumeration-guard cases. `pnpm locale:check` reports all locales up to date. - [x] Gates pass: typecheck, eslint, oxfmt, knip, comment hygiene. Resolves the localization-ownership finding from @DrJKL's Comfy-Org#17283 reviews: [architecture review](Comfy-Org#17283 (review)), [full review](Comfy-Org#17283 (review)). Linear: [FE-2188](https://linear.app/comfyorg/issue/FE-2188/refactor-give-auth-localization-one-host-owned-source-of-truth)
pull Bot
pushed a commit
to Mu-L/ComfyUI_frontend
that referenced
this pull request
Sep 17, 2026
… boundary (Comfy-Org#17830) ## Summary The session client's state now changes in exactly one place, and the closure no longer owns the credential cache or single-flight minting. A pure `transition(state, event)` in the new `core/sessionState.ts` owns every commit, `createSessionClient` only runs the ordered effects it hands back, and the storage codec and in-flight dedup live in `credentialCache.ts` and `mintCoordinator.ts`. This is the decomposition DrJKL asked for before the client becomes the shared auth foundation, and it changes no behavior except the two tightenings called out under Review Focus. Fixes FE-2191 ## Changes - `packages/account-core/src/core/sessionState.ts` is new. It holds one `SessionState` record, a `SessionEvent` union (identity changed or detached, invalidated, mint started, mint committed or rejected by caller or scheduler, credential adopted or expired), and `transition`, which returns the next state plus an ordered list of effects (`persist`, `armScheduler`, `clearStorage`, `stopScheduler`, `abandonInFlight`, `publish`). Effects carry their own payload, so the runner never reads state after the fact. - The same module has `arbitrateMint`, which is `refreshWith`'s old guard ladder (invalidation epoch, mint sequence, popup path, settled-null block, joiner reuse) lifted out as a pure verdict, and `scheduledMintHolds`, the old inline `guardsHold`. The guards inside `arbitrateMint` are named by the verdict they return (`userMismatchBlocksCommit`, `popupSettled`, `lostRace`), not by the situation they detect. - `createSessionClient` in `session.ts` keeps one `let state` and one `commit(event)`. The eleven places that used to set `credential`, `credentialTarget`, `failure`, `committedMint` and the epochs by hand are gone; the scheduler's `RefreshHost` callbacks call `commit` with the matching event. `session.ts` goes from 742 lines to 541, and the closure body from 512 to 330. - `credentialCache.ts` owns the cached-credential schema, the pure encode and decode (uid-filtered for the cache, unfiltered for a cross-tab message), `createCredentialCache`, which wraps the host's `CredentialStorage` with the same swallowed read, write and clear failures as before, and the freshness policy: `isCredentialFresh` and `selectFreshCredential`, the memory-then-storage, exact-target, first-fresh-wins rule that `ensureCore` used to inline. `CredentialStorage` and `isCredentialFresh` are re-exported from `session.ts`, so nothing a host imports moved. - `mintCoordinator.ts` owns only the in-flight mint: `canJoin` and the `.finally` that clears it while it is still the same promise. - `RefreshHost.commitRefreshed` now takes the `mintId` the scheduler minted with, so the recorded `committedMint` names an explicit id instead of reading the sequence at commit time. - `identity.ts` imports `AccountUser` from `sessionContracts` instead of `session`, which removes a type cycle. - `core/__fixtures__/sessionFakes.ts` holds the storage, user, credential, identity and exchange fakes the session suites share. The three new suites and the two existing ones import from it instead of carrying their own copies; no assertion changed. - `sessionState.test.ts` is a table over state × event, including the pairs that must be no-ops (a preserved transient failure, expiry of a credential that is no longer live even when value-equal) and the reference-identity cases that `arbitrateMint` and `credential-expired` depend on. `credentialCache.test.ts` and `mintCoordinator.test.ts` cover the codec rejects, the join-versus-start matrix and the candidate order. ## Review Focus - The claim that nothing changed rests on `session.test.ts` and `session.scheduler.test.ts` passing with their assertions untouched; the only edits to those two files swap their local helpers for the shared fixture imports. If you want to spot-check one site, the asymmetries are the ones worth a look: a caller-side permanent failure stops the scheduler and clears the target, a scheduler-side one only clears storage (`sessionState.ts`, the `mint-rejected` case). Those match the old code on purpose. - `commitExpired` in `session.ts` commits only when the expiring credential is still the live one, by reference, and returns the failure the transition produced. The value-equal clone row in the table pins that a stale copy is a no-op. - `mint-started` is a separate event solely so `mintSequence` lives in the one state record. It has no effects. - Tightening one: the popup mint now requires exactly one identity event since it started. `popupSettled` in `sessionState.ts` checks `identityEpoch === startEpoch + 1`; the old code accepted any number of events as long as the uid matched. The `sessionState.test.ts` row "a popup mint that crossed two identity events is superseded even when the uid matches again" pins it. - Tightening two: the stored-credential read is lazy. `selectFreshCredential` takes thunks (`credentialCache.ts`), so storage is not touched when the in-memory credential is fresh; the old inline code read storage every time. `session.test.ts` "serves a fresh in-memory credential without touching storage" pins it. - `selectFreshCredential` checks the uid on both candidates where the old inline code checked only the in-memory one. The stored candidate is already uid-filtered by `decodeCached`, so no outcome changes; flagging it because it reads like a tightening. ## QA - [x] Unit: `pnpm --filter @comfyorg/account-core test` 39 files, 716 tests - [x] Test diff against the base (`git diff --numstat origin/maanil/fe-2188-localization-sso...HEAD -- '**/*.test.ts'`): `credentialCache.test.ts` +210/-0, `mintCoordinator.test.ts` +157/-0, `sessionState.test.ts` +541/-0 (new files), `session.test.ts` +31/-70 and `session.scheduler.test.ts` +43/-91 (helper definitions replaced by fixture imports, plus one new test in `session.test.ts`); the shared fixture `__fixtures__/sessionFakes.ts` is +110/-0. No assertion was removed from an existing test. - [x] Consumers: `src/platform/workspace/stores` 326 tests, website `src/config` 2459 tests, all green - [x] Coverage: the two new modules are fully covered; `session.ts` keeps the same three pre-existing uncovered items (the fetch fallback chain, the expiry no-op return, the no-user early return) and nothing new - [x] fallow cyclomatic on `session.ts`: `refreshWith` 38 → 10, `ensureCore` 12 → 7 - [x] `pnpm typecheck` (root and package), `pnpm lint`, `oxfmt --check`, `pnpm knip` all clean - Not covered: no e2e run. This change is package-internal and flag-independent; the cloud store's delegation call sites are unchanged. This PR stacks on Comfy-Org#17643 and merges after it. Resolves review comment from @DrJKL on Comfy-Org#17283: [r3976008869](Comfy-Org#17283 (comment)). Linear: [FE-2191](https://linear.app/comfyorg/issue/FE-2191/refactor-centralize-account-session-commit-ownership) <details> <summary>Stack (merge bottom-up; each PR targets the one below it)</summary> Base: Comfy-Org#17643 hosts own the auth copy. The package is `@comfyorg/account-core` since the rename on main (Comfy-Org#17851); the Vue pieces live in `@comfyorg/account-ui` (Comfy-Org#17854). Publish preparation (files allowlist, dependency cut, `dist` build) now ships from the billing track in Comfy-Org#17882; the earlier Comfy-Org#17838, Comfy-Org#17839 and Comfy-Org#17840 are drafts kept for reference. 1. Comfy-Org#17830 the session client's state changes in one pure transition; cache and in-flight mint become their own modules ← this PR 2. Comfy-Org#17831 identity is passed to `createSessionClient` at construction; `dispose()` tears it down 3. Comfy-Org#17832 the cloud store binds identity at construction; the flag gates minting only 4. Comfy-Org#17833 the website binds identity through a lazily activated port so Firebase stays a lazy chunk 5. Comfy-Org#17834 the package initializes the cloud app's Firebase; vuefire no longer does 6. Comfy-Org#17835 the transitional `attachIdentity` seam is deleted; ADR-0033 records the outcome 7. Comfy-Org#17836 the legacy workspace-token rail moves into its own removable module and its hot paths are split into named steps 8. Comfy-Org#17837 the dead `vuefire` dependency and its inert test mocks go </details>
pull Bot
pushed a commit
to Penguinjanator/ComfyUI_frontend
that referenced
this pull request
Sep 18, 2026
…rkspace auth store (Comfy-Org#17832) ## Summary The cloud workspace auth store now hands its identity to the session client at construction and stops attaching and detaching it by hand. The `unified_cloud_auth` flag gates minting only; identity is bound for the store's lifetime. This deletes the host side of the transitional adapter that ADR-0028 marked for removal, and the ADR is amended in the same change. Part of FE-2196 ## Changes - `workspaceAuthStore.ts` constructs the client as `createSessionClient({ ..., autoMint: false }, useAuthStore().identity)`. `ensureUnifiedIdentityAttached`, `detachUnifiedIdentity` and the attach call inside `unifiedUser()` are gone. - The flag watch keeps its two jobs but not the attach half: on turns the rail on by minting the current target, off calls `clearUnifiedContext()`, whose `invalidate()` drops the credential, stops the scheduler and releases the cross-tab lease. The port stays subscribed but inert, because the store drives every mint itself. - The three flag-gated helpers (`mintAtLogin`, `remintUnifiedOnce`, `switchUnifiedWorkspace`) re-check `unified_cloud_auth` after awaiting `unifiedUser()`, not only before. A mint parked on the identity when a rollback flips the flag off now fails closed instead of committing a token, since `invalidate()` alone preserves the user. - `destroy()` calls `dispose()` on the client in place of the stored detach handle. Ordering is unchanged. - `docs/adr/AUTH-IDENTITY-0028` rules 1 and 4 are amended: identity is passed at construction, and with the flag off the port is subscribed but no token, network call or timer exists. - `src/utils/__tests__/stubAccountIdentityPort.ts` holds the two test seams for this binding: `stubAccountIdentityPort()` keeps a suite's construction-time subscription off Firebase (six suites use it), and `replayIdentityPort()` fakes the auth-state registration and replays the user on a microtask by default, the way the SDK does, or synchronously on request. Both `authStore.test.ts` blocks and `useWorkspaceAuth.test.ts` drive their identity events through it, so the first delivery is modelled one way. - `useWorkspaceAuth.test.ts` rewrites the four lifecycle cases to the new contract. - New tests: - `authStore.test.ts`, store construction order: building the workspace store first subscribes its port and mints once Firebase delivers on its microtask. - `authStore.test.ts`, unified identity source: now pins that both the store listener and the port registered at construction. - `useWorkspaceAuth.test.ts`: a port that delivers synchronously inside `onUserChanged` still leaves the store subscribed and minting for that user. - `useWorkspaceAuth.test.ts`, destroy: a mint after `destroy()` waits the settle ceiling and resolves false. ## Review Focus - Fail-closed on rollback: the flag-gated helpers re-check `unified_cloud_auth` after `await unifiedUser()`, so a mint that parked on the identity before the flip commits nothing. Pinned by `useWorkspaceAuth.test.ts` "refuses a mint that parked on the identity before the flag went off" (red without the re-check). - The flag-off contract changed on purpose: the port used to be detached, now it stays subscribed and the client is invalidated. The test at "turning the flag OFF keeps the identity subscribed..." pins the gate in `mintAtLogin`; removing that guard fails it. - Construction-order coupling: `workspaceAuthStore` reads `useAuthStore().identity` during its own setup while `authStore`'s listener calls back into `workspaceAuthStore`. This holds because Firebase delivers a new observer's first callback on a microtask, after persistence resolves, so each store finishes setup before the other can re-enter it. A synchronous identity source in that seat would re-enter a half-built store and leave the client unsubscribed, with every mint waiting its ceiling. The two-store failure is reproduced by the `store construction order` test in `authStore.test.ts` (which drives the real pair with `replayIdentityPort(..., 'sync')`); the `useWorkspaceAuth.test.ts` sync case pins only the session-client half, since its `onAuthStateChanged` is a no-op so `authStore`'s listener never re-enters. The comment at the call site and ADR-0028 rule 3 name the dependency. Comfy-Org#17834 removes the coupling by importing the identity module directly instead of reading it off `authStore`. - Under flag off with a signed-in user the client's snapshot reads `minting` instead of `pending`. The only phase reader outside the store is the billing transport, which runs only under a flag that requires unified auth. - `dispose()` is not terminal: a disposed client would still honor an explicit-user mint. Nothing calls the store after `destroy()` today, so this stays as it was; noted for the legacy-rail retirement. ## QA - [x] Unit: `pnpm exec vitest run src/platform/workspace src/stores src/platform/auth` 132 files, 2869 passed, 1 expected fail, 1 skipped; the one failure is `checkoutJourney.test.ts`, a known local-only failure unrelated to this change - [x] Mutation check: removing the `unifiedCloudAuthEnabled` guard in `mintAtLogin` fails the flag-off lifecycle test - [x] Package untouched: `pnpm --filter @comfyorg/account-core test` 42 files, 661 tests, no diff under `packages/` (the package is `@comfyorg/account-core`) - [x] Website consumers unaffected: `apps/website` `src/config` 2459 tests - [x] `pnpm typecheck`, `pnpm lint` (0 errors), `oxfmt --check`, `pnpm knip`, `fallow audit --changed-since` the parent branch: clean - [ ] Manual, cloud build with `unified_cloud_auth` on: sign in, switch workspace, wait past the refresh buffer, sign out; confirm the header keeps a token through the refresh and clears on sign-out - [ ] Manual, cloud build with the flag off: sign in and confirm no `/auth/token` request is issued - Not covered: no e2e in this PR; the auth e2e set is the gate for the Firebase-init PR that follows. This PR stacks on Comfy-Org#17831 and merges after it. Resolves review comment from @DrJKL on Comfy-Org#17283: [r3976008872](Comfy-Org#17283 (comment)). Linear: [FE-2196](https://linear.app/comfyorg/issue/FE-2196/remove-the-pinia-identity-adapter-package-owned-identity) <details> <summary>Stack (merge bottom-up; each PR targets the one below it)</summary> Base: Comfy-Org#17643 hosts own the auth copy. The package is `@comfyorg/account-core` since the rename on main (Comfy-Org#17851); the Vue pieces live in `@comfyorg/account-ui` (Comfy-Org#17854). Publish preparation (files allowlist, dependency cut, `dist` build) now ships from the billing track in Comfy-Org#17882; the earlier Comfy-Org#17838, Comfy-Org#17839 and Comfy-Org#17840 are drafts kept for reference. 1. Comfy-Org#17830 the session client's state changes in one pure transition; cache and in-flight mint become their own modules 2. Comfy-Org#17831 identity is passed to `createSessionClient` at construction; `dispose()` tears it down 3. Comfy-Org#17832 the cloud store binds identity at construction; the flag gates minting only ← this PR 4. Comfy-Org#17833 the website binds identity through a lazily activated port so Firebase stays a lazy chunk 5. Comfy-Org#17834 the package initializes the cloud app's Firebase; vuefire no longer does 6. Comfy-Org#17835 the transitional `attachIdentity` seam is deleted; ADR-0033 records the outcome 7. Comfy-Org#17836 the legacy workspace-token rail moves into its own removable module and its hot paths are split into named steps 8. Comfy-Org#17837 the dead `vuefire` dependency and its inert test mocks go </details>
AlexRAV
pushed a commit
to AlexRAV/ComfyUI_frontend
that referenced
this pull request
Sep 18, 2026
…dule (Comfy-Org#17836) ## Summary The legacy workspace-token rail moves out of `workspaceAuthStore` into its own module. The store keeps the flag dispatcher and host projection; `legacyWorkspaceTokenRail.ts` holds the pre-unified mint, refresh timer, recovery and token getters as one removable unit. Nothing is deleted: `unified_cloud_auth` is a PostHog percentage rollout that defaults off, so this rail still serves production users. When the cut-over completes, retiring it becomes a file deletion plus a handful of store lines. The PR has two review surfaces. The first is a verbatim move. The second splits the rail's two long functions into named steps and, in this revision, restores the original guard order and exit points that the split had drifted from. Part of FE-951 (the cut-over ticket; this PR isolates, it does not delete) ## Commits 1. `c130ee50` refactor: move the legacy workspace-token rail into its own module. The code moves verbatim; review with `--color-moved`. 2. `ea210e34` refactor: construct the legacy rail before the computed that reads it. 3. `bdb1c152` test: pin the legacy rail seam (five cases in `useWorkspaceAuth.test.ts`). 4. `c0944e6b` test: cover the rail at the factory seam (`legacyWorkspaceTokenRail.test.ts`). 5. `35b68dae` test: cover the rail's mint, refresh and recovery branches directly (`legacyWorkspaceTokenRail.lifecycle.test.ts`). 6. `e0bbd162` refactor: split the rail's mint and refresh flows into named steps. 7. `def7dfa4` test: pin the post-mint owner guard and the foreign-token refresh exit. 8. `dff474cd` test: drive the seam through the shared feature flag mock. 9. `f0136ca7` refactor: keep the rail's guard order and return after an exhausted refresh. 10. `c4f7f3c5` test: run the rail suites on a stepped fake clock. ## Review surface 1: the move (`c130ee50`, `ea210e34`) - `legacyWorkspaceTokenRail.ts` is new: `createLegacyWorkspaceTokenRail(deps)` returns the legacy surface the store used to define inline (`workspaceToken`, `initializeFromSession`, the legacy `switchWorkspace` branch, `refreshToken`, `ensureWorkspaceToken`, `ensureWorkspaceAuthHeader`, the token getters, `retireLegacyToken`, `stopRefreshTimer`, `clearLegacyContext`). - The dependency interface is explicit: the shared refs (`currentWorkspace`, `isLoading`, `error`), the uid helpers, lazy `getIdToken`/`hasSignedInUser`/`activeWorkspaceId` closures, `endWorkspaceSession`, `persistWorkspaceIdentity`, `clearSessionStorage`, `surfacePermanentAuthError`, and the store's `switchWorkspace`. That last one matters: the rail's timer-driven refresh still routes through the flag dispatcher, so with the flag on it reaches the unified switch exactly as before. - `workspaceAuthStore.ts` drops from 1179 to 590 lines. Its returned names and module exports are unchanged; `switchWorkspace` is now only the flag dispatcher; `clearWorkspaceContext` calls `clearLegacyContext()` and then its own lines in the original order. - `WorkspaceAuthError` lives in `workspaceAuthError.ts` (both rails throw it) and is re-exported from the store. `MAX_SCHEDULED_REFRESH_RETRIES` moves to `workspaceConstants.ts` since both rails read it. - Only five lines inside the moved block differ from the original: three store reads become injected closures, the flag branch leaves the legacy switch, and one docblock clause that claimed the unified path reuses `requestToken` is gone. - The second commit only moves the rail construction above the `isAuthenticated` computed that reads it. ## Review surface 2: the named-steps split (`e0bbd162`, then `f0136ca7`) Why: the repo's complexity gate flagged the moved file. `performSwitchWorkspace` and `refreshToken` each carried the original store's two largest bodies, and `ensureWorkspaceToken` was close behind. The split extracts the steps those functions were already doing in sequence, with the names the log lines and comments were already using: `requestToken` (network plus parse, no store writes), `readStoredSession` and `isUnexpiredSession` under `initializeFromSession`, `canRecheckAfterInFlightSwitch`, `canStartRecoveryMint` and `recoverWorkspaceToken` under `ensureWorkspaceToken`, and `endRefreshOnPermanentError`, `waitForRefreshBackoff`, `preserveTokenAfterExhaustedRefresh` and `settleExhaustedRefresh` under `refreshToken`. The rail's highest per-function cyclomatic goes from 20 to 9. Behavior is meant to be preserved, and the two suites added in this PR were written against the original semantics. Review found three places where the first split drifted; `f0136ca7` puts them back: - Guard order on restore. `readStoredSession` parsed and schema-validated the stored workspace before checking who owned the session; the original short-circuited on the owner check first. The owner check is back in front of the parse, so a foreign user's blob is never parsed. Same outcomes in every row of the restore table. - Exit after an exhausted refresh. `settleExhaustedRefresh` was the last statement of the catch, so control fell back into the loop and termination depended on the transient guard. The original returned after the preserve branch; the `return` is back. - The recovery target. A one-line helper sat under the docblock that belongs to `ensureWorkspaceToken`; the expression is inlined, the helper is gone, and the docblock is back on the function. To keep the complexity gate green after the inline, the cooldown and active-workspace gate now opens `recoverWorkspaceToken` instead of sitting one line above its call, which is the same check in the same order. - Two smaller readability points from the same review: `REFRESH_MAX_RETRIES` is renamed `REFRESH_ATTEMPT_MAX_RETRIES` (it bounds in-loop attempts; `MAX_SCHEDULED_REFRESH_RETRIES` is the scheduled budget), and the hand-rolled promise-over-`setTimeout` in `waitForRefreshBackoff` is `delay` from es-toolkit. ## Review Focus - Read the move commit with `--color-moved`; every test file is untouched in it. - Read `e0bbd162` and `f0136ca7` together against the parent's `workspaceAuthStore.ts`, checking that every early return and guard lands in the same order. - The seam cases in `useWorkspaceAuth.test.ts` drive the rail through the real store: the legacy refresh deadline and an expired-token recovery route through the flag dispatcher when unified auth is on (a rail calling its own legacy switch fails both), the fail-closed return in `ensureWorkspaceToken` (returning the other workspace's token fails it), and the injected identity and active-workspace closures resolving at call time. The other store suites stub the rail's actions. - This exceeds the usual 300-line guideline on purpose. It is one verbatim move; a split would have added seven throwaway members to keep each half green and doubled the review. - The true boundary today: `WorkspaceTokenResponse` is re-exported from the store because four Playwright files import it from there (`browser_tests/tests/authAccountSwitch.spec.ts`, `browser_tests/tests/currentUserPopoverCredits.spec.ts`, `browser_tests/fixtures/workspaceSwitcherFixture.ts`, `browser_tests/fixtures/data/workspaceAuthFixtures.ts`). `WorkspaceAuthError` is re-exported because `useWorkspaceAuth.test.ts` imports it from the store; pointing that test at `workspaceAuthError.ts` would have edited a test file inside the move commit. - What the eventual deletion looks like, so the boundary can be judged (this list belongs on FE-951): delete the rail file; remove the twelve rail-originated names the store destructures (`workspaceToken`, `initializeFromSession`, `switchLegacyWorkspace`, `refreshToken`, `ensureWorkspaceToken`, `ensureWorkspaceAuthHeader`, `getWorkspaceAuthHeader`, `getWorkspaceToken`, `hasValidWorkspaceToken`, `retireLegacyToken`, `stopRefreshTimer`, `clearLegacyContext`), seven of which the store also returns; drop the `retireLegacyToken()` call in the unified snapshot subscriber; drop the three token keys in `clearSessionStorage`; re-add `currentWorkspace = null` in `clearWorkspaceContext` (it sits inside `clearLegacyContext` today to keep the clear order identical); collapse `switchWorkspace` to its unified branch; drop `initializeFromSession` from `init` and `stopRefreshTimer` from `destroy`; retarget the four Playwright imports of `WorkspaceTokenResponse` or drop the type with them, and drop `WorkspaceTokenResponseSchema` with the file rather than retargeting it (the generated `zExchangeTokenResponse` already covers this endpoint, and the unified rail consumes it); and decide what `isLoading` means once nothing writes it. ## QA Test files added or changed against the parent branch (`git diff --numstat <parent>...HEAD -- '**/*.test.ts'`): | file | added | removed | | --- | --- | --- | | `src/platform/workspace/stores/legacyWorkspaceTokenRail.lifecycle.test.ts` (new) | 657 | 0 | | `src/platform/workspace/stores/legacyWorkspaceTokenRail.test.ts` (new) | 123 | 0 | | `src/platform/workspace/stores/useWorkspaceAuth.test.ts` | 143 | 1 | - [x] Move commit: no test file changed in it; the suites are green on it - [x] `legacyWorkspaceTokenRail.test.ts`: 6 cases at the factory seam (mint, owner-scoped validity, clear, refresh timer armed and stopped) - [x] `legacyWorkspaceTokenRail.lifecycle.test.ts`: 46 cases covering the mint failure table, session restore, `ensureWorkspaceToken` (cooldown, coalescing, fail-closed, in-flight join, recovery classification) and `refreshToken` (permanent-error exit, the doubling backoff stepped at 999/1, 1999/1 and 3999/1 ms with a fetch count after each step, pre-exchange failure, expired and foreign held tokens, abandoned chain, scheduled retry cap). A halved base delay fails the backoff case at the first step - [x] `useWorkspaceAuth.test.ts`: five additive seam cases, each proven against a mutant (flag-dispatch bypass in `refreshToken` and in `ensureWorkspaceToken`, the downgrade return, eager capture of `getIdToken`, eager capture of `activeWorkspaceId`); the refresh-deadline advance now subtracts `TOKEN_REFRESH_BUFFER_MS` rather than a literal - [x] Both rail suites and the store suite opt out of the auto-advancing fake clock (`shouldAdvanceTime: false`), so the 1 ms margins in the timing rows are real - [x] `src/platform/workspace`, `src/stores`, `src/platform/auth`: 134 files, 2928 tests green at the tip (the one red case, `checkoutJourney.test.ts`, is a known local-only failure in a file this PR does not touch) - [x] Complexity audit against the parent: pass, nothing newly introduced; the rail's highest per-function cyclomatic is 9 - [x] `pnpm typecheck`, `pnpm lint` (0 errors), `oxfmt --check`, `pnpm knip` clean - Not covered: no e2e; the flag-off production path is exercised only by the unit suites above. A cloud build with the flag off (sign in, switch workspace, wait past the refresh buffer) is the manual check if you want one. This PR stacks on Comfy-Org#17835 and merges after it. Addresses the isolate half of [r3976008872](Comfy-Org#17283 (comment)); the shared exchange contract stays on FE-951. Linear: [FE-951](https://linear.app/comfyorg/issue/FE-951/unified-cloud-auth-phase-2-cut-over-to-single-cloud-jwt-remove-legacy) <details> <summary>Stack (merge bottom-up; each PR targets the one below it)</summary> Base: Comfy-Org#17643 hosts own the auth copy. The package is `@comfyorg/account-core` since the rename on main (Comfy-Org#17851); the Vue pieces live in `@comfyorg/account-ui` (Comfy-Org#17854). Publish preparation (files allowlist, dependency cut, `dist` build) now ships from the billing track in Comfy-Org#17882; the earlier Comfy-Org#17838, Comfy-Org#17839 and Comfy-Org#17840 are drafts kept for reference. 1. Comfy-Org#17830 the session client's state changes in one pure transition; cache and in-flight mint become their own modules 2. Comfy-Org#17831 identity is passed to `createSessionClient` at construction; `dispose()` tears it down 3. Comfy-Org#17832 the cloud store binds identity at construction; the flag gates minting only 4. Comfy-Org#17833 the website binds identity through a lazily activated port so Firebase stays a lazy chunk 5. Comfy-Org#17834 the package initializes the cloud app's Firebase; vuefire no longer does 6. Comfy-Org#17835 the transitional `attachIdentity` seam is deleted; ADR-0033 records the outcome 7. Comfy-Org#17836 the legacy workspace-token rail moves into its own removable module and its hot paths are split into named steps ← this PR 8. Comfy-Org#17837 the dead `vuefire` dependency and its inert test mocks go </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One shared sign-in system for comfy.org and cloud.comfy.org: a new
@comfyorg/accountpackage holds the session core, and both apps adopt it instead of each hand-rolling their own auth. This PR combines the ten PRs that built it, already reviewed and individually CI-green, into one branch for final review.Combined from
@comfyorg/accountwith session core, credits client, and Firebase identity@comfyorg/accountin cloud sign-inuser-not-found/wrong-passwordcollapse into one invalid-credential message.workshop-authflag, matching the cloud app's actual behavior (error copy, timeout handling, funnel events), not just its look.signedInbefore its own redirect ran, and closes an open-redirect hole in the post-sign-in return URL.invalidate()for scope changes, and credential preservation across a transient mint failure. Noapps/websitechanges.@comfyorg/accountunified_cloud_auth) mint and refresh internals become wrappers over the shared client: one lifecycle implementation for both apps. Identity reaches the client through a Firebase-entry port rather than a hand-rolled push from Pinia. Carries ADR-AUTH-IDENTITY-0028.Breaking
None across the stack.
unified_cloud_authandworkshop-authboth default off, so unflagged builds see no behavior change. Existing session storage keys, telemetry events, and deeplinks are unchanged.Review Focus
Two merge conflicts came up assembling the ten branches into one, both resolved by hand:
useWorkspaceAuth.test.ts: main had picked up an unrelated global-Pinia test migration after this stack's last sync, colliding with refactor(cloud): unified auth path delegates to @comfyorg/account #17126's newer event-driven identity-port mock. Took refactor(cloud): unified auth path delegates to @comfyorg/account #17126's version, verified as a strict superset of every test on the stack's other branches.packages/account/package.json: two branches added differentexportsentries (./web,./SocialAuthButtons.vue) for files that both exist in the merged tree. Kept both.The identity-port wiring in ADR-AUTH-IDENTITY-0028 is worth a close look:
authStoreno longer pushes identity into the session client, and every mint waits for the port to have delivered the app's current user instead.Out of scope: cross-domain session (a comfy.org sign-in carrying over to cloud.comfy.org and platform.comfy.org) needs backend changes not yet landed (cloud #8601, #8602).
Testing
Each of the ten PRs shipped its own automated coverage and manual checklist; combined here rather than repeated per-file.
Automated, per PR: package suite 247/247 (#17127, #17125), cloud adoption suites (
authStore.test.ts,useAuthActions.test.ts, Turnstile) unchanged (#17120), website suite 212/1504 plus e2e (#16980, #16983, #16984, #16986, #16987), unified-lifecycle suite 94 tests through the fake identity port with zero edits to four dependent suites (#17126), scheduler and cross-tab channel suites plus a live two-tab Playwright spec (#17163). Typecheck and lint clean on every branch and on the combined result.Combined manual QA checklist (carried over from the individual PRs, needs a live Firebase project and backend):
returnTowith an embedded control character pointing off-site, confirm you land on/workshop/, not the external site/login/, confirm you land on the home page without the form flashingDISTRIBUTION=cloudbuild, sign in, open two tabs, confirm one tab holds the refresh lock vianavigator.locks.query(); close the leader tab and confirm the lease moves to the survivor