favorite
favorite
favorite_border
flutter_dash
auto_awesome
1 β†’

TEA-O-METER

πŸ’–
πŸ”₯
πŸ₯΄
🚩
PASSWORD-PROTECTED SYNC
Match-made In Tea-ven
MESSY BUT PROMISING
Spicy sync. Major vibes, minor bugs.
LUKEWARM DELUSION
Still glitching…Oof Try again!
RED FLAGS PARADE
Emotional Wi-fi Unstable

> Well well well… look who logged back in. Tea connoisseur energy. Luna’s circuits are beaming.

local_cafe
β†ͺ Click here to get started
tag in screen1. // It reads run_id from the URL, polls /delivery/:run_id every 4 seconds, // and calls window.onResultsReady(payload) when delivery_ready = true. // Stops after 1 success or 25 attempts (~100 seconds). (function startDeliveryPoller() { const runId = getRunIdFromParams(); if (!runId) { console.warn('[poller] No run_id in URL β€” poller not started. Waiting for manual trigger.'); return; } console.log('[poller] Starting delivery poll for run_id:', runId); const POLL_INTERVAL_MS = 4000; const MAX_ATTEMPTS = 25; let attempts = 0; let pollTimer = null; async function poll() { attempts++; console.log(`[poller] Attempt ${attempts}/${MAX_ATTEMPTS} for ${runId}`); try { const deliveryPath = `/delivery/${encodeURIComponent(runId)}`; const deliveryUrl = API_BASE ? `${API_BASE}${deliveryPath}` : deliveryPath; const res = await fetch(deliveryUrl, { headers: { 'Accept': 'application/json' }, }); // 202 = still processing (pending or manual_review_required) β€” keep polling if (res.status === 202) { console.log('[poller] Still processing (202) β€” will retry.'); scheduleNext(); return; } if (!res.ok) { console.warn(`[poller] Unexpected status ${res.status} β€” will retry.`); scheduleNext(); return; } const payload = await res.json(); if (payload.delivery_ready === true && payload.response_text) { console.log('[poller] Delivery ready β€” firing onResultsReady.'); stopPoller(); // Pass full payload so screen 1 can persist to sessionStorage for screen 2/3 if (typeof window.onResultsReady === 'function') { window.onResultsReady(payload); } else { console.error('[poller] window.onResultsReady is not defined β€” cannot trigger UI.'); } return; } // Payload arrived but not ready yet (owed_delivery / manual review) if (payload.owed_delivery) { console.log('[poller] Owed delivery β€” manual review in progress. Continuing to poll.'); } scheduleNext(); } catch (err) { console.warn(`[poller] Fetch error on attempt ${attempts}:`, err.message); scheduleNext(); } } function scheduleNext() { if (attempts >= MAX_ATTEMPTS) { console.warn('[poller] Max attempts reached β€” stopping. Reading may still arrive via email.'); stopPoller(); // Update status text so user knows what's happening const statusEl = document.getElementById('status-text'); if (statusEl) { statusEl.innerText = "Luna's still cooking... check your email β€” it'll land there. β˜•"; } return; } pollTimer = setTimeout(poll, POLL_INTERVAL_MS); } function stopPoller() { if (pollTimer) { clearTimeout(pollTimer); pollTimer = null; } } // Kick off first poll after a short delay so the page animations can settle setTimeout(poll, 2000); })();