From 71f90aa5695f14aaad9ede586cd49ad4cf947af7 Mon Sep 17 00:00:00 2001 From: Z User Date: Wed, 28 Oct 2026 19:10:58 +0000 Subject: [PATCH] feat: mmproj support, model subdirs, auto-categorize, perf overview, comfy total size, wake dashboard fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary 8 fixes in one PR — all from user feedback: 1. **Perf tab shows nothing** — added /api/props endpoint, Overview view with avg TPS / ctx usage / multimodal / sampling defaults 2. **Comfy models list — no total size** — added total size to header 3. **gpuctl wake doesn't start dashboard** — added belt-and-suspenders check + explicit docker compose up -d dashboard fallback 4. **mmproj support (multimodal)** — new mmprojPath config field, --mmproj arg, Set mmproj button in Models tab 5. **Subdirectory support in llama_models** — listModels() recurses one level deep, ModelFile has relativePath/subdir/kind fields 6. **Auto-categorize models** — detectModelKind() tags files as base/mmproj/mtp/draft by filename, shown as colored badges 7. **Comfy download progress** — reduced queue refresh from 5s to 2s 8. **Auto-create repo subdir on download** — HF/GitHub URLs automatically create user___repo/ subdirectory ## Details ### Perf tab (1) - New /api/props endpoint proxies llama.cpp /props - New Overview view shows: avg TPS, total slots, ctx usage, multimodal, predicted/prompt token counts, model name, total ctx, sampling defaults - Slots view now shows 'No slots' instead of 'No active slots' (idle slots are still listed by /slots) - Default view changed from slots to overview - Added 'Click Live to start polling' placeholder when not active - Error display if fetch fails ### Comfy total size (2) - ComfyTab header now shows total size: 'N file(s) · X.XX GB total' ### gpuctl wake dashboard fix (3) - wake_mode() now checks if dashboard container is running after the --profile wake up -d call, and if not, runs a plain 'docker compose up -d dashboard' as fallback ### mmproj support (4) - DashboardConfig.mmprojPath (relative path like 'Qwen3-VL/mmproj-F16.gguf') - DEFAULT_CONFIG.mmprojPath = '' - buildLlamaExtraArgs: --mmproj /models/ when set - parseLlamaExtraArgs: parses --mmproj, strips /models/ prefix - mergeConfig: includes mmprojPath - ModelsTab: 'Set mmproj' button for files with kind='mmproj' - Active mmproj shown with badge in model list ### Subdirectory support (5) - ModelFile: added relativePath, subdir, kind fields - listModels() now walks top-level entries; if a subdirectory is found, lists .gguf files inside it (one level deep — HF repos are flat) - Sort: by subdir (groups files in same repo together), then by size desc - deleteModel() accepts relative paths like 'Qwen3-VL/model.gguf' - Path traversal protection: resolved path must stay under LLAMA_MODELS_DIR ### Auto-categorize models (6) - detectModelKind(filename) checks lowercase filename: - 'mmproj' in name → 'mmproj' - 'mtp' in name → 'mtp' - 'draft' in name → 'draft' - otherwise → 'base' - Models tab shows colored Kind badge per file - Action buttons are context-aware: - base: 'Use' (sets config.model) - mmproj: 'Set mmproj' (sets config.mmprojPath) - mtp/draft: 'Set draft' (sets config.draftModel) ### Comfy download progress (7) - Queue refresh interval reduced from 5000ms to 2000ms for more responsive progress display ### Auto-create repo subdir on download (8) - startModelDownload() now detects HF and GitHub URLs and extracts user/repo to create a subdirectory: - huggingface.co///resolve// → subdir = '___' - github.com///releases/download// → subdir = '___' - Other URLs: no subdir (flat layout) - The subdirectory is created on the fly before starting curl - File is saved as // - Job.filename shows the full relative path (e.g. 'user___repo/model.gguf') ## Verification - npm run build — OK, 27 routes (1 new /api/props) - bash dashboard/validate-build.sh — all 8 COPY sources ✓ ## After deploy ```sh git pull && sh build.sh docker compose up -d --force-recreate dashboard ``` Test: - Download a HF model → it lands in user___repo/ subdir - Models tab shows files grouped by subdir with kind badges - Click 'Set mmproj' on an mmproj file → --mmproj added to launch args - Start Llama → check Perf tab → Overview shows TPS / ctx / multimodal - gpuctl sleep → gpuctl wake → dashboard should come back up --- dashboard/src/app/api/config/route.ts | 1 + dashboard/src/app/api/props/route.ts | 50 ++++ dashboard/src/app/page.tsx | 353 +++++++++++++++++++++----- dashboard/src/lib/docker.ts | 123 +++++++-- dashboard/src/lib/downloads.ts | 38 ++- ssh/scripts/status.sh | 13 + 6 files changed, 501 insertions(+), 77 deletions(-) create mode 100644 dashboard/src/app/api/props/route.ts diff --git a/dashboard/src/app/api/config/route.ts b/dashboard/src/app/api/config/route.ts index 891b4a4..e3d07f9 100644 --- a/dashboard/src/app/api/config/route.ts +++ b/dashboard/src/app/api/config/route.ts @@ -26,6 +26,7 @@ function mergeConfig( nGpuLayers: patch.nGpuLayers ?? base.nGpuLayers, threads: patch.threads ?? base.threads, draftModel: patch.draftModel ?? base.draftModel, + mmprojPath: patch.mmprojPath ?? base.mmprojPath, specType: patch.specType ?? base.specType, specDraftNMax: patch.specDraftNMax ?? base.specDraftNMax, batchSize: patch.batchSize ?? base.batchSize, diff --git a/dashboard/src/app/api/props/route.ts b/dashboard/src/app/api/props/route.ts new file mode 100644 index 0000000..b8e6416 --- /dev/null +++ b/dashboard/src/app/api/props/route.ts @@ -0,0 +1,50 @@ +import { NextResponse } from "next/server"; + +export const dynamic = "force-dynamic"; +export const runtime = "nodejs"; + +/** + * GET /api/props + * + * Proxies llama.cpp's /props endpoint. Returns: + * - default_generation_settings: { n_predict, temperature, top_k, top_p, + * min_p, repeat_penalty, ... } — the sampling defaults the server + * started with + * - total_slots: number of parallel slots + * - model_path: path to the loaded model + * - chat_template: chat template string (if --jinja) + * - n_context: total context size (ctx_size * parallel) + * - n_vocab, n_embd, n_params: model metadata + * - has_multimodal: bool (mmproj loaded) + * - timings: cumulative across all slots since server start + * + * Unlike /slots (per-slot state), /props gives server-wide info that's + * useful even when no chat is running. + */ +export async function GET() { + try { + const res = await fetch("http://llama:8080/props", { + cache: "no-store", + signal: AbortSignal.timeout(5000), + }); + if (!res.ok) { + return NextResponse.json( + { + ok: false, + error: `llama returned ${res.status}`, + }, + { status: res.status } + ); + } + const data = await res.json(); + return NextResponse.json({ ok: true, props: data }); + } catch (err) { + return NextResponse.json( + { + ok: false, + error: (err as Error).message, + }, + { status: 503 } + ); + } +} diff --git a/dashboard/src/app/page.tsx b/dashboard/src/app/page.tsx index 05366fd..ad3a516 100644 --- a/dashboard/src/app/page.tsx +++ b/dashboard/src/app/page.tsx @@ -58,8 +58,13 @@ import { cn, formatBytes, timeAgo } from "@/lib/utils"; // Types // --------------------------------------------------------------------------- +type ModelKind = "base" | "mmproj" | "mtp" | "draft"; + interface ModelFile { name: string; + relativePath: string; + subdir: string; + kind: ModelKind; sizeBytes: number; sizeHuman: string; modifiedAt: string; @@ -91,6 +96,8 @@ interface DashboardConfig { nGpuLayers: number; threads: number; draftModel: string; + /** Optional mmproj file (multimodal vision projector) */ + mmprojPath: string; specType: "none" | "draft-mtp" | "draft-llama"; specDraftNMax: number; batchSize: number; @@ -179,6 +186,7 @@ const DEFAULT_CONFIG: DashboardConfig = { nGpuLayers: -1, threads: -1, draftModel: "", + mmprojPath: "", specType: "none", specDraftNMax: 4, batchSize: 512, @@ -438,7 +446,7 @@ export default function DashboardPage() { refreshModels(); refreshComfyTypes(); refreshComfyModels(); - const id = setInterval(refreshComfyQueue, 5000); + const id = setInterval(refreshComfyQueue, 2000); return () => clearInterval(id); }, [ refreshConfig, @@ -1480,6 +1488,8 @@ export default function DashboardPage() { busy={busy} uploadProgress={uploadProgress} onSelectModel={(m) => update("model", m)} + onUseMmproj={(m) => update("mmprojPath", m)} + onUseDraft={(m) => update("draftModel", m)} onUpload={handleUpload} onDelete={handleDeleteModel} downloadJobs={downloadJobs} @@ -2311,6 +2321,8 @@ function ModelsTab({ busy, uploadProgress, onSelectModel, + onUseMmproj, + onUseDraft, onUpload, onDelete, downloadJobs, @@ -2327,6 +2339,8 @@ function ModelsTab({ busy: string | null; uploadProgress: { name: string; percent: number } | null; onSelectModel: (m: string) => void; + onUseMmproj: (m: string) => void; + onUseDraft: (m: string) => void; onUpload: (file: File) => void; onDelete: (name: string) => void; downloadJobs: DownloadJob[]; @@ -2591,59 +2605,102 @@ function ModelsTab({ Name + Kind Size Modified - Actions + Actions - {models.map((m) => ( - - -
- - {m.name} - {config.model === m.name && ( - - active - - )} -
- - - {m.sizeHuman} - - - {timeAgo(m.modifiedAt)} - - -
- - -
- - - ))} + {models.map((m) => { + const isActiveBase = config.model === m.relativePath; + const isActiveMmproj = config.mmprojPath === m.relativePath; + const isActiveDraft = config.draftModel === m.name; + const isActive = isActiveBase || isActiveMmproj || isActiveDraft; + const kindBadge = { + base: base, + mmproj: mmproj, + mtp: mtp, + draft: draft, + }[m.kind]; + return ( + + +
+ + {m.subdir && ( + + {m.subdir}/ + + )} + {m.name} + {isActive && ( + + {isActiveBase ? "active" : isActiveMmproj ? "mmproj" : "draft"} + + )} +
+ + {kindBadge} + + {m.sizeHuman} + + + {timeAgo(m.modifiedAt)} + + +
+ {m.kind === "base" && ( + + )} + {m.kind === "mmproj" && ( + + )} + {(m.kind === "mtp" || m.kind === "draft") && ( + + )} + +
+ + + ); + })} @@ -3063,6 +3120,8 @@ function ComfyTab({ /project/gpu/comfy/models {" · "} {models.length} file(s) + {" · "} + {formatBytes(models.reduce((s, m) => s + (m.sizeBytes || 0), 0))} total
@@ -3713,9 +3772,11 @@ interface SlotInfo { function PerfTab({ llamaRunning }: { llamaRunning: boolean }) { const [slots, setSlots] = React.useState([]); + const [props, setProps] = React.useState | null>(null); const [metricsRaw, setMetricsRaw] = React.useState(""); const [active, setActive] = React.useState(false); - const [view, setView] = React.useState<"slots" | "metrics">("slots"); + const [view, setView] = React.useState<"overview" | "slots" | "metrics">("overview"); + const [errors, setErrors] = React.useState(""); React.useEffect(() => { if (!active || !llamaRunning) return; @@ -3723,8 +3784,23 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) { async function poll() { if (cancelled) return; + setErrors(""); try { - if (view === "slots") { + if (view === "overview") { + // Fetch props + slots in parallel for the overview + const [propsRes, slotsRes] = await Promise.all([ + fetch("/api/props", { cache: "no-store" }).catch(() => null), + fetch("/api/slots", { cache: "no-store" }).catch(() => null), + ]); + if (propsRes && propsRes.ok) { + const pd = await propsRes.json(); + if (!cancelled && pd.ok) setProps(pd.props); + } + if (slotsRes && slotsRes.ok) { + const sd = await slotsRes.json(); + if (!cancelled) setSlots(sd.slots || []); + } + } else if (view === "slots") { const res = await fetch("/api/slots", { cache: "no-store" }); if (res.ok) { const data = await res.json(); @@ -3735,10 +3811,13 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) { if (res.ok) { const text = await res.text(); if (!cancelled) setMetricsRaw(text); + } else { + const text = await res.text().catch(() => ""); + if (!cancelled) setMetricsRaw(`[${res.status}] ${text.slice(0, 300)}`); } } - } catch { - /* ignore — will retry */ + } catch (err) { + if (!cancelled) setErrors((err as Error).message); } } @@ -3763,11 +3842,12 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) {
- setView(v as "overview" | "slots" | "metrics")}> + + Overview Slots Prometheus @@ -3801,23 +3881,181 @@ function PerfTab({ llamaRunning }: { llamaRunning: boolean }) { Start it to see live performance metrics.

+ ) : !active ? ( +
+ +

Click Live to start polling

+

Polls every 1.5s while active

+
+ ) : errors ? ( +
+ {errors} +
) : view === "slots" ? ( - ) : ( + ) : view === "metrics" ? (
             {metricsRaw || "[no metrics — was llama started with --metrics?]"}
           
+ ) : ( + )} ); } +function OverviewView({ + props, + slots, +}: { + props: Record | null; + slots: SlotInfo[]; +}) { + if (!props) { + return ( +

+ Loading… +

+ ); + } + const gen = props.default_generation_settings as + | { + n_predict?: number; + temperature?: number; + top_k?: number; + top_p?: number; + min_p?: number; + repeat_penalty?: number; + } + | undefined; + // Cumulative timings across all slots (sum of per-slot) + const totalPredictedN = slots.reduce( + (s, x) => s + (x.timings?.predicted_n || 0), + 0 + ); + const totalPromptN = slots.reduce( + (s, x) => s + (x.timings?.prompt_n || 0), + 0 + ); + // Average TPS across active slots + const activeSlots = slots.filter((s) => s.timings?.predicted_per_second); + const avgTps = + activeSlots.length > 0 + ? activeSlots.reduce((s, x) => s + (x.timings?.predicted_per_second || 0), 0) / + activeSlots.length + : null; + const hasMultimodal = Boolean(props.has_multimodal); + const totalSlots = (props.total_slots as number) || slots.length; + + return ( +
+ {/* Key metrics */} +
+ + + 0 + ? `${slots.reduce((s, x) => s + x.n_past, 0)} / ${slots.reduce( + (s, x) => s + x.n_ctx, + 0 + )}` + : "—" + } + hint="tokens across all slots" + /> + +
+ + {/* Cumulative stats */} +
+ 0 ? `${totalPredictedN}` : "—"} + hint="tokens generated" + /> + 0 ? `${totalPromptN}` : "—"} + hint="tokens processed" + /> + + +
+ + {/* Active slots breakdown */} + {slots.length > 0 && ( +
+
+ Slots +
+ +
+ )} + + {/* Generation defaults */} + {gen && ( +
+
+ Default sampling +
+
+ + temp: {gen.temperature ?? "?"} + + + top_k: {gen.top_k ?? "?"} + + + top_p: {gen.top_p ?? "?"} + + + min_p: {gen.min_p ?? "?"} + + + rep: {gen.repeat_penalty ?? "?"} + + + n_pred: {gen.n_predict ?? "?"} + +
+
+ )} +
+ ); +} + function SlotsView({ slots }: { slots: SlotInfo[] }) { if (slots.length === 0) { return (

- No active slots. Start a chat to see metrics. + No slots. (Llama might be loading the model still.)

); } @@ -4123,6 +4361,7 @@ function buildPreviewArgs(cfg: DashboardConfig): string { if (cfg.nPredict >= 0) parts.push(`--n-predict ${cfg.nPredict}`); parts.push(`--reasoning-format ${cfg.reasoningFormat}`); if (cfg.jinja) parts.push("--jinja"); + if (cfg.mmprojPath) parts.push(`--mmproj /models/${cfg.mmprojPath}`); if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim()); return parts.join(" "); } diff --git a/dashboard/src/lib/docker.ts b/dashboard/src/lib/docker.ts index 26d1cb6..a1690c9 100644 --- a/dashboard/src/lib/docker.ts +++ b/dashboard/src/lib/docker.ts @@ -180,8 +180,18 @@ export interface ContainerInfo { statusText: string; } +export type ModelKind = "base" | "mmproj" | "mtp" | "draft"; + export interface ModelFile { + /** Display name (just the filename, e.g. "Qwen3-VL-Q8_0.gguf") */ name: string; + /** Full path relative to LLAMA_MODELS_DIR (e.g. "Qwen3-VL/Qwen3-VL-Q8_0.gguf" + * if the file is in a subdirectory, or just "model.gguf" if at the root) */ + relativePath: string; + /** Subdirectory name (e.g. "Qwen3-VL") or empty string if at root */ + subdir: string; + /** Auto-detected category: base model / mmproj / mtp / draft */ + kind: ModelKind; sizeBytes: number; sizeHuman: string; modifiedAt: string; @@ -200,6 +210,8 @@ export interface DashboardConfig { threads: number; /** Optional draft model file */ draftModel: string; + /** Optional mmproj file (multimodal vision projector, e.g. mmproj-F16.gguf) */ + mmprojPath: string; /** Speculative decoding type */ specType: "none" | "draft-mtp" | "draft-llama"; /** Max draft tokens */ @@ -288,6 +300,7 @@ export const DEFAULT_CONFIG: DashboardConfig = { nGpuLayers: -1, threads: -1, draftModel: "", + mmprojPath: "", specType: "none", specDraftNMax: 4, batchSize: 512, @@ -551,6 +564,16 @@ export function parseLlamaExtraArgs( case "--jinja": cfg.jinja = true; break; + case "--mmproj": + // Multimodal vision projector path + // Strip /models/ prefix if present (we store just the relative path) + if (isValue(next)) { + let p = next; + if (p.startsWith("/models/")) p = p.slice("/models/".length); + cfg.mmprojPath = p; + i++; + } + break; case "--model-draft": cfg.draftModel = path.basename(next || ""); i++; @@ -657,6 +680,11 @@ export function buildLlamaExtraArgs(cfg: DashboardConfig): string { parts.push(`--reasoning-format ${cfg.reasoningFormat}`); // Jinja chat templates (required for reasoning format to work properly) if (cfg.jinja) parts.push("--jinja"); + // Multimodal vision projector (mmproj) — for vision-language models + // like Qwen3-VL, Llama 3.2 Vision, etc. + if (cfg.mmprojPath) { + parts.push(`--mmproj /models/${cfg.mmprojPath}`); + } if (cfg.extraArgs.trim()) parts.push(cfg.extraArgs.trim()); return parts.join(" "); } @@ -706,24 +734,78 @@ export async function writeEnvLlamaConfig( // Models // --------------------------------------------------------------------------- +/** + * Auto-detect model kind based on filename. + * - 'mmproj' — multimodal vision projector (filename contains 'mmproj') + * - 'mtp' — speculative decoding draft model (filename contains 'mtp') + * - 'draft' — draft model for speculative decoding (filename contains 'draft') + * - 'base' — regular model + */ +export function detectModelKind(filename: string): ModelKind { + const lower = filename.toLowerCase(); + if (lower.includes("mmproj")) return "mmproj"; + if (lower.includes("mtp")) return "mtp"; + if (lower.includes("draft")) return "draft"; + return "base"; +} + export async function listModels(): Promise { try { - const entries = await fs.readdir(LLAMA_MODELS_DIR, { withFileTypes: true }); const models: ModelFile[] = []; - for (const entry of entries) { - if (!entry.isFile()) continue; + // Walk the top-level entries. If a subdirectory is found, recurse one + // level deep (we don't go deeper — HuggingFace-style repos are flat). + const topEntries = await fs.readdir(LLAMA_MODELS_DIR, { withFileTypes: true }); + for (const entry of topEntries) { if (entry.name.startsWith(".")) continue; - if (!entry.name.toLowerCase().endsWith(".gguf")) continue; - const full = path.join(LLAMA_MODELS_DIR, entry.name); - const stat = await fs.stat(full); - models.push({ - name: entry.name, - sizeBytes: stat.size, - sizeHuman: humanSize(stat.size), - modifiedAt: stat.mtime.toISOString(), - }); + if (entry.isFile()) { + if (!entry.name.toLowerCase().endsWith(".gguf")) continue; + const full = path.join(LLAMA_MODELS_DIR, entry.name); + const stat = await fs.stat(full); + models.push({ + name: entry.name, + relativePath: entry.name, + subdir: "", + kind: detectModelKind(entry.name), + sizeBytes: stat.size, + sizeHuman: humanSize(stat.size), + modifiedAt: stat.mtime.toISOString(), + }); + } else if (entry.isDirectory()) { + // Subdirectory — list .gguf files inside + const subdir = entry.name; + const subdirPath = path.join(LLAMA_MODELS_DIR, subdir); + let subEntries: import("node:fs").Dirent[]; + try { + subEntries = await fs.readdir(subdirPath, { withFileTypes: true }); + } catch { + continue; // permission error etc — skip + } + for (const subEntry of subEntries) { + const subName = String(subEntry.name); + if (!subEntry.isFile()) continue; + if (subName.startsWith(".")) continue; + if (!subName.toLowerCase().endsWith(".gguf")) continue; + const full = path.join(subdirPath, subName); + const stat = await fs.stat(full); + models.push({ + name: subName, + relativePath: `${subdir}/${subName}`, + subdir, + kind: detectModelKind(subName), + sizeBytes: stat.size, + sizeHuman: humanSize(stat.size), + modifiedAt: stat.mtime.toISOString(), + }); + } + } } - models.sort((a, b) => b.sizeBytes - a.sizeBytes); + // Sort: by subdir (group files in same repo together), then by size desc + models.sort((a, b) => { + if (a.subdir !== b.subdir) { + return a.subdir.localeCompare(b.subdir); + } + return b.sizeBytes - a.sizeBytes; + }); return models; } catch { return []; @@ -1682,13 +1764,24 @@ export async function saveUploadedModel( } export async function deleteModel( - filename: string + relativePath: string ): Promise<{ ok: boolean; error?: string }> { - const safe = path.basename(filename).replace(/[^\w.\-]/g, "_"); + // relativePath can be "model.gguf" or "Qwen3-VL/Qwen3-VL-Q8_0.gguf" + // Sanitize each path segment to prevent path traversal + const segments = relativePath.split("/").map((s) => + s.replace(/[^\w.\-]/g, "_") + ); + const safe = segments.join("/"); if (!safe.toLowerCase().endsWith(".gguf")) { return { ok: false, error: "Only .gguf files are allowed" }; } const full = path.join(LLAMA_MODELS_DIR, safe); + // Ensure the resulting path is still under LLAMA_MODELS_DIR + const resolvedFull = path.resolve(full); + const resolvedBase = path.resolve(LLAMA_MODELS_DIR); + if (!resolvedFull.startsWith(resolvedBase + path.sep) && resolvedFull !== resolvedBase) { + return { ok: false, error: "Path traversal detected" }; + } try { await fs.unlink(full); return { ok: true }; diff --git a/dashboard/src/lib/downloads.ts b/dashboard/src/lib/downloads.ts index 7a0f6a3..2b6c15b 100644 --- a/dashboard/src/lib/downloads.ts +++ b/dashboard/src/lib/downloads.ts @@ -213,15 +213,37 @@ export async function startModelDownload( throw new Error(`only http(s) URLs are supported, got: ${parsed.protocol}`); } - // Determine filename + // Determine filename and optional subdirectory let filename: string; + let subdir: string = ""; if (filenameOverride) { filename = filenameOverride; } else { // Use last URL path segment, strip query string const pathname = parsed.pathname; - const last = pathname.split("/").filter(Boolean).pop() || "model.gguf"; + const segments = pathname.split("/").filter(Boolean); + const last = segments.pop() || "model.gguf"; filename = last; + // For HuggingFace URLs: ///resolve/main/ + // → subdir = "___" (sanitized) + // For GitHub releases: ///releases/download// + // → subdir = "___" + const host = parsed.hostname.toLowerCase(); + if (host === "huggingface.co" || host === "hf.co") { + // HF URL: /user/repo/resolve/branch/file + if (segments.length >= 2) { + const user = segments[0]; + const repo = segments[1]; + subdir = `${user}___${repo}`.replace(/[^\w.\-]/g, "_"); + } + } else if (host === "github.com" && segments.includes("releases")) { + // GitHub: /user/repo/releases/download/tag/file + if (segments.length >= 2) { + const user = segments[0]; + const repo = segments[1]; + subdir = `${user}___${repo}`.replace(/[^\w.\-]/g, "_"); + } + } } // Sanitize: only allow .gguf extension, no path traversal @@ -231,9 +253,15 @@ export async function startModelDownload( // Many HuggingFace URLs use ?download=true; ignore query. filename = `${filename}.gguf`; } + if (subdir) { + subdir = subdir.replace(/[^\w.\-]/g, "_"); + } - // Check we don't overwrite an existing file (race-safe via atomic rename) - const dest = path.join(LLAMA_MODELS_DIR, filename); + // If subdir is set, create it and download there + const destDir = subdir + ? path.join(LLAMA_MODELS_DIR, subdir) + : LLAMA_MODELS_DIR; + const dest = path.join(destDir, filename); const tmpDest = `${dest}.part`; const id = `dl-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; @@ -242,7 +270,7 @@ export async function startModelDownload( url, originalUrl: rawUrl !== url ? rawUrl : undefined, urlNote: urlNote || undefined, - filename, + filename: subdir ? `${subdir}/${filename}` : filename, status: "queued", bytesDownloaded: 0, bytesTotal: null, diff --git a/ssh/scripts/status.sh b/ssh/scripts/status.sh index c4baa3a..b43e772 100644 --- a/ssh/scripts/status.sh +++ b/ssh/scripts/status.sh @@ -163,6 +163,19 @@ wake_mode() { webdav \ dashboard + # Belt-and-suspenders: ensure dashboard is up even if the --profile wake + # flag above didn't include it (compose v2 with --profile + explicit names + # should work, but older versions may skip services without a matching + # profile). + DASHBOARD_CTR=$(get_service_container "dashboard" 2>/dev/null) || DASHBOARD_CTR="" + if [ -z "$DASHBOARD_CTR" ] || ! container_is_running "$DASHBOARD_CTR"; then + echo "Dashboard not running after wake — starting it explicitly..." + HOST_PROJECT_PATH="$HOST_PROJECT_PATH" \ + docker compose \ + -f "$COMPOSE_FILE" \ + up -d dashboard + fi + echo echo "Containers:" show_status