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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ function options(): McpConfigChoiceOption[] {
];
}

function renderDialog(mode: "adopt" | "resolve" = "adopt") {
function renderDialog(
mode: "adopt" | "resolve" = "adopt",
dialogOptions: McpConfigChoiceOption[] = options(),
) {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
});
Expand All @@ -66,7 +69,7 @@ function renderDialog(mode: "adopt" | "resolve" = "adopt") {
open
mode={mode}
serverName="context7"
options={options()}
options={dialogOptions}
pending={false}
onClose={vi.fn()}
onConfirm={onConfirm}
Expand All @@ -91,6 +94,9 @@ describe("McpConfigChoiceDialog", () => {
renderDialog();

expect(screen.getByRole("heading", { name: "Choose config to adopt" })).toBeInTheDocument();
expect(screen.getByText("Observed harness: Cursor")).toBeInTheDocument();
expect(screen.getByText("Observed harness: Claude")).toBeInTheDocument();
expect(screen.getByText("Recommended")).toBeInTheDocument();
fireEvent.click(screen.getByText("Claude"));
fireEvent.click(screen.getByRole("button", { name: "Adopt" }));

Expand All @@ -106,4 +112,20 @@ describe("McpConfigChoiceDialog", () => {

await waitFor(() => expect(onConfirm).toHaveBeenCalled());
});

it("labels managed config options", () => {
const [managed] = options();
renderDialog("resolve", [
{
...managed,
id: "managed",
sourceKind: "managed",
observedHarness: null,
label: "Skill Manager Config",
recommended: false,
},
]);

expect(screen.getByText("Managed MCP config")).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export function McpConfigChoiceDialog({
? copy.detail.configChoice.adoptDescription
: copy.detail.configChoice.resolveDescription;
const confirmLabel = mode === "adopt" ? copy.detail.configChoice.adoptConfirm : copy.detail.configChoice.applyConfig;
const sourceLabel = (option: McpConfigChoiceOption) =>
option.sourceKind === "managed"
? copy.detail.configChoice.managedConfig
: copy.detail.configChoice.observedHarness(option.label);

async function handleCommit(): Promise<void> {
if (!chosen) return;
Expand Down Expand Up @@ -135,6 +139,7 @@ export function McpConfigChoiceDialog({
<div className="mcp-choose-version__option-body">
<div className="mcp-choose-version__option-head">
<strong className="mcp-choose-version__option-label">{option.label}</strong>
<span className="chip">{sourceLabel(option)}</span>
{isRecommended ? (
<span className="chip chip--verified">{copy.detail.configChoice.recommended}</span>
) : null}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/features/mcp/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ const englishMcpCopy = {
ariaLabel: (title: string, serverName: string) => `${title} for ${serverName}`,
close: "Close config choice dialog",
recommended: "Recommended",
observedHarness: (label: string) => `Observed harness: ${label}`,
managedConfig: "Managed MCP config",
credentialInUrl: "Credential in URL",
noEnvironmentValues: "No environment values",
showPreview: "Show config preview",
Expand Down Expand Up @@ -370,6 +372,8 @@ export const mcpCopy = {
ariaLabel: (title: string, serverName: string) => `${serverName}:${title}`,
close: "关闭配置选择对话框",
recommended: "推荐",
observedHarness: (label: string) => `观察到的 harness:${label}`,
managedConfig: "托管 MCP 配置",
credentialInUrl: "URL 中包含凭据",
noEnvironmentValues: "没有环境变量值",
showPreview: "显示配置预览",
Expand Down