1import type { JSX } from "preact";2import {3 reloadAfterRuntimeStartupFailure,4 type RuntimeStartupFailure,5} from "../runtime/startup-recovery.ts";67/** Inputs for Lofi's explicit persistent-runtime recovery action. */8export type RuntimeRecoveryProps = {9 failure: RuntimeStartupFailure | null;10 reload?: () => void;11};1213/**14 * Renders recovery only when another tab is running an incompatible broker version.15 *16 * @example17 * ```tsx18 * import { RuntimeRecovery } from "@nzip/lofi/preact";19 *20 * <RuntimeRecovery failure={startupFailure} />;21 * ```22 *23 * @param props The startup failure to inspect and an optional reload override.24 * @returns The recovery prompt, or `null` when no incompatible-broker failure is present.25 */26export function RuntimeRecovery({ failure, reload }: RuntimeRecoveryProps): JSX.Element | null {27 if (failure?.code !== "broker-incompatible") return null;28 return (29 <div class="runtime-recovery" role="alert">30 <h4>Close other app tabs</h4>31 <p>{failure.message}</p>32 <p>This tab will not reload or retry automatically.</p>33 <button34 type="button"35 onClick={() => reloadAfterRuntimeStartupFailure(reload)}36 >37 Reload app38 </button>39 </div>40 );41}