diff --git a/apps/host/scripts/audit-ui.mjs b/apps/host/scripts/audit-ui.mjs index 10a79467bb..75ae80e48c 100644 --- a/apps/host/scripts/audit-ui.mjs +++ b/apps/host/scripts/audit-ui.mjs @@ -16,10 +16,15 @@ import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..'); -const APP = join(ROOT, 'src/styles/app.css'); +const STYLE_DIR = join(ROOT, 'src/styles'); const KIT_SRC = join(ROOT, '..', 'ui'); const KIT_COPY = join(ROOT, 'src/styles/kit'); +/** The app's own stylesheets, in cascade order: the last one wins. */ +const APP_SHEETS = ['app.css', 'liquid.css'] + .map((name) => ({ name, css: existsSync(join(STYLE_DIR, name)) ? readFileSync(join(STYLE_DIR, name), 'utf8') : null })) + .filter((sheet) => sheet.css !== null); + const KIT_SCALES = { radius: new Set(['8px', '14px', '20px', '24px', '9999px', '999px', '50%', '6px', '10px', '12px', '15px', '16px', '2px', '1.5px', 'inherit', '0']), fontSize: new Set(['11px', '12px', '13px', '14px', '15px', '16px', '17px', '18px', '19px', '22px', '24px', '30px', '32px', '40px', 'inherit']), @@ -66,9 +71,12 @@ const BLUR_ALLOWED = new Set([ '.menu', '.telepop', '.scrim', + ".scrim[data-open='true']", // the same scrim, once it is showing + '.dialog-scrim', // the sheet's scrim: it frosts the whole working screen '.config-savebar', // floating commit controls '.mobile-bar', // compact navigation controls '.st-toast--toned', + '.nav', // the navigation layer over the ambient depth layer ]); /** @@ -83,6 +91,7 @@ const ELEVATION_ALLOWED = new Set([ '.app[data-nav-open=\'true\'] > .nav', // dismissible navigation sheet '.st-tab[aria-checked=\'true\']', // selected segmented control '.nav-new', // primary action affordance + '.nav-new.st-btn--primary', // the same affordance, with its accent recipe '.st-drawer.sheet', '.slashmenu', '.select__pop', @@ -98,6 +107,8 @@ const ELEVATION_ALLOWED = new Set([ '.st-btn--primary', // the accent fill's own lift '.st-slider::-webkit-slider-thumb', // a control affordance: the thumb needs to read against its track '.st-toggle::after', // same: the knob needs to read against its track + '.family-switch button[aria-selected="true"]', // a selected segmented control, like .st-tab + '.native-choice__col .native-resource-choice button[data-selected="true"]', // same ]); /** @@ -110,25 +121,61 @@ const CAPSULE_CONTROLS = ['.st-btn', '.st-input', '.st-tab', '.navitem', '.navse /** Literal colours that are deliberate and documented. */ const DOCUMENTED_LITERALS = ['#05261b', '#12c68e', '#0a7a55']; +/** + * The only selector allowed to paint a gradient: the single ambient depth layer. + * + * The flat-surface rule exists so surfaces read as paper rather than decoration. + * Depth was the one thing it could not express, and the navigation material has + * nothing to sample over a flat fill. A fixed, two-field wash on the page — too + * quiet to read as a gradient at ~1.04:1 — is the smallest thing that makes the + * glass mean anything. It is body-only, it never moves, and both reduced- + * transparency gates remove it. See src/styles/liquid.css §1. + */ +const AMBIENT_SELECTORS = new Set(['body']); + const failures = []; const notes = []; const fail = (file, line, message) => failures.push(`${file}:${line} ${message}`); -/* ------------------------------------------------------------ app.css ---- */ +/* ------------------------------------------------------------ app sheets -- */ -const css = readFileSync(APP, 'utf8'); -const lines = css.split('\n'); -let selector = '(top level)'; -let inKeyframes = false; +/** + * Scan one app stylesheet for the design-system, motion and material rules. + * + * Run over every sheet in the cascade, not only app.css: a rule appended in a + * later file ships just the same, and the "audit palette" block that broke AA on + * the primary button survived precisely because it had never been scanned. + */ +function scanStylesheet(file, css) { + const lines = css.split('\n'); + let selector = '(top level)'; + let inKeyframes = false; -lines.forEach((raw, i) => { - const line = raw.replace(/\/\*.*?\*\//g, ''); - const n = i + 1; + lines.forEach((raw, i) => { + const line = raw.replace(/\/\*.*?\*\//g, ''); + const n = i + 1; - const sel = line.match(/^([^@{}\s][^{}]*)\{$/); + // Selectors are usually indented inside a media query or a nested block, so + // the line is trimmed before it is recognised. Without this every indented + // rule was attributed to "(top level)", and the material and elevation + // allowlists — which match on the selector — rejected most of the file. + const sel = line.trim().match(/^([^@{}\s][^{}]*)\{$/); if (sel) selector = sel[1].trim(); - if (/@keyframes/.test(line)) inKeyframes = true; - if (inKeyframes && /^\}/.test(line)) inKeyframes = false; + // A whole rule on one line (`a, b { … }`) never ends with `{`, so it used to + // be attributed to whatever rule ran before it — which is why a shadow on a + // segmented control was reported against `.menu .response-stats`. The rule's + // own selector is used for its declarations. + let selectorForLine = selector; + if (!sel && !inKeyframes) { + const inline = line.trim().match(/^([^@{}][^{}]*?)\s*\{/); + if (inline && /\}/.test(line)) selectorForLine = inline[1].trim(); + } + // A one-line `@keyframes name { … }` opens and closes on the same line, so it + // must not switch the tracker on: it never sees a closing brace at column 0, + // and every rule after it was then treated as part of an animation — which + // disabled the one-line selector attribution above. + if (/@keyframes/.test(line) && !/\}/.test(line)) inKeyframes = true; + if (inKeyframes && /^\}/.test(raw)) inKeyframes = false; for (const [, prop, rawValue] of line.matchAll(/([a-z-]+)\s*:\s*([^;]+);/g)) { const value = rawValue.trim(); @@ -137,24 +184,24 @@ lines.forEach((raw, i) => { if (prop === 'border-radius') { for (const part of value.split(/\s+/)) { if (!KIT_SCALES.radius.has(part) && !part.startsWith('var(') && !part.includes('%')) { - fail('app.css', n, `off-scale radius "${part}" in ${selector}`); + fail(file, n, `off-scale radius "${part}" in ${selectorForLine}`); } } } if (prop === 'font-size' && !value.startsWith('var(') && !value.includes('clamp') && !KIT_SCALES.fontSize.has(value)) { - fail('app.css', n, `off-scale font-size "${value}" in ${selector}`); + fail(file, n, `off-scale font-size "${value}" in ${selectorForLine}`); } if (prop === 'box-shadow' && !KIT_SCALES.shadow.some((re) => re.test(value))) { - fail('app.css', n, `shadow is not a kit token: "${value}" in ${selector}`); + fail(file, n, `shadow is not a kit token: "${value}" in ${selectorForLine}`); } - if (/gradient|radial|conic/.test(value) && prop.startsWith('background')) { - fail('app.css', n, `gradient in ${selector} — the system is flat`); + if (/gradient|radial|conic/.test(value) && prop.startsWith('background') && !AMBIENT_SELECTORS.has(selector)) { + fail(file, n, `gradient in ${selectorForLine} — the system is flat`); } if (/^(color|background|background-color|border-color)$/.test(prop)) { const literals = value.match(/#[0-9a-fA-F]{3,8}\b|rgba?\([^)]*\)/g); if (literals && !value.includes('data:image') && !value.includes('currentColor') && !DOCUMENTED_LITERALS.some((d) => value.includes(d))) { - fail('app.css', n, `literal colour "${value}" in ${selector} — use a token`); + fail(file, n, `literal colour "${value}" in ${selectorForLine} — use a token`); } } @@ -163,57 +210,70 @@ lines.forEach((raw, i) => { // Values must be a --st-material-* token: that is what collapses the blur // under reduced transparency, so gating cannot be forgotten. if (prop === 'backdrop-filter' || prop === '-webkit-backdrop-filter') { - if (!/^var\(--st-material-(thin|regular|thick)\)$/.test(value) && !(selector === '.scrim' && value === 'none !important')) { - fail('app.css', n, `blur must use a --st-material-* token (it carries the gating): "${value}"`); + if (!/^var\(--st-material-(thin|regular|thick)\)( !important)?$/.test(value) && !(selector === '.scrim' && value === 'none !important')) { + fail(file, n, `blur must use a --st-material-* token (it carries the gating): "${value}"`); } - if (!BLUR_ALLOWED.has(selector)) { - fail('app.css', n, `material on "${selector}", which is not an approved surface — it does not overlay moving content`); + if (!BLUR_ALLOWED.has(selectorForLine)) { + fail(file, n, `material on "${selectorForLine}", which is not an approved surface — it does not overlay moving content`); } } - if (prop === 'box-shadow' && /var\(--st-sh-(card|bar|pop)\)/.test(value) && !ELEVATION_ALLOWED.has(selector)) { - fail('app.css', n, `elevation shadow on "${selector}" — shadows are reserved for surfaces that overlap content`); + if (prop === 'box-shadow' && /var\(--st-sh-(card|bar|pop)\)/.test(value) && !ELEVATION_ALLOWED.has(selectorForLine)) { + fail(file, n, `elevation shadow on "${selectorForLine}" — shadows are reserved for surfaces that overlap content`); } if (prop === 'transition') { if (/^\d/.test(value) || /(^|[\s,])\d+m?s\b/.test(value)) { - fail('app.css', n, `raw duration in transition — use a --st-t-* token: "${value}"`); + fail(file, n, `raw duration in transition — use a --st-t-* token: "${value}"`); } for (const part of value.split(',')) { const prop0 = part.trim().split(/\s+/)[0]; if (LAYOUT_PROPS.includes(prop0)) { - fail('app.css', n, `transition on layout property "${prop0}" in ${selector}`); + fail(file, n, `transition on layout property "${prop0}" in ${selectorForLine}`); } } } if (prop === 'transition-property') { for (const p of value.split(',').map((v) => v.trim())) { - if (LAYOUT_PROPS.includes(p)) fail('app.css', n, `transition on layout property "${p}" in ${selector}`); + if (LAYOUT_PROPS.includes(p)) fail(file, n, `transition on layout property "${p}" in ${selectorForLine}`); } } if (prop === 'animation' || prop === 'animation-name') { const name = value.match(/^(st-[a-z-]+)/)?.[1]; const infinite = /infinite/.test(value); if (infinite && name && !INFINITE_OK.has(name)) { - fail('app.css', n, `looping animation "${name}" is not on the allowlist — nothing loops while idle`); + fail(file, n, `looping animation "${name}" is not on the allowlist — nothing loops while idle`); } const duration = value.match(/\b(\d+(?:\.\d+)?m?s)\b/)?.[1]; if (duration && !LOOP_DURATION_OK.has(duration)) { - fail('app.css', n, `raw animation duration "${duration}" in ${selector} — use a --st-t-* token`); + fail(file, n, `raw animation duration "${duration}" in ${selectorForLine} — use a --st-t-* token`); } } if (prop === 'animation-duration' && /^\d/.test(value) && !LOOP_DURATION_OK.has(value)) { - fail('app.css', n, `raw animation-duration "${value}" in ${selector}`); + fail(file, n, `raw animation-duration "${value}" in ${selectorForLine}`); } - } -}); + } + }); +} + +for (const sheet of APP_SHEETS) scanStylesheet(sheet.name, sheet.css); + +const css = APP_SHEETS.find((sheet) => sheet.name === 'app.css')?.css ?? ''; +const allAppCss = APP_SHEETS.map((sheet) => sheet.css).join('\n'); /* ------------------------------------------------- kit sync + motion scale -- */ for (const file of ['tokens.css', 'components.css']) { const a = join(KIT_SRC, file); const b = join(KIT_COPY, file); - if (!existsSync(a) || !existsSync(b)) { - fail('kit', 0, `${file} missing on one side`); + // Some checkouts of this branch do not carry the design-kit source (apps/ui), + // only the synced copy. There is nothing to compare against then, so the check + // reports that instead of failing every run with a condition no one can fix. + if (!existsSync(a)) { + notes.push(`kit copy: ${file} has no source in this checkout — drift check skipped`); + continue; + } + if (!existsSync(b)) { + fail('kit', 0, `${file} missing from src/styles/kit — run npm run sync:kit`); continue; } // The sync rewrites @font-face URLs to absolute; everything else must match. @@ -223,10 +283,11 @@ for (const file of ['tokens.css', 'components.css']) { } } -// Which selectors have been given the capsule radius. +// Which selectors have been given the capsule radius. Checked across the whole +// cascade: a control is a capsule wherever the rule that says so lives. const capsuled = new Set(); { - const rules = css.replace(/\/\*[\s\S]*?\*\//g, ''); + const rules = allAppCss.replace(/\/\*[\s\S]*?\*\//g, ''); for (const [, sel, body] of rules.matchAll(/([^{}]+)\{([^{}]*)\}/g)) { if (!/border-radius:\s*var\(--st-r-pill\)/.test(body)) continue; for (const part of sel.split(',')) capsuled.add(part.trim()); @@ -263,7 +324,7 @@ const referenced = new Set(); for (const file of [...readdirSync(join(ROOT, 'src'), { recursive: true })].filter((f) => /\.tsx$/.test(String(f)))) { const full = join(ROOT, 'src', String(file)); if (!statSync(full).isFile()) continue; - for (const m of readFileSync(full, 'utf8').matchAll(/name="([a-z-]+)"/g)) referenced.add(m[1]); + for (const m of readFileSync(full, 'utf8').matchAll(/<(?:Icon|IconBtn)\s[^>]*?\bname="([a-z-]+)"/g)) referenced.add(m[1]); } for (const name of referenced) { if (!symbols.has(name)) fail('src', 0, `icon "${name}" is referenced but not in the sprite — run npm run sync:kit`); diff --git a/apps/host/scripts/browser.mjs b/apps/host/scripts/browser.mjs new file mode 100644 index 0000000000..30e32b1534 --- /dev/null +++ b/apps/host/scripts/browser.mjs @@ -0,0 +1,54 @@ +/** + * Where the Chromium binary the probes drive actually lives. + * + * The probes launched a fixed macOS cache path, so on Windows and Linux they + * printed "No cached Chromium found" and every runtime gate (contrast, measure, + * luminance, motion) was skipped rather than run. Resolution is now a single + * place with the same order everywhere: + * + * 1. STRATA_CHROME — an explicit override, for a CI image or a second Chrome + * 2. the cached Playwright build (macOS, the original platforms) + * 3. an installed browser: Chrome, Edge, Chromium + * + * `requireChromium` exits with the harness message the scripts already used, so + * a machine with no browser at all still fails loudly instead of silently + * passing a gate. + */ +import { existsSync } from 'node:fs'; +import { join } from 'node:path'; +import { homedir } from 'node:os'; + +const PLAYWRIGHT_MAC = [ + join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), + join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), +]; + +const INSTALLED = [ + // Windows + 'C:/Program Files/Google/Chrome/Application/chrome.exe', + 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', + 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', + 'C:/Program Files/Microsoft/Edge/Application/msedge.exe', + // macOS + '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', + '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', + // Linux + '/usr/bin/google-chrome', + '/usr/bin/google-chrome-stable', + '/usr/bin/chromium', + '/usr/bin/chromium-browser', +]; + +export function findChromium() { + const candidates = [process.env.STRATA_CHROME, ...PLAYWRIGHT_MAC, ...INSTALLED].filter(Boolean); + return candidates.find((path) => existsSync(path)) ?? null; +} + +export function requireChromium() { + const path = findChromium(); + if (!path) { + console.error('No Chromium found. Set STRATA_CHROME, or install Chrome, Edge or Chromium.'); + process.exit(2); + } + return path; +} diff --git a/apps/host/scripts/contrast.mjs b/apps/host/scripts/contrast.mjs index 1161f3d7be..c829c8d995 100644 --- a/apps/host/scripts/contrast.mjs +++ b/apps/host/scripts/contrast.mjs @@ -19,13 +19,11 @@ import { chromium } from 'playwright-core'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); if (!executablePath) { console.error('No cached Chromium found. Run `npm run shot -- x.png ` once to confirm the harness.'); diff --git a/apps/host/scripts/flow.mjs b/apps/host/scripts/flow.mjs index eba86aff21..e60936d013 100644 --- a/apps/host/scripts/flow.mjs +++ b/apps/host/scripts/flow.mjs @@ -7,11 +7,9 @@ import { chromium } from 'playwright-core'; import { existsSync, mkdirSync } from 'node:fs'; import { join, resolve } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; const flow = process.argv[2] ?? 'chat'; diff --git a/apps/host/scripts/luminance.mjs b/apps/host/scripts/luminance.mjs index 890fff4dfc..0f745bb7d7 100644 --- a/apps/host/scripts/luminance.mjs +++ b/apps/host/scripts/luminance.mjs @@ -25,6 +25,7 @@ import { chromium } from 'playwright-core'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; /** Anything at or above this projected area is "large". Roughly a 64×64 block. */ @@ -43,10 +44,7 @@ const MIN_THICKNESS = 32; /** Ceiling for the relative luminance of a large surface, in dark mode. */ const CEILING = 0.15; -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); if (!executablePath) { console.error('No cached Chromium found.'); diff --git a/apps/host/scripts/measure.mjs b/apps/host/scripts/measure.mjs index 91c817e1ff..1c9061392f 100644 --- a/apps/host/scripts/measure.mjs +++ b/apps/host/scripts/measure.mjs @@ -20,15 +20,13 @@ import { chromium } from 'playwright-core'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; const MIN = 45; const MAX = 75; -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); if (!executablePath) { console.error('No cached Chromium found.'); diff --git a/apps/host/scripts/motion.mjs b/apps/host/scripts/motion.mjs index 0ba4665142..ca5994a9d5 100644 --- a/apps/host/scripts/motion.mjs +++ b/apps/host/scripts/motion.mjs @@ -21,6 +21,7 @@ import { promisify } from 'node:util'; import { existsSync, mkdirSync, rmSync, readdirSync } from 'node:fs'; import { join, resolve } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; const run = promisify(execFile); const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; @@ -28,10 +29,7 @@ const ROOT = resolve(process.env.STRATA_SHOTS ?? '.shots'); const TMP = join(ROOT, 'motion-frames'); mkdirSync(TMP, { recursive: true }); -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); const ffmpeg = [ join(homedir(), 'Library/Caches/ms-playwright/ffmpeg-1011/ffmpeg-mac'), diff --git a/apps/host/scripts/motionbudget.mjs b/apps/host/scripts/motionbudget.mjs index 129b5005e4..76fa34742b 100644 --- a/apps/host/scripts/motionbudget.mjs +++ b/apps/host/scripts/motionbudget.mjs @@ -20,14 +20,12 @@ import { chromium } from 'playwright-core'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { homedir } from 'node:os'; +import { requireChromium } from './browser.mjs'; const BASE = process.env.STRATA_URL ?? 'http://localhost:5199'; const BUDGET = 1.2; -const executablePath = [ - join(homedir(), 'Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing'), - join(homedir(), 'Library/Caches/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-mac-arm64/chrome-headless-shell'), -].find((p) => existsSync(p)); +const executablePath = requireChromium(); if (!executablePath) { console.error('No cached Chromium found. Run `npm run shot -- x.png ` once to confirm the harness.'); diff --git a/apps/host/src/app/App.tsx b/apps/host/src/app/App.tsx index 7604306c97..1881a3f490 100644 --- a/apps/host/src/app/App.tsx +++ b/apps/host/src/app/App.tsx @@ -9,7 +9,7 @@ import { Sidebar } from './Sidebar'; import { CommandPalette } from './CommandPalette'; import { ShortcutsDialog } from './Shortcuts'; import { FolderPathDialog } from '../components/FolderPathDialog'; -import { handleAppShortcut, runCommand } from '../lib/commands'; +import { MOD, handleAppShortcut, runCommand } from '../lib/commands'; import { useMedia } from '../lib/responsive'; import { Btn, Dialog, IconBtn, Toasts } from '../components/ui'; import { Brand } from '../components/Brand'; @@ -111,6 +111,9 @@ function ConnectionBar() { * way out. Everything else on this screen is the conversation. */ function FocusBar() { + // The hints are chords, not decorations: on Windows the modifier is Ctrl and + // Alt is spelled out, because ⌘ and ⌥ are not on that keyboard. + const mac = MOD === '⌘'; const native = useNative(), nativeCurrent = native?.instances.find(i => i.id === native.defaultId); const library = useStore((s) => s.library); const monitor = useStore((s) => s.monitor); @@ -139,11 +142,11 @@ function FocusBar() { {/* A chord reads as one key: the two caps sit tight together, with the space before the label doing the separating. */} - ⌥↑ - ⌥↓ + {mac ? '⌥↑' : 'Alt+↑'} + {mac ? '⌥↓' : 'Alt+↓'} {tr("turns")} - ⌘↓{tr(" latest")} + {mac ? '⌘↓' : 'Ctrl+↓'}{tr(" latest")} {tr("Esc")}{tr(" leave")} diff --git a/apps/host/src/app/CommandPalette.tsx b/apps/host/src/app/CommandPalette.tsx index 66a86c51de..3f0f003767 100644 --- a/apps/host/src/app/CommandPalette.tsx +++ b/apps/host/src/app/CommandPalette.tsx @@ -136,7 +136,7 @@ export function CommandPalette({ open }: { setQuery(e.target.value)} onKeyDown={onKeyDown}/> {tr("esc")} -
+
{tr(flat.length === 0 ? (
{tr("Nothing matches “{0}”. Try > for commands, # for conversations, or @ for workspaces.", [query])}
) : (grouped.map(([group, items]) => (
{tr(group)} @@ -167,6 +167,11 @@ export function CommandPalette({ open }: { }))}
))))}
+
+ Enter{tr("Open")} + + esc{tr("Close")} +
); } diff --git a/apps/host/src/app/Sidebar.tsx b/apps/host/src/app/Sidebar.tsx index 7415ec07dc..1194e31eee 100644 --- a/apps/host/src/app/Sidebar.tsx +++ b/apps/host/src/app/Sidebar.tsx @@ -10,7 +10,7 @@ import { FloatingMenu } from '../components/FloatingMenu'; import { QuitStrataDialog } from '../components/QuitStrata'; import { useAppMode } from '../lib/app-mode'; import { href, useLocation, type Route } from '../lib/router'; -import { cx, relTime } from '../lib/format'; +import { cx, relTime, relTimeShort } from '../lib/format'; import { useMedia } from '../lib/responsive'; import { recentChats, recentChatDescription } from '../lib/recent-chats'; import type { Session } from '../lib/types'; @@ -92,7 +92,7 @@ export function Sidebar({ containerRef }: {
{ setWsName(w.name); setNavOpen(false); setRenameWsId(w.id); }}/>{tr(w.id !== 'root' ? { setNavOpen(false); setRemoveWorkspaceId(w.id); }}/> : null)}
{tr(expanded ?
{tr(shown.map(s =>
- +
))} {tr(!shown.length ?

{tr(q ? 'No matching chats' : 'No chats yet')}

: null)} {tr(!q && rows.length > shown.length ? : null)} @@ -190,5 +190,5 @@ function MoreMenu({ current }: { const [quitOpen, setQuitOpen] = useState(false); const appMode = useAppMode(); const ref = useRef(null); - return <>{tr(open ? { setOpen(false); ref.current?.focus(); }}>{tr(([{ route: 'serving', label: 'Serving', icon: 'link' }, { route: 'settings', label: 'Settings', icon: 'settings' }] as const).map(d => setOpen(false)}>{tr(d.label)}))}{appMode.canQuit ? : null} : null)} setQuitOpen(false)}/>; + return <>{tr(open ? { setOpen(false); ref.current?.focus(); }}>{tr(([{ route: 'serving', label: 'Serving', icon: 'link' }, { route: 'settings', label: 'Settings', icon: 'settings' }] as const).map(d => setOpen(false)}>{tr(d.label)}))}{appMode.canQuit ? : null} : null)} setQuitOpen(false)}/>; } diff --git a/apps/host/src/components/ChatModelPicker.tsx b/apps/host/src/components/ChatModelPicker.tsx index 46e6b65651..9bc6674dc7 100644 --- a/apps/host/src/components/ChatModelPicker.tsx +++ b/apps/host/src/components/ChatModelPicker.tsx @@ -20,7 +20,7 @@ function NativeChatModelPicker() { const [open, setOpen] = useState(false), [error, setError] = useState(''); const ref = useRef(null); const current = native?.instances.find(i => i.id === native.defaultId); - return <>{tr(open ? setOpen(false)}>{tr(native?.instances.filter(i => i.status !== 'error').map(i => ))}{tr(providers?.connections.flatMap(c => c.models.map(m => )))}{tr(error ?

{tr(error)}

: null)}
: null)}; + return <>{tr(open ? setOpen(false)}>{tr(native?.instances.filter(i => i.status !== 'error').map(i => ))}{tr(providers?.connections.flatMap(c => c.models.map(m => )))}{tr(error ?

{tr(error)}

: null)}
: null)}; } function LegacyChatModelPicker() { const native = useNative(); diff --git a/apps/host/src/components/ComposerControls.tsx b/apps/host/src/components/ComposerControls.tsx index 7156199b04..bbebd5ee2b 100644 --- a/apps/host/src/components/ComposerControls.tsx +++ b/apps/host/src/components/ComposerControls.tsx @@ -45,6 +45,25 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas const remote = useStore(s => s.remoteModel), providers = useStore(s => s.providers); const apiModel = providers?.connections.find(c => c.id === remote?.connectionId)?.models.find(m => m.id === remote?.modelId); const [menu, setMenu] = useState(false), [preferences, setPreferences] = useState<'mode' | 'thinking' | null>(null), [reading, setReading] = useState(false); + + // The mode menu prints 1–3 beside its rows. They were decoration: make those + // keys pick the mode while the menu is open, and leave modified keys to the app. + useEffect(() => { + if (preferences !== 'mode') + return; + const onKey = (event: KeyboardEvent) => { + if (event.metaKey || event.ctrlKey || event.altKey) + return; + const option = modes[Number(event.key) - 1]; + if (!option) + return; + event.preventDefault(); + setChatPreferences(session?.id, { mode: option.value }); + setPreferences(null); + }; + window.addEventListener('keydown', onKey); + return () => window.removeEventListener('keydown', onKey); + }, [preferences, session?.id]); const [urlOpen, setUrlOpen] = useState(false), [url, setUrl] = useState(''), [error, setError] = useState(''); const files = useRef(null), folder = useRef(null), previewFile = useRef(null); const trigger = useRef(null), modeTrigger = useRef(null), thinkingTrigger = useRef(null); diff --git a/apps/host/src/components/NativeModels.tsx b/apps/host/src/components/NativeModels.tsx index 1cdcb1119d..e9bbc3415d 100644 --- a/apps/host/src/components/NativeModels.tsx +++ b/apps/host/src/components/NativeModels.tsx @@ -50,8 +50,20 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine const [deleting, setDeleting] = useState(null); const families = nativeCatalogModels(native?.catalog?.families ?? []); const expertSection = useRef(null); - useEffect(() => { if (expert) - expertSection.current?.scrollIntoView({ block: 'start', behavior: 'smooth' }); }, [expert]); + // The card is inserted above the fold and the browser's scroll anchoring + // immediately compensates by scrolling down, which cancelled the smooth + // scroll started in the same frame: the page stopped 121px in and clipped + // the cards above. Scroll after the layout has settled, and never animate + // when motion is reduced. + useEffect(() => { + if (!expert) + return; + const frame = requestAnimationFrame(() => expertSection.current?.scrollIntoView({ + block: 'start', + behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth', + })); + return () => cancelAnimationFrame(frame); + }, [expert]); const selectedFamily = families.find(f => f.family === family || f.sizes.some(size => size.sourceFamily === family)) ?? families[0], selectedSize = selectedFamily?.sizes.find(s => s.id === size) ?? selectedFamily?.sizes[0]; const installed = native?.installed?.models.find(m => m.model === selectedSize?.id); // The model that is running is shown as running, with Unload: not offered for loading again. @@ -189,7 +201,7 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine
{tr(selectedFamily && (!selectedSize || selectedSize.needsNewerEngine) ? <>

{tr("This model needs a newer engine.")}

{tr("Update your engine or import a local GGUF for this model.")}

{ setSettingsSection('Engine'); go('settings'); }}>{tr("Update engine")}{tr("Use a local GGUF\u2026")} : null)}{tr(!selectedFamily ? <>

{tr("Set up Strata")}

{tr("Connect your local installation to choose an optimized model.")}

{ setSettingsSection('Engine'); go('settings'); })}>{tr("Connect engine")}{tr(native?.error ?

{tr(native.error)}

: null)}{tr("Other local models")} : null)} {tr(selectedSize ? <>
{tr("Version")} { const f = families.find(f => f.family === v.family || f.sizes.some(s => s.sourceFamily === v.family)); if (!f) - return; presetPending.current = true; setFamily(f.family); setSize(f.sizes.find(s => s.model === v.model && (s.sourceFamily === v.family || f.family === v.family))?.id ?? ''); setContext(v.context ?? 32768); setVision(v.vision ?? 'no'); setKv(v.kv ?? 'int8'); setLowRam(v.low_ram ?? 'auto'); }}/> setManage(true)}>{tr("Manage models")}
+ return; presetPending.current = true; setFamily(f.family); setSize(f.sizes.find(s => s.model === v.model && (s.sourceFamily === v.family || f.family === v.family))?.id ?? ''); setContext(v.context ?? 32768); setVision(v.vision ?? 'no'); setKv(v.kv ?? 'int8'); setLowRam(v.low_ram ?? 'auto'); }}/> setManage(true)}>{tr("Manage models")}
{ const f = families.find(f => f.sizes.some(s => s.id === id)); if (f) { setFamily(f.family); setSize(id); setError(''); } }} onOwnGguf={() => (onImport ?? onOtherModels)()}/>
{tr(noFit ?

{tr("May run slower \u00B7 Model data can be read from SSD.")}

: null)} {tr(selectedSize?.multi_file && deepseekContextNote(context) ?

{tr(deepseekContextNote(context))}

: null)} @@ -214,12 +226,12 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine {tr(expert && IMAGE_GENERATION_VISIBLE ? <>
{tr("Image generation ")}{tr("Optional")} { }}/>
: null)} {tr(expert ?

{tr("Expert settings")}

{tr(tunedNow ?

{tr("Showing the values of your tuning '{0}'.", [tunedNow.name])}

: null)}
: null)}
- + !pending && setPlan(null)} actions={<> setPlan(null)}>{tr("Cancel")} void download()}>{tr(installed?.ready ? "Apply & load" : "Download & load")}}>

