// @ts-check // The status line's details: the mode, the thinking level and the model, each a tap to change, // and the readings the compact line leaves out. Changes go to the session as they're picked; the // sheet shows what the session reports back, so a refused change never looks made. import { html } from "./html.js"; import { Icon } from "./icons.js"; import { useEscape } from "./dock.js"; import { isCurrent, selectModelFrame, thinkingFrame, thinkingLevels } from "./models.js"; import { useRendered } from "./render.js"; /** @import { Frame } from "./connection.js" */ /** @import { Listing, ModelChoice } from "./models.js" */ /** The modes `set_mode` takes. */ export const MODES = ["build", "plan"]; /** * @param {{ facts: Record, mode: string, listing: Listing, * send: (frame: Frame) => boolean, close: () => void }} props */ export function DetailsSheet({ facts, mode, listing, send, close }) { useEscape(close); const levels = thinkingLevels(listing.models, facts.model); return html``; } /** * A row of choices with the current one marked; nothing when there's nothing to choose. * @param {{ title: string, options: string[], current: string, pick: (option: string) => void }} props */ function Choices({ title, options, current, pick }) { if (!options.length) return null; return html`

${title}

${options.map((option) => html``)}
`; } /** * @param {{ listing: Listing, current: import("./models.js").CurrentModel | undefined, * pick: (choice: ModelChoice) => void }} props */ function ModelPicker({ listing, current, pick }) { return html`

Model

<${ListingNote} state=${listing.state} empty=${!listing.models.length} /> `; } /** What the model list is waiting on, when it's not just a list. @param {{ state: string, empty: boolean }} props */ function ListingNote({ state, empty }) { if (state === "unsupported") return html`

Update Luxe on your computer to switch models from here.

`; if (state === "lost") return html`

Not connected.

`; if (state === "asking" && empty) return html`

Loading models…

`; if (state === "listed" && empty) return html`

No other models configured.

`; return null; } /** * Whether the rendered line holds a reading: a session that has spent nothing yet reports a total * the host words as no segment at all. @param {string | null | undefined} rendered */ export function hasReadings(rendered) { return /\bseg-(context|cost)\b/.test(rendered ?? ""); } /** * The context and cost, worded as the line words them: the line's own render, the same request, * with the model and thinking left to the pickers above. @param {{ facts: Record }} props */ function Readings({ facts }) { const rendered = useRendered({ kind: "status", ...facts }, true); if (!hasReadings(rendered)) return null; return html`

Session

`; }