Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(frontend): enforce semantic React layering (#20111)
p0ny8bb0a63f1bcb
diff --git a/.sonarcloud.properties b/.sonarcloud.propertiesindex 99ef0b4846..7ea0a4fb35 100644--- a/.sonarcloud.properties+++ b/.sonarcloud.properties@@ -25,6 +25,7 @@ sonar.test.inclusions=\frontend/src/**/*.test.tsx,\frontend/src/**/*.spec.ts,\frontend/src/**/*.spec.tsx,\+ frontend/scripts/**/*.test.mjs,\frontend/tests/**# Source encoding@@ -77,7 +78,7 @@ sonar.cpd.exclusions=\backend/plugin/db/**,\frontend/src/**/*.test.ts,\frontend/src/**/*.test.tsx,\+ frontend/scripts/**/*.test.mjs,\frontend/src/react/mount*.ts,\frontend/tests/**,\proto/gen/**-diff --git a/docs/superpowers/plans/2026-04-23-react-z-index-policy-cleanup.md b/docs/superpowers/plans/2026-04-23-react-z-index-policy-cleanup.mdnew file mode 100644index 0000000000..b2464d3df3--- /dev/null+++ b/docs/superpowers/plans/2026-04-23-react-z-index-policy-cleanup.md@@ -0,0 +1,660 @@+# React Z-Index Policy Cleanup Implementation Plan++> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.++**Goal:** Make React global overlays obey the semantic `overlay` / `agent` / `critical` layer policy from PR #20012 and prevent new feature-owned z-index escalation.++**Architecture:** Reuse the existing semantic layer roots in `frontend/src/react/components/ui/layer.ts`. Convert feature-owned full-screen overlays to `Dialog`, `AlertDialog`, or `Sheet`, convert escaping menus/popovers to overlay-root portals or existing primitives, then wire a script-based guardrail into `pnpm --dir frontend check`.++**Tech Stack:** React, Base UI wrappers, Tailwind CSS v4, Node ESM scripts, pnpm, Vitest.++---++## File Map++- Create: `frontend/scripts/check-react-layering.mjs`+ - Scans React source for feature-owned global overlay z-index patterns.+- Modify: `frontend/package.json`+ - Adds `node scripts/check-react-layering.mjs` to the `check` script after cleanup.+- Modify: `frontend/src/react/components/ui/sheet.tsx`+ - Adds width tiers needed by existing large drawers so consumers do not inline global `fixed z-*` shells.+- Modify global modal/dialog files:+ - `frontend/src/react/pages/settings/IDPDetailPage.tsx`+ - `frontend/src/react/pages/settings/IDPsPage.tsx`+ - `frontend/src/react/pages/settings/RolesPage.tsx`+ - `frontend/src/react/pages/project/ProjectDatabasesPage.tsx`+ - `frontend/src/react/pages/settings/InstancesPage.tsx`+ - `frontend/src/react/pages/settings/ProjectsPage.tsx`+ - `frontend/src/react/pages/settings/general/GeneralSection.tsx`+ - `frontend/src/react/components/AuditLogTable.tsx`+- Modify global drawer files:+ - `frontend/src/react/pages/settings/MembersPage.tsx`+ - `frontend/src/react/pages/settings/SemanticTypesPage.tsx`+ - `frontend/src/react/components/sql-review/Panels.tsx`+ - `frontend/src/react/components/IssueTable.tsx`+ - `frontend/src/react/pages/settings/IDPsPage.tsx`+ - `frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx`+ - `frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx`+ - `frontend/src/react/components/instance/InfoPanel.tsx`+- Modify menu/popover files:+ - `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx`+ - `frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx`+ - `frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx`+ - `frontend/src/react/components/EnvironmentMultiSelect.tsx`+- Test/update:+ - Existing nearby tests for converted components.+ - Add focused tests only where a component has existing test coverage or the conversion changes Escape/outside-click behavior.++---++### Task 1: Add Report-Only React Layering Scanner++**Files:**+- Create: `frontend/scripts/check-react-layering.mjs`+- No package script wiring yet.++- [ ] **Step 1: Create the scanner**++Use this complete file:++```js+// frontend/scripts/check-react-layering.mjs+//+// Enforces the React semantic overlay layering policy introduced by PR #20012.+// Feature code must not create global z-index overlays directly. Use shared UI+// primitives or portal into the semantic layer roots instead.++import { readFileSync, readdirSync } from "fs";+import { relative, resolve } from "path";+import { fileURLToPath } from "url";+import { dirname } from "path";++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = resolve(__dirname, "..");+const REACT_DIR = resolve(ROOT, "src/react");+const REPORT_ONLY = process.argv.includes("--report-only");++const APPROVED_PREFIXES = [+ "src/react/components/ui/",+ "src/react/plugins/agent/",+];++const APPROVED_FILES = new Set([+ "src/react/components/auth/SessionExpiredSurface.tsx",+]);++const LOCAL_PAINT_ORDER_EXCEPTIONS = new Map([+ [+ "src/react/components/monaco/MonacoEditor.tsx",+ "Monaco action buttons are local to the editor surface.",+ ],+ [+ "src/react/plugins/agent/components/AgentInput.tsx",+ "Approved agent-owned layer family.",+ ],+ [+ "src/react/plugins/agent/components/AgentWindow.tsx",+ "Approved agent-owned layer family.",+ ],+]);++const findFiles = (dir) => {+ const files = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ const full = resolve(dir, entry.name);+ if (entry.isDirectory()) {+ files.push(...findFiles(full));+ } else if (/\.(ts|tsx)$/.test(entry.name)) {+ files.push(full);+ }+ }+ return files;+};++const isApprovedPath = (path) =>+ APPROVED_FILES.has(path) ||+ APPROVED_PREFIXES.some((prefix) => path.startsWith(prefix));++const hasRawZClass = (line) =>+ /\bz-\d+\b/.test(line) || /\bz-\[[^\]]+\]/.test(line);++const hasGlobalFixedZ = (line) => /\bfixed\b/.test(line) && hasRawZClass(line);++const hasHighAbsoluteZ = (line) =>+ /\babsolute\b/.test(line) && /\b(?:z-4\d|z-5\d|z-\[[^\]]+\])\b/.test(line);++const hasInlineZIndex = (line) => /\bzIndex\s*:/.test(line);++const scanFile = (file) => {+ const rel = relative(ROOT, file);+ if (isApprovedPath(rel)) {+ return [];+ }+ if (LOCAL_PAINT_ORDER_EXCEPTIONS.has(rel)) {+ return [];+ }++ const source = readFileSync(file, "utf-8");+ const violations = [];+ const lines = source.split("\n");++ lines.forEach((line, index) => {+ const lineNumber = index + 1;+ if (hasGlobalFixedZ(line)) {+ violations.push({+ rel,+ lineNumber,+ reason: "feature-owned fixed overlay uses raw z-index",+ line,+ });+ }+ if (hasHighAbsoluteZ(line)) {+ violations.push({+ rel,+ lineNumber,+ reason: "feature-owned absolute overlay uses high raw z-index",+ line,+ });+ }+ if (hasInlineZIndex(line)) {+ violations.push({+ rel,+ lineNumber,+ reason: "inline zIndex bypasses semantic layer ownership",+ line,+ });+ }+ });++ const portalToBody = /createPortal\([\s\S]*?document\.body/g;+ let match;+ while ((match = portalToBody.exec(source))) {+ const lineNumber = source.slice(0, match.index).split("\n").length;+ violations.push({+ rel,+ lineNumber,+ reason: "feature-owned portal targets document.body directly",+ line: lines[lineNumber - 1] ?? "",+ });+ }++ return violations;+};++const violations = findFiles(REACT_DIR).flatMap(scanFile);++if (violations.length > 0) {+ console.error(+ `React layering policy violations (${violations.length}). ` ++ "Use shared overlay primitives or getLayerRoot(\"overlay\").\n"+ );+ for (const violation of violations) {+ console.error(+ `${violation.rel}:${violation.lineNumber}: ${violation.reason}\n` ++ ` ${violation.line.trim()}\n`+ );+ }+ if (!REPORT_ONLY) {+ process.exit(1);+ }+}++console.log(+ violations.length === 0+ ? "React layering policy: all checks passed."+ : "React layering policy: report-only mode completed with violations."+);+```++- [ ] **Step 2: Run in report-only mode**++Run:++```bash+pnpm --dir frontend exec node scripts/check-react-layering.mjs --report-only+```++Expected: exit 0 and prints current violations.++- [ ] **Step 3: Commit**++```bash+git add frontend/scripts/check-react-layering.mjs+git commit -m "chore(frontend): add react layering policy scanner"+```++---++### Task 2: Convert Centered Modal Surfaces To Dialog Primitives++**Files:**+- Modify: `frontend/src/react/pages/settings/IDPDetailPage.tsx`+- Modify: `frontend/src/react/pages/settings/IDPsPage.tsx`+- Modify: `frontend/src/react/pages/settings/RolesPage.tsx`+- Modify: `frontend/src/react/pages/project/ProjectDatabasesPage.tsx`+- Modify: `frontend/src/react/pages/settings/InstancesPage.tsx`+- Modify: `frontend/src/react/pages/settings/ProjectsPage.tsx`+- Modify: `frontend/src/react/pages/settings/general/GeneralSection.tsx`+- Modify: `frontend/src/react/components/AuditLogTable.tsx`++- [ ] **Step 1: Import primitives in each touched file**++Use `Dialog` for result/details/import modals and `AlertDialog` for destructive or confirmation modals:++```ts+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogTitle,+ AlertDialogDescription,+} from "@/react/components/ui/alert-dialog";+```++Only import the primitives each file actually uses.++- [ ] **Step 2: Replace manual centered result/detail modals**++For result/detail modals such as `TestConnectionResultDialog`, `ImportPermissionModal`, and `AuditLogTable` JSON detail view, use this shape:++```tsx+return (+ <Dialog open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <DialogContent className="w-[32rem] max-w-[calc(100vw-2rem)] p-6">+ <DialogTitle>{title}</DialogTitle>+ <div className="mt-4 flex flex-col gap-y-4">{children}</div>+ </DialogContent>+ </Dialog>+);+```++For the `AuditLogTable` JSON detail view, preserve the large viewport sizing:++```tsx+<DialogContent className="flex h-[calc(100vh-12rem)] w-[calc(100vw-12rem)] max-w-none flex-col p-0">+```++- [ ] **Step 3: Replace manual confirmation modals**++For destructive confirmations such as role delete, IDP delete, and database unassign, use this shape:++```tsx+return (+ <AlertDialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <AlertDialogContent>+ <AlertDialogTitle>{title}</AlertDialogTitle>+ <AlertDialogDescription className="mt-2">+ {description}+ </AlertDialogDescription>+ <div className="mt-6 flex justify-end gap-x-2">+ <Button variant="outline" onClick={onCancel}>+ {t("common.cancel")}+ </Button>+ <Button variant="destructive" onClick={onConfirm}>+ {confirmText}+ </Button>+ </div>+ </AlertDialogContent>+ </AlertDialog>+);+```++If an existing confirmation uses warning styling instead of destructive styling, keep the current button variant/classes but keep the `AlertDialog` shell.++- [ ] **Step 4: Remove manual Escape handlers that duplicate primitives**++Remove `useEscapeKey` calls or `document.addEventListener("keydown", handler)` blocks from components converted to `Dialog` or `AlertDialog`. Base UI handles Escape through `onOpenChange`.++- [ ] **Step 5: Run targeted checks**++Run:++```bash+pnpm --dir frontend exec node scripts/check-react-layering.mjs --report-only+pnpm --dir frontend test -- --run frontend/src/react/components/ui/dialog.test.tsx frontend/src/react/components/ui/layer.test.tsx+```++Expected: the converted files no longer report fixed elements with raw `z-*`; the targeted tests pass.++- [ ] **Step 6: Commit**++```bash+git add frontend/src/react/pages/settings/IDPDetailPage.tsx \+ frontend/src/react/pages/settings/IDPsPage.tsx \+ frontend/src/react/pages/settings/RolesPage.tsx \+ frontend/src/react/pages/project/ProjectDatabasesPage.tsx \+ frontend/src/react/pages/settings/InstancesPage.tsx \+ frontend/src/react/pages/settings/ProjectsPage.tsx \+ frontend/src/react/pages/settings/general/GeneralSection.tsx \+ frontend/src/react/components/AuditLogTable.tsx+git commit -m "fix(frontend): route modal surfaces through overlay layer"+```++---++### Task 3: Convert Manual Drawers To Sheet++**Files:**+- Modify: `frontend/src/react/components/ui/sheet.tsx`+- Modify: `frontend/src/react/pages/settings/MembersPage.tsx`+- Modify: `frontend/src/react/pages/settings/SemanticTypesPage.tsx`+- Modify: `frontend/src/react/components/sql-review/Panels.tsx`+- Modify: `frontend/src/react/components/IssueTable.tsx`+- Modify: `frontend/src/react/pages/settings/IDPsPage.tsx`+- Modify: `frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx`+- Modify: `frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx`+- Modify: `frontend/src/react/components/instance/InfoPanel.tsx`++- [ ] **Step 1: Add the required `SheetContent` width tiers**++In `frontend/src/react/components/ui/sheet.tsx`, extend `sheetContentVariants`:++```ts+width: {+ narrow: "w-[24rem]",+ standard: "w-[44rem]",+ wide: "w-[52rem]",+ large: "w-[64rem]",+ xlarge: "w-[70rem]",+ workspace: "w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)]",+},+```++- [ ] **Step 2: Import sheet primitives in drawer files**++```ts+import {+ Sheet,+ SheetContent,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";+```++Only import `SheetDescription` or `SheetFooter` if the existing component already has equivalent content.++- [ ] **Step 3: Replace each manual drawer shell**++Use this pattern:++```tsx+return (+ <Sheet open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="large">+ <SheetHeader>+ <SheetTitle>{title}</SheetTitle>+ </SheetHeader>+ <div className="flex-1 overflow-y-auto p-6">{body}</div>+ </SheetContent>+ </Sheet>+);+```++Map existing widths to tiers:++- `w-[40rem]` -> `width="standard"`+- `w-[64rem]` -> `width="large"`+- `w-[70rem]` -> `width="xlarge"`+- `w-[calc(100vw-8rem)] lg:w-160` -> `width="large"` unless visible content is clipped+- `w-[calc(100vw-8rem)] lg:w-240` -> `width="workspace"`++- [ ] **Step 4: Preserve close behavior**++Move existing close buttons into `SheetHeader` only when they provide custom behavior. Otherwise use the built-in close button from `SheetHeader` and keep `onOpenChange` as the single close path.++- [ ] **Step 5: Run targeted checks**++Run:++```bash+pnpm --dir frontend exec node scripts/check-react-layering.mjs --report-only+pnpm --dir frontend test -- --run frontend/src/react/components/ui/dialog.test.tsx frontend/src/react/components/ui/layer.test.tsx+```++Expected: converted drawer files no longer report fixed elements with raw `z-*`; tests pass.++- [ ] **Step 6: Commit**++```bash+git add frontend/src/react/components/ui/sheet.tsx \+ frontend/src/react/pages/settings/MembersPage.tsx \+ frontend/src/react/pages/settings/SemanticTypesPage.tsx \+ frontend/src/react/components/sql-review/Panels.tsx \+ frontend/src/react/components/IssueTable.tsx \+ frontend/src/react/pages/settings/IDPsPage.tsx \+ frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx \+ frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx \+ frontend/src/react/components/instance/InfoPanel.tsx+git commit -m "fix(frontend): route drawer surfaces through sheet layer"+```++---++### Task 4: Convert Escaping Menus And Popovers To Overlay Layer++**Files:**+- Modify: `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx`+- Modify: `frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx`+- Modify: `frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx`+- Modify: `frontend/src/react/components/EnvironmentMultiSelect.tsx`++- [ ] **Step 1: Replace direct `document.body` portal in `AsideTree.tsx`**++Import:++```ts+import { getLayerRoot, LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";+```++Change the context menu portal target and classes:++```tsx+createPortal(+ <div+ className="fixed inset-0"+ onClick={hideMenu}+ onContextMenu={(e) => {+ e.preventDefault();+ hideMenu();+ }}+ >+ <div+ className={`absolute rounded-sm border border-control-border bg-white py-1 shadow-md ${LAYER_SURFACE_CLASS}`}+ style={{ left: menuState.x, top: menuState.y }}+ onClick={(e) => e.stopPropagation()}+ >+ {menuOptions.map((opt) => (+ <button+ key={opt.key}+ type="button"+ className="flex w-full items-center px-3 py-1.5 text-left text-sm hover:bg-control-bg-hover"+ onClick={() => handleMenuSelect(opt.key)}+ >+ {opt.label}+ </button>+ ))}+ </div>+ </div>,+ getLayerRoot("overlay")+)+```++- [ ] **Step 2: Convert ready-for-review popover to `Popover`**++In `PlanDetailHeader.tsx`, replace the raw `absolute right-0 top-full z-40` panel with `Popover`, `PopoverTrigger`, and `PopoverContent` from `@/react/components/ui/popover`.++The content class should preserve width and spacing:++```tsx+<Popover open={showReviewPopover} onOpenChange={handleReviewPopoverOpenChange}>+ <PopoverTrigger render={<Button disabled={submitDisabled} title={submitDisabledReason} />}>+ {t("plan.ready-for-review")}+ </PopoverTrigger>+ <PopoverContent+ align="end"+ className="w-[min(28rem,calc(100vw-2rem))] px-4 py-4"+ >+ <ReadyForReviewPopoverContent+ checksWarningAcknowledged={checksWarningAcknowledged}+ confirmErrors={createIssueConfirmErrors}+ forceIssueLabels={project.forceIssueLabels}+ issueLabels={project.issueLabels ?? []}+ onCancel={() => handleReviewPopoverOpenChange(false)}+ onChecksWarningAcknowledgedChange={setChecksWarningAcknowledged}+ onConfirm={() => void handleCreateIssue()}+ onSelectedLabelsChange={setSelectedLabels}+ selectedLabels={selectedLabels}+ showChecksWarning={showChecksWarning}+ submitting={submittingReview}+ />+ </PopoverContent>+</Popover>+```++If the current Base UI `PopoverTrigger` API does not support `render`, keep the existing button and pass its ref as `anchor` to `PopoverContent`.++- [ ] **Step 3: Convert custom select dropdowns that must escape clipping**++For `PlanDetailMetadataSidebar.tsx` and `EnvironmentMultiSelect.tsx`, either use `Combobox` with `portal` when the existing behavior maps directly, or portal the existing dropdown content into `getLayerRoot("overlay")` with `LAYER_SURFACE_CLASS`.++The portal fallback should follow this shape:++```tsx+{open &&+ createPortal(+ <div+ ref={dropdownRef}+ className={`fixed max-h-60 overflow-auto rounded-sm border border-control-border bg-background shadow-lg ${LAYER_SURFACE_CLASS}`}+ style={dropdownStyle}+ >+ {options}+ </div>,+ getLayerRoot("overlay")+ )}+```++Use the existing `getPortalDropdownStyle` helpers from `frontend/src/react/components/ui/combobox-position.ts` when positioning against a trigger.++- [ ] **Step 4: Run targeted checks**++Run:++```bash+pnpm --dir frontend exec node scripts/check-react-layering.mjs --report-only+pnpm --dir frontend test -- --run frontend/src/react/components/ui/popover.test.tsx frontend/src/react/components/ui/combobox-position.test.ts+```++Expected: converted menu/popover files no longer report direct `document.body` portals or high raw `z-*`; tests pass.++- [ ] **Step 5: Commit**++```bash+git add frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx \+ frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx \+ frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx \+ frontend/src/react/components/EnvironmentMultiSelect.tsx+git commit -m "fix(frontend): route popover surfaces through overlay layer"+```++---++### Task 5: Lock The Guardrail Into Frontend Check++**Files:**+- Modify: `frontend/package.json`+- Modify: `frontend/scripts/check-react-layering.mjs`++- [ ] **Step 1: Run the scanner without report-only**++Run:++```bash+pnpm --dir frontend exec node scripts/check-react-layering.mjs+```++Expected: exit 0 and `React layering policy: all checks passed.`++If violations remain, classify each as either:++- a true global overlay violation to fix before continuing, or+- a local paint-order exception to document in `LOCAL_PAINT_ORDER_EXCEPTIONS` with a file-specific reason.++- [ ] **Step 2: Wire the scanner into `pnpm check`**++Update `frontend/package.json`:++```json+"check": "eslint --cache src && biome ci . && node scripts/check-react-i18n.mjs && node scripts/check-react-layering.mjs && node scripts/sort_i18n_keys.mjs --check"+```++- [ ] **Step 3: Run full frontend validation**++Run:++```bash+pnpm --dir frontend fix+pnpm --dir frontend check+pnpm --dir frontend type-check+pnpm --dir frontend test+```++Expected: all commands exit 0.++- [ ] **Step 4: Commit**++```bash+git add frontend/package.json frontend/scripts/check-react-layering.mjs+git commit -m "chore(frontend): enforce react layering policy"+```++---++### Task 6: Final Review Pass++**Files:**+- Review all modified files from Tasks 1-5.++- [ ] **Step 1: Verify no feature-owned global z-index overlays remain**++Run:++```bash+rg -n '(fixed[^\n]*(z-\[[^\]]+\]|\bz-[0-9]+\b)|createPortal\([^)]*document\.body|zIndex\s*:)' frontend/src/react \+ --glob '*.tsx' --glob '*.ts' \+ --glob '!frontend/src/react/components/ui/**' \+ --glob '!frontend/src/react/plugins/agent/**' \+ --glob '!frontend/src/react/components/auth/SessionExpiredSurface.tsx'+```++Expected: no true global overlay violations. Local paint-order matches must be documented in `frontend/scripts/check-react-layering.mjs`.++- [ ] **Step 2: Review policy docs against implementation**++Check:++```bash+sed -n '35,46p' frontend/AGENTS.md+sed -n '1,120p' frontend/src/react/components/ui/layer.ts+```++Expected: implementation still matches the documented `overlay` > `agent` > `critical` policy and no new layer family was introduced.++- [ ] **Step 3: Commit any final review changes**++```bash+git status --short+```++If `git status --short` prints modified files, inspect them with `git diff`, then stage the listed files explicitly and commit:++```bash+git diff+git add frontend/package.json frontend/scripts/check-react-layering.mjs frontend/src/react+git commit -m "fix(frontend): finish react layering cleanup"+```++Skip the commit when `git status --short` prints no files.diff --git a/docs/superpowers/specs/2026-04-23-react-z-index-policy-cleanup-design.md b/docs/superpowers/specs/2026-04-23-react-z-index-policy-cleanup-design.mdnew file mode 100644index 0000000000..1f1ab1c91e--- /dev/null+++ b/docs/superpowers/specs/2026-04-23-react-z-index-policy-cleanup-design.md@@ -0,0 +1,127 @@+# React Z-Index Policy Cleanup Design++## Summary++Clean up the drift from PR #20012 by making React global overlays obey the semantic layer policy:++- `overlay` for normal app dialogs, sheets, menus, popovers, selects, and tooltips+- `agent` for agent-owned surfaces+- `critical` only for forced auth/session recovery++This is a strict policy cleanup. It should not redesign page UX or broadly migrate unrelated custom controls.++## Problem++The semantic layer roots and shared primitives exist, but feature code still contains global stacking decisions such as:++- full-screen `fixed ... z-50` or `z-[60]` dialogs and drawers+- manual drawer backdrops with separate `z-40`/`z-50` values+- direct `document.body` portals for feature-owned menus+- freestanding dropdowns and popovers using `absolute z-50` to compete with page surfaces++Those patterns bypass the semantic roots, so normal app overlays can accidentally cover or disable the agent, and new migrations can reintroduce one-off z-index escalation.++## Goals++- Route normal React app overlays through the `overlay` family.+- Preserve the existing `agent` and `critical` behavior from PR #20012.+- Leave component-internal paint ordering alone when it is local to a component.+- Add a guardrail that catches new feature-owned global z-index overlays.+- Keep the cleanup reviewable by avoiding unrelated page redesigns.++## Non-Goals++- Do not standardize legacy Vue or Naive UI stacking.+- Do not replace every custom dropdown if it is only local paint order and does not compete globally.+- Do not introduce new semantic layer families.+- Do not change the product behavior of affected dialogs, drawers, or menus except for stacking and modality mechanics needed to follow the policy.++## Classification++### Global Modal Surfaces++Examples include full-screen dialogs, centered result modals, side drawers, and blocking confirmation surfaces implemented with raw `fixed` and `z-*` classes.++These should be replaced with existing app primitives:++- `Dialog` for short blocking dialogs and read-only result displays+- `AlertDialog` for destructive confirmations+- `Sheet` for right-side create/edit drawers++The primitives already portal into `getLayerRoot("overlay")` and preserve access to higher-priority layers.++### Freestanding Menus And Popovers++Examples include context menus portalled directly to `document.body`, dropdown lists that escape normal layout, and popovers using `absolute z-40` or `absolute z-50` to sit above other surfaces.++Prefer existing primitives:++- `DropdownMenu` for command menus+- `Popover` for richer anchored panels+- `Combobox` for searchable/selectable lists++If a surface is too specialized for a primitive but must escape clipping, it should portal into `getLayerRoot("overlay")` and use `LAYER_SURFACE_CLASS`. It should not choose a numeric global z-index.++### Local Paint Order++The cleanup should not touch local paint-order cases unless they are clearly competing globally.++Allowed examples:++- sticky table headers+- loading masks inside a single panel+- status dot rings+- resize handles+- badge or icon layering++These can keep local `z-0`, `z-1`, `z-10`, or similar values when the stacking context is local and does not try to outrank another page surface.++## Guardrail++Add a focused frontend policy check that scans `frontend/src/react` and fails on feature-owned global z-index patterns outside approved layer infrastructure.++The check should flag:++- `fixed` elements with raw `z-*` or arbitrary `z-[...]` classes outside approved files+- high arbitrary z-index values such as `z-[60]` or `z-[999...]`+- inline `zIndex` used for cross-surface ordering+- direct `createPortal(..., document.body)` in feature code++The allowlist should include:++- `frontend/src/react/components/ui/`+- `frontend/src/react/plugins/agent/`+- `frontend/src/react/components/auth/SessionExpiredSurface.tsx`+- narrow local paint-order exceptions only when documented in the check++The check should run with the existing frontend validation path, preferably through `pnpm --dir frontend check` or a test invoked by that command, so future migrations see the policy failure before review.++## Implementation Order++1. Add the guardrail in report-only form locally to produce the current violation list.+2. Convert the highest-risk global modal surfaces to `Dialog`, `AlertDialog`, or `Sheet`.+3. Convert direct `document.body` feature portals to `getLayerRoot("overlay")` or overlay primitives.+4. Convert freestanding global dropdowns/popovers that use raw `z-40`/`z-50`.+5. Lock the guardrail so the cleaned set must stay clean.++## Testing++Run the standard frontend gates after the cleanup:++- `pnpm --dir frontend fix`+- `pnpm --dir frontend check`+- `pnpm --dir frontend type-check`+- targeted frontend tests for touched components++Add or update tests for surfaces whose behavior changes from custom markup to primitives, especially:++- Escape dismissal+- outside click behavior+- rendering into the `overlay` root+- preserving the agent layer above normal app overlays++## Risks++- Some custom dialogs may currently rely on incomplete ARIA or manual keyboard handling. Moving them to primitives can expose behavior differences, so each conversion should keep visible behavior stable while adopting primitive modality.+- A broad regex guardrail can create false positives for local paint order. Keep the rule focused on global overlay patterns and make exceptions explicit.+- Converting too many bespoke controls in one PR can obscure regressions. Keep the first PR limited to clear policy violations.diff --git a/frontend/AGENTS.md b/frontend/AGENTS.mdindex 9ae5f260b9..8e5c604fcd 100644--- a/frontend/AGENTS.md+++ b/frontend/AGENTS.md@@ -43,6 +43,10 @@ React UI components live in `src/react/components/ui/` and follow shadcn-style p- Children inherit the owning family. If a parent mounts into `agent` or `critical`, its descendants must not remount into a lower family.- Raw global `z-index` values are forbidden in React feature code for cross-surface stacking. Local component-internal `z-index` remains allowed when it only affects internal composition.- Consumers of overlay primitives must not set their own global `z-index`.+ - Do not portal feature UI directly to `document.body` or a `document.body` alias. Use the shared overlay primitives, or explicitly mount into the correct semantic root with `getLayerRoot(<family>)`.+ - Do not hide raw global overlay classes in constants, imported helpers, `cn()` inputs, or interpolated template literals. A value like `fixed inset-0 z-50` is still forbidden even when it is not written directly in `className`.+ - When adding or changing React overlays, run `pnpm --dir frontend check` or `node frontend/scripts/check-react-layering.mjs` before handing off. The scanner is intended to catch raw high-z overlays, forbidden body portals, and policy drift in feature code.+ - The scanner is a guardrail, not proof of policy compliance. It intentionally avoids full static analysis, so imported, dynamic, shadowed, or complex expressions may be unresolved; passing the check does not permit raw global z-index overlays or body portals.- **Dialog vs Sheet** — use `<Sheet>` (right-side drawer, in `src/react/components/ui/sheet.tsx`) for **creating or editing a resource**. Use `<Dialog>` for **confirmations, single-field prompts, critical interrupts, and read-only result displays**. The dividing line is whether the user is filling out a form with multiple fields — drawers keep the parent list/table visible behind a scrim and scale to multi-section forms, while dialogs are for short blocking interactions. `AlertDialog` is the right pick for destructive confirms that need an explicit acknowledgment.- **Sheet width tiers** — `<SheetContent>` accepts a `width` variant. Pick the tier that matches the form complexity; don't inline ad-hoc widths. Add a new tier to `sheet.tsx` only if a genuinely new size is needed.- `narrow` (384px) — single-field pickers, short 2–3 field forms, environment/project selection, read-only display sheetsdiff --git a/frontend/package.json b/frontend/package.jsonindex 991faff077..90dc6b5a86 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -10,7 +10,7 @@"release-docker": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite build --mode release","release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite build --mode release-aws","precheck": "pnpm run prepare:artifacts",- "check": "eslint --cache src && biome ci . && node scripts/check-react-i18n.mjs && node scripts/sort_i18n_keys.mjs --check",+ "check": "eslint --cache src && biome ci . && node scripts/check-react-i18n.mjs && node scripts/check-react-layering.mjs && node scripts/sort_i18n_keys.mjs --check","fix": "pnpm run sort:i18n && eslint --cache --fix src && biome check --write .","bundle-visualize": "export NODE_OPTIONS=--max_old_space_size=80000 && vite-bundle-visualizer -c vite.config.ts","pretype-check": "pnpm run prepare:artifacts",diff --git a/frontend/scripts/check-react-layering.mjs b/frontend/scripts/check-react-layering.mjsnew file mode 100644index 0000000000..6f84e3d49f--- /dev/null+++ b/frontend/scripts/check-react-layering.mjs@@ -0,0 +1,687 @@+// frontend/scripts/check-react-layering.mjs+//+// Enforces the React semantic overlay layering policy introduced by PR #20012.+// Feature code must not create global z-index overlays directly. Use shared UI+// primitives or portal into the semantic layer roots instead.+//+// This is a conservative policy scanner, not a complete TypeScript evaluator.+// It resolves direct string literals, unique static identifiers, simple static+// string concatenations, named createPortal imports, and simple+// document/document.body aliases. Complex, dynamic, imported, or shadowed+// values may be unresolved; passing this check does not permit bypassing the+// policy.++import { readFileSync, readdirSync } from "node:fs";+import { dirname, relative, resolve } from "node:path";+import { fileURLToPath } from "node:url";+import ts from "typescript";++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = resolve(__dirname, "..");+const REACT_DIR = resolve(ROOT, "src/react");+const REPORT_ONLY = process.argv.includes("--report-only");++const APPROVED_PREFIXES = [+ "src/react/components/ui/",+ "src/react/plugins/agent/",+];++const APPROVED_FILES = new Set([+ "src/react/components/auth/SessionExpiredSurface.tsx",+]);++const CLASS_ATTR_PATTERN = /\bclass(Name)?\s*=\s*/g;++const findFiles = (dir) => {+ const files = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ const full = resolve(dir, entry.name);+ if (entry.isDirectory()) {+ files.push(...findFiles(full));+ } else if (/\.(ts|tsx)$/.test(entry.name)) {+ files.push(full);+ }+ }+ return files;+};++const isApprovedPath = (path) =>+ APPROVED_FILES.has(path) ||+ APPROVED_PREFIXES.some((prefix) => path.startsWith(prefix));++const hasInlineZIndex = (line) => /\bzIndex\s*:/.test(line);++const getRawOverlayViolation = (block) => {+ const fixedMatch = block.match(/\bfixed\b/);+ const absoluteMatch = block.match(/\babsolute\b/);+ const zMatches = [...block.matchAll(/\bz-auto\b|\bz-(\d+)\b|\bz-\[([^\]]+)\]/g)];+ if (zMatches.length === 0 || (!fixedMatch && !absoluteMatch)) {+ return null;+ }++ const isAbsoluteGlobal = zMatches.some((zMatch) => {+ if (zMatch[2] !== undefined) {+ return true;+ }+ const value = Number(zMatch[1]);+ return Number.isFinite(value) && value >= 40;+ });+ if (!fixedMatch && !isAbsoluteGlobal) {+ return null;+ }++ const tokenMatch = fixedMatch ?? absoluteMatch ?? zMatches.find((zMatch) => {+ if (isRawZToken(zMatch)) {+ return true;+ }+ const value = Number(zMatch[1]);+ return Number.isFinite(value) && value >= 40;+ });++ return {+ reason: fixedMatch+ ? "feature-owned fixed overlay uses raw z-index"+ : "feature-owned absolute overlay uses high raw z-index",+ index: tokenMatch?.index ?? 0,+ };+};++const buildLineStarts = (source) => {+ const lineStarts = [0];+ for (let index = source.indexOf("\n"); index !== -1; index = source.indexOf("\n", index + 1)) {+ lineStarts.push(index + 1);+ }+ return lineStarts;+};++const getLineNumber = (lineStarts, index) => {+ let low = 0;+ let high = lineStarts.length - 1;+ while (low <= high) {+ const mid = Math.floor((low + high) / 2);+ if (lineStarts[mid] <= index) {+ low = mid + 1;+ } else {+ high = mid - 1;+ }+ }+ return high + 1;+};++const skipWhitespace = (source, startIndex) => {+ let index = startIndex;+ while (index < source.length && /\s/.test(source[index])) {+ index++;+ }+ return index;+};++const scanQuotedExpression = (source, index, quote) => {+ const start = index;+ let current = index + 1;+ let escaped = false;+ while (current < source.length) {+ const ch = source[current];+ if (escaped) {+ escaped = false;+ } else if (ch === "\\") {+ escaped = true;+ } else if (ch === quote) {+ return { start, end: current + 1 };+ }+ current++;+ }+ return { start, end: source.length };+};++const scanBareExpression = (source, index) => {+ let current = index;+ while (current < source.length && !/[\s>]/.test(source[current])) {+ current++;+ }+ return { start: index, end: current };+};++const isStringQuote = (ch) => ch === "\"" || ch === "'" || ch === "`";++const scanStringState = (ch, stringQuote, escaped) => {+ if (escaped) {+ return { stringQuote, escaped: false };+ }+ if (ch === "\\") {+ return { stringQuote, escaped: true };+ }+ if (ch === stringQuote) {+ return { stringQuote: null, escaped: false };+ }+ return { stringQuote, escaped: false };+};++const getNextBraceDepth = (ch, depth) => {+ if (ch === "{") {+ return depth + 1;+ }+ if (ch === "}") {+ return depth - 1;+ }+ return depth;+};++const scanBalancedExpression = (source, index) => {+ let current = index + 1;+ let depth = 1;+ let stringQuote = null;+ let escaped = false;+ while (current < source.length) {+ const ch = source[current];+ if (stringQuote !== null) {+ ({ stringQuote, escaped } = scanStringState(ch, stringQuote, escaped));+ current++;+ continue;+ }++ if (isStringQuote(ch)) {+ stringQuote = ch;+ current++;+ continue;+ }+ depth = getNextBraceDepth(ch, depth);+ if (depth === 0) {+ return { start: index, end: current + 1 };+ }+ current++;+ }+ return { start: index, end: source.length };+};++const extractClassExpression = (source, startIndex) => {+ const index = skipWhitespace(source, startIndex);+ if (index >= source.length) {+ return null;+ }++ const startChar = source[index];+ if (startChar === "\"" || startChar === "'" || startChar === "`") {+ return scanQuotedExpression(source, index, startChar);+ }+ if (startChar === "{") {+ return scanBalancedExpression(source, index);+ }+ return scanBareExpression(source, index);+};++const isRawZToken = (zMatch) =>+ zMatch[0] === "z-auto" ||+ zMatch[2] !== undefined ||+ (zMatch[1] !== undefined && Number.isFinite(Number(zMatch[1])));++const scanClassExpressions = (source, rel, lines) => {+ const violations = [];+ const lineStarts = buildLineStarts(source);++ CLASS_ATTR_PATTERN.lastIndex = 0;+ let match;+ while ((match = CLASS_ATTR_PATTERN.exec(source))) {+ const expr = extractClassExpression(source, match.index + match[0].length);+ if (!expr) {+ continue;+ }++ const block = source.slice(expr.start, expr.end);+ const violation = getRawOverlayViolation(block);+ if (!violation) {+ continue;+ }++ const tokenIndex = expr.start + violation.index;+ const lineNumber = getLineNumber(lineStarts, tokenIndex);+ violations.push({+ rel,+ lineNumber,+ reason: violation.reason,+ line: lines[lineNumber - 1] ?? "",+ });+ }++ return violations;+};++const createSourceFile = (source, rel) =>+ ts.createSourceFile(+ rel,+ source,+ ts.ScriptTarget.Latest,+ true,+ rel.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS+ );++const getUniqueStaticString = (staticStrings, name) => {+ const entry = staticStrings.get(name);+ if (!entry || entry.count !== 1) {+ return null;+ }+ return entry.value;+};++const getDirectStaticString = (expression) => {+ const current = skipExpressionWrappers(expression);+ if (ts.isStringLiteral(current) || ts.isNoSubstitutionTemplateLiteral(current)) {+ return current.text;+ }+ return null;+};++const getStaticString = (expression, staticStrings = new Map()) => {+ const current = skipExpressionWrappers(expression);+ const directValue = getDirectStaticString(current);+ if (directValue !== null) {+ return directValue;+ }+ if (ts.isIdentifier(current)) {+ return getUniqueStaticString(staticStrings, current.text);+ }+ if (+ ts.isBinaryExpression(current) &&+ current.operatorToken.kind === ts.SyntaxKind.PlusToken+ ) {+ const left = getStaticString(current.left, staticStrings);+ const right = getStaticString(current.right, staticStrings);+ if (left !== null && right !== null) {+ return `${left}${right}`;+ }+ }+ return null;+};++const recordStaticString = (staticStrings, name, value) => {+ const current = staticStrings.get(name);+ staticStrings.set(name, {+ count: (current?.count ?? 0) + 1,+ value: current ? null : value,+ });+};++const collectStaticStrings = (sourceFile) => {+ const staticStrings = new Map();++ const visit = (node) => {+ if (+ ts.isVariableDeclaration(node) &&+ ts.isIdentifier(node.name)+ ) {+ recordStaticString(+ staticStrings,+ node.name.text,+ node.initializer ? getStaticString(node.initializer, staticStrings) : null+ );+ } else if (ts.isParameter(node) && ts.isIdentifier(node.name)) {+ recordStaticString(staticStrings, node.name.text, null);+ }+ ts.forEachChild(node, visit);+ };++ visit(sourceFile);+ return staticStrings;+};++const getTemplateParts = (sourceFile, node, staticStrings) => {+ const headPart = {+ text: node.head.text,+ start: node.head.getStart(sourceFile) + 1,+ };++ const spanParts = node.templateSpans.flatMap((span) => {+ const expressionValue = getStaticString(span.expression, staticStrings);+ const literalPart = {+ text: span.literal.text,+ start: span.literal.getStart(sourceFile) + 1,+ };+ if (expressionValue === null) {+ return [literalPart];+ }+ return [+ {+ text: expressionValue,+ start: span.expression.getStart(sourceFile),+ },+ literalPart,+ ];+ });++ return [+ headPart,+ ...spanParts,+ ];+};++const combineTemplateParts = (parts, fallbackIndex) => {+ const placeholder = " ";+ const combinedLineIndexes = [];+ const combinedText = parts+ .map((part) => part.text)+ .join(placeholder);++ let combinedOffset = 0;+ parts.forEach((part, partIndex) => {+ for (let index = 0; index < part.text.length; index++) {+ combinedLineIndexes[combinedOffset + index] = part.start + index;+ }+ combinedOffset += part.text.length;+ if (partIndex < parts.length - 1) {+ combinedLineIndexes[combinedOffset] = part.start;+ combinedOffset += placeholder.length;+ }+ });++ return {+ text: combinedText,+ getAbsoluteIndex: (index) => combinedLineIndexes[index] ?? fallbackIndex,+ };+};++const scanTemplateExpression = (sourceFile, node, staticStrings, scanText) => {+ const combined = combineTemplateParts(+ getTemplateParts(sourceFile, node, staticStrings),+ node.getStart(sourceFile)+ );+ const violation = getRawOverlayViolation(combined.text);+ if (violation) {+ scanText(combined.text, node.getStart(sourceFile), combined.getAbsoluteIndex);+ }+};++const scanStringLiteralNode = (sourceFile, node, scanText) => {+ scanText(node.text, node.getStart(sourceFile) + 1);+};++const scanLiteralNode = (sourceFile, node, staticStrings, scanText) => {+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {+ scanStringLiteralNode(sourceFile, node, scanText);+ return;+ }+ if (ts.isTemplateExpression(node)) {+ scanTemplateExpression(sourceFile, node, staticStrings, scanText);+ }+};++const scanStringLiterals = (sourceFile, rel, lines) => {+ const violations = [];+ const staticStrings = collectStaticStrings(sourceFile);++ const scanText = (+ text,+ startIndex,+ getAbsoluteIndex = (index) => startIndex + index+ ) => {+ const violation = getRawOverlayViolation(text);+ if (!violation) {+ return;+ }++ const lineNumber =+ sourceFile.getLineAndCharacterOfPosition(+ getAbsoluteIndex(violation.index)+ ).line + 1;+ violations.push({+ rel,+ lineNumber,+ reason: violation.reason,+ line: lines[lineNumber - 1] ?? "",+ });+ };++ const visit = (node) => {+ if (ts.isVariableDeclaration(node) && node.initializer) {+ const staticValue = getStaticString(node.initializer, staticStrings);+ if (staticValue !== null) {+ scanText(staticValue, node.initializer.getStart(sourceFile));+ }+ }+ scanLiteralNode(sourceFile, node, staticStrings, scanText);+ ts.forEachChild(node, visit);+ };++ visit(sourceFile);+ return violations;+};++const skipExpressionWrappers = (expression) => {+ let current = expression;+ while (+ ts.isParenthesizedExpression(current) ||+ ts.isAsExpression(current) ||+ ts.isNonNullExpression(current) ||+ ts.isTypeAssertionExpression(current)+ ) {+ current = current.expression;+ }+ return current;+};++const isDocumentExpression = (expression, documentAliases) => {+ const current = skipExpressionWrappers(expression);+ return (+ ts.isIdentifier(current) &&+ (current.text === "document" || documentAliases.has(current.text))+ );+};++const isDocumentBodyExpression = (+ expression,+ documentAliases,+ documentBodyAliases+) => {+ const current = skipExpressionWrappers(expression);+ if (ts.isIdentifier(current)) {+ return documentBodyAliases.has(current.text);+ }+ return (+ ts.isPropertyAccessExpression(current) &&+ current.name.text === "body" &&+ isDocumentExpression(current.expression, documentAliases)+ );+};++const collectCreatePortalAliases = (sourceFile) => {+ const aliases = new Set(["createPortal"]);++ const visit = (node) => {+ if (+ ts.isImportDeclaration(node) &&+ ts.isStringLiteral(node.moduleSpecifier) &&+ node.moduleSpecifier.text === "react-dom" &&+ node.importClause?.namedBindings &&+ ts.isNamedImports(node.importClause.namedBindings)+ ) {+ node.importClause.namedBindings.elements.forEach((element) => {+ const importedName = element.propertyName?.text ?? element.name.text;+ if (importedName === "createPortal") {+ aliases.add(element.name.text);+ }+ });+ }++ ts.forEachChild(node, visit);+ };++ visit(sourceFile);+ return aliases;+};++const isCreatePortalCall = (node, createPortalAliases) => {+ const expression = skipExpressionWrappers(node.expression);+ return (+ (ts.isIdentifier(expression) && createPortalAliases.has(expression.text)) ||+ (ts.isPropertyAccessExpression(expression) &&+ expression.name.text === "createPortal")+ );+};++const recordDocumentAliases = (+ declaration,+ documentAliases,+ documentBodyAliases+) => {+ if (!declaration.initializer) {+ return;+ }++ if (ts.isIdentifier(declaration.name)) {+ if (isDocumentExpression(declaration.initializer, documentAliases)) {+ documentAliases.add(declaration.name.text);+ }+ if (+ isDocumentBodyExpression(+ declaration.initializer,+ documentAliases,+ documentBodyAliases+ )+ ) {+ documentBodyAliases.add(declaration.name.text);+ }+ return;+ }++ if (+ !ts.isObjectBindingPattern(declaration.name) ||+ !isDocumentExpression(declaration.initializer, documentAliases)+ ) {+ return;+ }++ declaration.name.elements.forEach((element) => {+ if (!ts.isIdentifier(element.name)) {+ return;+ }+ const propertyName = element.propertyName;+ const sourceName =+ propertyName && ts.isIdentifier(propertyName)+ ? propertyName.text+ : element.name.text;+ if (sourceName === "body") {+ documentBodyAliases.add(element.name.text);+ }+ });+};++const scanPortalTargets = (sourceFile, rel, lines) => {+ const violations = [];+ const createPortalAliases = collectCreatePortalAliases(sourceFile);+ const documentAliases = new Set();+ const documentBodyAliases = new Set();++ const visit = (node) => {+ if (ts.isVariableDeclaration(node)) {+ recordDocumentAliases(node, documentAliases, documentBodyAliases);+ }++ if (+ ts.isCallExpression(node) &&+ isCreatePortalCall(node, createPortalAliases) &&+ node.arguments[1] &&+ isDocumentBodyExpression(+ node.arguments[1],+ documentAliases,+ documentBodyAliases+ )+ ) {+ const lineNumber =+ sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))+ .line + 1;+ violations.push({+ rel,+ lineNumber,+ reason: "feature-owned portal targets document.body directly",+ line: lines[lineNumber - 1] ?? "",+ });+ }++ ts.forEachChild(node, visit);+ };++ visit(sourceFile);+ return violations;+};++const dedupeViolations = (violations) => {+ const seen = new Set();+ return violations.filter((violation) => {+ const key = `${violation.rel}:${violation.lineNumber}:${violation.reason}`;+ if (seen.has(key)) {+ return false;+ }+ seen.add(key);+ return true;+ });+};++const scanInlineZIndex = (rel, lines) =>+ lines.flatMap((line, index) => {+ if (!hasInlineZIndex(line)) {+ return [];+ }+ return [+ {+ rel,+ lineNumber: index + 1,+ reason: "inline zIndex bypasses semantic layer ownership",+ line,+ },+ ];+ });++export const scanSource = (source, rel) => {+ if (isApprovedPath(rel)) {+ return [];+ }++ const violations = [];+ const lines = source.split("\n");+ const sourceFile = createSourceFile(source, rel);+ violations.push(+ ...scanClassExpressions(source, rel, lines),+ ...scanStringLiterals(sourceFile, rel, lines),+ ...scanInlineZIndex(rel, lines),+ ...scanPortalTargets(sourceFile, rel, lines)+ );++ return dedupeViolations(violations);+};++export const scanFile = (file) => {+ const rel = relative(ROOT, file);+ const source = readFileSync(file, "utf-8");+ return scanSource(source, rel);+};++export const scanReactLayering = () => findFiles(REACT_DIR).flatMap(scanFile);++const main = () => {+ const violations = scanReactLayering();++ if (violations.length > 0) {+ console.error(+ `React layering policy violations (${violations.length}). ` ++ "Use shared overlay primitives or getLayerRoot(\"overlay\").\n"+ );+ for (const violation of violations) {+ console.error(+ `${violation.rel}:${violation.lineNumber}: ${violation.reason}\n` ++ ` ${violation.line.trim()}\n`+ );+ }+ if (!REPORT_ONLY) {+ process.exit(1);+ }+ }++ console.log(+ violations.length === 0+ ? "React layering policy: all checks passed."+ : "React layering policy: report-only mode completed with violations."+ );+};++if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {+ main();+}diff --git a/frontend/scripts/check-react-layering.test.mjs b/frontend/scripts/check-react-layering.test.mjsnew file mode 100644index 0000000000..f7f9d53218--- /dev/null+++ b/frontend/scripts/check-react-layering.test.mjs@@ -0,0 +1,240 @@+import { describe, expect, test } from "vitest";+import { scanSource } from "./check-react-layering.mjs";++const FEATURE_FILE = "src/react/pages/project/Feature.tsx";+const APPROVED_FILE = "src/react/components/ui/overlay.tsx";++describe("check-react-layering", () => {+ test("flags raw overlay classes stored in local constants", () => {+ const violations = scanSource(+ `+const overlayClass = "fixed inset-0 z-50";++export function FeatureOverlay() {+ return <div className={overlayClass} />;+}+`,+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 2,+ reason: "feature-owned fixed overlay uses raw z-index",+ }),+ ])+ );+ });++ test("flags raw overlay classes split across template literal expressions", () => {+ const violations = scanSource(+ [+ 'const overlayClass = `fixed ${condition ? "opacity-100" : ""} inset-0 z-50`;',+ "",+ "export function FeatureOverlay() {",+ " return <div className={overlayClass} />;",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 1,+ reason: "feature-owned fixed overlay uses raw z-index",+ }),+ ])+ );+ });++ test("flags raw overlay classes interpolated from string constants", () => {+ const violations = scanSource(+ [+ 'const zClass = "z-50";',+ "const overlayClass = `fixed inset-0 ${zClass}`;",+ "",+ "export function FeatureOverlay() {",+ " return <div className={overlayClass} />;",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 2,+ reason: "feature-owned fixed overlay uses raw z-index",+ }),+ ])+ );+ });++ test("flags raw overlay classes concatenated from static strings", () => {+ const violations = scanSource(+ [+ 'const positionClass = "fixed inset-0";',+ 'const zClass = "z-50";',+ 'const overlayClass = positionClass + " " + zClass;',+ "",+ "export function FeatureOverlay() {",+ " return <div className={overlayClass} />;",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 3,+ reason: "feature-owned fixed overlay uses raw z-index",+ }),+ ])+ );+ });++ test("does not resolve duplicate static identifiers across scopes", () => {+ const violations = scanSource(+ [+ 'const zClass = "";',+ "const overlayClass = `fixed inset-0 ${zClass}`;",+ "",+ "export function OtherFeature() {",+ ' const zClass = "z-50";',+ " return zClass;",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).not.toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 2,+ reason: "feature-owned fixed overlay uses raw z-index",+ }),+ ])+ );+ });++ test("flags createPortal targets aliased from document.body", () => {+ const violations = scanSource(+ `+import { createPortal } from "react-dom";++const target = document.body;++export function FeatureOverlay() {+ return createPortal(<div />, target);+}+`,+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 7,+ reason: "feature-owned portal targets document.body directly",+ }),+ ])+ );+ });++ test("flags createPortal targets from document aliases", () => {+ const violations = scanSource(+ `+import { createPortal } from "react-dom";++const doc = document;++export function FeatureOverlay() {+ return createPortal(<div />, doc.body);+}+`,+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 7,+ reason: "feature-owned portal targets document.body directly",+ }),+ ])+ );+ });++ test("flags aliased createPortal calls", () => {+ const violations = scanSource(+ [+ 'import { createPortal as portal } from "react-dom";',+ "",+ "export function FeatureOverlay() {",+ " return portal(<div />, document.body);",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 4,+ reason: "feature-owned portal targets document.body directly",+ }),+ ])+ );+ });++ test("flags createPortal targets from destructured body aliases", () => {+ const violations = scanSource(+ [+ 'import { createPortal } from "react-dom";',+ "",+ "const { body } = document;",+ "",+ "export function FeatureOverlay() {",+ " return createPortal(<div />, body);",+ "}",+ "",+ ].join("\n"),+ FEATURE_FILE+ );++ expect(violations).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ lineNumber: 6,+ reason: "feature-owned portal targets document.body directly",+ }),+ ])+ );+ });++ test("allows semantic layer owners to manage raw layers", () => {+ const violations = scanSource(+ `+import { createPortal } from "react-dom";++const target = document.body;+const overlayClass = "fixed inset-0 z-50";++export function OverlayRoot() {+ return createPortal(<div className={overlayClass} />, target);+}+`,+ APPROVED_FILE+ );++ expect(violations).toEqual([]);+ });+});diff --git a/frontend/src/react/components/AccountMultiSelect.tsx b/frontend/src/react/components/AccountMultiSelect.tsxindex 47a525b897..367899b62b 100644--- a/frontend/src/react/components/AccountMultiSelect.tsx+++ b/frontend/src/react/components/AccountMultiSelect.tsx@@ -1,6 +1,7 @@import { Check, ChevronDown, KeyRound, Shield, Users, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { SearchInput } from "@/react/components/ui/search-input";import { useClickOutside } from "@/react/hooks/useClickOutside";import { useVueState } from "@/react/hooks/useVueState";@@ -323,7 +324,12 @@ export function AccountMultiSelect({{/* Dropdown */}{open && (- <div className="absolute z-50 mt-1 w-full bg-background border border-control-border rounded-sm shadow-lg max-h-72 overflow-auto flex flex-col">+ <div+ className={cn(+ "absolute mt-1 w-full bg-background border border-control-border rounded-sm shadow-lg max-h-72 overflow-auto flex flex-col",+ LAYER_SURFACE_CLASS+ )}+ >{/* Search input */}<SearchInputref={inputRef}diff --git a/frontend/src/react/components/AdvancedSearch.tsx b/frontend/src/react/components/AdvancedSearch.tsxindex 59d752f4c5..62bc631258 100644--- a/frontend/src/react/components/AdvancedSearch.tsx+++ b/frontend/src/react/components/AdvancedSearch.tsx@@ -2,6 +2,7 @@ import { Filter, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { HighlightLabelText } from "@/react/components/HighlightLabelText";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { cn } from "@/react/lib/utils";// ============================================================@@ -710,7 +711,10 @@ export function AdvancedSearch({{/* Dropdown menu */}{showMenu && (<div- className="absolute top-[38px] w-full bg-control-bg shadow-xl origin-top-left rounded-sm overflow-hidden z-50"+ className={cn(+ "absolute top-[38px] w-full bg-control-bg shadow-xl origin-top-left rounded-sm overflow-hidden",+ LAYER_SURFACE_CLASS+ )}onMouseDown={(e) => e.preventDefault()}>{/* Scope menu */}diff --git a/frontend/src/react/components/AuditLogTable.tsx b/frontend/src/react/components/AuditLogTable.tsxindex e7f78c8553..4b5416403e 100644--- a/frontend/src/react/components/AuditLogTable.tsx+++ b/frontend/src/react/components/AuditLogTable.tsx@@ -23,6 +23,12 @@ import {import { FeatureAttention } from "@/react/components/FeatureAttention";import { TimeRangePicker } from "@/react/components/TimeRangePicker";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { PagedTableFooter } from "@/react/hooks/usePagedData";import {getPageSizeOptions,@@ -181,15 +187,6 @@ function JSONStringView({ jsonString }: { jsonString: string }) {}}, [jsonString]);- useEffect(() => {- if (!showModal) return;- const handler = (e: KeyboardEvent) => {- if (e.key === "Escape") setShowModal(false);- };- document.addEventListener("keydown", handler);- return () => document.removeEventListener("keydown", handler);- }, [showModal]);-return (<><div className="group grow-0 w-full flex flex-row justify-start items-center gap-2">@@ -206,36 +203,31 @@ function JSONStringView({ jsonString }: { jsonString: string }) {</div></div>{showModal && (- <div- className="fixed inset-0 z-50 flex items-center justify-center bg-overlay/50"- onClick={() => setShowModal(false)}+ <Dialog+ open+ onOpenChange={(nextOpen) => !nextOpen && setShowModal(false)}>- <div- className="bg-background rounded-sm shadow-lg flex flex-col"- style={{- width: "calc(100vw - 12rem)",- height: "calc(100vh - 12rem)",- }}- onClick={(e) => e.stopPropagation()}- >+ <DialogContent className="flex h-[calc(100vh-12rem)] w-[calc(100vw-12rem)] max-w-none flex-col p-0"><div className="flex items-center justify-between px-4 py-3 border-b">- <h3 className="text-base font-medium">+ <DialogTitle className="text-base font-medium">{t("common.view-details")}- </h3>- <button- className="p-1 hover:bg-control-bg rounded-full"+ </DialogTitle>+ <Button+ variant="ghost"+ size="icon"+ aria-label={t("common.close")}onClick={() => setShowModal(false)}><X className="size-4" />- </button>+ </Button></div><div className="flex-1 overflow-auto p-4"><pre className="text-sm font-mono whitespace-pre-wrap break-all">{formatted}</pre></div>- </div>- </div>+ </DialogContent>+ </Dialog>)}</>);@@ -288,7 +280,12 @@ function ExportDropdown({{t("common.export")}</Button>{open && !disabled && (- <div className="absolute right-0 top-[42px] bg-background border border-control-border rounded-sm shadow-lg z-50 py-1 min-w-[100px]">+ <div+ className={cn(+ "absolute right-0 top-[42px] bg-background border border-control-border rounded-sm shadow-lg py-1 min-w-[100px]",+ LAYER_SURFACE_CLASS+ )}+ >{formats.map(({ format, label }) => (<buttonkey={label}diff --git a/frontend/src/react/components/DashboardBodyShell.tsx b/frontend/src/react/components/DashboardBodyShell.tsxindex 24a19b2f61..09dedab485 100644--- a/frontend/src/react/components/DashboardBodyShell.tsx+++ b/frontend/src/react/components/DashboardBodyShell.tsx@@ -1,6 +1,7 @@import { useEffect, useRef, useState, useSyncExternalStore } from "react";import { useTranslation } from "react-i18next";import { DashboardHeader } from "@/react/components/header/DashboardHeader";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import type {DashboardBodyShellProps,DashboardShellTargets,@@ -74,7 +75,8 @@ export function DashboardBodyShell({<><divclassName={cn(- "fixed inset-0 z-40 md:hidden",+ "fixed inset-0 md:hidden",+ LAYER_SURFACE_CLASS,isMobileSidebarOpen ? "" : "pointer-events-none")}>diff --git a/frontend/src/react/components/EnvironmentMultiSelect.tsx b/frontend/src/react/components/EnvironmentMultiSelect.tsxindex 353d5606a5..b1ae94877c 100644--- a/frontend/src/react/components/EnvironmentMultiSelect.tsx+++ b/frontend/src/react/components/EnvironmentMultiSelect.tsx@@ -1,8 +1,12 @@import { Check, ChevronDown, X } from "lucide-react";-import { useCallback, useRef, useState } from "react";+import { useRef, useState } from "react";import { useTranslation } from "react-i18next";import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";-import { useClickOutside } from "@/react/hooks/useClickOutside";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/react/components/ui/popover";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { useEnvironmentV1Store } from "@/store";@@ -22,9 +26,6 @@ export function EnvironmentMultiSelect({const [open, setOpen] = useState(false);const containerRef = useRef<HTMLDivElement>(null);- const handleClickOutside = useCallback(() => setOpen(false), []);- useClickOutside(containerRef, open, handleClickOutside);-const toggle = (name: string) => {onChange(value.includes(name) ? value.filter((v) => v !== name) : [...value, name]@@ -41,79 +42,87 @@ export function EnvironmentMultiSelect({// The selected-chip X buttons are rendered as siblings of the trigger// (not children) to avoid nested <button>, which is invalid HTML.return (- <div ref={containerRef} className="relative">- <div- className={cn(- "flex items-center flex-wrap gap-1 min-h-[2.25rem] w-full rounded-xs border border-control-border bg-transparent px-2 py-1 text-sm",- open && "border-accent"- )}- >- {value.length === 0 && (- <span className="text-control-placeholder">- {t("environment.select")}- </span>- )}- {value.map((name) => (- <span- key={name}- className="inline-flex items-center gap-x-1 rounded-xs border border-control-border px-1 py-0.5 text-xs"- >- <EnvironmentLabel environmentName={name} className="text-xs" />- <button- type="button"- className="text-control-light hover:text-control"- onClick={() => remove(name)}- aria-label={t("common.delete")}- >- <X className="h-3 w-3" />- </button>- </span>- ))}- <button- type="button"- className="ml-auto flex items-center text-control-light cursor-pointer"- onClick={() => setOpen(!open)}- aria-haspopup="listbox"- aria-expanded={open}- aria-label={t("environment.select")}+ <Popover open={open} onOpenChange={setOpen}>+ <div ref={containerRef} className="relative">+ <div+ className={cn(+ "flex items-center flex-wrap gap-1 min-h-[2.25rem] w-full rounded-xs border border-control-border bg-transparent px-2 py-1 text-sm",+ open && "border-accent"+ )}>- <ChevronDown className="h-4 w-4 shrink-0" />- </button>- </div>-- {open && (- <div className="absolute z-50 mt-1 w-full bg-background border border-control-border rounded-sm shadow-lg max-h-60 overflow-auto">- {environmentList.length === 0 && (- <div className="px-3 py-2 text-sm text-control-light">- {t("common.no-data")}- </div>+ {value.length === 0 && (+ <span className="text-control-placeholder">+ {t("environment.select")}+ </span>)}- {environmentList.map((env) => {- const selected = value.includes(env.name);- return (+ {value.map((name) => (+ <span+ key={name}+ className="inline-flex items-center gap-x-1 rounded-xs border border-control-border px-1 py-0.5 text-xs"+ >+ <EnvironmentLabel environmentName={name} className="text-xs" /><button- key={env.name}type="button"- className="flex items-center gap-x-2 px-3 py-1.5 text-sm hover:bg-control-bg cursor-pointer w-full text-left"- onClick={() => toggle(env.name)}- aria-pressed={selected}+ className="text-control-light hover:text-control"+ onClick={() => remove(name)}+ aria-label={t("common.delete")}>- <div- className={cn(- "size-4 rounded-xs border flex items-center justify-center shrink-0",- selected- ? "bg-accent border-accent text-accent-text"- : "border-control-border"- )}- >- {selected && <Check className="h-3 w-3" />}- </div>- <EnvironmentLabel environment={env} />+ <X className="h-3 w-3" /></button>- );- })}+ </span>+ ))}+ <PopoverTrigger+ render={+ <button+ type="button"+ className="ml-auto flex items-center text-control-light cursor-pointer"+ aria-label={t("environment.select")}+ />+ }+ >+ <ChevronDown className="h-4 w-4 shrink-0" />+ </PopoverTrigger></div>- )}- </div>+ </div>+ <PopoverContent+ anchor={containerRef}+ side="bottom"+ align="start"+ initialFocus={false}+ finalFocus={false}+ style={{ width: "var(--anchor-width)" }}+ className="max-h-60 overflow-auto p-0"+ >+ {environmentList.length === 0 && (+ <div className="px-3 py-2 text-sm text-control-light">+ {t("common.no-data")}+ </div>+ )}+ {environmentList.map((env) => {+ const selected = value.includes(env.name);+ return (+ <button+ key={env.name}+ type="button"+ className="flex w-full cursor-pointer items-center gap-x-2 px-3 py-1.5 text-left text-sm hover:bg-control-bg"+ onClick={() => toggle(env.name)}+ aria-pressed={selected}+ >+ <div+ className={cn(+ "flex size-4 shrink-0 items-center justify-center rounded-xs border",+ selected+ ? "border-accent bg-accent text-accent-text"+ : "border-control-border"+ )}+ >+ {selected && <Check className="h-3 w-3" />}+ </div>+ <EnvironmentLabel environment={env} />+ </button>+ );+ })}+ </PopoverContent>+ </Popover>);}diff --git a/frontend/src/react/components/ExprEditor.tsx b/frontend/src/react/components/ExprEditor.tsxindex e595e4ccf8..2989c06319 100644--- a/frontend/src/react/components/ExprEditor.tsx+++ b/frontend/src/react/components/ExprEditor.tsx@@ -39,6 +39,7 @@ import {} from "@/plugins/cel";import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";import { Input } from "@/react/components/ui/input";+import { getLayerRoot, LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { SearchInput } from "@/react/components/ui/search-input";import {Select,@@ -47,6 +48,8 @@ import {SelectTrigger,SelectValue,} from "@/react/components/ui/select";+import { Tooltip } from "@/react/components/ui/tooltip";+import { cn } from "@/react/lib/utils";import { environmentNamePrefix } from "@/store/modules/v1/common";import { getDefaultPagination } from "@/utils";import { CEL_ATTRIBUTE_RESOURCE_ENVIRONMENT_ID } from "@/utils/cel-attributes";@@ -218,7 +221,6 @@ function PortaledDropdown({position: "fixed",top: rect.bottom + 4,left: rect.left,- zIndex: 100,...(matchAnchorWidth ? { width: rect.width } : {}),});}, [anchorRef, matchAnchorWidth]);@@ -241,10 +243,14 @@ function PortaledDropdown({}, [updatePosition, anchorRef]);return createPortal(- <div ref={dropdownRef} style={style} className={className}>+ <div+ ref={dropdownRef}+ style={style}+ className={cn(className, LAYER_SURFACE_CLASS)}+ >{children}</div>,- document.body+ getLayerRoot("overlay"));}@@ -1497,18 +1503,15 @@ function ConditionGroup({</button><buttontype="button"- className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded-xs hover:bg-control-bg disabled:opacity-50 group relative"+ className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded-xs hover:bg-control-bg disabled:opacity-50"disabled={readonly}onClick={addConditionGroup}><Plus className="size-4" />{t("cel.condition.add-group")}- <span className="relative">+ <Tooltip content={t("cel.condition.group.tooltip")}><HelpCircle className="ml-1 size-3 text-control-placeholder" />- <span className="absolute bottom-full left-1/2 -translate-x-1/2 mb-1 hidden group-hover:block w-72 p-2 text-xs bg-main text-accent-text rounded-sm shadow-lg z-50">- {t("cel.condition.group.tooltip")}- </span>- </span>+ </Tooltip></button>{enableRawExpression && (<buttondiff --git a/frontend/src/react/components/IssueLabelSelect.tsx b/frontend/src/react/components/IssueLabelSelect.tsxindex e4e04e4d7f..a508382fbe 100644--- a/frontend/src/react/components/IssueLabelSelect.tsx+++ b/frontend/src/react/components/IssueLabelSelect.tsx@@ -1,6 +1,7 @@import { ChevronDown, X } from "lucide-react";import { useCallback, useRef, useState } from "react";import { useTranslation } from "react-i18next";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { useClickOutside } from "@/react/hooks/useClickOutside";import { cn } from "@/react/lib/utils";@@ -97,7 +98,12 @@ export function IssueLabelSelect({/></button>{open && (- <div className="absolute z-50 mt-1 w-full bg-background border border-block-border rounded-sm shadow-lg overflow-hidden">+ <div+ className={cn(+ "absolute mt-1 w-full bg-background border border-block-border rounded-sm shadow-lg overflow-hidden",+ LAYER_SURFACE_CLASS+ )}+ ><div className="max-h-60 overflow-y-auto">{labels.length === 0 ? (<div className="px-3 py-6 text-sm text-control-placeholder text-center">diff --git a/frontend/src/react/components/IssueTable.tsx b/frontend/src/react/components/IssueTable.tsxindex c56dee6f16..5916354c24 100644--- a/frontend/src/react/components/IssueTable.tsx+++ b/frontend/src/react/components/IssueTable.tsx@@ -1,5 +1,5 @@import { create } from "@bufbuild/protobuf";-import { ArrowUpDown, Check, Loader2, X } from "lucide-react";+import { ArrowUpDown, Check, Loader2 } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { issueServiceClientConnect } from "@/connect";@@ -12,6 +12,15 @@ import {import { HumanizeTs } from "@/react/components/HumanizeTs";import { TimeRangePicker } from "@/react/components/TimeRangePicker";import { Button } from "@/react/components/ui/button";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import { Tooltip } from "@/react/components/ui/tooltip";import { useClickOutside } from "@/react/hooks/useClickOutside";import { useEscapeKey } from "@/react/hooks/useEscapeKey";@@ -144,7 +153,12 @@ function IssueSortDropdown({<span className="hidden md:inline ml-1">{t("issue.sort.sort")}</span></Button>{open && (- <div className="absolute right-0 top-full mt-1 z-50 bg-background border border-block-border rounded-sm shadow-lg min-w-[180px] py-1">+ <div+ className={cn(+ "absolute right-0 top-full mt-1 bg-background border border-block-border rounded-sm shadow-lg min-w-[180px] py-1",+ LAYER_SURFACE_CLASS+ )}+ >{sortOptions.map((group) => (<div key={group.label}><div className="px-3 py-1.5 text-xs text-control-light font-medium">@@ -1033,20 +1047,13 @@ export function BatchIssueStatusActionDrawer({: t("issue.batch-transition.reopen");return (- <div className="fixed inset-0 z-50 flex">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="ml-auto relative bg-background w-[calc(100vw-8rem)] lg:w-160 max-w-[calc(100vw-8rem)] h-full shadow-lg flex flex-col">- <div className="px-6 py-4 border-b border-control-border flex items-center justify-between">- <span className="text-lg font-semibold">{title}</span>- <button- className="p-1 hover:bg-control-bg rounded-xs"- onClick={onClose}- >- <X className="size-4" />- </button>- </div>+ <Sheet open={!!action} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="medium">+ <SheetHeader>+ <SheetTitle>{title}</SheetTitle>+ </SheetHeader>- <div className="flex-1 overflow-y-auto p-6 flex flex-col gap-y-4">+ <SheetBody className="p-6 gap-y-4"><div className="flex flex-col gap-y-1"><div className="font-medium text-control">{t("common.issues")}</div><ul@@ -1072,9 +1079,9 @@ export function BatchIssueStatusActionDrawer({onChange={(e) => setComment(e.target.value)}/></div>- </div>+ </SheetBody>- <div className="px-6 py-4 border-t border-control-border flex items-center justify-end gap-x-2">+ <SheetFooter><Button variant="outline" onClick={onClose}>{t("common.cancel")}</Button>@@ -1082,8 +1089,8 @@ export function BatchIssueStatusActionDrawer({{loading && <Loader2 className="size-4 mr-1 animate-spin" />}{t("common.confirm")}</Button>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsxindex c940b18a4f..309330f895 100644--- a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx@@ -14,6 +14,7 @@ import { useCallback, useMemo, useRef, useState } from "react";import type { NodeRendererProps } from "react-arborist";import { Tree } from "react-arborist";import { createPortal } from "react-dom";+import { getLayerRoot, LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { SearchInput } from "@/react/components/ui/search-input";import { cn } from "@/react/lib/utils";import type {@@ -378,7 +379,7 @@ export function AsideTree() {menuOptions.length > 0 &&createPortal(<div- className="fixed inset-0 z-50"+ className="fixed inset-0"onClick={hideMenu}onContextMenu={(e) => {e.preventDefault();@@ -386,7 +387,7 @@ export function AsideTree() {}}><div- className="absolute rounded-sm border border-control-border bg-white py-1 shadow-md"+ className={`absolute rounded-sm border border-control-border bg-white py-1 shadow-md ${LAYER_SURFACE_CLASS}`}style={{ left: menuState.x, top: menuState.y }}onClick={(e) => e.stopPropagation()}>@@ -402,7 +403,7 @@ export function AsideTree() {))}</div></div>,- document.body+ getLayerRoot("overlay"))}{/* Modals */}diff --git a/frontend/src/react/components/TimeRangePicker.tsx b/frontend/src/react/components/TimeRangePicker.tsxindex e8097c1335..0122a186e5 100644--- a/frontend/src/react/components/TimeRangePicker.tsx+++ b/frontend/src/react/components/TimeRangePicker.tsx@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";import type { SearchParams } from "./AdvancedSearch";import { Button } from "./ui/button";import { Input } from "./ui/input";+import { LAYER_SURFACE_CLASS } from "./ui/layer";interface TimeRangePickerProps {params: SearchParams;@@ -108,7 +109,9 @@ export function TimeRangePicker({<Calendar className="size-4 text-control-light ml-1 shrink-0" /></button>{showPicker && (- <div className="absolute right-0 top-[42px] bg-background border border-control-border rounded-sm shadow-lg z-50 p-3 flex flex-col gap-y-2 min-w-[300px]">+ <div+ className={`absolute right-0 top-[42px] bg-background border border-control-border rounded-sm shadow-lg p-3 flex flex-col gap-y-2 min-w-[300px] ${LAYER_SURFACE_CLASS}`}+ ><div className="flex items-center gap-x-2"><label className="text-sm text-control-light whitespace-nowrap w-10">{t("common.from")}diff --git a/frontend/src/react/components/database/CreateDatabaseSheet.tsx b/frontend/src/react/components/database/CreateDatabaseSheet.tsxindex 186cfb123e..3c3c0e7c74 100644--- a/frontend/src/react/components/database/CreateDatabaseSheet.tsx+++ b/frontend/src/react/components/database/CreateDatabaseSheet.tsx@@ -1,10 +1,10 @@import { create } from "@bufbuild/protobuf";-import { ChevronDown, X } from "lucide-react";-import { useCallback, useEffect, useRef, useState } from "react";+import { useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { v4 as uuidv4 } from "uuid";import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";import { InstanceSelect } from "@/react/components/InstanceSelect";+import { IssueLabelSelect } from "@/react/components/IssueLabelSelect";import { ProjectSelect } from "@/react/components/ProjectSelect";import { Button } from "@/react/components/ui/button";import { Combobox } from "@/react/components/ui/combobox";@@ -17,7 +17,6 @@ import {SheetHeader,SheetTitle,} from "@/react/components/ui/sheet";-import { useClickOutside } from "@/react/hooks/useClickOutside";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { router } from "@/router";@@ -52,124 +51,6 @@ import {const INTERNAL_RDS_USERS = ["rds_ad", "rdsadmin", "rds_iam"];-function IssueLabelSelect({- labels,- selected,- required,- onChange,-}: {- labels: { value: string; color: string }[];- selected: string[];- required: boolean;- onChange: (labels: string[]) => void;-}) {- const { t } = useTranslation();- const [open, setOpen] = useState(false);- const containerRef = useRef<HTMLDivElement>(null);- const closeDropdown = useCallback(() => setOpen(false), []);- useClickOutside(containerRef, open, closeDropdown);-- const toggleLabel = (value: string) => {- onChange(- selected.includes(value)- ? selected.filter((l) => l !== value)- : [...selected, value]- );- };-- return (- <div>- <label className="block text-sm font-medium mb-1">- {t("issue.labels")}- {required && <span className="text-error"> *</span>}- </label>- <div ref={containerRef} className="relative">- <button- type="button"- className={cn(- "w-full flex items-center justify-between gap-2 border border-control-border rounded-xs h-9 px-3 text-sm bg-background text-left transition-colors",- "hover:border-gray-400",- open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]"- )}- onClick={() => setOpen(!open)}- >- {selected.length > 0 ? (- <div className="flex items-center gap-1.5 truncate">- {selected.map((val) => {- const label = labels.find((l) => l.value === val);- return (- <span- key={val}- className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-xs bg-control-bg text-xs"- >- <span- className="size-2.5 rounded-sm shrink-0"- style={{ backgroundColor: label?.color }}- />- {val}- <X- className="size-3 text-control-placeholder hover:text-control-light"- onClick={(e) => {- e.stopPropagation();- toggleLabel(val);- }}- />- </span>- );- })}- </div>- ) : (- <span className="text-control-placeholder">- {t("common.select")}- </span>- )}- <ChevronDown- className={cn(- "size-4 text-control-placeholder shrink-0 transition-transform",- open && "rotate-180"- )}- />- </button>- {open && (- <div className="absolute z-50 mt-1 w-full bg-background border border-block-border rounded-sm shadow-lg overflow-hidden">- <div className="max-h-60 overflow-y-auto">- {labels.length === 0 ? (- <div className="px-3 py-6 text-sm text-control-placeholder text-center">- {t("common.no-data")}- </div>- ) : (- labels.map((label) => {- const isSelected = selected.includes(label.value);- return (- <button- key={label.value}- type="button"- className="w-full text-left px-3 py-2 text-sm flex items-center gap-2 hover:bg-control-bg transition-colors"- onClick={() => toggleLabel(label.value)}- >- <input- type="checkbox"- checked={isSelected}- readOnly- className="rounded-xs border-control-border accent-accent"- />- <span- className="size-4 rounded-sm shrink-0"- style={{ backgroundColor: label.color }}- />- <span>{label.value}</span>- </button>- );- })- )}- </div>- </div>- )}- </div>- </div>- );-}-export interface CreateDatabaseSheetProps {open: boolean;onClose: () => void;diff --git a/frontend/src/react/components/instance/InfoPanel.tsx b/frontend/src/react/components/instance/InfoPanel.tsxindex e1bde5b5f3..7ffba31c18 100644--- a/frontend/src/react/components/instance/InfoPanel.tsx+++ b/frontend/src/react/components/instance/InfoPanel.tsx@@ -3,6 +3,13 @@ import { Check, Copy, X } from "lucide-react";import type { ReactNode } from "react";import { useCallback, useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import type { Engine } from "@/types/proto-es/v1/common_pb";import {getInfoContent,@@ -51,24 +58,18 @@ export function InfoPanel({if (mode === "overlay") {if (!mounted) return null;return (- <div- className={`fixed inset-0 z-50 flex justify-end transition-opacity duration-200 ${- visible ? "opacity-100" : "opacity-0 pointer-events-none"- }`}- onClick={(e) => {- if (e.target === e.currentTarget) onClose();- }}- onTransitionEnd={handleTransitionEnd}- >- <div- className={`w-[500px] bg-background border-l border-block-border shadow-lg flex flex-col h-full transition-transform duration-200 ${- visible ? "translate-x-0" : "translate-x-full"- }`}+ <Sheet open={visible} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent+ width="panel"+ className="border-l border-block-border"+ onTransitionEnd={handleTransitionEnd}>- <PanelHeader title={title} onClose={onClose} className="px-4 py-3" />- <div className="flex-1 overflow-y-auto px-4 py-4">{children}</div>- </div>- </div>+ <SheetHeader className="px-4 py-3">+ <SheetTitle className="truncate text-sm">{title}</SheetTitle>+ </SheetHeader>+ <SheetBody className="px-4 py-4">{children}</SheetBody>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/components/instance/InstanceSyncButton.tsx b/frontend/src/react/components/instance/InstanceSyncButton.tsxindex 34e224b838..8e539351c4 100644--- a/frontend/src/react/components/instance/InstanceSyncButton.tsx+++ b/frontend/src/react/components/instance/InstanceSyncButton.tsx@@ -2,6 +2,12 @@ import { ChevronDown } from "lucide-react";import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/react/components/ui/dropdown-menu";import { pushNotification, useDatabaseV1Store } from "@/store";import { SyncStatus } from "@/types/proto-es/v1/database_service_pb";import { hasWorkspacePermissionV2 } from "@/utils";@@ -120,37 +126,29 @@ export function InstanceSyncButton({);return (- <div className="relative">- <Button- variant="outline"- disabled={!hasPermission || disabled || syncing}- onClick={() => setOpen(!open)}+ <DropdownMenu open={open} onOpenChange={setOpen}>+ <DropdownMenuTrigger+ render={+ <Button+ variant="outline"+ disabled={!hasPermission || disabled || syncing}+ />+ }>{syncing ? t("instance.syncing") : t("instance.sync.self")}<ChevronDown className="ml-1 size-4" />- </Button>- {open && (- <>- <div className="fixed inset-0 z-40" onClick={() => setOpen(false)} />- <div className="absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-sm border bg-background shadow-md py-1">- <button- type="button"- className="w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg"- title={t("instance.sync.sync-all-tip")}- onClick={() => syncSchema("sync-all")}- >- {t("instance.sync.sync-all")}- </button>- <button- type="button"- className="w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg"- onClick={() => syncSchema("sync-new")}- >- {t("instance.sync.sync-new")}- </button>- </div>- </>- )}- </div>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="min-w-[140px]">+ <DropdownMenuItem+ title={t("instance.sync.sync-all-tip")}+ onClick={() => syncSchema("sync-all")}+ >+ {t("instance.sync.sync-all")}+ </DropdownMenuItem>+ <DropdownMenuItem onClick={() => syncSchema("sync-new")}>+ {t("instance.sync.sync-new")}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>);}diff --git a/frontend/src/react/components/sql-review/Panels.tsx b/frontend/src/react/components/sql-review/Panels.tsxindex a9f1621df6..2c15f0f8bd 100644--- a/frontend/src/react/components/sql-review/Panels.tsx+++ b/frontend/src/react/components/sql-review/Panels.tsx@@ -1,9 +1,16 @@-import { X } from "lucide-react";import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { getRuleKey } from "@/components/SQLReview/components/utils";import { Alert, AlertDescription } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import { useEscapeKey } from "@/react/hooks/useEscapeKey";import { useVueState } from "@/react/hooks/useVueState";import {@@ -100,18 +107,12 @@ export function RulesSelectPanel({if (!show) return null;return (- <div className="fixed inset-0 z-50 flex">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="ml-auto relative bg-background w-[70rem] max-w-[100vw] h-full shadow-lg flex flex-col">- <div className="px-4 py-3 border-b flex items-center justify-between">- <h2 className="text-lg font-medium">- {t("sql-review.select-review-rules")}- </h2>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="size-4" />- </Button>- </div>- <div className="flex-1 overflow-y-auto p-4">+ <Sheet open={show} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="xlarge">+ <SheetHeader className="px-4 py-3">+ <SheetTitle>{t("sql-review.select-review-rules")}</SheetTitle>+ </SheetHeader>+ <SheetBody className="p-4"><TabsByEngine ruleMapByEngine={ruleTemplateMapV2}>{(ruleList, engine) => (<RuleTableWithFilter@@ -128,14 +129,14 @@ export function RulesSelectPanel({/>)}</TabsByEngine>- </div>- <div className="px-4 py-3 border-t flex justify-end gap-x-3">+ </SheetBody>+ <SheetFooter className="px-4 py-3"><Button variant="outline" onClick={onClose}>{t("common.close")}</Button>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}@@ -252,19 +253,13 @@ export function AttachResourcesPanel({if (!show) return null;return (- <div className="fixed inset-0 z-50 flex">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="ml-auto relative bg-background w-[40rem] max-w-[100vw] h-full shadow-lg flex flex-col">- <div className="px-4 py-3 border-b flex items-center justify-between">- <h2 className="text-lg font-medium">- {t("sql-review.attach-resource.self")}- </h2>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="size-4" />- </Button>- </div>+ <Sheet open={show} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="medium">+ <SheetHeader className="px-4 py-3">+ <SheetTitle>{t("sql-review.attach-resource.self")}</SheetTitle>+ </SheetHeader>- <div className="flex-1 overflow-y-auto p-4">+ <SheetBody className="p-4"><div className="flex flex-col gap-y-6"><p className="textinfolabel">{t("sql-review.attach-resource.label")}@@ -344,7 +339,7 @@ export function AttachResourcesPanel({</div></div></div>- </div>+ </SheetBody>{showOverrideConfirm && conflictingResources.length > 0 && (<div className="px-4 py-3 border-t">@@ -365,7 +360,7 @@ export function AttachResourcesPanel({</div>)}- <div className="px-4 py-3 border-t flex justify-end gap-x-2">+ <SheetFooter className="px-4 py-3"><Button variant="outline" onClick={onClose}>{t("common.cancel")}</Button>@@ -378,8 +373,8 @@ export function AttachResourcesPanel({{t("common.confirm")}</Button>)}- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/components/ui/sheet.tsx b/frontend/src/react/components/ui/sheet.tsxindex 2dc33cff02..0e2ae1102f 100644--- a/frontend/src/react/components/ui/sheet.tsx+++ b/frontend/src/react/components/ui/sheet.tsx@@ -2,6 +2,7 @@ import { Dialog as BaseDialog } from "@base-ui/react/dialog";import { cva, type VariantProps } from "class-variance-authority";import { X } from "lucide-react";import type { ComponentProps } from "react";+import { useTranslation } from "react-i18next";import { cn } from "@/react/lib/utils";import {getLayerRoot,@@ -61,8 +62,13 @@ const sheetContentVariants = cva(variants: {width: {narrow: "w-[24rem]",+ panel: "w-[31.25rem]",+ medium: "w-[40rem]",standard: "w-[44rem]",wide: "w-[52rem]",+ large: "w-[64rem]",+ xlarge: "w-[70rem]",+ workspace: "w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)]",},},defaultVariants: {@@ -108,6 +114,8 @@ function SheetContent({// optional `SheetDescription` — both are wrapped in a flex-col for the// vertical stack layout while the close button remains flush right.function SheetHeader({ className, children, ...props }: ComponentProps<"div">) {+ const { t } = useTranslation();+return (<divclassName={cn(@@ -120,7 +128,7 @@ function SheetHeader({ className, children, ...props }: ComponentProps<"div">) {{/* Built-in close affordance. Callers should not render their own closebutton — Base UI's Close dismisses the Sheet via Root's onOpenChange. */}<BaseDialog.Close- aria-label="Close"+ aria-label={t("common.close")}className="shrink-0 rounded-xs p-1 text-control hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent cursor-pointer"><X className="size-4" />diff --git a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx b/frontend/src/react/pages/project/ProjectDatabasesPage.tsxindex e82c87c73f..b1b99982c2 100644--- a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx+++ b/frontend/src/react/pages/project/ProjectDatabasesPage.tsx@@ -19,6 +19,12 @@ import {} from "@/react/components/database";import { EditEnvironmentSheet } from "@/react/components/EditEnvironmentSheet";import { PermissionGuard } from "@/react/components/PermissionGuard";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from "@/react/components/ui/alert-dialog";import { Button } from "@/react/components/ui/button";import { useVueState } from "@/react/hooks/useVueState";import {@@ -456,19 +462,20 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {{/* Unassign confirmation dialog */}{showUnassignConfirm && (- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div- className="fixed inset-0 bg-overlay/50"- onClick={() => setShowUnassignConfirm(false)}- />- <div className="relative bg-background rounded-sm shadow-lg p-6 max-w-md w-full mx-4">- <h3 className="text-lg font-semibold mb-2">+ <AlertDialog+ open+ onOpenChange={(nextOpen) =>+ !nextOpen && setShowUnassignConfirm(false)+ }+ >+ <AlertDialogContent>+ <AlertDialogTitle>{t("database.unassign-alert-title")}- </h3>- <p className="text-sm text-control-light mb-6">+ </AlertDialogTitle>+ <AlertDialogDescription className="mt-2">{t("database.unassign-alert-description")}- </p>- <div className="flex justify-end items-center gap-x-2">+ </AlertDialogDescription>+ <div className="mt-6 flex items-center justify-end gap-x-2"><Buttonvariant="ghost"onClick={() => setShowUnassignConfirm(false)}@@ -484,8 +491,8 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {{t("common.confirm")}</Button></div>- </div>- </div>+ </AlertDialogContent>+ </AlertDialog>)}</div>);diff --git a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsxindex b3afd268f2..dba98cfe7a 100644--- a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx+++ b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx@@ -27,6 +27,14 @@ import {} from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { SearchInput } from "@/react/components/ui/search-input";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import { Tooltip } from "@/react/components/ui/tooltip";import { useEscapeKey } from "@/react/hooks/useEscapeKey";import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";@@ -832,22 +840,15 @@ function AddSpecDrawer({if (!open) return null;return (- <div className="fixed inset-0 z-50 flex">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="ml-auto relative bg-background w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)] h-full shadow-lg flex flex-col">+ <Sheet open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="workspace">{/* Header */}- <div className="px-6 py-4 border-b border-control-border flex items-center justify-between">- <span className="text-lg font-semibold">{title}</span>- <button- className="p-1 hover:bg-control-bg rounded-xs"- onClick={onClose}- >- <X className="size-4" />- </button>- </div>+ <SheetHeader>+ <SheetTitle>{title}</SheetTitle>+ </SheetHeader>{/* Content */}- <div className="flex-1 overflow-y-auto p-6">+ <SheetBody className="p-6"><DatabaseAndGroupSelectorprojectName={projectName}changeSource={changeSource}@@ -857,10 +858,10 @@ function AddSpecDrawer({selectedDatabaseGroup={selectedDatabaseGroup}onSelectedDatabaseGroupChange={setSelectedDatabaseGroup}/>- </div>+ </SheetBody>{/* Footer */}- <div className="px-6 py-4 border-t border-control-border flex items-center justify-end gap-x-2">+ <SheetFooter><Button variant="outline" onClick={onClose}>{t("common.close")}</Button>@@ -868,9 +869,9 @@ function AddSpecDrawer({{creating && <Loader2 className="size-4 mr-1 animate-spin" />}{t("common.confirm")}</Button>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx b/frontend/src/react/pages/project/ProjectSyncSchemaPage.tsxindex e6a5a4256c..2743803ad8 100644--- a/frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx+++ b/frontend/src/react/pages/project/ProjectSyncSchemaPage.tsx@@ -31,8 +31,17 @@ import {DialogContent,DialogTitle,} from "@/react/components/ui/dialog";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";import { SearchInput } from "@/react/components/ui/search-input";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import { useClickOutside } from "@/react/hooks/useClickOutside";import { useEscapeKey } from "@/react/hooks/useEscapeKey";import { useVueState } from "@/react/hooks/useVueState";@@ -860,7 +869,12 @@ function ChangelogSelector({/></button>{open && (- <div className="absolute z-50 mt-1 min-w-full w-max bg-background border border-block-border rounded-sm shadow-lg overflow-hidden">+ <div+ className={cn(+ "absolute mt-1 min-w-full w-max bg-background border border-block-border rounded-sm shadow-lg overflow-hidden",+ LAYER_SURFACE_CLASS+ )}+ ><div className="max-h-60 overflow-y-auto">{entries.map((entry) => (<button@@ -1830,14 +1844,11 @@ function SchemaDiffViewerModal({modified: string;onClose: () => void;}) {- useEscapeKey(true, onClose);-return (- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="relative bg-background w-full h-screen flex flex-col p-4">+ <Dialog open onOpenChange={(open) => !open && onClose()}>+ <DialogContent className="flex h-screen max-h-screen w-full max-w-none flex-col rounded-none p-4 2xl:max-w-none"><div className="flex items-center justify-between mb-2">- <h2 className="text-lg font-semibold">{title}</h2>+ <DialogTitle>{title}</DialogTitle><Button variant="ghost" size="sm" onClick={onClose}>×</Button>@@ -1845,8 +1856,8 @@ function SchemaDiffViewerModal({<div className="flex-1 overflow-hidden"><SchemaDiffViewer title="" original={original} modified={modified} /></div>- </div>- </div>+ </DialogContent>+ </Dialog>);}@@ -2078,21 +2089,12 @@ function TargetDatabasesSelectPanel({}, [selected, onUpdate]);return (- <div className="fixed inset-0 z-50 flex">- <div className="fixed inset-0 bg-overlay/50" onClick={onClose} />- <div className="ml-auto relative bg-background w-[64rem] max-w-[100vw] h-full shadow-lg flex flex-col">+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="large">{/* Header */}- <div className="flex items-center justify-between px-6 py-4 border-b border-control-border">- <h2 className="text-lg font-semibold">- {t("database.sync-schema.target-databases")}- </h2>- <button- className="p-1 hover:bg-control-bg rounded-xs"- onClick={onClose}- >- ×- </button>- </div>+ <SheetHeader>+ <SheetTitle>{t("database.sync-schema.target-databases")}</SheetTitle>+ </SheetHeader>{/* Search */}<div className="px-6 pt-4">@@ -2104,7 +2106,7 @@ function TargetDatabasesSelectPanel({</div>{/* Database list */}- <div className="flex-1 overflow-y-auto px-6 py-2">+ <SheetBody className="px-6 py-2">{loading ? (<div className="flex items-center justify-center py-8"><div className="animate-spin rounded-full size-6 border-b-2 border-control-placeholder" />@@ -2192,10 +2194,10 @@ function TargetDatabasesSelectPanel({)}</>)}- </div>+ </SheetBody>{/* Footer */}- <div className="flex items-center justify-between px-6 py-4 border-t border-control-border">+ <SheetFooter className="justify-between"><div className="textinfolabel">{t("database.selected-n-databases", { n: selected.size })}</div>@@ -2207,8 +2209,8 @@ function TargetDatabasesSelectPanel({{t("common.select")}</Button></div>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx b/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsxindex 2e33797185..a78e9d95f1 100644--- a/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx+++ b/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx@@ -28,6 +28,7 @@ import {DialogContent,DialogTitle,} from "@/react/components/ui/dialog";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import {Sheet,SheetBody,@@ -509,7 +510,12 @@ export function IssueDetailActionBar() {</span></Tooltip>{menuOpen && (- <div className="absolute right-0 top-full z-40 mt-1 min-w-44 overflow-hidden rounded-sm border border-control-border bg-white py-1 shadow-lg">+ <div+ className={cn(+ "absolute right-0 top-full mt-1 min-w-44 overflow-hidden rounded-sm border border-control-border bg-white py-1 shadow-lg",+ LAYER_SURFACE_CLASS+ )}+ >{secondaryActions.map((action) => {const disabled = isActionDisabled(action) || isSubmitting;return (@@ -908,7 +914,10 @@ function IssueDetailReviewPopover({return (<div- className="absolute right-0 top-full z-40 mt-2 w-[min(34rem,calc(100vw-2rem))] rounded-sm border border-control-border bg-white px-4 py-4 shadow-lg"+ className={cn(+ "absolute right-0 top-full mt-2 w-[min(34rem,calc(100vw-2rem))] rounded-sm border border-control-border bg-white px-4 py-4 shadow-lg",+ LAYER_SURFACE_CLASS+ )}ref={popoverRef}>{content}diff --git a/frontend/src/react/pages/project/issue-detail/components/IssueDetailLabels.tsx b/frontend/src/react/pages/project/issue-detail/components/IssueDetailLabels.tsxindex 08ecd38930..a38447e1d3 100644--- a/frontend/src/react/pages/project/issue-detail/components/IssueDetailLabels.tsx+++ b/frontend/src/react/pages/project/issue-detail/components/IssueDetailLabels.tsx@@ -9,6 +9,7 @@ import {} from "react";import { useTranslation } from "react-i18next";import { issueServiceClientConnect } from "@/connect";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { useClickOutside } from "@/react/hooks/useClickOutside";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";@@ -183,7 +184,12 @@ export function IssueDetailLabels() {</button>{open && (- <div className="absolute z-50 mt-1 w-full overflow-hidden rounded-sm border border-control-border bg-white shadow-lg">+ <div+ className={cn(+ "absolute mt-1 w-full overflow-hidden rounded-sm border border-control-border bg-white shadow-lg",+ LAYER_SURFACE_CLASS+ )}+ ><div className="max-h-60 overflow-y-auto">{options.length === 0 ? (<div className="flex flex-col items-center gap-y-3 px-3 py-6 text-sm text-control-placeholder">diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsxindex 5001647bb2..31feb11ca7 100644--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx@@ -1,6 +1,6 @@import { clone, create } from "@bufbuild/protobuf";import { Ban, ChevronUp, Loader2, Menu, Plus } from "lucide-react";-import { useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { issueServiceClientConnect, planServiceClientConnect } from "@/connect";import {@@ -9,7 +9,11 @@ import {} from "@/react/components/IssueLabelSelect";import { MarkdownEditor } from "@/react/components/MarkdownEditor";import { Button } from "@/react/components/ui/button";-import { useClickOutside } from "@/react/hooks/useClickOutside";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/react/components/ui/popover";import { cn } from "@/react/lib/utils";import { router } from "@/router";import {@@ -65,7 +69,6 @@ export function PlanDetailHeader() {const [checksWarningAcknowledged, setChecksWarningAcknowledged] =useState(false);const [submittingReview, setSubmittingReview] = useState(false);- const reviewPopoverRef = useRef<HTMLDivElement>(null);const { emptySpecIdSet } = usePlanDetailSpecValidation(page.plan.specs ?? []);useEffect(() => {@@ -357,10 +360,6 @@ export function PlanDetailHeader() {}};- useClickOutside(reviewPopoverRef, showReviewPopover, () =>- handleReviewPopoverOpenChange(false)- );-const isDescriptionLong =(description?.length ?? 0) > 150 ||(description?.split("\n").length ?? 0) > 3;@@ -474,34 +473,41 @@ export function PlanDetailHeader() {) : (<>{showSubmitForReview && (- <div className="relative" ref={reviewPopoverRef}>- <Button- disabled={submitDisabled}- onClick={() => handleReviewPopoverOpenChange(true)}- title={submitDisabledReason}+ <Popover+ open={showReviewPopover}+ onOpenChange={handleReviewPopoverOpenChange}+ >+ <PopoverTrigger+ render={+ <Button+ disabled={submitDisabled}+ title={submitDisabledReason}+ />+ }>{t("plan.ready-for-review")}- </Button>- {showReviewPopover && (- <div className="absolute right-0 top-full z-40 mt-2 w-[min(28rem,calc(100vw-2rem))] rounded-sm border border-control-border bg-white px-4 py-4 shadow-lg">- <ReadyForReviewPopoverContent- checksWarningAcknowledged={checksWarningAcknowledged}- confirmErrors={createIssueConfirmErrors}- forceIssueLabels={project.forceIssueLabels}- issueLabels={project.issueLabels ?? []}- onCancel={() => handleReviewPopoverOpenChange(false)}- onChecksWarningAcknowledgedChange={- setChecksWarningAcknowledged- }- onConfirm={() => void handleCreateIssue()}- onSelectedLabelsChange={setSelectedLabels}- selectedLabels={selectedLabels}- showChecksWarning={showChecksWarning}- submitting={submittingReview}- />- </div>- )}- </div>+ </PopoverTrigger>+ <PopoverContent+ align="end"+ className="w-[min(28rem,calc(100vw-2rem))] px-4 py-4"+ >+ <ReadyForReviewPopoverContent+ checksWarningAcknowledged={checksWarningAcknowledged}+ confirmErrors={createIssueConfirmErrors}+ forceIssueLabels={project.forceIssueLabels}+ issueLabels={project.issueLabels ?? []}+ onCancel={() => handleReviewPopoverOpenChange(false)}+ onChecksWarningAcknowledgedChange={+ setChecksWarningAcknowledged+ }+ onConfirm={() => void handleCreateIssue()}+ onSelectedLabelsChange={setSelectedLabels}+ selectedLabels={selectedLabels}+ showChecksWarning={showChecksWarning}+ submitting={submittingReview}+ />+ </PopoverContent>+ </Popover>)}{showClosePlan && (<Buttondiff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsxindex 9546c33060..6acc20cec4 100644--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailMetadataSidebar.tsx@@ -10,6 +10,11 @@ import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { issueServiceClientConnect } from "@/connect";import { Button } from "@/react/components/ui/button";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/react/components/ui/popover";import { Tooltip } from "@/react/components/ui/tooltip";import { cn } from "@/react/lib/utils";import {@@ -298,17 +303,20 @@ function IssueLabelsSection({<div className="flex items-center gap-x-1 textinfolabel"><span>{t("issue.labels")}</span></div>- <div className="relative">- <button- className={cn(- "flex min-h-9 w-full items-center justify-between gap-2 rounded-sm border border-control-border bg-white px-3 py-1.5 text-left text-sm transition-colors",- allowChange && !isUpdating && "hover:bg-control-bg",- open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]",- (!allowChange || isUpdating) && "cursor-not-allowed opacity-60"- )}- disabled={!allowChange || isUpdating}- onClick={() => setOpen((current) => !current)}- type="button"+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger+ render={+ <button+ className={cn(+ "flex min-h-9 w-full items-center justify-between gap-2 rounded-sm border border-control-border bg-white px-3 py-1.5 text-left text-sm transition-colors",+ allowChange && !isUpdating && "hover:bg-control-bg",+ open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]",+ (!allowChange || isUpdating) && "cursor-not-allowed opacity-60"+ )}+ disabled={!allowChange || isUpdating}+ type="button"+ />+ }><div className="flex min-w-0 flex-1 flex-wrap items-center gap-1.5">{labels.length > 0 ? (@@ -333,45 +341,50 @@ function IssueLabelsSection({</span>)}</div>- </button>+ </PopoverTrigger>- {open && (- <div className="absolute z-50 mt-1 w-full overflow-hidden rounded-sm border border-control-border bg-white shadow-lg">- <div className="max-h-60 overflow-y-auto">- {options.length === 0 ? (- <div className="px-3 py-6 text-sm text-control-placeholder">- {t("common.no-data")}- </div>- ) : (- options.map((option) => {- const isSelected = labels.includes(option.value);- return (- <button- key={option.value}- className="flex w-full items-center gap-x-2 px-3 py-2 text-left text-sm transition-colors hover:bg-control-bg"- disabled={isUpdating}- onClick={() => void toggleLabel(option.value)}- type="button"- >- <input- checked={isSelected}- className="accent-accent"- readOnly- type="checkbox"- />- <span- className="size-4 shrink-0 rounded-sm"- style={{ backgroundColor: option.color }}- />- <span>{option.value}</span>- </button>- );- })- )}- </div>+ <PopoverContent+ side="bottom"+ align="start"+ initialFocus={false}+ finalFocus={false}+ style={{ width: "var(--anchor-width)" }}+ className="overflow-hidden bg-white p-0"+ >+ <div className="max-h-60 overflow-y-auto">+ {options.length === 0 ? (+ <div className="px-3 py-6 text-sm text-control-placeholder">+ {t("common.no-data")}+ </div>+ ) : (+ options.map((option) => {+ const isSelected = labels.includes(option.value);+ return (+ <button+ key={option.value}+ className="flex w-full items-center gap-x-2 px-3 py-2 text-left text-sm transition-colors hover:bg-control-bg"+ disabled={isUpdating}+ onClick={() => void toggleLabel(option.value)}+ type="button"+ >+ <input+ checked={isSelected}+ className="accent-accent"+ readOnly+ type="checkbox"+ />+ <span+ className="size-4 shrink-0 rounded-sm"+ style={{ backgroundColor: option.color }}+ />+ <span>{option.value}</span>+ </button>+ );+ })+ )}</div>- )}- </div>+ </PopoverContent>+ </Popover></div>);}diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsxindex ae81035a33..fdaea1bafd 100644--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx@@ -33,7 +33,13 @@ import { FeatureBadge } from "@/react/components/FeatureBadge";import { PermissionGuard } from "@/react/components/PermissionGuard";import { ResourceIdField } from "@/react/components/ResourceIdField";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";+import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import {Sheet,SheetBody,@@ -341,7 +347,12 @@ function RolloutPolicyConfig({{t("common.add")}</Button>{showRoleDropdown && (- <div className="absolute z-50 mt-1 w-64 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md">+ <div+ className={cn(+ "absolute mt-1 w-64 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md",+ LAYER_SURFACE_CLASS+ )}+ >{availableRoles.map((group) => (<div key={group.label}><div className="px-2 py-1 text-xs font-semibold text-gray-500 uppercase">@@ -557,7 +568,12 @@ function SQLReviewSectionInner({t("sql-review.configure-policy")}</Button>{showSelectPanel && (- <div className="absolute z-50 mt-1 w-80 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md">+ <div+ className={cn(+ "absolute mt-1 w-80 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md",+ LAYER_SURFACE_CLASS+ )}+ >{reviewPolicyList.length === 0 ? (<div className="px-3 py-2 text-sm text-gray-400">{t("common.no-data")}@@ -956,61 +972,63 @@ function EnvironmentDetail({{/* Delete confirmation dialog */}{showDeleteConfirm && (- <>- <div- className="fixed inset-0 z-40 bg-black/30"- onClick={() => setShowDeleteConfirm(false)}- />- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div className="bg-white rounded-sm shadow-xl p-6 max-w-md w-full mx-4">- <h3 className="text-lg font-medium mb-2">- {t("common.delete")} '{editTitle}'?- </h3>- <div className="mt-3">- {existRelatedResource && (- <label className="flex items-start gap-x-2 mb-2">- <input- type="checkbox"- checked={confirmDelete}- onChange={(e) => setConfirmDelete(e.target.checked)}- className="mt-0.5 rounded-xs border-gray-300"- />- <span className="text-sm text-gray-600">- {t("environment.delete-description")}- </span>- </label>- )}- {!existRelatedResource && (+ <Dialog+ open={showDeleteConfirm}+ onOpenChange={(open) => {+ if (!open) {+ setShowDeleteConfirm(false);+ setConfirmDelete(false);+ }+ }}+ >+ <DialogContent className="max-w-md p-6">+ <DialogTitle className="mb-2 text-lg font-medium">+ {t("common.delete")} '{editTitle}'?+ </DialogTitle>+ <div className="mt-3">+ {existRelatedResource && (+ <label className="flex items-start gap-x-2 mb-2">+ <input+ type="checkbox"+ checked={confirmDelete}+ onChange={(e) => setConfirmDelete(e.target.checked)}+ className="mt-0.5 rounded-xs border-gray-300"+ /><span className="text-sm text-gray-600">- {t("common.cannot-undo-this-action")}+ {t("environment.delete-description")}</span>- )}- </div>- <div className="flex justify-end gap-x-2 mt-4">- <Button- variant="outline"- onClick={() => {- setShowDeleteConfirm(false);- setConfirmDelete(false);- }}- >- {t("common.cancel")}- </Button>- <Button- variant="destructive"- disabled={existRelatedResource && !confirmDelete}- onClick={() => {- setShowDeleteConfirm(false);- setConfirmDelete(false);- onDelete(environment);- }}- >- {t("common.delete")}- </Button>- </div>+ </label>+ )}+ {!existRelatedResource && (+ <span className="text-sm text-gray-600">+ {t("common.cannot-undo-this-action")}+ </span>+ )}</div>- </div>- </>+ <div className="flex justify-end gap-x-2 mt-4">+ <Button+ variant="outline"+ onClick={() => {+ setShowDeleteConfirm(false);+ setConfirmDelete(false);+ }}+ >+ {t("common.cancel")}+ </Button>+ <Button+ variant="destructive"+ disabled={existRelatedResource && !confirmDelete}+ onClick={() => {+ setShowDeleteConfirm(false);+ setConfirmDelete(false);+ onDelete(environment);+ }}+ >+ {t("common.delete")}+ </Button>+ </div>+ </DialogContent>+ </Dialog>)}</div>);diff --git a/frontend/src/react/pages/settings/IDPDetailPage.tsx b/frontend/src/react/pages/settings/IDPDetailPage.tsxindex 61bb8d5b4b..1cc4b018be 100644--- a/frontend/src/react/pages/settings/IDPDetailPage.tsx+++ b/frontend/src/react/pages/settings/IDPDetailPage.tsx@@ -1,14 +1,25 @@import { create } from "@bufbuild/protobuf";import type { ConnectError } from "@connectrpc/connect";import { cloneDeep, isEqual } from "lodash-es";-import { ArrowRight, Database, Info, Key, ShieldCheck, X } from "lucide-react";+import { ArrowRight, Database, Info, Key, ShieldCheck } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { identityProviderServiceClientConnect } from "@/connect";import { LearnMoreLink } from "@/react/components/LearnMoreLink";import { PermissionGuard } from "@/react/components/PermissionGuard";import { ResourceIdField } from "@/react/components/ResourceIdField";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from "@/react/components/ui/alert-dialog";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";import { router } from "@/router";@@ -69,35 +80,17 @@ function TestConnectionResultDialog({}) {const { t } = useTranslation();- useEffect(() => {- const handler = (e: KeyboardEvent) => {- if (e.key === "Escape") onClose();- };- document.addEventListener("keydown", handler);- return () => document.removeEventListener("keydown", handler);- }, [onClose]);-return (- <div- className="fixed inset-0 z-[60] flex items-center justify-center bg-overlay/50"- onClick={(e) => {- if (e.target === e.currentTarget) onClose();- }}- >- <div className="bg-background rounded-sm shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-x-2">- <div className="size-6 text-success">✓</div>- <h3 className="text-lg font-medium">- {t("identity-provider.test-connection-success")}- </h3>- </div>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="h-4 w-4" />- </Button>+ <Dialog open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <DialogContent className="w-[32rem] max-w-[calc(100vw-2rem)] p-6">+ <div className="flex items-center gap-x-2">+ <div className="size-6 text-success">✓</div>+ <DialogTitle>+ {t("identity-provider.test-connection-success")}+ </DialogTitle></div>- <div className="flex flex-col gap-y-4">+ <div className="mt-4 flex flex-col gap-y-4"><p className="text-sm text-control-light">{t("identity-provider.userinfo-description")}</p>@@ -162,8 +155,8 @@ function TestConnectionResultDialog({<div className="flex justify-end mt-4"><Button onClick={onClose}>{t("common.close")}</Button></div>- </div>- </div>+ </DialogContent>+ </Dialog>);}@@ -332,27 +325,14 @@ function DeleteConfirmDialog({}) {const { t } = useTranslation();- useEffect(() => {- const handler = (e: KeyboardEvent) => {- if (e.key === "Escape") onCancel();- };- document.addEventListener("keydown", handler);- return () => document.removeEventListener("keydown", handler);- }, [onCancel]);-return (- <div- className="fixed inset-0 z-[60] flex items-center justify-center bg-overlay/50"- onClick={(e) => {- if (e.target === e.currentTarget) onCancel();- }}- >- <div className="bg-background rounded-sm shadow-lg w-96 p-6">- <h3 className="text-lg font-medium mb-2">{t("settings.sso.delete")}</h3>- <p className="text-sm text-control-light mb-6">+ <AlertDialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <AlertDialogContent>+ <AlertDialogTitle>{t("settings.sso.delete")}</AlertDialogTitle>+ <AlertDialogDescription className="mt-2">{t("identity-provider.delete-warning")}- </p>- <div className="flex justify-end gap-x-2">+ </AlertDialogDescription>+ <div className="mt-6 flex justify-end gap-x-2"><Button variant="outline" onClick={onCancel}>{t("common.cancel")}</Button>@@ -360,8 +340,8 @@ function DeleteConfirmDialog({{t("common.delete")}</Button></div>- </div>- </div>+ </AlertDialogContent>+ </AlertDialog>);}diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsxindex 6b9f5ea6a3..86cc745163 100644--- a/frontend/src/react/pages/settings/IDPsPage.tsx+++ b/frontend/src/react/pages/settings/IDPsPage.tsx@@ -11,7 +11,6 @@ import {Key,Plus,ShieldCheck,- X,} from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";@@ -25,7 +24,20 @@ import {type ResourceIdFieldRef,} from "@/react/components/ResourceIdField";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import {Table,TableBody,@@ -197,29 +209,18 @@ function TestConnectionResultDialog({onClose: () => void;}) {const { t } = useTranslation();- useEscapeKey(onClose);return (- <div- className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50"- onClick={(e) => {- if (e.target === e.currentTarget) onClose();- }}- >- <div className="bg-white rounded-sm shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-x-2">- <div className="w-6 h-6 text-green-500">✓</div>- <h3 className="text-lg font-medium">- {t("identity-provider.test-connection-success")}- </h3>- </div>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="h-4 w-4" />- </Button>+ <Dialog open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <DialogContent className="w-[32rem] max-w-[calc(100vw-2rem)] p-6">+ <div className="flex items-center gap-x-2">+ <div className="size-6 text-success">✓</div>+ <DialogTitle>+ {t("identity-provider.test-connection-success")}+ </DialogTitle></div>- <div className="flex flex-col gap-y-4">+ <div className="mt-4 flex flex-col gap-y-4"><p className="text-sm text-control-light">{t("identity-provider.userinfo-description")}</p>@@ -284,8 +285,8 @@ function TestConnectionResultDialog({<div className="flex justify-end mt-4"><Button onClick={onClose}>{t("common.close")}</Button></div>- </div>- </div>+ </DialogContent>+ </Dialog>);}@@ -1650,19 +1651,14 @@ function CreateWizardDrawer({const mappingStep = isOAuth2 ? 5 : 4;return (- <>- <div className="fixed inset-0 z-40 bg-black/30" onClick={onClose} />- <div className="fixed inset-y-0 right-0 z-50 w-[64rem] max-w-[100vw] bg-white shadow-xl flex flex-col">- {/* Header */}- <div className="flex items-center justify-between px-6 py-4 border-b">- <h2 className="text-lg font-medium">{t("identity-provider.self")}</h2>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="h-5 w-5" />- </Button>- </div>+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="large" className="bg-white">+ <SheetHeader>+ <SheetTitle>{t("identity-provider.self")}</SheetTitle>+ </SheetHeader>{/* Content */}- <div className="flex-1 overflow-auto px-6 py-6">+ <SheetBody className="px-6 py-6"><div className="flex flex-col gap-y-6">{/* Step indicators */}<div className="flex items-center gap-x-2">@@ -1935,10 +1931,10 @@ function CreateWizardDrawer({)}</div></div>- </div>+ </SheetBody>{/* Footer */}- <div className="flex items-center justify-end gap-x-2 px-6 py-4 border-t">+ <SheetFooter>{currentStep === 1 ? (<Button variant="outline" onClick={onClose}>{t("common.cancel")}@@ -1957,15 +1953,15 @@ function CreateWizardDrawer({{t("common.create")}</Button>)}- </div>+ </SheetFooter>{isCreating && (<div className="absolute inset-0 z-10 bg-white/50 flex items-center justify-center"><div className="animate-spin h-6 w-6 border-2 border-accent border-t-transparent rounded-full" /></div>)}- </div>- </>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/pages/settings/InstancesPage.tsx b/frontend/src/react/pages/settings/InstancesPage.tsxindex d7217ec1ca..7a3c95104e 100644--- a/frontend/src/react/pages/settings/InstancesPage.tsx+++ b/frontend/src/react/pages/settings/InstancesPage.tsx@@ -1,6 +1,5 @@import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";-import { sortBy, uniq } from "lodash-es";import {ChevronDown,ChevronUp,@@ -27,6 +26,12 @@ import {AlertDescription,AlertTitle,} from "@/react/components/ui/alert";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from "@/react/components/ui/alert-dialog";import { Button } from "@/react/components/ui/button";import {DropdownMenu,@@ -44,6 +49,10 @@ import {SheetTitle,} from "@/react/components/ui/sheet";import { PagedTableFooter } from "@/react/hooks/usePagedData";+import {+ getPageSizeOptions,+ useSessionPageSize,+} from "@/react/hooks/useSessionPageSize";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { router } from "@/router";@@ -52,7 +61,6 @@ import {featureToRef,pushNotification,useActuatorV1Store,- useCurrentUserV1,useEnvironmentV1Store,useInstanceV1Store,useSubscriptionV1Store,@@ -75,7 +83,6 @@ import {} from "@/types/proto-es/v1/subscription_service_pb";import {engineNameV1,- getDefaultPagination,hasWorkspacePermissionV2,hexToRgb,hostPortOfDataSource,@@ -83,56 +90,6 @@ import {supportedEngineV1List,} from "@/utils";-// ============================================================-// Pagination helpers-// ============================================================--const PAGE_SIZE_OPTIONS = [50, 100, 200, 500];--function getPageSizeOptions(): number[] {- const defaultSize = getDefaultPagination();- return sortBy(uniq([defaultSize, ...PAGE_SIZE_OPTIONS]));-}--function useSessionPageSize(- sessionKey: string-): [number, (size: number) => void] {- const currentUser = useCurrentUserV1();- const email = useVueState(() => currentUser.value.email);- const storageKey = `bb.paged-table.${sessionKey}.${email}`;-- const [pageSize, setPageSize] = useState<number>(() => {- try {- const stored = localStorage.getItem(storageKey);- if (stored) {- const parsed = JSON.parse(stored);- const size = parsed?.pageSize;- const options = getPageSizeOptions();- if (typeof size === "number" && options.includes(size)) {- return Math.max(options[0], size);- }- }- } catch {- // ignore- }- return getPageSizeOptions()[0];- });-- const updatePageSize = useCallback(- (size: number) => {- setPageSize(size);- try {- localStorage.setItem(storageKey, JSON.stringify({ pageSize: size }));- } catch {- // ignore- }- },- [storageKey]- );-- return [pageSize, updatePageSize];-}-// ============================================================// Shared hooks// ============================================================@@ -154,17 +111,6 @@ function useClickOutside(}, [ref, active, onClose]);}-function useEscapeKey(active: boolean, onClose: () => void) {- useEffect(() => {- if (!active) return;- const handler = (e: KeyboardEvent) => {- if (e.key === "Escape") onClose();- };- document.addEventListener("keydown", handler);- return () => document.removeEventListener("keydown", handler);- }, [active, onClose]);-}-// ============================================================// ConfirmDialog// ============================================================@@ -189,7 +135,6 @@ function ConfirmDialog({children?: React.ReactNode;}) {const { t } = useTranslation();- useEscapeKey(open, onCancel);if (!open) return null;@@ -200,20 +145,14 @@ function ConfirmDialog({: "bg-warning hover:bg-warning-hover text-accent-text";return (- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div className="fixed inset-0 bg-overlay/50" onClick={onCancel} />- <div- className={cn(- "relative bg-background rounded-sm shadow-lg max-w-lg w-full mx-4 border-t-4",- borderColor- )}- >- <div className="p-6">- <h3 className="text-lg font-semibold mb-2">{title}</h3>- <p className="text-sm text-control-light mb-4">{description}</p>- {children}- </div>- <div className="flex justify-end gap-x-2 px-6 pb-6">+ <AlertDialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <AlertDialogContent className={cn("max-w-lg border-t-4", borderColor)}>+ <AlertDialogTitle>{title}</AlertDialogTitle>+ <AlertDialogDescription className="mt-2">+ {description}+ </AlertDialogDescription>+ {children && <div className="mt-4">{children}</div>}+ <div className="mt-6 flex justify-end gap-x-2"><Button variant="outline" onClick={onCancel}>{t("common.cancel")}</Button>@@ -227,8 +166,8 @@ function ConfirmDialog({{okText}</button></div>- </div>- </div>+ </AlertDialogContent>+ </AlertDialog>);}diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsxindex 5b0c1da288..8b73ac856f 100644--- a/frontend/src/react/pages/settings/MembersPage.tsx+++ b/frontend/src/react/pages/settings/MembersPage.tsx@@ -44,6 +44,14 @@ import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { SearchInput } from "@/react/components/ui/search-input";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import {Tabs,TabsList,@@ -1265,185 +1273,179 @@ function EditMemberRoleDrawer({const memberEmail = member.user?.email ?? member.binding;return (<>- <div className="fixed inset-0 z-40 bg-overlay/30" onClick={onClose} />- <div- role="dialog"- aria-modal="true"- className="fixed inset-y-0 right-0 z-50 w-[40rem] max-w-[100vw] bg-background shadow-xl flex flex-col"- >- {/* Header */}- <div className="flex items-center justify-between px-6 py-4 border-b">- <h2 className="text-lg font-medium">- {t("project.members.edit-member", {- member: `${member.title} (${memberEmail})`,- })}- </h2>- <div className="flex items-center gap-x-2">- <Button- variant="outline"- onClick={() => setShowNestedGrant(true)}- >- <Plus className="h-4 w-4 mr-1" />- {t("settings.members.grant-access")}- </Button>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="h-5 w-5" />- </Button>- </div>- </div>-- {/* Body — Role Bindings */}- <div className="flex-1 overflow-auto px-6 py-6">- <div className="flex flex-col gap-y-6">- {liveProjectRoleBindings.length === 0 && (- <div className="text-center text-control-light py-8">- {t("common.no-data")}- </div>- )}- {liveProjectRoleBindings.map((binding, idx) => {- const rows = getSingleBindingRows(binding);- const envs = roleHasEnvironmentLimitation(binding.role)- ? getEnvironmentLimitation(binding)- : [];- const showEnvBanner = roleHasEnvironmentLimitation(- binding.role- );- return (- <div- key={`${binding.role}-${idx}`}- className="border rounded-sm"- >- {/* Role header */}- <div className="flex items-center justify-between px-4 py-3 bg-control-bg border-b">- <span className="font-medium text-sm">- {displayRoleTitle(binding.role)}- </span>- <div className="flex items-center gap-x-1">- <Button- variant="ghost"- size="icon"- title={t("common.edit")}- onClick={() => setShowNestedGrant(true)}- >- <Pencil className="h-4 w-4" />- </Button>- <Button- variant="ghost"- size="icon"- title={t("common.delete")}- disabled={isRequesting}- onClick={() => handleDeleteRole(binding)}- >- <Trash2 className="h-4 w-4" />- </Button>+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="medium">+ <SheetHeader>+ <div className="flex min-w-0 items-center justify-between gap-x-2">+ <SheetTitle className="truncate">+ {t("project.members.edit-member", {+ member: `${member.title} (${memberEmail})`,+ })}+ </SheetTitle>+ <Button+ variant="outline"+ onClick={() => setShowNestedGrant(true)}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.members.grant-access")}+ </Button>+ </div>+ </SheetHeader>++ {/* Body — Role Bindings */}+ <SheetBody className="px-6 py-6">+ <div className="flex flex-col gap-y-6">+ {liveProjectRoleBindings.length === 0 && (+ <div className="text-center text-control-light py-8">+ {t("common.no-data")}+ </div>+ )}+ {liveProjectRoleBindings.map((binding, idx) => {+ const rows = getSingleBindingRows(binding);+ const envs = roleHasEnvironmentLimitation(binding.role)+ ? getEnvironmentLimitation(binding)+ : [];+ const showEnvBanner = roleHasEnvironmentLimitation(+ binding.role+ );+ return (+ <div+ key={`${binding.role}-${idx}`}+ className="border rounded-sm"+ >+ {/* Role header */}+ <div className="flex items-center justify-between px-4 py-3 bg-control-bg border-b">+ <span className="font-medium text-sm">+ {displayRoleTitle(binding.role)}+ </span>+ <div className="flex items-center gap-x-1">+ <Button+ variant="ghost"+ size="icon"+ title={t("common.edit")}+ onClick={() => setShowNestedGrant(true)}+ >+ <Pencil className="h-4 w-4" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ title={t("common.delete")}+ disabled={isRequesting}+ onClick={() => handleDeleteRole(binding)}+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </div></div>- </div>- {/* Environment info banner */}- {showEnvBanner && (- <div className="mx-4 mt-3 flex items-start gap-x-2 rounded-sm bg-blue-50 border border-blue-200 px-3 py-2 text-xs text-blue-700">- <Info className="h-4 w-4 shrink-0 mt-0.5" />- <div>- {envs.length > 0 ? (- <>- <span>{t("project.members.allow-ddl")}</span>- <div className="flex flex-wrap gap-1 mt-1">- {envs.map((env) => (- <Badge- key={env}- variant="secondary"- className="text-xs"- >- <EnvironmentLabel- environmentName={env}+ {/* Environment info banner */}+ {showEnvBanner && (+ <div className="mx-4 mt-3 flex items-start gap-x-2 rounded-sm bg-blue-50 border border-blue-200 px-3 py-2 text-xs text-blue-700">+ <Info className="h-4 w-4 shrink-0 mt-0.5" />+ <div>+ {envs.length > 0 ? (+ <>+ <span>{t("project.members.allow-ddl")}</span>+ <div className="flex flex-wrap gap-1 mt-1">+ {envs.map((env) => (+ <Badge+ key={env}+ variant="secondary"className="text-xs"- />- </Badge>- ))}- </div>- </>- ) : (- <span>- {t(- "project.members.disallow-ddl-all-environments"- )}- </span>- )}+ >+ <EnvironmentLabel+ environmentName={env}+ className="text-xs"+ />+ </Badge>+ ))}+ </div>+ </>+ ) : (+ <span>+ {t(+ "project.members.disallow-ddl-all-environments"+ )}+ </span>+ )}+ </div></div>- </div>- )}+ )}- {/* Database resources table */}- <div className="p-4">- <table className="w-full text-sm">- <thead>- <tr className="border-b">- <th className="px-2 py-1.5 text-left font-medium text-control-light">- {t("common.database")}- </th>- <th className="px-2 py-1.5 text-left font-medium text-control-light">- {t("common.schema")}- </th>- <th className="px-2 py-1.5 text-left font-medium text-control-light">- {t("common.table")}- </th>- <th className="px-2 py-1.5 text-left font-medium text-control-light">- {t("common.expiration")}- </th>- </tr>- </thead>- <tbody>- {rows.map((row, rowIdx) => (- <tr- key={rowIdx}- className="border-b last:border-b-0"- >- <td className="px-2 py-1.5 text-sm">- {row.databaseResource?.databaseFullName ?? "*"}- </td>- <td className="px-2 py-1.5 text-sm">- {row.databaseResource?.schema ?? "*"}- </td>- <td className="px-2 py-1.5 text-sm">- {row.databaseResource?.table ?? "*"}- </td>- <td className="px-2 py-1.5 text-sm">- {row.expiration- ? formatAbsoluteDateTime(- row.expiration.getTime()- )- : t("project.members.never-expires")}- </td>+ {/* Database resources table */}+ <div className="p-4">+ <table className="w-full text-sm">+ <thead>+ <tr className="border-b">+ <th className="px-2 py-1.5 text-left font-medium text-control-light">+ {t("common.database")}+ </th>+ <th className="px-2 py-1.5 text-left font-medium text-control-light">+ {t("common.schema")}+ </th>+ <th className="px-2 py-1.5 text-left font-medium text-control-light">+ {t("common.table")}+ </th>+ <th className="px-2 py-1.5 text-left font-medium text-control-light">+ {t("common.expiration")}+ </th></tr>- ))}- </tbody>- </table>+ </thead>+ <tbody>+ {rows.map((row, rowIdx) => (+ <tr+ key={rowIdx}+ className="border-b last:border-b-0"+ >+ <td className="px-2 py-1.5 text-sm">+ {row.databaseResource?.databaseFullName ??+ "*"}+ </td>+ <td className="px-2 py-1.5 text-sm">+ {row.databaseResource?.schema ?? "*"}+ </td>+ <td className="px-2 py-1.5 text-sm">+ {row.databaseResource?.table ?? "*"}+ </td>+ <td className="px-2 py-1.5 text-sm">+ {row.expiration+ ? formatAbsoluteDateTime(+ row.expiration.getTime()+ )+ : t("project.members.never-expires")}+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div></div>- </div>- );- })}- </div>- </div>+ );+ })}+ </div>+ </SheetBody>- {/* Footer */}- <div className="flex items-center justify-between px-6 py-4 border-t">- <div>- <Button- variant="destructive"- disabled={isRequesting}- onClick={handleRevoke}- >- {t("settings.members.revoke-access")}- </Button>- </div>- <div className="flex items-center gap-x-2">- <Button variant="outline" onClick={onClose}>- {t("common.cancel")}- </Button>- <Button onClick={onClose}>{t("common.ok")}</Button>- </div>- </div>- </div>+ {/* Footer */}+ <SheetFooter className="justify-between">+ <div>+ <Button+ variant="destructive"+ disabled={isRequesting}+ onClick={handleRevoke}+ >+ {t("settings.members.revoke-access")}+ </Button>+ </div>+ <div className="flex items-center gap-x-2">+ <Button variant="outline" onClick={onClose}>+ {t("common.cancel")}+ </Button>+ <Button onClick={onClose}>{t("common.ok")}</Button>+ </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>{/* Nested grant access drawer (stacked on top, member pre-selected) */}{showNestedGrant && (@@ -1459,23 +1461,13 @@ function EditMemberRoleDrawer({// Workspace edit mode, workspace/project create mode — original UIreturn (- <>- <div className="fixed inset-0 z-40 bg-overlay/30" onClick={onClose} />- <div- role="dialog"- aria-modal="true"- className="fixed inset-y-0 right-0 z-50 w-[40rem] max-w-[100vw] bg-background shadow-xl flex flex-col"- >- <div className="flex items-center justify-between px-6 py-4 border-b">- <h2 className="text-lg font-medium">- {t("common.members", { count: 1 })}- </h2>- <Button variant="ghost" size="icon" onClick={onClose}>- <X className="h-5 w-5" />- </Button>- </div>+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onClose()}>+ <SheetContent width="medium">+ <SheetHeader>+ <SheetTitle>{t("common.members", { count: 1 })}</SheetTitle>+ </SheetHeader>- <div className="flex-1 overflow-auto px-6 py-6">+ <SheetBody className="px-6 py-6"><div className="flex flex-col gap-y-6">{!isEditMode && !projectName && hasEmailSetting && (<Alert variant="info">@@ -1524,9 +1516,9 @@ function EditMemberRoleDrawer({</div>)}</div>- </div>+ </SheetBody>- <div className="flex items-center justify-between px-6 py-4 border-t">+ <SheetFooter className="justify-between"><div>{isEditMode && (<Button@@ -1549,9 +1541,9 @@ function EditMemberRoleDrawer({{isEditMode ? t("common.update") : t("common.create")}</Button></div>- </div>- </div>- </>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/pages/settings/ProjectsPage.tsx b/frontend/src/react/pages/settings/ProjectsPage.tsxindex dde2a51bbc..772b5cdec2 100644--- a/frontend/src/react/pages/settings/ProjectsPage.tsx+++ b/frontend/src/react/pages/settings/ProjectsPage.tsx@@ -1,4 +1,3 @@-import { sortBy, uniq } from "lodash-es";import {Archive,Check,@@ -17,6 +16,12 @@ import {} from "@/react/components/AdvancedSearch";import { ProjectCreateDialog } from "@/react/components/header/ProjectCreateDialog";import { PermissionGuard } from "@/react/components/PermissionGuard";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from "@/react/components/ui/alert-dialog";import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import {@@ -26,14 +31,16 @@ import {DropdownMenuTrigger,} from "@/react/components/ui/dropdown-menu";import { PagedTableFooter } from "@/react/hooks/usePagedData";-import { useVueState } from "@/react/hooks/useVueState";+import {+ getPageSizeOptions,+ useSessionPageSize,+} from "@/react/hooks/useSessionPageSize";import { cn } from "@/react/lib/utils";import { router } from "@/router";import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";import {pushNotification,useAuthStore,- useCurrentUserV1,useProjectV1Store,useUIStateStore,} from "@/store";@@ -42,93 +49,10 @@ import { State } from "@/types/proto-es/v1/common_pb";import type { Project } from "@/types/proto-es/v1/project_service_pb";import {extractProjectResourceName,- getDefaultPagination,hasProjectPermissionV2,hasWorkspacePermissionV2,} from "@/utils";-// ============================================================-// Escape key stack for overlays-// ============================================================--// Track the topmost overlay's escape handler. Only active (enabled) overlays-// participate. The ref ensures the latest callback is always invoked.-const escapeStack: React.RefObject<(() => void) | null>[] = [];--function useEscapeKey(onEscape: () => void, enabled = true) {- const callbackRef = useRef(onEscape);- callbackRef.current = onEscape;-- useEffect(() => {- if (!enabled) return;- escapeStack.push(callbackRef);- const handler = (e: KeyboardEvent) => {- if (- e.key === "Escape" &&- escapeStack[escapeStack.length - 1] === callbackRef- ) {- callbackRef.current?.();- }- };- document.addEventListener("keydown", handler);- return () => {- document.removeEventListener("keydown", handler);- const idx = escapeStack.indexOf(callbackRef);- if (idx >= 0) escapeStack.splice(idx, 1);- };- }, [enabled]);-}--// ============================================================-// Pagination helpers-// ============================================================--const PAGE_SIZE_OPTIONS = [50, 100, 200, 500];--function getPageSizeOptions(): number[] {- const defaultSize = getDefaultPagination();- return sortBy(uniq([defaultSize, ...PAGE_SIZE_OPTIONS]));-}--function useSessionPageSize(- sessionKey: string-): [number, (size: number) => void] {- const currentUser = useCurrentUserV1();- const email = useVueState(() => currentUser.value.email);- const storageKey = `bb.paged-table.${sessionKey}.${email}`;-- const [pageSize, setPageSize] = useState<number>(() => {- try {- const stored = localStorage.getItem(storageKey);- if (stored) {- const parsed = JSON.parse(stored);- const size = parsed?.pageSize;- const options = getPageSizeOptions();- if (typeof size === "number" && options.includes(size)) {- return Math.max(options[0], size);- }- }- } catch {- // ignore- }- return getPageSizeOptions()[0];- });-- const updatePageSize = useCallback(- (size: number) => {- setPageSize(size);- try {- localStorage.setItem(storageKey, JSON.stringify({ pageSize: size }));- } catch {- // ignore- }- },- [storageKey]- );-- return [pageSize, updatePageSize];-}-// ============================================================// ConfirmDialog// ============================================================@@ -153,8 +77,6 @@ function ConfirmDialog({children?: React.ReactNode;}) {const { t } = useTranslation();- const onClose = useCallback(() => onCancel(), [onCancel]);- useEscapeKey(onClose, open);if (!open) return null;@@ -165,20 +87,14 @@ function ConfirmDialog({: "bg-warning hover:bg-warning-hover text-accent-text";return (- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div className="fixed inset-0 bg-overlay/50" onClick={onCancel} />- <div- className={cn(- "relative bg-background rounded-sm shadow-lg max-w-lg w-full mx-4 border-t-4",- borderColor- )}- >- <div className="p-6">- <h3 className="text-lg font-semibold mb-2">{title}</h3>- <p className="text-sm text-control-light mb-4">{description}</p>- {children}- </div>- <div className="flex justify-end gap-x-2 px-6 pb-6">+ <AlertDialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <AlertDialogContent className={cn("max-w-lg border-t-4", borderColor)}>+ <AlertDialogTitle>{title}</AlertDialogTitle>+ <AlertDialogDescription className="mt-2">+ {description}+ </AlertDialogDescription>+ {children && <div className="mt-4">{children}</div>}+ <div className="mt-6 flex justify-end gap-x-2"><Button variant="outline" onClick={onCancel}>{t("common.cancel")}</Button>@@ -192,8 +108,8 @@ function ConfirmDialog({{okText}</button></div>- </div>- </div>+ </AlertDialogContent>+ </AlertDialog>);}diff --git a/frontend/src/react/pages/settings/RolesPage.tsx b/frontend/src/react/pages/settings/RolesPage.tsxindex e84c2ff80f..0861af3fb0 100644--- a/frontend/src/react/pages/settings/RolesPage.tsx+++ b/frontend/src/react/pages/settings/RolesPage.tsx@@ -18,8 +18,19 @@ import {AlertDescription,AlertTitle,} from "@/react/components/ui/alert";+import {+ AlertDialog,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogTitle,+} from "@/react/components/ui/alert-dialog";import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";import { SearchInput } from "@/react/components/ui/search-input";import {@@ -65,29 +76,6 @@ import {} from "@/utils";import { extractGrpcErrorMessage, getErrorCode } from "@/utils/connect";-// Escape key stack: only the topmost overlay handles Escape.-const escapeStack: (() => void)[] = [];--function useEscapeKey(onEscape: () => void) {- useEffect(() => {- escapeStack.push(onEscape);- const handler = (e: KeyboardEvent) => {- if (- e.key === "Escape" &&- escapeStack[escapeStack.length - 1] === onEscape- ) {- onEscape();- }- };- document.addEventListener("keydown", handler);- return () => {- document.removeEventListener("keydown", handler);- const idx = escapeStack.lastIndexOf(onEscape);- if (idx >= 0) escapeStack.splice(idx, 1);- };- }, [onEscape]);-}-// ============================================================// PermissionTransfer// ============================================================@@ -230,7 +218,6 @@ function ImportPermissionModal({const roleStore = useRoleStore();const roleList = useVueState(() => [...roleStore.roleList]);const [selectedRoleName, setSelectedRoleName] = useState<string>("");- useEscapeKey(onCancel);const selectedRole = useMemo(() => roleList.find((r) => r.name === selectedRoleName),@@ -240,21 +227,11 @@ function ImportPermissionModal({const permissions = selectedRole?.permissions ?? [];return (- <div- className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"- onClick={(e) => {- if (e.target === e.currentTarget) onCancel();- }}- >- <div className="bg-white rounded-sm shadow-lg w-[28rem] p-6">- <div className="flex items-center justify-between mb-4">- <h3 className="text-lg font-medium">{t("role.import-from-role")}</h3>- <Button variant="ghost" size="icon" onClick={onCancel}>- <X className="h-4 w-4" />- </Button>- </div>+ <Dialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <DialogContent className="w-[28rem] max-w-[calc(100vw-2rem)] p-6">+ <DialogTitle>{t("role.import-from-role")}</DialogTitle>- <div className="flex flex-col gap-y-3">+ <div className="mt-4 flex flex-col gap-y-3"><div><label className="textlabel mb-1 block">{t("role.select-role")}@@ -298,8 +275,8 @@ function ImportPermissionModal({</Button></div></div>- </div>- </div>+ </DialogContent>+ </Dialog>);}@@ -320,22 +297,16 @@ function DeleteConfirmModal({}) {const { t } = useTranslation();const canDelete = occupiedResources.length === 0;- useEscapeKey(onCancel);return (- <div- className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"- onClick={(e) => {- if (e.target === e.currentTarget) onCancel();- }}- >- <div className="bg-white rounded-sm shadow-lg w-[28rem] p-6">- <h3 className="text-lg font-medium mb-4">+ <AlertDialog open onOpenChange={(nextOpen) => !nextOpen && onCancel()}>+ <AlertDialogContent>+ <AlertDialogTitle>{t("common.delete")} - {displayRoleTitle(roleName)}- </h3>+ </AlertDialogTitle>{occupiedResources.length > 0 ? (- <div className="mb-4">+ <div className="mt-4"><Alert variant="warning"><AlertDescription><p className="mb-2">@@ -353,14 +324,14 @@ function DeleteConfirmModal({</Alert></div>) : (- <p className="mb-4 text-sm text-control-light">+ <AlertDialogDescription className="mt-2">{t("resource.delete-warning", {name: displayRoleTitle(roleName),})}- </p>+ </AlertDialogDescription>)}- <div className="flex justify-end gap-x-2">+ <div className="mt-6 flex justify-end gap-x-2"><Button variant="outline" onClick={onCancel}>{t("common.cancel")}</Button>@@ -370,8 +341,8 @@ function DeleteConfirmModal({</Button>)}</div>- </div>- </div>+ </AlertDialogContent>+ </AlertDialog>);}diff --git a/frontend/src/react/pages/settings/SemanticTypesPage.tsx b/frontend/src/react/pages/settings/SemanticTypesPage.tsxindex 352dfb5073..b7a10508fe 100644--- a/frontend/src/react/pages/settings/SemanticTypesPage.tsx+++ b/frontend/src/react/pages/settings/SemanticTypesPage.tsx@@ -1,5 +1,5 @@import { create } from "@bufbuild/protobuf";-import { Check, Info, Pencil, Plus, Trash2, Undo2, X } from "lucide-react";+import { Check, Info, Pencil, Plus, Trash2, Undo2 } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { v4 as uuidv4 } from "uuid";@@ -7,6 +7,14 @@ import { FeatureAttention } from "@/react/components/FeatureAttention";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { NumberInput } from "@/react/components/ui/number-input";+import {+ Sheet,+ SheetBody,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";import { Tooltip } from "@/react/components/ui/tooltip";import { useVueState } from "@/react/hooks/useVueState";import {@@ -662,24 +670,17 @@ function MaskingAlgorithmDrawer({};return (- <div className="fixed inset-0 z-50 flex justify-end">- <div className="absolute inset-0 bg-overlay/40" onClick={onDismiss} />- <div className="relative w-[40rem] max-w-[calc(100vw-5rem)] bg-background shadow-xl flex flex-col">- <div className="flex items-center justify-between px-6 py-4 border-b border-control-border">- <h2 className="text-lg font-medium">+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onDismiss()}>+ <SheetContent width="medium">+ <SheetHeader>+ <SheetTitle>{t("settings.sensitive-data.semantic-types.table.masking-algorithm")}- </h2>- <button- className="p-1 rounded-xs hover:bg-control-bg-hover text-control-light"- onClick={onDismiss}- >- <X className="w-5 h-5" />- </button>- </div>+ </SheetTitle>+ </SheetHeader>- <div className="flex-1 overflow-y-auto p-6">+ <SheetBody className="p-6">{/* Masking type selector */}<div className="mb-6"><label className="text-sm font-medium">@@ -950,9 +951,9 @@ function MaskingAlgorithmDrawer({</>)}</div>- </div>+ </SheetBody>- <div className="flex justify-end gap-x-2 px-6 py-4 border-t border-control-border">+ <SheetFooter><Button variant="outline" onClick={onDismiss}>{t("common.cancel")}</Button>@@ -963,9 +964,9 @@ function MaskingAlgorithmDrawer({>{algorithm ? t("common.update") : t("common.create")}</Button>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}@@ -985,21 +986,14 @@ function SemanticTemplateDrawer({const templates = useMemo(() => getSemanticTemplateList(), []);return (- <div className="fixed inset-0 z-50 flex justify-end">- <div className="absolute inset-0 bg-overlay/40" onClick={onDismiss} />- <div className="relative w-2xl max-w-[100vw] bg-background shadow-xl flex flex-col">- <div className="flex items-center justify-between px-6 py-4 border-b border-control-border">- <h2 className="text-lg font-medium">+ <Sheet open onOpenChange={(nextOpen) => !nextOpen && onDismiss()}>+ <SheetContent width="standard">+ <SheetHeader>+ <SheetTitle>{t("settings.sensitive-data.semantic-types.table.semantic-type")}- </h2>- <button- className="p-1 rounded-xs hover:bg-control-bg-hover text-control-light"- onClick={onDismiss}- >- <X className="w-5 h-5" />- </button>- </div>- <div className="flex-1 overflow-y-auto p-6">+ </SheetTitle>+ </SheetHeader>+ <SheetBody className="p-6"><p className="text-sm text-control-placeholder mb-4">{t("settings.sensitive-data.semantic-types.template.description")}</p>@@ -1060,14 +1054,14 @@ function SemanticTemplateDrawer({</tbody></table></div>- </div>- <div className="flex justify-end px-6 py-4 border-t border-control-border">+ </SheetBody>+ <SheetFooter><Button variant="outline" onClick={onDismiss}>{t("common.cancel")}</Button>- </div>- </div>- </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>);}diff --git a/frontend/src/react/pages/settings/general/GeneralSection.tsx b/frontend/src/react/pages/settings/general/GeneralSection.tsxindex 2a8ccc2ad2..f372c9edf2 100644--- a/frontend/src/react/pages/settings/general/GeneralSection.tsx+++ b/frontend/src/react/pages/settings/general/GeneralSection.tsx@@ -16,6 +16,11 @@ import {} from "@/react/components/PermissionGuard";import { Alert } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogTitle,+} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";import { router } from "@/router";@@ -233,21 +238,22 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>({/* Modal after switching to Editor mode */}{showModal && (- <div className="fixed inset-0 z-50 flex items-center justify-center">- <div- className="fixed inset-0 bg-overlay/40"- onClick={() => setShowModal(false)}- />- <div className="relative bg-background rounded-sm shadow-lg p-6 max-w-md w-full mx-4 flex flex-col gap-2">- <h2 className="text-lg font-semibold">+ <Dialog+ open+ onOpenChange={(nextOpen) => !nextOpen && setShowModal(false)}+ >+ <DialogContent className="w-[32rem] max-w-[calc(100vw-2rem)] p-6">+ <DialogTitle>{t("settings.general.workspace.config-updated")}- </h2>- <div className="py-2">- {t(- "settings.general.workspace.default-landing-page.default-view-changed-to-sql-editor"- )}+ </DialogTitle>+ <div className="mt-4 flex flex-col gap-y-4">+ <div>+ {t(+ "settings.general.workspace.default-landing-page.default-view-changed-to-sql-editor"+ )}+ </div></div>- <div className="flex items-center justify-end gap-2">+ <div className="mt-4 flex items-center justify-end gap-x-2"><Button variant="outline" onClick={() => setShowModal(false)}>{t("common.ok")}</Button>@@ -257,8 +263,8 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>()}</Button></div>- </div>- </div>+ </DialogContent>+ </Dialog>)}</div>);diff --git a/scripts/check_link_test.go b/scripts/check_link_test.goindex a2fa15098c..08333ad38e 100644--- a/scripts/check_link_test.go+++ b/scripts/check_link_test.go@@ -1,9 +1,6 @@package scriptsimport (- "fmt"- "io"- "net/http""net/url""os""path/filepath"@@ -37,6 +34,7 @@ var (}frontendDirectory = "../frontend"+ sitemapURL = "https://www.bytebase.com/sitemap.xml")func TestValidateLinks(t *testing.T) {@@ -44,19 +42,7 @@ func TestValidateLinks(t *testing.T) {links, err := extractLinkRecursive()a.NoError(err)- resp, err := http.Get("http://bytebase.com/sitemap.xml")- if err != nil {- t.Fatalf("failed to get sitemap xml: %v", err)- }- defer resp.Body.Close()-- body, err := io.ReadAll(resp.Body)- if err != nil {- t.Fatalf("failed to read sitemap xml: %v", err)- }- fmt.Println(string(body))-- sm, err := sitemap.Get("http://bytebase.com/sitemap.xml", nil)+ sm, err := sitemap.Get(sitemapURL, nil)a.NoError(err)paths := map[string]struct{}{}