diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index e1aa31e4..53b9d477 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -405,17 +405,20 @@ export default function CourrierPage() { setAccounts(updatedAccounts); console.log('[DEBUG] Updated accounts:', updatedAccounts); - // Auto-select the first non-All account if available - if (updatedAccounts.length > 1) { - console.log('Auto-selecting account:', updatedAccounts[1]); - setSelectedAccount(updatedAccounts[1]); - setShowFolders(true); + // Auto-select the first account if available + if (updatedAccounts.length > 0) { + // Get first real account (not "All Accounts") + const firstAccount = updatedAccounts.length > 1 ? updatedAccounts[1] : updatedAccounts[0]; + console.log('Auto-selecting first account:', firstAccount); - // Set initial selected folder - setSelectedFolders(prev => ({ - ...prev, - [updatedAccounts[1].id]: 'INBOX' - })); + // Trigger account selection + setTimeout(() => { + // Use the same account selection flow we use when user clicks + if (firstAccount) { + // This will handle showing folders and loading emails + handleAccountSelect(firstAccount); + } + }, 200); } } else { // User is authenticated but doesn't have email credentials @@ -1053,7 +1056,7 @@ export default function CourrierPage() { { try { const result = await sendEmail(emailData);