From ecaa0115020594b81e002cd563185f8f74625043 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 12 Jan 2026 22:22:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=20CLI=20=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AE=A1=E7=90=86=EF=BC=8C=E6=94=AF=E6=8C=81=E4=BB=8E?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=84=E5=8A=A0=E8=BD=BD=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routes/codexlens/semantic-handlers.ts | 2 +- .../dashboard-js/components/cli-status.js | 32 +++++++++++++++++++ ccw/src/templates/dashboard-js/main.js | 13 ++++++-- .../dashboard-js/views/cli-manager.js | 2 +- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ccw/src/core/routes/codexlens/semantic-handlers.ts b/ccw/src/core/routes/codexlens/semantic-handlers.ts index bd1f7852..ddd03948 100644 --- a/ccw/src/core/routes/codexlens/semantic-handlers.ts +++ b/ccw/src/core/routes/codexlens/semantic-handlers.ts @@ -414,7 +414,7 @@ export async function handleCodexLensSemanticRoutes(ctx: RouteContext): Promise< // Special handling for litellm backend - auto-configure from litellm-api-config if (resolvedBackend === 'litellm' && (resolvedModelName || resolvedLiteLLMEndpoint)) { - const selectedModel = resolvedModelName || resolvedLiteLLMEndpoint; + const selectedModel = (resolvedModelName || resolvedLiteLLMEndpoint) as string; // Find the provider that has this model const providers = getAllProviders(initialPath); diff --git a/ccw/src/templates/dashboard-js/components/cli-status.js b/ccw/src/templates/dashboard-js/components/cli-status.js index 549db6ee..42c02cb2 100644 --- a/ccw/src/templates/dashboard-js/components/cli-status.js +++ b/ccw/src/templates/dashboard-js/components/cli-status.js @@ -33,11 +33,43 @@ function initCliStatus() { * Load all statuses using aggregated endpoint (single API call) */ async function loadAllStatuses() { + // 1. 尝试从缓存获取(预加载的数据) + if (window.cacheManager) { + const cached = window.cacheManager.get('all-status'); + if (cached) { + console.log('[CLI Status] Loaded all statuses from cache'); + // 应用缓存数据 + cliToolStatus = cached.cli || {}; + codexLensStatus = cached.codexLens || { ready: false }; + semanticStatus = cached.semantic || { available: false }; + ccwInstallStatus = cached.ccwInstall || { installed: true, workflowsInstalled: true, missingFiles: [], installPath: '' }; + + // Load CLI tools config, API endpoints, and CLI Settings(这些有自己的缓存) + await Promise.all([ + loadCliToolsConfig(), + loadApiEndpoints(), + loadCliSettingsEndpoints() + ]); + + // Update badges + updateCliBadge(); + updateCodexLensBadge(); + updateCcwInstallBadge(); + return cached; + } + } + + // 2. 缓存未命中,从服务器获取 try { const response = await fetch('/api/status/all'); if (!response.ok) throw new Error('Failed to load status'); const data = await response.json(); + // 存入缓存 + if (window.cacheManager) { + window.cacheManager.set('all-status', data, 300000); // 5分钟 + } + // Update all status data - merge with config tools to ensure all tools are tracked cliToolStatus = data.cli || {}; codexLensStatus = data.codexLens || { ready: false }; diff --git a/ccw/src/templates/dashboard-js/main.js b/ccw/src/templates/dashboard-js/main.js index b830714a..faf8c6e1 100644 --- a/ccw/src/templates/dashboard-js/main.js +++ b/ccw/src/templates/dashboard-js/main.js @@ -105,20 +105,29 @@ function initPreloadServices() { window.preloadService = new PreloadService(window.cacheManager, window.eventManager); // 注册高优先级数据源(页面进入时立即预加载) + + // 聚合状态接口 - 最高优先级(cli-status.js 的 loadAllStatuses 使用) + window.preloadService.register('all-status', + () => fetch('/api/status/all').then(r => r.ok ? r.json() : Promise.reject(r)), + { isHighPriority: true, ttl: 300000 } // 5分钟 + ); + window.preloadService.register('dashboard-init', () => fetch('/api/codexlens/dashboard-init').then(r => r.ok ? r.json() : Promise.reject(r)), { isHighPriority: true, ttl: 300000 } // 5分钟 ); + // workspace-status: NOT high priority - must wait for projectPath to be set via switchToPath() + // Will be triggered by codexlens-manager.js when the view loads window.preloadService.register('workspace-status', () => { const path = encodeURIComponent(projectPath || ''); return fetch('/api/codexlens/workspace-status?path=' + path).then(r => r.ok ? r.json() : Promise.reject(r)); }, - { isHighPriority: true, ttl: 120000 } // 2分钟 + { isHighPriority: false, ttl: 120000 } // 2分钟 ); - // CLI 状态 - 高优先级 + // CLI 状态 - 高优先级(备用,用于独立加载) window.preloadService.register('cli-status', () => fetch('/api/cli/status').then(r => r.ok ? r.json() : Promise.reject(r)), { isHighPriority: true, ttl: 300000 } // 5分钟 diff --git a/ccw/src/templates/dashboard-js/views/cli-manager.js b/ccw/src/templates/dashboard-js/views/cli-manager.js index b446e0ab..1f2da100 100644 --- a/ccw/src/templates/dashboard-js/views/cli-manager.js +++ b/ccw/src/templates/dashboard-js/views/cli-manager.js @@ -732,7 +732,7 @@ function initToolConfigModalEvents(tool, currentConfig, models) { function buildCliManagerSkeleton() { return '
' + '
' + - '

' + (t('nav.cliManager') || 'CLI Status') + '

' + + '

' + (t('title.cliTools') || 'CLI Tools & CCW') + '

' + '
' + '
' + // 左侧 Tools 区域骨架