Add a durable, acknowledged Local network sharing switch with fail-closed hydration, serialized mutation, and redacted ephemeral-identity diagnostics. Keep local Call-to-Play state available while gating every network action on the effective sharing generation. Render revisioned verification, invalid-source retry, and sticky source exhaustion states. Preserve opaque attempt IDs through progress delivery so out-of-order webview events cannot attach stale bytes to a successor transfer, and keep terminal exhaustion visible after the last source departs. Own listeners, native invokes, persistence, dialogs, and companion-window creation through webview close. Late creation is settled and cleaned before the parent realm is destroyed. Test Plan: - `just frontend-test` -- passed (91/91) - `just build` -- passed with TypeScript, Vite, and release Tauri compilation - `just test` -- passed on the completed stack (708 workspace tests) - `just clippy` -- passed on the completed stack - `git diff --cached --check` -- passed
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import {
|
|
INITIAL_PROTOCOL_MISMATCH_SNAPSHOT,
|
|
newestProtocolMismatchSnapshot,
|
|
type ProtocolMismatchSnapshot,
|
|
} from "../src/lib/protocolMismatch.ts";
|
|
|
|
const assertEquals = <T>(actual: T, expected: T, message: string) => {
|
|
if (JSON.stringify(actual) !== JSON.stringify(expected)) {
|
|
throw new Error(
|
|
`${message}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,
|
|
);
|
|
}
|
|
};
|
|
|
|
Deno.test("delayed bootstrap snapshot cannot overwrite a newer mismatch event", () => {
|
|
const delayedQuery = INITIAL_PROTOCOL_MISMATCH_SNAPSHOT;
|
|
const event: ProtocolMismatchSnapshot = {
|
|
revision: 1,
|
|
mismatch: { observed: 7, expected: 8 },
|
|
};
|
|
|
|
const afterEvent = newestProtocolMismatchSnapshot(
|
|
INITIAL_PROTOCOL_MISMATCH_SNAPSHOT,
|
|
event,
|
|
);
|
|
assertEquals(
|
|
newestProtocolMismatchSnapshot(afterEvent, delayedQuery),
|
|
event,
|
|
"delayed query must lose to event",
|
|
);
|
|
});
|
|
|
|
Deno.test("new runtime generation clears an older mismatch", () => {
|
|
const mismatch: ProtocolMismatchSnapshot = {
|
|
revision: 4,
|
|
mismatch: { observed: null, expected: 8 },
|
|
};
|
|
const cleared: ProtocolMismatchSnapshot = { revision: 5, mismatch: null };
|
|
|
|
assertEquals(
|
|
newestProtocolMismatchSnapshot(mismatch, cleared),
|
|
cleared,
|
|
"new generation clear must win",
|
|
);
|
|
});
|