generated from coulomb/repo-seed
Persist capture data per session (field values, schema, links)
Capture mode state lived only in React memory and was lost when reopening a session or remounting EngineProvider. - Add per-session localStorage capture snapshot (schema, values, links) - Restore on session mount; persist on field/schema/link changes - Seed binder links from storage without spurious bus events - Clean up capture key when session is deleted - Integration test for reload persistence
This commit is contained in:
29
src/app/forms/CaptureLinkPersister.tsx
Normal file
29
src/app/forms/CaptureLinkPersister.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Writes evidence links to per-session capture storage whenever the
|
||||
* binder mutates links.
|
||||
*/
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
import type { SessionId } from "@shared/ids";
|
||||
|
||||
import { useBinder } from "@binder/index";
|
||||
import { useEngineEventTick } from "@work/index";
|
||||
|
||||
import { persistCapturePatch } from "./capture-persistence";
|
||||
|
||||
export function CaptureLinkPersister({ sessionId }: { sessionId: SessionId }) {
|
||||
const { links } = useBinder();
|
||||
const linkTick = useEngineEventTick("EvidenceLinkCreated");
|
||||
const unlinkTick = useEngineEventTick("EvidenceLinkRemoved");
|
||||
const updateTick = useEngineEventTick("EvidenceLinkUpdated");
|
||||
|
||||
useEffect(() => {
|
||||
void linkTick;
|
||||
void unlinkTick;
|
||||
void updateTick;
|
||||
persistCapturePatch(sessionId, { evidenceLinks: links.list() });
|
||||
}, [sessionId, links, linkTick, unlinkTick, updateTick]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user