personal memory agent
at main 51 lines 1.4 kB view raw
1{# Support background service: polls for ticket updates, manages badges #} 2 3const POLL_INTERVAL = 5 * 60 * 1000; // 5 minutes 4let pollTimer = null; 5 6AppServices.register('support', { 7 initialize() { 8 updateBadge(); 9 pollTimer = setInterval(updateBadge, POLL_INTERVAL); 10 11 // Listen for proactive suggestions from callosum 12 if (window.appEvents) { 13 window.appEvents.listen('support', function(msg) { 14 if (msg.event === 'proactive_suggestion') { 15 AppServices.notifications.show({ 16 app: 'support', 17 icon: '🛟', 18 title: 'Support suggestion', 19 message: msg.message || 'Something may need attention.', 20 action: '/app/support', 21 dismissible: true, 22 autoDismiss: 30000 23 }); 24 } 25 }); 26 } 27 }, 28 29 stop() { 30 if (pollTimer) { 31 clearInterval(pollTimer); 32 pollTimer = null; 33 } 34 } 35 }); 36 37 async function updateBadge() { 38 try { 39 const resp = await fetch('/app/support/api/badge-count'); 40 if (!resp.ok) return; 41 const data = await resp.json(); 42 const count = data.count || 0; 43 if (count > 0) { 44 AppServices.badges.app.set('support', count); 45 } else { 46 AppServices.badges.app.clear('support'); 47 } 48 } catch (e) { 49 // Silently ignore — support may be disabled or portal unreachable 50 } 51 }