/** * Tractatus Framework - Governed Feedback Component * Demonstrates Agent Lightning + Tractatus governance in action * * Features: * - Floating Action Button (FAB) for quick access * - Modal dialog for feedback submission * - Mobile-optimized bottom sheet * - Real-time governance pathway classification * - Integration with BoundaryEnforcer, PluralisticDeliberator, CrossReferenceValidator */ class TractausFeedback { constructor() { console.log('[Feedback] Constructor called'); this.isOpen = false; this.isMobile = window.matchMedia('(max-width: 768px)').matches; this.selectedType = null; this.csrfToken = null; this.init(); console.log('[Feedback] Constructor complete'); } async init() { console.log('[Feedback] Init called'); // Render components IMMEDIATELY (don't wait for CSRF) this.renderFAB(); console.log('[Feedback] FAB rendered'); this.renderModal(); console.log('[Feedback] Modal rendered'); // Attach event listeners this.attachEventListeners(); console.log('[Feedback] Event listeners attached'); // Get CSRF token in parallel (non-blocking) this.fetchCsrfToken(); // Listen for window resize window.addEventListener('resize', () => { this.isMobile = window.matchMedia('(max-width: 768px)').matches; }); // Listen for external open feedback requests (from navbar, etc.) window.addEventListener('openFeedbackModal', () => { this.openModal(); }); } async fetchCsrfToken() { try { const response = await fetch('/api/csrf-token'); const data = await response.json(); this.csrfToken = data.csrfToken; } catch (error) { console.error('[Feedback] Failed to fetch CSRF token:', error); } } /** * Render Floating Action Button (FAB) * Omnipresent on all pages for quick feedback access */ renderFAB() { const fabHTML = ` `; document.body.insertAdjacentHTML('beforeend', fabHTML); } /** * Render Feedback Modal/Bottom Sheet * Adapts to mobile (bottom sheet) vs desktop (modal) */ renderModal() { const modalHTML = `
Powered by Tractatus + Agent Lightning
How this works
Your feedback is automatically classified by our BoundaryEnforcer to determine the appropriate response pathway. This ensures you get the right type of response while maintaining governance.
Tracking ID:
Pathway: ${info.pathway}
${info.description}
Governance Summary
${data.feedbackId}