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);