function downloadVersion(versionId) { fetch('/api/versions/' + versionId + '/download') .then(function(res) { if (!res.ok) throw new Error('Failed to get download URL'); return res.json(); }) .then(function(data) { window.location.href = data.download_url; }) .catch(function(err) { showToast(err.message || 'Download failed'); }); }