useIdeConnectionStatus.ts
hooks/useIdeConnectionStatus.ts
No strong subsystem tag
34
Lines
981
Bytes
2
Exports
2
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 34 lines, 2 detected imports, and 2 detected exports.
Important relationships
Detected exports
IdeStatususeIdeConnectionStatus
Keywords
idenameconfigstatusideclientconnectedpendingmcpclientsusememomcpserverconnectionidestatus
Detected imports
react../services/mcp/types.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { useMemo } from 'react'
import type { MCPServerConnection } from '../services/mcp/types.js'
export type IdeStatus = 'connected' | 'disconnected' | 'pending' | null
type IdeConnectionResult = {
status: IdeStatus
ideName: string | null
}
export function useIdeConnectionStatus(
mcpClients?: MCPServerConnection[],
): IdeConnectionResult {
return useMemo(() => {
const ideClient = mcpClients?.find(client => client.name === 'ide')
if (!ideClient) {
return { status: null, ideName: null }
}
// Extract IDE name from config if available
const config = ideClient.config
const ideName =
config.type === 'sse-ide' || config.type === 'ws-ide'
? config.ideName
: null
if (ideClient.type === 'connected') {
return { status: 'connected', ideName }
}
if (ideClient.type === 'pending') {
return { status: 'pending', ideName }
}
return { status: 'disconnected', ideName }
}, [mcpClients])
}