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.

feat(web): refine Local models card styling and layout

Dongdong Chenf047bf206277
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index b6bcc167..c59ca0d6 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -31,10 +31,13 @@ build:assets` to check the initial JS budget.
owner confirms. The Local model tab is one Computer's model library as
TeamHub last stored it. The Computer decides
fit, availability, placement, the recommendation and memory; the page only
- orders and labels them, picks the Make room default, renders family icons,
- capability/parameter badges, download speed/ETA and model-card facts from
- structured `LocalModel` fields in `local-models-rules.ts`, and maps every
- code and enum label to English in `local-models-copy.ts`. Without `?computer=`
+ orders and labels them, picks the Make room default, renders tinted family
+ icon tiles, Agent usage counts, structured capability/parameter badges (never
+ matched against `name` or `description`), state-distinct cards (`loaded`,
+ `recommended`, `failed`, `unavailable`), download speed/ETA, and top
+ diagnostic callouts with a two-column model-card facts grid from structured
+ `LocalModel` fields in `local-models-rules.ts`, and maps every code and enum
+ label to English in `local-models-copy.ts`. Without `?computer=`
the desktop app opens
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
diff --git a/apps/web/src/features/local-models/local-model-details.tsx b/apps/web/src/features/local-models/local-model-details.tsx
index 951873dc..94ec5160 100644
--- a/apps/web/src/features/local-models/local-model-details.tsx
+++ b/apps/web/src/features/local-models/local-model-details.tsx
@@ -22,6 +22,7 @@ import {
contextLabel,
downloadStopped,
formatGigabytes,
+ isModelOnComputer,
modelCapabilities,
modelSourceLabel,
parametersLabel,
@@ -39,11 +40,29 @@ const segmentColors = ["bg-rain-500", "bg-lichen-500", "bg-sun-500"] as const;
/** Foundation components hold memory too, but are not models of the list. */
const componentColor = "bg-muted-foreground/40";
-function Fact({ label, children }: { label: string; children: ReactNode }) {
+function Fact({
+ bordered = true,
+ children,
+ className,
+ label,
+}: {
+ bordered?: boolean;
+ children: ReactNode;
+ className?: string;
+ label: string;
+}) {
return (
- <div className="flex min-h-10 items-center gap-3 py-1.5 text-sm">
+ <div
+ className={cn(
+ "flex min-h-9 items-center gap-3 py-1.5 text-sm",
+ bordered && "border-t border-border/70",
+ className,
+ )}
+ >
<span className="w-28 shrink-0 text-muted-foreground">{label}</span>
- <span className="min-w-0 flex-1 text-foreground">{children}</span>
+ <span className="min-w-0 flex-1 tabular-nums text-foreground">
+ {children}
+ </span>
</div>
);
}
@@ -81,8 +100,7 @@ export function ModelFacts({
// A stopped download holds only a partial file, so it reads like a model
// not yet on the Computer.
const stopped = downloadStopped(model);
- const onComputer =
- status !== "available" && status !== "unavailable" && !stopped;
+ const onComputer = isModelOnComputer(model, status);
const pool = poolOf(view, model.pool);
const plannedPlace =
status === "available" || stopped ? placeName(view, model.pool) : undefined;
@@ -91,84 +109,105 @@ export function ModelFacts({
const speed = speedLabel(model);
const sourceUrl = safeModelSourceUrl(model.source_url);
return (
- <div className="divide-y divide-border">
- {model.publisher ? (
- <Fact label="Publisher">{model.publisher}</Fact>
- ) : null}
- {parameters ? <Fact label="Parameters">{parameters}</Fact> : null}
- {capabilities.length ? (
- <Fact label="Capabilities">
- <span className="flex flex-wrap gap-1.5">
- {capabilities.map((capability) => (
- <span
- className="rounded-full bg-muted px-2 py-0.5 text-xs text-secondary-foreground"
- key={capability}
- >
- {capabilityCopy(capability)}
+ <div>
+ {model.error || status === "unavailable" ? (
+ <div className="my-1.5 rounded-lg border border-[var(--app-status-danger-border)] bg-[var(--app-status-danger-surface)] px-3 py-0.5">
+ {model.error ? (
+ <Fact
+ bordered={false}
+ label={stopped ? "Last download" : "Last load"}
+ >
+ <span className="text-app-danger">
+ {modelErrorCopy(model.error.code)}
</span>
- ))}
- </span>
- </Fact>
- ) : null}
- <Fact label="Version">{model.quant}</Fact>
- <Fact label="Memory">
- {formatGigabytes(model.memory_bytes)}
- {onComputer && pool
- ? ` on ${poolLabel(view, pool)}`
- : plannedPlace
- ? ` on ${plannedPlace}`
- : ""}
- </Fact>
- <Fact label={onComputer ? "On disk" : "Download"}>
- {formatGigabytes(model.download_bytes)}
- </Fact>
- <Fact label="Context">{contextLabel(model.context_tokens)}</Fact>
- {speed ? <Fact label="Speed">{speed}</Fact> : null}
- {model.license ? <Fact label="License">{model.license}</Fact> : null}
- {sourceUrl ? (
- <Fact label="Source">
- <a
- className="inline-flex max-w-full items-center gap-1 text-foreground underline underline-offset-2"
- href={sourceUrl}
- rel="noopener noreferrer"
- target="_blank"
- >
- <span className="truncate">{modelSourceLabel(sourceUrl)}</span>
- <Icon className="shrink-0" icon={LinkSquare02Icon} size={14} />
- </a>
- </Fact>
- ) : null}
- {onComputer ? (
- <Fact label="Used by">
- {entry.used_by.length ? agentNames(entry) : "No Agent yet"}
- </Fact>
+ </Fact>
+ ) : null}
+ {status === "unavailable" ? (
+ <Fact bordered={Boolean(model.error)} label="Why not">
+ <span className="text-app-danger">
+ {unavailableCopy(model.availability.reason)}
+ </span>
+ </Fact>
+ ) : null}
+ </div>
) : null}
- {model.endpoint ? (
- <Fact label="Endpoint">
- <CopyEndpoint endpoint={model.endpoint.base_url} name={model.name} />
- </Fact>
+ {model.note ? (
+ <div className="my-1.5 rounded-lg border border-[var(--app-status-warning-border)] bg-[var(--app-status-warning-surface)] px-3 py-0.5">
+ <Fact bordered={false} label="Note">
+ <span className="text-app-warning">
+ {modelNoteCopy(model.note.code, placeName(view, model.pool))}
+ </span>
+ </Fact>
+ </div>
) : null}
- {model.error ? (
- <Fact label={stopped ? "Last download" : "Last load"}>
- <span className="text-app-danger">
- {modelErrorCopy(model.error.code)}
- </span>
+ <div className="mt-1 grid grid-cols-1 gap-x-6 @xl:grid-cols-2">
+ {capabilities.length ? (
+ <Fact className="@xl:col-span-2" label="Capabilities">
+ <span className="flex flex-wrap gap-1.5">
+ {capabilities.map((capability) => (
+ <span
+ className="rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-secondary-foreground"
+ key={capability}
+ >
+ {capabilityCopy(capability)}
+ </span>
+ ))}
+ </span>
+ </Fact>
+ ) : null}
+ {model.publisher ? (
+ <Fact label="Publisher">{model.publisher}</Fact>
+ ) : null}
+ {parameters ? <Fact label="Parameters">{parameters}</Fact> : null}
+ <Fact label="Memory">
+ {formatGigabytes(model.memory_bytes)}
+ {onComputer && pool
+ ? ` on ${poolLabel(view, pool)}`
+ : plannedPlace
+ ? ` on ${plannedPlace}`
+ : ""}
</Fact>
- ) : null}
- {model.note ? (
- <Fact label="Note">
- <span className="text-app-warning">
- {modelNoteCopy(model.note.code, placeName(view, model.pool))}
- </span>
+ <Fact label={onComputer ? "On disk" : "Download"}>
+ {formatGigabytes(model.download_bytes)}
</Fact>
- ) : null}
- {status === "unavailable" ? (
- <Fact label="Why not">
- <span className="text-app-danger">
- {unavailableCopy(model.availability.reason)}
- </span>
+ <Fact label="Context">{contextLabel(model.context_tokens)}</Fact>
+ <Fact label="Version">
+ <code className="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-secondary-foreground">
+ {model.quant}
+ </code>
</Fact>
- ) : null}
+ {speed ? <Fact label="Speed">{speed}</Fact> : null}
+ {model.license ? <Fact label="License">{model.license}</Fact> : null}
+ {onComputer ? (
+ <Fact
+ className={entry.used_by.length > 1 ? "@xl:col-span-2" : undefined}
+ label="Used by"
+ >
+ {entry.used_by.length ? agentNames(entry) : "No Agent yet"}
+ </Fact>
+ ) : null}
+ {sourceUrl ? (
+ <Fact className="@xl:col-span-2" label="Source">
+ <a
+ className="inline-flex max-w-full items-center gap-1 text-foreground underline underline-offset-2"
+ href={sourceUrl}
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <span className="truncate">{modelSourceLabel(sourceUrl)}</span>
+ <Icon className="shrink-0" icon={LinkSquare02Icon} size={14} />
+ </a>
+ </Fact>
+ ) : null}
+ {model.endpoint ? (
+ <Fact className="@xl:col-span-2" label="Endpoint">
+ <CopyEndpoint
+ endpoint={model.endpoint.base_url}
+ name={model.name}
+ />
+ </Fact>
+ ) : null}
+ </div>
</div>
);
}
@@ -286,8 +325,8 @@ export function AdvancedDialog({
<h3 className="mt-5 mb-1 text-sm font-medium text-muted-foreground">
Hardware
</h3>
- <div className="divide-y divide-border">
- <Fact label="Memory">
+ <div>
+ <Fact bordered={false} label="Memory">
{formatGigabytes(host.ram_total_bytes)}
</Fact>
{host.gpus.map((gpu) => (
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 343e8ef5..c901e7f8 100644
--- a/apps/web/src/features/local-models/local-model-row.tsx
+++ b/apps/web/src/features/local-models/local-model-row.tsx
@@ -26,33 +26,99 @@ import type {
LocalModelsView,
} from "./local-models-queries";
import {
+ agentNames,
downloadPercent,
downloadStatusDetail,
downloadStopped,
formatGigabytes,
placeName,
rowBadges,
+ rowBadgesOverflowTitle,
+ usedByBadge,
type ModelEntry,
type ModelStatus,
} from "./local-models-rules";
-const familyIcons: Record<NonNullable<LocalModel["family"]>, IconSvgElement> = {
- claude: ClaudeIcon,
- deepseek: DeepseekIcon,
- gemma: GoogleGeminiIcon,
- glm: AiChipIcon,
- grok: GrokIcon,
- kimi: KimiAiIcon,
- llama: MetaIcon,
- mistral: MistralIcon,
- openai: ChatGptIcon,
- other: AiChipIcon,
- phi: MicrosoftIcon,
- qwen: QwenIcon,
+interface FamilyBrand {
+ icon: IconSvgElement;
+ tone: string;
+}
+
+const defaultBrand: FamilyBrand = {
+ icon: AiChipIcon,
+ tone: "bg-muted text-muted-foreground",
+};
+
+const familyBrands: Record<NonNullable<LocalModel["family"]>, FamilyBrand> = {
+ claude: { icon: ClaudeIcon, tone: "bg-acorn-500/15 text-acorn-700" },
+ deepseek: {
+ icon: DeepseekIcon,
+ tone: "bg-bluebell-500/15 text-bluebell-700",
+ },
+ gemma: {
+ icon: GoogleGeminiIcon,
+ tone: "bg-bluebell-500/15 text-bluebell-700",
+ },
+ glm: { icon: AiChipIcon, tone: "bg-grass-500/15 text-grass-700" },
+ grok: { icon: GrokIcon, tone: "bg-fawn-500/15 text-fawn-700" },
+ kimi: { icon: KimiAiIcon, tone: "bg-bubblegum-500/15 text-bubblegum-700" },
+ llama: { icon: MetaIcon, tone: "bg-rain-500/15 text-rain-700" },
+ mistral: { icon: MistralIcon, tone: "bg-sun-500/15 text-sun-700" },
+ openai: { icon: ChatGptIcon, tone: "bg-lake-500/15 text-lake-700" },
+ other: defaultBrand,
+ phi: { icon: MicrosoftIcon, tone: "bg-lichen-500/15 text-lichen-700" },
+ qwen: { icon: QwenIcon, tone: "bg-lavender-500/15 text-lavender-700" },
};
-function familyIcon(family: LocalModel["family"]) {
- return family ? familyIcons[family] : AiChipIcon;
+function familyBrand(family: LocalModel["family"]): FamilyBrand {
+ return family ? familyBrands[family] : defaultBrand;
+}
+
+function cardTone(
+ status: ModelStatus,
+ recommended: boolean,
+ expanded: boolean,
+): string {
+ if (status === "loaded") {
+ return cn(
+ "bg-card shadow-sm",
+ expanded
+ ? "border-app-success/45"
+ : "border-[var(--app-status-success-border)] hover:border-app-success/45",
+ );
+ }
+ if (recommended) {
+ return cn(
+ "bg-[var(--app-card-info-surface)]",
+ expanded
+ ? "border-app-info/45"
+ : "border-[var(--app-card-info-border)] hover:border-app-info/45",
+ );
+ }
+ if (status === "downloading" || status === "loading") {
+ return cn(
+ "bg-card",
+ expanded ? "border-app-info/45" : "border-[var(--app-card-info-border)]",
+ );
+ }
+ if (status === "failed") {
+ return cn(
+ "bg-card",
+ expanded
+ ? "border-app-danger/45"
+ : "border-[var(--app-status-danger-border)] hover:border-app-danger/45",
+ );
+ }
+ if (status === "unavailable") {
+ return cn(
+ "bg-muted/35",
+ expanded ? "border-border-hover" : "border-border/70 hover:bg-muted/55",
+ );
+ }
+ return cn(
+ "bg-card",
+ expanded ? "border-border-hover" : "border-border hover:bg-accent/40",
+ );
}
/**
@@ -89,6 +155,146 @@ function stopRowClick(event: MouseEvent) {
event.stopPropagation();
}
+function RowStatusLine({
+ detail,
+ download,
+ recommended,
+ slower,
+ status,
+ tag,
+}: {
+ detail: string | null;
+ download: string;
+ recommended: boolean;
+ slower: boolean;
+ status: ModelStatus;
+ tag: { dot?: string; label: string; working?: boolean };
+}) {
+ return (
+ <span className="mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">
+ {tag.dot ? (
+ <span
+ aria-hidden
+ className={cn("size-1.5 shrink-0 rounded-full", tag.dot)}
+ />
+ ) : null}
+ <span
+ className={cn(
+ "truncate tabular-nums",
+ tag.working && "town-shimmer-text",
+ )}
+ >
+ <span
+ className={
+ status === "loaded"
+ ? "font-medium text-app-success"
+ : status === "failed"
+ ? "text-app-danger"
+ : tag.dot
+ ? "text-foreground"
+ : undefined
+ }
+ >
+ {tag.label}
+ </span>
+ {recommended ? (
+ <>
+ {" · "}
+ {download}
+ {" · "}
+ <span className="font-medium text-app-info">Recommended</span>
+ </>
+ ) : slower ? (
+ <>
+ {" · "}
+ {download}
+ {" · "}
+ <span className="text-app-warning">runs slower</span>
+ </>
+ ) : detail ? (
+ ` · ${detail}`
+ ) : null}
+ </span>
+ </span>
+ );
+}
+
+function RowMetadataPills({
+ badges,
+ entry,
+ overflowTitle,
+ status,
+ usedBy,
+}: {
+ badges: string[];
+ entry: ModelEntry;
+ overflowTitle?: string;
+ status: ModelStatus;
+ usedBy?: string;
+}) {
+ return (
+ <div
+ className={cn(
+ "col-span-2 row-start-2 flex flex-wrap items-center gap-1.5 pl-13 @2xl:col-span-1 @2xl:col-start-2 @2xl:row-start-1 @2xl:justify-end @2xl:pl-0",
+ status === "unavailable" && "opacity-60",
+ )}
+ >
+ {usedBy ? (
+ <span
+ className={cn(
+ "rounded-full px-2 py-0.5 text-xs font-medium tabular-nums",
+ status === "loaded"
+ ? "bg-[var(--app-status-success-surface)] text-app-success"
+ : "bg-muted text-secondary-foreground",
+ )}
+ title={`Used by ${agentNames(entry)}`}
+ >
+ {usedBy}
+ </span>
+ ) : null}
+ {badges.map((badge, index) => (
+ <span
+ className="rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground"
+ key={badge}
+ title={index === badges.length - 1 ? overflowTitle : undefined}
+ >
+ {badge}
+ </span>
+ ))}
+ </div>
+ );
+}
+
+function DownloadProgress({
+ model,
+ progress,
+}: {
+ model: LocalModel;
+ progress: number;
+}) {
+ return (
+ <div className="px-4 pb-3">
+ <span
+ aria-label={`${model.name} download progress`}
+ aria-valuemax={100}
+ aria-valuemin={0}
+ aria-valuenow={progress}
+ className="block h-1.5 overflow-hidden rounded-full bg-muted"
+ role="progressbar"
+ >
+ <span
+ className={cn(
+ "block h-full origin-left rounded-full bg-app-info transition-transform duration-200 motion-reduce:transition-none",
+ model.download?.step === "verify" &&
+ "animate-pulse motion-reduce:animate-none",
+ )}
+ style={{ transform: `scaleX(${progress / 100})` }}
+ />
+ </span>
+ </div>
+ );
+}
+
/**
* One catalog model on one Computer: a full-width Connectors-style card whose
* header carries the status and one action, and which expands to the details.
@@ -127,7 +333,14 @@ export function ModelRow({
: statusTags[status];
const progress = downloadPercent(model);
const download = formatGigabytes(model.download_bytes);
+ const recommended = status === "available" && model.recommended;
+ const slower =
+ status === "available" && !model.recommended && model.fit === "system";
+ const brand = familyBrand(model.family);
+ const usedBy = usedByBadge(entry);
const badges = rowBadges(model);
+ const overflowTitle = rowBadgesOverflowTitle(model);
+ const hasMeta = Boolean(usedBy) || badges.length > 0;
const detail = {
available: model.recommended
? `${download} · Recommended`
@@ -170,112 +383,111 @@ export function ModelRow({
return (
<article
className={cn(
- "rounded-xl border bg-card transition-colors duration-150 motion-reduce:transition-none",
- expanded ? "border-border-hover" : "border-border hover:bg-accent/40",
+ "@container rounded-xl border transition-[background-color,border-color,box-shadow] duration-150 motion-reduce:transition-none",
+ cardTone(status, recommended, expanded),
)}
+ data-recommended={recommended || undefined}
+ data-status={status}
>
- <div className="flex items-center gap-3 px-4 py-3">
+ <div
+ className={cn(
+ "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-2 px-4 py-3",
+ hasMeta && "@2xl:grid-cols-[minmax(0,1fr)_auto_auto]",
+ )}
+ >
<button
aria-controls={panelId}
aria-expanded={expanded}
aria-label={model.name}
className={cn(
- "flex min-w-0 flex-1 items-center gap-3 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ "col-start-1 row-start-1 flex min-w-0 items-center gap-3 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
status === "unavailable" && "opacity-60",
)}
onClick={handlers.onToggle}
type="button"
>
<span
- className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-card text-foreground shadow-outline"
+ aria-hidden
+ className={cn(
+ "flex size-10 shrink-0 items-center justify-center rounded-lg shadow-outline",
+ brand.tone,
+ )}
data-family={model.family ?? "other"}
>
- <Icon icon={familyIcon(model.family)} size={20} />
+ <Icon icon={brand.icon} size={20} />
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium text-foreground">
{model.name}
</span>
- <span className="mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">
- {tag.dot ? (
- <span
- aria-hidden
- className={cn("size-1.5 shrink-0 rounded-full", tag.dot)}
- />
- ) : null}
- <span
- className={cn("truncate", tag.working && "town-shimmer-text")}
- >
- <span className={tag.dot ? "text-foreground" : undefined}>
- {tag.label}
- </span>
- {detail ? ` · ${detail}` : null}
- </span>
- </span>
+ <RowStatusLine
+ detail={detail}
+ download={download}
+ recommended={recommended}
+ slower={slower}
+ status={status}
+ tag={tag}
+ />
</span>
</button>
- {badges.length ? (
- <span className="flex shrink-0 items-center gap-1.5">
- {badges.map((badge) => (
- <span
- className="rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground"
- key={badge}
- >
- {badge}
- </span>
- ))}
- </span>
+ {hasMeta ? (
+ <RowMetadataPills
+ badges={badges}
+ entry={entry}
+ overflowTitle={overflowTitle}
+ status={status}
+ usedBy={usedBy}
+ />
) : null}
- {action ? (
+ <div
+ className={cn(
+ "col-start-2 row-start-1 flex shrink-0 items-center gap-1.5",
+ hasMeta && "@2xl:col-start-3",
+ )}
+ >
+ {action ? (
+ <Button
+ aria-label={`${action[0]} ${model.name}`}
+ className="px-2.5"
+ disabled={disabled}
+ loading={requested === action[2]}
+ onClick={(event) => {
+ stopRowClick(event);
+ action[1]();
+ }}
+ size="compact"
+ tone={
+ status === "downloading"
+ ? "ghost"
+ : recommended
+ ? "primary"
+ : "secondary"
+ }
+ >
+ {action[0]}
+ </Button>
+ ) : null}
<Button
- aria-label={`${action[0]} ${model.name}`}
- className="px-2.5"
- disabled={disabled}
- loading={requested === action[2]}
- onClick={(event) => {
- stopRowClick(event);
- action[1]();
- }}
- size="compact"
- tone={status === "downloading" ? "ghost" : "secondary"}
+ aria-hidden
+ className="text-muted-foreground"
+ onClick={handlers.onToggle}
+ size="compactIcon"
+ tabIndex={-1}
+ tone="ghost"
>
- {action[0]}
+ <Icon
+ className={cn(
+ "transition-transform duration-200 motion-reduce:transition-none",
+ !expanded && "-rotate-90",
+ )}
+ icon={ArrowDown01Icon}
+ size={14}
+ />
</Button>
- ) : null}
- <Button
- aria-hidden
- className="text-muted-foreground"
- onClick={handlers.onToggle}
- size="compactIcon"
- tabIndex={-1}
- tone="ghost"
- >
- <Icon
- className={cn(
- "transition-transform duration-200 motion-reduce:transition-none",
- !expanded && "-rotate-90",
- )}
- icon={ArrowDown01Icon}
- size={14}
- />
- </Button>
+ </div>
</div>
{entry.status === "downloading" ? (
- <div className="px-4 pb-3">
- <span
- aria-label={`${model.name} download progress`}
- aria-valuemax={100}
- aria-valuemin={0}
- aria-valuenow={progress}
- className="block h-1 overflow-hidden rounded-full bg-muted"
- role="progressbar"
- >
- <span
- className="block h-full origin-left rounded-full bg-primary transition-transform duration-200 motion-reduce:transition-none"
- style={{ transform: `scaleX(${progress / 100})` }}
- />
- </span>
- </div>
+ <DownloadProgress model={model} progress={progress} />
) : null}
{expanded ? (
<div
@@ -290,29 +502,31 @@ export function ModelRow({
</p>
) : null}
<ModelFacts entry={entry} view={view} />
- {removable ? (
- <Button
- className="mt-2"
- disabled={disabled}
- loading={requested === "remove"}
- onClick={handlers.onRemove}
- size="compact"
- tone="danger"
- >
- Remove from computer
- </Button>
- ) : null}
- {stopped ? (
- <Button
- className="mt-2"
- disabled={disabled}
- loading={requested === "cancel"}
- onClick={handlers.onCancel}
- size="compact"
- tone="danger"
- >
- Discard download
- </Button>
+ {removable || stopped ? (
+ <div className="mt-2 border-t border-border/70 pt-2.5">
+ {removable ? (
+ <Button
+ disabled={disabled}
+ loading={requested === "remove"}
+ onClick={handlers.onRemove}
+ size="compact"
+ tone="danger"
+ >
+ Remove from computer
+ </Button>
+ ) : null}
+ {stopped ? (
+ <Button
+ disabled={disabled}
+ loading={requested === "cancel"}
+ onClick={handlers.onCancel}
+ size="compact"
+ tone="danger"
+ >
+ Discard download
+ </Button>
+ ) : null}
+ </div>
) : null}
</div>
) : null}
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 dcbd775f..d43241ed 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
@@ -647,6 +647,10 @@ describe("LocalModelsPage", () => {
renderPage(fixture);
await findModels();
+ expect(
+ within(card("Qwen3 Coder 30B")).getByText("2 Agents"),
+ ).toHaveAttribute("title", "Used by Research agent, Code reviewer");
+
fireEvent.click(
screen.getByRole("button", { name: "Unload Qwen3 Coder 30B" }),
);
@@ -679,6 +683,9 @@ describe("LocalModelsPage", () => {
screen.getByRole("region", { name: "Qwen3 Coder 30B details" }),
).toHaveTextContent("No Agent yet"),
);
+ expect(
+ within(card("Qwen3 Coder 30B")).queryByText(/^\d+ Agents?$/),
+ ).not.toBeInTheDocument();
fireEvent.click(
screen.getByRole("button", { name: "Unload Qwen3 Coder 30B" }),
);
@@ -1134,16 +1141,24 @@ describe("LocalModelsPage", () => {
await findModels();
const coderCard = card("Qwen3 Coder 30B");
- expect(coderCard.querySelector('[data-family="qwen"]')).toBeInTheDocument();
+ expect(coderCard).toHaveAttribute("data-status", "loaded");
+ const qwenTile = coderCard.querySelector('[data-family="qwen"]');
+ expect(qwenTile).toBeInTheDocument();
+ expect(qwenTile).toHaveClass("bg-lavender-500/15", "text-lavender-700");
+ expect(within(coderCard).getByText("2 Agents")).toBeVisible();
expect(within(coderCard).getByText("3B active")).toBeVisible();
expect(within(coderCard).getByText("Tool use")).toBeVisible();
expect(within(coderCard).getByText("Reasoning")).toBeVisible();
- expect(within(coderCard).getByText("+1")).toBeVisible();
+ expect(within(coderCard).getByText("+1")).toHaveAttribute(
+ "title",
+ "Coding",
+ );
const gemmaCard = card("Gemma 3 4B");
- expect(
- gemmaCard.querySelector('[data-family="gemma"]'),
- ).toBeInTheDocument();
+ expect(gemmaCard).toHaveAttribute("data-status", "available");
+ const gemmaTile = gemmaCard.querySelector('[data-family="gemma"]');
+ expect(gemmaTile).toBeInTheDocument();
+ expect(gemmaTile).toHaveClass("bg-bluebell-500/15", "text-bluebell-700");
expect(within(gemmaCard).getByText("Vision")).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: "Qwen3 Coder 30B" }));
@@ -1166,6 +1181,48 @@ describe("LocalModelsPage", () => {
expect(link).toHaveAttribute("rel", "noopener noreferrer");
});
+ it("distinguishes card states and keeps a single-node responsive header without competing utilities", async () => {
+ const view = withModel(
+ withModel(labView(), "gpt-oss-20b:Q4_K_M", {
+ capabilities: ["tool_use"],
+ parameters: "20B",
+ }),
+ "gemma3-27b:Q4_K_M",
+ {
+ error: { code: "ENGINE_START_FAILED" },
+ state: "failed",
+ },
+ );
+ renderPage(setup([view]));
+ await findModels();
+
+ const loadedCard = card("Qwen3 Coder 30B");
+ expect(loadedCard).toHaveAttribute("data-status", "loaded");
+ expect(loadedCard).not.toHaveAttribute("data-recommended");
+
+ const recommendedCard = card("GPT-OSS 20B");
+ expect(recommendedCard).toHaveAttribute("data-status", "available");
+ expect(recommendedCard).toHaveAttribute("data-recommended", "true");
+ expect(
+ within(recommendedCard).getByRole("button", {
+ name: "Download GPT-OSS 20B",
+ }),
+ ).toHaveClass("bg-primary");
+ const badgeGroup = within(recommendedCard)
+ .getByText("Tool use")
+ .closest("div")!;
+ expect(badgeGroup).toHaveClass("flex");
+ expect(badgeGroup).not.toHaveClass("hidden");
+ expect(recommendedCard.firstElementChild).toHaveClass("grid");
+ expect(recommendedCard.firstElementChild).not.toHaveClass("flex", "hidden");
+
+ const failedCard = card("Gemma 3 27B");
+ expect(failedCard).toHaveAttribute("data-status", "failed");
+
+ const unavailableCard = card("Llama 3.1 405B");
+ expect(unavailableCard).toHaveAttribute("data-status", "unavailable");
+ });
+
it("shows live download rate and ETA when bytes_per_second is reported", async () => {
const mb = 1024 * 1024;
renderPage(
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 f3a9b273..20c7d58e 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
@@ -5,6 +5,7 @@ import {
downloadStatusDetail,
downloadStopped,
formatGigabytes,
+ isModelOnComputer,
loadCheck,
makeRoomSelection,
makesRoom,
@@ -16,8 +17,10 @@ import {
placeName,
poolLabel,
rowBadges,
+ rowBadgesOverflowTitle,
safeModelSourceUrl,
speedLabel,
+ usedByBadge,
} from "./local-models-rules";
import {
gb,
@@ -192,8 +195,28 @@ describe("local models rules", () => {
parameters: "4B",
});
expect(parametersLabel(dense)).toBe("4B (Dense)");
- // Avoid repeating "4B" next to a model whose title already includes it.
- expect(rowBadges(dense)).toEqual(["Tool use"]);
+ expect(rowBadges(dense)).toEqual(["4B", "Tool use"]);
+
+ // Collapsed badges depend strictly on structured fields, never name or description.
+ expect(
+ rowBadges({
+ ...dense,
+ description: "Vision reasoning model with 70B scale.",
+ name: "Renamed Without Size",
+ }),
+ ).toEqual(rowBadges(dense));
+
+ expect(
+ rowBadgesOverflowTitle(
+ localModel({
+ active_parameters: "3B",
+ capabilities: ["coding", "reasoning", "tool_use", "vision"],
+ id: "qwen3-coder-30b:Q4_K_M",
+ name: "Qwen3 Coder 30B",
+ }),
+ ),
+ ).toBe("Reasoning, Coding");
+ expect(rowBadgesOverflowTitle(dense)).toBeUndefined();
expect(
rowBadges(
@@ -206,6 +229,76 @@ describe("local models rules", () => {
).toEqual(["70B"]);
});
+ it("identifies models on the computer and formats Agent usage chips", () => {
+ expect(
+ isModelOnComputer(localModel({ id: "m", name: "M" }), "available"),
+ ).toBe(false);
+ expect(
+ isModelOnComputer(localModel({ id: "m", name: "M" }), "unavailable"),
+ ).toBe(false);
+ expect(
+ isModelOnComputer(
+ localModel({
+ error: { code: "DOWNLOAD_FAILED" },
+ id: "m",
+ name: "M",
+ state: "failed",
+ }),
+ "failed",
+ ),
+ ).toBe(false);
+ expect(
+ isModelOnComputer(
+ localModel({ id: "m", name: "M", state: "loaded" }),
+ "loaded",
+ ),
+ ).toBe(true);
+
+ expect(
+ usedByBadge({
+ model: localModel({ id: "m", name: "M", state: "loaded" }),
+ status: "loaded",
+ used_by: [{ agent_id: "a1", name: "Research" }],
+ }),
+ ).toBe("1 Agent");
+ expect(
+ usedByBadge({
+ model: localModel({ id: "m", name: "M", state: "idle" }),
+ status: "idle",
+ used_by: [
+ { agent_id: "a1", name: "Research" },
+ { agent_id: "a2", name: "Writer" },
+ ],
+ }),
+ ).toBe("2 Agents");
+ expect(
+ usedByBadge({
+ model: localModel({ id: "m", name: "M", state: "loaded" }),
+ status: "loaded",
+ used_by: [],
+ }),
+ ).toBeUndefined();
+ expect(
+ usedByBadge({
+ model: localModel({ id: "m", name: "M", state: "absent" }),
+ status: "available",
+ used_by: [{ agent_id: "a1", name: "Research" }],
+ }),
+ ).toBeUndefined();
+ expect(
+ usedByBadge({
+ model: localModel({
+ error: { code: "NETWORK_UNAVAILABLE" },
+ id: "m",
+ name: "M",
+ state: "failed",
+ }),
+ status: "failed",
+ used_by: [{ agent_id: "a1", name: "Research" }],
+ }),
+ ).toBeUndefined();
+ });
+
it("formats live download speed, ETA, prompt speed, and safe source URLs", () => {
const mb = 1024 * 1024;
expect(
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 de890869..599c2b43 100644
--- a/apps/web/src/features/local-models/local-models-rules.ts
+++ b/apps/web/src/features/local-models/local-models-rules.ts
@@ -55,6 +55,21 @@ export function downloadStopped(model: LocalModel): boolean {
);
}
+/**
+ * Whether the Computer currently holds a model record (loaded, loading, idle,
+ * or a failed load, excluding absent rows and stopped partial downloads).
+ */
+export function isModelOnComputer(
+ model: LocalModel,
+ status: ModelStatus,
+): boolean {
+ return (
+ status !== "available" &&
+ status !== "unavailable" &&
+ !downloadStopped(model)
+ );
+}
+
const fitOrder: Record<LocalModel["fit"], number> = {
gpu: 0,
none: 2,
@@ -219,6 +234,18 @@ export function agentNames(entry: Pick<LocalModelView, "used_by">) {
return entry.used_by.map((user) => user.name).join(", ");
}
+/** Compact Agent count chip for a model on the Computer, or undefined when unused. */
+export function usedByBadge(
+ entry: Pick<ModelEntry, "model" | "status" | "used_by">,
+): string | undefined {
+ if (!isModelOnComputer(entry.model, entry.status) || !entry.used_by.length) {
+ return undefined;
+ }
+ return entry.used_by.length === 1
+ ? "1 Agent"
+ : `${entry.used_by.length} Agents`;
+}
+
export type LocalModelCapability = NonNullable<
LocalModel["capabilities"]
>[number];
@@ -253,26 +280,34 @@ export function parametersLabel(model: LocalModel) {
return scale || arch;
}
-/** Concise badges for the collapsed row: parameter scale (when distinct) and capabilities. */
-export function rowBadges(model: LocalModel): string[] {
+function allModelBadges(model: LocalModel): string[] {
const badges: string[] = [];
if (model.active_parameters) {
badges.push(`${model.active_parameters} active`);
- } else if (
- model.parameters &&
- !model.name.toLowerCase().includes(model.parameters.toLowerCase())
- ) {
+ } else if (model.parameters) {
badges.push(model.parameters);
}
for (const capability of modelCapabilities(model)) {
badges.push(capabilityCopy(capability));
}
+ return badges;
+}
+
+/** Concise badges for the collapsed row: structured parameter scale and capabilities. */
+export function rowBadges(model: LocalModel): string[] {
+ const badges = allModelBadges(model);
if (badges.length > 3) {
return [...badges.slice(0, 3), `+${badges.length - 3}`];
}
return badges;
}
+/** Full list of hidden badges when `rowBadges` truncates with `+N`. */
+export function rowBadgesOverflowTitle(model: LocalModel): string | undefined {
+ const badges = allModelBadges(model);
+ return badges.length > 3 ? badges.slice(3).join(", ") : undefined;
+}
+
function formatRemainingTime(seconds: number) {
if (seconds < 60) return `${seconds}s left`;
if (seconds < 3600) return `${Math.ceil(seconds / 60)}m left`;