Fix MCP server status parsing to match API response

- Map server status values correctly: connected -> running, disabled -> stopped, failed -> error
- Remove array parsing logic as API returns Record<string, status>
- Fixes incorrect MCP server status display in instance welcome view
This commit is contained in:
Shantur Rathore
2025-10-24 18:41:26 +01:00
parent 2c9a29ebc4
commit 24237c25b9

View File

@@ -182,19 +182,23 @@ const InstanceWelcomeView: Component<InstanceWelcomeViewProps> = (props) => {
if (!status || typeof status !== "object") return [] if (!status || typeof status !== "object") return []
try { try {
if (Array.isArray(status)) { const obj = status as Record<string, string>
return status.map((s) => ({ return Object.entries(obj).map(([name, statusValue]) => {
name: s.name || "Unknown", let mappedStatus: "running" | "stopped" | "error"
status: s.status || "stopped",
})) if (statusValue === "connected") {
} mappedStatus = "running"
} else if (statusValue === "disabled") {
mappedStatus = "stopped"
} else if (statusValue === "failed") {
mappedStatus = "error"
} else {
mappedStatus = "stopped"
}
const obj = status as Record<string, unknown>
return Object.entries(obj).map(([name, data]) => {
const serverData = data as { status?: string }
return { return {
name, name,
status: (serverData?.status as "running" | "stopped" | "error") || "stopped", status: mappedStatus,
} }
}) })
} catch { } catch {