cuga-agent / docs /flags.html
Sami Marreed
feat: docker-v1 with optimized frontend
0646b18
Raw History Blame Contribute Delete
43 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Mode Selector with Feature Flags</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 20px; } .container { max-width: 1600px; margin: 0 auto; background: white; border-radius: 20px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1); overflow: hidden; display: flex; min-height: 600px; } .modes-section { flex: 2; padding: 40px; background: #f8f9fa; } .flags-section { flex: 1.5; padding: 40px; background: #fff; border-left: 2px solid #e9ecef; min-width: 500px; } h1 { color: #2c3e50; margin-bottom: 30px; font-size: 2.5em; text-align: center; background: linear-gradient(45deg, #667eea, #764ba2); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } h2 { color: #34495e; margin-bottom: 20px; font-size: 1.8em; border-bottom: 3px solid #3498db; padding-bottom: 10px; } .modes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; } .mode-card { background: white; border-radius: 15px; padding: 25px; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); cursor: pointer; transition: all 0.3s ease; border: 3px solid transparent; position: relative; overflow: hidden; } .mode-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, #3498db, #2ecc71); transform: scaleX(0); transition: transform 0.3s ease; } .mode-card:hover { transform: translateY(-5px); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15); } .mode-card:hover::before { transform: scaleX(1); } .mode-card.active { border-color: #3498db; background: linear-gradient(135deg, #e8f4fd 0%, #f0f8ff 100%); transform: translateY(-3px); } .mode-card.active::before { transform: scaleX(1); } .mode-title { font-size: 1.4em; font-weight: bold; color: #2c3e50; margin-bottom: 10px; display: flex; align-items: center; } .mode-icon { width: 24px; height: 24px; margin-right: 10px; border-radius: 50%; } .fast .mode-icon { background: #e74c3c; } .balanced .mode-icon { background: #f39c12; } .accurate .mode-icon { background: #2ecc71; } .save_reuse_fast .mode-icon { background: #e67e22; } .custom .mode-icon { background: #9b59b6; } .mode-description { color: #7f8c8d; line-height: 1.6; font-size: 0.95em; } .mode-stats { margin-top: 15px; padding-top: 15px; border-top: 1px solid #e9ecef; } .stat-item { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.85em; } .stat-label { color: #6c757d; } .stat-value { font-weight: 600; color: #495057; } .flags-container { display: flex; flex-direction: column; gap: 12px; } .flag-item { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; background: #f8f9fa; border-radius: 10px; transition: all 0.3s ease; border-left: 4px solid #dee2e6; cursor: pointer; position: relative; min-height: 60px; gap: 15px; } .flag-item:hover { background: #e9ecef; transform: translateX(2px); } .flag-item.active { background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%); border-left-color: #28a745; transform: translateX(5px); } .flag-item.active .flag-name { color: #155724; font-weight: 600; } .flag-item.active .flag-description { color: #155724; opacity: 0.8; } .flag-content { flex: 1; min-width: 0; margin-right: 15px; } .flag-name { font-weight: 500; color: #495057; font-size: 0.95em; margin-bottom: 4px; white-space: nowrap; display: flex; align-items: center; gap: 8px; } .flag-description { font-size: 0.8em; color: #6c757d; line-height: 1.3; opacity: 0; max-height: 0; overflow: hidden; transition: all 0.3s ease; } .flag-item:hover .flag-description { opacity: 1; max-height: 100px; } .flag-toggle { width: 50px; height: 24px; background: #dee2e6; border-radius: 12px; position: relative; transition: all 0.3s ease; cursor: pointer; flex-shrink: 0; } .flag-toggle.active { background: #28a745; } .flag-toggle::after { content: ""; position: absolute; width: 20px; height: 20px; background: white; border-radius: 50%; top: 2px; left: 2px; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .flag-toggle.active::after { left: 28px; } .flag-select { padding: 5px 8px; border-radius: 5px; border: 1px solid #ced4da; background-color: #e9ecef; font-size: 0.85em; color: #495057; transition: all 0.2s ease; min-width: 100px; flex-shrink: 0; } .flag-select:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); } .flag-select:disabled { background-color: #f1f3f5; cursor: not-allowed; } .flag-input { padding: 5px 8px; border-radius: 5px; border: 1px solid #ced4da; background-color: #e9ecef; font-size: 0.85em; color: #495057; transition: all 0.2s ease; min-width: 150px; flex-shrink: 0; } .flag-input:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); } .flag-input:disabled { background-color: #f1f3f5; cursor: not-allowed; } .configuration-header { display: flex; justify-content: space-between; /* Changed to space-between */ align-items: center; margin-bottom: 20px; gap: 10px; } .mode-indicator { background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 8px 16px; border-radius: 25px; font-size: 0.9em; font-weight: 600; text-transform: capitalize; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); } .export-btn { background: #3498db; color: white; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 0.85em; font-weight: 500; transition: all 0.3s ease; display: flex; align-items: center; gap: 6px; } .export-btn:hover { background: #2980b9; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3); } .export-btn:active { transform: translateY(0); } .export-icon { width: 14px; height: 14px; fill: currentColor; } .copyMessage { margin-top: 10px; margin-bottom: 10px; border: 1px solid #d2eded; padding: 10px; border-radius: 10px; background-color: #dffff8; } .config-summary { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 10px; padding: 15px; margin-bottom: 20px; } .summary-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 0.9em; } .summary-row:last-child { margin-bottom: 0; } .summary-label { color: #6c757d; font-weight: 500; } .summary-value { font-weight: 600; color: #495057; } .category-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75em; font-weight: 500; margin-left: 8px; } .category-performance { background: #e3f2fd; color: #1976d2; } .category-ux { background: #e8f5e8; color: #2e7d32; } .category-complex_tasks { background: #fff3e0; color: #f57c00; } .category-output_tokens { background: #f3e5f5; color: #7b1fa2; } .category-context_summarization { background: #e0f2f1; color: #00695c; } .category-error_adaptation { background: #ffebee; color: #c62828; } .category-execution_control { background: #e0f7fa; color: #00838f; } .category-reliability_safety { background: #fff8e1; color: #f57c00; } /* Modal Styles */ .modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1000; /* Sit on top */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */ justify-content: center; align-items: center; } .modal.show-modal { display: flex; } .modal-content { background-color: #fefefe; margin: auto; padding: 30px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); width: 80%; max-width: 600px; position: relative; animation: animatemodal 0.3s; } @keyframes animatemodal { from { top: -100px; opacity: 0; } to { top: 0; opacity: 1; } } .close-button { color: #aaa; position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; cursor: pointer; } .close-button:hover, .close-button:focus { color: black; text-decoration: none; } #exportContent { border-radius: 8px; font-family: "Cascadia Code", "Courier New", monospace; font-size: 0.9em; white-space: pre-wrap; /* Ensures text wraps */ word-break: break-all; /* Breaks long words */ max-height: 400px; overflow-y: auto; margin-bottom: 20px; color: #333; } .copy-btn { background: #2ecc71; color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 1em; font-weight: 500; transition: all 0.3s ease; display: block; /* Make it a block element to center */ margin: 0 auto; /* Center the button */ } .copy-btn:hover { background: #27ae60; transform: translateY(-2px); } .copy-btn.copied { background: #27ae60; } @media (max-width: 1200px) { .container { max-width: 1200px; } .flags-section { min-width: 400px; } } @media (max-width: 768px) { .container { flex-direction: column; margin: 10px; max-width: 100%; } .modes-section, .flags-section { padding: 20px; min-width: auto; } .modes-grid { grid-template-columns: 1fr; } h1 { font-size: 2em; } .configuration-header { flex-direction: column; align-items: stretch; } .download-controls { justify-content: center; } .modal-content { width: 95%; padding: 20px; } .flag-item { flex-direction: column; align-items: stretch; gap: 10px; } .flag-content { margin-right: 0; } .flag-name { white-space: normal; } } </style> </head> <body> <div class="container"> <div class="modes-section"> <h1>App Modes</h1> <div class="modes-grid"> <div class="mode-card fast active" data-mode="fast"> <div class="mode-title"> <div class="mode-icon"></div> Fast Mode </div> <div class="mode-description"> Optimized for speed and quick responses. Minimal processing overhead with basic feature set for rapid execution. </div> <div class="mode-stats"> <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">Best</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">Simple</span> </div> <div class="stat-item"> <span class="stat-label">Exec Time:</span> <span class="stat-value">4-10s</span> </div> <div class="stat-item"> <span class="stat-label">LLM Calls:</span> <span class="stat-value">6</span> </div> <div class="stat-item"> <span class="stat-label">Tokens:</span> <span class="stat-value">21k-24k</span> </div> </div> </div> <div class="mode-card accurate" data-mode="accurate"> <div class="mode-title"> <div class="mode-icon"></div> Accurate Mode </div> <div class="mode-description"> Maximum precision and comprehensive analysis. All validation and quality checks enabled for critical operations. </div> <div class="mode-stats"> <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">Ok</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">Complex</span> </div> <div class="stat-item"> <span class="stat-label">Exec Time:</span> <span class="stat-value">35-40s</span> </div> <div class="stat-item"> <span class="stat-label">LLM Calls:</span> <span class="stat-value">10</span> </div> <div class="stat-item"> <span class="stat-label">Tokens:</span> <span class="stat-value">35k-37k</span> </div> </div> </div> <div class="mode-card balanced" data-mode="balanced"> <div class="mode-title"> <div class="mode-icon"></div> Balanced Mode </div> <div class="mode-description"> Balanced approach between speed and accuracy. Good performance with moderate feature set for most use cases. </div> <div class="mode-stats"> <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">Good</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">Moderate</span> </div> <div class="stat-item"> <span class="stat-label">Exec Time:</span> <span class="stat-value">9-15s</span> </div> <div class="stat-item"> <span class="stat-label">LLM Calls:</span> <span class="stat-value">9</span> </div> <div class="stat-item"> <span class="stat-label">Tokens:</span> <span class="stat-value">29k-33k</span> </div> </div> </div> <div class="mode-card save_reuse_fast" data-mode="save_reuse_fast"> <div class="mode-title"> <div class="mode-icon"></div> Save & Reuse Fast </div> <div class="mode-description"> Fast mode with save and reuse capabilities enabled. Build time same as fast mode, with additional 2s for save operation. </div> <div class="mode-stats"> <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">Good</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">Any</span> </div> <div class="stat-item"> <span class="stat-label">Exec Time:</span> <span class="stat-value">15s-35s -> 3s</span> </div> <div class="stat-item"> <span class="stat-label">LLM Calls:</span> <span class="stat-value">8 -> 1</span> </div> <div class="stat-item"> <span class="stat-label">Tokens:</span> <span class="stat-value">21k-24k -> 1k</span> </div> </div> </div> <div class="mode-card custom" data-mode="custom"> <div class="mode-title"> <div class="mode-icon"></div> Custom Mode </div> <div class="mode-description"> Manually configure individual feature flags. Full control over system behavior and resource allocation. </div> <div class="mode-stats"> <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">Variable</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">Variable</span> </div> </div> </div> </div> </div> <div class="flags-section"> <div class="configuration-header"> <h2>Feature Flags</h2> <button class="export-btn" id="exportConfigBtn" title="Export Configuration"> <svg class="export-icon" viewBox="0 0 24 24"> <path d="M19,10H15V6H9V10H5L12,17L19,10M3,2H21A2,2 0 0,1 23,4V20A2,2 0 0,1 21,22H3A2,2 0 0,1 1,20V4A2,2 0 0,1 3,2M3,4V20H21V4H3Z" /> </svg> Export Configuration </button> </div> <div class="mode-indicator" id="modeIndicator">Fast Mode</div> <div class="config-summary"> <div class="summary-row"> <span class="summary-label">Active Flags:</span> <span class="summary-value" id="activeFlagsCount">2</span> </div> <div class="summary-row"> <span class="summary-label">Total Flags:</span> <span class="summary-value" id="totalFlagsCount">10</span> </div> <div class="summary-row"> <span class="summary-label">Performance Impact:</span> <span class="summary-value" id="performanceImpact">Low</span> </div> </div> <div class="flags-container"></div> </div> </div> <div id="exportModal" class="modal"> <div class="modal-content"> <span class="close-button">&times;</span> <h2>Current Configuration</h2> <pre><code id="exportContent"></code></pre> <button class="copy-btn" id="copyToClipboardBtn">Copy to Clipboard</button> <div class="copyMessage">Replace under settings.toml [features] section</div> </div> </div> <script> // Configuration data const config = { featureFlags: { chat: { name: "Enable Chat", description: "Enables followup questions and chat interface with task execution", category: "ux", type: "boolean", impact: "high", }, save_reuse: { name: "Enable Save & Reuse", description: "Enables Save and Reuse where system after final answer asks to save the flow, then will be available in chat mode.", category: "ux", type: "boolean", impact: "low", }, task_decomposition: { name: "Enable Task Decomposition", description: "Decomposes complex tasks into multiple sub-tasks for better handling", category: "complex_tasks", type: "boolean", impact: "high", }, local_sandbox: { name: "Local Sandbox", description: "Enables fast local sandbox without docker sandbox", category: "reliability_safety", type: "boolean", impact: "medium", }, thoughts: { name: "Enable Thoughts", description: "Enables detailed thought process logging and reasoning for better transparency", category: "output_tokens", type: "boolean", impact: "medium", }, code_output_summary: { name: "Code Output Summary", description: "Summarizes code output using additional context summarization task", category: "context_summarization", type: "boolean", impact: "low", }, code_generation: { name: "Code Generation Style", description: "Controls output verbosity: minimal code (fast) or detailed code (accurate)", category: "output_tokens", type: "categorical", options: ["fast", "accurate"], impact: "low", }, code_output_reflection: { name: "Code Output Reflection", description: "Reflects on code output to adapt and improve based on errors", category: "error_adaptation", type: "boolean", impact: "medium", }, final_answer: { name: "Final Answer", description: "Produces user-friendly final answer instead of raw variables", category: "ux", type: "boolean", impact: "low", }, forced_apps: { name: "Forced Applications", description: "List of applications that must always be active during execution", category: "execution_control", type: "array", impact: "low", }, }, modeConfigurations: { fast: { task_decomposition: false, final_answer: false, thoughts: false, local_sandbox: true, code_generation: "fast", code_output_summary: false, code_output_reflection: false, save_reuse: false, forced_apps: [], chat: false, }, accurate: { chat: false, task_decomposition: true, local_sandbox: false, thoughts: true, code_output_summary: true, code_generation: "accurate", code_output_reflection: true, save_reuse: false, forced_apps: [], final_answer: true, }, balanced: { chat: false, task_decomposition: true, local_sandbox: true, thoughts: false, code_output_summary: false, code_generation: "fast", code_output_reflection: true, save_reuse: false, forced_apps: [], final_answer: true, }, save_reuse_fast: { task_decomposition: false, final_answer: false, thoughts: true, local_sandbox: true, code_generation: "fast", code_output_summary: false, code_output_reflection: false, save_reuse: true, forced_apps: [], chat: true, }, custom: { // This will be dynamically populated }, }, }; let currentMode = "fast"; // Changed initial mode to "fast" // Deep copy to ensure customFlags is independent and can be modified let customFlags = JSON.parse(JSON.stringify(config.modeConfigurations["fast"])); // Changed initial customFlags to "fast" // Get DOM elements const modeCards = document.querySelectorAll(".mode-card"); const flagsContainer = document.querySelector(".flags-container"); const modeIndicator = document.getElementById("modeIndicator"); const activeFlagsCount = document.getElementById("activeFlagsCount"); const totalFlagsCount = document.getElementById("totalFlagsCount"); const performanceImpact = document.getElementById("performanceImpact"); // Modal elements const exportModal = document.getElementById("exportModal"); const exportConfigBtn = document.getElementById("exportConfigBtn"); const closeButton = document.querySelector(".close-button"); const exportContent = document.getElementById("exportContent"); const copyToClipboardBtn = document.getElementById("copyToClipboardBtn"); // Initialize the interface function init() { createFlagElements(); // Create all flag elements first selectMode(currentMode); // Select initial mode to apply its configurations // Event listeners for mode cards are added only once during init modeCards.forEach((card) => { card.addEventListener("click", () => { const mode = card.dataset.mode; selectMode(mode); }); }); // Event listeners for modal exportConfigBtn.addEventListener("click", exportConfig); closeButton.addEventListener("click", () => { exportModal.classList.remove("show-modal"); }); window.addEventListener("click", (event) => { if (event.target == exportModal) { exportModal.classList.remove("show-modal"); } }); copyToClipboardBtn.addEventListener("click", copyConfigToClipboard); } // Create flag elements function createFlagElements() { flagsContainer.innerHTML = ""; // Clear existing flags Object.keys(config.featureFlags).forEach((flagKey) => { const flag = config.featureFlags[flagKey]; const flagElement = document.createElement("div"); flagElement.className = "flag-item"; flagElement.dataset.flag = flagKey; let flagControlHtml = ""; if (flag.type === "boolean") { flagControlHtml = `<div class="flag-toggle"></div>`; } else if (flag.type === "categorical") { flagControlHtml = ` <select class="flag-select" data-flag="${flagKey}"> ${flag.options.map((option) => `<option value="${option}">${option}</option>`).join("")} </select> `; } else if (flag.type === "array") { flagControlHtml = ` <input type="text" class="flag-input" data-flag="${flagKey}" placeholder="Enter apps (comma-separated)" /> `; } flagElement.innerHTML = ` <div class="flag-content"> <span class="flag-name"> ${flag.name} <span class="category-badge category-${flag.category}">${flag.category}</span> </span> <div class="flag-description">${flag.description}</div> </div> ${flagControlHtml} `; flagsContainer.appendChild(flagElement); }); // Add event listeners after elements are created addToggleListeners(); addCategoricalFlagListeners(); addArrayFlagListeners(); } function addToggleListeners() { // Remove existing listeners to prevent duplicates document.querySelectorAll(".flag-toggle").forEach((toggle) => { toggle.removeEventListener("click", handleToggleClick); }); // Add new listeners document.querySelectorAll(".flag-toggle").forEach((toggle) => { toggle.addEventListener("click", handleToggleClick); }); } function handleToggleClick(e) { e.stopPropagation(); const flagKey = this.closest(".flag-item").dataset.flag; if (currentMode === "custom") { customFlags[flagKey] = !customFlags[flagKey]; updateFlagsDisplay(); } } function addCategoricalFlagListeners() { // Remove existing listeners to prevent duplicates document.querySelectorAll(".flag-select").forEach((select) => { select.removeEventListener("change", handleCategoricalChange); }); // Add new listeners document.querySelectorAll(".flag-select").forEach((select) => { select.addEventListener("change", handleCategoricalChange); }); } function handleCategoricalChange(e) { const flagKey = this.dataset.flag; if (currentMode === "custom") { customFlags[flagKey] = e.target.value; updateFlagsDisplay(); } } function addArrayFlagListeners() { // Remove existing listeners to prevent duplicates document.querySelectorAll(".flag-input").forEach((input) => { input.removeEventListener("input", handleArrayChange); }); // Add new listeners document.querySelectorAll(".flag-input").forEach((input) => { input.addEventListener("input", handleArrayChange); }); } function handleArrayChange(e) { const flagKey = this.dataset.flag; if (currentMode === "custom") { const value = e.target.value; // Convert comma-separated string to array customFlags[flagKey] = value ? value.split(',').map(item => item.trim()).filter(item => item) : []; updateFlagsDisplay(); } } // Select a mode function selectMode(mode) { currentMode = mode; // Update active mode card modeCards.forEach((card) => { card.classList.remove("active"); if (card.dataset.mode === mode) { card.classList.add("active"); } }); // If switching TO custom mode, capture the current mode's settings if (currentMode === "custom") { // If we're coming from another pre-defined mode, initialize customFlags with its values // Otherwise, if already in custom, maintain its state if (!config.modeConfigurations.custom.initialized) { // Use a flag or check if it's empty customFlags = JSON.parse(JSON.stringify(config.modeConfigurations["fast"])); // Start custom from fast config.modeConfigurations.custom.initialized = true; } } else { // When switching FROM custom mode to a predefined mode, reset customFlags // so that if we switch back to custom, it starts fresh from the last active predefined mode customFlags = JSON.parse(JSON.stringify(config.modeConfigurations[currentMode])); config.modeConfigurations.custom.initialized = false; // Reset init flag } updateFlagsDisplay(); updateModeStatsDisplay(currentMode); // Call to update the stats display } // Update the flags display based on current mode function updateFlagsDisplay() { // Determine which set of flags to use for display const activeFlagsConfig = currentMode === "custom" ? customFlags : config.modeConfigurations[currentMode]; const flagItems = document.querySelectorAll(".flag-item"); flagItems.forEach((item) => { const flagKey = item.dataset.flag; const flagDefinition = config.featureFlags[flagKey]; const flagValue = activeFlagsConfig[flagKey]; // Get the value for the current mode if (flagDefinition.type === "boolean") { const toggle = item.querySelector(".flag-toggle"); if (flagValue === true) { item.classList.add("active"); toggle.classList.add("active"); } else { item.classList.remove("active"); toggle.classList.remove("active"); } // Enable/disable toggle interaction for custom mode if (currentMode === "custom") { toggle.style.cursor = "pointer"; toggle.style.opacity = "1"; } else { toggle.style.cursor = "not-allowed"; toggle.style.opacity = "0.8"; } } else if (flagDefinition.type === "categorical") { const selectElement = item.querySelector(".flag-select"); if (selectElement) { selectElement.value = flagValue; // Set the current value from the active config if (currentMode === "custom") { selectElement.disabled = false; item.classList.add("active"); // Categorical flags are "active" if they have a value } else { selectElement.disabled = true; item.classList.add("active"); // Still active as they have a pre-defined value } } } else if (flagDefinition.type === "array") { const inputElement = item.querySelector(".flag-input"); if (inputElement) { inputElement.value = Array.isArray(flagValue) ? flagValue.join(', ') : ''; // Set the current value from the active config if (currentMode === "custom") { inputElement.disabled = false; item.classList.add("active"); // Array flags are "active" if they have values } else { inputElement.disabled = true; item.classList.add("active"); // Still active as they have a pre-defined value } } } }); updateSummary(activeFlagsConfig); } // Update the mode stats display function updateModeStatsDisplay(mode) { modeCards.forEach(card => { if (card.dataset.mode === mode) { const modeConfig = config.modeConfigurations[mode]; const statsContainer = card.querySelector(".mode-stats"); // Clear existing stats and add performance data let performanceValue = 'Variable'; let execTime = 'Variable'; let llmCalls = 'Variable'; let tokens = 'Variable'; let taskComplexity = 'Variable'; if (mode === 'fast') { performanceValue = 'Best'; execTime = '4-10s'; llmCalls = '6'; tokens = '21k-24k'; taskComplexity = 'Simple'; } else if (mode === 'accurate') { performanceValue = 'Ok'; execTime = '35-40s'; llmCalls = '10'; tokens = '35k-37k'; taskComplexity = 'Complex'; } else if (mode === 'balanced') { performanceValue = 'Good'; execTime = '9-15s'; llmCalls = '9'; tokens = '29k-33k'; taskComplexity = 'Moderate'; } else if (mode === 'save_reuse_fast') { performanceValue = 'Good'; execTime = '15s-35s -> 3s'; llmCalls = '8 -> 1'; tokens = '21k-24k -> 1k'; taskComplexity = 'Any'; } statsContainer.innerHTML = ` <div class="stat-item"> <span class="stat-label">Performance:</span> <span class="stat-value">${performanceValue}</span> </div> <div class="stat-item"> <span class="stat-label">Task Complexity:</span> <span class="stat-value">${taskComplexity}</span> </div> <div class="stat-item"> <span class="stat-label">Exec Time:</span> <span class="stat-value">${execTime}</span> </div> <div class="stat-item"> <span class="stat-label">LLM Calls:</span> <span class="stat-value">${llmCalls}</span> </div> <div class="stat-item"> <span class="stat-label">Tokens:</span> <span class="stat-value">${tokens}</span> </div> `; } }); } // Update configuration summary function updateSummary(activeFlagsConfig) { const modeNames = { fast: "Fast Mode", accurate: "Accurate Mode", balanced: "Balanced Mode", save_reuse_fast: "Save & Reuse Fast", custom: "Custom Mode", }; modeIndicator.textContent = modeNames[currentMode]; let currentlyActiveFlags = 0; let totalFlags = 0; let totalImpactScore = 0; let impactFlagCount = 0; Object.keys(config.featureFlags).forEach((flagKey) => { totalFlags++; const flagDefinition = config.featureFlags[flagKey]; const flagValue = activeFlagsConfig[flagKey]; // Get the value for the current mode's configuration if (flagDefinition.type === "boolean" && flagValue === true) { currentlyActiveFlags++; if (flagDefinition.impact) { totalImpactScore += getImpactScore(flagDefinition.impact); impactFlagCount++; } } else if (flagDefinition.type === "categorical") { // A categorical flag is considered 'active' if it has a value set (not null/undefined/empty string/empty array) if ( flagValue !== undefined && flagValue !== null && flagValue !== "" && !(Array.isArray(flagValue) && flagValue.length === 0) ) { currentlyActiveFlags++; if (flagDefinition.impact) { totalImpactScore += getImpactScore(flagDefinition.impact); impactFlagCount++; } } } else if (flagDefinition.type === "array") { // An array flag is considered 'active' if it has values if (Array.isArray(flagValue) && flagValue.length > 0) { currentlyActiveFlags++; if (flagDefinition.impact) { totalImpactScore += getImpactScore(flagDefinition.impact); impactFlagCount++; } } } }); activeFlagsCount.textContent = currentlyActiveFlags; totalFlagsCount.textContent = totalFlags; const averageImpact = impactFlagCount > 0 ? totalImpactScore / impactFlagCount : 0; let impactLevel = "Low"; if (averageImpact >= 2.5) impactLevel = "High"; else if (averageImpact >= 1.5) impactLevel = "Medium"; performanceImpact.textContent = impactLevel; } function getImpactScore(impact) { switch (impact) { case "low": return 1; case "medium": return 2; case "high": return 3; default: return 0; } } // Export configuration to modal function exportConfig() { const currentActiveConfig = currentMode === "custom" ? customFlags : config.modeConfigurations[currentMode]; let configText = ""; Object.keys(config.featureFlags).forEach((flagKey) => { const flagDefinition = config.featureFlags[flagKey]; const flagValue = currentActiveConfig[flagKey]; let formattedValue; if (flagDefinition.type === "boolean") { formattedValue = flagValue ? "true" : "false"; } else if (flagDefinition.type === "array") { formattedValue = Array.isArray(flagValue) ? `[${flagValue.map(item => `"${item}"`).join(', ')}]` : "[]"; } else { formattedValue = flagValue; } configText += `${flagKey} = ${formattedValue}\n`; }); exportContent.textContent = configText; exportModal.classList.add("show-modal"); } // Copy to clipboard functionality function copyConfigToClipboard() { navigator.clipboard .writeText(exportContent.textContent) .then(() => { copyToClipboardBtn.textContent = "Copied!"; copyToClipboardBtn.classList.add("copied"); setTimeout(() => { copyToClipboardBtn.textContent = "Copy to Clipboard"; copyToClipboardBtn.classList.remove("copied"); }, 2000); }) .catch((err) => { console.error("Failed to copy: ", err); }); } // Initialize the application init(); </script> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mode Selector with Feature Flags</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1600px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
overflow: hidden;
display: flex;
min-height: 600px;
}
.modes-section {
flex: 2;
padding: 40px;
background: #f8f9fa;
}
.flags-section {
flex: 1.5;
padding: 40px;
background: #fff;
border-left: 2px solid #e9ecef;
min-width: 500px;
}
h1 {
color: #2c3e50;
margin-bottom: 30px;
font-size: 2.5em;
text-align: center;
background: linear-gradient(45deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
h2 {
color: #34495e;
margin-bottom: 20px;
font-size: 1.8em;
border-bottom: 3px solid #3498db;
padding-bottom: 10px;
}
.modes-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
margin-top: 20px;
}
.mode-card {
background: white;
border-radius: 15px;
padding: 25px;
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: all 0.3s ease;
border: 3px solid transparent;
position: relative;
overflow: hidden;
}
.mode-card::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, #3498db, #2ecc71);
transform: scaleX(0);
transition: transform 0.3s ease;
}
.mode-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}