From 5ff0635aa585a8c9cedf585853cd378827bf33ff Mon Sep 17 00:00:00 2001 From: Claus Lohmar Date: Tue, 21 Jul 2026 19:43:04 +0000 Subject: [PATCH] fix: show upload phase immediately + fallback for non-computable progress Added loadstart handler to show 'Uploading...' spinner as soon as upload begins, plus fallback label when lengthComputable is false (shows bytes uploaded even without percentage). --- frontend/templates/index.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/templates/index.html b/frontend/templates/index.html index a22d8ec..5e41565 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -128,17 +128,31 @@ async function startSession(e) { } btn.disabled = false; } - async function handleUpload(formData) { return new Promise((resolve) => { const xhr = new XMLHttpRequest(); xhr.open('POST', '/session/upload'); + xhr.timeout = 7200000; // 2 hour timeout for very large uploads + xhr.upload.addEventListener('progress', (e) => { if (e.lengthComputable) { const pct = Math.round((e.loaded / e.total) * 100); setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', pct, false); + } else { + // Fallback: show bytes uploaded even without total + setPhase('Uploading source file... ' + (e.loaded / (1024**3)).toFixed(1) + ' GiB', 0, true); } }); + + xhr.addEventListener('loadstart', () => { + setPhase('Uploading source file...', 0, true); + }); + + xhr.addEventListener('timeout', () => { + setPhase('Upload timed out', 0, false); + showError('Upload timed out after 2 hours. The file may be too large for your connection speed. Try downloading the file directly on the server instead.'); + resolve(); + }); xhr.addEventListener('load', async () => { if (xhr.status === 200) { const data = JSON.parse(xhr.responseText);