The UI source from the 14 October handoff (src/, public/, index.html, vite and tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses, the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip (server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real job's own record. The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning goes where the handoff sends it), and src/components/TunePanel.tsx and src/styles/tuning.css, which only that route used, are not carried over. Left out of git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints (170 MB of screenshots, kept in StrataSplit\evidence-archive). From the owner's rebuild branch strata/rebuild-2026-10.
43 lines
3.8 KiB
TypeScript
43 lines
3.8 KiB
TypeScript
import { tr } from '../lib/i18n';
|
|
import { Fragment, useEffect, useId, useRef, useState, type ReactNode } from 'react';
|
|
import type { Hardware, ModelVariant } from '../lib/types';
|
|
import { versionFit, VERSION_FIT_LABEL } from '../lib/model-versions';
|
|
import { sizeGb } from '../lib/format';
|
|
import { Icon } from './ui';
|
|
import { VersionMemoryTooltip } from './VersionMemoryTooltip';
|
|
export function VersionLadder({ versions, hardware, context, selected, recommended, onSelect, selectedDetail, detailId, fitLabel, compact = false, disabled = false, memoryNote }: {
|
|
versions: ModelVariant[];
|
|
hardware: Hardware | null;
|
|
context: number;
|
|
selected?: string;
|
|
recommended?: string;
|
|
onSelect: (id: string) => void;
|
|
selectedDetail?: ReactNode;
|
|
detailId?: string;
|
|
fitLabel?: (version: ModelVariant) => string;
|
|
compact?: boolean;
|
|
disabled?: boolean;
|
|
memoryNote?: (version: ModelVariant) => string | undefined;
|
|
}) {
|
|
const tooltipId = useId();
|
|
const [hint, setHint] = useState<{
|
|
id: string;
|
|
text: string;
|
|
anchor: HTMLElement;
|
|
} | null>(null);
|
|
const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
function keepHint() { clearTimeout(closeTimer.current); }
|
|
function closeHint() { keepHint(); setHint(null); }
|
|
function showHint(id: string, text: string, anchor: HTMLElement) { keepHint(); setHint({ id, text, anchor }); }
|
|
function delayClose() { keepHint(); closeTimer.current = setTimeout(() => setHint(null), 140); }
|
|
useEffect(() => () => clearTimeout(closeTimer.current), []);
|
|
return <div className={`version-ladder${compact ? ' version-ladder--compact' : ''}`} role="group" aria-label={tr("Model versions")}>{tr(versions.map(v => {
|
|
const fit = versionFit(v, hardware, context), active = selected === v.id, note = compact ? memoryNote?.(v) : undefined;
|
|
return <Fragment key={v.id}>
|
|
<button className="version-rung" disabled={disabled} data-fit={fit.zone} data-state={v.state} aria-pressed={active} aria-expanded={selectedDetail ? active : undefined} aria-controls={selectedDetail ? detailId : undefined} aria-describedby={hint?.id === v.id ? tooltipId : undefined} onFocus={event => { const icon = event.currentTarget.querySelector<HTMLElement>('.version-rung__info'); if (note && icon)
|
|
showHint(v.id, note, icon); }} onBlur={closeHint} onClick={() => onSelect(v.id)}><span className="version-rung__node">{tr(compact ? <i>{tr(active ? <Icon name="check" size={11}/> : null)}</i> : <Icon name="model-file" size={16}/>)}</span><span className="version-rung__label"><strong>{tr(v.name)}</strong><small>{tr(compact ? v.quant : `${v.quant} · ${sizeGb(v.diskGb)} · ${fitLabel ? fitLabel(v) : VERSION_FIT_LABEL[fit.zone]}`)}</small></span>{tr(compact ? <span className="version-rung__size">{tr(sizeGb(v.diskGb))}</span> : null)}<span className="version-rung__state">{tr(v.state === 'loaded' ? 'Running' : v.state === 'loading' ? 'Loading…' : v.state === 'unloading' ? 'Unloading…' : v.state === 'downloading' ? `${Math.round(v.progress?.pct ?? 0)}%` : !compact && recommended === v.id ? 'Recommended' : v.state === 'installed' ? 'Downloaded' : compact ? v.local ? v.state === 'error' ? 'Reconnect file' : 'Local file' : v.state === 'error' ? 'Retry download' : 'Not downloaded' : 'Available')}{tr(note ? <span className="version-rung__info" role="img" aria-label={tr("SSD spill information")} onPointerEnter={event => showHint(v.id, note, event.currentTarget)} onPointerLeave={delayClose}><Icon name="info" size={14}/></span> : null)}</span></button>
|
|
{tr(active ? selectedDetail : null)}
|
|
</Fragment>;
|
|
}))}{tr(hint ? <VersionMemoryTooltip id={tooltipId} anchor={hint.anchor} text={hint.text} onClose={closeHint} onEnter={keepHint} onLeave={delayClose}/> : null)}</div>;
|
|
}
|