diff --git a/client/src/App.tsx b/client/src/App.tsx index d2a7695..84be122 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -19,7 +19,7 @@ import ResourcesTab, { Resource } from "./components/ResourcesTab"; import NotificationsTab from "./components/NotificationsTab"; import PromptsTab, { Prompt } from "./components/PromptsTab"; import ToolsTab, { Tool as ToolType } from "./components/ToolsTab"; -import History from "./components/CommandHistory"; +import History from "./components/History"; const App = () => { const [socket, setSocket] = useState(null); diff --git a/client/src/components/ListPane.tsx b/client/src/components/ListPane.tsx new file mode 100644 index 0000000..0a0760b --- /dev/null +++ b/client/src/components/ListPane.tsx @@ -0,0 +1,43 @@ +import { Button } from "./ui/button"; + +type ListPaneProps = { + items: T[]; + listItems: () => void; + setSelectedItem: (item: T) => void; + renderItem: (item: T) => React.ReactNode; + title: string; + buttonText: string; +}; + +const ListPane = ({ + items, + listItems, + setSelectedItem, + renderItem, + title, + buttonText, +}: ListPaneProps) => ( +
+
+

{title}

+
+
+ +
+ {items.map((item, index) => ( +
setSelectedItem(item)} + > + {renderItem(item)} +
+ ))} +
+
+
+); + +export default ListPane; diff --git a/client/src/components/PromptsTab.tsx b/client/src/components/PromptsTab.tsx index 97cb926..19fbf5d 100644 --- a/client/src/components/PromptsTab.tsx +++ b/client/src/components/PromptsTab.tsx @@ -6,6 +6,7 @@ import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { useState } from "react"; import { Label } from "@/components/ui/label"; +import ListPane from "./ListPane"; export type Prompt = { name: string; @@ -48,34 +49,22 @@ const PromptsTab = ({ return ( -
-
-

Prompts

-
-
- -
- {prompts.map((prompt) => ( -
{ - setSelectedPrompt(prompt); - setPromptArgs({}); - }} - > - {prompt.name} -
- ))} -
-
-
+ { + setSelectedPrompt(prompt); + setPromptArgs({}); + }} + renderItem={(prompt) => ( + <> + {prompt.name} + {prompt.description} + + )} + title="Prompts" + buttonText="List Prompts" + />
diff --git a/client/src/components/ResourcesTab.tsx b/client/src/components/ResourcesTab.tsx index 6239561..9792ca9 100644 --- a/client/src/components/ResourcesTab.tsx +++ b/client/src/components/ResourcesTab.tsx @@ -1,13 +1,8 @@ -import { - FileText, - PlayCircle, - ChevronRight, - AlertCircle, - RefreshCw, -} from "lucide-react"; +import { FileText, ChevronRight, AlertCircle, RefreshCw } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { TabsContent } from "@/components/ui/tabs"; +import ListPane from "./ListPane"; export type Resource = { uri: string; @@ -31,37 +26,23 @@ const ResourcesTab = ({ error: string | null; }) => ( -
-
-

Resources

-
-
- -
- {resources.map((resource, index) => ( -
{ - setSelectedResource(resource); - readResource(resource.uri); - }} - > - - {resource.uri} - -
- ))} -
-
-
+ { + setSelectedResource(resource); + readResource(resource.uri); + }} + renderItem={(resource) => ( + <> + + {resource.uri} + + + )} + title="Resources" + buttonText="List Resources" + />
diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index 9cd090c..8e58dae 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -5,6 +5,7 @@ import { Send, AlertCircle } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { useState } from "react"; import { Label } from "@/components/ui/label"; +import ListPane from "./ListPane"; export type Tool = { name: string; @@ -36,30 +37,19 @@ const ToolsTab = ({ return ( -
-
-

Tools

-
-
- -
- {tools.map((tool, index) => ( -
setSelectedTool(tool)} - > - {tool.name} - - {tool.description} - -
- ))} -
-
-
+ ( + <> + {tool.name} + {tool.description} + + )} + title="Tools" + buttonText="List Tools" + />