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

feat: link data manager items to sources and allow individual cleanup

[._.]/ Adam Eivybd89afee7fe5
diff --git a/client/src/components/dataManager/DataTreemap.jsx b/client/src/components/dataManager/DataTreemap.jsx
index 27aafa00ef..91622bebde 100644
--- a/client/src/components/dataManager/DataTreemap.jsx
+++ b/client/src/components/dataManager/DataTreemap.jsx
@@ -30,16 +30,19 @@ function NestedItems({ items, width, height }) {
return rects.map(({ item, x, y, w, h }) => {
const showName = w > 56 && h > 18;
const showSize = showName && h > 34;
+ const Tile = item.sourceHref ? 'a' : 'span';
return (
- <span
+ <Tile
key={item.name}
- className="absolute block overflow-hidden rounded-sm border border-black/20 bg-black/15 px-1.5 py-0.5"
+ href={item.sourceHref}
+ aria-label={item.sourceHref ? `Open source: ${item.label || item.name}` : undefined}
+ className={`absolute block overflow-hidden rounded-sm border border-black/20 bg-black/15 px-1.5 py-0.5 ${item.sourceHref ? 'pointer-events-auto hover:bg-black/25 focus-visible:ring-2 focus-visible:ring-port-accent' : ''}`}
style={{ left: x + 1, top: y + 1, width: Math.max(0, w - 2), height: Math.max(0, h - 2) }}
- title={`${item.name} — ${formatBytes(item.size)}`}
+ title={`${item.label || item.name} — ${formatBytes(item.size)}`}
>
- {showName && <span className="block truncate text-[11px] leading-4 text-gray-200">{item.name}</span>}
+ {showName && <span className="block truncate text-[11px] leading-4 text-gray-200">{item.label || item.name}</span>}
{showSize && <span className="block truncate text-[10px] leading-3 text-gray-400 font-mono">{formatBytes(item.size)}</span>}
- </span>
+ </Tile>
);
});
}
@@ -86,30 +89,36 @@ export default function DataTreemap({ categories, looseBytes = 0, selectedKey, d
const items = selected && detail?.key === cat.key ? detail.items : null;
const bodyH = tileH - HEADER_H - 4;
return (
- <button
+ <div
key={cat.key}
- type="button"
- onClick={() => onSelect(cat.key)}
- disabled={cat.loose}
- title={cat.loose
- ? `Files directly in data/ (settings and state) — ${formatBytes(cat.size)}`
- : `${cat.label} — ${formatBytes(cat.size)} · ${kind.label}`}
- aria-pressed={selected}
+
className={`absolute flex flex-col justify-start overflow-hidden rounded-md border-t-2 text-left transition-colors ${kind.tile} ${kind.edge} ${selected ? 'ring-2 ring-white/70 z-10' : ''}`}
style={{ left: x, top: y, width: tileW, height: tileH, ...(kind.hatch ? HATCH_STYLE : null) }}
>
- {showHeader && (
- <span className="flex w-full shrink-0 items-baseline justify-between gap-2 px-2 bg-black/20" style={{ height: HEADER_H, lineHeight: `${HEADER_H}px` }}>
+ <button
+ type="button"
+ onClick={() => onSelect(cat.key)}
+ disabled={cat.loose}
+ title={cat.loose
+ ? `Files directly in data/ (settings and state) — ${formatBytes(cat.size)}`
+ : `${cat.label} — ${formatBytes(cat.size)} · ${kind.label}`}
+ aria-label={cat.label}
+ aria-pressed={selected}
+ className="absolute inset-0 flex flex-col text-left"
+ >
+ {showHeader && (
+ <span className="flex w-full shrink-0 items-baseline justify-between gap-2 px-2 bg-black/20" style={{ height: HEADER_H, lineHeight: `${HEADER_H}px` }}>
<span className="truncate text-xs font-medium text-white">{cat.label}</span>
{showSize && <span className="shrink-0 text-[11px] font-mono text-gray-400">{formatBytes(cat.size)}</span>}
- </span>
- )}
+ </span>
+ )}
+ </button>
{items?.length > 0 && showHeader && bodyH > 24 && (
- <span className="absolute left-1 right-1 bottom-1" style={{ top: HEADER_H + 2 }}>
+ <span className="pointer-events-none absolute left-1 right-1 bottom-1" style={{ top: HEADER_H + 2 }}>
<NestedItems items={items} width={tileW - 8} height={bodyH} />
</span>
)}
- </button>
+ </div>
);
})}
</div>
diff --git a/client/src/pages/DataManager.jsx b/client/src/pages/DataManager.jsx
index 29160393b4..13b38f003d 100644
--- a/client/src/pages/DataManager.jsx
+++ b/client/src/pages/DataManager.jsx
@@ -10,6 +10,7 @@ import { useAsyncAction } from '../hooks/useAsyncAction';
import { useConfirmDelete } from '../hooks/useConfirmDelete';
import { useSocketSubscription } from '../hooks/useSocketSubscription';
import useMounted from '../hooks/useMounted';
+import CollapsibleListItem from '../components/ui/CollapsibleListItem';
import InlineConfirmRow from '../components/ui/InlineConfirmRow';
import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import DataTreemap from '../components/dataManager/DataTreemap';
@@ -146,7 +147,7 @@ function SizeBar({ size, maxSize, color }) {
);
}
-function CategoryRow({ onMaintenanceComplete, cat, maxSize, onExpand, expanded, detail, onArchive, onPurge, onConfirmPurge, onCancelPurge, onDeleteItem, deletingItem, confirmingPurge, archiving, purging }) {
+function CategoryRow({ onMaintenanceComplete, cat, maxSize, onExpand, expanded, detail, onArchive, onPurge, onConfirmPurge, onCancelPurge, onDeleteItem, onRemoveItem, deletingItem, confirmingPurge, archiving, purging }) {
// Directories with no CATEGORIES entry come back with `classified: false` and
// no Archive/Purge flags. Say why the buttons are missing in outcome terms so
// the row reads as a deliberate safety stance, not a broken row (#3285).
@@ -158,7 +159,9 @@ function CategoryRow({ onMaintenanceComplete, cat, maxSize, onExpand, expanded,
// whole-directory Purge button is replaced by a per-row delete in the detail
// table (#3327). Older servers omit `purgeScope` entirely — treat that as the
// legacy category-wide behavior rather than silently dropping the button.
+ const [removingItems, setRemovingItems] = useState(new Set());
const itemScoped = cat.deletable && cat.purgeScope === 'items';
+ const itemColumns = cat.deletable ? 'minmax(160px, 1fr) 80px 60px 120px' : 'minmax(160px, 1fr) 80px 60px';
const categoryPurgeable = cat.deletable && !itemScoped;
// Some reproducible-scratch categories hold the working state of a job that is
// running right now — the server refuses the whole-directory purge while that
@@ -224,7 +227,7 @@ function CategoryRow({ onMaintenanceComplete, cat, maxSize, onExpand, expanded,
) : (
<button
onClick={() => onPurge(cat.key)}
- disabled={purging}
+ disabled={purging || !!deletingItem}
className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-port-error/10 text-port-error rounded hover:bg-port-error/20 transition-colors disabled:opacity-50"
>
<Trash2 size={12} />
@@ -253,57 +256,69 @@ function CategoryRow({ onMaintenanceComplete, cat, maxSize, onExpand, expanded,
{detail.items.length === 0 ? (
<div className="p-3 text-xs text-gray-500">Empty</div>
) : (
- <table className={`w-full text-xs ${itemScoped ? 'min-w-[420px]' : ''}`}>
- <thead>
- <tr className="text-gray-500 border-b border-port-border/30">
- <th className="text-left p-2 pl-3 font-medium">Name</th>
- <th className="text-right p-2 font-medium">Size</th>
- <th className="text-right p-2 pr-3 font-medium">Files</th>
- {itemScoped && <th className="text-right p-2 pr-3 font-medium"><span className="sr-only">Delete</span></th>}
- </tr>
- </thead>
- <tbody>
+ <div role="table" aria-label={`${cat.label} contents`} className="w-full min-w-[460px] text-xs" tabIndex={-1}>
+ <div role="rowgroup">
+ <div role="row" style={{ gridTemplateColumns: itemColumns }} className="grid text-gray-500 border-b border-port-border/30">
+ <div role="columnheader" className="text-left p-2 pl-3 font-medium">Name</div>
+ <div role="columnheader" className="text-right p-2 font-medium">Size</div>
+ <div role="columnheader" className="text-right p-2 pr-3 font-medium">Files</div>
+ {cat.deletable && <div role="columnheader" className="text-right p-2 pr-3 font-medium"><span className="sr-only">Delete</span></div>}
+ </div>
+ </div>
+ <div role="rowgroup">
{detail.items.map(item => (
- <tr key={item.name} className="border-b border-port-border/20 hover:bg-port-card/30">
- <td className="p-2 pl-3 text-gray-300 flex items-center gap-1.5">
- {item.type === 'directory' ? <FolderOpen size={11} className="text-port-accent shrink-0" /> : <File size={11} className="text-gray-500 shrink-0" />}
- <span className="truncate">{item.name}</span>
- </td>
- <td className="p-2 text-right text-gray-400 font-mono">{formatBytes(item.size)}</td>
- <td className="p-2 pr-3 text-right text-gray-500">{item.type === 'directory' ? (item.fileCount == null ? 'Unavailable' : formatCount(item.fileCount)) : '—'}</td>
- {itemScoped && (
- <td className="p-2 pr-3 text-right">
- {item.type === 'directory' ? (
- // Subdirectories of these categories are another
- // feature's working state (in-flight render
- // control dirs, scratch), not user assets — the
- // server refuses them too.
- <span className="text-gray-600" title="Directories here hold working files for other features and are not deletable from this page">—</span>
- ) : isConfirming(item.name) ? (
- <ConfirmButtonPair
- className="justify-end"
- prompt="Delete?"
- onConfirm={() => confirmDelete(() => onDeleteItem(cat.key, item.name))}
- onCancel={cancelDelete}
- ariaLabel={`Confirm delete ${item.name} from ${cat.label}`}
- />
- ) : (
- <button
- onClick={() => requestDelete(item.name)}
- disabled={deletingItem === item.name}
- className="text-gray-500 hover:text-port-error transition-colors disabled:opacity-50"
- title={`Delete ${item.name}`}
- aria-label={`Delete ${item.name} from ${cat.label}`}
- >
- <Trash2 size={12} />
- </button>
- )}
- </td>
- )}
- </tr>
+ <CollapsibleListItem key={item.name} spacing="0" removing={removingItems.has(item.name)} onExited={() => {
+ onRemoveItem(cat.key, item.name);
+ setRemovingItems(prev => { const next = new Set(prev); next.delete(item.name); return next; });
+ }}>
+ <div role="row" style={{ gridTemplateColumns: itemColumns }} className="grid border-b border-port-border/20 hover:bg-port-card/30">
+ <div role="cell" className="p-2 pl-3 text-gray-300 flex items-center gap-1.5">
+ {item.type === 'directory' ? <FolderOpen size={11} className="text-port-accent shrink-0" /> : <File size={11} className="text-gray-500 shrink-0" />}
+ <div className="min-w-0">
+ {item.sourceHref ? <a href={item.sourceHref} className="block truncate text-port-accent hover:underline" title={`Open source for ${item.name}`}>{item.label || item.name}</a> : <span className="block truncate">{item.label || item.name}</span>}
+ {item.label && item.label !== item.name && <span className="block truncate text-gray-500" title={item.name}>{item.name}</span>}
+ {(item.description || item.sourceUnavailable) && <span className="block text-gray-500">{item.description || item.sourceUnavailable}</span>}
+ </div>
+ </div>
+ <div role="cell" className="p-2 text-right text-gray-400 font-mono">{formatBytes(item.size)}</div>
+ <div role="cell" className="p-2 pr-3 text-right text-gray-500">{item.type === 'directory' ? (item.fileCount == null ? 'Unavailable' : formatCount(item.fileCount)) : '—'}</div>
+ {cat.deletable && (
+ <div role="cell" className="p-2 pr-3 text-right">
+ {itemScoped && item.type === 'directory' ? (
+ // Subdirectories of these categories are another
+ // feature's working state (in-flight render
+ // control dirs, scratch), not user assets — the
+ // server refuses them too.
+ <span className="text-gray-600" title="Directories here hold working files for other features and are not deletable from this page">—</span>
+ ) : isConfirming(item.name) ? (
+ <ConfirmButtonPair
+ className="justify-end flex-wrap"
+ prompt={item.type === 'directory' ? "Delete folder and contents?" : "Delete?"}
+ busy={busy || !!deletingItem || !!purging}
+ onConfirm={() => confirmDelete(async () => {
+ if (await onDeleteItem(cat.key, item.name)) setRemovingItems(prev => new Set(prev).add(item.name));
+ })}
+ onCancel={cancelDelete}
+ ariaLabel={`Confirm delete ${item.name} from ${cat.label}`}
+ />
+ ) : (
+ <button
+ onClick={() => requestDelete(item.name)}
+ disabled={busy || !!deletingItem || !!purging}
+ className="text-gray-500 hover:text-port-error transition-colors disabled:opacity-50"
+ title={`Delete ${item.name}`}
+ aria-label={`Delete ${item.name} from ${cat.label}`}
+ >
+ <Trash2 size={12} />
+ </button>
+ )}
+ </div>
+ )}
+ </div>
+ </CollapsibleListItem>
))}
- </tbody>
- </table>
+ </div>
+ </div>
)}
</div>
) : (
@@ -396,6 +411,7 @@ export default function DataManager() {
const [deletingItem, setDeletingItem] = useState(null);
// Ref, not state: two clicks in one render would both read a stale state value.
const deletingBackupsRef = useRef(new Set());
+ const deletingItemRef = useRef(false);
const overviewRequestRef = useRef(0);
const overviewReadRef = useRef(null);
@@ -508,16 +524,24 @@ export default function DataManager() {
refreshAfterAction(key);
};
- // Per-item purge for `purgeScope: 'items'` categories — the only delete those
- // categories offer (#3327). Drops the row locally for immediate feedback and
- // refetches the overview so the size bars and totals catch up.
const handleDeleteItem = async (key, name) => {
+ if (deletingItemRef.current) return false;
+ deletingItemRef.current = true;
setDeletingItem(name);
const result = await api.purgeDataCategory(key, { subPath: name }).catch(() => null);
+ deletingItemRef.current = false;
setDeletingItem(null);
- if (!result) return;
- setDetail(prev => (prev?.key === key ? { ...prev, items: prev.items.filter(i => i.name !== name) } : prev));
+ if (!result) return false;
fetchOverview();
+ return true;
+ };
+
+ const removeDeletedItem = (key, name) => {
+ setDetail(prev => {
+ if (prev?.key !== key) return prev;
+ const removed = prev.items.find(item => item.name === name);
+ return { ...prev, totalSize: Math.max(0, (prev.totalSize || 0) - (removed?.size || 0)), items: prev.items.filter(item => item.name !== name) };
+ });
};
const handleDeleteBackup = async (filename) => {
@@ -640,6 +664,7 @@ export default function DataManager() {
onConfirmPurge={executePurge}
onCancelPurge={() => setConfirmPurge(null)}
onDeleteItem={handleDeleteItem}
+ onRemoveItem={removeDeletedItem}
deletingItem={expandedCat === cat.key ? deletingItem : null}
confirmingPurge={confirmPurge === cat.key}
archiving={archiving === cat.key}
diff --git a/client/src/pages/DataManager.test.jsx b/client/src/pages/DataManager.test.jsx
index e4679ddd67..40dbf8eefc 100644
--- a/client/src/pages/DataManager.test.jsx
+++ b/client/src/pages/DataManager.test.jsx
@@ -552,3 +552,42 @@ describe('DataManager backup deletion (#8922)', () => {
expect(screen.getByText('backup-2025-01-02.tar.gz')).toBeInTheDocument();
});
});
+
+describe('DataManager training-run sources and individual cleanup', () => {
+ const runItem = { name: 'example-run', label: 'Example portrait study', sourceHref: '/models/training/example-dataset', description: 'example-model · completed', type: 'directory', size: 1200, fileCount: 3 };
+ beforeEach(() => {
+ getDataOverview.mockReset().mockResolvedValue({ ...busyOverview, categories: [{ ...busyOverview.categories[0], busy: false }] });
+ getDataCategory.mockReset().mockResolvedValue({ key: 'training-runs', busy: false, items: [runItem, { name: 'another-run', type: 'directory', size: 800, fileCount: 2 }] });
+ purgeDataCategory.mockReset().mockResolvedValue({ category: 'training-runs', subPath: 'example-run' });
+ });
+
+ it('links the named source and deletes only the selected run after confirmation', async () => {
+ render(<DataManager />);
+ await screen.findAllByText('LoRA Training Runs');
+ expandRow('LoRA Training Runs');
+ expect(await screen.findByRole('link', { name: 'Example portrait study' })).toHaveAttribute('href', '/models/training/example-dataset');
+ expect(screen.getByRole('link', { name: 'Open source: Example portrait study' })).toHaveAttribute('href', '/models/training/example-dataset');
+ fireEvent.click(screen.getByRole('button', { name: 'Delete example-run from LoRA Training Runs' }));
+ expect(purgeDataCategory).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+ await waitFor(() => expect(screen.queryByRole('link', { name: 'Example portrait study' })).not.toBeInTheDocument());
+ expect(purgeDataCategory).toHaveBeenCalledWith('training-runs', { subPath: 'example-run' });
+ expect(screen.getByRole('button', { name: 'Delete another-run from LoRA Training Runs' })).toBeInTheDocument();
+ expect(getDataCategory).toHaveBeenCalledTimes(1);
+ });
+
+ it('retains the row on failure and disables individual deletion while busy', async () => {
+ purgeDataCategory.mockRejectedValue(new Error('busy'));
+ render(<DataManager />);
+ await screen.findAllByText('LoRA Training Runs');
+ expandRow('LoRA Training Runs');
+ fireEvent.click(await screen.findByRole('button', { name: 'Delete example-run from LoRA Training Runs' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Delete example-run from LoRA Training Runs' })).toBeEnabled());
+ expect(screen.getByRole('link', { name: 'Example portrait study' })).toBeInTheDocument();
+ getDataCategory.mockResolvedValue({ key: 'training-runs', busy: true, items: [runItem] });
+ expandRow('LoRA Training Runs');
+ expandRow('LoRA Training Runs');
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Delete example-run from LoRA Training Runs' })).toBeDisabled());
+ });
+});
diff --git a/server/services/dataManager.busy.test.js b/server/services/dataManager.busy.test.js
index b222ac8ad3..dd37507382 100644
--- a/server/services/dataManager.busy.test.js
+++ b/server/services/dataManager.busy.test.js
@@ -74,13 +74,11 @@ describe('purgeCategory — CATEGORY_BUSY refusal', () => {
expect(existsSync(dataPath(key))).toBe(true);
});
- // A per-item purge names the one entry the user picked, so it stays available
- // while the category is busy — the refusal is about the all-at-once wipe.
- it('still allows a per-item purge while the category is busy', async () => {
+ it('refuses a per-item purge while the category is busy', async () => {
trainingRunsBusy.mockImplementation(busyWith('a trainer is running'));
- await purgeCategory('training-runs', { subPath: 'run-0001' });
- expect(existsSync(dataPath('training-runs', 'run-0001'))).toBe(false);
- expect(trainingRunsBusy).not.toHaveBeenCalled();
+ await expect(purgeCategory('training-runs', { subPath: 'run-0001' }))
+ .rejects.toMatchObject({ status: 409, code: 'CATEGORY_BUSY' });
+ expect(existsSync(dataPath('training-runs', 'run-0001'))).toBe(true);
});
it('leaves a category with no busyCheck completely unaffected', async () => {
diff --git a/server/services/dataManager.itemPurge.test.js b/server/services/dataManager.itemPurge.test.js
index cd5e97e592..d32fc65dc0 100644
--- a/server/services/dataManager.itemPurge.test.js
+++ b/server/services/dataManager.itemPurge.test.js
@@ -20,7 +20,10 @@ vi.mock('../lib/fileUtils.js', async (importOriginal) => {
return makePathsProxy(actual, { dataRoot: TEST_DATA_ROOT });
});
-const { purgeCategory } = await import('./dataManager.js');
+vi.mock('../lib/db.js', () => ({ query: vi.fn() }));
+const { query } = await import('../lib/db.js');
+
+const { purgeCategory, getCategoryDetail } = await import('./dataManager.js');
afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true }));
@@ -115,3 +118,34 @@ describe('purgeCategory — category-scoped categories keep their behavior', ()
expect(existsSync(dataPath('images', 'render-0001.png'))).toBe(true);
});
});
+
+
+describe('training-run source details', () => {
+ it('resolves stored run names and dataset links while retaining orphan folders', async () => {
+ for (const id of ['example-run', 'orphan-run']) {
+ mkdirSync(dataPath('training-runs', id), { recursive: true });
+ writeFileSync(dataPath('training-runs', id, 'checkpoint.bin'), 'checkpoint');
+ }
+ query.mockResolvedValue({ rows: [{ data: {
+ id: 'example-run', name: 'Example portrait study', datasetId: 'example-dataset',
+ baseModelId: 'example-model', status: 'completed',
+ } }] });
+ const detail = await getCategoryDetail('training-runs');
+ expect(detail.items.find(item => item.name === 'example-run')).toMatchObject({
+ label: 'Example portrait study', sourceHref: '/models/training/example-dataset',
+ description: 'example-model · completed',
+ });
+ expect(detail.items.find(item => item.name === 'orphan-run')).toMatchObject({ sourceUnavailable: 'Run record no longer available' });
+ await purgeCategory('training-runs', { subPath: 'example-run' });
+ expect(existsSync(dataPath('training-runs', 'example-run'))).toBe(false);
+ expect(existsSync(dataPath('training-runs', 'orphan-run', 'checkpoint.bin'))).toBe(true);
+ });
+
+ it('keeps storage details usable when source lookup fails', async () => {
+ mkdirSync(dataPath('training-runs', 'example-run'), { recursive: true });
+ query.mockRejectedValue(new Error('database unavailable'));
+ const detail = await getCategoryDetail('training-runs');
+ expect(detail.items[0]).toMatchObject({ name: 'example-run', sourceUnavailable: 'Source lookup unavailable' });
+ expect(detail.items[0].sourceHref).toBeUndefined();
+ });
+});
diff --git a/server/services/dataManager.js b/server/services/dataManager.js
index 2276120d7b..8679c55cad 100644
--- a/server/services/dataManager.js
+++ b/server/services/dataManager.js
@@ -41,9 +41,9 @@ const DATA_DIR = PATHS.data;
// genuinely reproducible scratch, yet only while nothing is USING them: a
// category-wide purge mid-job destroys the working state of a render, a
// trainer, or a self-update. A category carrying a `busyCheck` refuses the
-// directory-wide purge with 409 CATEGORY_BUSY while its probe says busy;
-// per-item purges (the user named one entry) and categories with no
-// `busyCheck` are unaffected (issue #3342). Probes live in
+// purge with 409 CATEGORY_BUSY while its probe says busy, including
+// per-item deletion: naming a directory does not make a live job safe.
+// Categories with no `busyCheck` are unaffected. Probes live in
// `dataManagerBusy.js`.
export const CATEGORIES = {
'agents': { label: 'Agents', description: 'Agent personality data', archivable: false, deletable: false },
@@ -340,6 +340,30 @@ export async function getCategoryDetail(categoryKey, { measure = false } = {}) {
});
const items = await Promise.all(itemPromises);
+ // Resolve opaque training-run folders in one bounded-to-the-list
+ // lookup, including old runs beyond the training page's recent-run limit.
+ if (categoryKey === 'training-runs' && items.length) {
+ const { query } = await import('../lib/db.js');
+ const result = await query(
+ 'SELECT data FROM lora_training_runs WHERE id = ANY($1::text[])',
+ [items.filter(item => item.type === 'directory').map(item => item.name)],
+ ).catch(() => null);
+ const runs = new Map((result?.rows || []).map(({ data }) => [data.id, data]));
+ for (const item of items) {
+ const run = runs.get(item.name);
+ if (run) {
+ item.label = run.name || run.character?.name || run.baseModelId || item.name;
+ item.description = [run.baseModelId, run.status].filter(Boolean).join(' · ');
+ if (run.datasetId) item.sourceHref = `/models/training/${encodeURIComponent(run.datasetId)}`;
+ }
+ item.sourceUnavailable = result === null ? 'Source lookup unavailable' : !run ? 'Run record no longer available' : null;
+ }
+ }
+ if (categoryKey === 'images' || categoryKey === 'videos') {
+ for (const item of items) {
+ if (item.type === 'file') item.sourceHref = `/data/${categoryKey}/${encodeURIComponent(item.name)}`;
+ }
+ }
items.sort((a, b) => b.size - a.size);
const totalSize = items.reduce((sum, item) => sum + item.size, 0);
@@ -440,17 +464,10 @@ export async function purgeCategory(categoryKey, options = {}) {
throw new ServerError(`Category directory not found: ${categoryKey}`, { status: 404, code: 'NOT_FOUND' });
}
- // A category-wide purge empties the directory in one action, so a job that is
- // mid-flight loses its working state with no warning. Refuse outright while a
- // category's `busyCheck` reports live work, rather than filtering "the busy
- // files" out of the wipe — a partial purge is harder to reason about, and the
- // user can retry in seconds once the job finishes (#3342). A per-item purge
- // is exempt: the user named the one entry they meant. This runs before any
- // `rm` below.
- if (!wantsItem) {
- const { busy, busyReason } = await resolveCategoryBusy(categoryKey);
- if (busy) throw new ServerError(busyReason, { status: 409, code: 'CATEGORY_BUSY' });
- }
+ // A named directory can still contain a live job's working state. Apply
+ // the same fail-closed busy probe to both deletion scopes.
+ const { busy, busyReason } = await resolveCategoryBusy(categoryKey);
+ if (busy) throw new ServerError(busyReason, { status: 409, code: 'CATEGORY_BUSY' });
if (wantsItem) {
const resolvedRoot = resolve(dirPath);