diff --git a/app/static/js/monaco_editor.js b/app/static/js/monaco_editor.js index 1bab1c7..f453a3f 100644 --- a/app/static/js/monaco_editor.js +++ b/app/static/js/monaco_editor.js @@ -50,16 +50,31 @@ function initializeWorkspaceEditor() { } function insertTextAtCursor(text) { - if (!workspaceMonacoEditor) return; + console.log('[insertTextAtCursor] Called with text:', text); + console.log('[insertTextAtCursor] Type of text:', typeof text); + console.trace('Stack trace for insertTextAtCursor'); + + if (!workspaceMonacoEditor) { + console.error('[insertTextAtCursor] No workspace editor available'); + return; + } + + if (text === 'Unknown' || text === undefined || text === null || text === 'undefined') { + console.error('[insertTextAtCursor] WARNING: Attempting to insert problematic text:', text); + console.trace('Stack trace for problematic insertion'); + // Block insertion of "Unknown" + return; + } const selection = workspaceMonacoEditor.getSelection(); const position = selection.getStartPosition(); + console.log('[insertTextAtCursor] Executing edit at position:', position); workspaceMonacoEditor.executeEdits('quickaction-insert', [{ range: new monaco.Range(position.lineNumber, position.column, position.lineNumber, position.column), text: text }]); - console.log("Inserted text:", text); + console.log("[insertTextAtCursor] Successfully inserted text:", text); // Move cursor to end of inserted text const newPosition = new monaco.Position(position.lineNumber, position.column + text.length); diff --git a/app/templates/base.html b/app/templates/base.html index 8daa445..187cf8c 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -26,6 +26,22 @@ {% include 'components/styles.html' %} + {% include 'components/navbar.html' %}
diff --git a/app/templates/components/quick_actions.html b/app/templates/components/quick_actions.html index 7b8be7c..2f49e2b 100644 --- a/app/templates/components/quick_actions.html +++ b/app/templates/components/quick_actions.html @@ -139,6 +139,21 @@

workspaceSection.style.transition = 'opacity 300ms ease-in-out'; } + // Debug: Global click logger to catch ALL clicks + document.addEventListener('click', function(e) { + const target = e.target; + const button = target.closest('button'); + if (button) { + console.log('[GLOBAL CLICK DEBUG] Button clicked:', { + button: button, + onclick: button.getAttribute('onclick'), + classes: button.className, + text: button.textContent.trim(), + target: target + }); + } + }, true); // Use capture phase to get it early + // Load actions from backend loadActionsFromBackend(); }); @@ -173,40 +188,49 @@

// Render agents (max 4) const agentsContainer = document.getElementById('agents-container'); if (agentsContainer && data.agents) { - agentsContainer.innerHTML = data.agents.slice(0, 4).map(agent => ` - - `).join(''); + `}).join(''); } // Render MCPs (max 4) const mcpsContainer = document.getElementById('mcps-container'); if (mcpsContainer && data.mcps) { - mcpsContainer.innerHTML = data.mcps.slice(0, 4).map(mcp => ` - - `).join(''); + `}).join(''); } // Render rules (max 4) const rulesContainer = document.getElementById('rules-container'); if (rulesContainer && data.rules) { - rulesContainer.innerHTML = data.rules.slice(0, 4).map(rule => ` - - `).join(''); + `}).join(''); } } catch (error) { console.error('Error loading actions:', error); @@ -255,14 +279,29 @@

// Action functions that use backend data function addAgent(name) { + console.log('[addAgent] Called with name:', name); + if (!name || name === 'Unknown') { + console.error('[addAgent] Invalid agent name:', name); + return; + } createNewContextAndInstallAgent(name); } function addRule(name) { + console.log('[addRule] Called with name:', name); + if (!name || name === 'Unknown') { + console.error('[addRule] Invalid rule name:', name); + return; + } createNewContextAndInsertRule(name); } function addMCP(name) { + console.log('[addMCP] Called with name:', name); + if (!name || name === 'Unknown') { + console.error('[addMCP] Invalid MCP name:', name); + return; + } createNewContextAndInstallMCP(name); } diff --git a/app/templates/components/workspace_actions.html b/app/templates/components/workspace_actions.html index 3fe18a8..4774f57 100644 --- a/app/templates/components/workspace_actions.html +++ b/app/templates/components/workspace_actions.html @@ -262,34 +262,40 @@

Quick Actions

// Render MCPs const mcpsContainer = document.getElementById('sidebar-mcps-container'); if (mcpsContainer && data.mcps) { - mcpsContainer.innerHTML = data.mcps.map(mcp => ` - - `).join(''); + `}).join(''); } // Render rules const rulesContainer = document.getElementById('sidebar-rules-container'); if (rulesContainer && data.rules) { - rulesContainer.innerHTML = data.rules.map(rule => ` - - `).join(''); + `}).join(''); } // Render agents const agentsContainer = document.getElementById('sidebar-agents-container'); if (agentsContainer && data.agents) { - agentsContainer.innerHTML = data.agents.map(agent => ` - - `).join(''); + `}).join(''); } } catch (error) { console.error('Error loading sidebar actions:', error); @@ -298,6 +304,10 @@

Quick Actions

// Install functions async function installAgent(agentName) { + if (!agentName || agentName === 'Unknown') { + console.error('Invalid agent name'); + return; + } try { const response = await fetch(`/api/actions/agent-content/${encodeURIComponent(agentName)}`); @@ -320,6 +330,10 @@

Quick Actions

} async function installMCP(mcpName) { + if (!mcpName || mcpName === 'Unknown') { + console.error('Invalid MCP name'); + return; + } try { // Get current .mcp.json content from workspace let currentConfig = {}; @@ -361,6 +375,10 @@

Quick Actions

} async function installRule(ruleName) { + if (!ruleName || ruleName === 'Unknown') { + console.error('Invalid rule name'); + return; + } try { const response = await fetch(`/api/actions/rule-content/${encodeURIComponent(ruleName)}`);