Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit f869d50

Browse files
committed
fix: fix dark mode
1 parent c188144 commit f869d50

7 files changed

Lines changed: 345 additions & 81 deletions

File tree

packages/inspector/src/client/components/CommandPalette.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,37 @@ export function CommandPalette({
9797
name: tool.name,
9898
description: tool.description,
9999
type: 'tool' as const,
100-
category: 'Tools',
101-
metadata: tool.inputSchema,
100+
category: (tool as any)._serverName ? `Tools - ${(tool as any)._serverName}` : 'Tools',
101+
metadata: {
102+
inputSchema: tool.inputSchema,
103+
serverId: (tool as any)._serverId,
104+
serverName: (tool as any)._serverName,
105+
},
102106
})),
103107
...prompts.map(prompt => ({
104108
id: `prompt-${prompt.name}`,
105109
name: prompt.name,
106110
description: prompt.description,
107111
type: 'prompt' as const,
108-
category: 'Prompts',
109-
metadata: prompt.arguments,
112+
category: (prompt as any)._serverName ? `Prompts - ${(prompt as any)._serverName}` : 'Prompts',
113+
metadata: {
114+
arguments: prompt.arguments,
115+
serverId: (prompt as any)._serverId,
116+
serverName: (prompt as any)._serverName,
117+
},
110118
})),
111119
...resources.map(resource => ({
112120
id: `resource-${resource.uri}`,
113121
name: resource.name,
114122
description: resource.description,
115123
type: 'resource' as const,
116-
category: 'Resources',
117-
metadata: { uri: resource.uri, mimeType: resource.mimeType },
124+
category: (resource as any)._serverName ? `Resources - ${(resource as any)._serverName}` : 'Resources',
125+
metadata: {
126+
uri: resource.uri,
127+
mimeType: resource.mimeType,
128+
serverId: (resource as any)._serverId,
129+
serverName: (resource as any)._serverName,
130+
},
118131
})),
119132
]
120133

