From f878c350e673bf85793e9a9103bae12d154c1952 Mon Sep 17 00:00:00 2001 From: Nicolas Iragne Date: Thu, 21 Aug 2025 18:36:55 +0200 Subject: [PATCH 1/2] test fix unknown msg --- app/templates/components/quick_actions.html | 42 +++++++++++++------ .../components/workspace_actions.html | 42 +++++++++++++------ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/app/templates/components/quick_actions.html b/app/templates/components/quick_actions.html index 7b8be7c..1b5e793 100644 --- a/app/templates/components/quick_actions.html +++ b/app/templates/components/quick_actions.html @@ -173,40 +173,46 @@

// 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 +261,26 @@

// Action functions that use backend data function addAgent(name) { + if (!name || name === 'Unknown') { + console.error('Invalid agent name'); + return; + } createNewContextAndInstallAgent(name); } function addRule(name) { + if (!name || name === 'Unknown') { + console.error('Invalid rule name'); + return; + } createNewContextAndInsertRule(name); } function addMCP(name) { + if (!name || name === 'Unknown') { + console.error('Invalid MCP 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)}`); From c4fdbe30135739fda666ece02ce1ad060f983fa4 Mon Sep 17 00:00:00 2001 From: Nicolas Iragne Date: Thu, 21 Aug 2025 18:43:05 +0200 Subject: [PATCH 2/2] test --- app/static/js/monaco_editor.js | 19 ++++++++++++-- app/templates/base.html | 16 ++++++++++++ app/templates/components/quick_actions.html | 29 ++++++++++++++++++--- 3 files changed, 58 insertions(+), 6 deletions(-) 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 1b5e793..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,10 +188,13 @@

// Render agents (max 4) const agentsContainer = document.getElementById('agents-container'); if (agentsContainer && data.agents) { + console.log('[renderActions] Rendering agents:', data.agents); agentsContainer.innerHTML = data.agents.slice(0, 4).map(agent => { const name = agent.name || 'Unknown'; + console.log('[renderActions] Processing agent:', agent, 'name:', name); + const escapedName = name.replace(/'/g, "\\'").replace(/"/g, '\\"'); return ` -