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
6 changes: 1 addition & 5 deletions e2e/oauth-connection-validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ for (const catalog of [false, true]) {
});
await page.goto(catalog ? APP.SERVER_CATALOG : APP.SERVERS);
const popupPromise = context.waitForEvent("page");
if (catalog) {
await page.getByRole("button", { name: "Actions for Validation server" }).click();
await page.getByRole("menuitem", { name: "Authorize", exact: true }).click();
}
if (!catalog) await page.getByRole("button", { name: "Authorize Validation server" }).click();
await page.getByRole("button", { name: "Authorize Validation server" }).click();
const popup = await popupPromise;
await popup.waitForURL(/\/oauth\/authorize\//);
authorized = true;
Expand Down
24 changes: 17 additions & 7 deletions e2e/server-catalog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,8 @@ test.describe("Server catalog page", () => {
).toHaveCount(0);
expect(sourceReads).toBe(0);
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
await expect(
page.getByRole("button", { name: "Expose components for Secret Service" }),
).toBeVisible();
await page.getByRole("button", { name: "Actions for Secret Service" }).click();
await expect(page.getByRole("menuitem", { name: "Expose components" })).toBeVisible();
});

for (const width of [1440, 390]) {
Expand Down Expand Up @@ -496,9 +495,14 @@ test.describe("Server catalog page", () => {
await expect(page).toHaveURL(/\/app\/gateways$/);
expect(createCalls).toBe(0);
await page.goto(APP.SERVER_CATALOG);
await page.getByRole("button", { name: "Expose components for Public Notes" }).click();
await page.getByRole("button", { name: "Actions for Public Notes" }).click();
await page.getByRole("menuitem", { name: "Expose components" }).click();
await expect(page.getByRole("checkbox", { name: /select search/i })).toBeVisible();
expect(registerCalls).toBe(1);
// Resumed exposure cancels back to its own page; only registration offers Skip.
await expect(page.getByRole("button", { name: "Skip", exact: true })).toHaveCount(0);
await page.getByRole("button", { name: "Cancel", exact: true }).click();
await expect(page.getByRole("heading", { name: "Public Notes", exact: true })).toBeVisible();
// The MCP Servers list offers the same continuation after a full page load.
await page.goto(APP.SERVERS);
const resume = page.getByRole("button", { name: "Expose components for Public Notes" });
Expand All @@ -509,16 +513,22 @@ test.describe("Server catalog page", () => {
await expect(resume).toBeFocused();
expect(associationCalls).toBe(checksBeforeExposure);
await resume.click();
await page.getByRole("button", { name: "Cancel", exact: true }).click();
await expect(resume).toBeFocused();
// Focus returns by script, so the tooltip must not read that as a hover.
await expect(page.getByRole("tooltip")).toHaveCount(0);
await resume.hover();
await expect(page.getByRole("tooltip")).toBeVisible();
await resume.click();
await page.getByRole("checkbox", { name: /select search/i }).check();
await page.getByRole("button", { name: "Expose components", exact: true }).click();
await expect(page).toHaveURL(/\/app\/gateways$/);
expect(createCalls).toBe(1);
expect(registerCalls).toBe(1);
await page.goto(APP.SERVER_CATALOG);
await expect(page.getByRole("heading", { name: "Public Notes", exact: true })).toBeVisible();
await expect(
page.getByRole("button", { name: "Expose components for Public Notes" }),
).toHaveCount(0);
await page.getByRole("button", { name: "Actions for Public Notes" }).click();
await expect(page.getByRole("menuitem", { name: "Expose components" })).toHaveCount(0);
});
}

Expand Down
31 changes: 0 additions & 31 deletions src/components/gateways/ExposeComponentsAction.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions src/components/gateways/ExposeComponentsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useRef, useState } from "react";
import { Settings } from "lucide-react";
import { useIntl } from "react-intl";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";

/** Opens the component exposure form. */
export function ExposeComponentsButton({
gatewayId,
name,
onClick,
}: {
gatewayId: string;
name: string;
onClick: () => void;
}) {
const intl = useIntl();
const triggerRef = useRef<HTMLButtonElement>(null);
const hoveredRef = useRef(false);
const [open, setOpen] = useState(false);
return (
<Tooltip
open={open}
onOpenChange={(next) => {
const trigger = triggerRef.current;
const openedByFocus =
!hoveredRef.current &&
trigger === document.activeElement &&
!trigger?.matches(":focus-visible");
if (next && openedByFocus) return;
setOpen(next);
}}
>
<TooltipTrigger asChild>
<Button
ref={triggerRef}
id={`expose-components-${gatewayId}`}
type="button"
variant="ghost"
size="icon-xs"
// Absorbs the 24px control into a 16px line so the row keeps its height.
className="-my-1 text-muted-foreground"
aria-label={intl.formatMessage({ id: "mcpServer.exposure.actionFor" }, { name })}
// Radix opens on pointermove.
onPointerMove={() => (hoveredRef.current = true)}
onPointerLeave={() => (hoveredRef.current = false)}
onClick={onClick}
>
<Settings className="size-3.5" aria-hidden="true" />
</Button>
</TooltipTrigger>
<TooltipContent>{intl.formatMessage({ id: "mcpServer.exposure.tooltip" })}</TooltipContent>
</Tooltip>
);
}
18 changes: 18 additions & 0 deletions src/components/gateways/ExposeComponentsForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ describe("ExposeComponentsForm", () => {
).toBeInTheDocument();
});

it("navigates to Virtual Servers from the intro link", async () => {
const user = userEvent.setup();
renderWithProviders(<ExposeComponentsForm {...defaultProps} />);

await user.click(await screen.findByRole("button", { name: "virtual server" }));

expect(window.location.pathname).toBe("/app/gateways");
});

