Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(desktop): address review findings on the Quick Install recommendation
claude-opus-5-5-medium90f9f6ad4a1b
diff --git a/apps/desktop/src/main/local-server.test.ts b/apps/desktop/src/main/local-server.test.tsindex dc429216..44f704c8 100644--- a/apps/desktop/src/main/local-server.test.ts+++ b/apps/desktop/src/main/local-server.test.ts@@ -1326,7 +1326,9 @@ describe("LocalServerModule", () => {expect(f.module.status().localModels).toMatchObject({state: "checked",eligible: false,- reasons: ["facts-unavailable: nvidia-smi was not found"],+ reasons: [+ { code: "facts-unavailable", message: "nvidia-smi was not found" },+ ],recommendation: "codex",}),);diff --git a/apps/desktop/src/main/local-server.ts b/apps/desktop/src/main/local-server.tsindex 67153c18..ba83c626 100644--- a/apps/desktop/src/main/local-server.ts+++ b/apps/desktop/src/main/local-server.ts@@ -32,6 +32,10 @@ import {} from "@linger/local-installation/account";import { downloadVerified } from "@linger/local-installation/download";import { legacyMigrationPending } from "@linger/local-installation/home";+import {+ type SetupChoice,+ setupChoices,+} from "@linger/local-installation/setup-plan";import {removeRetrying,renameRetrying,@@ -107,15 +111,18 @@ export type LocalModelsCheck =readonly gpu?: string;// Present only when eligible.readonly model?: LocalModel;- // Why not, in the localmodels tool's words; present only when not- // eligible.- readonly reasons?: readonly string[];+ // Why not, as the localmodels tool's code and words; present only+ // when not eligible.+ readonly reasons?: readonly SetupReason[];// The localmodels tool's pick for this computer, which Quick Install// installs; the page adds no rule of its own.- readonly recommendation?: SetupRecommendation;+ readonly recommendation?: SetupChoice;};-export type SetupRecommendation = "local-models" | "codex" | "claude" | "pi";+export interface SetupReason {+ readonly code: string;+ readonly message?: string;+}// A download under way: its bytes so far and in all, and the rate when the// source reports one. partial: the counts cover only the file downloading@@ -126,12 +133,6 @@ export interface Transfer {readonly bytesPerSecond?: number;readonly partial?: boolean;}-const RECOMMENDATIONS: readonly string[] = [- "local-models",- "codex",- "claude",- "pi",-] satisfies readonly SetupRecommendation[];// What to install, chosen on the setup page; the installer applies it at once.export interface LocalServerPlan {@@ -508,7 +509,11 @@ export class LocalServerModule implements Module {? { recommendation: check.recommendation }: {}),...(check.state === "checked" && check.reasons- ? { reasons: check.reasons }+ ? {+ reasons: check.reasons.map(({ code, message }) =>+ message ? `${code}: ${message}` : code,+ ),+ }: {}),});this.#check = check;@@ -619,16 +624,17 @@ export class LocalServerModule implements Module {const strings = (value: unknown) =>Array.isArray(value) ? value.map(String) : [];const messages = strings(report.localModels.reasonMessages);- const reasons = strings(report.localModels.reasons).map((code, index) =>- messages[index] ? `${code}: ${messages[index]}` : code,+ const reasons = strings(report.localModels.reasons).map(+ (code, index): SetupReason =>+ messages[index] ? { code, message: messages[index] } : { code },);const pick = report.recommendation;// The local model is recommended only with a model the page can show.const recommendation =typeof pick === "string" &&- RECOMMENDATIONS.includes(pick) &&+ (setupChoices as readonly string[]).includes(pick) &&(pick !== "local-models" || eligible)- ? (pick as SetupRecommendation)+ ? (pick as SetupChoice): undefined;return {state: "checked",diff --git a/apps/desktop/src/shared/setup.ts b/apps/desktop/src/shared/setup.tsindex 41b86a43..aaa2db29 100644--- a/apps/desktop/src/shared/setup.ts+++ b/apps/desktop/src/shared/setup.ts@@ -2,6 +2,8 @@// The setup window walks a new install through server, sign-in, connecting// this computer and the system permissions it needs.+import type { SetupChoice } from "@linger/local-installation/setup-plan";+export interface SetupFolder {readonly grantId: string;readonly label: string;@@ -107,11 +109,15 @@ export type SetupLocalModelsCheck =readonly diskBytes: number | null;readonly memoryBytes: number | null;};- // Why not, in the localmodels tool's words; when not eligible.- readonly reasons?: readonly string[];+ // Why not, as the localmodels tool's code and words; when not+ // eligible.+ readonly reasons?: readonly {+ readonly code: string;+ readonly message?: string;+ }[];// The localmodels tool's pick, which Quick Install installs:// "local-models" is the model above served by Pi.- readonly recommendation?: "local-models" | "codex" | "claude" | "pi";+ readonly recommendation?: SetupChoice;};// The AI runtime the installer sets up; "recommended" lets it pick anddiff --git a/apps/desktop/src/shell/setup-page.test.ts b/apps/desktop/src/shell/setup-page.test.tsindex e6ac8415..f52fa02b 100644--- a/apps/desktop/src/shell/setup-page.test.ts+++ b/apps/desktop/src/shell/setup-page.test.ts@@ -180,7 +180,10 @@ const small: SetupLocalModelsCheck = {eligible: false,memoryBytes: 8 * GB,diskFreeBytes: 100 * GB,- reasons: ["plan-unavailable: No model fits this computer."],+ // A code the page never parses: it shows only the message.+ reasons: [+ { code: "upstream_policy", message: "No model fits this computer." },+ ],recommendation: "codex",};const welcome = (localModels: SetupLocalModelsCheck): SetupState => {@@ -274,6 +277,27 @@ describe("setup page Quick Install recommendation", () => {);});+ it("follows the tool's pick when Auto was chosen during the check", async () => {+ const { run, push } = await openPage(+ welcome({ state: "checking" }),+ "welcome",+ );+ $("local-customize").click();+ const option = (value: string) =>+ document.querySelector<HTMLButtonElement>(+ `[data-plan="runtime"] [data-value="${value}"]`,+ )!;+ option("recommended").click();+ push(welcome(capable));+ expect(option("recommended").hidden).toBe(true);+ expect(option("pi").getAttribute("aria-checked")).toBe("true");+ expect($("local-model").getAttribute("aria-checked")).toBe("true");+ $("local-install").click();+ await vi.waitFor(() =>+ expect(installed(run)).toEqual([{ op: "local.start", runtime: "local" }]),+ );+ });+it("marks the recommendation under Customize and installs the person's choice", async () => {const { run } = await openPage(welcome(capable), "welcome");$("local-customize").click();diff --git a/apps/desktop/src/shell/setup.html b/apps/desktop/src/shell/setup.htmlindex 7f52dbf2..6d39be75 100644--- a/apps/desktop/src/shell/setup.html+++ b/apps/desktop/src/shell/setup.html@@ -2182,6 +2182,14 @@const renderLocal = (busy) => {const local = state.localServer;const recommended = defaults();+ // Auto, picked before the check named a pick, means that pick; once+ // it is known Auto no longer shows.+ if (+ picked &&+ plan.runtime === "recommended" &&+ recommended.runtime !== "recommended"+ )+ picked = false;if (!picked) plan = recommended;// The local model is offered only once this computer is known to// serve it; until then its row does not show.@@ -2253,9 +2261,7 @@.join(" · "): models.state === "checked" && !models.eligible? "No local model: " +- // The tool's message, without the "<code>: " the main- // process puts before it.- (models.reasons?.[0]?.replace(/^[a-z-]+: /, "") ||+ (models.reasons?.[0]?.message ||"this computer can't run one."): models.state === "unavailable"? "Couldn't check this computer for a local model."diff --git a/packages/local-installation/src/local-models.test.ts b/packages/local-installation/src/local-models.test.tsindex a823819a..c8ac002e 100644--- a/packages/local-installation/src/local-models.test.ts+++ b/packages/local-installation/src/local-models.test.ts@@ -648,6 +648,15 @@ test("names what downloads and keeps the tool's counters", () => {stackProgress({ ...progress, component: "embedding", phase: "verify" })?.message,).toBe("Checking the embedding model…");+ // A rate is bytes over elapsed time, so the tool may send a fraction.+ expect(+ stackProgress({ ...progress, bytes_per_second: 42123456.7 })?.progress+ ?.bytesPerSecond,+ ).toBe(42123457);+ for (const rate of [-1, Number.NaN, Number.POSITIVE_INFINITY, "3"])+ expect(+ stackProgress({ ...progress, bytes_per_second: rate })?.progress,+ ).not.toHaveProperty("bytesPerSecond");for (const other of [{ ...progress, phase: "loading", done: null, total: null },{ ...progress, done: 11 },diff --git a/packages/local-installation/src/local-models.ts b/packages/local-installation/src/local-models.tsindex f0f3f3ad..f74c036e 100644--- a/packages/local-installation/src/local-models.ts+++ b/packages/local-installation/src/local-models.ts@@ -90,7 +90,12 @@ export function stackProgress(value: unknown): InstallerEvent | undefined {wholeTotal !== undefined &&wholeTotal > 0 &&wholeDone <= wholeTotal;- const rate = count("bytes_per_second");+ // A rate is bytes over elapsed time, so it may be fractional.+ const rawRate = event.bytes_per_second;+ const rate =+ typeof rawRate === "number" && Number.isFinite(rawRate) && rawRate >= 0+ ? Math.round(rawRate)+ : undefined;const what =event.step === "engine"? "the inference engine"diff --git a/packages/local-installation/src/setup-plan.ts b/packages/local-installation/src/setup-plan.tsindex 45a2d7e5..39017abb 100644--- a/packages/local-installation/src/setup-plan.ts+++ b/packages/local-installation/src/setup-plan.ts@@ -111,7 +111,12 @@ interface UpstreamReport {};recommendation: SetupChoice;}-const choices: SetupChoice[] = ["local-models", "codex", "claude", "pi"];+export const setupChoices: readonly SetupChoice[] = [+ "local-models",+ "codex",+ "claude",+ "pi",+];/** Presentation adapter only. Host probes, admission, recommendation and budgets belong upstream. */export async function inspectSetup(options: SetupOptions = {},@@ -149,7 +154,7 @@ export async function inspectSetup(if (value.schema !== "localmodels.setup-report/v1" ||value.harness.schema !== "localmodels.harness-status/v1" ||- !choices.includes(value.recommendation) ||+ !setupChoices.includes(value.recommendation) ||typeof value.stack.available !== "boolean")throw new Error("Invalid upstream report");@@ -182,7 +187,7 @@ export async function inspectSetup() ?? false,})),},- choices: [...choices],+ choices: [...setupChoices],localModels: {eligible: value.stack.available,reasons: value.stack.reasons.map((reason) => reason.code),