/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * What every builder draws of a run of the app's optimiser (#1409; `Optimise * Spec.md` §6, §7): the eye in its toolbar, before the history item, and its * entry, which a builder whose View bundles the period's controls on a phone * lists in the eye's place where the row's floor needs the eye's room (ruled * 27 Oct 2026, "Into the View menu"); the banner in its banners slot while * the highlight is on, or until the next run on failure — a title and one * line, no actions and no close, as the mock's alert is; the footer line * while the call is out and for 2.5s after Stop; * the legend's `Elara change` during the highlight; and the lock while the * call is out. One hook over the run (`useOptimise`) and the landing * (east-ui-components' `useLanding`), so each builder lists the parts in its * frame and draws nothing of them itself. * * A result lands once the builder's own reads hold it: a step recorded moves * the drafts, the builder reads its rows again, and only then do its entries * carry the run's marks. So the landing waits for the builder's data to move * ({@link OptimisePartsArgs.landKey}) before it measures the entries and * starts the cascade — on a result, and on a Redo that re-inserts the run's * step, which replays the landing without the banner (R9). * * @packageDocumentation */ import { type ReactElement, type ReactNode } from "react"; import { type HistoryAction, type Landing, type OptimiseButtonSize, type ToolbarItem } from "@elaraai/east-ui-components"; import type { LoadingLineValue } from "@elaraai/east-ui-components/internal"; import type { OptimiseRun } from "./use-optimise.js"; /** * What the parts are made over. * * @typeParam Req - The run's request */ export interface OptimisePartsArgs { /** The run. */ readonly run: OptimiseRun; /** The landing over the builder's frame. */ readonly landing: Landing; /** The period's label — `W11`, `Oct 5 – 9`, `8 work orders` — which the eye, the footer line and the banner name. */ readonly period: string; /** * Whether the period cannot be optimised at all — read only, published, a month in view (ruled 25 Oct 2026, over * D1): the builder lists no eye, rather than a disabled one. */ readonly readOnly: boolean; /** * Whether the period cannot take a run yet — its reads in flight, a save under way: the eye disabled, its place * kept, so a period step moves nothing in the toolbar. */ readonly busy?: boolean | undefined; /** The run's request for a run number: the period's rows as the session holds them, and the builder's context. */ readonly request: (run: number) => Req; /** * What moves when the builder's reads hold a step's drafts — its rows as read, by identity: a result lands once it * has moved from where it stood as the step was recorded. */ readonly landKey: unknown; /** The eye's size: `toolbar` — 32 × 28, the builders' toolbar rows' — unless given. */ readonly size?: OptimiseButtonSize | undefined; } /** The parts, as a builder lists them in its frame. */ export interface OptimiseParts { /** The eye's toolbar item, to list immediately before the history item; `undefined` with no optimiser, or where the period cannot be optimised. */ readonly toolbarItem: ToolbarItem | undefined; /** * The eye as an entry of the builder's View (`OptimiseEntry`): what a builder whose View bundles the period's controls * on a phone lists in the eye's place where the row's floor folds the eye into it (ruled 27 Oct 2026, "Into the View * menu") — the same run, its Stop and why it is off. `undefined` wherever {@link OptimiseParts.toolbarItem} is. */ readonly entry: ReactElement | undefined; /** The banner, for the banners slot; nothing with no optimiser. */ readonly banner: ReactNode; /** The footer line while the call is out or just stopped; `undefined` otherwise, when the builder's own line shows. */ readonly line: LoadingLineValue | undefined; /** Whether the legend's `Elara change` shows: the highlight is on over a run that changed something. */ readonly legend: boolean; /** Whether the builder holds its lock (R2): a call is out. */ readonly locked: boolean; /** * Lands a run's result once the builder's reads hold it: called as the step is recorded, it waits for `landKey` * to move, then starts the cascade and the highlight. * * @param run - The run that landed */ landAfter(run: number): void; /** * A history action the builder is about to run, heard first (R9, R16): Undo, Apply and Discard end the highlight; * a Redo that re-inserts a run's step replays its landing without the banner. * * @param action - The action * @param redoOrigin - The origin of the step the Redo would re-insert, when the action is one */ acted(action: HistoryAction, redoOrigin?: string | undefined): void; } /** * The parts of a run, over the run and the landing (see the module docs). * * @typeParam Req - The run's request * @param args - The run, the landing, the period, its request and what moves as the builder's reads do * @returns The parts */ export declare function useOptimiseParts({ run, landing, period, readOnly, busy, request, landKey, size }: OptimisePartsArgs): OptimiseParts; //# sourceMappingURL=optimise-parts.d.ts.map