feat: Add aggregated endpoint for CodexLens dashboard initialization and improve loading performance

This commit is contained in:
catlog22
2025-12-25 17:22:42 +08:00
parent c5f379ba01
commit 777d5df573
2 changed files with 110 additions and 21 deletions

View File

@@ -129,6 +129,54 @@ async function loadCodexLensStatus() {
}
}
/**
* Load CodexLens dashboard data using aggregated endpoint (single API call)
* This is optimized for the CodexLens Manager page initialization
* @returns {Promise<object|null>} Dashboard init data or null on error
*/
async function loadCodexLensDashboardInit() {
try {
const response = await fetch('/api/codexlens/dashboard-init');
if (!response.ok) throw new Error('Failed to load CodexLens dashboard init');
const data = await response.json();
// Update status variables from aggregated response
codexLensStatus = data.status || { ready: false };
semanticStatus = data.semantic || { available: false };
// Expose to window for other modules
if (!window.cliToolsStatus) {
window.cliToolsStatus = {};
}
window.cliToolsStatus.codexlens = {
installed: data.installed || false,
version: data.status?.version || null,
installedModels: [],
config: data.config || {},
semantic: data.semantic || {}
};
// Store config globally for easy access
window.codexLensConfig = data.config || {};
window.codexLensStatusData = data.statusData || {};
// Update badges
updateCodexLensBadge();
console.log('[CLI Status] CodexLens dashboard init loaded:', {
installed: data.installed,
version: data.status?.version,
semanticAvailable: data.semantic?.available
});
return data;
} catch (err) {
console.error('Failed to load CodexLens dashboard init:', err);
// Fallback to individual calls
return await loadCodexLensStatus();
}
}
/**
* Legacy: Load semantic status individually
*/