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:
2026-06-08 01:23:48 +02:00
parent ba34ba868f
commit b28feaad42
8 changed files with 437 additions and 9 deletions

View 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;
}