it("explains inbound OAuth in a popover", async () => {
const user = userEvent.setup();
renderWithProviders(<ExposeComponentsForm {...defaultProps} />);

await user.click(await screen.findByRole("button", { name: "OAuth information" }));

expect(await screen.findByText(/Inbound clients are the AI clients/i)).toBeVisible();
});

it("should render action buttons", async () => {
renderWithProviders(<ExposeComponentsForm {...defaultProps} />);

Expand Down
41 changes: 34 additions & 7 deletions src/components/gateways/ExposeComponentsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Switch } from "@/components/ui/switch";
import { Label } from "@/components/ui/label";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import {
Table,
TableBody,
Expand All @@ -33,6 +34,8 @@ import type { Visibility } from "@/types/server";
interface ExposeComponentsFormProps {
gatewayId: string;
gatewayName: string;
/** Set when the caller can return the user where they came from: offers Cancel instead of Skip. */
onCancel?: () => void;
onSubmittingChange?: (isSubmitting: boolean) => void;
visibility?: Visibility;
teamId?: string;
Expand Down Expand Up @@ -140,6 +143,7 @@ function MCPObjectsTable({
export function ExposeComponentsForm({
gatewayId,
gatewayName,
onCancel,
onSubmittingChange,
visibility = "public",
teamId,
Expand Down Expand Up @@ -348,7 +352,15 @@ export function ExposeComponentsForm({

<p className="text-sm leading-6 text-neutral-600 dark:text-neutral-400">
ContextForge will create an endpoint that exposes selected components to AI clients as a{" "}
<span className="font-medium text-cyan-700 dark:text-cyan-400">virtual server</span>.
<Button
type="button"
variant="link"
onClick={() => navigate("/app/gateways")}
className="inline h-auto p-0 font-medium text-cyan-700 decoration-cyan-300 underline-offset-4 transition hover:text-cyan-800 hover:no-underline dark:text-cyan-400 dark:decoration-cyan-700 dark:hover:text-cyan-300"
>
virtual server
</Button>
Comment thread
a-effort marked this conversation as resolved.
Resolved
.
</p>
</div>

Expand Down Expand Up @@ -604,10 +616,25 @@ export function ExposeComponentsForm({
<h3 className="text-base font-medium text-neutral-950 dark:text-neutral-50">
Require OAuth for inbound clients
</h3>
<Info
className="h-4 w-4 text-neutral-500 dark:text-neutral-500"
aria-label="OAuth information"
/>
<Popover>
<PopoverTrigger
type="button"
aria-label="OAuth information"
className="rounded text-neutral-500 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-neutral-500"
>
<Info className="h-4 w-4" aria-hidden="true" />
</PopoverTrigger>
<PopoverContent side="right" className="w-auto max-w-xs space-y-2 p-3 text-sm">
Comment thread
a-effort marked this conversation as resolved.
Resolved
<p>
Inbound clients are the AI clients that connect to this virtual server, which is
separate from how ContextForge authenticates to the MCP server behind it.
</p>
<p>
With this on, ContextForge rejects unauthenticated requests to the endpoint and
publishes RFC 9728 metadata so OAuth-aware clients can discover how to authorize.
</p>
</PopoverContent>
</Popover>
</div>
<div className="flex items-start gap-3">
<Switch
Expand Down Expand Up @@ -640,11 +667,11 @@ export function ExposeComponentsForm({
<Button
type="button"
variant="ghost"
onClick={handleSkip}
onClick={onCancel ?? handleSkip}
disabled={isCreating}
className="h-10 rounded-md px-3 text-sm font-medium text-neutral-700 hover:bg-neutral-100 hover:text-neutral-950 dark:text-neutral-300 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"
>
Skip
{onCancel ? "Cancel" : "Skip"}
</Button>
<Button
type="button"
Expand Down
3 changes: 3 additions & 0 deletions src/components/gateways/GatewayExposureStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { ExposeComponentsForm } from "./ExposeComponentsForm";
export function GatewayExposureStep({
gatewayId,
onBack,
onCancel,
}: {
gatewayId: string;
onBack: () => void;
onCancel?: () => void;
}) {
const intl = useIntl();
const containerRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -56,6 +58,7 @@ export function GatewayExposureStep({
<ExposeComponentsForm
gatewayId={gatewayId}
gatewayName={data.name}
onCancel={onCancel}
onSubmittingChange={setIsCreating}
visibility={data.visibility ?? "private"}
teamId={data.teamId ?? undefined}
Expand Down
13 changes: 4 additions & 9 deletions src/components/gateways/SourceSelection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,19 @@ describe("SourceSelection", () => {
expect(checkbox).toBeEnabled();
expect(
await screen.findByRole("button", {
name: "OAuth source status: Authorization status unavailable. Show details",
name: "Check status for OAuth source",
}),
).toBeInTheDocument();

await user.click(checkbox);
expect(checkbox).toBeChecked();
await user.click(
screen.getByRole("button", {
name: "OAuth source status: Authorization status unavailable. Show details",
}),
);
await user.click(await screen.findByRole("button", { name: "Retry status for OAuth source" }));
await user.click(screen.getByRole("button", { name: "Check status for OAuth source" }));

expect(
await user.click(
await screen.findByRole("button", {
name: "OAuth source status: Authorization required. Show details",
}),
).toBeInTheDocument();
);
expect(
await screen.findByText(
"Authorize from Server catalog or MCP Servers. Your wizard selections will be preserved.",
Expand Down
Loading
Loading