Skip to content

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): explain Make room and show local model actions under way

Dongdong Chen737989f5e740
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 19f5c3eb..26fb3d87 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -47,8 +47,13 @@ build:assets` to check the initial JS budget.
its own Computer. Only the Computer's owner can act; actions return at once
and progress arrives as `local-models` invalidation hints. From the click
until a snapshot with another status or observation time, or a refusal, the
- row shows a requested load or download as started and spins the button of
- any other action, with the row's actions off. A Computer's
+ row shows a requested load or download as started, labels a cancel, unload
+ or remove under way (Cancelling, Unloading, Removing), and spins that
+ action's button, with the row's actions off; a download the Computer
+ accepted can be cancelled before its first progress. Make room lists what
+ else holds the pool (components, and other apps from `used_bytes` no holder
+ accounts for) when unloading models cannot free enough, and says a model
+ cannot fit only when it needs more than the pool's total. A Computer's
detail on the Computers page links here and reads no model state itself.
- `src/test`: unit-test support, including the in-process TeamHub test server.
- `e2e`: Playwright product workflows; every spec runs on the real TeamHub and
diff --git a/apps/web/src/features/local-models/local-model-dialogs.tsx b/apps/web/src/features/local-models/local-model-dialogs.tsx
index f8e36a51..eee661e3 100644
--- a/apps/web/src/features/local-models/local-model-dialogs.tsx
+++ b/apps/web/src/features/local-models/local-model-dialogs.tsx
@@ -12,6 +12,7 @@ import {
formatGigabytes,
makeRoomSelection,
makesRoom,
+ placeName,
poolLabel,
poolOf,
poolOtherBytes,
@@ -64,17 +65,29 @@ export function MakeRoomDialog({
const effectiveSelected = roomFreeNow ? [] : selected;
const chosen = new Set(effectiveSelected);
const enough = roomFreeNow || makesRoom(check, chosen);
+ const pool = poolLabel(view, check.pool);
const otherBytes = poolOtherBytes(check.pool);
const unifiedFitsHardware =
check.pool.kind === "unified" &&
(view.computer.host?.ram_total_bytes ?? 0) >= check.needBytes;
+ // Whether unloading every model offered here frees enough; when not, what
+ // else holds the memory is the thing to show.
+ const reachable =
+ roomFreeNow ||
+ makesRoom(check, new Set(check.loaded.map((item) => item.model.id)));
+ // Free memory never exceeds the pool's total, whatever else closes.
+ const tooBig = check.needBytes > check.pool.total_bytes;
+ const inUse = [
+ ...(otherBytes ? [{ bytes: otherBytes, id: "", name: "Other apps" }] : []),
+ ...check.kept,
+ ];
const affected = check.loaded.flatMap((item) =>
chosen.has(item.model.id) ? item.used_by.map((user) => user.name) : [],
);
return (
<ModalDialog
- description={`${entry.model.name} needs ${formatGigabytes(check.needBytes)} on ${poolLabel(view, check.pool)}; ${formatGigabytes(check.freeBytes)} is free.`}
+ description={`${entry.model.name} needs ${formatGigabytes(check.needBytes)} on ${pool}; ${formatGigabytes(check.freeBytes)} is free.`}
footer={
<>
{onRecheck ? (
@@ -147,19 +160,44 @@ export function MakeRoomDialog({
</label>
))}
</fieldset>
- ) : (
+ ) : null}
+ {tooBig ? (
<FormFeedback tone="danger">
- Nothing else is loaded there.
- {otherBytes > 0 || unifiedFitsHardware
- ? `${otherBytes > 0 ? ` Other apps are using ${formatGigabytes(otherBytes)}.` : ""} Close video players, games, or other memory-heavy apps, then click Recheck memory so loading won't overload your computer.`
- : " This model doesn't fit even when the memory is empty."}
+ {entry.model.name} needs more than all{" "}
+ {formatGigabytes(check.pool.total_bytes)} of {pool}, so it
+ can&apos;t load there.
</FormFeedback>
+ ) : reachable ? null : (
+ <>
+ {inUse.length ? (
+ <ul aria-label="Also using this memory" className="grid gap-0.5">
+ {inUse.map((holder) => (
+ <li
+ className="flex min-h-8 items-center gap-2 px-2 text-sm text-app-body"
+ key={holder.id}
+ >
+ <span className="min-w-0 flex-1 truncate">
+ {holder.name}
+ </span>
+ <span className="w-16 text-right text-xs tabular-nums text-muted-foreground">
+ {formatGigabytes(holder.bytes)}
+ </span>
+ </li>
+ ))}
+ </ul>
+ ) : null}
+ <FormFeedback tone="danger">
+ {otherBytes > 0 || unifiedFitsHardware
+ ? `${otherBytes > 0 ? `Other apps are using ${formatGigabytes(otherBytes)}. ` : ""}Close other apps that use ${placeName(view, check.pool.id)}, then ${onRecheck ? "click Recheck memory" : "try again"}.`
+ : "Unloading models here doesn't free enough. Choose a smaller model."}
+ </FormFeedback>
+ </>
)}
- {check.loaded.length > 0 && !enough && otherBytes > 0 ? (
+ {reachable && !enough && otherBytes > 0 ? (
<FormFeedback tone="warning">
- Other apps are using {formatGigabytes(otherBytes)} on{" "}
- {poolLabel(view, check.pool)}. Close unnecessary apps and click
- Recheck memory to free the remaining room.
+ Other apps are using {formatGigabytes(otherBytes)} on {pool}. Close
+ unnecessary apps and click Recheck memory to free the remaining
+ room.
</FormFeedback>
) : null}
{affected.length ? (
diff --git a/apps/web/src/features/local-models/local-model-row.tsx b/apps/web/src/features/local-models/local-model-row.tsx
index f3b7405e..fca89c33 100644
--- a/apps/web/src/features/local-models/local-model-row.tsx
+++ b/apps/web/src/features/local-models/local-model-row.tsx
@@ -141,6 +141,17 @@ const statusTags: Record<
unavailable: { label: "Can't download" },
};
+/**
+ * The label a row shows while an action that ends its current status is
+ * under way: until a snapshot moves the model on, the status alone would
+ * read as if nothing had happened.
+ */
+const endingLabels: Partial<Record<LocalModelAction, string>> = {
+ cancel: "Cancelling",
+ remove: "Removing",
+ unload: "Unloading",
+};
+
interface Handlers {
onCancel: () => void;
onDownload: () => void;
@@ -320,19 +331,28 @@ export function ModelRow({
const panelId = useId();
const { model } = entry;
// A requested load or download reads as started at once; the snapshot that
- // follows says how it went.
+ // follows says how it went. A cancel can follow a download no snapshot
+ // shows yet.
const status: ModelStatus =
requested === "load"
? "loading"
- : requested === "download"
+ : requested === "download" ||
+ (requested === "cancel" && entry.status === "available")
? "downloading"
: entry.status;
const started = status !== entry.status;
const stopped = status === "failed" && downloadStopped(model);
const where = placeName(view, model.pool);
- const tag = stopped
- ? { ...statusTags.failed, label: "Download stopped" }
- : statusTags[status];
+ const ending = requested && endingLabels[requested];
+ const tag = ending
+ ? {
+ dot: statusTags[status].dot,
+ label: stopped && requested === "cancel" ? "Discarding" : ending,
+ working: true,
+ }
+ : stopped
+ ? { ...statusTags.failed, label: "Download stopped" }
+ : statusTags[status];
const progress = downloadPercent(model);
const download = formatGigabytes(model.download_bytes);
const recommended = status === "available" && model.recommended;
@@ -418,7 +438,7 @@ export function ModelRow({
{model.name}
</span>
<RowStatusLine
- detail={detail}
+ detail={ending ? null : detail}
download={download}
recommended={recommended}
slower={slower}
diff --git a/apps/web/src/features/local-models/local-models-page.test.tsx b/apps/web/src/features/local-models/local-models-page.test.tsx
index 00e30ea9..315058df 100644
--- a/apps/web/src/features/local-models/local-models-page.test.tsx
+++ b/apps/web/src/features/local-models/local-models-page.test.tsx
@@ -494,6 +494,70 @@ describe("LocalModelsPage", () => {
answer();
});
+ it("lets an accepted download be cancelled before its first progress", async () => {
+ const fixture = setup();
+ await renderPage(fixture);
+ await findModels();
+
+ fireEvent.click(
+ screen.getByRole("button", { name: "Download GPT-OSS 20B" }),
+ );
+ const cancel = await screen.findByRole("button", {
+ name: "Cancel GPT-OSS 20B",
+ });
+ await waitFor(() => expect(cancel).toBeEnabled());
+ expect(statusOf("GPT-OSS 20B")).toBe("Downloading");
+
+ const answer = holdActions(fixture, () => accepted("cancel"));
+ fireEvent.click(cancel);
+ await waitFor(() => expect(statusOf("GPT-OSS 20B")).toBe("Cancelling"));
+ expect(
+ screen.queryByRole("button", { name: "Download GPT-OSS 20B" }),
+ ).toBeNull();
+ answer();
+ });
+
+ it("shows a download as cancelling from the click until the Computer stops it", async () => {
+ const fixture = setup([
+ withModel(labView(), "gpt-oss-20b:Q4_K_M", {
+ download: { done_bytes: 32, step: "download", total_bytes: 100 },
+ state: "downloading",
+ }),
+ ]);
+ const answer = holdActions(fixture, () => accepted("cancel"));
+ await renderPage(fixture);
+ await findModels();
+
+ fireEvent.click(screen.getByRole("button", { name: "Cancel GPT-OSS 20B" }));
+ await waitFor(() => expect(statusOf("GPT-OSS 20B")).toBe("Cancelling"));
+ expect(
+ card("GPT-OSS 20B").querySelector(".town-shimmer-text"),
+ ).not.toBeNull();
+
+ // Progress keeps arriving while the tool stops the download.
+ publishSnapshot(
+ fixture,
+ withModel(labView(), "gpt-oss-20b:Q4_K_M", {
+ download: { done_bytes: 40, step: "download", total_bytes: 100 },
+ state: "downloading",
+ }),
+ );
+ await waitFor(() =>
+ expect(
+ screen.getByRole("progressbar", {
+ name: "GPT-OSS 20B download progress",
+ }),
+ ).toHaveAttribute("aria-valuenow", "40"),
+ );
+ expect(statusOf("GPT-OSS 20B")).toBe("Cancelling");
+
+ publishSnapshot(fixture, labView());
+ answer();
+ await waitFor(() =>
+ expect(statusOf("GPT-OSS 20B")).toMatch(/^Not downloaded/),
+ );
+ });
+
it("discards a stopped download instead of removing it", async () => {
const fixture = setup([
withModel(macView(), "llama3.3-70b:Q4_K_M", {
@@ -654,9 +718,91 @@ describe("LocalModelsPage", () => {
fireEvent.click(
screen.getByRole("button", { name: "Retry Llama 3.3 70B" }),
);
+ const dialog = screen.getByRole("dialog", { name: "Make room to load" });
+ expect(dialog).toHaveTextContent(
+ "Llama 3.3 70B needs more than all 40 GB of Unified memory, so it can't load there.",
+ );
+ expect(within(dialog).getByRole("button", { name: "Load" })).toBeDisabled();
+ });
+
+ it("names the apps holding the memory instead of calling the model too big", async () => {
+ const lab = labView();
+ const qwen = localModel({
+ id: "qwen3-14b:Q4_K_M",
+ memory_bytes: gb(8.9),
+ name: "Qwen3 14B",
+ pool: "gpu:0",
+ state: "idle",
+ });
+ // A 16 GB card where Linger's embedding holds 1 GB and other apps 8 GB:
+ // the model fits the empty card but not what is free now.
+ const pool = gpuPool(0, 16, [
+ { component: true, gb: 1, id: "embedding", name: "Qwen3 Embedding" },
+ ]);
+ await renderPage(
+ setup([
+ {
+ ...lab,
+ models: [modelView(qwen)],
+ pools: [{ ...pool, used_bytes: gb(9) }],
+ },
+ ]),
+ );
+ await findModels();
+
+ fireEvent.click(screen.getByRole("button", { name: "Load Qwen3 14B" }));
+ const dialog = screen.getByRole("dialog", { name: "Make room to load" });
+ expect(dialog).toHaveTextContent(
+ "Qwen3 14B needs 8.9 GB on GPU 0 · RTX 4090; 7 GB is free.",
+ );
+ expect(dialog).not.toHaveTextContent("empty");
+ const inUse = within(dialog).getByRole("list", {
+ name: "Also using this memory",
+ });
expect(
- screen.getByRole("dialog", { name: "Make room to load" }),
- ).toHaveTextContent("Nothing else is loaded there.");
+ within(inUse)
+ .getAllByRole("listitem")
+ .map((item) => item.textContent),
+ ).toEqual(["Other apps8 GB", "Qwen3 Embedding1 GB"]);
+ expect(dialog).toHaveTextContent(
+ "Other apps are using 8 GB. Close other apps that use GPU 0, then click Recheck memory.",
+ );
+ expect(within(dialog).getByRole("button", { name: "Load" })).toBeDisabled();
+ });
+
+ it("lists other apps when unloading every model still isn't enough", async () => {
+ const lab = labView();
+ const pool = gpuPool(0, 24, [
+ { gb: 10, id: "qwen3-coder-30b:Q4_K_M", name: "Qwen3 Coder 30B" },
+ ]);
+ await renderPage(
+ setup([
+ withModel(
+ withModel(
+ { ...lab, pools: [{ ...pool, used_bytes: gb(22) }, lab.pools[1]!] },
+ "qwen3-coder-30b:Q4_K_M",
+ { memory_bytes: gb(10) },
+ ),
+ "gemma3-27b:Q4_K_M",
+ { pool: "gpu:0", memory_bytes: gb(13) },
+ ),
+ ]),
+ );
+ await findModels();
+
+ fireEvent.click(screen.getByRole("button", { name: "Load Gemma 3 27B" }));
+ const dialog = screen.getByRole("dialog", { name: "Make room to load" });
+ expect(
+ within(dialog).getByRole("checkbox", { name: /Qwen3 Coder 30B/ }),
+ ).not.toBeChecked();
+ expect(
+ within(
+ within(dialog).getByRole("list", { name: "Also using this memory" }),
+ ).getByRole("listitem"),
+ ).toHaveTextContent("Other apps12 GB");
+ expect(dialog).toHaveTextContent(
+ "Other apps are using 12 GB. Close other apps that use GPU 0, then click Recheck memory.",
+ );
});
it("asks before unloading a model an Agent uses, and not otherwise", async () => {
@@ -911,6 +1057,7 @@ describe("LocalModelsPage", () => {
});
await waitFor(() => expect(unload).toHaveAttribute("aria-busy", "true"));
expect(unload).toBeDisabled();
+ expect(statusOf("Qwen3 Coder 30B")).toBe("Unloading");
answer();
publishSnapshot(
diff --git a/apps/web/src/features/local-models/local-models-page.tsx b/apps/web/src/features/local-models/local-models-page.tsx
index 5c95eb1f..51831a50 100644
--- a/apps/web/src/features/local-models/local-models-page.tsx
+++ b/apps/web/src/features/local-models/local-models-page.tsx
@@ -536,6 +536,12 @@ function Library({
for (const input of sending) {
if (input) requests.set(input.modelId, input.action);
}
+ // A download the Computer accepted is a job it can cancel before the
+ // first progress reaches a snapshot; every other request holds the row.
+ const busy = (modelId: string) =>
+ requests.has(modelId) &&
+ (requests.get(modelId) !== "download" ||
+ sending.some((input) => input?.modelId === modelId));
const offline = view.computer.status === "offline";
const readOnly = !view.viewer_is_owner;
// A dialog stays open across snapshots, so its confirm checks the model
@@ -560,6 +566,7 @@ function Library({
(dialogPool
? {
freeBytes: poolFreeBytes(dialogPool),
+ kept: [],
loaded: [],
needBytes: dialogEntry.model.memory_bytes,
pool: dialogPool,
@@ -671,9 +678,7 @@ function Library({
entry.model.id !== status.runtime_model;
return (
<ModelRow
- disabled={
- offline || readOnly || switching || requests.has(modelId)
- }
+ disabled={offline || readOnly || switching || busy(modelId)}
entry={entry}
expanded={expandedId === modelId}
key={modelId}
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.ts
index 2991c6f2..76b2b0f5 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
@@ -276,6 +276,9 @@ describe("local models rules", () => {
expect(check.loaded.map((entry) => entry.model.name)).toEqual([
"GPT-OSS 20B",
]);
+ // The loaded model is offered, so nothing else holds the pool.
+ expect(check.kept).toEqual([]);
+ expect(poolOtherBytes(check.pool)).toBe(0);
});
it("preselects the fewest models, preferring ones no Agent uses", () => {
@@ -289,6 +292,7 @@ describe("local models rules", () => {
...item,
status: "loaded" as const,
})),
+ kept: [],
needBytes: gb(12),
pool,
};
diff --git a/apps/web/src/features/local-models/local-models-rules.ts b/apps/web/src/features/local-models/local-models-rules.ts
index 8d10247b..2fa2e962 100644
--- a/apps/web/src/features/local-models/local-models-rules.ts
+++ b/apps/web/src/features/local-models/local-models-rules.ts
@@ -290,6 +290,11 @@ export interface LoadCheck {
freeBytes: number;
/** Loaded models in the same pool, the ones the user could unload. */
loaded: ModelEntry[];
+ /**
+ * What else holds the pool that Make room cannot unload: components and
+ * models in another state, by holder.
+ */
+ kept: LocalModelPool["holders"];
}
/** Why a model cannot load now, or `null` when its pool reports room for it. */
@@ -299,14 +304,18 @@ export function loadCheck(
): LoadCheck | null {
const pool = poolOf(view, model.pool);
if (!pool || poolFreeBytes(pool) >= model.memory_bytes) return null;
+ const loaded = modelEntries(view).filter(
+ (entry) =>
+ entry.status === "loaded" &&
+ entry.model.pool === pool.id &&
+ entry.model.id !== model.id,
+ );
return {
freeBytes: poolFreeBytes(pool),
- loaded: modelEntries(view).filter(
- (entry) =>
- entry.status === "loaded" &&
- entry.model.pool === pool.id &&
- entry.model.id !== model.id,
+ kept: pool.holders.filter(
+ (holder) => !loaded.some((entry) => entry.model.id === holder.id),
),
+ loaded,
needBytes: model.memory_bytes,
pool,
};