From 46989dcbadc5d98ada7df824bc7408807dde8059 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 28 Feb 2026 10:00:36 +0800 Subject: [PATCH] fix(frontend): add missing i18n keys and improve workspace switch cache invalidation - Add common.status.ready i18n key for zh/en locales - Add ready/initialized/archived/failed status colors to dashboard widgets - Expand QueryInvalidator to invalidate projectOverview, workflowStatusCounts, and dashboardStats queries on workspace switch --- ccw/frontend/src/App.tsx | 11 ++++++++--- .../dashboard/widgets/RecentSessionsWidget.tsx | 3 +++ .../dashboard/widgets/WorkflowTaskWidget.tsx | 4 ++++ ccw/frontend/src/locales/en/common.json | 3 ++- ccw/frontend/src/locales/zh/common.json | 3 ++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ccw/frontend/src/App.tsx b/ccw/frontend/src/App.tsx index 6ea8f6ab..e20283ab 100644 --- a/ccw/frontend/src/App.tsx +++ b/ccw/frontend/src/App.tsx @@ -53,13 +53,18 @@ function QueryInvalidator() { const registerQueryInvalidator = useWorkflowStore((state) => state.registerQueryInvalidator); useEffect(() => { - // Register callback to invalidate all 'workspace' prefixed queries + // Register callback to invalidate all workspace-related queries on workspace switch const callback = () => { queryClient.invalidateQueries({ predicate: (query) => { const queryKey = query.queryKey; - // Check if the first element of the query key is 'workspace' - return Array.isArray(queryKey) && queryKey[0] === 'workspace'; + if (!Array.isArray(queryKey)) return false; + const prefix = queryKey[0]; + // Invalidate all query families that depend on workspace data + return prefix === 'workspace' + || prefix === 'projectOverview' + || prefix === 'workflowStatusCounts' + || prefix === 'dashboardStats'; }, }); }; diff --git a/ccw/frontend/src/components/dashboard/widgets/RecentSessionsWidget.tsx b/ccw/frontend/src/components/dashboard/widgets/RecentSessionsWidget.tsx index f5d128c4..3854d2ce 100644 --- a/ccw/frontend/src/components/dashboard/widgets/RecentSessionsWidget.tsx +++ b/ccw/frontend/src/components/dashboard/widgets/RecentSessionsWidget.tsx @@ -69,6 +69,7 @@ const statusIcons: Record = { cancelled: XCircle, idle: Clock, initializing: Loader2, + ready: CheckCircle2, }; // Status color mapping @@ -83,6 +84,7 @@ const statusColors: Record = { cancelled: 'bg-destructive/20 text-destructive border-destructive/30', idle: 'bg-muted text-muted-foreground border-border', initializing: 'bg-info/20 text-info border-info/30', + ready: 'bg-success/20 text-success border-success/30', }; // Status to i18n key mapping @@ -97,6 +99,7 @@ const statusI18nKeys: Record = { cancelled: 'cancelled', idle: 'idle', initializing: 'initializing', + ready: 'ready', }; // Lite task sub-type icons diff --git a/ccw/frontend/src/components/dashboard/widgets/WorkflowTaskWidget.tsx b/ccw/frontend/src/components/dashboard/widgets/WorkflowTaskWidget.tsx index 97ea9e73..685b6ccd 100644 --- a/ccw/frontend/src/components/dashboard/widgets/WorkflowTaskWidget.tsx +++ b/ccw/frontend/src/components/dashboard/widgets/WorkflowTaskWidget.tsx @@ -119,6 +119,10 @@ const sessionStatusColors: Record = { in_progress: { bg: 'bg-warning/20', text: 'text-warning' }, completed: { bg: 'bg-success/20', text: 'text-success' }, paused: { bg: 'bg-slate-400/20', text: 'text-slate-500' }, + ready: { bg: 'bg-success/20', text: 'text-success' }, + initialized: { bg: 'bg-info/20', text: 'text-info' }, + archived: { bg: 'bg-slate-300/20', text: 'text-slate-400' }, + failed: { bg: 'bg-destructive/20', text: 'text-destructive' }, }; // ---- Mini Stat Card with Sparkline ---- diff --git a/ccw/frontend/src/locales/en/common.json b/ccw/frontend/src/locales/en/common.json index 4dea4416..4fe2b106 100644 --- a/ccw/frontend/src/locales/en/common.json +++ b/ccw/frontend/src/locales/en/common.json @@ -82,7 +82,8 @@ "label": "Status", "openIssues": "Open Issues", "enabled": "Enabled", - "disabled": "Disabled" + "disabled": "Disabled", + "ready": "Ready" }, "priority": { "low": "Low", diff --git a/ccw/frontend/src/locales/zh/common.json b/ccw/frontend/src/locales/zh/common.json index 3bfdca34..dffe0a75 100644 --- a/ccw/frontend/src/locales/zh/common.json +++ b/ccw/frontend/src/locales/zh/common.json @@ -82,7 +82,8 @@ "label": "状态", "openIssues": "开放问题", "enabled": "已启用", - "disabled": "已禁用" + "disabled": "已禁用", + "ready": "就绪" }, "priority": { "low": "低",