Repository navigation
refactor(cloud): initialize Firebase through the account package, dropping vuefire #17834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c19c893
e211cd3
64ece9e
3aa6c3c
36c5790
c66a653
9348238
b742c75
7184764
d0e3c13
3633eb7
cea548a
61b4451
b7a3541
885faf4
e68e3f0
4db1dbe
d69670b
7a16e1f
6c9c0a5
d5e9fc3
4878540
3ccca0d
d18c716
ce6d000
c265fdb
4516673
75711dc
e35ef22
dcc57ab
35d7eb4
d043b0f
78ed507
c723b51
1e2216a
f48b71c
4695894
755e77e
c6a9f83
39dfbd8
821bdf6
20a8d0c
c31f4ac
75e3c28
9dc4b31
f5fc42b
706de77
f7e2e23
e7153ec
7459488
f2adf68
370a871
9874cfe
651e277
59b7573
1b84482
8f17e4e
3357db2
71e38b3
0f96221
d48d1f1
3edfb4c
5f7ad49
612a1bb
44bbc19
d65981c
84a1ca2
91acae0
7547ac9
0a237d9
0122487
aeb36fc
6699d65
709b4c8
0fd63d5
23c5bb6
df8ea1d
82e272e
65fa927
eb6dd94
2e0858b
3f4ad32
448c4b9
52054e1
838ae89
d179a6c
eaa4428
6e8dfcd
386d96d
1b89a09
ffbec33
ea2ac9a
2889104
a846e1d
006f110
df6ffd7
dc2ab4c
b9b17fe
19ae957
d48db49
2edcccb
c5801ad
016f718
7306ed8
a68fe71
03bfdb7
482ba49
7d1d4c7
37a84c2
7af0afe
4bea63d
9826d1b
f8e97d4
4d98540
53db9f3
ba5c637
bc716ee
feaeccc
01a3b78
112bec2
83d8fb8
b321250
f32024e
693f781
4fbdc9b
50580a6
94b1495
6b17307
da83189
5b8b504
9c1a388
2ee9541
7614f52
4fa9efd
cb01c88
a8003b7
a4a0c77
e8b0522
e3ef8fd
2949c2e
4eea04e
c01fa5f
d145c57
6e819ed
a2187f8
5e57606
549b82b
c93e823
0748a15
ba521c5
381c38f
5ec0021
cd67079
53051ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,9 @@ Proposed | |
| Amended 2026-09-16: rules 1 and 4 follow the session client taking identity at | ||
| construction (FE-2196). | ||
|
|
||
| Amended 2026-09-16: rule 5 follows the package initializing the cloud app's | ||
| Firebase, replacing vuefire (FE-2196, C4). | ||
|
|
||
| ## Context | ||
|
|
||
| The cloud app holds two consumers of Firebase identity: | ||
|
|
@@ -29,11 +32,11 @@ is not a contract to build on. | |
|
|
||
| ## Decision | ||
|
|
||
| 1. Identity reaches the session client through the package entry bound to | ||
| the app's own `Auth` instance: `authStore` creates | ||
| `createFirebaseIdentity({ auth })` and `workspaceAuthStore` passes it to | ||
| `createSessionClient` at construction. No hand-rolled port exists in | ||
| `src/`. | ||
| 1. Identity reaches the session client through the package entry: the | ||
| identity module (`src/platform/auth/firebaseIdentity.ts`) creates it and | ||
| `workspaceAuthStore` passes it to `createSessionClient` at construction. | ||
| `authStore` subscribes to the same entry for its side effects and holds | ||
| no identity of its own. No hand-rolled port exists in `src/`. | ||
| 2. The Pinia `authStore` is a projection for app-wide side effects. It is | ||
| not an identity authority for the session client and pushes nothing | ||
| into it. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: Minor (record) What: rule 3 says " Why this is an issue: the merged ADR describes two contradictory wirings, and #17835 builds on rule 3. The same clause has a thread on #17832 from the auth-first side; the rewrite belongs here where the coupling goes away. Proposed Fix: rewrite the clause for this head: " |
||
|
|
@@ -48,16 +51,12 @@ is not a contract to build on. | |
| port's user is what mints. The wait is bounded, so a silent port fails | ||
| the mint closed instead of hanging the auth gate. Mints stay | ||
| host-driven (`autoMint: false`), so telemetry and coalescing are | ||
| unchanged. The two stores construct each other (`workspaceAuthStore` | ||
| reads `useAuthStore().identity` in its setup, `authStore`'s listener | ||
| calls `useWorkspaceAuthStore()`), which holds only because the SDK | ||
| delivers a new observer's first emission asynchronously, after | ||
| persistence resolves; a synchronous identity source in its place would | ||
| re-enter a half-built store: built workspace-first it throws a boot-time | ||
| `TypeError` from `authStore`'s listener against the half-assigned store, | ||
| built auth-first it leaves the client unsubscribed and every mint waiting | ||
| its ceiling. The "store construction order" test in `authStore.test.ts` | ||
| pins the working microtask order. | ||
| unchanged. The two-store construction-order coupling is gone at | ||
| this head: `workspaceAuthStore` binds the package `firebaseIdentity`, and | ||
| every `useAuthStore()` read is inside a function or callback, not the setup | ||
| body, so neither store re-enters the other during construction and nothing | ||
| depends on the SDK's microtask timing. `useWorkspaceAuth.test.ts` pins the | ||
| store subscribing and minting even when built before `authStore` exists. | ||
| 4. `syncUnifiedIdentity` is gone, and the flag gates minting, not | ||
| subscription: identity is bound to the session client for the store's | ||
| lifetime. With `unified_cloud_auth` off the port stays subscribed but | ||
|
|
@@ -69,16 +68,30 @@ is not a contract to build on. | |
| either: no unified token, network call or timer exists. The residue is the | ||
| snapshot's user and a `minting`/`pending` phase that no flag-off consumer | ||
| reads. | ||
| 5. Nothing in `src/` may initialize a second Firebase app through | ||
| `createFirebaseIdentity({ options })` while the app runs on vuefire; a | ||
| second auth instance diverges the session. Package-initialized Firebase | ||
| for the cloud app (dropping the `VueFire` plugin and `useFirebaseAuth`) | ||
| is a separate migration and the one remaining divergence from the TDD's | ||
| "the package initializes Firebase". | ||
| 5. The package initializes the cloud app's Firebase: the identity module | ||
| (`src/platform/auth/firebaseIdentity.ts`) is the one entry, created from | ||
| `getFirebaseConfig()` under the default app name (`[DEFAULT]`, the name | ||
| persisted sessions are keyed by) with an ordered persistence hierarchy: | ||
| localStorage, then the IndexedDB store vuefire persisted sessions into, | ||
| then session storage, and the popup resolver. Firebase restores a user | ||
| from the first store that holds one and migrates it into localStorage, | ||
| which is what keeps existing sign-ins alive. Nothing else in `src/` | ||
| creates a Firebase app or `Auth`. `main.ts` calls `initialize()` after | ||
| remote config has loaded, so the config is the server's; resolution | ||
| before remote config has loaded throws in every environment, so the | ||
| `main.ts` ordering is the invariant. `firebaseIdentity.test.ts` pins it: | ||
| the config is read at `initialize()` rather than at import, and a resolve | ||
| while remote config is still unloaded throws. The cloud e2e set is the | ||
| end-to-end proof of the `main.ts` sequence and runs green in the `cloud` | ||
| and `chromium` projects. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| Booting on build-time config could point auth at the wrong Firebase | ||
| project, so the module fails closed rather than falling back. | ||
| `currentUser()` never initializes, so a feature-flag read before that | ||
| point fails closed instead of booting Firebase early. | ||
|
|
||
| The contract is pinned by the "unified identity source" test in | ||
| `authStore.test.ts`, the identity-driven cases in `useWorkspaceAuth.test.ts` | ||
| (driven through a fake port, never through the store), and the package's | ||
| (driven through a fake port that mirrors the store's user), and the package's | ||
| "keeps the identity after invalidation" test. | ||
|
|
||
| ## Alternatives Considered | ||
|
|
@@ -90,8 +103,9 @@ The contract is pinned by the "unified identity source" test in | |
| to re-deliver. | ||
| - **A reactive `watch` on `authStore.currentUser`**: rejected, it keeps | ||
| Pinia as the messenger and reintroduces ordering ambiguity. | ||
| - **Package-initialized Firebase now**: rejected at this stage for the | ||
| vuefire coupling in rule 5; it supersedes rule 5 when it lands. | ||
| - **Package-initialized Firebase now**: deferred at first for the vuefire | ||
| coupling; landed as the amended rule 5 once the entry passed the popup | ||
| resolver alongside a host persistence. | ||
|
|
||
| ## Consequences | ||
|
|
||
|
|
@@ -101,5 +115,6 @@ The contract is pinned by the "unified identity source" test in | |
| - Token reads go through the Firebase `User` directly; a transient read | ||
| failure is a retried transient exchange failure, not a permanent | ||
| not-authenticated error. | ||
| - The `comfy-account` named app stays unused by the cloud app until the | ||
| package-initialized migration. | ||
| - The cloud app runs on the package-initialized `[DEFAULT]` app, not the | ||
| package's `comfy-account` default name, so persisted sessions and the e2e | ||
| seed keep their IndexedDB key. | ||
Uh oh!
There was an error while loading. Please reload this page.