Formatting

This commit is contained in:
cliffhall 2026-02-23 11:49:44 -05:00
commit 92b6c89354
3 changed files with 46 additions and 4 deletions

View file

@ -1526,6 +1526,9 @@ const App = () => {
error={errors.prompts}
/>
<ToolsTab
serverSupportsTaskRequests={
!!serverCapabilities?.tasks?.requests?.tools?.call
}
tools={tools}
listTools={() => {
clearError("tools");

View file

@ -177,6 +177,7 @@ const ToolsTab = ({
error,
resourceContent,
onReadResource,
serverSupportsTaskRequests,
}: {
tools: Tool[];
listTools: () => void;
@ -195,6 +196,7 @@ const ToolsTab = ({
error: string | null;
resourceContent: Record<string, string>;
onReadResource?: (uri: string) => void;
serverSupportsTaskRequests: boolean;
}) => {
const [params, setParams] = useState<Record<string, unknown>>({});
const [runAsTask, setRunAsTask] = useState(false);
@ -239,15 +241,17 @@ const ToolsTab = ({
];
});
setParams(Object.fromEntries(params));
const taskSupport = getTaskSupport(selectedTool);
setRunAsTask(taskSupport === "required");
const toolTaskSupport = serverSupportsTaskRequests
? getTaskSupport(selectedTool)
: "forbidden";
setRunAsTask(toolTaskSupport === "required");
// Reset validation errors when switching tools
setHasValidationErrors(false);
// Clear form refs for the previous tool
formRefs.current = {};
}, [selectedTool]);
}, [selectedTool, serverSupportsTaskRequests]);
const hasReservedMetadataEntry = metadataEntries.some(({ key }) => {
const trimmedKey = key.trim();
@ -264,7 +268,9 @@ const ToolsTab = ({
return trimmedKey !== "" && !hasValidMetaName(trimmedKey);
});
const taskSupport = getTaskSupport(selectedTool);
const taskSupport = serverSupportsTaskRequests
? getTaskSupport(selectedTool)
: "forbidden";
return (
<TabsContent value="tools">

View file

@ -73,6 +73,7 @@ describe("ToolsTab", () => {
error: null,
resourceContent: {},
onReadResource: jest.fn(),
serverSupportsTaskRequests: true,
};
const renderToolsTab = (props = {}) => {
@ -155,6 +156,38 @@ describe("ToolsTab", () => {
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 () => {
renderToolsTab({
selectedTool: mockTools[1], // Use the tool with integer type