Formatting
This commit is contained in:
parent
f64a7ea6e3
commit
92b6c89354
3 changed files with 46 additions and 4 deletions
|
|
@ -1526,6 +1526,9 @@ const App = () => {
|
||||||
error={errors.prompts}
|
error={errors.prompts}
|
||||||
/>
|
/>
|
||||||
<ToolsTab
|
<ToolsTab
|
||||||
|
serverSupportsTaskRequests={
|
||||||
|
!!serverCapabilities?.tasks?.requests?.tools?.call
|
||||||
|
}
|
||||||
tools={tools}
|
tools={tools}
|
||||||
listTools={() => {
|
listTools={() => {
|
||||||
clearError("tools");
|
clearError("tools");
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ const ToolsTab = ({
|
||||||
error,
|
error,
|
||||||
resourceContent,
|
resourceContent,
|
||||||
onReadResource,
|
onReadResource,
|
||||||
|
serverSupportsTaskRequests,
|
||||||
}: {
|
}: {
|
||||||
tools: Tool[];
|
tools: Tool[];
|
||||||
listTools: () => void;
|
listTools: () => void;
|
||||||
|
|
@ -195,6 +196,7 @@ const ToolsTab = ({
|
||||||
error: string | null;
|
error: string | null;
|
||||||
resourceContent: Record<string, string>;
|
resourceContent: Record<string, string>;
|
||||||
onReadResource?: (uri: string) => void;
|
onReadResource?: (uri: string) => void;
|
||||||
|
serverSupportsTaskRequests: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const [params, setParams] = useState<Record<string, unknown>>({});
|
const [params, setParams] = useState<Record<string, unknown>>({});
|
||||||
const [runAsTask, setRunAsTask] = useState(false);
|
const [runAsTask, setRunAsTask] = useState(false);
|
||||||
|
|
@ -239,15 +241,17 @@ const ToolsTab = ({
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
setParams(Object.fromEntries(params));
|
setParams(Object.fromEntries(params));
|
||||||
const taskSupport = getTaskSupport(selectedTool);
|
const toolTaskSupport = serverSupportsTaskRequests
|
||||||
setRunAsTask(taskSupport === "required");
|
? getTaskSupport(selectedTool)
|
||||||
|
: "forbidden";
|
||||||
|
setRunAsTask(toolTaskSupport === "required");
|
||||||
|
|
||||||
// Reset validation errors when switching tools
|
// Reset validation errors when switching tools
|
||||||
setHasValidationErrors(false);
|
setHasValidationErrors(false);
|
||||||
|
|
||||||
// Clear form refs for the previous tool
|
// Clear form refs for the previous tool
|
||||||
formRefs.current = {};
|
formRefs.current = {};
|
||||||
}, [selectedTool]);
|
}, [selectedTool, serverSupportsTaskRequests]);
|
||||||
|
|
||||||
const hasReservedMetadataEntry = metadataEntries.some(({ key }) => {
|
const hasReservedMetadataEntry = metadataEntries.some(({ key }) => {
|
||||||
const trimmedKey = key.trim();
|
const trimmedKey = key.trim();
|
||||||
|
|
@ -264,7 +268,9 @@ const ToolsTab = ({
|
||||||
return trimmedKey !== "" && !hasValidMetaName(trimmedKey);
|
return trimmedKey !== "" && !hasValidMetaName(trimmedKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
const taskSupport = getTaskSupport(selectedTool);
|
const taskSupport = serverSupportsTaskRequests
|
||||||
|
? getTaskSupport(selectedTool)
|
||||||
|
: "forbidden";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabsContent value="tools">
|
<TabsContent value="tools">
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ describe("ToolsTab", () => {
|
||||||
error: null,
|
error: null,
|
||||||
resourceContent: {},
|
resourceContent: {},
|
||||||
onReadResource: jest.fn(),
|
onReadResource: jest.fn(),
|
||||||
|
serverSupportsTaskRequests: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderToolsTab = (props = {}) => {
|
const renderToolsTab = (props = {}) => {
|
||||||
|
|
@ -155,6 +156,38 @@ describe("ToolsTab", () => {
|
||||||
expect(requiredCheckbox).toBeDisabled();
|
expect(requiredCheckbox).toBeDisabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should hide run-as-task checkbox when serverSupportsTaskRequests is false even for required/optional tools", async () => {
|
||||||
|
const requiredTool: ExtendedTool = {
|
||||||
|
...mockTools[0],
|
||||||
|
name: "requiredTool",
|
||||||
|
execution: { taskSupport: "required" },
|
||||||
|
};
|
||||||
|
const optionalTool: ExtendedTool = {
|
||||||
|
...mockTools[0],
|
||||||
|
name: "optionalTool",
|
||||||
|
execution: { taskSupport: "optional" },
|
||||||
|
};
|
||||||
|
|
||||||
|
const { rerender } = renderToolsTab({
|
||||||
|
selectedTool: requiredTool,
|
||||||
|
serverSupportsTaskRequests: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument();
|
||||||
|
|
||||||
|
rerender(
|
||||||
|
<Tabs defaultValue="tools">
|
||||||
|
<ToolsTab
|
||||||
|
{...defaultProps}
|
||||||
|
selectedTool={optionalTool}
|
||||||
|
serverSupportsTaskRequests={false}
|
||||||
|
/>
|
||||||
|
</Tabs>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it("should handle integer type inputs", async () => {
|
it("should handle integer type inputs", async () => {
|
||||||
renderToolsTab({
|
renderToolsTab({
|
||||||
selectedTool: mockTools[1], // Use the tool with integer type
|
selectedTool: mockTools[1], // Use the tool with integer type
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue