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
This commit is contained in:
catlog22
2026-02-28 10:00:36 +08:00
parent 4763edb0e4
commit 46989dcbad
5 changed files with 19 additions and 5 deletions

View File

@@ -53,13 +53,18 @@ function QueryInvalidator() {
const registerQueryInvalidator = useWorkflowStore((state) => state.registerQueryInvalidator); const registerQueryInvalidator = useWorkflowStore((state) => state.registerQueryInvalidator);
useEffect(() => { useEffect(() => {
// Register callback to invalidate all 'workspace' prefixed queries // Register callback to invalidate all workspace-related queries on workspace switch
const callback = () => { const callback = () => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
predicate: (query) => { predicate: (query) => {
const queryKey = query.queryKey; const queryKey = query.queryKey;
// Check if the first element of the query key is 'workspace' if (!Array.isArray(queryKey)) return false;
return Array.isArray(queryKey) && queryKey[0] === 'workspace'; const prefix = queryKey[0];
// Invalidate all query families that depend on workspace data
return prefix === 'workspace'
|| prefix === 'projectOverview'
|| prefix === 'workflowStatusCounts'
|| prefix === 'dashboardStats';
}, },
}); });
}; };

View File

@@ -69,6 +69,7 @@ const statusIcons: Record<string, React.ElementType> = {
cancelled: XCircle, cancelled: XCircle,
idle: Clock, idle: Clock,
initializing: Loader2, initializing: Loader2,
ready: CheckCircle2,
}; };
// Status color mapping // Status color mapping
@@ -83,6 +84,7 @@ const statusColors: Record<string, string> = {
cancelled: 'bg-destructive/20 text-destructive border-destructive/30', cancelled: 'bg-destructive/20 text-destructive border-destructive/30',
idle: 'bg-muted text-muted-foreground border-border', idle: 'bg-muted text-muted-foreground border-border',
initializing: 'bg-info/20 text-info border-info/30', initializing: 'bg-info/20 text-info border-info/30',
ready: 'bg-success/20 text-success border-success/30',
}; };
// Status to i18n key mapping // Status to i18n key mapping
@@ -97,6 +99,7 @@ const statusI18nKeys: Record<string, string> = {
cancelled: 'cancelled', cancelled: 'cancelled',
idle: 'idle', idle: 'idle',
initializing: 'initializing', initializing: 'initializing',
ready: 'ready',
}; };
// Lite task sub-type icons // Lite task sub-type icons

View File

@@ -119,6 +119,10 @@ const sessionStatusColors: Record<string, { bg: string; text: string }> = {
in_progress: { bg: 'bg-warning/20', text: 'text-warning' }, in_progress: { bg: 'bg-warning/20', text: 'text-warning' },
completed: { bg: 'bg-success/20', text: 'text-success' }, completed: { bg: 'bg-success/20', text: 'text-success' },
paused: { bg: 'bg-slate-400/20', text: 'text-slate-500' }, 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 ---- // ---- Mini Stat Card with Sparkline ----

View File

@@ -82,7 +82,8 @@
"label": "Status", "label": "Status",
"openIssues": "Open Issues", "openIssues": "Open Issues",
"enabled": "Enabled", "enabled": "Enabled",
"disabled": "Disabled" "disabled": "Disabled",
"ready": "Ready"
}, },
"priority": { "priority": {
"low": "Low", "low": "Low",

View File

@@ -82,7 +82,8 @@
"label": "状态", "label": "状态",
"openIssues": "开放问题", "openIssues": "开放问题",
"enabled": "已启用", "enabled": "已启用",
"disabled": "已禁用" "disabled": "已禁用",
"ready": "就绪"
}, },
"priority": { "priority": {
"low": "低", "low": "低",