mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 23:41:08 +02:00
Closes the userContext race-on-first-mount that surfaced as a "10 fields overwritten" conflict toast pre-F2. Adds a fire-and-forget hook in the /register flow that writes the per-user `userContext` singleton straight into `mana_sync.sync_changes` with `client_id='system:bootstrap'` and `origin='system'`. Behavior: - On successful `signUpEmail`, `bootstrapUserSingletons(userId, syncSql)` inserts a `profile/userContext` row with the empty-default shape that mirrors the webapp's `emptyUserContext()` factory in `apps/mana/apps/web/src/lib/modules/profile/types.ts`. - The receiving client treats the change as origin='server-replay' on apply (per F2 conflict-gate), so no toasts on first pull. - Failure is logged but does not abort registration — the webapp's existing `ensureDoc()` fallback still works during the F4→F5 transition. Module-scoped postgres pool (max=2 connections) lazy-initialized on first signUp; reused for the lifetime of the process. Same pattern as `UserDataService.getSyncSql`. Out of scope for F4: - `kontextDoc` is per-Space (not per-user) — bootstrap there will be hooked into the Space-creation flow, not /register. The webapp's `ensureDoc()` for kontextDoc stays as-is for now. - Webapp `ensureDoc()` removal is F5. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| sql | ||
| src | ||
| CLAUDE.md | ||
| Dockerfile | ||
| drizzle.config.ts | ||
| package.json | ||
| tsconfig.json | ||