// SPDX-License-Identifier: MIT // Copyright (C) 2026 Pooya Parsa // An app's installer window (installer.ts runs it; launcher.ts opens it for // an app that lacks packages or downloads): the app's icon (a flat tile in // its colour) and name, one line for the current step (Paused while the // machine is held; the error once failed, in red), one progress bar (the // accent; red once failed; a sliding piece while nothing is known yet), a // Log disclosure, and Cancel (dimmed while stopping would leave packages // half installed) or, failed, Close and Retry. The log: the install's real // output in mono, kept at its end while it grows unless the user scrolled up // (scrolling back to the end follows again), with a copy button. // TileProgress: the same install as a bar over the app's tile (the Dock's, // the launcher's). // Ids: #installer- (data-state running or failed), its -step, -bar, // -log, -last (the log's newest line while the log is closed), -cancel, // -retry and -close. // In compact mode the window fills the screen: the content is a column at // most 440 px wide, in the middle while the log is closed, like a sheet. import { useLayoutEffect, useRef, useState, type CSSProperties } from "react"; import { cancelInstall, dismissInstall, logOf, retryInstall, toggleInstallLog, useInstall, useLogSeq, type Install } from "../installer.ts"; import { KW } from "../kw.ts"; import { isHeld, isRunning, useStore } from "../store.ts"; import { AppGlyph, CheckIcon, ChevronIcon, CopyIcon } from "./icons.tsx"; /** The app's icon: a flat rounded tile in its first colour, its glyph in white. */ function Face({ inst }: { inst: Install }) { const style: CSSProperties = { background: inst.colors?.[0] ?? "#3f3f46" }; return ( ); } /** The bar: `value` 0 to 1, or null (indeterminate). */ export function ProgressBar({ id, value, failed, label }: { id?: string; value: number | null; failed?: boolean; label: string }) { const pct = value === null ? undefined : Math.round(value * 100); return (
); } /** An app's install as a bar over its tile's face (style.css .tile-progress: the Dock's, the launcher's), or nothing; `className` places it. */ export function TileProgress({ inst, className = "" }: { inst: Install | undefined; className?: string }) { if (!inst) return null; const failed = inst.state === "failed"; const v = failed ? inst.progress ?? 1 : inst.progress; return (