Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

delete a model's cached weights from its own row on Media → Models

[._.]/ Adam Eivy220c676a5116
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index be133e665e..9fb179e603 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Media
+- **Freeing a model's disk space on Media → Models is now done from the model's own row.** The page listed the same models twice for two unrelated reasons: a catalog list at the top (what you can pick in the gen forms) where a downloaded built-in showed a padlock and no way to act on it, and a separate "Cached Models" list far below (what is on disk) where the delete actually lived. Reclaiming 12 GB meant recognizing the model a second time under a different name, after scrolling past the whole catalog. The two lists are now joined on the HuggingFace repo: each catalog row shows its own on-disk size, and carries its own **Delete weights** button — built-ins included, because the padlock only ever meant "you can't rename or remove this catalog entry," never "you can't reclaim the download." User-added models keep a separate **Remove** for the catalog entry itself, so the two very different deletes are distinct actions with distinct wording instead of one ambiguous trash icon. The catalog also moved above the add-from-HuggingFace form, so managing what you already have doesn't start with scrolling. The section below now lists only downloads the catalog does *not* cover — text encoders, and weights left behind by a model you removed — and says so. Every delete on the page, weights and LoRAs alike, now arms an inline confirm first: these are multi-gigabyte, no-undo actions that were one stray tap away.
+
- **Picking a source image on Video Gen now shows you the images.** Every gallery slot on the Video Gen form — the image-to-video source frame, the FFLF first/last pair, each multi-keyframe row, and each IC-LoRA reference row — used to be a dropdown of bare filenames capped at the 50 newest renders, which meant choosing a frame by guessing at `ltx-1754...png`. Those dropdowns are now the same searchable thumbnail-grid picker the Image Gen image-to-image form uses: your whole gallery, with previews, full-text search across prompt/model/seed/LoRA, and universe/collection and type filters. Uploading a frame from disk works exactly as before.
- **Accepting a restricted model's license now counts everywhere, and the acceptance appears where you're blocked.** Generating a music video scene with MiniMax H3 failed with "requires acknowledgement of its territory restrictions, Community License, and Acceptable Use Policy" — even for someone who had already ticked exactly that box on the Video Gen page, because the acknowledgement was only remembered in that page's browser storage and no other screen had a way to show it. The acknowledgement is now a property of the install: accept it once, on any screen, and every render path is authorized — the Video Gen page, the music video scene board, and background producers like pipeline stages and scheduled agent runs that have no way to ask you. The music video board also shows the acknowledgement panel inline next to its renderer picker, so the terms are readable and acceptable on the screen that triggers the render; when a render is refused anyway, the message now says where the acceptance is made instead of naming rules with no way to reach them. Acceptance is keyed to the exact reviewed license version, so a future revision asks again rather than inheriting an old approval. And because the recorded acknowledgement is the *only* thing that authorizes a render — a request can no longer assert its own — withdrawing it takes effect everywhere at once, including on work already sitting in the render queue.
diff --git a/client/src/pages/MediaModels.jsx b/client/src/pages/MediaModels.jsx
index 1075ae9d11..4e85381ffe 100644
--- a/client/src/pages/MediaModels.jsx
+++ b/client/src/pages/MediaModels.jsx
@@ -11,11 +11,19 @@
* (`~/.cache/huggingface/hub` unless HF_HOME is set). PortOS doesn't move or
* symlink them — it reads sizes for display and offers Delete to free disk.
* LoRAs sit in `data/loras/`.
+ *
+ * The two views are JOINED on the HF repo id: a catalog row whose weights are
+ * on disk shows its size and a "Delete weights" action inline, so freeing disk
+ * for a model no longer means scrolling to a second list to find the same model
+ * again. The cached-weights section below only lists what the catalog does NOT
+ * cover (text encoders, orphaned/removed repos).
*/
import { useState, useEffect, useCallback } from 'react';
-import { AlertTriangle, Trash2, Image as ImageIcon, Film, Plus, Pencil, Lock, X, Check } from 'lucide-react';
+import { AlertTriangle, Trash2, Image as ImageIcon, Film, Plus, Pencil, Lock, X, Check, HardDrive } from 'lucide-react';
import toast from '../components/ui/Toast';
+import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
+import useConfirmDelete from '../hooks/useConfirmDelete';
import {
listCachedModels,
deleteCachedModel,
@@ -26,6 +34,58 @@ import {
removeCustomMediaModel,
} from '../services/api';
+const DESTRUCTIVE_BTN = 'px-3 py-1.5 text-xs bg-port-error/20 hover:bg-port-error/40 text-port-error rounded disabled:opacity-50 flex items-center gap-1';
+
+/**
+ * One arm-then-confirm destructive action. All four deletes on this page —
+ * a catalog row's weights, a catalog row's registry entry, an orphaned cache
+ * dir, a LoRA — are the same shape: a trigger that arms `confirmKey`, swapped
+ * in place for the inline confirm pair. Keeping it in one component means the
+ * confirm UX can't drift between them. `confirm` is a useConfirmDelete()
+ * result, so only one action across the whole page is ever armed.
+ */
+function DeleteAction({
+ confirm,
+ confirmKey,
+ prompt,
+ ariaLabel,
+ label,
+ confirmText = 'Delete',
+ busyText = 'Deleting…',
+ busy = false,
+ title,
+ className = DESTRUCTIVE_BTN,
+ icon: Icon = Trash2,
+ onConfirm,
+}) {
+ if (confirm.isConfirming(confirmKey)) {
+ return (
+ <ConfirmButtonPair
+ prompt={prompt}
+ confirmText={confirmText}
+ confirmIcon={Icon}
+ busyText={busyText}
+ busy={busy}
+ ariaLabel={ariaLabel}
+ onConfirm={() => confirm.confirmDelete(onConfirm)}
+ onCancel={confirm.cancelDelete}
+ className="shrink-0"
+ />
+ );
+ }
+ return (
+ <button
+ type="button"
+ onClick={() => confirm.requestDelete(confirmKey)}
+ disabled={busy}
+ title={title}
+ className={className}
+ >
+ <Icon className="w-3 h-3" /> {busy ? busyText : label}
+ </button>
+ );
+}
+
export default function MediaModels() {
const [data, setData] = useState({ models: [], loras: [], hubDir: '', diskUsage: {} });
const [registry, setRegistry] = useState({ video: [], image: [] });
@@ -41,6 +101,11 @@ export default function MediaModels() {
const [editId, setEditId] = useState(null);
const [editFields, setEditFields] = useState({ name: '', steps: '', guidance: '' });
+ // One armed destructive action at a time, page-wide. Keys are namespaced
+ // (`weights:` / `entry:` on a catalog row, `cache:` / `lora:` below) because
+ // a catalog row carries TWO different deletes — its weights and its entry.
+ const deleteConfirm = useConfirmDelete();
+
const refresh = useCallback(() => {
setError(null);
// silent:true — the failure renders as the page's own full error state;
@@ -166,10 +231,25 @@ export default function MediaModels() {
);
}
+ // repo -> cached HF dir entry. Both sides key off `org/name`, so a catalog
+ // row can report its own on-disk size and delete its own weights.
+ const cachedByRepo = new Map((data.models || []).filter((m) => m.repo).map((m) => [m.repo, m]));
+ const claimedRepos = new Set(
+ [...registry.video, ...registry.image].map((m) => m.repo).filter(Boolean),
+ );
+ // Anything the catalog doesn't cover: text encoders, and repos whose catalog
+ // entry was removed but whose (multi-GB) weights are still on disk.
+ const unclaimedCached = (data.models || []).filter((m) => !claimedRepos.has(m.repo));
+
const renderRegistryRow = (m) => {
const isEditing = editId === m.id;
+ const cached = m.repo ? cachedByRepo.get(m.repo) : null;
+ const weightsBusy = cached && busy === cached.id;
+ // Same key the row is rendered under: an id can repeat across kinds, and a
+ // bare id would arm the image and video rows together.
+ const rowKey = `${m.kind}-${m.id}`;
return (
- <div key={`${m.kind}-${m.id}`} className="bg-port-bg border border-port-border rounded-lg p-3">
+ <div key={rowKey} className="bg-port-bg border border-port-border rounded-lg p-3">
{isEditing ? (
<div className="space-y-2">
<div>
@@ -219,30 +299,63 @@ export default function MediaModels() {
</div>
</div>
) : (
- <div className="flex items-center gap-3">
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2">
<div className="flex-1 min-w-0">
<div className="text-sm text-white truncate flex items-center gap-2">
{m.name}
- {m.builtIn && <Lock className="w-3 h-3 text-gray-500 shrink-0" title="Built-in (read-only)" />}
+ {m.builtIn && <Lock className="w-3 h-3 text-gray-500 shrink-0" title="Built-in catalog entry (name/steps are read-only)" />}
{m.deprecated && <span className="text-[10px] px-1 rounded bg-port-warning/20 text-port-warning">legacy</span>}
+ {cached && (
+ <span className="text-[10px] px-1 rounded bg-port-success/20 text-port-success shrink-0 flex items-center gap-1">
+ <HardDrive className="w-2.5 h-2.5" /> {cached.sizeHuman}
+ </span>
+ )}
</div>
<div className="text-xs text-gray-500 truncate">
{m.repo || m.id}
{' · '}
{m.runtime || m.runner || m.kind}
{m.steps != null && ` · ${m.steps} steps`}
+ {!cached && ' · weights not downloaded'}
</div>
</div>
- {!m.builtIn && (
- <div className="flex gap-1 shrink-0">
+ <div className="flex flex-wrap gap-1 shrink-0">
+ {!m.builtIn && (
<button type="button" onClick={() => startEdit(m)} disabled={busy === m.id} className="px-2 py-1.5 text-xs bg-port-card border border-port-border rounded text-gray-300 hover:bg-port-bg disabled:opacity-50 flex items-center gap-1">
<Pencil className="w-3 h-3" /> Edit
</button>
- <button type="button" onClick={() => handleRemoveCustom(m.id)} disabled={busy === m.id} className="px-2 py-1.5 text-xs bg-port-error/20 hover:bg-port-error/40 text-port-error rounded disabled:opacity-50 flex items-center gap-1">
- <Trash2 className="w-3 h-3" /> {busy === m.id ? '…' : 'Remove'}
- </button>
- </div>
- )}
+ )}
+ {/* Weights are deletable for BUILT-INS too — the lock only
+ covers the catalog entry, not the multi-GB download. */}
+ {cached && (
+ <DeleteAction
+ confirm={deleteConfirm}
+ confirmKey={`weights:${rowKey}`}
+ prompt={`Delete ${cached.sizeHuman} of weights?`}
+ ariaLabel={`Confirm deleting cached weights for ${m.name}`}
+ label="Delete weights"
+ title="Delete the downloaded weights (re-downloads on next use)"
+ busy={weightsBusy}
+ onConfirm={() => handleDeleteModel(cached.id)}
+ />
+ )}
+ {!m.builtIn && (
+ <DeleteAction
+ confirm={deleteConfirm}
+ confirmKey={`entry:${rowKey}`}
+ prompt="Remove from catalog?"
+ ariaLabel={`Confirm removing ${m.name} from the catalog`}
+ label="Remove"
+ confirmText="Remove"
+ busyText="Removing…"
+ title="Remove this entry from the model catalog"
+ icon={X}
+ className="px-2 py-1.5 text-xs bg-port-card border border-port-border rounded text-gray-300 hover:bg-port-bg disabled:opacity-50 flex items-center gap-1"
+ busy={busy === m.id}
+ onConfirm={() => handleRemoveCustom(m.id)}
+ />
+ )}
+ </div>
</div>
)}
</div>
@@ -260,7 +373,30 @@ export default function MediaModels() {
))}
</div>
- {/* Model Catalog — add from HuggingFace + manage user-added entries */}
+ {/* Model catalog — every pickable model, with its on-disk footprint and
+ both of its deletes (weights / entry) on the row itself. Kept ABOVE
+ the add form so managing existing models needs no scrolling. */}
+ <div className="bg-port-card border border-port-border rounded-xl p-5 space-y-4">
+ <h2 className="text-sm font-medium text-gray-300 flex items-center gap-2">
+ <ImageIcon className="w-4 h-4" /> Model catalog
+ </h2>
+ {registry.video.length > 0 && (
+ <div className="space-y-2">
+ <h3 className="text-xs font-medium text-gray-400 flex items-center gap-2"><Film className="w-3 h-3" /> Video models ({registry.video.length})</h3>
+ <div className="space-y-2">{registry.video.map(renderRegistryRow)}</div>
+ </div>
+ )}
+ {registry.image.length > 0 && (
+ <div className="space-y-2">
+ <h3 className="text-xs font-medium text-gray-400 flex items-center gap-2"><ImageIcon className="w-3 h-3" /> Image models ({registry.image.length})</h3>
+ <div className="space-y-2">{registry.image.map(renderRegistryRow)}</div>
+ </div>
+ )}
+ {registry.video.length === 0 && registry.image.length === 0 && (
+ <p className="text-xs text-gray-500">No models in the catalog yet — add one from HuggingFace below.</p>
+ )}
+ </div>
+
<div className="bg-port-card border border-port-border rounded-xl p-5 space-y-4">
<h2 className="text-sm font-medium text-gray-300 flex items-center gap-2">
<Plus className="w-4 h-4" /> Add a base model from HuggingFace
@@ -295,19 +431,6 @@ export default function MediaModels() {
GGUF-only, Wan, and HunyuanVideo repos are refused — no PortOS runtime can load them. For a GGUF LTX build, use the native MLX Q4 model instead.
</p>
</form>
-
- {registry.video.length > 0 && (
- <div className="space-y-2">
- <h3 className="text-xs font-medium text-gray-400 flex items-center gap-2"><Film className="w-3 h-3" /> Video models ({registry.video.length})</h3>
- <div className="space-y-2">{registry.video.map(renderRegistryRow)}</div>
- </div>
- )}
- {registry.image.length > 0 && (
- <div className="space-y-2">
- <h3 className="text-xs font-medium text-gray-400 flex items-center gap-2"><ImageIcon className="w-3 h-3" /> Image models ({registry.image.length})</h3>
- <div className="space-y-2">{registry.image.map(renderRegistryRow)}</div>
- </div>
- )}
</div>
{data.hubDir && (
@@ -318,27 +441,31 @@ export default function MediaModels() {
<div className="bg-port-card border border-port-border rounded-xl p-5 space-y-3">
<h2 className="text-sm font-medium text-gray-300 flex items-center gap-2">
- <ImageIcon className="w-4 h-4" /> Cached Models ({data.models.length})
+ <HardDrive className="w-4 h-4" /> Other cached weights ({unclaimedCached.length})
</h2>
- {data.models.length === 0 ? (
- <p className="text-xs text-gray-500">No models cached yet. They'll appear here as you generate.</p>
+ <p className="text-[11px] text-gray-600">
+ Downloads with no catalog entry — text encoders, and models you removed from the catalog above. Weights for catalog models are deleted from their own row.
+ </p>
+ {unclaimedCached.length === 0 ? (
+ <p className="text-xs text-gray-500">Nothing here — every cached download belongs to a model in the catalog above.</p>
) : (
<div className="space-y-2">
- {data.models.map((m) => (
- <div key={m.id} className="flex items-center gap-3 bg-port-bg border border-port-border rounded-lg p-3">
+ {unclaimedCached.map((m) => (
+ <div key={m.id} className="flex flex-wrap items-center gap-x-3 gap-y-2 bg-port-bg border border-port-border rounded-lg p-3">
<div className="flex-1 min-w-0">
<div className="text-sm text-white truncate">{m.label || m.repo}</div>
<div className="text-xs text-gray-500 truncate">{m.repo}</div>
</div>
<span className="text-sm text-gray-400 shrink-0">{m.sizeHuman}</span>
- <button
- type="button"
- onClick={() => handleDeleteModel(m.id)}
- disabled={busy === m.id}
- className="px-3 py-1.5 text-xs bg-port-error/20 hover:bg-port-error/40 text-port-error rounded disabled:opacity-50 flex items-center gap-1"
- >
- <Trash2 className="w-3 h-3" /> {busy === m.id ? 'Deleting...' : 'Delete'}
- </button>
+ <DeleteAction
+ confirm={deleteConfirm}
+ confirmKey={`cache:${m.id}`}
+ prompt={`Delete ${m.sizeHuman}?`}
+ ariaLabel={`Confirm deleting cached weights for ${m.label || m.repo}`}
+ label="Delete"
+ busy={busy === m.id}
+ onConfirm={() => handleDeleteModel(m.id)}
+ />
</div>
))}
</div>
@@ -356,20 +483,21 @@ export default function MediaModels() {
) : (
<div className="space-y-2">
{data.loras.map((l) => (
- <div key={l.filename} className="flex items-center gap-3 bg-port-bg border border-port-border rounded-lg p-3">
+ <div key={l.filename} className="flex flex-wrap items-center gap-x-3 gap-y-2 bg-port-bg border border-port-border rounded-lg p-3">
<div className="flex-1 min-w-0">
<div className="text-sm text-white truncate">{l.name}</div>
<div className="text-xs text-gray-500 truncate">{l.filename}</div>
</div>
<span className="text-sm text-gray-400 shrink-0">{l.sizeHuman}</span>
- <button
- type="button"
- onClick={() => handleDeleteLora(l.filename)}
- disabled={busy === l.filename}
- className="px-3 py-1.5 text-xs bg-port-error/20 hover:bg-port-error/40 text-port-error rounded disabled:opacity-50 flex items-center gap-1"
- >
- <Trash2 className="w-3 h-3" /> {busy === l.filename ? 'Deleting...' : 'Delete'}
- </button>
+ <DeleteAction
+ confirm={deleteConfirm}
+ confirmKey={`lora:${l.filename}`}
+ prompt={`Delete ${l.sizeHuman}?`}
+ ariaLabel={`Confirm deleting LoRA ${l.name}`}
+ label="Delete"
+ busy={busy === l.filename}
+ onConfirm={() => handleDeleteLora(l.filename)}
+ />
</div>
))}
</div>
diff --git a/client/src/pages/MediaModels.test.jsx b/client/src/pages/MediaModels.test.jsx
new file mode 100644
index 0000000000..18fe39d5a7
--- /dev/null
+++ b/client/src/pages/MediaModels.test.jsx
@@ -0,0 +1,127 @@
+/**
+ * Media Models — the catalog row owns BOTH of a model's deletes.
+ *
+ * The page used to render the catalog (with a read-only lock on built-ins) and
+ * the on-disk HF cache as two disconnected lists, so freeing a built-in model's
+ * weights meant scrolling past the whole catalog to find the same model again.
+ * These tests pin the join: a catalog row whose repo is cached shows its size
+ * and deletes its own weights (built-in included), and the cache section below
+ * only lists downloads the catalog doesn't cover.
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor, fireEvent, within } from '@testing-library/react';
+import MediaModels from './MediaModels';
+import {
+ listCachedModels,
+ listMediaModelRegistry,
+ deleteCachedModel,
+ removeCustomMediaModel,
+} from '../services/api';
+
+vi.mock('../services/api', () => ({
+ listCachedModels: vi.fn(),
+ listMediaModelRegistry: vi.fn(),
+ deleteCachedModel: vi.fn(),
+ deleteLora: vi.fn(),
+ addMediaModelFromHf: vi.fn(),
+ patchCustomMediaModel: vi.fn(),
+ removeCustomMediaModel: vi.fn(),
+}));
+
+vi.mock('../components/ui/Toast', () => ({
+ default: { success: vi.fn(), error: vi.fn(), info: vi.fn() },
+}));
+
+const BUILT_IN = {
+ id: 'example-video',
+ name: 'Example Video Model',
+ repo: 'example-org/example-video',
+ kind: 'video',
+ runtime: 'mlx',
+ builtIn: true,
+};
+const CUSTOM = {
+ id: 'hf-mine',
+ name: 'My Model',
+ repo: 'example-org/mine',
+ kind: 'image',
+ runner: 'mflux',
+ builtIn: false,
+};
+const CACHED_BUILT_IN = {
+ id: 'models--example-org--example-video',
+ repo: 'example-org/example-video',
+ label: 'Example Video Model (Video)',
+ size: 12e9,
+ sizeHuman: '12 GB',
+};
+const ORPHAN = {
+ id: 'models--example-org--text-encoder',
+ repo: 'example-org/text-encoder',
+ label: 'Text Encoder',
+ size: 9e9,
+ sizeHuman: '9 GB',
+};
+
+const CACHE_RESPONSE = {
+ models: [CACHED_BUILT_IN, ORPHAN],
+ loras: [],
+ hubDir: '/example/hub',
+ diskUsage: {},
+};
+
+describe('MediaModels catalog/cache join', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ listCachedModels.mockResolvedValue(CACHE_RESPONSE);
+ listMediaModelRegistry.mockResolvedValue({ video: [BUILT_IN], image: [CUSTOM] });
+ deleteCachedModel.mockResolvedValue({});
+ removeCustomMediaModel.mockResolvedValue({});
+ });
+
+ it('shows the cached size on the catalog row and "not downloaded" when it is absent', async () => {
+ render(<MediaModels />);
+ await screen.findByText('Example Video Model');
+ expect(screen.getByText('12 GB')).toBeInTheDocument();
+ expect(screen.getByText(/weights not downloaded/)).toBeInTheDocument();
+ });
+
+ it('deletes a BUILT-IN model\'s weights from its own row, behind a confirm', async () => {
+ render(<MediaModels />);
+ fireEvent.click(await screen.findByRole('button', { name: /Delete weights/ }));
+ expect(deleteCachedModel).not.toHaveBeenCalled();
+
+ const confirmPair = screen.getByRole('group', {
+ name: 'Confirm deleting cached weights for Example Video Model',
+ });
+ fireEvent.click(within(confirmPair).getByRole('button', { name: 'Delete' }));
+ await waitFor(() => expect(deleteCachedModel).toHaveBeenCalledWith(
+ CACHED_BUILT_IN.id,
+ { silent: true },
+ ));
+ // The row drops back to "not downloaded" without a refetch.
+ await waitFor(() => expect(listCachedModels).toHaveBeenCalledTimes(1));
+ expect(screen.queryByText('12 GB')).not.toBeInTheDocument();
+ });
+
+ it('lists only cache dirs with no catalog entry under "Other cached weights"', async () => {
+ render(<MediaModels />);
+ await screen.findByText('Text Encoder');
+ expect(screen.getByText(/Other cached weights \(1\)/)).toBeInTheDocument();
+ // The built-in's cache dir is represented by its catalog row, not repeated.
+ expect(screen.queryByText('Example Video Model (Video)')).not.toBeInTheDocument();
+ });
+
+ it('arms a separate confirm for removing a custom catalog entry', async () => {
+ render(<MediaModels />);
+ fireEvent.click(await screen.findByRole('button', { name: /^Remove$/ }));
+ expect(removeCustomMediaModel).not.toHaveBeenCalled();
+ expect(screen.getByText('Remove from catalog?')).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Remove' }));
+ await waitFor(() => expect(removeCustomMediaModel).toHaveBeenCalledWith(
+ CUSTOM.id,
+ { silent: true },
+ ));
+ });
+});