Extract three more AppInner state clusters into hooks: - useDashboardHealth: dashboard health state + mount fetch + on-demand refresh; exposes setHealth for the TaskIdIntegrityBanner remediation callback. - useAuthTokenRecovery: the auth-token-recovery dialog open state driven by the AUTH_TOKEN_RECOVERY_REQUIRED_EVENT window listener. - useScopedDismissFlag: a generic per-project dismissable banner flag (scoped storage + project-change re-read + dismiss); backs the setup-warning banner. Capacity-risk dismiss stays inline pending its dedicated useCapacityRiskBanner hook. Behavior-preserving; App.test.tsx identical (5 pre-existing failures, none introduced). Verified by typecheck, eslint, and 7 renderHook tests. Part of U5 (App.tsx module-breakup plan).
29 lines
844 B
TypeScript
29 lines
844 B
TypeScript
/*
|
|
FNXC:AuthTokenRecovery 2026-06-24-00:00:
|
|
App-level open state for the auth-token recovery dialog, opened when the daemon signals auth failure (AUTH_TOKEN_RECOVERY_REQUIRED_EVENT). Extracted verbatim from AppInner.
|
|
*/
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { AUTH_TOKEN_RECOVERY_REQUIRED_EVENT } from "../auth";
|
|
|
|
export interface UseAuthTokenRecoveryResult {
|
|
open: boolean;
|
|
}
|
|
|
|
export function useAuthTokenRecovery(): UseAuthTokenRecoveryResult {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const handleDaemonAuthFailure = () => {
|
|
setOpen(true);
|
|
};
|
|
|
|
window.addEventListener(AUTH_TOKEN_RECOVERY_REQUIRED_EVENT, handleDaemonAuthFailure);
|
|
return () => {
|
|
window.removeEventListener(AUTH_TOKEN_RECOVERY_REQUIRED_EVENT, handleDaemonAuthFailure);
|
|
};
|
|
}, []);
|
|
|
|
return { open };
|
|
}
|