{tr(plan?.plan?.title ?? selectedFamily?.title)}{tr(installed?.ready ? null : <>{tr(" \u00B7 approximately ")}{tr(plan?.plan?.download_gb ?? selectedSize?.download_gb)}{tr(" GB")})}

{tr(plan?.drafting?.needed ?

{tr("Choosing DFlash2 also downloads its drafter: about {0} GB, once. If it does not fit in graphics memory, the model uses the MTP instead.", [plan.drafting.gb])}

: null)}{tr(installed?.ready ?

{tr("The model files are already on this computer. Nothing will be downloaded; only the settings you chose are applied.")}

: null)}{tr(plan?.plan?.disk_short ? : null)}{tr(installed?.ready ?

{tr("Any currently loaded native models will be unloaded first.")}

: <>

{tr("Existing files are checked and reused. Any currently loaded native models will be unloaded before preparing files.")}

{tr("Your computer may feel slower while weights load. You can stop the download and resume later.")}

)}{tr(selectedSize?.images ?

{tr("Vision encoder files are included. Picture reading loads only when enabled.")}

: null)}
setDeleting(null)}/> - setManage(false)} actions={ setManage(false)}>{tr("Done")}}>
+ setManage(false)} actions={ setManage(false)}>{tr("Done")}}>
{tr(downloaded.some(m => m.ready || m.diskGb) ?
{tr(downloaded.filter(m => m.ready || m.diskGb).map(m => { const v = allSizes.find(x => x.id === m.model), loaded = native?.instances.some(i => i.model === m.model && i.status === 'ready'); return
{tr(v ? `${catalogVersionLabel(v)}` : m.model_name ?? m.model)}{tr(v ? v.model : m.model)}{tr(m.diskGb ? ` · ${sizeGb(m.diskGb)}` : '')} {tr(loaded ? 'Loaded' : 'Downloaded')} diff --git a/apps/host/src/components/NativeOperations.tsx b/apps/host/src/components/NativeOperations.tsx index ed454fb332..8551025fc0 100644 --- a/apps/host/src/components/NativeOperations.tsx +++ b/apps/host/src/components/NativeOperations.tsx @@ -116,7 +116,7 @@ export function NativeOperations() { return

{tr("Update component")}

{tr(update === 'available' ? 0} onClick={() => setConfirm(true)}>{tr("Update available")} : null)}{tr(update !== 'available' ? void checkForUpdates()}>{tr(update === 'checking' ? 'Checking…' : 'Check for updates')} : null)}

{tr("Update the engine for this computer. Your models and settings are kept.")}

{tr(update === 'current' ?

{tr("Up to date")}

: null)}{tr(checkError ?

{tr(checkError)}

: null)}{tr(update === 'available' && (native?.instances.length ?? 0) > 0 ?

{tr("Open Models and unload the running native models first.")}

: null)}

{tr("Diagnostics")}

setShowLogs(true)}>{tr("View logs")}

{tr("Downloads, preparation and engine failures include their original messages here.")}

{tr(native?.jobs.filter(j => j.state === 'error').slice(-3).map(j => ))}
- setShowLogs(false)} actions={<> void saveLogs()}>{tr(saving ? 'Working…' : 'Save logs')} setShowLogs(false)}>{tr("Close")}}> + setShowLogs(false)} actions={<> void saveLogs()}>{tr(saving ? 'Working…' : 'Save logs')} setShowLogs(false)}>{tr("Close")}}>
{logs.length ? logs.map(l => `${l.at} · ${l.line}`).join(String.fromCharCode(10)) : tr('No engine messages yet.')}
{tr(saved ?

{tr("Saved to {0}", [saved])}

: null)}
diff --git a/apps/host/src/components/NativePresets.tsx b/apps/host/src/components/NativePresets.tsx index dec80366d0..dea5e7480f 100644 --- a/apps/host/src/components/NativePresets.tsx +++ b/apps/host/src/components/NativePresets.tsx @@ -29,6 +29,6 @@ export function NativePresets({ values, onApply }: { setError('Browser storage is full. Free space before saving settings.'); return false; } } - return <>{tr(open ? setOpen(false)}>

{tr("Saved settings")}

{tr(items.map(item => ))}{tr(!items.length ?

{tr("Save a setup to use it again.")}

: null)}
: null)} setSave(false)} actions={<> setSave(false)}>{tr("Done")} { if (persist([...items, { id: crypto.randomUUID(), name: name.trim(), values }])) + return <>{tr(open ? setOpen(false)}>

{tr("Saved settings")}

{tr(items.map(item => ))}{tr(!items.length ?

{tr("Save a setup to use it again.")}

: null)}
: null)} setSave(false)} actions={<> setSave(false)}>{tr("Done")} { if (persist([...items, { id: crypto.randomUUID(), name: name.trim(), values }])) setSave(false); }}>{tr("Save")}}>{tr(items.map(item =>
{item.name} persist(items.filter(i => i.id !== item.id))}>{tr("Remove")}
))}{tr(error ?

{tr(error)}

: null)}
; } diff --git a/apps/host/src/components/TimeSkipWorking.tsx b/apps/host/src/components/TimeSkipWorking.tsx index 5b22a46669..ab9b618af3 100644 --- a/apps/host/src/components/TimeSkipWorking.tsx +++ b/apps/host/src/components/TimeSkipWorking.tsx @@ -26,7 +26,7 @@ export function TimeSkipWorking({ run, sessionId }: { run: TimeSkipRun; sessionI {fork ? : null}
{activityWords(run.job)}{clock(now - run.startedAt)} - {fork ? null :
}
+ {fork ? null :
}
{ setStopping(true); void stopTimeSkip(sessionId, run.id).finally(() => setStopping(false)); }}>{tr("Stop")}
; @@ -39,7 +39,7 @@ function Lane({ name, lane, waitingText }: { name: string; lane: ForkLane | null const words = !lane ? waitingText : lane.waiting ? waitingText : lane.line || (lane.text ? lane.text : tr('Starting…')); return
{name} -
+
{words}
; } diff --git a/apps/host/src/components/TuneRunView.tsx b/apps/host/src/components/TuneRunView.tsx index b9c40bbae7..3133455d87 100644 --- a/apps/host/src/components/TuneRunView.tsx +++ b/apps/host/src/components/TuneRunView.tsx @@ -51,7 +51,7 @@ export function TuneRunView({ progress, ratio, saving }: { progress: TuneProgres {tr("Speed now")}
{now != null ? fmt(now) : '—'}{tr("tokens per second")}
x.tok_s)}/> -
+

{left != null ? tr("about {0} min left", [left]) : tr("This takes about 20 minutes.")}

    {speeds.slice(-6).map((x, i) =>
  • {x.label === 'base' ? tr("Your settings") : x.label} base ? 'true' : undefined}>{fmt(x.tok_s)}
  • )}
diff --git a/apps/host/src/components/UsageDashboard.tsx b/apps/host/src/components/UsageDashboard.tsx index 12484d9858..5196ae2f14 100644 --- a/apps/host/src/components/UsageDashboard.tsx +++ b/apps/host/src/components/UsageDashboard.tsx @@ -75,6 +75,6 @@ export function UsageDashboard({ loaded }: { )}
- {tr(!canChat ? go('models')}>{tr("Choose a model")} : null)} + {tr(!canChat ? go('models')}>{tr("Choose a model")} : null)} ; } diff --git a/apps/host/src/components/ui.tsx b/apps/host/src/components/ui.tsx index 48f8464570..31ccc12645 100644 --- a/apps/host/src/components/ui.tsx +++ b/apps/host/src/components/ui.tsx @@ -532,6 +532,9 @@ export function ErrorNotice({ message, next, action, onRetry, detail, secondary const known = plain.kind !== 'plain'; const nextStep = known ? (plain.next ? tr(plain.next) : next) : next; const raw = detail ?? (known ? plain.detail : undefined); - return
{tr(known ? plain.message : userError(message))}{tr(nextStep ?

{tr(nextStep)}

: null)}{tr(raw ?
{tr("Details")}
{raw}
: null)}
{tr(onRetry ? (secondary ?
{tr(action ?? 'Try again')}{tr(secondary.label)}
: {tr(action ?? 'Try again')}) : null)}
; + // An unrecognised failure still goes through plainFailure: it peels an + // `{"error":"…"}` body down to the sentence, where userError only capitalised + // the JSON and showed an object to the person. + return
{tr(plain.message)}{tr(nextStep ?

{tr(nextStep)}

: null)}{tr(raw ?
{tr("Details")}
{raw}
: null)}
{tr(onRetry ? (secondary ?
{tr(action ?? 'Try again')}{tr(secondary.label)}
: {tr(action ?? 'Try again')}) : null)}
; } export function PreviewBadge() { const demo = useStore(s => s.library?.mode === 'simulated'); return demo ? {tr("Preview build")} : null; } diff --git a/apps/host/src/lib/format.ts b/apps/host/src/lib/format.ts index f0e6623e6c..5d67a54168 100644 --- a/apps/host/src/lib/format.ts +++ b/apps/host/src/lib/format.ts @@ -35,6 +35,29 @@ export function relTime(iso: string | number | Date): string { return `${days}d ago`; return new Date(iso).toLocaleDateString(localeTag(), { month: 'short', day: 'numeric' }); } +/** + * The same age without the words: "9m", "3h", "5d". + * + * A sidebar row has no width to spare, and "26m ago" cost a third of the space a + * chat title needed (the title was the thing being cut). The unit carries the + * meaning on its own; the sentence form stays everywhere there is room for it. + */ +export function relTimeShort(iso: string | number | Date): string { + const then = new Date(iso).getTime(); + const diff = Date.now() - then; + if (diff < 45000) + return 'now'; + const mins = Math.round(diff / 60000); + if (mins < 60) + return `${mins}m`; + const hours = Math.round(mins / 60); + if (hours < 24) + return `${hours}h`; + const days = Math.round(hours / 24); + if (days < 7) + return `${days}d`; + return new Date(iso).toLocaleDateString(localeTag(), { month: 'short', day: 'numeric' }); +} export function duration(ms: number): string { if (ms < 1000) return `${Math.round(ms)} ms`; diff --git a/apps/host/src/lib/plain-errors.ts b/apps/host/src/lib/plain-errors.ts index ec212527cb..844f2e9d5c 100644 --- a/apps/host/src/lib/plain-errors.ts +++ b/apps/host/src/lib/plain-errors.ts @@ -49,7 +49,7 @@ const RULES: Rule[] = [ /** The message as a person should read it, its next step, and the original text for the Details disclosure. */ export function plainFailure(raw: string | null | undefined): PlainFailure { - const text = String(raw ?? '').replace(/^\s*Fixture:\s*/i, '').trim(); + const text = unwrapErrorPayload(String(raw ?? '').replace(/^\s*Fixture:\s*/i, '').trim()); for (const rule of RULES) { const m = text.match(rule.match); if (!m) continue; @@ -58,6 +58,33 @@ export function plainFailure(raw: string | null | undefined): PlainFailure { return { kind: 'plain', message: text.replace(/^./, c => c.toUpperCase()) }; } +/** + * Reduce an error body to the sentence inside it. + * + * The host answers a refused request with `{"error":"…"}` and the fetch layer + * forwards `HTTP 400: {"error":"…"}`; both reached the screen verbatim, so a + * person was shown a JSON object where a sentence belonged. The wrapper is + * peeled here — before the rules run, so a wrapped message still matches its + * own rule — and anything that is not a recognisable error body is returned + * untouched. + */ +function unwrapErrorPayload(text: string): string { + // `HTTP 400: {…}` or a bare `{…}` body. + const body = text.replace(/^HTTP\s+\d{3}\s*:\s*/i, '').trim(); + if (!body.startsWith('{')) return text; + try { + const parsed = JSON.parse(body) as Record; + // FastAPI and the host both use `detail`/`error`/`message`, and `detail` + // is itself sometimes an object with a `message`. + const detail = parsed.detail; + const candidate = [parsed.error, parsed.message, typeof detail === 'string' ? detail : (detail as Record | undefined)?.message] + .find((value): value is string => typeof value === 'string' && value.trim().length > 0); + return candidate ? candidate.trim() : text; + } catch { + return text; + } +} + /** Translated copy of a failure, ready to show. */ export function plainFailureText(raw: string | null | undefined) { const f = plainFailure(raw); diff --git a/apps/host/src/lib/runtime-models.ts b/apps/host/src/lib/runtime-models.ts index b974cd29cc..9f5691e9a0 100644 --- a/apps/host/src/lib/runtime-models.ts +++ b/apps/host/src/lib/runtime-models.ts @@ -26,4 +26,8 @@ export function scopedMonitor(live:MonitorState|null,runtime:RuntimeModels|null, totals:{...live.totals,tokensIn:count('tokensIn'),tokensOut:count('tokensOut'),requests:done.length,cachedTokens:0,uncachedTokens:count('tokensIn'),promptMs:undefined,decodeMs:undefined,avgTps:0} }; } -export const instanceLabel=(i:RuntimeModel)=>`${i.family}${i.family.toLowerCase().endsWith(i.name.toLowerCase())?"":` · ${i.name}`}${i.memory.context>0?` · ${i.memory.context/1024}K`:""}`; +// A quantisation tag is written the way the rest of the app writes it: Q2_0, not q2_0. +// The catalogue stores the id in lower case, so labels read as a typo beside the +// Models screen without this. +const quantLabel=(name:string)=>/^q\d/i.test(name)?name.toUpperCase():name; +export const instanceLabel=(i:RuntimeModel)=>`${i.family}${i.family.toLowerCase().endsWith(i.name.toLowerCase())?"":` · ${quantLabel(i.name)}`}${i.memory.context>0?` · ${i.memory.context/1024}K`:""}`; diff --git a/apps/host/src/main.tsx b/apps/host/src/main.tsx index 446e060a56..dec0076a68 100644 --- a/apps/host/src/main.tsx +++ b/apps/host/src/main.tsx @@ -28,3 +28,7 @@ import './styles/onboarding.css'; import './styles/board.css'; import './styles/gpu-roles.css'; + +// Loaded last: the shared depth, material and interaction treatment. See the +// header of the file for the order of the layers and why it sits here. +import './styles/liquid.css'; diff --git a/apps/host/src/screens/Monitor.tsx b/apps/host/src/screens/Monitor.tsx index d75db79ac7..a359797fbe 100644 --- a/apps/host/src/screens/Monitor.tsx +++ b/apps/host/src/screens/Monitor.tsx @@ -182,12 +182,12 @@ function LegacyMonitorScreen({ native }: { {tr(multipleModels ?

{tr("Model performance")}

{tr(runtime?.instances.map(i => { const recent = (data.requests ?? []).find(r => r.instanceId === i.id); const writing = i.phase === 'generating' || i.phase === 'thinking', reading = i.phase === 'reading'; return ; }))}
{tr("Model / device")}{tr("Generating tok/s")}{tr("Reading tok/s")}{tr("State")}{tr("Active / queued")}
{tr(deviceLabel(i.gpuIds, inventory))}{tr(number(writing ? i.outputTps : recent?.tps, 1))}{tr(writing ? 'Now' : recent ? 'Last request' : 'No request yet')}{tr(number(reading ? i.promptTps : recent?.promptTps, 0))}{tr(reading ? 'Now' : recent ? 'Last request' : 'No request yet')}{tr(i.phase)}{tr(runtime.mode === 'simulated' ? {tr("Illustrative")} : null)}{tr(number(i.active))} / {tr(number(i.queued))}
: null)} {tr(multipleModels ?

{tr(selectedInstance ? selectedInstance.gpuIds.length ? 'Requests, context and speed are scoped to this model. GPU readings include all work on the selected devices.' : 'CPU-only model. Requests and context are scoped to this model; system metrics are shared host measurements.' : 'Select a model for its context and speed. GPU readings and system RAM are shared host measurements.')}

: null)}
-

{tr(multipleScope ? 'Model activity' : 'Model state')}

{tr([{ id: 'idle', label: 'Idle' }, { id: 'reading', label: 'Reading' }, { id: 'generating', label: 'Generating' }, { id: 'queued', label: 'Queued' }, { id: 'error', label: 'Error' }].map(s => 0}>{tr(s.label)}{tr(s.id === 'queued' && data.queue.waiting > 0 ? ` (${data.queue.waiting})` : '')}))}
{tr(devices.length > 1 ? ({ value: p.id, label: `CPU ${i + 1} · ${p.model}` }))]} onChange={setCpuSelection}/> : null)}
+

