mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-17 07:50:59 +00:00
fix(web): show correct MCP server runtime status in sidebar dots
Use runtime_info.status from the API instead of only checking the enable flag. Dots now show: green (connected), yellow (connecting), red (error), gray (disabled or no status).
This commit is contained in:
@@ -204,6 +204,21 @@ function sortByRecent(items: SidebarEntityItem[]): SidebarEntityItem[] {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MCP status dot color: disabled → gray, error → red, connecting → yellow, connected → green
|
||||||
|
function mcpStatusColor(item: SidebarEntityItem): string {
|
||||||
|
if (item.enabled === false) return 'bg-muted-foreground/40';
|
||||||
|
switch (item.runtimeStatus) {
|
||||||
|
case 'connected':
|
||||||
|
return 'bg-green-500';
|
||||||
|
case 'connecting':
|
||||||
|
return 'bg-yellow-500';
|
||||||
|
case 'error':
|
||||||
|
return 'bg-red-500';
|
||||||
|
default:
|
||||||
|
return 'bg-muted-foreground/40';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Plugin operation type enum
|
// Plugin operation type enum
|
||||||
enum PluginOperationType {
|
enum PluginOperationType {
|
||||||
DELETE = 'DELETE',
|
DELETE = 'DELETE',
|
||||||
@@ -412,9 +427,11 @@ function NavItems({
|
|||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-popover',
|
'absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-popover',
|
||||||
item.enabled === false
|
isMCP
|
||||||
? 'bg-muted-foreground/40'
|
? mcpStatusColor(item)
|
||||||
: 'bg-green-500',
|
: item.enabled === false
|
||||||
|
? 'bg-muted-foreground/40'
|
||||||
|
: 'bg-green-500',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -423,9 +440,7 @@ function NavItems({
|
|||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'size-2 shrink-0 rounded-full',
|
'size-2 shrink-0 rounded-full',
|
||||||
item.enabled === false
|
mcpStatusColor(item),
|
||||||
? 'bg-muted-foreground/40'
|
|
||||||
: 'bg-green-500',
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -468,9 +483,11 @@ function NavItems({
|
|||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-sidebar',
|
'absolute -bottom-0.5 -right-0.5 size-2 rounded-full border-2 border-sidebar',
|
||||||
item.enabled === false
|
isMCP
|
||||||
? 'bg-muted-foreground/40'
|
? mcpStatusColor(item)
|
||||||
: 'bg-green-500',
|
: item.enabled === false
|
||||||
|
? 'bg-muted-foreground/40'
|
||||||
|
: 'bg-green-500',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -479,9 +496,7 @@ function NavItems({
|
|||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'size-2 shrink-0 rounded-full',
|
'size-2 shrink-0 rounded-full',
|
||||||
item.enabled === false
|
mcpStatusColor(item),
|
||||||
? 'bg-muted-foreground/40'
|
|
||||||
: 'bg-green-500',
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ export interface SidebarEntityItem {
|
|||||||
updatedAt?: string; // ISO timestamp for sorting by most recently edited
|
updatedAt?: string; // ISO timestamp for sorting by most recently edited
|
||||||
// Bot-specific fields
|
// Bot-specific fields
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
// MCP-specific fields
|
||||||
|
runtimeStatus?: 'connecting' | 'connected' | 'error';
|
||||||
// Plugin-specific fields
|
// Plugin-specific fields
|
||||||
installSource?: string;
|
installSource?: string;
|
||||||
installInfo?: Record<string, unknown>;
|
installInfo?: Record<string, unknown>;
|
||||||
@@ -169,6 +171,7 @@ export function SidebarDataProvider({
|
|||||||
id: server.name,
|
id: server.name,
|
||||||
name: server.name,
|
name: server.name,
|
||||||
enabled: server.enable,
|
enabled: server.enable,
|
||||||
|
runtimeStatus: server.runtime_info?.status,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user