Fix: no-cache headers for static files, null guards in loadQueue/loadGallery, error boundaries in initializeApp, add paused to queue filter

This commit is contained in:
2026-07-01 09:01:54 -04:00
parent 9a8d3a814a
commit 037eb6ae23
2 changed files with 23 additions and 7 deletions
+16
View File
@@ -19,6 +19,22 @@ import app.upscaler as upscaler
app = FastAPI(title="AI Video Upscaler Dashboard")
# Middleware to prevent browser caching of static files (dev mode)
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
class NoCacheStaticMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
response = await call_next(request)
path = request.url.path
if path.endswith(('.js', '.css', '.html')) or path == '/':
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
return response
app.add_middleware(NoCacheStaticMiddleware)
# CORS middleware for local development
app.add_middleware(
CORSMiddleware,
+7 -7
View File
@@ -1494,7 +1494,7 @@ async function loadQueue() {
const jobs = await res.json();
const displayJobs = jobs.filter(job =>
["queued", "analyzing", "extracting", "upscaling", "restoring_faces", "interpolating", "assembling", "completed", "failed", "cancelled", "interrupted"].includes(job.status)
["queued", "analyzing", "extracting", "upscaling", "restoring_faces", "interpolating", "assembling", "completed", "failed", "cancelled", "interrupted", "paused"].includes(job.status)
);
if (displayJobs.length === 0) {
@@ -1520,7 +1520,7 @@ async function loadQueue() {
let metaHtml = `
<span><i class="fa-solid fa-microchip"></i> Model: ${modelLabel} (${scaleLabel})</span>
<span><i class="fa-solid fa-file-video"></i> Source: ${job.video_path.split('/').pop()}</span>
<span><i class="fa-solid fa-file-video"></i> Source: ${job.video_path ? job.video_path.split('/').pop() : 'Unknown'}</span>
`;
let errorHtml = "";
@@ -2033,11 +2033,11 @@ async function loadUploadsBrowser() {
}
async function initializeApp() {
await loadModels();
await checkActiveJobs();
await loadGallery(); // Load enhancement gallery at page load
await loadQueue(); // Load active jobs queue at page load
await loadUploadsBrowser(); // Load previously uploaded videos browser
try { await loadModels(); } catch(e) { console.error("initializeApp: loadModels failed:", e); }
try { await checkActiveJobs(); } catch(e) { console.error("initializeApp: checkActiveJobs failed:", e); }
try { await loadGallery(); } catch(e) { console.error("initializeApp: loadGallery failed:", e); }
try { await loadQueue(); } catch(e) { console.error("initializeApp: loadQueue failed:", e); }
try { await loadUploadsBrowser(); } catch(e) { console.error("initializeApp: loadUploadsBrowser failed:", e); }
// Load GPU Diagnostics
try {