Skip to content

Commit d69452f

Browse files
committed
fix: refactor getStatusColorClass to simplify status color handling
1 parent 8120b84 commit d69452f

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

webview-ui/src/components/chat/IndexingStatusBadge.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ export const IndexingStatusDot: React.FC<IndexingStatusDotProps> = ({ onNavigate
8484
handleMouseLeave()
8585
}
8686

87+
// Get status color classes based on status and hover state
88+
const getStatusColorClass = () => {
89+
const statusColors = {
90+
Standby: {
91+
default: "bg-vscode-descriptionForeground/40",
92+
hover: "bg-vscode-descriptionForeground/60",
93+
},
94+
Indexing: {
95+
default: "bg-yellow-500/40 animate-pulse",
96+
hover: "bg-yellow-500 animate-pulse",
97+
},
98+
Indexed: {
99+
default: "bg-green-500/40",
100+
hover: "bg-green-500",
101+
},
102+
Error: {
103+
default: "bg-red-500/40",
104+
hover: "bg-red-500",
105+
},
106+
}
107+
108+
const colors = statusColors[indexingStatus.systemStatus as keyof typeof statusColors] || statusColors.Standby
109+
return isHovered ? colors.hover : colors.default
110+
}
111+
87112
return (
88113
<div className={cn("relative inline-block", className)}>
89114
<button
@@ -101,13 +126,7 @@ export const IndexingStatusDot: React.FC<IndexingStatusDotProps> = ({ onNavigate
101126
<span
102127
className={cn(
103128
"inline-block w-2 h-2 rounded-full relative z-10 transition-colors duration-200",
104-
// Default state - always show muted color
105-
!isHovered && "bg-vscode-descriptionForeground/60",
106-
// Hover states - show status colors
107-
isHovered && indexingStatus.systemStatus === "Standby" && "bg-vscode-descriptionForeground/60",
108-
isHovered && indexingStatus.systemStatus === "Indexing" && "bg-yellow-500 animate-pulse",
109-
isHovered && indexingStatus.systemStatus === "Indexed" && "bg-green-500",
110-
isHovered && indexingStatus.systemStatus === "Error" && "bg-red-500",
129+
getStatusColorClass(),
111130
)}
112131
/>
113132
</button>

0 commit comments

Comments
 (0)