/** * 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() { this.isOpen = false; this.isMobile = window.matchMedia('(max-width: 768px)').matches; this.selectedType = null; this.csrfToken = null; this.init(); } async init() { // Get CSRF token await this.fetchCsrfToken(); // Render components this.renderFAB(); this.renderModal(); // Attach event listeners this.attachEventListeners(); // 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}