Repository navigation
fix(ui): sort MCP tools by name and lead the template page back to the chat #3644
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
Draft
cjlg-soloio
wants to merge
2
commits into
kagent-dev:main
Choose a base branch
from
cjlg-soloio:cjlg-soloio/issueFollowups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+274
−22
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { cleanup, render, screen } from "@testing-library/react"; | ||
| import { ThemeProvider } from "@emotion/react"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { themeFor } from "@/theme/theme"; | ||
| import { ToolServerTools } from "./ToolServerTools"; | ||
|
|
||
| function renderedNames(names: string[]) { | ||
| render( | ||
| <ThemeProvider theme={themeFor("light")}> | ||
| <ToolServerTools tools={names.map((name) => ({ name, description: "" }))} /> | ||
| </ThemeProvider>, | ||
| ); | ||
| return screen.getAllByTestId("tool-server-tool").map((item) => item.textContent); | ||
| } | ||
|
|
||
| describe("ToolServerTools", () => { | ||
| it("lists tools alphabetically, whatever order the server reported them in", () => { | ||
| expect( | ||
| renderedNames(["k8s_get_pods", "K8s_apply", "k8s_describe"]), | ||
| ).toEqual(["K8s_apply", "k8s_describe", "k8s_get_pods"]); | ||
| }); | ||
|
|
||
| it("orders numbered tools by number rather than character by character", () => { | ||
| expect(renderedNames(["tool_10", "tool_2"])).toEqual([ | ||
| "tool_2", | ||
| "tool_10", | ||
| ]); | ||
| }); | ||
|
|
||
| it("gives names that differ only in case one fixed order", () => { | ||
| const first = renderedNames(["get_pods", "Get_pods"]); | ||
| cleanup(); | ||
| expect(renderedNames(["Get_pods", "get_pods"])).toEqual(first); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { render, screen } from "@testing-library/react"; | ||
| import { MemoryRouter } from "react-router-dom"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { backLinkState, useBackLink } from "./backLink"; | ||
|
|
||
| const FALLBACK = { to: "/agents?tab=templates", label: "Back to templates" }; | ||
|
|
||
| function Probe() { | ||
| const back = useBackLink(FALLBACK); | ||
| return <a href={back.to}>{back.label}</a>; | ||
| } | ||
|
|
||
| function renderAt(state: unknown) { | ||
| render( | ||
| <MemoryRouter initialEntries={[{ pathname: "/agent-templates/kagent/a", state }]}> | ||
| <Probe /> | ||
| </MemoryRouter>, | ||
| ); | ||
| return screen.getByRole("link"); | ||
| } | ||
|
|
||
| describe("useBackLink", () => { | ||
| it("leads back to the page that opened this one, search included", () => { | ||
| const link = renderAt( | ||
| backLinkState({ pathname: "/agents/abc/chat", search: "?mock=ok" }, "Back to conversation"), | ||
| ); | ||
| expect(link.textContent).toBe("Back to conversation"); | ||
| expect(link.getAttribute("href")).toBe("/agents/abc/chat?mock=ok"); | ||
| }); | ||
|
|
||
| it("falls back to the list on a direct visit", () => { | ||
| const link = renderAt(undefined); | ||
| expect(link.textContent).toBe("Back to templates"); | ||
| expect(link.getAttribute("href")).toBe(FALLBACK.to); | ||
| }); | ||
|
|
||
| it.each([ | ||
| { from: "https://example.com/", fromLabel: "Back" }, | ||
| { from: "//example.com/", fromLabel: "Back" }, | ||
| { from: "/agents", fromLabel: "" }, | ||
| { from: 42, fromLabel: "Back" }, | ||
| "not an object", | ||
| ])("ignores state that is not an in-app origin: %j", (state) => { | ||
| expect(renderAt(state).textContent).toBe("Back to templates"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.