@@ -131,6 +144,10 @@ export function CommandPalette({
131144
}
132145
}
133146
else {
147+
// If the item belongs to a specific server, switch to that server first
148+
if (item.metadata?.serverId) {
149+
onServerSelect(item.metadata.serverId)
150+
}
134151
onNavigate(item.type as 'tools' | 'prompts' | 'resources', item.name)
135152
onOpenChange(false)
136153
}
@@ -161,12 +178,12 @@ export function CommandPalette({
161178
}
162179

163180
const getMetadataPreview = (item: CommandItem) => {
164-
if (item.type === 'tool' && item.metadata?.properties) {
165-
const props = Object.keys(item.metadata.properties)
181+
if (item.type === 'tool' && item.metadata?.inputSchema?.properties) {
182+
const props = Object.keys(item.metadata.inputSchema.properties)
166183
return props.length > 0 ? `${props.length} parameter${props.length > 1 ? 's' : ''}` : 'No parameters'
167184
}
168-
if (item.type === 'prompt' && item.metadata) {
169-
const args = Object.keys(item.metadata)
185+
if (item.type === 'prompt' && item.metadata?.arguments) {
186+
const args = Object.keys(item.metadata.arguments)
170187
return args.length > 0 ? `${args.length} argument${args.length > 1 ? 's' : ''}` : 'No arguments'
171188
}
172189
if (item.type === 'resource' && item.metadata?.mimeType) {

packages/inspector/src/client/components/Layout.tsx

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ export function Layout({ children }: LayoutProps) {
121121

122122
const selectedServer = connections.find(c => c.id === selectedServerId)
123123

124+
// Aggregate tools, prompts, and resources from all connected servers
125+
// When a server is selected, use only that server's items
126+
// When no server is selected, aggregate from all ready servers and add server metadata
127+
const aggregatedTools = selectedServer
128+
? selectedServer.tools.map(tool => ({ ...tool, _serverId: selectedServer.id }))
129+
: connections.flatMap(conn =>
130+
conn.state === 'ready'
131+
? conn.tools.map(tool => ({ ...tool, _serverId: conn.id, _serverName: conn.name }))
132+
: [],
133+
)
134+
135+
const aggregatedPrompts = selectedServer
136+
? selectedServer.prompts.map(prompt => ({ ...prompt, _serverId: selectedServer.id }))
137+
: connections.flatMap(conn =>
138+
conn.state === 'ready'
139+
? conn.prompts.map(prompt => ({ ...prompt, _serverId: conn.id, _serverName: conn.name }))
140+
: [],
141+
)
142+
143+
const aggregatedResources = selectedServer
144+
? selectedServer.resources.map(resource => ({ ...resource, _serverId: selectedServer.id }))
145+
: connections.flatMap(conn =>
146+
conn.state === 'ready'
147+
? conn.resources.map(resource => ({ ...resource, _serverId: conn.id, _serverName: conn.name }))
148+
: [],
149+
)
150+
124151
// Load config and auto-connect if URL is provided
125152
useEffect(() => {
126153
if (configLoaded)
@@ -162,10 +189,15 @@ export function Layout({ children }: LayoutProps) {
162189

163190
// If no server is selected and we're on a server route, navigate to root
164191
useEffect(() => {
165-
if (!selectedServer && location.pathname.startsWith('/servers/')) {
192+
const serverIdFromRoute = location.pathname.split('/servers/')[1]
193+
const decodedServerId = serverIdFromRoute ? decodeURIComponent(serverIdFromRoute) : null
194+
195+
// Only navigate away if we've already set selectedServerId from the route
196+
// and the server still wasn't found in connections
197+
if (!selectedServer && location.pathname.startsWith('/servers/') && selectedServerId === decodedServerId) {
166198
navigate('/')
167199
}
168-
}, [selectedServer, location.pathname, navigate])
200+
}, [selectedServer, location.pathname, navigate, selectedServerId])
169201

170202
// Handle keyboard shortcuts
171203
useEffect(() => {
@@ -374,9 +406,9 @@ export function Layout({ children }: LayoutProps) {
374406
<CommandPalette
375407
isOpen={isCommandPaletteOpen}
376408
onOpenChange={setIsCommandPaletteOpen}
377-
tools={selectedServer?.tools || []}
378-
prompts={selectedServer?.prompts || []}
379-
resources={selectedServer?.resources || []}
409+
tools={aggregatedTools}
410+
prompts={aggregatedPrompts}
411+
resources={aggregatedResources}
380412
connections={connections}
381413
onNavigate={handleCommandPaletteNavigate}
382414
onServerSelect={handleServerSelect}

packages/inspector/src/client/components/PromptsTab.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Prompt } from '@modelcontextprotocol/sdk/types.js'
22
import { Check, Copy, MessageSquare, Play, Search } from 'lucide-react'
33
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
44
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
5-
import { tomorrow } from 'react-syntax-highlighter/dist/esm/styles/prism'
5+
import { usePrismTheme } from '@/client/hooks/usePrismTheme'
66

77
import { Badge } from '@/components/ui/badge'
88
import { Button } from '@/components/ui/button'
@@ -34,6 +34,7 @@ interface PromptResult {
3434

3535
export function PromptsTab({ prompts, callPrompt, isConnected }: PromptsTabProps) {
3636
const [selectedPrompt, setSelectedPrompt] = useState<Prompt | null>(null)
37+
const { prismStyle } = usePrismTheme()
3738
const [promptArgs, setPromptArgs] = useState<Record<string, unknown>>({})
3839
const [results, setResults] = useState<PromptResult[]>([])
3940
const [isExecuting, setIsExecuting] = useState(false)
@@ -82,7 +83,7 @@ export function PromptsTab({ prompts, callPrompt, isConnected }: PromptsTabProps
8283
// Handle auto-selection from command palette
8384
useEffect(() => {
8485
const selectedPromptName = sessionStorage.getItem('selected-prompts')
85-
if (selectedPromptName) {
86+
if (selectedPromptName && prompts.length > 0) {
8687
const prompt = prompts.find(p => p.name === selectedPromptName)
8788
if (prompt) {
8889
handlePromptSelect(prompt)
@@ -378,7 +379,7 @@ export function PromptsTab({ prompts, callPrompt, isConnected }: PromptsTabProps
378379
) : (
379380
<SyntaxHighlighter
380381
language="json"
381-
style={tomorrow}
382+
style={prismStyle}
382383
className="text-xs rounded"
383384
customStyle={{
384385
margin: 0,

packages/inspector/src/client/components/ResourcesTab.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Resource } from '@modelcontextprotocol/sdk/types.js'
22
import { Copy, Download, FileText, Search } from 'lucide-react'
33
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
44
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
5-
import { tomorrow } from 'react-syntax-highlighter/dist/esm/styles/prism'
5+
import { usePrismTheme } from '@/client/hooks/usePrismTheme'
66

77
import { Badge } from '@/components/ui/badge'
88
import { Button } from '@/components/ui/button'
@@ -31,6 +31,7 @@ interface ResourceResult {
3131
}
3232

3333
export function ResourcesTab({ resources, readResource, isConnected }: ResourcesTabProps) {
34+
const { prismStyle } = usePrismTheme()
3435
const [selectedResource, setSelectedResource] = useState<Resource | null>(null)
3536
const [results, setResults] = useState<ResourceResult[]>([])
3637
const [isLoading, setIsLoading] = useState(false)
@@ -53,7 +54,7 @@ export function ResourcesTab({ resources, readResource, isConnected }: Resources
5354
// Handle auto-selection from command palette
5455
useEffect(() => {
5556
const selectedResourceName = sessionStorage.getItem('selected-resources')
56-
if (selectedResourceName) {
57+
if (selectedResourceName && resources.length > 0) {
5758
const resource = resources.find(r => r.name === selectedResourceName)
5859
if (resource) {
5960
handleResourceSelect(resource)
@@ -358,7 +359,7 @@ export function ResourcesTab({ resources, readResource, isConnected }: Resources
358359
<div className="max-h-64 overflow-y-auto">
359360
<SyntaxHighlighter
360361
language="json"
361-
style={tomorrow}
362+
style={prismStyle}
362363
className="text-xs rounded"
363364
customStyle={{
364365
margin: 0,

0 commit comments

Comments
 (0)