fix(coach): bind the delete journal to the account and record it was sent for

A tab outlives a logout, another login and a switch into a managed
profile. A delete re-sent in another scope met a 404 that read as
"already gone" and dropped the entry, or tripped the record fence and
toasted a failure for a row the person could not see. Entries now carry
their owner, only the current owner's are re-sent, and a session end
clears the journal with the rest of the session state.
This commit is contained in:
Marc-André Bombeck committed 2026-10-09 10:29:36 +02:00
1 parent c40b21de3d
commit 587ea35d34
6 files changed
+282 -48

No files matched your search

+4
View File
@@ -28,6 +28,7 @@ import type { ModuleAccessState } from "@/lib/sharing/module-disclosure";
import type { OnboardingStateDto } from "@/lib/onboarding/needs";
import type { TourProgress } from "@/lib/onboarding/tour-progress";
import { clearLastDay } from "@/lib/day/last-day";
import { clearCoachDeleteJournal } from "@/lib/ai/coach/delete-journal";
import { clearOfflineCachesForSessionEnd } from "@/lib/pwa/query-persister";
import {
setRecordScope,
@@ -624,6 +625,9 @@ export function clearCachesForSessionEnd(queryClient: QueryClient): void {
clearWasAuthenticated();
// The day the layer last showed is a date of this account's record.
clearLastDay();
// Coach deletes this session could not confirm belong to its account; the
// next one must not re-send them against its own record.
clearCoachDeleteJournal();
void clearOfflineCachesForSessionEnd();
}