diff --git a/client/src/components/DynamicJsonForm.tsx b/client/src/components/DynamicJsonForm.tsx index 4fbd45ca6..0da5a9f9b 100644 --- a/client/src/components/DynamicJsonForm.tsx +++ b/client/src/components/DynamicJsonForm.tsx @@ -13,6 +13,7 @@ interface DynamicJsonFormProps { value: JsonValue; onChange: (value: JsonValue) => void; maxDepth?: number; + forceJsonMode?: boolean; } const isSimpleObject = (schema: JsonSchemaType): boolean => { @@ -58,8 +59,9 @@ const DynamicJsonForm = ({ value, onChange, maxDepth = 3, + forceJsonMode = false, }: DynamicJsonFormProps) => { - const isOnlyJSON = !isSimpleObject(schema); + const isOnlyJSON = forceJsonMode || !isSimpleObject(schema); const [isJsonMode, setIsJsonMode] = useState(isOnlyJSON); const [jsonError, setJsonError] = useState(); const [copiedJson, setCopiedJson] = useState(false); @@ -99,12 +101,12 @@ const DynamicJsonForm = ({ // Update rawJsonValue when value prop changes useEffect(() => { - if (!isJsonMode) { + if (!isJsonMode || forceJsonMode) { setRawJsonValue( JSON.stringify(value ?? generateDefaultValue(schema), null, 2), ); } - }, [value, schema, isJsonMode]); + }, [value, schema, isJsonMode, forceJsonMode]); const handleSwitchToFormMode = () => { if (isJsonMode) { diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index 3c7db84e4..3ce4b2e98 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -5,7 +5,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { TabsContent } from "@/components/ui/tabs"; import { Textarea } from "@/components/ui/textarea"; -import DynamicJsonForm from "./DynamicJsonForm"; +import { ToggleGroup, ToggleGroupItem } from "@/components/ui/togglegroup"; import type { JsonValue, JsonSchemaType } from "@/utils/jsonUtils"; import { generateDefaultValue, isPropertyRequired } from "@/utils/schemaUtils"; import { @@ -16,6 +16,7 @@ import { import { Loader2, Send, ChevronDown, ChevronUp } from "lucide-react"; import { useEffect, useState } from "react"; import ListPane from "./ListPane"; +import DynamicJsonForm from "./DynamicJsonForm"; import JsonView from "./JsonView"; import ToolResults from "./ToolResults"; @@ -46,6 +47,7 @@ const ToolsTab = ({ const [params, setParams] = useState>({}); const [isToolRunning, setIsToolRunning] = useState(false); const [isOutputSchemaExpanded, setIsOutputSchemaExpanded] = useState(false); + const [paramsInputMode, setParamsInputMode] = useState("form"); useEffect(() => { const params = Object.entries( @@ -97,117 +99,135 @@ const ToolsTab = ({

{selectedTool.description}

- {Object.entries(selectedTool.inputSchema.properties ?? []).map( - ([key, value]) => { - const prop = value as JsonSchemaType; - const inputSchema = - selectedTool.inputSchema as JsonSchemaType; - const required = isPropertyRequired(key, inputSchema); - return ( -
- - {prop.type === "boolean" ? ( -
- { + const prop = value as JsonSchemaType; + const inputSchema = + selectedTool.inputSchema as JsonSchemaType; + const required = isPropertyRequired(key, inputSchema); + return ( +
+ + {prop.type === "boolean" ? ( +
+ + setParams({ + ...params, + [key]: checked, + }) + } + /> + +
+ ) : prop.type === "string" ? ( +