Skip to content

Commit 9bdfeba

Browse files
committed
feat: enhance MCP server status handling with session phase integration
- Added `sessionPhase` prop to `McpServersAccordion` to conditionally fetch MCP status based on the session's running state. - Updated status display logic to improve user experience by showing placeholders only when the session is not running or when MCP status is pending. - Enhanced visual elements in the MCP servers accordion for better clarity and usability. This update aims to provide more accurate status information and improve the overall functionality of the MCP server integration.
1 parent 79c8e78 commit 9bdfeba

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

components/frontend/src/app/projects/[name]/sessions/[sessionName]/components/accordions/mcp-integrations-accordion.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,33 @@ import type { McpServer, McpTool } from '@/services/api/sessions'
3030
type McpServersAccordionProps = {
3131
projectName: string
3232
sessionName: string
33+
sessionPhase?: string
3334
}
3435

3536
export function McpServersAccordion({
3637
projectName,
3738
sessionName,
39+
sessionPhase,
3840
}: McpServersAccordionProps) {
3941
const [placeholderTimedOut, setPlaceholderTimedOut] = useState(false)
4042

41-
const { data: mcpStatus, isPending: mcpPending } = useMcpStatus(projectName, sessionName)
43+
// Only fetch MCP status once the session is actually running (runner pod ready)
44+
const isRunning = sessionPhase === 'Running'
45+
const { data: mcpStatus, isPending: mcpPending } = useMcpStatus(projectName, sessionName, isRunning)
4246
const mcpServers = mcpStatus?.servers || []
4347

4448
const showPlaceholders =
45-
mcpPending || (mcpServers.length === 0 && !placeholderTimedOut)
49+
!isRunning || mcpPending || (mcpServers.length === 0 && !placeholderTimedOut)
4650

4751
useEffect(() => {
4852
if (mcpServers.length > 0) {
4953
setPlaceholderTimedOut(false)
5054
return
5155
}
52-
if (!mcpStatus) return
56+
if (!isRunning || !mcpStatus) return
5357
const t = setTimeout(() => setPlaceholderTimedOut(true), 15 * 1000)
5458
return () => clearTimeout(t)
55-
}, [mcpStatus, mcpServers.length])
59+
}, [mcpStatus, mcpServers.length, isRunning])
5660

5761
const getStatusIcon = (server: McpServer) => {
5862
switch (server.status) {
@@ -132,8 +136,8 @@ export function McpServersAccordion({
132136
([, v]) => typeof v === 'boolean'
133137
)
134138
return (
135-
<div key={tool.name} className="flex items-center justify-between gap-2 py-1.5 px-1">
136-
<span className="text-xs font-mono truncate">{tool.name}</span>
139+
<div key={tool.name} className="flex items-center justify-between gap-3 px-3 py-2">
140+
<code className="text-xs truncate">{tool.name}</code>
137141
{annotations.length > 0 && (
138142
<div className="flex items-center gap-1 flex-shrink-0">
139143
{annotations.map(([k, v]) => renderAnnotationBadge(k, v as boolean))}
@@ -158,6 +162,8 @@ export function McpServersAccordion({
158162
{getStatusIcon(server)}
159163
</div>
160164
<h4 className="font-medium text-sm">{server.displayName}</h4>
165+
</div>
166+
<div className="flex items-center gap-2 mt-1 ml-6">
161167
{server.version && (
162168
<span className="text-[10px] text-muted-foreground">v{server.version}</span>
163169
)}
@@ -176,12 +182,12 @@ export function McpServersAccordion({
176182
align="start"
177183
className="w-80 p-0"
178184
>
179-
<div className="px-3 py-2 border-b">
185+
<div className="px-3 py-2.5 border-b bg-muted/30">
180186
<p className="text-xs font-medium">
181187
{server.displayName}{toolCount} {toolCount === 1 ? 'tool' : 'tools'}
182188
</p>
183189
</div>
184-
<div className="max-h-64 overflow-y-auto divide-y">
190+
<div className="max-h-72 overflow-y-auto">
185191
{tools.map((tool) => renderToolRow(tool))}
186192
</div>
187193
</PopoverContent>

components/frontend/src/app/projects/[name]/sessions/[sessionName]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,7 @@ export default function ProjectSessionDetailPage({
16391639
<McpServersAccordion
16401640
projectName={projectName}
16411641
sessionName={sessionName}
1642+
sessionPhase={phase}
16421643
/>
16431644

16441645
<IntegrationsAccordion />

0 commit comments

Comments
 (0)