mcp: update resources + icon alignment
This commit is contained in:
parent
35286a24c6
commit
a114db85bd
3 changed files with 65 additions and 32 deletions
|
|
@ -9,12 +9,12 @@ import {
|
||||||
PromptReference,
|
PromptReference,
|
||||||
ResourceReference,
|
ResourceReference,
|
||||||
} from "@modelcontextprotocol/sdk/types.js";
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { AlertCircle } from "lucide-react";
|
import { AlertCircle, ChevronRight } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import ListPane from "./ListPane";
|
import ListPane from "./ListPane";
|
||||||
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
||||||
import JsonView from "./JsonView";
|
import JsonView from "./JsonView";
|
||||||
import IconDisplay from "./IconDisplay";
|
import IconDisplay, { WithIcons } from "./IconDisplay";
|
||||||
|
|
||||||
export type Prompt = {
|
export type Prompt = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -110,12 +110,17 @@ const PromptsTab = ({
|
||||||
setPromptArgs({});
|
setPromptArgs({});
|
||||||
}}
|
}}
|
||||||
renderItem={(prompt) => (
|
renderItem={(prompt) => (
|
||||||
<div className="flex flex-col items-start">
|
<div className="flex items-start w-full gap-2">
|
||||||
<IconDisplay icons={prompt.icons} size="sm" />
|
<div className="flex-shrink-0 mt-1">
|
||||||
<span className="flex-1">{prompt.name}</span>
|
<IconDisplay icons={prompt.icons} size="sm" />
|
||||||
<span className="text-sm text-gray-500 text-left">
|
</div>
|
||||||
{prompt.description}
|
<div className="flex flex-col flex-1 min-w-0">
|
||||||
</span>
|
<span className="truncate">{prompt.name}</span>
|
||||||
|
<span className="text-sm text-gray-500 text-left line-clamp-2">
|
||||||
|
{prompt.description}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<ChevronRight className="w-4 h-4 flex-shrink-0 text-gray-400 mt-1" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
title="Prompts"
|
title="Prompts"
|
||||||
|
|
@ -125,9 +130,17 @@ const PromptsTab = ({
|
||||||
|
|
||||||
<div className="bg-card border border-border rounded-lg shadow">
|
<div className="bg-card border border-border rounded-lg shadow">
|
||||||
<div className="p-4 border-b border-gray-200 dark:border-border">
|
<div className="p-4 border-b border-gray-200 dark:border-border">
|
||||||
<h3 className="font-semibold">
|
<div className="flex items-center gap-2">
|
||||||
{selectedPrompt ? selectedPrompt.name : "Select a prompt"}
|
{selectedPrompt && (
|
||||||
</h3>
|
<IconDisplay
|
||||||
|
icons={(selectedPrompt as WithIcons).icons}
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<h3 className="font-semibold">
|
||||||
|
{selectedPrompt ? selectedPrompt.name : "Select a prompt"}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
{error ? (
|
{error ? (
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { useEffect, useState } from "react";
|
||||||
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
||||||
import JsonView from "./JsonView";
|
import JsonView from "./JsonView";
|
||||||
import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
||||||
|
import IconDisplay, { WithIcons } from "./IconDisplay";
|
||||||
|
|
||||||
const ResourcesTab = ({
|
const ResourcesTab = ({
|
||||||
resources,
|
resources,
|
||||||
|
|
@ -129,7 +130,10 @@ const ResourcesTab = ({
|
||||||
}}
|
}}
|
||||||
renderItem={(resource) => (
|
renderItem={(resource) => (
|
||||||
<div className="flex items-center w-full">
|
<div className="flex items-center w-full">
|
||||||
<FileText className="w-4 h-4 mr-2 flex-shrink-0 text-gray-500" />
|
<IconDisplay icons={(resource as WithIcons).icons} size="sm" />
|
||||||
|
{!(resource as WithIcons).icons && (
|
||||||
|
<FileText className="w-4 h-4 mr-2 flex-shrink-0 text-gray-500" />
|
||||||
|
)}
|
||||||
<span className="flex-1 truncate" title={resource.uri.toString()}>
|
<span className="flex-1 truncate" title={resource.uri.toString()}>
|
||||||
{resource.name}
|
{resource.name}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -159,7 +163,10 @@ const ResourcesTab = ({
|
||||||
}}
|
}}
|
||||||
renderItem={(template) => (
|
renderItem={(template) => (
|
||||||
<div className="flex items-center w-full">
|
<div className="flex items-center w-full">
|
||||||
<FileText className="w-4 h-4 mr-2 flex-shrink-0 text-gray-500" />
|
<IconDisplay icons={(template as WithIcons).icons} size="sm" />
|
||||||
|
{!(template as WithIcons).icons && (
|
||||||
|
<FileText className="w-4 h-4 mr-2 flex-shrink-0 text-gray-500" />
|
||||||
|
)}
|
||||||
<span className="flex-1 truncate" title={template.uriTemplate}>
|
<span className="flex-1 truncate" title={template.uriTemplate}>
|
||||||
{template.name}
|
{template.name}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -175,16 +182,26 @@ const ResourcesTab = ({
|
||||||
|
|
||||||
<div className="bg-card border border-border rounded-lg shadow">
|
<div className="bg-card border border-border rounded-lg shadow">
|
||||||
<div className="p-4 border-b border-gray-200 dark:border-border flex justify-between items-center">
|
<div className="p-4 border-b border-gray-200 dark:border-border flex justify-between items-center">
|
||||||
<h3
|
<div className="flex items-center gap-2 truncate">
|
||||||
className="font-semibold truncate"
|
{(selectedResource || selectedTemplate) && (
|
||||||
title={selectedResource?.name || selectedTemplate?.name}
|
<IconDisplay
|
||||||
>
|
icons={
|
||||||
{selectedResource
|
((selectedResource || selectedTemplate) as WithIcons).icons
|
||||||
? selectedResource.name
|
}
|
||||||
: selectedTemplate
|
size="md"
|
||||||
? selectedTemplate.name
|
/>
|
||||||
: "Select a resource or template"}
|
)}
|
||||||
</h3>
|
<h3
|
||||||
|
className="font-semibold truncate"
|
||||||
|
title={selectedResource?.name || selectedTemplate?.name}
|
||||||
|
>
|
||||||
|
{selectedResource
|
||||||
|
? selectedResource.name
|
||||||
|
: selectedTemplate
|
||||||
|
? selectedTemplate.name
|
||||||
|
: "Select a resource or template"}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
{selectedResource && (
|
{selectedResource && (
|
||||||
<div className="flex row-auto gap-1 justify-end w-2/5">
|
<div className="flex row-auto gap-1 justify-end w-2/5">
|
||||||
{resourceSubscriptionsSupported &&
|
{resourceSubscriptionsSupported &&
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import {
|
||||||
Send,
|
Send,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
ChevronUp,
|
ChevronUp,
|
||||||
|
ChevronRight,
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
Copy,
|
Copy,
|
||||||
CheckCheck,
|
CheckCheck,
|
||||||
|
|
@ -159,12 +160,17 @@ const ToolsTab = ({
|
||||||
}}
|
}}
|
||||||
setSelectedItem={setSelectedTool}
|
setSelectedItem={setSelectedTool}
|
||||||
renderItem={(tool) => (
|
renderItem={(tool) => (
|
||||||
<div className="flex flex-col items-start">
|
<div className="flex items-start w-full gap-2">
|
||||||
<IconDisplay icons={(tool as WithIcons).icons} size="sm" />
|
<div className="flex-shrink-0 mt-1">
|
||||||
<span className="flex-1">{tool.name}</span>
|
<IconDisplay icons={(tool as WithIcons).icons} size="sm" />
|
||||||
<span className="text-sm text-gray-500 text-left line-clamp-3">
|
</div>
|
||||||
{tool.description}
|
<div className="flex flex-col flex-1 min-w-0">
|
||||||
</span>
|
<span className="truncate">{tool.name}</span>
|
||||||
|
<span className="text-sm text-gray-500 text-left line-clamp-2">
|
||||||
|
{tool.description}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<ChevronRight className="w-4 h-4 flex-shrink-0 text-gray-400 mt-1" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
title="Tools"
|
title="Tools"
|
||||||
|
|
@ -174,9 +180,6 @@ const ToolsTab = ({
|
||||||
|
|
||||||
<div className="bg-card border border-border rounded-lg shadow">
|
<div className="bg-card border border-border rounded-lg shadow">
|
||||||
<div className="p-4 border-b border-gray-200 dark:border-border">
|
<div className="p-4 border-b border-gray-200 dark:border-border">
|
||||||
<h3 className="font-semibold">
|
|
||||||
{selectedTool ? selectedTool.name : "Select a tool"}
|
|
||||||
</h3>
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{selectedTool && (
|
{selectedTool && (
|
||||||
<IconDisplay
|
<IconDisplay
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue