From dfb60674c5e9fd77ef7e9d77b49a0d61b89def27 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Fri, 3 Jul 2026 12:31:48 +0700 Subject: [PATCH] Fix Amber timeout: increase to 3 minutes so user has time to approve in Amber and return Co-authored-by: shakespeare.diy --- src/components/auth/LoginDialog.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/auth/LoginDialog.tsx b/src/components/auth/LoginDialog.tsx index ff16cb4..d428bb6 100644 --- a/src/components/auth/LoginDialog.tsx +++ b/src/components/auth/LoginDialog.tsx @@ -276,7 +276,7 @@ export const LoginDialog: React.FC = ({ isOpen, onClose, onLog amberStepRef.current = 'waiting'; setAmberStep('waiting'); - setAmberStatus('Waiting for Amber to approve...'); + setAmberStatus('Approve in Amber, then come back here.'); // Live relay subscription (works on web/PWA; may be backgrounded in Capacitor) const pool = new SimplePool(); @@ -316,10 +316,13 @@ export const LoginDialog: React.FC = ({ isOpen, onClose, onLog ); subRef.current = sub; - // Timeout after 20 seconds — show error, let user retry + // On Capacitor (native app) give 3 minutes — the visibility change handler does the real work + // after the user returns from Amber, so the live subscription just needs to stay alive. + // On web/PWA the live subscription fires instantly, so 3 min is still fine as a safety net. + const TIMEOUT_MS = isCapacitor ? 3 * 60 * 1000 : 3 * 60 * 1000; setTimeout(() => { if (!controller.signal.aborted) { - console.warn('[Amber] Timed out after 20s — no response received'); + console.warn('[Amber] Timed out — no response received'); controller.abort(); cleanup(); if (amberStepRef.current === 'waiting') { @@ -328,7 +331,7 @@ export const LoginDialog: React.FC = ({ isOpen, onClose, onLog setAmberStatus('Amber did not respond in time. Did you approve the connection?'); } } - }, 20 * 1000); + }, TIMEOUT_MS); }, [cleanup, completeLogin, toast]); const handleBunkerLogin = async () => {