Revert "Add copy button to JSON & fix button styles override."

This reverts commit c48670f426.
This commit is contained in:
NicolasMontone
2025-04-01 16:48:01 -03:00
parent c48670f426
commit d1e155f984
4 changed files with 33 additions and 27 deletions

View File

@@ -13,11 +13,10 @@ import {
ListToolsResult,
Tool,
} from "@modelcontextprotocol/sdk/types.js";
import { AlertCircle, Copy, Send, CheckCheck } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { AlertCircle, Send } from "lucide-react";
import { useEffect, useState } from "react";
import ListPane from "./ListPane";
import JsonView from "./JsonView";
import { toast } from 'react-toastify'
const ToolsTab = ({
tools,
@@ -45,20 +44,6 @@ const ToolsTab = ({
setParams({});
}, [selectedTool]);
const [copied, setCopied] = useState(false)
const handleCopy = useCallback(() => {
try {
navigator.clipboard.writeText(JSON.stringify(toolResult))
setCopied(true)
setTimeout(() => {
setCopied(false)
}, 500)
} catch (error) {
toast.error(`There was an error coping result into the clipboard: ${error instanceof Error ? error.message : String(error)}`)
}
}, [toolResult])
const renderToolResult = () => {
if (!toolResult) return null;
@@ -68,8 +53,7 @@ const ToolsTab = ({
return (
<>
<h4 className="font-semibold mb-2">Invalid Tool Result:</h4>
<div className="p-4 border rounded relative">
<Copy className="size-4 text-primary" />
<div className="p-4 border rounded">
<JsonView data={toolResult} />
</div>
<h4 className="font-semibold mb-2">Errors:</h4>
@@ -92,12 +76,7 @@ const ToolsTab = ({
{structuredResult.content.map((item, index) => (
<div key={index} className="mb-2">
{item.type === "text" && (
<div className="p-4 border rounded relative">
<Button size="icon" variant="ghost" className="absolute top-2 right-2" onClick={handleCopy}>
{copied ?
<CheckCheck className="size-4 dark:text-green-700 text-green-600" />
: <Copy className="size-4 text-foreground" />}
</Button>
<div className="p-4 border rounded">
<JsonView data={item.text} />
</div>
)}
@@ -255,7 +234,7 @@ const ToolsTab = ({
...params,
[key]:
prop.type === "number" ||
prop.type === "integer"
prop.type === "integer"
? Number(e.target.value)
: e.target.value,
})