First-run card: one plain line when the drive for the engine is short on space
This commit is contained in:
1 parent
61a4b6bd02
commit
ff84ff8164
2 files changed
+6
-2
No files matched your search
@@ -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).
|
||||
|
||||
@@ -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}<p>{tr("To run models on it, Strata needs one download:")}<br/><strong>{tr("The engine for this card")}: {mb(info.offer.bytes)} MB</strong></p>
|
||||
{info.freeBytes !== undefined && info.freeBytes < info.offer.bytes * 2.5 ? <p className="small inline-error">{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)])}</p> : null}
|
||||
<p className="small muted">{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.")}</p></>;
|
||||
actions = <><Btn variant="primary" disabled={busy} onClick={() => void start()}>{tr(failed ? 'Continue' : 'Download the engine')}</Btn>{pick("I already have the file…")}</>;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user