Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
55 changes: 53 additions & 2 deletions site/src/pages/AgentsPage/AgentChatPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
MockChat,
MockChatMessage,
MockChatQueuedMessage,
MockMCPServerConfig,
} from "#/testHelpers/chatEntities";
import { MockChatModelConfig } from "#/testHelpers/chatModels";
import {
Expand Down Expand Up @@ -255,7 +256,10 @@ const buildChatAuthorizationQuery = (
const buildQueries = (
chat: TypesGen.Chat,
messagesData: TypesGen.ChatMessagesResponse,
opts?: { diffUrl?: string },
opts?: {
diffUrl?: string;
mcpServers?: readonly TypesGen.MCPServerConfig[];
},
) => {
const diffStatus: TypesGen.ChatDiffStatus = {
chat_id: CHAT_ID,
Expand Down Expand Up @@ -301,7 +305,7 @@ const buildQueries = (
},
{ key: chatModelsKey, data: mockModelCatalog },
{ key: chatModelConfigs().queryKey, data: mockModelConfigs },
{ key: mcpServersKey, data: [] },
{ key: mcpServersKey, data: opts?.mcpServers ?? [] },
buildChatAuthorizationQuery(chat, {
canShareChat: {
action: "share",
Expand Down Expand Up @@ -3217,6 +3221,53 @@ export const SendResponseAfterChatSwitch: Story = {
},
};

export const RemoveLastMCPServer: Story = {
parameters: {
queries: buildQueries(
{
id: CHAT_ID,
...baseChatFields,
title: "Remove last MCP server",
status: "waiting",
mcp_server_ids: [MockMCPServerConfig.id],
},
{ messages: [], queued_messages: [], has_more: false },
{
diffUrl: undefined,
mcpServers: [MockMCPServerConfig],
},
),
},
beforeEach: () => {
spyOn(API.experimental, "getUserSkills").mockResolvedValue([]);
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const sendSpy = spyOn(
API.experimental,
"createChatMessage",
).mockResolvedValue({ queued: false });

await userEvent.click(
await canvas.findByRole("button", { name: "Remove MCP Server" }),
);
const editor = await canvas.findByTestId("chat-message-input");
await userEvent.click(editor);
await userEvent.type(editor, "Send without MCP tools");
await userEvent.keyboard("{Enter}");

await waitFor(() => {
expect(sendSpy).toHaveBeenCalledTimes(1);
});
expect(sendSpy).toHaveBeenCalledWith(
CHAT_ID,
expect.objectContaining({
mcp_server_ids: [],
}),
);
},
};

/**
* The send flow renders the durable user row once the server accepts the
* prompt, before the assistant turn produces any output.
Expand Down
5 changes: 1 addition & 4 deletions site/src/pages/AgentsPage/AgentChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1799,10 +1799,7 @@ const AgentChatPage: FC = () => {
content,
model_config_id: selectedModelConfigID,
reasoning_effort: effectiveReasoningEffort,
mcp_server_ids:
effectiveMCPServerIds.length > 0
? [...effectiveMCPServerIds]
: undefined,
mcp_server_ids: [...effectiveMCPServerIds],
...(planModeSwitch !== undefined
? {
plan_mode:
Expand Down
Loading