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(web): show Local models sizes in GB
Ethan3f94832dab29
diff --git a/apps/web/src/features/local-models/local-model-details.tsx b/apps/web/src/features/local-models/local-model-details.tsxindex 52b0d3ae..27fdba1b 100644--- a/apps/web/src/features/local-models/local-model-details.tsx+++ b/apps/web/src/features/local-models/local-model-details.tsx@@ -5,7 +5,6 @@ import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";import { ModalDialog } from "@/components/ui/modal-dialog";import { cn } from "@/lib/cn";-import { formatBytes } from "@/lib/format-bytes";import {modelErrorCopy,@@ -16,6 +15,7 @@ import type { LocalModelPool, LocalModelsView } from "./local-models-queries";import {agentNames,contextLabel,+ formatGigabytes,placeName,poolFreeBytes,poolLabel,@@ -75,7 +75,7 @@ export function ModelFacts({<div className="divide-y divide-border"><Fact label="Version">{model.quant}</Fact><Fact label="Memory">- {formatBytes(model.memory_bytes)}+ {formatGigabytes(model.memory_bytes)}{onComputer && pool? ` on ${poolLabel(view, pool)}`: plannedPlace@@ -83,7 +83,7 @@ export function ModelFacts({: ""}</Fact><Fact label={onComputer ? "On disk" : "Download"}>- {formatBytes(model.download_bytes)}+ {formatGigabytes(model.download_bytes)}</Fact><Fact label="Context">{contextLabel(model.context_tokens)}</Fact>{model.tokens_per_second ? (@@ -151,7 +151,7 @@ function PoolBar({{pool.kind === "gpu" ? `GPU ${pool.gpu_index}` : label}</span><span- aria-label={`${label}: ${formatBytes(pool.used_bytes)} of ${formatBytes(pool.total_bytes)} in use`}+ aria-label={`${label}: ${formatGigabytes(pool.used_bytes)} of ${formatGigabytes(pool.total_bytes)} in use`}className="flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted"role="img">@@ -163,19 +163,19 @@ function PoolBar({)}key={holder.id}style={{ width: width(holder.bytes) }}- title={`${holder.name} · ${formatBytes(holder.bytes)}`}+ title={`${holder.name} · ${formatGigabytes(holder.bytes)}`}/>))}{otherBytes ? (<spanclassName="h-full bg-muted-foreground/30"style={{ width: width(otherBytes) }}- title={`Other apps · ${formatBytes(otherBytes)}`}+ title={`Other apps · ${formatGigabytes(otherBytes)}`}/>) : null}</span><span className="w-24 shrink-0 text-right text-xs whitespace-nowrap tabular-nums text-muted-foreground">- {formatBytes(poolFreeBytes(pool))} free+ {formatGigabytes(poolFreeBytes(pool))} free</span></div>);@@ -240,13 +240,17 @@ export function AdvancedDialog({Hardware</h3><div className="divide-y divide-border">- <Fact label="Memory">{formatBytes(host.ram_total_bytes)}</Fact>+ <Fact label="Memory">+ {formatGigabytes(host.ram_total_bytes)}+ </Fact>{host.gpus.map((gpu) => (<Fact key={gpu.index} label={`GPU ${gpu.index}`}>- {gpu.name} · {formatBytes(gpu.total_bytes)}+ {gpu.name} · {formatGigabytes(gpu.total_bytes)}</Fact>))}- <Fact label="Free disk">{formatBytes(host.disk_free_bytes)}</Fact>+ <Fact label="Free disk">+ {formatGigabytes(host.disk_free_bytes)}+ </Fact></div></>) : null}diff --git a/apps/web/src/features/local-models/local-model-dialogs.tsx b/apps/web/src/features/local-models/local-model-dialogs.tsxindex a7d19a67..e81bae3f 100644--- a/apps/web/src/features/local-models/local-model-dialogs.tsx+++ b/apps/web/src/features/local-models/local-model-dialogs.tsx@@ -5,11 +5,11 @@ import { FormFeedback } from "@/components/ui/form-feedback";import { ModalDialog } from "@/components/ui/modal-dialog";import { sourceCheckClassName } from "@/features/settings/provider-selection-picker";import { cn } from "@/lib/cn";-import { formatBytes } from "@/lib/format-bytes";import type { LocalModelsView } from "./local-models-queries";import {agentNames,+ formatGigabytes,makeRoomSelection,makesRoom,poolLabel,@@ -63,7 +63,7 @@ export function MakeRoomDialog({return (<ModalDialog- description={`${entry.model.name} needs ${formatBytes(check.needBytes)} on ${poolLabel(view, check.pool)}; ${formatBytes(check.freeBytes)} is free.`}+ description={`${entry.model.name} needs ${formatGigabytes(check.needBytes)} on ${poolLabel(view, check.pool)}; ${formatGigabytes(check.freeBytes)} is free.`}footer={<><Button onClick={onClose}>Cancel</Button>@@ -117,7 +117,7 @@ export function MakeRoomDialog({: "Not used"}</span><span className="w-16 text-right text-xs tabular-nums text-muted-foreground">- {formatBytes(item.model.memory_bytes)}+ {formatGigabytes(item.model.memory_bytes)}</span></label>))}@@ -157,7 +157,7 @@ export function UnloadModelDialog({const pool = poolOf(view, entry.model.pool);return (<ModalDialog- description={`Frees ${formatBytes(entry.model.memory_bytes)} of ${+ description={`Frees ${formatGigabytes(entry.model.memory_bytes)} of ${pool ? poolLabel(view, pool) : "memory"}. It stays on disk, so you can load it again later.`}footer={@@ -199,7 +199,7 @@ export function RemoveModelDialog({entry.status === "loaded"? "Unloads it, deletes its files": "Deletes its files"- } and frees ${formatBytes(entry.model.download_bytes)} of disk on ${view.computer.display_name}. You can download it again later.`}+ } and frees ${formatGigabytes(entry.model.download_bytes)} of disk on ${view.computer.display_name}. You can download it again later.`}footer={<><Button onClick={onClose}>Cancel</Button>diff --git a/apps/web/src/features/local-models/local-model-row.tsx b/apps/web/src/features/local-models/local-model-row.tsxindex ef546e05..3abcaf9e 100644--- a/apps/web/src/features/local-models/local-model-row.tsx+++ b/apps/web/src/features/local-models/local-model-row.tsx@@ -5,13 +5,12 @@ import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";import { cn } from "@/lib/cn";-import { formatBytes } from "@/lib/format-bytes";-import { ModelFacts } from "./local-model-details";import { unavailableShortCopy } from "./local-models-copy";import type { LocalModelsView } from "./local-models-queries";import {downloadPercent,+ formatGigabytes,placeName,type ModelEntry,type ModelStatus,@@ -73,7 +72,7 @@ export function ModelRow({const where = placeName(view, model.pool);const tag = statusTags[status];const progress = downloadPercent(model);- const download = formatBytes(model.download_bytes);+ const download = formatGigabytes(model.download_bytes);const detail = {available: model.recommended? `${download} · Recommended`@@ -86,7 +85,7 @@ export function ModelRow({idle: model.note ? "no room to load yet" : null,loaded: [where ? `${where[0]!.toUpperCase()}${where.slice(1)}` : undefined,- formatBytes(model.memory_bytes),+ formatGigabytes(model.memory_bytes),].filter(Boolean).join(" · "),diff --git a/apps/web/src/features/local-models/local-models-copy.ts b/apps/web/src/features/local-models/local-models-copy.tsindex dd775757..802bf7f3 100644--- a/apps/web/src/features/local-models/local-models-copy.ts+++ b/apps/web/src/features/local-models/local-models-copy.ts@@ -1,6 +1,6 @@import type { components } from "@linger/wire-contracts/teamhub-public/types";-import { formatBytes } from "@/lib/format-bytes";+import { formatGigabytes } from "./local-models-rules";type Schemas = components["schemas"];@@ -94,7 +94,7 @@ export function unavailableShortCopy(reason: AvailabilityReason | undefined) {if (reason?.code === "PLATFORM_UNSUPPORTED" || !reason)return "not for this computer";const need =- reason.need_bytes === undefined ? "" : formatBytes(reason.need_bytes);+ reason.need_bytes === undefined ? "" : formatGigabytes(reason.need_bytes);if (!need)return reason.code === "DISK_INSUFFICIENT"? "needs more disk"@@ -109,11 +109,11 @@ export function unavailableCopy(reason: AvailabilityReason | undefined) {const need =reason?.need_bytes === undefined? undefined- : formatBytes(reason.need_bytes);+ : formatGigabytes(reason.need_bytes);const have =reason?.have_bytes === undefined? undefined- : formatBytes(reason.have_bytes);+ : formatGigabytes(reason.have_bytes);switch (reason?.code) {case "MEMORY_INSUFFICIENT":return need && havediff --git a/apps/web/src/features/local-models/local-models-page.tsx b/apps/web/src/features/local-models/local-models-page.tsxindex c9e46572..84b37576 100644--- a/apps/web/src/features/local-models/local-models-page.tsx+++ b/apps/web/src/features/local-models/local-models-page.tsx@@ -19,7 +19,6 @@ import { localComputersQueryOptions } from "@/features/local-computer/local-compimport { requireRoomRouteParam } from "@/features/rooms/room-route-params";import { TeamHubError } from "@/features/teamhub/teamhub-error";import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";-import { formatBytes } from "@/lib/format-bytes";import { AdvancedDialog } from "./local-model-details";import { ModelRow } from "./local-model-row";@@ -38,6 +37,7 @@ import {type LocalModelsView,} from "./local-models-queries";import {+ formatGigabytes,loadCheck,memorySummary,modelEntries,@@ -209,8 +209,8 @@ function ComputerModels({<h1 className="text-2xl text-foreground">Local models</h1>{summary?.totalBytes ? (<p className="mt-1.5 text-sm text-muted-foreground">- {formatBytes(summary.usedBytes)} of{" "}- {formatBytes(summary.totalBytes)}{" "}+ {formatGigabytes(summary.usedBytes)} of{" "}+ {formatGigabytes(summary.totalBytes)}{" "}{summary.gpu ? "GPU memory" : "memory"} in use</p>) : null}diff --git a/apps/web/src/features/local-models/local-models-rules.test.ts b/apps/web/src/features/local-models/local-models-rules.test.tsindex 54b25417..a46efedd 100644--- a/apps/web/src/features/local-models/local-models-rules.test.ts+++ b/apps/web/src/features/local-models/local-models-rules.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";import {downloadPercent,+ formatGigabytes,loadCheck,makeRoomSelection,makesRoom,@@ -48,6 +49,13 @@ describe("local models rules", () => {]);});+ it("formats every size in GB with at most one decimal", () => {+ expect(formatGigabytes(gb(0.6))).toBe("0.6 GB");+ expect(formatGigabytes(0)).toBe("0 GB");+ expect(formatGigabytes(gb(46))).toBe("46 GB");+ expect(formatGigabytes(gb(21.44))).toBe("21.4 GB");+ });+it("names pools from what the Computer reported", () => {const view = labView();expect(view.pools.map((pool) => poolLabel(view, pool))).toEqual([diff --git a/apps/web/src/features/local-models/local-models-rules.ts b/apps/web/src/features/local-models/local-models-rules.tsindex 89772d35..d5932103 100644--- a/apps/web/src/features/local-models/local-models-rules.ts+++ b/apps/web/src/features/local-models/local-models-rules.ts@@ -86,6 +86,15 @@ export function placeName(view: LocalModelsView, poolId: string | undefined) {return pool.kind === "system" ? "system memory" : "memory";}+/**+ * Model and memory sizes always read in GB with at most one decimal, so a+ * small model and an empty pool compare at a glance with the rest: 0.6 GB and+ * 0 GB, not 614.4 MB and 0 B.+ */+export function formatGigabytes(bytes: number) {+ return `${Math.round((bytes / 1024 ** 3) * 10) / 10} GB`;+}+export function poolFreeBytes(pool: LocalModelPool) {return Math.max(0, pool.total_bytes - pool.used_bytes);}