Skip to content

Commit 3d87695

Browse files
committed
test cache api calls
1 parent fcf72fc commit 3d87695

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

app/static/js/monaco_editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function updateWorkspaceEditor(tabId) {
123123
if (config) {
124124
workspaceMonacoEditor.setValue(config.content);
125125
monaco.editor.setModelLanguage(workspaceMonacoEditor.getModel(), config.language);
126+
console.log("Updated workspace editor:", config.content);
126127
const languageSelect = document.getElementById('workspace-language-select');
127128
if (languageSelect) {
128129
languageSelect.value = config.language;

app/templates/components/quick_actions.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ <h3 class="text-sm font-black text-black mb-2 flex items-center gap-1">
128128
// Global state
129129
let isWorkspaceVisible = false;
130130

131+
// Cache for actions data
132+
let actionsCache = null;
133+
131134
// Initialize on page load
132135
document.addEventListener('DOMContentLoaded', function() {
133136
const workspaceSection = document.querySelector('.workspace-container');
@@ -143,11 +146,30 @@ <h3 class="text-sm font-black text-black mb-2 flex items-center gap-1">
143146
// Fetch and display actions from backend API
144147
async function loadActionsFromBackend() {
145148
try {
149+
// Use cached data if available
150+
if (actionsCache) {
151+
renderActions(actionsCache);
152+
return;
153+
}
154+
146155
const response = await fetch('/api/actions/');
147156
if (!response.ok) throw new Error('Failed to fetch actions');
148157

149158
const data = await response.json();
150159

160+
// Cache the data
161+
actionsCache = data;
162+
163+
renderActions(data);
164+
} catch (error) {
165+
console.error('Error loading actions:', error);
166+
}
167+
}
168+
169+
// Render actions from data
170+
function renderActions(data) {
171+
try {
172+
151173
// Render agents (max 4)
152174
const agentsContainer = document.getElementById('agents-container');
153175
if (agentsContainer && data.agents) {

app/templates/components/workspace_actions.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,36 @@ <h3 class="text-lg font-black text-black mb-3">Quick Actions</h3>
229229
}
230230
}
231231

232+
// Cache for sidebar actions data
233+
let sidebarActionsCache = null;
234+
232235
// Load sidebar actions from backend
233236
async function loadSidebarActions() {
234237
try {
238+
// Use cached data if available
239+
if (sidebarActionsCache) {
240+
renderSidebarActions(sidebarActionsCache);
241+
return;
242+
}
243+
235244
const response = await fetch('/api/actions/');
236245
if (!response.ok) throw new Error('Failed to fetch actions');
237246

238247
const data = await response.json();
239248

249+
// Cache the data
250+
sidebarActionsCache = data;
251+
252+
renderSidebarActions(data);
253+
} catch (error) {
254+
console.error('Error loading sidebar actions:', error);
255+
}
256+
}
257+
258+
// Render sidebar actions from data
259+
function renderSidebarActions(data) {
260+
try {
261+
240262
// Render MCPs
241263
const mcpsContainer = document.getElementById('sidebar-mcps-container');
242264
if (mcpsContainer && data.mcps) {

0 commit comments

Comments
 (0)