mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-27 09:37:42 +02:00
fix(mana/web): sprint 2 — auth-aware data layer + guest migration
- Single source of truth for the active user via data/current-user.ts; layout pushes authStore.user.id into it on every auth state change. - Dexie creating-hook auto-stamps userId from getEffectiveUserId(); the updating-hook strips userId from modifications so records are effectively user-immutable after creation. - BaseRecord gains an optional userId so module types inherit it without per-module declarations. All hardcoded 'guest'/'local' fallbacks in module type-converters and session timer stores are deleted; the dead userId field is removed from the public view types where it was unused (Task, Conversation, Template, Deck, Plant, Contact, etc.). - New guest-migration.ts: on first authenticated session, walks every sync-tracked table, deletes guest-owned records and re-adds them so the creating-hook re-stamps with the real user id and produces fresh insert pending-changes with the full payload. Stale guest pending- changes are cleared up-front. - Drive-by: root onMount now returns its cleanup synchronously; the previous async form silently dropped the cleanup callback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0909538827
commit
28942abede
24 changed files with 182 additions and 47 deletions
|
|
@ -18,7 +18,6 @@ import type {
|
|||
export function toConversation(local: LocalConversation): Conversation {
|
||||
return {
|
||||
id: local.id,
|
||||
userId: local.userId ?? 'guest',
|
||||
modelId: local.modelId ?? '',
|
||||
templateId: local.templateId ?? undefined,
|
||||
spaceId: local.spaceId ?? undefined,
|
||||
|
|
@ -35,7 +34,6 @@ export function toConversation(local: LocalConversation): Conversation {
|
|||
export function toTemplate(local: LocalTemplate): Template {
|
||||
return {
|
||||
id: local.id,
|
||||
userId: local.userId ?? 'guest',
|
||||
name: local.name,
|
||||
description: local.description || null,
|
||||
systemPrompt: local.systemPrompt,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ export interface LocalTemplate extends BaseRecord {
|
|||
|
||||
export interface Conversation {
|
||||
id: string;
|
||||
userId: string;
|
||||
modelId: string;
|
||||
templateId?: string;
|
||||
spaceId?: string;
|
||||
|
|
@ -60,7 +59,6 @@ export interface Message {
|
|||
|
||||
export interface Template {
|
||||
id: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
systemPrompt: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue