Skip to content

Commit 92b6c89

Browse files
committed
Formatting
1 parent f64a7ea commit 92b6c89

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

client/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,9 @@ const App = () => {
15261526
error={errors.prompts}
15271527
/>
15281528
<ToolsTab
1529+
serverSupportsTaskRequests={
1530+
!!serverCapabilities?.tasks?.requests?.tools?.call
1531+
}
15291532
tools={tools}
15301533
listTools={() => {
15311534
clearError("tools");

client/src/components/ToolsTab.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ const ToolsTab = ({
177177
error,
178178
resourceContent,
179179
onReadResource,
180+
serverSupportsTaskRequests,
180181
}: {
181182
tools: Tool[];
182183
listTools: () => void;
@@ -195,6 +196,7 @@ const ToolsTab = ({
195196
error: string | null;
196197
resourceContent: Record<string, string>;
197198
onReadResource?: (uri: string) => void;
199+
serverSupportsTaskRequests: boolean;
198200
}) => {
199201
const [params, setParams] = useState<Record<string, unknown>>({});
200202
const [runAsTask, setRunAsTask] = useState(false);
@@ -239,15 +241,17 @@ const ToolsTab = ({
239241
];
240242
});
241243
setParams(Object.fromEntries(params));
242-
const taskSupport = getTaskSupport(selectedTool);
243-
setRunAsTask(taskSupport === "required");
244+
const toolTaskSupport = serverSupportsTaskRequests
245+
? getTaskSupport(selectedTool)
246+
: "forbidden";
247+
setRunAsTask(toolTaskSupport === "required");
244248

245249
// Reset validation errors when switching tools
246250
setHasValidationErrors(false);
247251

248252
// Clear form refs for the previous tool
249253
formRefs.current = {};
250-
}, [selectedTool]);
254+
}, [selectedTool, serverSupportsTaskRequests]);
251255

252256
const hasReservedMetadataEntry = metadataEntries.some(({ key }) => {
253257
const trimmedKey = key.trim();
@@ -264,7 +268,9 @@ const ToolsTab = ({
264268
return trimmedKey !== "" && !hasValidMetaName(trimmedKey);
265269
});
266270

267-
const taskSupport = getTaskSupport(selectedTool);
271+
const taskSupport = serverSupportsTaskRequests
272+
? getTaskSupport(selectedTool)
273+
: "forbidden";
268274

269275
return (
270276
<TabsContent value="tools">

client/src/components/__tests__/ToolsTab.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe("ToolsTab", () => {
7373
error: null,
7474
resourceContent: {},
7575
onReadResource: jest.fn(),
76+
serverSupportsTaskRequests: true,
7677
};
7778

7879
const renderToolsTab = (props = {}) => {
@@ -155,6 +156,38 @@ describe("ToolsTab", () => {
155156
expect(requiredCheckbox).toBeDisabled();
156157
});
157158

159+
it("should hide run-as-task checkbox when serverSupportsTaskRequests is false even for required/optional tools", async () => {
160+
const requiredTool: ExtendedTool = {
161+
...mockTools[0],
162+
name: "requiredTool",
163+
execution: { taskSupport: "required" },
164+
};
165+
const optionalTool: ExtendedTool = {
166+
...mockTools[0],
167+
name: "optionalTool",
168+
execution: { taskSupport: "optional" },
169+
};
170+
171+
const { rerender } = renderToolsTab({
172+
selectedTool: requiredTool,
173+
serverSupportsTaskRequests: false,
174+
});
175+
176+
expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument();
177+
178+
rerender(
179+
<Tabs defaultValue="tools">
180+
<ToolsTab
181+
{...defaultProps}
182+
selectedTool={optionalTool}
183+
serverSupportsTaskRequests={false}
184+
/>
185+
</Tabs>,
186+
);
187+
188+
expect(screen.queryByLabelText(/run as task/i)).not.toBeInTheDocument();
189+
});
190+
158191
it("should handle integer type inputs", async () => {
159192
renderToolsTab({
160193
selectedTool: mockTools[1], // Use the tool with integer type

0 commit comments

Comments
 (0)