/** * Web live-connection accessor — ticket #13, lot F5. * * The web gateways share a single {@link WsLiveClient} (created in * `createHttpWsGateways`). The live surfaces (workstate / background / * notifications) need to know when that socket **reconnects** after an outage so * they can re-synchronise their read-models (events emitted while disconnected * were missed). The `SystemGateway` port intentionally does not expose transport * connection state, so — rather than leak it through the port — the web client is * registered here as a module singleton and consumed only by the web feature * (`useLiveReconnect`). Desktop never registers a client, so this is inert there. * * Lives in `src/adapters/**`; touches no `@tauri-apps/api`. */ import type { WsLiveClient } from "./wsLiveClient"; let liveClient: WsLiveClient | null = null; /** Registers the shared web live client (called by `createHttpWsGateways`). */ export function setWebLiveClient(client: WsLiveClient | null): void { liveClient = client; } /** Returns the shared web live client, or `null` outside web transport. */ export function getWebLiveClient(): WsLiveClient | null { return liveClient; } /** * Soft-disconnects the shared live client (sign-out / auth bounce — F6): tears * down the socket and stops the reconnect loop but keeps the client reusable, so * re-pairing reconnects cleanly. Inert (no client registered) on desktop. */ export function disconnectWebLive(): void { liveClient?.disconnect(); }