From b3f669afe4095eeabc1a911a3cc60f84bd80ec8e Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Mon, 6 Apr 2026 22:00:20 -0400 Subject: [PATCH] fix: extension defaulting to UDP mode causing upload failures The extension was saving and restoring UDP mode from storage. If UDP was previously selected and the relay isn't configured, every upload immediately fails with "UDP relay not configured". - Default to HTTP mode on fresh installs (no saved mode) - Before UDP upload, check /api/health relayConfigured flag and auto-fall-back to HTTP with a warning if relay isn't set up Co-Authored-By: Claude Sonnet 4.6 --- chrome-extension/popup.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/chrome-extension/popup.js b/chrome-extension/popup.js index 1ee352e..eff88cc 100644 --- a/chrome-extension/popup.js +++ b/chrome-extension/popup.js @@ -14,6 +14,8 @@ let connected = false; if (stored.config) config = { ...config, ...stored.config }; if (stored.token && stored.token !== null) authToken = stored.token; if (stored.mode) uploadMode = stored.mode; + // Default to HTTP if no mode saved + if (!stored.mode) uploadMode = 'http'; document.getElementById('cfg-server').value = config.serverUrl; document.getElementById('cfg-user').value = config.username; @@ -232,6 +234,17 @@ function updateBtn() { // ==================== UPLOAD ==================== async function startUpload() { if (!connected) { showStatus('Not connected to server', 'error'); return; } + // If UDP mode selected but relay not configured, fall back to HTTP silently + if (uploadMode === 'udp') { + try { + const health = await apiFetch('GET', '/api/health'); + if (!health.relayConfigured) { + showStatus('⚠️ UDP relay not configured — switching to HTTP', 'loading'); + setMode('http'); + await new Promise(r => setTimeout(r, 1000)); + } + } catch (_) {} + } const pending = selectedFiles.filter(f => f.status === 'pending'); document.getElementById('upload-btn').disabled = true; const prefix = document.getElementById('folder-select').value;