Skip to content

Display "completions not supported" for resource templates which do not support completions. #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions client/src/components/ResourcesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ const ResourcesTab = ({
id={key}
placeholder={`Enter ${key}`}
value={templateValues[key] || ""}
emptyMessage={
<div className="px-6">
This resource does not support{" "}
<a
href="https://modelcontextprotocol.io/specification/2025-03-26/server/utilities/completion"
target="_blank"
>
completions
</a>
.
</div>
}
onChange={(value) =>
handleTemplateValueChange(key, value)
}
Expand Down
41 changes: 41 additions & 0 deletions client/src/components/__tests__/combobox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { render, screen, fireEvent } from "@testing-library/react";
import "@testing-library/jest-dom";
import { describe, it } from "@jest/globals";
import { Combobox } from "../ui/combobox";

describe("combobox", () => {
it("should render custom empty message", async () => {
const customMessage = (
<div data-testid="custom-empty">Custom empty message</div>
);
render(
<Combobox
value=""
onChange={() => {}}
onInputChange={() => {}}
options={[]}
emptyMessage={customMessage}
/>,
);

fireEvent.click(screen.getByRole("combobox"));

expect(await screen.findByTestId("custom-empty")).toBeInTheDocument();
expect(screen.getByText("Custom empty message")).toBeInTheDocument();
});

it("should render default empty message", async () => {
render(
<Combobox
value=""
onChange={() => {}}
onInputChange={() => {}}
options={[]}
/>,
);

fireEvent.click(screen.getByRole("combobox"));

expect(await screen.findByText("No results found.")).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion client/src/components/ui/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ComboboxProps {
onInputChange: (value: string) => void;
options: string[];
placeholder?: string;
emptyMessage?: string;
emptyMessage?: string | React.ReactNode;
id?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ h1 {
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive: 0 81.8% 54.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 24% 24%;
--input: 217.2 24% 24%;
Expand Down