Flow logout : POST /api/logout puis retour à l'écran de pairing et déconnexion du live. 401 renvoie au pairing sans boucle. Bannière de reconnexion couvrant le cas live-only et le serveur indisponible. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
/**
|
|
* 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();
|
|
}
|