2026-10-10 14:11:19 +03:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The auto-update banner (Wave C, owner 2026-10-10: silent download +
|
|
|
|
|
* restart-banner UX). The shell pushes "lh:update-status" once a staged
|
2026-10-25 19:19:38 +02:00
|
|
|
* update exists (electron/main.cjs update-downloaded). Snapshot retrieval
|
|
|
|
|
* also covers a late load. The card offers Restart alongside Settings.
|
2026-10-10 14:11:19 +03:00
|
|
|
* Browser builds have no window.lh and never see a push: renders null.
|
|
|
|
|
*
|
|
|
|
|
* No dismiss: a downloaded update installs on quit anyway
|
|
|
|
|
* (autoInstallOnAppQuit); the banner is a courtesy, not a gate.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-10-25 19:19:38 +02:00
|
|
|
import { useUpdateState } from "@/components/settings/update-settings.tsx";
|
2026-10-10 14:11:19 +03:00
|
|
|
|
|
|
|
|
export default function UpdateBanner() {
|
2026-10-25 19:19:38 +02:00
|
|
|
const { state: ready } = useUpdateState();
|
|
|
|
|
if (ready?.status !== "downloaded") return null;
|
2026-10-10 14:11:19 +03:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
data-testid="update-banner"
|
|
|
|
|
className="fixed right-4 bottom-4 z-50 flex items-center gap-3 rounded-lg border border-border bg-popover px-4 py-3 shadow-lg"
|
|
|
|
|
>
|
|
|
|
|
<div className="text-sm">
|
|
|
|
|
<span className="font-medium">LearnHarness {ready.version ?? "update"} is ready</span>
|
|
|
|
|
<span className="text-muted-foreground"> — restart to finish installing.</span>
|
|
|
|
|
</div>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => window.lh?.installUpdate?.()}
|
|
|
|
|
className="rounded-md bg-accent px-3 py-1.5 text-sm font-medium transition-colors hover:bg-accent/80"
|
|
|
|
|
>
|
|
|
|
|
Restart
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|