Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: unify the mcp and access consent page (#21517)
ecmadaoa6c227d2c30a
diff --git a/frontend/src/components/mcp/MCPCapabilityList.tsx b/frontend/src/components/mcp/MCPCapabilityList.tsxnew file mode 100644index 0000000000..4f523839ea--- /dev/null+++ b/frontend/src/components/mcp/MCPCapabilityList.tsx@@ -0,0 +1,144 @@+import { Check, Minus } from "lucide-react";+import { Fragment } from "react";+import { useTranslation } from "react-i18next";+import type {+ MCPCapabilityRow,+ MCPCapabilityTier,+} from "@/components/mcp/mcpCapabilityRows";+import {+ isRowServed,+ MCP_CAPABILITY_TIERS,+ mcpRowKey,+ mcpTierKey,+ rowsInTier,+} from "@/components/mcp/mcpCapabilityRows";+import type { MCPServingMode } from "@/components/mcp/mcpPolicy";+import type { BadgeProps } from "@/components/ui/badge";+import { Badge } from "@/components/ui/badge";+import { Separator } from "@/components/ui/separator";+import { cn } from "@/lib/utils";++const TIER_VARIANT: Record<MCPCapabilityTier, BadgeProps["variant"]> = {+ read: "success",+ write: "warning",+};++interface Props {+ readonly mode: MCPServingMode;+ readonly details: boolean;+ readonly tierDividers?: boolean;+ readonly floor?: boolean;+}++/**+ * The capability rows shared by policy configuration and consent.+ *+ * Every consumer shows the same capability boundary: what the selected mode+ * serves, where it stops, and what it refuses.+ */+export function MCPCapabilityList({+ mode,+ details,+ tierDividers = false,+ floor = false,+}: Props) {+ const { t } = useTranslation();+ return (+ <>+ <ul role="list" className="flex flex-col gap-y-2">+ {MCP_CAPABILITY_TIERS.map((tier) => (+ <Fragment key={tier}>+ {rowsInTier(tier).map((row) => (+ <CapabilityRow+ key={row.id}+ row={row}+ served={isRowServed(mode, row)}+ details={details}+ />+ ))}+ {tierDividers && <TierDivider tier={tier} />}+ </Fragment>+ ))}+ </ul>+ {floor && (+ <p className="bg-error/5 px-3 py-2 text-sm text-error my-2">+ <span className="font-medium">+ {t("settings.mcp.ladder.floor.label")}+ </span>{" "}+ {t("settings.mcp.ladder.floor.text")}+ </p>+ )}+ </>+ );+}++function CapabilityRow({+ row,+ served,+ details,+}: {+ row: MCPCapabilityRow;+ served: boolean;+ details: boolean;+}) {+ const { t } = useTranslation();+ return (+ <li className="flex items-start gap-x-2 px-1 py-1">+ <span+ className={cn(+ "mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full",+ served ? "bg-success/10 text-success" : "bg-error/10 text-error"+ )}+ >+ {served ? (+ <Check className="size-3" aria-hidden="true" />+ ) : (+ <Minus className="size-3" aria-hidden="true" />+ )}+ <span className="sr-only">+ {served+ ? t("settings.mcp.ladder.mark.allowed")+ : t("settings.mcp.ladder.mark.refused")}+ </span>+ </span>+ <div className="flex min-w-0 flex-col gap-1">+ <div className="flex flex-wrap items-center gap-2">+ <span+ className={cn("text-sm", served ? "text-main" : "text-control")}+ >+ {t(mcpRowKey(row, "title"))}+ </span>+ {served && (+ <Badge+ variant={TIER_VARIANT[row.tier]}+ className="px-2 py-0 text-xs"+ >+ {t(mcpTierKey(row.tier, "tier"))}+ </Badge>+ )}+ </div>+ {details && (+ <p className="text-xs leading-5 text-control-light">+ {t(mcpRowKey(row, "details"))}+ </p>+ )}+ </div>+ </li>+ );+}++function TierDivider({ tier }: { tier: MCPCapabilityTier }) {+ const { t } = useTranslation();+ return (+ <li+ role="presentation"+ className="flex items-center gap-x-2 py-2 text-xs text-control-light"+ >+ <Separator className="flex-1" />+ <span className="uppercase font-medium text-main tracking-wide">+ {t(mcpTierKey(tier, "stops"))}+ </span>+ <Separator className="flex-1" />+ </li>+ );+}diff --git a/frontend/src/components/mcp/MCPModeBadge.tsx b/frontend/src/components/mcp/MCPModeBadge.tsxindex ba239adccd..448efc031d 100644--- a/frontend/src/components/mcp/MCPModeBadge.tsx+++ b/frontend/src/components/mcp/MCPModeBadge.tsx@@ -32,7 +32,7 @@ export function MCPModeBadge({ mode, describedAs }: Props) {const { icon: Icon, badge } = MCP_MODE_PRESENTATION[mode];const label = t(mcpModeKey(mode, "title"));return (- <Badge variant={badge} className="gap-x-1">+ <Badge variant={badge} className="gap-x-1 whitespace-nowrap"><Icon className="size-3.5 shrink-0" aria-hidden="true" />{/* Carried as text rather than aria-label: a Badge renders a bare span,and ARIA forbids naming its implicit `generic` role, so a label putdiff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex a44235099e..9184f552ec 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -254,7 +254,6 @@"address": "Address","admin": "Admin","all": "All",- "allow": "Allow","and": "and","approve": "Approve","approved": "Approved",@@ -1627,6 +1626,7 @@},"oauth2": {"consent": {+ "allow-access": "Allow access","description": "{{clientName}} is requesting access to your account","error-client-not-found": "Client not found","error-load-failed": "Failed to load client information",@@ -1644,13 +1644,6 @@"policy-label": "Workspace policy","title": "MCP access is turned off"},- "line": {- "audit": "Audited actions carry an MCP tag, and anything the policy refuses is streamed to stdout when audit logging to stdout is enabled",- "capped-read-only": "Capped by your own Bytebase permissions, and by what Bytebase can check on each database engine — where it cannot show a statement is a read, no query runs at all",- "capped-read-write": "Capped by your own Bytebase permissions, and by what Bytebase supports for each database engine and each operation",- "masking": "Your masking exemptions do not apply to this session",- "no-write": "No changes, rollouts, exports or database management"- },"title": "This session may","undisclosed": {"line": {@@ -2758,8 +2751,10 @@}},"policy": {+ "audit": "MCP operations are recorded in Bytebase audit logs.",+ "bound": "Every MCP session is limited by the connected user's Bytebase permissions and the target database engine's supported operations.","current": "Current policy: {{mode}}",- "description": "This is the maximum any MCP session may do in this workspace. Sessions are also capped by each user's permissions, and policy refusals are streamed to stdout when audit logging to stdout is enabled.",+ "description": "{{bound}} {{audit}}","edit": "Edit policy","loading": "Reading the access policy…","masking": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 8925c0ec53..6e9306a742 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -254,7 +254,6 @@"address": "Dirección","admin": "Administrador","all": "Todos",- "allow": "Permitir","and": "y","approve": "Aprobar","approved": "Aprobado",@@ -1627,6 +1626,7 @@},"oauth2": {"consent": {+ "allow-access": "Permitir acceso","description": "{{clientName}} está solicitando acceso a tu cuenta","error-client-not-found": "Cliente no encontrado","error-load-failed": "Error al cargar la información del cliente",@@ -1644,13 +1644,6 @@"policy-label": "Política del espacio de trabajo","title": "El acceso MCP está desactivado"},- "line": {- "audit": "Las acciones auditadas llevan una etiqueta MCP, y lo que la política rechaza se envía a la salida estándar cuando el registro de auditoría en la salida estándar está habilitado",- "capped-read-only": "Limitado por sus propios permisos de Bytebase y por lo que Bytebase puede comprobar en cada motor: donde no puede demostrar que una sentencia es de lectura, no se ejecuta ninguna consulta",- "capped-read-write": "Limitado por sus propios permisos de Bytebase y por lo que Bytebase admite para cada motor de base de datos y cada operación",- "masking": "Sus exenciones de enmascaramiento no se aplican a esta sesión",- "no-write": "Sin cambios, despliegues, exportaciones ni administración de bases de datos"- },"title": "Esta sesión puede","undisclosed": {"line": {@@ -2758,8 +2751,10 @@}},"policy": {+ "audit": "Las operaciones de MCP se registran en los registros de auditoría de Bytebase.",+ "bound": "Cada sesión MCP está limitada por los permisos de Bytebase del usuario conectado y por las operaciones que admite el motor de base de datos de destino.","current": "Política actual: {{mode}}",- "description": "Lo máximo que puede hacer aquí cualquier sesión MCP. Las sesiones también están limitadas por los permisos de cada usuario, y las denegaciones de la política se envían a la salida estándar cuando el registro de auditoría en la salida estándar está habilitado.",+ "description": "{{bound}} {{audit}}","edit": "Editar política","loading": "Leyendo la política de acceso…","masking": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 2c31ccc7c1..60073b33e5 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -254,7 +254,6 @@"address": "接続先","admin": "管理者","all": "全て",- "allow": "許可","and": "と","approve": "承認","approved": "承認済み",@@ -1627,6 +1626,7 @@},"oauth2": {"consent": {+ "allow-access": "アクセスを許可","description": "{{clientName}} があなたのアカウントへのアクセスを要求しています","error-client-not-found": "クライアントが見つかりません","error-load-failed": "クライアント情報の読み込みに失敗しました",@@ -1644,13 +1644,6 @@"policy-label": "ワークスペースポリシー","title": "MCP アクセスはオフです"},- "line": {- "audit": "監査対象の操作には MCP タグが付き、監査ログの標準出力への出力が有効な場合、ポリシーが拒否したものは標準出力に出力されます",- "capped-read-only": "上限はあなた自身の Bytebase 権限と、Bytebase が各データベースエンジンで確認できる範囲。ステートメントが読み取りだと示せないエンジンでは、クエリは一切実行されません",- "capped-read-write": "上限はあなた自身の Bytebase 権限と、Bytebase が各データベースエンジンおよび各操作にどこまで対応しているか",- "masking": "あなたのマスキング適用除外はこのセッションには適用されません",- "no-write": "変更・ロールアウト・エクスポート・データベース管理はできない"- },"title": "このセッションでできること","undisclosed": {"line": {@@ -2758,8 +2751,10 @@}},"policy": {+ "audit": "MCP 操作は Bytebase の監査ログに記録されます。",+ "bound": "各 MCP セッションは、接続ユーザーの Bytebase 権限と対象データベースエンジンが対応する操作によって制限されます。","current": "現在のポリシー:{{mode}}",- "description": "このワークスペースで MCP セッションが実行できる操作の上限です。各セッションは接続ユーザー自身の権限によっても制限され、監査ログの標準出力への出力が有効な場合、ポリシーによる拒否は標準出力に出力されます。",+ "description": "{{bound}}{{audit}}","edit": "ポリシーを編集","loading": "アクセスポリシーを読み込んでいます…","masking": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex be8335b4d0..c389b9baba 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -254,7 +254,6 @@"address": "Địa chỉ","admin": "Quản trị viên","all": "Tất cả",- "allow": "Cho phép","and": "và","approve": "Phê duyệt","approved": "Đã phê duyệt",@@ -1627,6 +1626,7 @@},"oauth2": {"consent": {+ "allow-access": "Cho phép truy cập","description": "{{clientName}} đang yêu cầu truy cập vào tài khoản của bạn","error-client-not-found": "Không tìm thấy client","error-load-failed": "Tải thông tin client thất bại",@@ -1644,13 +1644,6 @@"policy-label": "Chính sách không gian làm việc","title": "Truy cập MCP đang tắt"},- "line": {- "audit": "Hành động được kiểm toán mang nhãn MCP, và những gì chính sách từ chối được ghi vào đầu ra chuẩn khi bật ghi nhật ký kiểm toán vào đầu ra chuẩn",- "capped-read-only": "Giới hạn bởi quyền Bytebase của chính bạn, và bởi những gì Bytebase có thể kiểm tra trên từng engine — nơi không thể chứng minh một câu lệnh là đọc, không truy vấn nào chạy",- "capped-read-write": "Giới hạn bởi quyền Bytebase của chính bạn và bởi mức hỗ trợ của Bytebase cho từng loại cơ sở dữ liệu và từng thao tác",- "masking": "Các miễn trừ che dữ liệu của bạn không áp dụng cho phiên này",- "no-write": "Không thay đổi, triển khai, xuất dữ liệu hay quản trị cơ sở dữ liệu"- },"title": "Phiên này có thể","undisclosed": {"line": {@@ -2758,8 +2751,10 @@}},"policy": {+ "audit": "Các thao tác MCP được ghi lại trong nhật ký kiểm toán của Bytebase.",+ "bound": "Mỗi phiên MCP bị giới hạn bởi quyền Bytebase của người dùng đã kết nối và các thao tác mà engine cơ sở dữ liệu đích hỗ trợ.","current": "Chính sách hiện tại: {{mode}}",- "description": "Mức tối đa mà bất kỳ phiên MCP nào có thể làm ở đây. Các phiên còn bị giới hạn bởi quyền của từng người dùng, và những lần từ chối theo chính sách được ghi vào đầu ra chuẩn khi bật ghi nhật ký kiểm toán vào đầu ra chuẩn.",+ "description": "{{bound}} {{audit}}","edit": "Sửa chính sách","loading": "Đang đọc chính sách truy cập…","masking": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex a4395a84e7..823110f44c 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -254,7 +254,6 @@"address": "地址","admin": "管理员","all": "全部",- "allow": "允许","and": "和","approve": "批准","approved": "已批准",@@ -1627,6 +1626,7 @@},"oauth2": {"consent": {+ "allow-access": "允许访问","description": "{{clientName}} 正在请求访问您的账户","error-client-not-found": "未找到客户端","error-load-failed": "加载客户端信息失败",@@ -1644,13 +1644,6 @@"policy-label": "工作空间策略","title": "MCP 访问已关闭"},- "line": {- "audit": "被审计的操作会带上 MCP 标记,启用审计日志输出到标准输出时,策略拒绝的操作会输出到标准输出",- "capped-read-only": "上限取决于你自己的 Bytebase 权限,以及 Bytebase 在各数据库引擎上能确认的范围——在无法确认语句是读取的引擎上,任何查询都不会执行",- "capped-read-write": "上限取决于你自己的 Bytebase 权限,以及 Bytebase 对每种数据库引擎和每种操作的支持程度",- "masking": "你的脱敏豁免对此会话不生效",- "no-write": "不能变更、部署、导出或管理数据库"- },"title": "此会话可以","undisclosed": {"line": {@@ -2758,8 +2751,10 @@}},"policy": {+ "audit": "MCP 操作会记录在 Bytebase 审计日志中。",+ "bound": "每个 MCP 会话都受连接用户的 Bytebase 权限以及目标数据库引擎支持的操作限制。","current": "当前策略:{{mode}}",- "description": "MCP 会话在此最多能做的事。每个会话还受各用户自身权限的限制;启用审计日志输出到标准输出时,策略拒绝会输出到标准输出。",+ "description": "{{bound}}{{audit}}","edit": "编辑策略","loading": "正在读取访问策略…","masking": {diff --git a/frontend/src/routes/auth/MCPConsentCeiling.tsx b/frontend/src/routes/auth/MCPConsentCeiling.tsxindex c977e0ec60..92e817219f 100644--- a/frontend/src/routes/auth/MCPConsentCeiling.tsx+++ b/frontend/src/routes/auth/MCPConsentCeiling.tsx@@ -1,8 +1,11 @@-import { Check, EyeOff, Info, ScrollText, X } from "lucide-react";+import { Info, ScrollText } from "lucide-react";+import { useState } from "react";import { useTranslation } from "react-i18next";-import { mcpRowKey, servedRows } from "@/components/mcp/mcpCapabilityRows";+import { MCPCapabilityList } from "@/components/mcp/MCPCapabilityList";import type { MCPServingMode } from "@/components/mcp/mcpPolicy";import { Alert } from "@/components/ui/alert";+import { Badge } from "@/components/ui/badge";+import { Button } from "@/components/ui/button";import { MCPSetting_Capability } from "@/types/proto-es/v1/setting_service_pb";import type { MCPConsentLine } from "./MCPConsentPolicyCard";import { MCPConsentPolicyCard } from "./MCPConsentPolicyCard";@@ -30,57 +33,21 @@ export function MCPConsentCeiling({dataMaskingAvailable,}: Props) {const { t } = useTranslation();+ const [details, setDetails] = useState(false);- const readWrite = mode === MCPSetting_Capability.READ_WRITE;const lines: MCPConsentLine[] = [- ...servedRows(mode).map((row) => ({- key: row.id,- icon: <Check className="size-4 text-success" />,- mark: t("settings.mcp.ladder.mark.allowed"),- text: t(mcpRowKey(row, "title")),- })),- // One line for the whole unserved tier rather than five muted rows: this- // screen is an approval, not a comparison, and the person is deciding- // about what the session gains.- ...(readWrite- ? []- : [- {- // No mark: the sentence states the prohibition itself, and- // prefixing "Not allowed" would double the negative.- key: "no-write",- icon: <X className="size-4 text-error" />,- text: t("oauth2.consent.mcp.line.no-write"),- },- ]),// A bound, not a grant: neutral glyph and no mark, so it is not counted- // among the rows above it. Scoped by mode because Read-only's statement- // clamp is one rule with one consequence, while Read-write's answer varies- // by engine and by operation — so that line states the bound and stops.+ // among the rows above it. The capability list holds mode-specific details;+ // this shared line gives the constraint that applies to every MCP session.{key: "capped",icon: <Info className="size-4 text-control-light" />,- text: readWrite- ? t("oauth2.consent.mcp.line.capped-read-write")- : t("oauth2.consent.mcp.line.capped-read-only"),+ text: t("settings.mcp.policy.bound"),},- // Both halves, because the line promises a restriction. The toggle- // withholds unmasking exemptions from MCP sessions, which changes nothing- // where masking does not run at all — asserting it there would tell the- // person approving that their data is covered when it is not.- ...(ignoreMaskingExemptions && dataMaskingAvailable- ? [- {- key: "masking",- icon: <EyeOff className="size-4 text-control-light" />,- text: t("oauth2.consent.mcp.line.masking"),- },- ]- : []),{key: "audit",icon: <ScrollText className="size-4 text-control-light" />,- text: t("oauth2.consent.mcp.line.audit"),+ text: t("settings.mcp.policy.audit"),},];@@ -89,10 +56,31 @@ export function MCPConsentCeiling({<MCPConsentPolicyCardlabel={t("oauth2.consent.mcp.title")}mode={mode}+ modeAddon={+ ignoreMaskingExemptions && dataMaskingAvailable ? (+ <Badge variant="secondary" className="whitespace-nowrap">+ {t("settings.mcp.policy.masking.badge")}+ </Badge>+ ) : undefined+ }+ headerAction={+ <Button+ appearance="link"+ size="sm"+ aria-expanded={details}+ onClick={() => setDetails(!details)}+ >+ {details+ ? t("settings.mcp.ladder.hide-details")+ : t("settings.mcp.ladder.show-details")}+ </Button>+ }lines={lines}- />+ >+ <MCPCapabilityList mode={mode} details={details} tierDividers floor />+ </MCPConsentPolicyCard>- {readWrite && (+ {mode === MCPSetting_Capability.READ_WRITE && (<Alertvariant="warning"description={t("oauth2.consent.mcp.write-caution")}diff --git a/frontend/src/routes/auth/MCPConsentPolicyCard.tsx b/frontend/src/routes/auth/MCPConsentPolicyCard.tsxindex 97392116d5..9b51273a6c 100644--- a/frontend/src/routes/auth/MCPConsentPolicyCard.tsx+++ b/frontend/src/routes/auth/MCPConsentPolicyCard.tsx@@ -5,13 +5,6 @@ import type { MCPMode } from "@/components/mcp/mcpPolicy";export interface MCPConsentLine {readonly key: string;readonly icon: ReactNode;- /**- * What the mark means, for a reader who cannot see it. Allowed and refused- * are otherwise carried by a green check against a red cross — color and- * glyph, both visual — on the screen where someone decides whether to hand an- * agent access.- */- readonly mark?: string;readonly text: string;}@@ -19,7 +12,10 @@ interface Props {readonly label: string;/** Omitted by the panel for a ceiling this build has no name for. */readonly mode?: MCPMode;- readonly lines: readonly MCPConsentLine[];+ readonly headerAction?: ReactNode;+ readonly modeAddon?: ReactNode;+ readonly lines?: readonly MCPConsentLine[];+ readonly children?: ReactNode;}/**@@ -27,24 +23,43 @@ interface Props {* means for the session being approved. Shared so the three screens cannot* drift apart.*/-export function MCPConsentPolicyCard({ label, mode, lines }: Props) {+export function MCPConsentPolicyCard({+ label,+ mode,+ headerAction,+ modeAddon,+ lines,+ children,+}: Props) {return (<div className="bg-control-bg rounded-sm p-4 flex flex-col gap-3">- <div className="flex items-center justify-between gap-x-2">- <p className="text-sm text-control-light">{label}</p>- {mode !== undefined && <MCPModeBadge mode={mode} />}+ <div className="flex flex-col gap-2">+ <div className="flex items-center gap-2">+ <p className="text-sm text-control-light">{label}</p>+ {headerAction && (+ <div className="ml-auto shrink-0">{headerAction}</div>+ )}+ </div>+ {mode !== undefined && (+ <div className="flex max-w-full flex-wrap items-center gap-2">+ <MCPModeBadge mode={mode} />+ {modeAddon}+ </div>+ )}</div>- <ul role="list" className="text-sm text-main flex flex-col gap-2">- {lines.map((line) => (- <li key={line.key} className="flex items-start gap-2">- <span className="mt-0.5 shrink-0" aria-hidden="true">- {line.icon}- </span>- {line.mark && <span className="sr-only">{line.mark}</span>}- <span>{line.text}</span>- </li>- ))}- </ul>+ {children}+ {lines && (+ <ul role="list" className="text-sm text-main flex flex-col gap-2">+ {lines.map((line) => (+ <li key={line.key} className="flex items-start gap-2">+ <span className="mt-0.5 shrink-0" aria-hidden="true">+ {line.icon}+ </span>+ <span>{line.text}</span>+ </li>+ ))}+ </ul>+ )}</div>);}diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsxindex 7e044f7f26..23b5f19e8d 100644--- a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx+++ b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx@@ -597,39 +597,94 @@ describe("OAuth2ConsentPage", () => {handle.unmount();});- test("a read-only ceiling says what the session may not do", async () => {+ test("a read-only ceiling starts compact and can reveal the complete MCP policy boundary", async () => {const { container, unmount } = await renderWithCeiling({capability: 3,ignoreMaskingExemptions: false,});expect(container.textContent).toContain("settings.mcp.ladder.row.read-schemas.title");- expect(container.textContent).toContain("oauth2.consent.mcp.line.no-write");- expect(container.textContent).not.toContain("settings.mcp.ladder.row.run-statements.title");+ expect(container.textContent).not.toContain(+ "settings.mcp.ladder.row.read-schemas.details"+ );+ expect(container.textContent).toContain(+ "settings.mcp.ladder.row.run-statements.title"+ );+ expect(container.textContent).not.toContain(+ "settings.mcp.ladder.row.run-statements.details"+ );+ expect(container.textContent).toContain("settings.mcp.ladder.stops.read");+ expect(container.textContent).toContain("settings.mcp.ladder.floor.text");+ expect(container.textContent).not.toContain("oauth2.consent.mcp.line.no-write");// The masking line is the toggle's, not the ceiling's.expect(container.textContent).not.toContain("oauth2.consent.mcp.line.masking");- expect(container.textContent).toContain("common.allow");+ expect(container.textContent).toContain("settings.mcp.ladder.show-details");+ expect(container.textContent).toContain("oauth2.consent.allow-access");++ const detailsAction = [...container.querySelectorAll("button")].find(+ (button) =>+ button.textContent?.includes("settings.mcp.ladder.show-details")+ );+ const sessionTitle = [...container.querySelectorAll("p")].find((node) =>+ node.textContent?.includes("oauth2.consent.mcp.title")+ );+ const modeBadge = [...container.querySelectorAll("span")].find((node) =>+ node.textContent?.includes("settings.mcp.policy.mode.read-only.title")+ );+ expect(detailsAction).toHaveAttribute("aria-expanded", "false");+ expect(detailsAction?.parentElement).toHaveClass("ml-auto", "shrink-0");+ expect(sessionTitle?.parentElement).toHaveClass("items-center", "gap-2");+ expect(sessionTitle?.parentElement?.parentElement).toHaveClass(+ "flex-col",+ "gap-2"+ );+ expect(modeBadge).toHaveClass("whitespace-nowrap");+ expect(modeBadge?.parentElement).toHaveClass(+ "flex-wrap",+ "max-w-full"+ );+ expect(modeBadge?.parentElement).not.toHaveClass("ml-auto", "xl:ml-auto");+ act(() => detailsAction?.click());++ expect(container.textContent).toContain(+ "settings.mcp.ladder.row.read-schemas.details"+ );+ expect(container.textContent).toContain(+ "settings.mcp.ladder.row.run-statements.details"+ );+ expect(container.textContent).toContain("settings.mcp.ladder.hide-details");+ expect(detailsAction).toHaveAttribute("aria-expanded", "true");+ unmount();+ });++ test("uses the broad responsive consent-card width", async () => {+ const { container, unmount } = await renderWithCeiling({+ capability: 3,+ ignoreMaskingExemptions: false,+ });++ expect(container.firstElementChild).toHaveClass(+ "w-full",+ "max-w-5xl",+ "px-4",+ "md:w-3/5",+ "lg:w-1/2",+ "lg:px-0"+ );unmount();});- // The row titles carry no caveats, so this bound is the only thing limiting- // the check marks. It has to be the RIGHT bound: the statement clamp it- // describes runs only under Read-only, so claiming it under Read-write would- // promise an approver that no query runs where writes execute unverified.- test("each ceiling states the bound that holds for it", async () => {+ test("each ceiling states the shared policy bound", async () => {const readOnly = await renderWithCeiling({capability: 3,ignoreMaskingExemptions: false,});expect(readOnly.container.textContent).toContain(- "oauth2.consent.mcp.line.capped-read-only"- );- expect(readOnly.container.textContent).not.toContain(- "oauth2.consent.mcp.line.capped-read-write"+ "settings.mcp.policy.bound");expect(readOnly.container.textContent).toContain(- "oauth2.consent.mcp.line.audit"+ "settings.mcp.policy.audit");readOnly.unmount();@@ -638,13 +693,10 @@ describe("OAuth2ConsentPage", () => {ignoreMaskingExemptions: false,});expect(readWrite.container.textContent).toContain(- "oauth2.consent.mcp.line.capped-read-write"- );- expect(readWrite.container.textContent).not.toContain(- "oauth2.consent.mcp.line.capped-read-only"+ "settings.mcp.policy.bound");expect(readWrite.container.textContent).toContain(- "oauth2.consent.mcp.line.audit"+ "settings.mcp.policy.audit");readWrite.unmount();});@@ -656,24 +708,27 @@ describe("OAuth2ConsentPage", () => {});expect(container.textContent).toContain("settings.mcp.ladder.row.run-statements.title");expect(container.textContent).toContain("oauth2.consent.mcp.write-caution");- expect(container.textContent).toContain("oauth2.consent.mcp.line.masking");+ expect(container.textContent).toContain("settings.mcp.policy.masking.badge");+ expect(container.textContent).not.toContain(+ "oauth2.consent.mcp.line.masking"+ );unmount();});- // The masking line promises a restriction. The toggle withholds unmasking+ // The masking badge promises a restriction. The toggle withholds unmasking// exemptions from MCP sessions, which restricts nothing on a workspace where// masking does not run — and this card is read at the moment someone decides// whether to hand over access.- test("the masking line is not promised where masking does not run", async () => {+ test("the masking badge is not promised where masking does not run", async () => {mocks.dataMaskingAvailable.value = false;const { container, unmount } = await renderWithCeiling({capability: 4,ignoreMaskingExemptions: true,});- // The rest of the card is unchanged, so this is the line and not the card.+ // The rest of the card is unchanged, so this is the badge and not the card.expect(container.textContent).toContain("settings.mcp.ladder.row.run-statements.title");expect(container.textContent).not.toContain(- "oauth2.consent.mcp.line.masking"+ "settings.mcp.policy.masking.badge");unmount();});@@ -730,7 +785,7 @@ describe("OAuth2ConsentPage", () => {"oauth2.consent.mcp.disabled.ask-admin");// Nothing to approve and nothing to deny: the grant is not on offer.- expect(container.textContent).not.toContain("common.allow");+ expect(container.textContent).not.toContain("oauth2.consent.allow-access");expect(container.textContent).not.toContain("common.deny");unmount();});@@ -759,7 +814,7 @@ describe("OAuth2ConsentPage", () => {"oauth2.consent.mcp.undisclosed.unknown.title");// The hole: neither the grant button nor the form that carries it.- expect(container.textContent).not.toContain("common.allow");+ expect(container.textContent).not.toContain("oauth2.consent.allow-access");expect(container.querySelector('form[method="POST"]')).toBeNull();// The default mock resolves, so the retry reaches a ceiling and the page@@ -773,7 +828,7 @@ describe("OAuth2ConsentPage", () => {});await flushPromises();expect(container.textContent).toContain("settings.mcp.ladder.row.read-schemas.title");- expect(container.textContent).toContain("common.allow");+ expect(container.textContent).toContain("oauth2.consent.allow-access");unmount();});@@ -794,7 +849,7 @@ describe("OAuth2ConsentPage", () => {capability,ignoreMaskingExemptions: false,});- expect(container.textContent).not.toContain("common.allow");+ expect(container.textContent).not.toContain("oauth2.consent.allow-access");expect(container.querySelector('form[method="POST"]')).toBeNull();expect(container.textContent).toContain("oauth2.consent.mcp.undisclosed.undisclosable.title"diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.tsxindex c1dea3d9f5..a5aed664d3 100644--- a/frontend/src/routes/auth/OAuth2ConsentPage.tsx+++ b/frontend/src/routes/auth/OAuth2ConsentPage.tsx@@ -378,7 +378,7 @@ export function OAuth2ConsentPage() {name="action"value="allow">- {t("common.allow")}+ {t("oauth2.consent.allow-access")}</Button></div></form>@@ -391,7 +391,7 @@ export function OAuth2ConsentPage() {// scroll: the ceiling panel and its caution make the card taller than a// short viewport, and the part that clips is Allow and Deny. The auto// margins keep it centred while it still fits.- <div className="h-full overflow-y-auto flex flex-col mx-auto w-full max-w-sm py-8">+ <div className="h-full overflow-y-auto flex flex-col mx-auto w-full max-w-5xl px-4 py-8 md:w-3/5 lg:w-1/2 lg:px-0"><BytebaseLogo className="mx-auto mb-8 mt-auto shrink-0" /><div className="rounded-sm border border-control-border bg-background p-6 mb-auto shrink-0">{consentBody()}diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsxindex 52164d7f5a..a4ac10ed2c 100644--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx@@ -152,6 +152,9 @@ describe("MCPAccessPolicySection", () => {expect(container.textContent).toContain("settings.mcp.policy.mode.read-only.title");+ expect(container.textContent).toContain(+ "settings.mcp.policy.description(settings.mcp.policy.bound,settings.mcp.policy.audit)"+ );unmount();});@@ -350,9 +353,12 @@ describe("MCPAccessPolicySection", () => {const title = [...container.querySelectorAll("div")].find((node) =>- node.classList.contains("textinfo") &&+ node.classList.contains("text-base") &&+ node.classList.contains("font-semibold") &&+ node.classList.contains("text-main") &&node.textContent === "settings.mcp.policy.masking.title");+ expect(title).toBeDefined();expect(maskingSwitch(container)?.parentElement).toBe(title?.parentElement);unmount();});@@ -896,7 +902,7 @@ describe("MCPAccessPolicySection", () => {render();await flush();expect(container.textContent).not.toContain("settings.mcp.policy.tightening");- expect(container.textContent).not.toContain("settings.mcp.policy.audit");+ expect(container.textContent).toContain("settings.mcp.policy.audit");clickText(container, "settings.mcp.policy.edit");await flush();diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsxindex 9a8fb83b22..05bfcf93b0 100644--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx@@ -361,7 +361,7 @@ export function MCPAccessPolicySection() {aria-label={t("settings.mcp.policy.masking.title")}className="shrink-0"/>- <div className="textinfo font-semibold">+ <div className="text-base font-semibold text-main">{t("settings.mcp.policy.masking.title")}</div></div>@@ -412,7 +412,12 @@ export function MCPAccessPolicySection() {<h3 className="text-base font-medium">{t("settings.mcp.policy.title")}</h3>- <p className="textinfolabel">{t("settings.mcp.policy.description")}</p>+ <p className="textinfolabel">+ {t("settings.mcp.policy.description", {+ bound: t("settings.mcp.policy.bound"),+ audit: t("settings.mcp.policy.audit"),+ })}+ </p></div>{policyBody()}diff --git a/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.test.tsx b/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.test.tsxindex 7f493ea1fa..a99f300f08 100644--- a/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.test.tsx+++ b/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.test.tsx@@ -137,9 +137,15 @@ describe("MCPCapabilityLadder", () => {test("expanded, the trigger becomes the list heading naming the mode", () => {const { container, unmount } = renderIntoContainer(ladder({}));- expect(container.textContent).toContain(+ const heading = [...container.querySelectorAll("span")].find((node) =>+ node.textContent?.includes(+ "settings.mcp.ladder.heading(settings.mcp.policy.mode.read-only.title)"+ )+ );+ expect(heading?.textContent).toContain("settings.mcp.ladder.heading(settings.mcp.policy.mode.read-only.title)");+ expect(heading).toHaveClass("text-base", "font-semibold", "text-main");expect(container.textContent).not.toContain("settings.mcp.ladder.summary.read-only");@@ -193,6 +199,20 @@ describe("MCPCapabilityLadder", () => {unmount();});+ test("prioritizes granted capability titles over refused titles", () => {+ const { container, unmount } = renderIntoContainer(ladder({}));+ const allowed = [...container.querySelectorAll("span")].find((node) =>+ node.textContent?.includes("settings.mcp.ladder.row.read-schemas.title")+ );+ const refused = [...container.querySelectorAll("span")].find((node) =>+ node.textContent?.includes("settings.mcp.ladder.row.propose.title")+ );++ expect(allowed).toHaveClass("text-main");+ expect(refused).toHaveClass("text-control");+ unmount();+ });+test("toggling asks the owner rather than keeping its own state", () => {const expanded: boolean[] = [];const details: boolean[] = [];@@ -262,7 +282,7 @@ describe("MCPCapabilityLadder", () => {for (const row of rowItems(container)) {expect(row).not.toHaveClass("border-b");}- expect(divider).toHaveClass("py-2", "text-sm");+ expect(divider).toHaveClass("py-2", "text-xs");expect(divider?.querySelector("span")).toHaveClass("font-medium");unmount();});diff --git a/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.tsx b/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.tsxindex 39cffec5c9..c53d39f2e7 100644--- a/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.tsx+++ b/frontend/src/routes/workspace/mcp/MCPCapabilityLadder.tsx@@ -1,38 +1,19 @@-import { Check, ChevronRight, Minus } from "lucide-react";-import { Fragment } from "react";+import { ChevronRight } from "lucide-react";import { useTranslation } from "react-i18next";-import type {- MCPCapabilityRow,- MCPCapabilityTier,-} from "@/components/mcp/mcpCapabilityRows";-import {- isRowServed,- MCP_CAPABILITY_TIERS,- mcpRowKey,- mcpTierKey,- rowsInTier,-} from "@/components/mcp/mcpCapabilityRows";+import { MCPCapabilityList } from "@/components/mcp/MCPCapabilityList";import {type MCPServingMode,mcpModeKey,mcpSummaryKey,} from "@/components/mcp/mcpPolicy";-import type { BadgeProps } from "@/components/ui/badge";-import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import {Collapsible,CollapsiblePanel,CollapsibleTrigger,} from "@/components/ui/collapsible";-import { Separator } from "@/components/ui/separator";import { cn } from "@/lib/utils";-const TIER_VARIANT: Record<MCPCapabilityTier, BadgeProps["variant"]> = {- read: "success",- write: "warning",-};-interface Props {readonly mode: MCPServingMode;readonly expanded: boolean;@@ -80,8 +61,10 @@ export function MCPCapabilityLadder({this is. */}<spanclassName={cn(- "min-w-0 text-sm",- expanded ? "font-medium text-main" : "text-control-light"+ "min-w-0",+ expanded+ ? "text-base font-semibold text-main"+ : "text-sm text-control-light")}>{expanded@@ -106,109 +89,8 @@ export function MCPCapabilityLadder({</div><CollapsiblePanel>- {/* One list, so the rows are announced as a single ordered set and a- row's position in it survives without sight — the prefix the design- rests on. Each divider is a presentational sibling of the rows it- closes, never content inside the last of them. */}- {/* Tailwind's preflight removes the marker from every `ul`, and Safari- drops list semantics from an unstyled list — so the position- announcement this list depends on needs the role stated. */}- <ul role="list" className="flex flex-col gap-y-2">- {MCP_CAPABILITY_TIERS.map((tier) => (- <Fragment key={tier}>- {rowsInTier(tier).map((row) => (- <LadderRow- key={row.id}- row={row}- served={isRowServed(mode, row)}- details={details}- />- ))}- <TierDivider tier={tier} />- </Fragment>- ))}- </ul>- {/* The floor is one line rather than a row: it is what no mode serves,- so it has no mark and belongs to no tier. */}- <p className="bg-error/5 px-3 py-2 text-sm text-error my-2">- <span className="font-medium">- {t("settings.mcp.ladder.floor.label")}- </span>{" "}- {t("settings.mcp.ladder.floor.text")}- </p>+ <MCPCapabilityList mode={mode} details={details} tierDividers floor /></CollapsiblePanel></Collapsible>);}--function LadderRow({- row,- served,- details,-}: {- row: MCPCapabilityRow;- served: boolean;- details: boolean;-}) {- const { t } = useTranslation();- return (- <li className="flex items-start gap-x-2 px-1 py-1">- <span- className={cn(- "mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full",- served ? "bg-success/10 text-success" : "bg-error/10 text-error"- )}- >- {served ? (- <Check className="size-3" aria-hidden="true" />- ) : (- <Minus className="size-3" aria-hidden="true" />- )}- {/* Served and unserved are otherwise carried by the glyph, the muting- and the presence of the tier tag — all of them visual. Without this- a refused row is announced the same as an allowed one. */}- <span className="sr-only">- {served- ? t("settings.mcp.ladder.mark.allowed")- : t("settings.mcp.ladder.mark.refused")}- </span>- </span>- <div className="flex min-w-0 flex-col gap-1">- <div className="flex flex-wrap items-center gap-2">- <span className="text-sm text-control-light">- {t(mcpRowKey(row, "title"))}- </span>- {served && (- <Badge- variant={TIER_VARIANT[row.tier]}- className="px-2 py-0 text-xs"- >- {t(mcpTierKey(row.tier, "tier"))}- </Badge>- )}- </div>- {details && (- <p className="text-xs leading-5 text-control-light">- {t(mcpRowKey(row, "details"))}- </p>- )}- </div>- </li>- );-}--function TierDivider({ tier }: { tier: MCPCapabilityTier }) {- const { t } = useTranslation();- return (- <li- role="presentation"- className="flex items-center gap-x-2 py-2 text-sm text-control-light"- >- <Separator className="flex-1" />- <span className="uppercase font-medium text-main tracking-wide">- {t(mcpTierKey(tier, "stops"))}- </span>- <Separator className="flex-1" />- </li>- );-}