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

fix: require an inline confirm before deleting an installed LoRA file (#3519)

[._.]/ Adam Eivy0582f8643bda
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index b0bbac5afe..f797591fcf 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -97,6 +97,8 @@
- **[issue-3515] A failed AI goal organization stacked two identical error toasts on top of each other.** Both the Goals list and the Goals tree already showed their own "Failed to organize goals" message, but the API wrapper they called dropped the caller's request-level options on the floor, so the shared request helper had no way to be told to stay quiet and toasted the same failure a second time. `organizeGoals` now takes the provider selection and the request options as separate arguments and forwards the latter, and both views ask for silence — the wrapper is not hard-coded silent, so a future caller with no error UI of its own still gets the helper's toast. Guarded from both ends: a service-level test drives the real request helper against a failing fetch and asserts nothing toasts, and each view asserts it passes `{ silent: true }` and fires exactly one toast.
+- **[issue-3519] One stray tap on an installed LoRA card permanently deleted a multi-gigabyte model file.** The trash icon on the LoRA Manager's installed cards went straight to the delete — no confirmation, no undo, and re-downloading or re-training is measured in hours. It now arms an inline "Delete file? / Delete / Cancel" pair in place of the card's action row, using the same `useConfirmDelete` + `ConfirmButtonPair` pattern the rest of PortOS uses for destructive list actions, so only one card is ever armed at a time and cancelling leaves the file untouched. The pair replaces the whole row rather than squeezing in beside Test and the Civitai link, because a single-column phone layout has no room for both, and it stays put with a spinner while the delete is in flight instead of flashing the trash icon back mid-request.
+
## Three.js Models
- **[issue-3481] A generated model now tells you which of its own promises it did not actually build.** The spec check only ever proved that every feature the model listed pointed at a real part — so a spec could name eight defining features, aim all eight at the same box, and still validate clean: one fused mesh wearing a photograph. Each finished generation is now measured against its own inventory and the result is shown on the model's page: features collapsed onto a single shared part, geometry no feature claims, and features nothing was built for at all. Severity follows how much of the subject rides on the miss — a missing defining feature is an error, fine relief folded into the piece it sits on is called out as the correct modeling choice rather than a defect. When you hit Refine without typing your own notes, the refinement pass is now aimed at exactly those errors instead of a generic "improve it." The page states the check's honest limit alongside the findings: it proves the model built what its spec promised, never that the spec promised enough.
diff --git a/client/src/pages/Loras.jsx b/client/src/pages/Loras.jsx
index 7270f59e8c..da2db2cc3a 100644
--- a/client/src/pages/Loras.jsx
+++ b/client/src/pages/Loras.jsx
@@ -15,7 +15,9 @@ import PageSkeleton from '../components/ui/PageSkeleton';
import toast from '../components/ui/Toast';
import Modal from '../components/ui/Modal';
import Banner from '../components/ui/Banner';
+import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import { FormField } from '../components/ui/FormField';
+import { useConfirmDelete } from '../hooks/useConfirmDelete';
import { formatBytes } from '../utils/formatters';
import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, isVideoLoraFamily } from '../lib/runnerFamilies';
import {
@@ -92,6 +94,10 @@ export default function Loras() {
// unrecognizable id shouldn't dead-end at an error toast.
const [hfFamilyPrompt, setHfFamilyPrompt] = useState(null);
const [deleting, setDeleting] = useState(null);
+ // Arms one installed card's delete at a time — a LoRA is a multi-gigabyte
+ // file with no undo, so the trash icon only reveals an inline confirm pair
+ // instead of deleting on the first click/tap (#3519).
+ const deleteConfirm = useConfirmDelete();
// Civitai auth — `auth` is `{ hasKey, source }`; `authPrompt` is set to a
// pending install URL when a 401/403 redirects the user to the inline key
// form. The form saves the key and retries the same install in one click
@@ -424,8 +430,8 @@ export default function Loras() {
render it flat. */}
{visibleLoras.length > 0 && (
mediaFilter === 'all'
- ? <InstalledGroups loras={visibleLoras} deleting={deleting} onDelete={handleDelete} />
- : <LoraGrid loras={visibleLoras} deleting={deleting} onDelete={handleDelete} />
+ ? <InstalledGroups loras={visibleLoras} deleting={deleting} onDelete={handleDelete} deleteConfirm={deleteConfirm} />
+ : <LoraGrid loras={visibleLoras} deleting={deleting} onDelete={handleDelete} deleteConfirm={deleteConfirm} />
)}
</div>
</div>
@@ -1033,11 +1039,17 @@ function CivitaiAuthModal({ pendingUrl, message, auth, onClose, onSaved, onRetry
// Responsive grid of installed LoRA cards. Extracted so the Installed section
// can render either one flat grid (filtered view) or several grouped grids
// (the "All" view) without duplicating the grid markup.
-function LoraGrid({ loras, deleting, onDelete }) {
+function LoraGrid({ loras, deleting, onDelete, deleteConfirm }) {
return (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
{loras.map((lora) => (
- <LoraCard key={lora.filename} lora={lora} onDelete={() => onDelete(lora.filename)} deleting={deleting === lora.filename} />
+ <LoraCard
+ key={lora.filename}
+ lora={lora}
+ onDelete={() => onDelete(lora.filename)}
+ deleting={deleting === lora.filename}
+ deleteConfirm={deleteConfirm}
+ />
))}
</div>
);
@@ -1047,7 +1059,7 @@ function LoraGrid({ loras, deleting, onDelete }) {
// with a labeled header mirroring the suggestion panel's grouping. Empty groups
// are omitted. Video is listed first (fewer, and the source of the layout
// confusion this grouping resolves).
-function InstalledGroups({ loras, deleting, onDelete }) {
+function InstalledGroups({ loras, deleting, onDelete, deleteConfirm }) {
const video = loras.filter((l) => isVideoLoraFamily(l.runnerFamily));
const image = loras.filter((l) => !isVideoLoraFamily(l.runnerFamily));
const groups = [
@@ -1062,14 +1074,14 @@ function InstalledGroups({ loras, deleting, onDelete }) {
<h3 className="text-sm font-medium text-gray-300">{g.label}</h3>
<span className="text-xs text-gray-600">{g.items.length}</span>
</div>
- <LoraGrid loras={g.items} deleting={deleting} onDelete={onDelete} />
+ <LoraGrid loras={g.items} deleting={deleting} onDelete={onDelete} deleteConfirm={deleteConfirm} />
</div>
))}
</div>
);
}
-function LoraCard({ lora, onDelete, deleting }) {
+function LoraCard({ lora, onDelete, deleting, deleteConfirm }) {
const family = lora.runnerFamily;
const familyLabel = family ? (RUNNER_LABEL[family] || family) : 'Unsupported base';
const badgeClass = family ? (RUNNER_BADGE_CLASS[family] || 'bg-gray-600/20 text-gray-300 border-gray-500/30') : 'bg-port-warning/20 text-port-warning border-port-warning/30';
@@ -1081,6 +1093,10 @@ function LoraCard({ lora, onDelete, deleting }) {
// preselect an LTX adapter into an incompatible image render.
const isVideoLora = family === VIDEO_LORA_FAMILIES.LTX_VIDEO;
const testHref = `${isVideoLora ? '/media/video' : '/media/image'}?lora=${encodeURIComponent(lora.filename)}`;
+ // The confirm pair also stays mounted while the delete is in flight (the hook
+ // disarms the moment it fires), so the spinner replaces the row rather than
+ // flashing the trash icon back for the duration of the request.
+ const confirming = deleteConfirm.isConfirming(lora.filename) || deleting;
return (
<div className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">
@@ -1137,44 +1153,61 @@ function LoraCard({ lora, onDelete, deleting }) {
{civitai?.baseModel && (<><span>Base model</span><span className="text-gray-300 truncate text-right" title={civitai.baseModel}>{civitai.baseModel}</span></>)}
</div>
- <div className="mt-auto flex items-center gap-2">
- <Link
- to={testHref}
- className="flex-1 bg-port-accent text-white px-3 py-1.5 rounded text-xs font-medium hover:bg-port-accent/90 text-center"
- >
- Test
- </Link>
- {civitai?.url && (
- <a
- href={civitai.url}
- target="_blank"
- rel="noopener noreferrer"
- className="text-gray-400 hover:text-gray-200 p-1.5 rounded hover:bg-port-bg"
- title="Open on Civitai"
+ {/* Armed state replaces the whole action row instead of squeezing the
+ confirm pair in beside Test/Civitai — a narrow card (or a phone at
+ one column) has no room for both, and the row would wrap. */}
+ {confirming ? (
+ <div className="mt-auto">
+ <ConfirmButtonPair
+ prompt="Delete file?"
+ confirmText="Delete"
+ confirmIcon={Trash2}
+ busy={deleting}
+ busyText="Deleting"
+ ariaLabel={`Confirm delete ${lora.name}`}
+ onConfirm={() => deleteConfirm.confirmDelete(onDelete)}
+ onCancel={deleteConfirm.cancelDelete}
+ />
+ </div>
+ ) : (
+ <div className="mt-auto flex items-center gap-2">
+ <Link
+ to={testHref}
+ className="flex-1 bg-port-accent text-white px-3 py-1.5 rounded text-xs font-medium hover:bg-port-accent/90 text-center"
>
- <ExternalLink size={14} />
- </a>
- )}
- {lora.huggingface?.url && (
- <a
- href={lora.huggingface.url}
- target="_blank"
- rel="noopener noreferrer"
- className="text-gray-400 hover:text-gray-200 p-1.5 rounded hover:bg-port-bg"
- title="Open on HuggingFace"
+ Test
+ </Link>
+ {civitai?.url && (
+ <a
+ href={civitai.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-gray-400 hover:text-gray-200 p-1.5 rounded hover:bg-port-bg"
+ title="Open on Civitai"
+ >
+ <ExternalLink size={14} />
+ </a>
+ )}
+ {lora.huggingface?.url && (
+ <a
+ href={lora.huggingface.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-gray-400 hover:text-gray-200 p-1.5 rounded hover:bg-port-bg"
+ title="Open on HuggingFace"
+ >
+ <ExternalLink size={14} />
+ </a>
+ )}
+ <button
+ onClick={() => deleteConfirm.requestDelete(lora.filename)}
+ className="text-port-error hover:text-port-error/80 p-1.5 rounded hover:bg-port-error/10"
+ title={`Delete ${lora.name}`} aria-label={`Delete ${lora.name}`}
>
- <ExternalLink size={14} />
- </a>
- )}
- <button
- onClick={onDelete}
- disabled={deleting}
- className="text-port-error hover:text-port-error/80 p-1.5 rounded hover:bg-port-error/10 disabled:opacity-50"
- title="Delete LoRA" aria-label="Delete LoRA"
- >
- <Trash2 size={14} />
- </button>
- </div>
+ <Trash2 size={14} />
+ </button>
+ </div>
+ )}
</div>
</div>
);
diff --git a/client/src/pages/Loras.test.jsx b/client/src/pages/Loras.test.jsx
new file mode 100644
index 0000000000..51d3b87adf
--- /dev/null
+++ b/client/src/pages/Loras.test.jsx
@@ -0,0 +1,104 @@
+/**
+ * Delete-confirmation tests for the installed-LoRA cards (#3519). A LoRA is a
+ * multi-gigabyte file with no undo, so the trash icon must only arm an inline
+ * confirm pair — one stray tap can never reach deleteLoraFull.
+ */
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor, fireEvent } from '@testing-library/react';
+import { MemoryRouter } from 'react-router';
+import Loras from './Loras';
+import { listLorasFull, deleteLoraFull } from '../services/api';
+
+vi.mock('../services/api', () => ({
+ listLorasFull: vi.fn(),
+ installLoraFromCivitai: vi.fn(),
+ installLoraFromHuggingfaceStream: vi.fn(),
+ deleteLoraFull: vi.fn(),
+ getCivitaiAuth: vi.fn(async () => ({ hasKey: false, source: 'none' })),
+ setCivitaiAuth: vi.fn(),
+ clearCivitaiAuth: vi.fn(),
+ getCivitaiSuggestions: vi.fn(async () => ({ runners: {}, video: [], fetchedAt: null })),
+ searchCivitaiLoras: vi.fn(),
+}));
+
+vi.mock('../components/ui/Toast', () => ({
+ default: { success: vi.fn(), error: vi.fn(), info: vi.fn() },
+}));
+
+const LORA = {
+ filename: 'example-lora.safetensors',
+ name: 'Example LoRA',
+ runnerFamily: 'mflux',
+ sizeBytes: 1234567,
+ recommendedScale: 0.9,
+ triggerWords: [],
+};
+const OTHER_LORA = { ...LORA, filename: 'second-lora.safetensors', name: 'Second LoRA' };
+
+const renderPage = () => render(<MemoryRouter><Loras /></MemoryRouter>);
+
+describe('Loras installed-card delete confirmation', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ listLorasFull.mockResolvedValue([LORA]);
+ deleteLoraFull.mockResolvedValue({});
+ });
+
+ it('arms an inline confirm instead of deleting on the first trash click', async () => {
+ renderPage();
+ const trash = await screen.findByLabelText('Delete Example LoRA');
+
+ fireEvent.click(trash);
+
+ expect(deleteLoraFull).not.toHaveBeenCalled();
+ expect(screen.getByText('Delete file?')).toBeInTheDocument();
+ expect(screen.queryByLabelText('Delete Example LoRA')).not.toBeInTheDocument();
+ });
+
+ it('deletes and drops the card from local state once confirmed', async () => {
+ renderPage();
+ fireEvent.click(await screen.findByLabelText('Delete Example LoRA'));
+
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+
+ await waitFor(() => expect(deleteLoraFull).toHaveBeenCalledWith('example-lora.safetensors', { silent: true }));
+ await waitFor(() => expect(screen.queryByText('Example LoRA')).not.toBeInTheDocument());
+ // Reactive local-state update, not a refetch.
+ expect(listLorasFull).toHaveBeenCalledTimes(1);
+ });
+
+ it('leaves the model file intact when the confirm is cancelled', async () => {
+ renderPage();
+ fireEvent.click(await screen.findByLabelText('Delete Example LoRA'));
+
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+
+ expect(deleteLoraFull).not.toHaveBeenCalled();
+ expect(screen.queryByText('Delete file?')).not.toBeInTheDocument();
+ expect(await screen.findByLabelText('Delete Example LoRA')).toBeInTheDocument();
+ });
+
+ it('arms only one card at a time', async () => {
+ listLorasFull.mockResolvedValue([LORA, OTHER_LORA]);
+ renderPage();
+
+ fireEvent.click(await screen.findByLabelText('Delete Example LoRA'));
+ fireEvent.click(screen.getByLabelText('Delete Second LoRA'));
+
+ expect(screen.getAllByText('Delete file?')).toHaveLength(1);
+ expect(screen.getByLabelText('Delete Example LoRA')).toBeInTheDocument();
+ expect(deleteLoraFull).not.toHaveBeenCalled();
+ });
+
+ it('keeps the card when the delete fails, re-showing the trash affordance', async () => {
+ deleteLoraFull.mockRejectedValue(new Error('Delete failed'));
+ renderPage();
+ fireEvent.click(await screen.findByLabelText('Delete Example LoRA'));
+
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+
+ await waitFor(() => expect(deleteLoraFull).toHaveBeenCalled());
+ expect(await screen.findByLabelText('Delete Example LoRA')).toBeInTheDocument();
+ expect(screen.getByText('Example LoRA')).toBeInTheDocument();
+ });
+});