fix(webui): keep MCP connection rows compact (NAN-321)

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-24 20:11:31 +08:00
1 parent 8af2d396ab
commit 60420b45c8
4 files changed
+123 -48

No files matched your search

@@ -547,6 +547,7 @@ function McpAppsCatalogRow({
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
const [managementOpen, setManagementOpen] = useState(false);
const [managementTab, setManagementTab] = useState<McpManagementTab>("overview");
const connectionStatusId = useId();
useEffect(() => {
if (!openConnection) return;
setManagementTab("connection");
@@ -574,6 +575,7 @@ function McpAppsCatalogRow({
const runtimeConnected = !toggleable && preset.runtime_status === "connected";
const runtimeConnecting = !toggleable && preset.runtime_status === "connecting";
const runtimeFailed = !toggleable && preset.installed && preset.runtime_status === "failed";
const connecting = Boolean(oauthFlow) || (runtimeConnecting && configuredInstalled);
const statusLabel = toggleable
? tx("settings.nanobotFeatures.enabled", "Enabled")
: runtimeConnected
@@ -615,8 +617,9 @@ function McpAppsCatalogRow({
<button
type="button"
aria-label={preset.display_name}
aria-describedby={connecting ? connectionStatusId : undefined}
onClick={() => openManagement()}
className="flex min-w-0 flex-[1_1_8rem] items-center gap-3 rounded-control text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
className="flex min-w-0 flex-[1_1_6rem] items-center gap-3 rounded-control text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<McpPresetLogo preset={preset} showBrandLogos={showBrandLogos} />
<div className="min-w-0 flex-1">
@@ -631,18 +634,21 @@ function McpAppsCatalogRow({
) : null}
</div>
<p
id={connectionStatusId}
className={cn(
"mt-0.5 flex min-w-0 items-center gap-1.5 text-[12.5px] leading-5 text-muted-foreground",
runtimeFailed && "font-medium text-destructive",
!connecting && runtimeFailed && "font-medium text-destructive",
)}
>
{runtimeFailed ? (
{connecting ? (
<Loader2 className="h-3.5 w-3.5 shrink-0 animate-spin motion-reduce:animate-none" aria-hidden />
) : runtimeFailed ? (
<TriangleAlert className="h-3.5 w-3.5 shrink-0" aria-hidden />
) : null}
<span className="truncate">
{runtimeFailed ? failureLabel : detail}
{connecting ? tx("settings.mcp.connectingLabel", "Connecting…") : runtimeFailed ? failureLabel : detail}
</span>
{!runtimeFailed && agentPlugin && description && preset.requires ? (
{!connecting && !runtimeFailed && agentPlugin && description && preset.requires ? (
<span className="min-w-0 truncate">{preset.requires}</span>
) : null}
</p>
@@ -650,39 +656,22 @@ function McpAppsCatalogRow({
</button>
<div className="ml-auto flex shrink-0 items-center gap-1">
{oauthFlow ? (
<>
<AppsActionButton
ariaLabel={t("settings.mcp.connectingAccount", {
name: preset.display_name,
defaultValue: "Connecting {{name}}",
})}
visibleLabel={tx("settings.mcp.connectingLabel", "Connecting…")}
busy
/>
<AppsActionButton
ariaLabel={tx("settings.actions.cancel", "Cancel")}
visibleLabel={tx("settings.actions.cancel", "Cancel")}
tone="danger"
onClick={onOAuthCancel}
/>
</>
<AppsActionButton
ariaLabel={tx("settings.actions.cancel", "Cancel")}
visibleLabel={tx("settings.actions.cancel", "Cancel")}
tone="danger"
onClick={onOAuthCancel}
/>
) : runtimeConnecting && configuredInstalled ? (
<>
<AppsActionButton
ariaLabel={`${preset.display_name}: ${tx("settings.mcp.connectingLabel", "Connecting…")}`}
visibleLabel={tx("settings.mcp.connectingLabel", "Connecting…")}
busy
/>
<AppsActionButton
ariaLabel={tx("settings.mcp.remove", "Remove")}
busy={removeBusy}
disabled={busy && !removeBusy}
tone="danger"
onClick={() => onAction("remove", preset.name)}
>
<Trash2 className="h-4 w-4" aria-hidden />
</AppsActionButton>
</>
<AppsActionButton
ariaLabel={tx("settings.mcp.remove", "Remove")}
busy={removeBusy}
disabled={busy && !removeBusy}
tone="danger"
onClick={() => onAction("remove", preset.name)}
>
<Trash2 className="h-4 w-4" aria-hidden />
</AppsActionButton>
) : runtimeFailed ? (
<AppsActionButton
ariaLabel={t("settings.mcp.manageTitle", {
+4 -4
View File
@@ -276,7 +276,7 @@ describe("SettingsView Apps catalog", () => {
expect(screen.getByRole("status")).toHaveTextContent(
"Complete sign-in in the browser window.",
);
expect(screen.getByRole("button", { name: "Connecting Xmind" })).toHaveTextContent(
expect(screen.getByRole("button", { name: "Xmind" })).toHaveAccessibleDescription(
"Connecting…",
);
expect(screen.getByRole("button", { name: "Cancel" })).toBeInTheDocument();
@@ -426,8 +426,8 @@ describe("SettingsView Apps catalog", () => {
renderSettingsView({ initialSection: "apps" });
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
expect(await screen.findByRole("button", { name: "Xmind: Connecting…" }))
.toHaveTextContent("Connecting…");
expect(await screen.findByRole("button", { name: "Xmind" }))
.toHaveAccessibleDescription("Connecting…");
expect(await screen.findByRole(
"button",
{ name: "Manage Xmind" },
@@ -738,7 +738,7 @@ describe("SettingsView Apps catalog", () => {
await connectXmind();
const cancelButton = await screen.findByRole("button", { name: "Cancel" });
expect(screen.getByRole("button", { name: "Connecting Xmind" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Xmind" })).toHaveAccessibleDescription("Connecting…");
popup.closed = true;
fireEvent.click(cancelButton);