diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs index f8438dbe..8bc2948f 100644 --- a/apps/host/server/index.mjs +++ b/apps/host/server/index.mjs @@ -32,7 +32,7 @@ import { findBrowser, findPlaywrightMcp } from './agent/browser-probe.mjs'; */ import http from 'node:http'; import { homedir } from 'node:os'; -import { cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'; +import { statfsSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'; import { pipeline } from 'node:stream/promises'; import { spawn } from 'node:child_process'; import { execFile } from 'node:child_process'; @@ -1330,7 +1330,9 @@ async function api(req, res, path, method, url) { if (path === '/api/setup' && method === 'GET') return json(res, 200, setupState()); if (path === '/api/engine/first-run' && method === 'GET') { if (!control?.updateCheck) return json(res, 200, { status: 'unavailable', gpus: [] }); - return json(res, 200, await engineFirstRun({ control, gpus: hardware.cachedHardware()?.gpus ?? [] })); + const info = await engineFirstRun({ control, gpus: hardware.cachedHardware()?.gpus ?? [] }); + try { let at = componentsDirectory(); while (at && !existsSync(at) && dirname(at) !== at) at = dirname(at); const f = statfsSync(at); info.freeBytes = Number(f.bavail) * Number(f.bsize); } catch { /* unknown: no warning */ } + return json(res, 200, info); } if (path === '/api/engine/job' && method === 'GET') { // The newest engine download / file install, read without waiting for the native snapshot to connect (the first-run card needs it before that). diff --git a/apps/host/src/components/EngineFirstRun.tsx b/apps/host/src/components/EngineFirstRun.tsx index bc19f4d4..fac6cce4 100644 --- a/apps/host/src/components/EngineFirstRun.tsx +++ b/apps/host/src/components/EngineFirstRun.tsx @@ -15,6 +15,7 @@ export interface FirstRunInfo { message?: string | null; reasons?: string[]; details?: string; + freeBytes?: number; } const MB = 1024 * 1024; @@ -147,6 +148,7 @@ export function EngineFirstRun({ onDone }: { onDone: () => void }) { let main, actions; if (info.status === 'offer' && info.offer) { main = <>{found}

{tr("To run models on it, Strata needs one download:")}
{tr("The engine for this card")}: {mb(info.offer.bytes)} MB

+ {info.freeBytes !== undefined && info.freeBytes < info.offer.bytes * 2.5 ?

{tr("The engine needs about {0} GB of free space on this drive and only {1} GB is free. Free some space, then continue.", [Math.ceil(info.offer.bytes * 2.5 / 1e9), (info.freeBytes / 1e9).toFixed(1)])}

: null}

{tr("It comes from Strata’s own update server and is checked before it is used. Your models and chats are never touched by it.")}

; actions = <> void start()}>{tr(failed ? 'Continue' : 'Download the engine')}{pick("I already have the file…")}; }