// InsightFlow AI - Custom UI Script document.addEventListener('DOMContentLoaded', function() { // Create and append the custom UI elements once the Chainlit UI has loaded setTimeout(createCustomUI, 1000); }); // Main function to create the custom UI function createCustomUI() { createLeftSidebar(); createAppTabs(); createRightSidebar(); setupEventListeners(); } // Create the left sidebar with settings function createLeftSidebar() { const sidebar = document.querySelector('.cl-sidebar'); if (!sidebar) return; // Clear existing content sidebar.innerHTML = ''; // Add app title const appTitle = document.createElement('div'); appTitle.className = 'app-title'; appTitle.textContent = 'InsightFlow AI'; sidebar.appendChild(appTitle); // Create Research Panel Settings section const researchSettings = document.createElement('div'); researchSettings.className = 'settings-section'; researchSettings.innerHTML = `
Select Persona Types:
Methodical examination of details and logical connections for problem-solving.
Available Personalities:
Evidence-based reasoning using empirical data and research.
Available Personalities:
Holistic perspectives examining deeper meaning and interconnectedness.
Available Personalities:
Add background information or specific instructions
`; // Assemble the research context sidebar researchContext.appendChild(tabs); researchContext.appendChild(activePersonasSection); researchContext.appendChild(additionalContextSection); // Add the research context to the main element const parent = main.parentElement; parent.appendChild(researchContext); } // Set up event listeners for interactive elements function setupEventListeners() { // Toggle persona accordions const personaHeaders = document.querySelectorAll('.persona-header'); personaHeaders.forEach(header => { header.addEventListener('click', function() { const content = this.nextElementSibling; const indicator = this.querySelector('span'); if (content.style.display === 'none') { content.style.display = 'block'; indicator.textContent = '▼'; } else { content.style.display = 'none'; indicator.textContent = '▶'; } }); }); // Handle tab switching const appTabs = document.querySelectorAll('.app-tab'); appTabs.forEach(tab => { tab.addEventListener('click', function() { // Remove active class from all tabs appTabs.forEach(t => t.classList.remove('active')); // Add active class to clicked tab this.classList.add('active'); // Update the selected personas header based on tab const header = document.querySelector('.selected-personas-header'); if (header) { if (this.dataset.tab === 'research') { header.textContent = 'Selected Persona Types: Analytical/Diagnostic, Scientific/STEM Explorer, Spiritual/Philosophical'; } else { header.textContent = 'Multi-Persona Discussion Mode: All personas participate independently'; } } }); }); // Handle research context tabs const researchTabs = document.querySelectorAll('.research-tab'); researchTabs.forEach(tab => { tab.addEventListener('click', function() { // Remove active class from all tabs researchTabs.forEach(t => t.classList.remove('active')); // Add active class to clicked tab this.classList.add('active'); }); }); // Handle clear chat button const clearChatBtn = document.getElementById('clearChat'); if (clearChatBtn) { clearChatBtn.addEventListener('click', function() { // This would typically call a Chainlit function to clear the chat // For now, just clear the messages in the UI const messageList = document.querySelector('.cl-message-list'); if (messageList) { messageList.innerHTML = ''; } }); } } // Periodically check if UI needs to be refreshed (in case of Chainlit UI refreshes) setInterval(function() { const customUi = document.querySelector('.app-title'); if (!customUi) { createCustomUI(); } }, 3000);