feat(frontend): polish web (logout, 401→pairing, reconnexion globale) (#13)

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>
This commit is contained in:
2026-07-16 08:23:11 +02:00
parent d538808a0d
commit 6117177957
10 changed files with 288 additions and 14 deletions

View File

@ -0,0 +1,29 @@
/**
* `useLiveConnectionState` — ticket #13, lot F6. Web-only hook exposing the shared
* live WebSocket's current {@link ConnectionState} to the UI so a reconnection
* banner can be shown even when no terminal is open (the F3 xterm notice only
* covers terminal cells; live-only surfaces had no visible signal).
*
* Inert outside web transport (no client registered), so it is safe to mount
* unconditionally: it returns `null` on desktop.
*/
import { useEffect, useState } from "react";
import { getWebLiveClient, type ConnectionState } from "@/adapters/http";
export function useLiveConnectionState(): ConnectionState | null {
const [state, setState] = useState<ConnectionState | null>(
() => getWebLiveClient()?.getConnectionState() ?? null,
);
useEffect(() => {
const client = getWebLiveClient();
if (!client) return;
// Sync in case the state changed between the initial render and this effect.
setState(client.getConnectionState());
return client.onConnectionStateChange(setState);
}, []);
return state;
}