Files
citation-evidence/src/app/forms/CaptureLinkPersister.tsx
tegwick b28feaad42 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
2026-06-08 01:23:48 +02:00

29 lines
873 B
TypeScript

/**
* 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;
}