Skip to content

Commit c5f379b

Browse files
catlog22claude
andcommitted
fix: Force refresh ccw-litellm status on first page load
- Add isFirstApiSettingsRender flag to track first load - Force refresh ccw-litellm status on first page load - Add ?refresh=true query param support to backend API - Frontend passes refresh param to bypass backend cache - Subsequent tab switches still use cache for performance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 145d38c commit c5f379b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

ccw/src/core/routes/litellm-api-routes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,12 @@ export async function handleLiteLLMApiRoutes(ctx: RouteContext): Promise<boolean
554554
// ===========================
555555

556556
// GET /api/litellm-api/ccw-litellm/status - Check ccw-litellm installation status
557+
// Supports ?refresh=true to bypass cache
557558
if (pathname === '/api/litellm-api/ccw-litellm/status' && req.method === 'GET') {
558-
// Check cache first
559-
if (ccwLitellmStatusCache.data &&
559+
const forceRefresh = url.searchParams.get('refresh') === 'true';
560+
561+
// Check cache first (unless force refresh)
562+
if (!forceRefresh && ccwLitellmStatusCache.data &&
560563
Date.now() - ccwLitellmStatusCache.timestamp < ccwLitellmStatusCache.ttl) {
561564
res.writeHead(200, { 'Content-Type': 'application/json' });
562565
res.end(JSON.stringify(ccwLitellmStatusCache.data));

ccw/src/templates/dashboard-js/views/api-settings.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ let ccwLitellmStatusCache = null;
2323
let ccwLitellmStatusCacheTime = 0;
2424
const CCW_LITELLM_STATUS_CACHE_TTL = 60000; // 60 seconds
2525

26+
// Track if this is the first render (force refresh on first load)
27+
let isFirstApiSettingsRender = true;
28+
2629
// ========== Data Loading ==========
2730

2831
/**
@@ -1036,8 +1039,13 @@ async function renderApiSettings() {
10361039
renderCacheMainPanel();
10371040
}
10381041

1039-
// Check and render ccw-litellm status (use cache by default)
1040-
checkCcwLitellmStatus(false).then(renderCcwLitellmStatusCard);
1042+
// Check and render ccw-litellm status
1043+
// Force refresh on first load, use cache on subsequent renders
1044+
const forceStatusRefresh = isFirstApiSettingsRender;
1045+
if (isFirstApiSettingsRender) {
1046+
isFirstApiSettingsRender = false;
1047+
}
1048+
checkCcwLitellmStatus(forceStatusRefresh).then(renderCcwLitellmStatusCard);
10411049

10421050
if (window.lucide) lucide.createIcons();
10431051
}
@@ -3082,7 +3090,9 @@ async function checkCcwLitellmStatus(forceRefresh = false) {
30823090

30833091
try {
30843092
console.log('[API Settings] Checking ccw-litellm status from server...');
3085-
var response = await fetch('/api/litellm-api/ccw-litellm/status');
3093+
// Add refresh=true to bypass backend cache when forceRefresh is true
3094+
var statusUrl = '/api/litellm-api/ccw-litellm/status' + (forceRefresh ? '?refresh=true' : '');
3095+
var response = await fetch(statusUrl);
30863096
console.log('[API Settings] Status response:', response.status);
30873097
var status = await response.json();
30883098
console.log('[API Settings] ccw-litellm status:', status);

0 commit comments

Comments
 (0)