{tr(multipleScope ? 'Model activity' : 'Model state')}

{tr({tr(phase === 'reading' ? 'Reading' : writing ? 'Generating' : phase === 'queued' ? 'Queued' : phase === 'error' ? 'Error' : phase === 'loading' ? 'Loading' : 'Idle')}{tr(phase === 'queued' && data.queue.waiting > 0 ? ` (${data.queue.waiting})` : '')})}
{tr(devices.length > 1 ? ({ value: p.id, label: `CPU ${i + 1} · ${p.model}` }))]} onChange={setCpuSelection}/> : null)}
{tr(multipleScope ? `${number(data.queue.running)} active · ${number(data.queue.waiting)} queued` : data.phase === 'idle' ? 'Waiting for a request' : data.phaseLabel)}{tr(statusDetail)}
{tr(!multipleScope ? : null)}
- {tr(!multipleScope ?
{tr(number(prefill))}{tr(hasReading(prefill) ? {tr("t/s")} : null)}
{tr(data.phase === 'reading' ? 'Prefill now' : writing ? 'Prefill this request' : last ? 'Prefill last request' : 'Prefill')}
} chart={ throughputKnown ? s.outputTps : null)} secondary={{ data: history.map(s => throughputKnown ? s.promptTps : null), label: 'Prefill', tone: 'var(--st-chart-prefill)' }} tone="var(--st-chart-decode)" unit="t/s" timestamps={timestamps}/>}/> : null)} + {tr(!multipleScope ?
{tr(number(prefill))}{tr(hasReading(prefill) ? {tr("tok/s")} : null)}
{tr(data.phase === 'reading' ? 'Prefill now' : writing ? 'Prefill this request' : last ? 'Prefill last request' : 'Prefill')}
} chart={ throughputKnown ? s.outputTps : null)} secondary={{ data: history.map(s => throughputKnown ? s.promptTps : null), label: 'Prefill', tone: 'var(--st-chart-prefill)' }} tone="var(--st-chart-decode)" unit="tok/s" timestamps={timestamps}/>}/> : null)} @@ -205,7 +205,10 @@ function LegacyMonitorScreen({ native }: {

{tr("Recent requests")}

{tr(requests.length > 12 ? setShowAll(!showAll)}>{tr(showAll ? 'Show fewer' : `Show all (${requests.length})`)} : null)}
{tr(multipleModels ? : null)}{tr(visibleRequests.length ? visibleRequests.map(r => {tr(multipleModels ? : null)}) : )}
{tr("Time")}{tr("Status")}{tr("Model")}{tr("Prompt")}{tr("Reused")}{tr("Output")}{tr("Tok/s")}{tr("VRAM hit rate")}{tr("Duration")}
{tr(new Date(r.at).toLocaleTimeString(localeTag(), { hour: '2-digit', minute: '2-digit', second: '2-digit' }))}{tr(requestStatus(r))}{tr(r.usageSource === 'demo' ? {tr("Illustrative")} : null)}{tr(r.model)}{tr(number(r.tokensIn))}{tr(number(r.cachedTokens))}{tr(number(r.tokensOut))}{tr(number(r.tps, 1))}{tr(hasReading(r.hitRate) ? `${number(r.hitRate * 100, 1)}%` : '—')}{tr(hasReading(r.pcieShare) && r.pcieShare > 0 ? +{tr(number(r.pcieShare * 100, 1))}{tr("% PCIe")} : null)}{tr(r.durationMs ? duration(r.durationMs) : '—')}
{tr("No requests yet")}
- {tr(data.totals.requests > 0 ?

{requestSummary({ requests: data.totals.requests, output: outputSpeed, reading: promptSpeed, reused: data.totals.cachedTokens }, { number, tokens })}

: null)} + {/* One request is already the row above: the aggregate sentence would only + restate it, and in English it also read “In 1 requests”. Show it from two + requests on, where it carries information the table cannot. */} + {tr(data.totals.requests > 1 ?

{requestSummary({ requests: data.totals.requests, output: outputSpeed, reading: promptSpeed, reused: data.totals.cachedTokens }, { number, tokens })}

: null)}

{tr("Conversation cache")}

{tr(lastReused ? {tr("{0} of {1} requests reused prompt tokens", [number(cache?.requestsReused ?? reused.filter(r => (r.cachedTokens ?? 0) > 0).length),number(cache?.requests ?? requests.length)])} : null)}
diff --git a/apps/host/src/screens/Serving.tsx b/apps/host/src/screens/Serving.tsx index 0eb86676d1..ca169b6a4a 100644 --- a/apps/host/src/screens/Serving.tsx +++ b/apps/host/src/screens/Serving.tsx @@ -87,7 +87,7 @@ export function ServingScreen() {

{tr("Set ")}model{tr(" in each request. Each model has its own queue.")}{tr(runtime?.mode === 'simulated' ? ' Design preview · responses are illustrative.' : '')}

: null)}

