Files
Jyotisha/frontend/src/lib/chart-library-session.ts
T
Jesse_ChenandCursor ce6a8a7e72
Independent Staging Quality Gate / validate (push) Has been cancelled
Independent Staging Quality Gate / publish (push) Has been cancelled
fix(chat): make cloud the only truth for charts, synastry, and pin/archive
Local fallbacks were creating fake saves and resurrecting deleted rows.
Pin and archive now live on chat_sessions so they follow the account.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 21:38:21 +08:00

26 lines
815 B
TypeScript

export type ChartLibrarySessionBranch = "clear" | "hydrate-then-persist" | "persist-self";
export function chartLibrarySessionBranch(
accountId: string | null | undefined,
loadedAccount: string,
): ChartLibrarySessionBranch {
if (!accountId) return "clear";
if (loadedAccount !== accountId) return "hydrate-then-persist";
return "persist-self";
}
export function chartLibraryFromCloudOthers<T extends { role: "self" | "other" }, P>(
cloudLibrary: readonly T[],
profile: P,
upsertSelfChart: (library: T[], profile: P) => T[],
): T[] {
return upsertSelfChart(cloudLibrary.filter((record) => record.role !== "self"), profile);
}
export function chartLibraryOnCloudFailure<T, P>(
profile: P,
upsertSelfChart: (library: T[], profile: P) => T[],
): T[] {
return upsertSelfChart([], profile);
}