{tr(scopeStats.running)}{tr(" active \u00B7 ")}{tr(scopeStats.waiting)}{tr(" queued \u00B7 ")}{tr(scopeStats.completed)}{tr(" completed")}

{tr(multipleModels ? setQuery(e.target.value)}/>
- {tr(requests.length ?
{tr(multipleModels ? : null)}{tr(requests.map(r => {tr(multipleModels ? : null)}))}
{tr("Client / endpoint")}{tr("Model")}{tr("Status")}{tr("Tokens in / out")}
{tr(r.client)}
{tr(r.endpoint)}
{r.model}{tr({tr(r.cancelRequested ? r.cancellable ? 'Cancelling…' : 'Cancelled' : r.state.charAt(0).toUpperCase() + r.state.slice(1))})}{tr(tokens(r.tokensIn))} / {tr(tokens(r.tokensOut))}
{tr(r.usageSource === 'demo' ? 'Simulated' : r.usageSource === 'reported' ? 'Reported by model' : 'Usage unavailable')}
{tr(r.durationMs ? duration(r.durationMs) : '—')}
: { setQuery(''); setFilter('all'); setModelFilter('all'); }}>{tr("Clear filters")} : setGuide(true)}>{tr("Connect an app")})}/>)}
+ {tr(requests.length ?
{tr(multipleModels ? : null)}{tr(requests.map(r => {tr(multipleModels ? : null)}))}
{tr("Client / endpoint")}{tr("Model")}{tr("Status")}{tr("Tokens in / out")}
{tr(r.client)}
{tr(r.endpoint)}
{r.model}{tr({tr(r.cancelRequested ? r.cancellable ? 'Cancelling…' : 'Cancelled' : r.state.charAt(0).toUpperCase() + r.state.slice(1))})}{tr(tokens(r.tokensIn))} / {tr(tokens(r.tokensOut))}
{tr(r.usageSource === 'demo' ? 'Simulated' : r.usageSource === 'reported' ? 'Reported by model' : 'Usage unavailable')}
{tr(r.durationMs ? duration(r.durationMs) : '—')}
: { setQuery(''); setFilter('all'); setModelFilter('all'); }}>{tr("Clear filters")} : setGuide(true)}>{tr("Connect an app")})}/>)} {tr(error ? : null)} setGuide(false)} headerActions={
} sheet>
{tr(multipleModels ?