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: polish schema editor in plan detail (#20298)
boojack65f2253d4df7
diff --git a/.gitignore b/.gitignoreindex c56f783a23..94af06fa1e 100644--- a/.gitignore+++ b/.gitignore@@ -42,3 +42,9 @@ scripts/azure-marketplace/*.backup# playwright-cli local session artifacts.playwright-cli/++# playwright-mcp local session artifacts (chrome-devtools/playwright-mcp dumps)+.playwright-mcp/++# superpowers brainstorm sessions (visual companion mockups)+.superpowers/diff --git a/docs/superpowers/plans/2026-05-12-byt-9473-schema-editor-plan-detail-container.md b/docs/superpowers/plans/2026-05-12-byt-9473-schema-editor-plan-detail-container.mdnew file mode 100644index 0000000000..69f09d4d42--- /dev/null+++ b/docs/superpowers/plans/2026-05-12-byt-9473-schema-editor-plan-detail-container.md@@ -0,0 +1,986 @@+# Schema Editor — Plan Detail Container + BYT-9473 Polish 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:** Replace the fixed-width drawer hosting the schema editor in plan detail with a maximizable drawer, and bundle the four BYT-9473 polish fixes (column icon, "new table" action, add-column highlight, badge/empty-state polish) into one coherent change.++**Architecture:** Extend the shared `Sheet` primitive with one new width tier (`huge`) and an `actions` slot on `SheetHeader`. `SchemaEditorSheet` owns the maximize state locally — it resets on each open because the body is gated on `{open && ...}`. The four BYT-9473 items are scoped, low-risk swaps that keep the editor internals untouched.++**Tech Stack:** React, Base UI (`@base-ui/react`), Tailwind CSS v4, shadcn-style component patterns, `react-i18next`, `lucide-react`, `class-variance-authority`.++**Spec:** [`docs/superpowers/specs/2026-05-12-byt-9473-schema-editor-plan-detail-container-design.md`](../specs/2026-05-12-byt-9473-schema-editor-plan-detail-container-design.md)++**Linear:** [BYT-9473](https://linear.app/bytebase/issue/BYT-9473/schema-editor-display-not-work-properly)++---++## Task 1: Add `huge` width tier and `actions` slot to `SheetHeader`++**Files:**+- Modify: `frontend/src/react/components/ui/sheet.tsx`++- [ ] **Step 1: Add `huge` width variant**++ Open `frontend/src/react/components/ui/sheet.tsx`. Inside `sheetContentVariants` add a `huge` tier and a one-line comment so the convention is visible.++ Replace the `variants.width` block (currently lines 62-73) with:++ ```ts+ variants: {+ width: {+ narrow: "w-[24rem]",+ panel: "w-[31.25rem]",+ medium: "w-[40rem]",+ standard: "w-[44rem]",+ wide: "w-[52rem]",+ large: "w-[64rem]",+ xlarge: "w-[70rem]",+ // Maximized editor surfaces (e.g. plan-detail schema editor). Leaves a+ // 5vw strip on the left as a visual anchor; clicking the strip closes+ // the sheet like any other scrim click.+ huge: "w-[95vw]",+ workspace: "w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)]",+ },+ },+ ```++- [ ] **Step 2: Add `actions` slot to `SheetHeader`**++ Replace the existing `SheetHeader` function (currently lines 116-138) with:++ ```tsx+ // Sticky top region with a bottom border, laid out as a row so the built-in+ // close button sits on the right. Typically contains a `SheetTitle` and an+ // optional `SheetDescription` — both are wrapped in a flex-col for the+ // vertical stack layout while the close button remains flush right.+ // `actions` renders secondary icon-buttons (maximize, settings, etc.)+ // immediately before the close button. Use the slot rather than rolling+ // a bespoke header so dismissal stays consistent across sheets.+ function SheetHeader({+ className,+ children,+ actions,+ ...props+ }: ComponentProps<"div"> & { actions?: React.ReactNode }) {+ const { t } = useTranslation();++ return (+ <div+ className={cn(+ "flex items-start justify-between gap-x-4 border-b border-control-border px-6 py-4",+ className+ )}+ {...props}+ >+ <div className="flex flex-col gap-y-1 min-w-0 flex-1">{children}</div>+ {actions ? (+ <div className="flex items-center gap-x-1 shrink-0">{actions}</div>+ ) : null}+ {/* Built-in close affordance. Callers should not render their own close+ button — Base UI's Close dismisses the Sheet via Root's onOpenChange. */}+ <BaseDialog.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" />+ </BaseDialog.Close>+ </div>+ );+ }+ ```++ Note: `React` is not imported as a value anywhere else in this file. Add the type import at the top:++ ```ts+ import type { ComponentProps, ReactNode } from "react";+ ```++ …and use `ReactNode` instead of `React.ReactNode`:++ ```tsx+ }: ComponentProps<"div"> & { actions?: ReactNode }) {+ ```++- [ ] **Step 3: Type-check**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS (no new errors). The `actions` prop is opt-in; no existing callers need to change.++- [ ] **Step 4: Commit**++ ```bash+ git add frontend/src/react/components/ui/sheet.tsx+ git commit -m "feat(ui): add huge width tier and actions slot to SheetHeader"+ ```++---++## Task 2: Wire maximize toggle into `SchemaEditorSheet`++**Files:**+- Modify: `frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx`+- Modify: `frontend/src/locales/en-US.json` (and any other locale files that mirror the same keys)++- [ ] **Step 1: Add `common.maximize` to locales**++ In `frontend/src/locales/en-US.json`, locate the `common` block (around line 200). Add a `"maximize": "Maximize"` entry alongside the existing `"restore": "Restore"` (already at line 377; reuse it for the unmaximized tooltip). Keep keys alphabetized — add immediately after `"manual"` / `"max"` style neighbors.++ If the project uses other locale files under `frontend/src/locales/` (e.g. `zh-CN.json`, `ja.json`), add the same key with the English fallback in each — the existing build typically copies missing keys; if not, use the existing language's word for "Maximize" if obvious, otherwise leave the English value.++ Run: `pnpm --dir frontend fix`+ Expected: PASS (formats JSON).++- [ ] **Step 2: Update `SchemaEditorSheet` imports**++ Open `frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx`. Replace the existing `lucide-react` import line (currently `import { Loader2 } from "lucide-react";`) with:++ ```ts+ import { Loader2, Maximize2, Minimize2 } from "lucide-react";+ ```++- [ ] **Step 3: Add maximize state and pass `actions` + `width` to the sheet**++ Replace the existing `SchemaEditorSheet` function (currently lines 37-62) with:++ ```tsx+ export function SchemaEditorSheet({+ open,+ onOpenChange,+ databaseNames,+ project,+ onInsert,+ }: Props) {+ const { t } = useTranslation();+ // Local state — resets on each open because the body below is gated on+ // {open && ...} and remounts when the sheet reopens.+ const [maximized, setMaximized] = useState(false);+ const MaximizeIcon = maximized ? Minimize2 : Maximize2;+ return (+ <Sheet+ open={open}+ onOpenChange={(next) => {+ if (!next) setMaximized(false);+ onOpenChange(next);+ }}+ >+ <SheetContent width={maximized ? "huge" : "xlarge"} className="flex flex-col">+ <SheetHeader+ actions={+ <button+ type="button"+ aria-label={+ maximized ? t("common.restore") : t("common.maximize")+ }+ title={maximized ? t("common.restore") : t("common.maximize")}+ onClick={() => setMaximized((v) => !v)}+ className="rounded-xs p-1 text-control hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent cursor-pointer"+ >+ <MaximizeIcon className="size-4" />+ </button>+ }+ >+ <SheetTitle>{t("schema-editor.self")}</SheetTitle>+ </SheetHeader>+ {open && (+ <SchemaEditorSheetBody+ databaseNames={databaseNames}+ project={project}+ onInsert={onInsert}+ onCancel={() => onOpenChange(false)}+ />+ )}+ </SheetContent>+ </Sheet>+ );+ }+ ```++ Note: `useState` must be imported — the existing `import { useCallback, useEffect, useRef, useState } from "react";` line already has it.++- [ ] **Step 4: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS.++ Run: `pnpm --dir frontend check`+ Expected: PASS. The layering scanner (`check-react-layering.mjs`) should not flag this change — no new portal targets, no raw `z-index`, no body portals.++- [ ] **Step 5: Manual sanity check**++ Run: `pnpm --dir frontend dev`+ Open a plan in the browser. Click "Schema editor" in the statement section toolbar.+ Expected:+ - Drawer opens at the same width as today (`xlarge`).+ - The ⤢ button appears immediately left of the X in the header. Tooltip reads "Maximize".+ - Click ⤢ — drawer expands to ~95% viewport, leaving a thin strip on the left. Icon flips to "Minimize" and tooltip reads "Restore".+ - Click the icon again — drawer collapses back to `xlarge`.+ - Click the left strip — sheet closes (matches scrim behavior).+ - Close + reopen — drawer is back at `xlarge` (state reset).++- [ ] **Step 6: Commit**++ ```bash+ git add frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx \+ frontend/src/locales/+ git commit -m "feat(react): maximize toggle on plan-detail schema editor sheet"+ ```++---++## Task 3: Shared `ColumnIcon` — fix the "C" mismatch (BYT-9473 item 1)++**Files:**+- Create: `frontend/src/react/components/schema/icons.tsx`+- Modify: `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx`+- Modify: `frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx` (re-export from shared module)++- [ ] **Step 1: Create the shared icon module**++ Create `frontend/src/react/components/schema/icons.tsx` with:++ ```tsx+ import { cn } from "@/react/lib/utils";++ interface IconProps {+ className?: string;+ }++ /**+ * Single-column variant of `lucide:columns-3` (the second internal gap line+ * removed). Used in both Schema Editor and SQL Editor tree views so the two+ * surfaces stay visually identical.+ */+ export function ColumnIcon({ className }: IconProps) {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ className={cn("size-4 text-control-light", className)}+ >+ <rect width="18" height="18" x="3" y="3" rx="2" />+ <path d="M9 3v18" />+ </svg>+ );+ }+ ```++ Note: this uses the semantic `text-control-light` token, not `text-gray-500`. AGENTS.md forbids raw colors in React UI.++- [ ] **Step 2: Re-export from the SQL Editor's icons file**++ Open `frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx`. Replace the existing `ColumnIcon` definition (currently lines 129-151) with a re-export so the two surfaces share one source of truth:++ ```tsx+ // ColumnIcon is shared with SchemaEditorLite; both surfaces must render+ // identical icons so users don't see drift across editors.+ export { ColumnIcon } from "@/react/components/schema/icons";+ ```++ Remove the now-unused `cn` and `baseSize` references if no other icon in the file uses them. (`Check` is still in use for `CheckConstraintIcon` above — leave that.)++- [ ] **Step 3: Swap `<div>C</div>` for `<ColumnIcon />` in `AsideTree`**++ In `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx`, add the import near the other component imports at the top:++ ```ts+ import { ColumnIcon } from "@/react/components/schema/icons";+ ```++ Then replace the `case "column"` branch in `NodeIcon` (currently lines 472-477):++ ```tsx+ case "column":+ return <ColumnIcon className={cls} />;+ ```++ `cls` is the existing `"size-4 shrink-0"` constant a few lines above — keep it so sizing stays consistent with the other Lucide icons in this switch.++- [ ] **Step 4: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS.++ Run: `pnpm --dir frontend check`+ Expected: PASS.++- [ ] **Step 5: Manual sanity check**++ Reopen the schema editor in the dev server. Expand a table. Expected:+ - Each column row now shows the same single-column SVG used by SQL Editor (no more bold "C" text).+ - Status colors on the row label remain (`text-success` for created, etc.) — they apply to the label, not the icon.+ - Open the SQL Editor's schema pane in parallel and confirm column icons look identical.++- [ ] **Step 6: Commit**++ ```bash+ git add frontend/src/react/components/schema/icons.tsx \+ frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx \+ frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+ git commit -m "fix(schema-editor): use shared ColumnIcon to match SQL Editor"+ ```++---++## Task 4: Convert tree status text into a Badge (BYT-9473 polish)++**Files:**+- Modify: `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx`++- [ ] **Step 1: Add `Badge` import**++ In `AsideTree.tsx`, add:++ ```ts+ import { Badge } from "@/react/components/ui/badge";+ ```++- [ ] **Step 2: Add a small `StatusBadge` helper**++ Just below the existing `statusClassName` helper (around line 512), add:++ ```tsx+ // Single-letter badge to mark created / updated / dropped entries in the+ // tree. Sits to the right of the label so it doesn't crowd the icon column+ // and reads at a glance — text color alone was too quiet (BYT-9473).+ function StatusBadge({ status }: { status: EditStatus }) {+ if (status === "normal") return null;+ const variant =+ status === "created"+ ? "success"+ : status === "updated"+ ? "warning"+ : "error";+ const letter =+ status === "created" ? "+" : status === "updated" ? "~" : "−";+ return (+ <Badge variant={variant} className="ml-1 h-4 px-1 text-[10px] leading-none">+ {letter}+ </Badge>+ );+ }+ ```++ Note: confirm `Badge` exposes `success`, `warning`, `error` variants by opening `frontend/src/react/components/ui/badge.tsx`. If it only exposes `default`, `secondary`, `destructive`, `outline`, use semantic class overrides via `className` instead — e.g. `<Badge className="ml-1 bg-success/10 text-success ...">`. Pick whichever route lands without modifying `badge.tsx`.++- [ ] **Step 3: Render the badge in `NodeRenderer`**++ Replace the label span in `NodeRenderer` (currently lines 577-579):++ ```tsx+ <span className={cn("truncate", statusClassName(status))}>+ {treeNode.label || "(empty)"}+ </span>+ <StatusBadge status={status} />+ ```++ Keep `statusClassName(status)` on the label so the existing strike-through for `dropped` survives — the badge is additive, not a replacement.++- [ ] **Step 4: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS.++ Run: `pnpm --dir frontend check`+ Expected: PASS.++- [ ] **Step 5: Manual sanity check**++ In the dev server, make any schema edit (add a table, drop a column). Expected:+ - Created entries show a `+` badge in the tree, updated `~`, dropped `−`.+ - Dropped entries still show the strike-through on the label.+ - Normal entries show no badge (no visual change vs today).++- [ ] **Step 6: Commit**++ ```bash+ git add frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+ git commit -m "feat(schema-editor): badge created/updated/dropped tree entries"+ ```++---++## Task 5: Convert `TableNameDialog` to inline `TableNamePopover` (BYT-9473 item 2)++**Files:**+- Create: `frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsx`+- Modify: `frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx` (swap call site)+- Delete: `frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx` (last task step, after wiring proves out)++- [ ] **Step 1: Investigate the failure (5 minutes)**++ Before writing code, reproduce the BYT-9473 "new table not work" symptom locally. Open the schema editor → right-click a schema → "New table". Note exactly what fails (modal doesn't appear, input doesn't focus, Enter does nothing, Esc closes the sheet instead of the dialog, etc.). Record observations in the PR description later.++ This step is information-gathering — no code change. It confirms the root cause matches the spec's hypothesis (nested Base UI Dialog inside Sheet in the same `overlay` layer family).++- [ ] **Step 2: Create the popover component**++ Create `frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsx` with:++ ```tsx+ import { create } from "@bufbuild/protobuf";+ import { useCallback, useState } from "react";+ import { useTranslation } from "react-i18next";+ import { Button } from "@/react/components/ui/button";+ import { Input } from "@/react/components/ui/input";+ import {+ Popover,+ PopoverContent,+ } from "@/react/components/ui/popover";+ import { Engine } from "@/types/proto-es/v1/common_pb";+ import type {+ Database,+ DatabaseMetadata,+ SchemaMetadata,+ TableMetadata,+ } from "@/types/proto-es/v1/database_service_pb";+ import {+ ColumnMetadataSchema,+ TableMetadataSchema,+ } from "@/types/proto-es/v1/database_service_pb";+ import { getDatabaseEngine } from "@/utils";+ import { useSchemaEditorContext } from "../context";+ import { upsertColumnPrimaryKey } from "../core/edit";+ import { markUUID } from "../Panels/common";++ interface Props {+ open: boolean;+ onClose: () => void;+ /** Screen-space coordinates of the click that triggered the popover.+ * The popover anchors to a virtual rect at this point so we don't depend+ * on a DOM element that may have unmounted (e.g. the context menu item).+ */+ anchorPoint: { x: number; y: number };+ db: Database;+ database: DatabaseMetadata;+ schema: SchemaMetadata;+ table?: TableMetadata;+ }++ const TABLE_NAME_REGEX = /^\S[\S ]*\S?$/;++ export function TableNamePopover({+ open,+ onClose,+ anchorPoint,+ db,+ database,+ schema,+ table,+ }: Props) {+ const { t } = useTranslation();+ const { tabs, editStatus, rebuildTree, rebuildEditStatus, scrollStatus } =+ useSchemaEditorContext();+ const engine = getDatabaseEngine(db);++ const [tableName, setTableName] = useState(table?.name ?? "");+ const isCreateMode = !table;++ const isDuplicate =+ tableName !== table?.name &&+ schema.tables.some((tt) => tt.name === tableName);++ const isValid =+ tableName.length > 0 && TABLE_NAME_REGEX.test(tableName) && !isDuplicate;++ const handleConfirm = useCallback(() => {+ if (!isValid) return;++ if (isCreateMode) {+ const newTable = create(TableMetadataSchema, {+ name: tableName,+ columns: [],+ indexes: [],+ foreignKeys: [],+ partitions: [],+ comment: "",+ });+ schema.tables.push(newTable);+ editStatus.markEditStatus(db, { schema, table: newTable }, "created");++ const defaultType = engine === Engine.POSTGRES ? "integer" : "int";+ const idColumn = create(ColumnMetadataSchema, {+ name: "id",+ type: defaultType,+ nullable: false,+ hasDefault: false,+ default: "",+ comment: "",+ });+ markUUID(idColumn);+ newTable.columns.push(idColumn);+ editStatus.markEditStatus(+ db,+ { schema, table: newTable, column: idColumn },+ "created"+ );+ upsertColumnPrimaryKey(engine, newTable, "id");++ tabs.addTab({+ type: "table",+ database: db,+ metadata: { database, schema, table: newTable },+ });+ scrollStatus.queuePendingScrollToTable({+ db,+ metadata: { database, schema, table: newTable },+ });+ rebuildTree(false);+ } else {+ table.name = tableName;+ rebuildEditStatus(["tree"]);+ }++ onClose();+ }, [+ isValid,+ isCreateMode,+ tableName,+ schema,+ editStatus,+ db,+ database,+ engine,+ tabs,+ scrollStatus,+ rebuildTree,+ rebuildEditStatus,+ table,+ onClose,+ ]);++ // Virtual anchor at the click point. Base UI's Positioner accepts an+ // object with getBoundingClientRect(); we expose a 1×1 rect at (x, y).+ const anchor = {+ getBoundingClientRect: () =>+ ({+ width: 0,+ height: 0,+ x: anchorPoint.x,+ y: anchorPoint.y,+ top: anchorPoint.y,+ left: anchorPoint.x,+ right: anchorPoint.x,+ bottom: anchorPoint.y,+ toJSON() {+ return this;+ },+ }) as DOMRect,+ };++ return (+ <Popover open={open} onOpenChange={(next) => !next && onClose()}>+ <PopoverContent+ anchor={anchor}+ side="bottom"+ align="start"+ className="w-72 p-3"+ >+ <div className="flex flex-col gap-y-3">+ <div className="text-sm font-medium text-control">+ {isCreateMode+ ? t("schema-editor.actions.create-table")+ : t("schema-editor.actions.rename-table")}+ </div>+ <Input+ value={tableName}+ placeholder={t("schema-editor.table.name-placeholder")}+ autoFocus+ onChange={(e) => setTableName(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter") handleConfirm();+ if (e.key === "Escape") onClose();+ }}+ />+ {isDuplicate && (+ <p className="text-xs text-error">+ {t("schema-editor.table.duplicate-name")}+ </p>+ )}+ <div className="flex items-center justify-end gap-x-2">+ <Button variant="outline" size="sm" onClick={onClose}>+ {t("common.cancel")}+ </Button>+ <Button size="sm" disabled={!isValid} onClick={handleConfirm}>+ {isCreateMode ? t("common.create") : t("common.save")}+ </Button>+ </div>+ </div>+ </PopoverContent>+ </Popover>+ );+ }+ ```++- [ ] **Step 3: Swap the call site in `AsideTree`**++ In `AsideTree.tsx`:++ - Replace the import:+ ```ts+ import { TableNamePopover } from "../Modals/TableNamePopover";+ ```+ (was `import { TableNameDialog } from "../Modals/TableNameDialog";`)++ - The existing `tableNameModalCtx` state captures `{ db, database, schema, table? }`. Extend the context to also carry the click coordinates. Locate the right-click handler that opens the menu (search for `setMenuState` / `handleMenuSelect`). Where the "create-table" / "rename-table" branch sets `tableNameModalCtx`, also include `anchorPoint: { x: menuState.x, y: menuState.y }`. Update the `tableNameModalCtx` type accordingly:++ ```ts+ type TableNameModalCtx = {+ db: Database;+ database: DatabaseMetadata;+ schema: SchemaMetadata;+ table?: TableMetadata;+ anchorPoint: { x: number; y: number };+ };+ ```++ - Replace the `<TableNameDialog ... />` block (currently lines 410-419) with:++ ```tsx+ {tableNameModalCtx && (+ <TableNamePopover+ open+ onClose={() => setTableNameModalCtx(null)}+ anchorPoint={tableNameModalCtx.anchorPoint}+ db={tableNameModalCtx.db}+ database={tableNameModalCtx.database}+ schema={tableNameModalCtx.schema}+ table={tableNameModalCtx.table}+ />+ )}+ ```++- [ ] **Step 4: Delete the old dialog**++ Delete `frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx`.++ ```bash+ git rm frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx+ ```++- [ ] **Step 5: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS. If the layering scanner complains about the new file, double-check that `PopoverContent` is the only portal target — it already mounts into `getLayerRoot("overlay")` via the shared primitive.++ Run: `pnpm --dir frontend check`+ Expected: PASS.++- [ ] **Step 6: Manual sanity check**++ Reopen the schema editor:+ - Right-click a schema → "New table". Popover appears at the cursor; name input is autofocused; typing + Enter creates the table, opens its tab, scrolls to it.+ - Right-click a table → "Rename". Popover appears prefilled with the current name; edit + Enter renames; the tree refreshes.+ - Esc closes the popover but leaves the sheet open.+ - Clicking outside the popover (but inside the sheet) dismisses the popover only — sheet stays.++- [ ] **Step 7: Commit**++ ```bash+ git add frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsx \+ frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+ git commit -m "fix(schema-editor): convert table-name dialog to inline popover"+ ```++ Note: the `git rm` from Step 4 stages the deletion automatically; `git add` here covers the new file and the call-site change.++---++## Task 6: Highlight new column on add (BYT-9473 item 3)++**Files:**+- Modify: `frontend/src/assets/css/tailwind.css`+- Modify: `frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx`+- Modify: `frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor.tsx` (apply the data attribute and focus the input — confirm exact filename when opening)++- [ ] **Step 1: Add the row-flash keyframe**++ Open `frontend/src/assets/css/tailwind.css`. Locate the `@theme` / `@utility` sections (search for `@utility` to find existing ones). Add:++ ```css+ @keyframes row-flash {+ 0% {+ background-color: color-mix(in oklch, var(--color-success) 18%, transparent);+ }+ 100% {+ background-color: transparent;+ }+ }++ @utility animate-row-flash {+ animation: row-flash 1.2s ease-out forwards;+ }+ ```++ Use `color-mix` against `--color-success` so the flash respects the theme; `bg-success/10` directly does not apply through animation in Tailwind v4 without a custom keyframe.++- [ ] **Step 2: Mark newly-added columns in `handleAddColumn`**++ In `frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx`, replace `handleAddColumn` (currently lines 69-86) with:++ ```tsx+ const handleAddColumn = useCallback(() => {+ const column = create(ColumnMetadataSchema, {+ name: "",+ type: "",+ nullable: true,+ hasDefault: false,+ default: "",+ comment: "",+ });+ markUUID(column);+ table.columns.push(column);+ editStatus.markEditStatus(db, { schema, table, column }, "created");+ rebuildTree(false);+ scrollStatus.queuePendingScrollToColumn({+ db,+ metadata: { database, schema, table, column },+ });+ // Surface the new row visually. The flash + autofocus run in+ // TableColumnEditor when it sees data-just-added on the row.+ scrollStatus.queuePendingFocusForColumn?.({+ db,+ metadata: { database, schema, table, column },+ });+ }, [db, database, schema, table, editStatus, rebuildTree, scrollStatus]);+ ```++ Note: if `queuePendingFocusForColumn` doesn't yet exist on `scrollStatus`, locate `scrollStatus` (likely in `frontend/src/react/components/SchemaEditorLite/context.ts` or a hook nearby) and add a small queue parallel to `queuePendingScrollToColumn`:++ ```ts+ // Inside the scrollStatus state object:+ pendingFocusColumnKey: null as string | null,++ queuePendingFocusForColumn(target: ColumnTarget) {+ this.pendingFocusColumnKey = columnKey(target);+ },++ consumePendingFocusForColumn(target: ColumnTarget): boolean {+ if (this.pendingFocusColumnKey !== columnKey(target)) return false;+ this.pendingFocusColumnKey = null;+ return true;+ },+ ```++ Use the existing `columnKey` helper that `queuePendingScrollToColumn` already uses (search the file for it). If the existing scrollStatus is a Zustand-like store with `set`, follow the same pattern.++- [ ] **Step 3: Consume the flag in the column editor row**++ Open `frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor.tsx` (verify exact filename — referenced via `import { TableColumnEditor } from "./TableColumnEditor";` in `TableEditor.tsx`). For each rendered column row:++ - Add a `useRef<HTMLInputElement>(null)` for the Name input on each row (if not already present).+ - On mount of a row whose column matches the pending-focus key, call `consumePendingFocusForColumn`; if it returns `true`, focus the name input, set `data-just-added="true"` on the row, and add `animate-row-flash` to the row's `className`.+ - Remove the attribute / class on `onAnimationEnd`.++ Minimal sketch (drop into the row component):++ ```tsx+ const rowRef = useRef<HTMLTableRowElement>(null);+ const nameInputRef = useRef<HTMLInputElement>(null);+ const [justAdded, setJustAdded] = useState(false);++ useEffect(() => {+ if (scrollStatus.consumePendingFocusForColumn({ db, metadata: { database, schema, table, column } })) {+ setJustAdded(true);+ // Defer focus to the next frame so the row is in the DOM.+ requestAnimationFrame(() => nameInputRef.current?.focus());+ }+ // We only want this on mount per row instance.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ return (+ <tr+ ref={rowRef}+ data-just-added={justAdded || undefined}+ className={cn(rowClassName, justAdded && "animate-row-flash")}+ onAnimationEnd={() => setJustAdded(false)}+ >+ {/* …existing cells, with nameInputRef passed to the Name <Input /> */}+ </tr>+ );+ ```++ If `TableColumnEditor` renders rows via a virtualized list, apply the same pattern at whichever element actually represents a row in the DOM.++- [ ] **Step 4: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS.++ Run: `pnpm --dir frontend check`+ Expected: PASS.++- [ ] **Step 5: Manual sanity check**++ In the dev server, open a table and click "Add column". Expected:+ - The row appears, the editor scrolls to it (existing behavior).+ - The row pulses a faint green for ~1.2s.+ - The Name input is focused — you can immediately type the column name.+ - Adding a second column does the same; previously-added rows do not re-flash.++- [ ] **Step 6: Commit**++ ```bash+ git add frontend/src/assets/css/tailwind.css \+ frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx \+ frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor.tsx \+ frontend/src/react/components/SchemaEditorLite/context.ts+ git commit -m "feat(schema-editor): flash and focus newly added columns"+ ```++---++## Task 7: Toolbar density and empty-state polish++**Files:**+- Modify: `frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx`+- Modify: `frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx` (or wherever the editor renders when no tables exist — verify on opening)++- [ ] **Step 1: Tighten the body spacing in `SchemaEditorSheet`**++ In `frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx`, locate the body wrapper (currently `<div className="flex flex-1 flex-col gap-y-3 overflow-hidden px-4 pb-2">` on line 212). Change:++ ```tsx+ <div className="flex flex-1 flex-col gap-y-2 overflow-hidden px-4 pb-2">+ ```++ (`gap-y-3` → `gap-y-2`). Align the combobox row above the editor by giving the combobox `<div>` a fixed height: `<div className="flex h-9 items-center gap-x-2">` — this keeps the baseline stable whether or not the row is present.++- [ ] **Step 2: Add an empty-state for the editor panel**++ Open `frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx` and locate where the right panel (`EditorPanel`) renders. Find the path where the selected database has no tables and no views yet — likely a render that returns nothing or a bare empty `<div>`. Replace whatever is rendered in that branch with:++ ```tsx+ <div className="flex h-full items-center justify-center px-6">+ <div className="flex flex-col items-center gap-y-2 text-center">+ <Table2 className="size-8 text-control-light" />+ <p className="text-sm text-control">+ {t("schema-editor.empty-state.no-tables")}+ </p>+ <p className="text-xs text-control-light">+ {t("schema-editor.empty-state.hint")}+ </p>+ </div>+ </div>+ ```++ Add the corresponding locale entries to `frontend/src/locales/en-US.json` under the existing `"schema-editor"` block (the block starts around line 1773):++ ```json+ "empty-state": {+ "no-tables": "No objects yet",+ "hint": "Right-click a schema in the tree to create your first table."+ }+ ```++ Import `Table2` from `lucide-react` and `useTranslation` from `react-i18next` if not already in this file.++- [ ] **Step 3: Type-check and lint**++ Run: `pnpm --dir frontend type-check`+ Expected: PASS.++ Run: `pnpm --dir frontend check`+ Expected: PASS.++- [ ] **Step 4: Manual sanity check**++ - Open a plan whose target database has at least one table — confirm there's no visual regression in the editor body; the combobox row should not jitter when switching databases.+ - Open a plan whose target database has no tables yet — confirm the empty-state appears with the correct icon, title, and hint.++- [ ] **Step 5: Commit**++ ```bash+ git add frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx \+ frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx \+ frontend/src/locales/+ git commit -m "feat(schema-editor): tighten toolbar spacing and add empty state"+ ```++---++## Task 8: Final verification++**Files:** none — verification only.++- [ ] **Step 1: Run the full frontend check suite**++ ```bash+ pnpm --dir frontend fix+ pnpm --dir frontend check+ pnpm --dir frontend type-check+ pnpm --dir frontend test+ ```++ Expected: all PASS. `fix` may auto-format a few files; if so, amend the most recent task's commit:++ ```bash+ git add -u+ git commit --amend --no-edit+ ```++- [ ] **Step 2: End-to-end manual walkthrough**++ In the dev server, walk the full BYT-9473 acceptance set in a single session:++ 1. Open a plan, open the schema editor → drawer is `xlarge` width.+ 2. Click ⤢ → drawer expands to ~95vw with the left strip visible. ⤢ again → back to `xlarge`.+ 3. Click the left strip → sheet closes. Reopen → back at `xlarge` (state reset).+ 4. Tree shows the new column SVG icon (matches SQL Editor); created/updated/dropped entries show their badges.+ 5. Right-click a schema → "New table" → popover at cursor → name → Enter → table created, tab opened, tree updated.+ 6. Click "Add column" → row scrolls into view, flashes green for ~1.2s, Name input is focused.+ 7. Switch to a database with no tables → empty-state appears with hint.+ 8. Esc closes the sheet from both `xlarge` and `huge` modes.++- [ ] **Step 3: Compare against the pre-PR checklist**++ Open `docs/pre-pr-checklist.md` and run through it. Notable items for this change:+ - No breaking changes (UI only).+ - No composite-PK queries touched.+ - No backend changes.+ - i18n: all new strings live in `frontend/src/locales/`.+ - SonarCloud properties: unchanged.++- [ ] **Step 4: Push and open PR**++ ```bash+ git push -u origin steven/byt-9473-schema-editor-display-not-work-properly+ gh pr create --title "fix(schema-editor): maximize toggle + BYT-9473 polish" --body "$(cat <<'EOF'+ ## Summary+ - Plan-detail schema editor drawer gains a maximize toggle (xlarge ↔ 95vw)+ - Replaces the bold "C" column icon with the shared SQL Editor `ColumnIcon`+ - Converts the nested "New table" dialog to an inline popover (fixes nested-modal focus issue)+ - Flashes + focuses newly added column rows so they're not silently appended+ - Adds Badge markers + empty-state polish in the schema editor tree++ Closes BYT-9473.++ ## Test plan+ - [ ] Drawer opens at xlarge; ⤢ toggles to 95vw; resets on each open+ - [ ] Strip click closes the sheet+ - [ ] Tree column rows render the shared `ColumnIcon`+ - [ ] "New table" popover works from the schema context menu+ - [ ] "Add column" — row scrolls in, flashes, Name input is focused+ - [ ] Empty-state appears for a database with no tables+ - [ ] `pnpm --dir frontend type-check && pnpm --dir frontend check && pnpm --dir frontend test` all pass++ 🤖 Generated with [Claude Code](https://claude.com/claude-code)+ EOF+ )"+ ```++---++## Notes for the implementing engineer++- **TDD posture for this plan:** the spec deliberately calls for no new automated tests (the schema editor has none today, and adding them is out of scope). Verification is via type-check, lint, the layering scanner, and the manual walkthrough at the end of each task and in Task 8. If a step surfaces a unit-testable invariant cheaply (e.g. the maximize state reset), feel free to add a test in `frontend/src/react/components/ui/sheet.test.tsx`-style — but don't block the plan on it.+- **Layering policy:** every overlay surface in this plan portals into the shared `overlay` family via the existing primitives (`Sheet`, `Popover`). Do not introduce raw `z-index`, raw body portals, or new layer roots. Run `pnpm --dir frontend check` after each task to keep the layering scanner happy.+- **Locale files:** the project usually mirrors keys across all locales under `frontend/src/locales/`. If a `pnpm` build fails because a key is missing from a non-English locale, copy the English fallback into the missing file rather than silently dropping the key.+- **Worktree:** if executing in an isolated worktree, it should have been created via `superpowers:using-git-worktrees`. Otherwise work in the `steven/byt-9473-schema-editor-display-not-work-properly` branch already named on the Linear issue.diff --git a/docs/superpowers/specs/2026-05-12-byt-9473-schema-editor-plan-detail-container-design.md b/docs/superpowers/specs/2026-05-12-byt-9473-schema-editor-plan-detail-container-design.mdnew file mode 100644index 0000000000..30407eb2af--- /dev/null+++ b/docs/superpowers/specs/2026-05-12-byt-9473-schema-editor-plan-detail-container-design.md@@ -0,0 +1,262 @@+# Schema Editor — Plan Detail Container Redesign + BYT-9473 Polish++**Date:** 2026-05-12+**Linear:** [BYT-9473](https://linear.app/bytebase/issue/BYT-9473/schema-editor-display-not-work-properly)+**Branch:** `steven/byt-9473-schema-editor-display-not-work-properly`++## Summary++Replace the fixed-width drawer that hosts the schema editor inside the plan+detail page with a drawer that can be maximized to ~95% viewport. Bundle the+four polish issues called out in BYT-9473 (column icon mismatch, broken "new+table" action, missing add-column highlight, general unfinished feel) into the+same change so the editor lands in a coherent state.++The editor's *internals* (tree + table editor + DDL preview layout) are+explicitly out of scope. This is a container change plus targeted polish, not+a redesign of the schema editor itself.++## Motivation++Today `SchemaEditorSheet` opens a right-side `Sheet` at the `xlarge` width tier+(70rem ≈ 1120px). At that width the tree, table editor, and DDL preview+compete for horizontal space and the experience feels cramped — which is half+of what BYT-9473's "overall display not so polished" actually reports. The+other half is four concrete defects flagged in the same ticket.++A wider drawer is the smallest change that resolves the cramped feeling+without (a) violating the AGENTS.md rule that resource editing uses Sheets,+(b) restructuring the plan detail page, or (c) rewriting the schema editor+internals.++## Goals++- Give the schema editor enough horizontal room to feel polished without+ losing the plan context behind it.+- Fix the four BYT-9473 defects in one coherent change.+- Stay inside the existing design system (Sheet for editing, shared UI+ components, semantic color tokens).++## Non-Goals++- No redesign of the schema editor's internal layout (tree / table editor /+ DDL preview). The "diff-first / ER diagram / DDL split / step builder"+ options were explored and ruled out.+- No changes to other call sites of `SchemaEditorLite`. Only+ `SchemaEditorSheet` in plan detail gets the new container behavior.+- No persistence of the maximize toggle across sessions. Always resets to+ the default width on each open.+- No new schema editor tests. The component has no integration tests today;+ this change is not the place to add them.++## Design++### 1. Container behavior++**Default open** — same as today: right-side `Sheet` at the `xlarge` width+tier (70rem). No regression for users with current habits.++**New `huge` width tier** — extend `sheetContentVariants` in+`frontend/src/react/components/ui/sheet.tsx`:++```ts+huge: "w-[95vw]",+```++This leaves a 5vw strip on the left as the visual anchor the user asked for.++**Maximize toggle** — a `⤢` icon button (`Maximize2` / `Minimize2` from+`lucide-react`) in the sheet header, immediately left of the close X. Click+toggles between `xlarge` and `huge`. Tooltips: "Maximize" / "Restore" (new+locale entries).++**State** — local `useState(false)` inside `SchemaEditorSheet`. The body is+already mounted via `{open && <SchemaEditorSheetBody />}`, so closing and+reopening the sheet remounts the body and resets `maximized` to `false`. No+localStorage, no Pinia.++**Strip click semantics** — keep Base UI's default: clicking the scrim /+strip closes the sheet (same as every other sheet in the app). The strip is+purely a visual anchor; it is not a de-maximize handle. Toggle is via the+button only. This avoids hijacking Base UI's outside-click behavior and+keeps a single mental model for sheet dismissal across the app.++**Keyboard** — `Esc` closes (existing behavior, unchanged). No new shortcut+for maximize, to avoid collision risk with the schema editor's own+keybindings.++### 2. Sheet header actions slot++The shared `SheetHeader` currently renders `children` (a flex column for+title + description) and a fixed `SheetClose`. There's no place to inject a+secondary action like the maximize toggle.++Add an optional `actions` slot rendered immediately before the close button:++```tsx+function SheetHeader({ className, children, actions, ...props }) {+ return (+ <div className={...}>+ <div className="flex flex-col gap-y-1 min-w-0 flex-1">{children}</div>+ {actions ? (+ <div className="flex items-center gap-x-1 shrink-0">{actions}</div>+ ) : null}+ <BaseDialog.Close ...>+ <X className="size-4" />+ </BaseDialog.Close>+ </div>+ );+}+```++This is a reusable extension. Any other sheet that needs a header-level+action (e.g. a settings gear, an external-link icon) can use the same slot.+No existing callers need to change.++### 3. BYT-9473 polish fixes++#### 3.1 Column "C" icon mismatch++Today `AsideTree.tsx:472-477`:++```tsx+case "column":+ return <div className="size-4 text-center text-xs font-bold leading-4">C</div>;+```++SQL Editor uses a proper SVG `ColumnIcon` in+`frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx:133-150`.++**Fix** — create a shared module+`frontend/src/react/components/schema/icons.tsx` and move `ColumnIcon`+(plus its siblings if convenient) there. Import from both editors so they+cannot drift again. During the move, swap the raw `text-gray-500` for the+semantic `text-control-light`, per AGENTS.md "no raw color values".++#### 3.2 "New table" action does not work++`TableNameDialog` is a Base UI `Dialog` rendered inside an open `Sheet`. Both+portal into the same `overlay` layer family. The symptom in BYT-9473 is+consistent with the inner Dialog losing focus / event propagation to the+parent Sheet's focus trap — a known Base UI nested-modal hazard.++**Fix** — replace the nested Dialog with an inline name-entry popover+anchored to the schema's "New table" menu item. Specifically:++- Trigger from the tree context menu opens a `Popover` (Base UI) anchored to+ the menu item, containing the same `Input` + Cancel/Create buttons.+- No portal nesting inside the overlay family, no focus trap conflict.+- Rename flow can keep the inline popover as well, or stay as a Dialog if+ it is invoked from a context where no Sheet is open. Default: convert+ both to the popover for consistency.++This is meaningfully lighter than repairing the nested focus trap and+matches recent React UI patterns elsewhere in the app.++#### 3.3 No highlight on "Add column"++Today `TableEditor.tsx:69-92` pushes the new `ColumnMetadata` and marks it+`created`. The row's status text turns green but the row blends in; no+animation, no scroll, no focus shift.++**Fix** — three small additions in `handleAddColumn`:++1. Queue a scroll-to via the existing+ `scrollStatus.queuePendingScrollToColumn(...)` (already used on click).+2. Set `data-just-added="true"` on the new row. A Tailwind keyframe+ (`animate-row-flash`) fades a `bg-success/10` background over 1.2 s and+ removes the attribute on animation end.+3. Focus the Name input on the new row so the user can immediately type.++Define `animate-row-flash` in `frontend/src/assets/css/tailwind.css` via+`@keyframes` + `@utility`. Uses the semantic `--color-success` token.++#### 3.4 General polish++Tightly scoped — only changes that read as "unfinished" today:++- Replace `<div>C</div>`-style bare text status indicators with shared+ `Badge` for create / update / drop markers in the tree. Status text-color+ alone (`text-success` / `text-warning` / `text-error`) is too quiet.+- Toolbar density pass on the editor body: current `gap-y-3` is uneven+ against the database combobox. Tighten to `gap-y-2` and align baselines.+- Empty-state visual when the selected database has no tables yet (today+ the panel is silent and looks broken).++### 4. Files touched++```+frontend/src/react/components/ui/sheet.tsx+ + add "huge" width tier (w-[95vw])+ + add optional `actions` slot to SheetHeader++frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx+ + maximized state + ⤢ Maximize2/Minimize2 toggle wired into SheetHeader actions+ + width = maximized ? "huge" : "xlarge"+ + new locale keys for "Maximize" / "Restore" tooltips++frontend/src/react/components/schema/icons.tsx (new)+ + house ColumnIcon (+ siblings if appropriate); text-control-light not text-gray-500++frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+ + replace <div>C</div> with the shared ColumnIcon+ + wrap status text with Badge for create / update / drop markers++frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx+ → convert to an inline Popover-based component (rename file accordingly,+ e.g. TableNamePopover.tsx); update call sites++frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx+ + handleAddColumn: queue scroll, set data-just-added, focus Name input++frontend/src/assets/css/tailwind.css+ + @keyframes + @utility for animate-row-flash (1.2s bg-success/10 fade)++frontend/src/locales/*.json+ + Maximize, Restore tooltip strings+```++### 5. Testing++**Manual** — open a plan, click "Schema editor":++- Default opens at `xlarge` width (no regression).+- ⤢ toggles to ~95vw; ⤢ again restores; closing and reopening always lands+ back at `xlarge`.+- 5vw strip click closes the sheet (same as today's scrim behavior).+- Tree column rows show the new `ColumnIcon`, visually identical to SQL+ Editor.+- "New table" creates a table, opens a tab, scrolls to it; works from+ every entry point.+- "Add column" — new row scrolls into view, flashes briefly, Name input is+ focused.+- `Esc` closes the sheet from both `xlarge` and `huge` modes.++**Automated** — none required for this scope. Existing checks cover:++- `pnpm --dir frontend type-check`+- `pnpm --dir frontend check` (lint, biome, layering scanner)+- `pnpm --dir frontend test` (existing tests must still pass)++**i18n** — confirm no hardcoded display strings; the two new tooltip+strings are added to `frontend/src/locales/`.++## Trade-offs Considered++- **Full-page route** instead of a maximizable drawer — explicitly rejected.+ Loses plan context; routing overhead is wrong for a short-lived+ compose-then-insert flow.+- **Centered modal Dialog** — explicitly rejected. Violates AGENTS.md+ ("Sheet for editing, Dialog for confirmations").+- **Inline expansion** inside the plan detail statement section — explicitly+ rejected. Crowds vertical space and competes with the SQL textarea.+- **Split pane** in plan detail — explicitly rejected. Restructures the plan+ detail page for one feature; cost > benefit.+- **Persisting maximize across sessions** — rejected. Reset on each open+ keeps state model simple; users who always want maximized can ask later.++## Open Questions++None at design time. Implementation may surface a focus-trap edge case in+section 3.2 (inline popover inside a sheet) — the fallback is to leave+rename as a Dialog and convert only the create path.diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsxindex 309330f895..8f352e492f 100644--- a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx@@ -7,13 +7,24 @@ import {FileCode,FunctionSquare,Layers,+ Plus,Table2,View,} from "lucide-react";-import { useCallback, useMemo, useRef, useState } from "react";+import { Fragment, useCallback, useMemo, useRef, useState } from "react";import type { NodeRendererProps } from "react-arborist";import { Tree } from "react-arborist";import { createPortal } from "react-dom";+import { useTranslation } from "react-i18next";+import { ColumnIcon } from "@/react/components/schema/icons";+import { Badge } from "@/react/components/ui/badge";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/react/components/ui/dropdown-menu";import { getLayerRoot, LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";import { SearchInput } from "@/react/components/ui/search-input";import { cn } from "@/react/lib/utils";@@ -27,9 +38,16 @@ import {ProcedureMetadataSchema,ViewMetadataSchema,} from "@/types/proto-es/v1/database_service_pb";+import { getDatabaseEngine } from "@/utils";import { useSchemaEditorContext } from "../context";+import {+ engineSupportsEditFunctions,+ engineSupportsEditProcedures,+ engineSupportsEditViews,+ engineSupportsMultiSchema,+} from "../core/spec";import { SchemaNameDialog } from "../Modals/SchemaNameDialog";-import { TableNameDialog } from "../Modals/TableNameDialog";+import { TableNamePopover } from "../Modals/TableNamePopover";import type { EditStatus } from "../types";import { NodeCheckbox } from "./NodeCheckbox";import type { TreeNode, TreeNodeForTable } from "./tree-builder";@@ -37,6 +55,7 @@ import { buildTree } from "./tree-builder";import { useContextMenu } from "./useContextMenu";export function AsideTree() {+ const { t } = useTranslation();const context = useSchemaEditorContext();const {targets,@@ -51,6 +70,10 @@ export function AsideTree() {const [searchPattern, setSearchPattern] = useState("");const containerRef = useRef<HTMLDivElement>(null);+ // Anchor for the "+" dropdown — the same ref is used as the popover anchor+ // when the user picks "New table" from the dropdown, so the popover always+ // appears in the same spot regardless of how the user opened it.+ const createTriggerRef = useRef<HTMLButtonElement>(null);// Tree data — treeBuildVersion busts the cache after in-place metadata mutationsconst { tree, nodeMap } = useMemo(@@ -79,6 +102,7 @@ export function AsideTree() {typeof useSchemaEditorContext>["targets"][0]["metadata"]["schemas"][0];table?: TreeNodeForTable["metadata"]["table"];+ anchorPoint: { x: number; y: number };} | null>(null);const [schemaNameModalCtx, setSchemaNameModalCtx] = useState<{@@ -109,6 +133,7 @@ export function AsideTree() {db: node.db,database: node.metadata.database,schema: node.metadata.schema,+ anchorPoint: { x: menuState.x, y: menuState.y },});} else if (key === "rename-table" && node.type === "table") {setTableNameModalCtx({@@ -116,6 +141,7 @@ export function AsideTree() {database: node.metadata.database,schema: node.metadata.schema,table: node.metadata.table,+ anchorPoint: { x: menuState.x, y: menuState.y },});} else if (key === "drop-table" && node.type === "table") {const status = editStatus.getTableStatus(node.db, node.metadata);@@ -257,7 +283,15 @@ export function AsideTree() {rebuildTree(false);}},- [menuState.node, hideMenu, editStatus, rebuildTree, tabs]+ [+ menuState.node,+ menuState.x,+ menuState.y,+ hideMenu,+ editStatus,+ rebuildTree,+ tabs,+ ]);// Node click handler@@ -338,14 +372,173 @@ export function AsideTree() {[editStatus]);+ // Discoverable "+" dropdown next to the search input. Mirrors the+ // right-click context menu but is always visible. Routes to the first+ // target + first schema (the common single-DB single-schema case in+ // plan-detail); power users with multi-schema setups can still+ // right-click a specific schema.+ const createActions = useMemo(() => {+ if (readonly || targets.length === 0) return [];+ const target = targets[0];+ const engine = getDatabaseEngine(target.database);+ const firstSchema = target.metadata.schemas[0];+ if (!firstSchema) return [];++ const actions: {+ key: string;+ label: string;+ onSelect: () => void;+ separatorBefore?: boolean;+ }[] = [];++ actions.push({+ key: "create-table",+ label: t("schema-editor.actions.create-table"),+ onSelect: () => {+ const rect = createTriggerRef.current?.getBoundingClientRect();+ setTableNameModalCtx({+ db: target.database,+ database: target.metadata,+ schema: firstSchema,+ anchorPoint: rect ? { x: rect.left, y: rect.bottom } : { x: 0, y: 0 },+ });+ },+ });++ if (engineSupportsEditViews(engine)) {+ actions.push({+ key: "create-view",+ label: t("schema-editor.actions.create-view"),+ onSelect: () => {+ const view = create(ViewMetadataSchema, {+ name: "new_view",+ definition: "",+ }) as ViewMetadata;+ firstSchema.views.push(view);+ editStatus.markEditStatus(+ target.database,+ { schema: firstSchema, view },+ "created"+ );+ tabs.addTab({+ type: "view",+ database: target.database,+ metadata: {+ database: target.metadata,+ schema: firstSchema,+ view,+ },+ });+ rebuildTree(false);+ },+ });+ }++ if (engineSupportsEditProcedures(engine)) {+ actions.push({+ key: "create-procedure",+ label: t("schema-editor.actions.create-procedure"),+ onSelect: () => {+ const procedure = create(ProcedureMetadataSchema, {+ name: "new_procedure",+ definition: "",+ }) as ProcedureMetadata;+ firstSchema.procedures.push(procedure);+ editStatus.markEditStatus(+ target.database,+ { schema: firstSchema, procedure },+ "created"+ );+ tabs.addTab({+ type: "procedure",+ database: target.database,+ metadata: {+ database: target.metadata,+ schema: firstSchema,+ procedure,+ },+ });+ rebuildTree(false);+ },+ });+ }++ if (engineSupportsEditFunctions(engine)) {+ actions.push({+ key: "create-function",+ label: t("schema-editor.actions.create-function"),+ onSelect: () => {+ const func = create(FunctionMetadataSchema, {+ name: "new_function",+ definition: "",+ }) as FunctionMetadata;+ firstSchema.functions.push(func);+ editStatus.markEditStatus(+ target.database,+ { schema: firstSchema, function: func },+ "created"+ );+ tabs.addTab({+ type: "function",+ database: target.database,+ metadata: {+ database: target.metadata,+ schema: firstSchema,+ function: func,+ },+ });+ rebuildTree(false);+ },+ });+ }++ if (engineSupportsMultiSchema(engine)) {+ actions.push({+ key: "create-schema",+ separatorBefore: true,+ label: t("schema-editor.actions.create-schema"),+ onSelect: () => {+ setSchemaNameModalCtx({+ db: target.database,+ database: target.metadata,+ });+ },+ });+ }++ return actions;+ }, [readonly, targets, t, editStatus, tabs, rebuildTree]);+return (<div className="flex size-full flex-col gap-y-2">- <div className="sticky top-0 px-1 pt-1">+ <div className="sticky top-0 flex items-center gap-x-1 px-1 pt-1"><SearchInput- placeholder="Search..."+ placeholder={t("common.search")}onChange={(e) => handleSearchChange(e.target.value)}- className="h-7"+ className="h-7 flex-1"/>+ {createActions.length > 0 && (+ <DropdownMenu>+ <DropdownMenuTrigger+ ref={createTriggerRef}+ aria-label={t("common.create")}+ title={t("common.create")}+ className="flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-xs text-control hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent"+ >+ <Plus className="size-4" />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ {createActions.map((action) => (+ <Fragment key={action.key}>+ {action.separatorBefore && <DropdownMenuSeparator />}+ <DropdownMenuItem onClick={action.onSelect}>+ {action.label}+ </DropdownMenuItem>+ </Fragment>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ )}</div><div ref={containerRef} className="flex-1 overflow-hidden"><Tree@@ -387,7 +580,7 @@ export function AsideTree() {}}><div- className={`absolute rounded-sm border border-control-border bg-white py-1 shadow-md ${LAYER_SURFACE_CLASS}`}+ className={`absolute rounded-sm border border-control-border bg-background py-1 shadow-md ${LAYER_SURFACE_CLASS}`}style={{ left: menuState.x, top: menuState.y }}onClick={(e) => e.stopPropagation()}>@@ -408,9 +601,10 @@ export function AsideTree() {{/* Modals */}{tableNameModalCtx && (- <TableNameDialog+ <TableNamePopoveropenonClose={() => setTableNameModalCtx(null)}+ anchorPoint={tableNameModalCtx.anchorPoint}db={tableNameModalCtx.db}database={tableNameModalCtx.database}schema={tableNameModalCtx.schema}@@ -470,11 +664,7 @@ function NodeIcon({ node }: { node: TreeNode }) {case "table":return <Table2 className={cls} />;case "column":- return (- <div className={cn(cls, "text-center text-xs font-bold leading-4")}>- C- </div>- );+ return <ColumnIcon className={cls} />;case "view":return <View className={cls} />;case "procedure":@@ -511,6 +701,25 @@ function statusClassName(status: EditStatus): string {}}+// Single-character badge next to created/updated/dropped tree entries.+// Text-color alone was too quiet (BYT-9473); the badge is additive and+// keeps the existing color/strike-through on the label.+function StatusBadge({ status }: { status: EditStatus }) {+ if (status === "normal") return null;+ const variant =+ status === "created"+ ? "success"+ : status === "updated"+ ? "warning"+ : "destructive";+ const letter = status === "created" ? "+" : status === "updated" ? "~" : "−";+ return (+ <Badge variant={variant} className="ml-1 h-4 px-1 text-[10px] leading-none">+ {letter}+ </Badge>+ );+}+// Custom node rendererfunction NodeRenderer(props: NodeRendererProps<ArboristNode> & {@@ -577,6 +786,7 @@ function NodeRenderer(<span className={cn("truncate", statusClassName(status))}>{treeNode.label || "(empty)"}</span>+ <StatusBadge status={status} /></div>);}diff --git a/frontend/src/react/components/SchemaEditorLite/EditorPanel.tsx b/frontend/src/react/components/SchemaEditorLite/EditorPanel.tsxindex 17c0757447..4f926d14f5 100644--- a/frontend/src/react/components/SchemaEditorLite/EditorPanel.tsx+++ b/frontend/src/react/components/SchemaEditorLite/EditorPanel.tsx@@ -1,4 +1,5 @@import { useCallback, useState } from "react";+import { useTranslation } from "react-i18next";import { useSchemaEditorContext } from "./context";import { DatabaseEditor } from "./Panels/DatabaseEditor";import { FunctionEditor } from "./Panels/FunctionEditor";@@ -8,6 +9,7 @@ import { ViewEditor } from "./Panels/ViewEditor";import { TabsContainer } from "./TabsContainer";export function EditorPanel() {+ const { t } = useTranslation();const { tabs } = useSchemaEditorContext();const { currentTab } = tabs;@@ -38,7 +40,7 @@ export function EditorPanel() {<div className="flex-1 overflow-y-hidden" key={currentTab?.id ?? "empty"}>{!currentTab && (<div className="flex size-full items-center justify-center text-sm text-control-light">- Select a database object from the tree to edit+ {t("schema-editor.select-object-hint")}</div>)}{currentTab?.type === "database" && (diff --git a/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx b/frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsxsimilarity index 68%rename from frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsxrename to frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsxindex c51dc8b0cb..374c345e3e 100644--- a/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Modals/TableNamePopover.tsx@@ -2,12 +2,8 @@ import { create } from "@bufbuild/protobuf";import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";-import {- Dialog,- DialogContent,- DialogTitle,-} from "@/react/components/ui/dialog";import { Input } from "@/react/components/ui/input";+import { Popover, PopoverContent } from "@/react/components/ui/popover";import { Engine } from "@/types/proto-es/v1/common_pb";import type {Database,@@ -27,6 +23,10 @@ import { markUUID } from "../Panels/common";interface Props {open: boolean;onClose: () => void;+ // Screen-space coordinates of the click that triggered the popover. We+ // anchor to a virtual 0×0 rect at this point so we don't depend on a DOM+ // element that may have unmounted (e.g. the closed context menu item).+ anchorPoint: { x: number; y: number };db: Database;database: DatabaseMetadata;schema: SchemaMetadata;@@ -35,9 +35,10 @@ interface Props {const TABLE_NAME_REGEX = /^\S[\S ]*\S?$/;-export function TableNameDialog({+export function TableNamePopover({open,onClose,+ anchorPoint,db,database,schema,@@ -53,7 +54,7 @@ export function TableNameDialog({const isDuplicate =tableName !== table?.name &&- schema.tables.some((t) => t.name === tableName);+ schema.tables.some((tt) => tt.name === tableName);const isValid =tableName.length > 0 && TABLE_NAME_REGEX.test(tableName) && !isDuplicate;@@ -124,15 +125,40 @@ export function TableNameDialog({onClose,]);+ // Virtual anchor at the click point. Base UI's Positioner accepts an+ // object exposing getBoundingClientRect(); a 0×0 rect at (x, y) lets the+ // popover float right next to where the user clicked.+ const anchor = {+ getBoundingClientRect: () =>+ ({+ width: 0,+ height: 0,+ x: anchorPoint.x,+ y: anchorPoint.y,+ top: anchorPoint.y,+ left: anchorPoint.x,+ right: anchorPoint.x,+ bottom: anchorPoint.y,+ toJSON() {+ return this;+ },+ }) as DOMRect,+ };+return (- <Dialog open={open} onOpenChange={(next) => !next && onClose()}>- <DialogContent>- <DialogTitle>- {isCreateMode- ? t("schema-editor.actions.create-table")- : t("schema-editor.actions.rename-table")}- </DialogTitle>- <div className="mt-4 flex flex-col gap-y-4">+ <Popover open={open} onOpenChange={(next) => !next && onClose()}>+ <PopoverContent+ anchor={anchor}+ side="bottom"+ align="start"+ className="w-72 p-3"+ >+ <div className="flex flex-col gap-y-3">+ <div className="text-sm font-medium text-control">+ {isCreateMode+ ? t("schema-editor.actions.create-table")+ : t("schema-editor.actions.rename-table")}+ </div><Inputvalue={tableName}placeholder={t("schema-editor.table.name-placeholder")}@@ -140,6 +166,7 @@ export function TableNameDialog({onChange={(e) => setTableName(e.target.value)}onKeyDown={(e) => {if (e.key === "Enter") handleConfirm();+ if (e.key === "Escape") onClose();}}/>{isDuplicate && (@@ -148,15 +175,15 @@ export function TableNameDialog({</p>)}<div className="flex items-center justify-end gap-x-2">- <Button variant="outline" onClick={onClose}>+ <Button variant="outline" size="sm" onClick={onClose}>{t("common.cancel")}</Button>- <Button disabled={!isValid} onClick={handleConfirm}>+ <Button size="sm" disabled={!isValid} onClick={handleConfirm}>{isCreateMode ? t("common.create") : t("common.save")}</Button></div></div>- </DialogContent>- </Dialog>+ </PopoverContent>+ </Popover>);}diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.tsxindex c69df69dad..d47b08e993 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.tsx@@ -1,5 +1,4 @@-import { create } from "@bufbuild/protobuf";-import { Plus, Trash2 } from "lucide-react";+import { Trash2 } from "lucide-react";import { useCallback } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";@@ -21,7 +20,6 @@ import type {SchemaMetadata,TableMetadata,} from "@/types/proto-es/v1/database_service_pb";-import { IndexMetadataSchema } from "@/types/proto-es/v1/database_service_pb";import { useSchemaEditorContext } from "../../context";interface Props {@@ -47,18 +45,6 @@ export function IndexesEditor({value: col.name,}));- const handleAddIndex = useCallback(() => {- const index = create(IndexMetadataSchema, {- name: `idx_${table.name}_${Date.now()}`,- expressions: [],- primary: false,- unique: false,- comment: "",- });- table.indexes.push(index);- editStatus.markEditStatus(db, { schema, table }, "updated");- }, [table, editStatus, db, schema]);-const handleDropIndex = useCallback((index: IndexMetadata) => {const idx = table.indexes.indexOf(index);@@ -74,14 +60,6 @@ export function IndexesEditor({return (<div className="flex size-full flex-col gap-y-2 overflow-auto">- {!isReadonly && (- <div>- <Button variant="outline" size="sm" onClick={handleAddIndex}>- <Plus className="mr-1 size-4" />- {t("schema-editor.actions.add-index")}- </Button>- </div>- )}<Table><TableHeader><TableRow>diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.tsxindex 85dd6d16b1..c034dfd54c 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.tsx@@ -1,5 +1,4 @@-import { create } from "@bufbuild/protobuf";-import { Plus, RotateCcw, Trash2 } from "lucide-react";+import { RotateCcw, Trash2 } from "lucide-react";import { useCallback } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";@@ -20,10 +19,7 @@ import type {TableMetadata,TablePartitionMetadata,} from "@/types/proto-es/v1/database_service_pb";-import {- TablePartitionMetadata_Type,- TablePartitionMetadataSchema,-} from "@/types/proto-es/v1/database_service_pb";+import { TablePartitionMetadata_Type } from "@/types/proto-es/v1/database_service_pb";import { useSchemaEditorContext } from "../../context";interface Props {@@ -44,19 +40,6 @@ export function PartitionsEditor({const { t } = useTranslation();const { editStatus } = useSchemaEditorContext();- const handleAddPartition = useCallback(() => {- const firstPartition = table.partitions[0];- const partition = create(TablePartitionMetadataSchema, {- name: `p${table.partitions.length}`,- type: firstPartition?.type ?? TablePartitionMetadata_Type.RANGE,- expression: firstPartition?.expression ?? "",- value: "",- subpartitions: [],- });- table.partitions.push(partition);- editStatus.markEditStatus(db, { schema, table }, "updated");- }, [table, editStatus, db, schema]);-const handleDropPartition = useCallback((partition: TablePartitionMetadata) => {const status = editStatus.getPartitionStatus(db, {@@ -98,14 +81,6 @@ export function PartitionsEditor({return (<div className="flex size-full flex-col gap-y-2 overflow-auto">- {!isReadonly && (- <div>- <Button variant="outline" size="sm" onClick={handleAddPartition}>- <Plus className="mr-1 size-4" />- {t("schema-editor.actions.add-partition")}- </Button>- </div>- )}<Table><TableHeader><TableRow>diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsxindex 3d1d763c95..a02cd931f1 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx@@ -151,16 +151,18 @@ export function PreviewPane({ db, database, schema, table }: Props) {</button>{expanded && (<div- className="relative overflow-hidden"+ className="relative overflow-y-auto"style={{ height: `${height}px` }}>{pending && (- <div className="absolute inset-0 z-10 flex items-center justify-center bg-white/60">+ <div className="absolute inset-0 z-10 flex items-center justify-center bg-background/60"><Loader2 className="size-5 animate-spin text-accent" /></div>)}{error ? (- <pre className="p-2 text-xs text-error">{error}</pre>+ <pre className="m-2 overflow-auto rounded-xs bg-error/5 p-3 text-xs whitespace-pre-wrap text-error">+ {error}+ </pre>) : (<ReadonlyMonacocontent={ddl}diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsxindex 99b2c5743a..60c30482fe 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx@@ -246,17 +246,29 @@ export function TableColumnEditor({<TableRowkey={key}className={cn(- status === "created" && "text-success",- status === "updated" && "text-warning",- status === "dropped" && "text-error line-through"+ // Soft per-status background tint instead of coloring every+ // input's text — far easier to read at a glance. Line-through+ // on dropped survives so the row reads as "going away."+ status === "created" && "bg-success/5",+ status === "updated" && "bg-warning/5",+ status === "dropped" && "bg-error/5 line-through",+ // Hover only on rows with no status tint so we don't fight+ // the colored backgrounds above.+ status === "normal" && "hover:bg-control-bg-hover")}><TableCell className={cellClass}><Input+ // Newly-created, unnamed rows autofocus on mount so the+ // user can type immediately. `autoFocus` fires only on+ // the initial mount of a row, so clearing the name on+ // an existing column won't re-steal focus.+ autoFocus={status === "created" && column.name === ""}+ placeholder={t("schema-editor.column.name-placeholder")}value={column.name}disabled={disabled}size="xs"- className="border-none bg-transparent shadow-none focus-visible:ring-1"+ className="border-none bg-transparent shadow-none enabled:hover:bg-control-bg/60 focus-visible:ring-1"onChange={(e) =>handleColumnNameChange(column, e.target.value)}@@ -283,7 +295,7 @@ export function TableColumnEditor({value={column.comment}disabled={disabled}size="xs"- className="border-none bg-transparent shadow-none focus-visible:ring-1"+ className="border-none bg-transparent shadow-none enabled:hover:bg-control-bg/60 focus-visible:ring-1"onChange={(e) =>handleCommentChange(column, e.target.value)}@@ -322,7 +334,7 @@ export function TableColumnEditor({<Buttonvariant="ghost"size="sm"- className="size-7 p-0 text-error hover:text-error"+ className="size-7 p-0 text-control-light hover:bg-error/10 hover:text-error"disabled={disableChangeTable}onClick={() => handleDropColumn(column)}>diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsxindex c1007856fc..1ab4461728 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx@@ -3,13 +3,19 @@ import { Plus } from "lucide-react";import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";+import { SegmentedControl } from "@/react/components/ui/segmented-control";import type {Database,DatabaseMetadata,SchemaMetadata,TableMetadata,} from "@/types/proto-es/v1/database_service_pb";-import { ColumnMetadataSchema } from "@/types/proto-es/v1/database_service_pb";+import {+ ColumnMetadataSchema,+ IndexMetadataSchema,+ TablePartitionMetadata_Type,+ TablePartitionMetadataSchema,+} from "@/types/proto-es/v1/database_service_pb";import { getDatabaseEngine } from "@/utils";import { useSchemaEditorContext } from "../context";import {@@ -85,6 +91,63 @@ export function TableEditor({});}, [db, database, schema, table, editStatus, rebuildTree, scrollStatus]);+ // Add-index / add-partition handlers live at the TableEditor level so the+ // three "Add …" actions can share a single right-aligned slot in the+ // toolbar instead of jumping into the body panel when the user switches+ // tabs. The child editors no longer render their own add buttons.+ const handleAddIndex = useCallback(() => {+ const index = create(IndexMetadataSchema, {+ name: `idx_${table.name}_${Date.now()}`,+ expressions: [],+ primary: false,+ unique: false,+ comment: "",+ });+ table.indexes.push(index);+ editStatus.markEditStatus(db, { schema, table }, "updated");+ }, [table, editStatus, db, schema]);++ const handleAddPartition = useCallback(() => {+ const firstPartition = table.partitions[0];+ const partition = create(TablePartitionMetadataSchema, {+ name: `p${table.partitions.length}`,+ type: firstPartition?.type ?? TablePartitionMetadata_Type.RANGE,+ expression: firstPartition?.expression ?? "",+ value: "",+ subpartitions: [],+ });+ table.partitions.push(partition);+ editStatus.markEditStatus(db, { schema, table }, "updated");+ }, [table, editStatus, db, schema]);++ const addAction = useMemo(() => {+ if (readonly || disableChangeTable) return null;+ if (mode === "COLUMNS") {+ return {+ label: t("schema-editor.actions.add-column"),+ onClick: handleAddColumn,+ };+ }+ if (mode === "INDEXES") {+ return {+ label: t("schema-editor.actions.add-index"),+ onClick: handleAddIndex,+ };+ }+ return {+ label: t("schema-editor.actions.add-partition"),+ onClick: handleAddPartition,+ };+ }, [+ readonly,+ disableChangeTable,+ mode,+ t,+ handleAddColumn,+ handleAddIndex,+ handleAddPartition,+ ]);+const markTableStatus = useCallback((status: "updated") => {if (tableStatus === "created" || tableStatus === "dropped") return;@@ -93,41 +156,42 @@ export function TableEditor({[tableStatus, editStatus, db, schema, table]);+ const modeOptions = useMemo(() => {+ const items: { value: EditorMode; label: string }[] = [+ { value: "COLUMNS", label: t("schema-editor.columns") },+ ];+ if (showIndexes) {+ items.push({ value: "INDEXES", label: t("schema-editor.indexes") });+ }+ if (showPartitions) {+ items.push({+ value: "PARTITIONS",+ label: t("schema-editor.partitions"),+ });+ }+ return items;+ }, [showIndexes, showPartitions, t]);+return (<div className="flex size-full flex-col gap-y-2 overflow-y-hidden pt-2">{/* Toolbar */}<div className="flex items-center gap-x-2 px-4">- <div className="flex items-center gap-x-1">+ <SegmentedControl+ value={mode}+ options={modeOptions}+ onValueChange={setMode}+ ariaLabel={t("schema-editor.self")}+ size="sm"+ />+ {addAction && (<Button- variant={mode === "COLUMNS" ? "default" : "outline"}+ variant="outline"size="sm"- onClick={() => setMode("COLUMNS")}+ className="ml-auto"+ onClick={addAction.onClick}>- {t("schema-editor.columns")}- </Button>- {showIndexes && (- <Button- variant={mode === "INDEXES" ? "default" : "outline"}- size="sm"- onClick={() => setMode("INDEXES")}- >- {t("schema-editor.indexes")}- </Button>- )}- {showPartitions && (- <Button- variant={mode === "PARTITIONS" ? "default" : "outline"}- size="sm"- onClick={() => setMode("PARTITIONS")}- >- {t("schema-editor.partitions")}- </Button>- )}- </div>- {!readonly && !disableChangeTable && mode === "COLUMNS" && (- <Button variant="outline" size="sm" onClick={handleAddColumn}><Plus className="mr-1 size-4" />- {t("schema-editor.actions.add-column")}+ {addAction.label}</Button>)}</div>diff --git a/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx b/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsxindex 1aa22217bb..9a67650b59 100644--- a/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx+++ b/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx@@ -175,7 +175,7 @@ export const SchemaEditorLite = forwardRef<<SchemaEditorProvider value={contextValue}><div className="bb-schema-editor relative flex size-full flex-col overflow-hidden rounded-sm border">{combinedLoading && (- <div className="absolute inset-0 z-10 flex items-center justify-center bg-white/60">+ <div className="absolute inset-0 z-10 flex items-center justify-center bg-background/60"><Loader2 className="size-8 animate-spin text-accent" /></div>)}diff --git a/frontend/src/react/components/schema/icons.tsx b/frontend/src/react/components/schema/icons.tsxnew file mode 100644index 0000000000..ce6ef18a8e--- /dev/null+++ b/frontend/src/react/components/schema/icons.tsx@@ -0,0 +1,28 @@+import { cn } from "@/react/lib/utils";++interface IconProps {+ className?: string;+}++// Single-column variant of `lucide:columns-3` (the second internal gap line+// removed). Used in both Schema Editor and SQL Editor tree views so the two+// surfaces stay visually identical.+export function ColumnIcon({ className }: IconProps) {+ return (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="24"+ height="24"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ className={cn("size-4 text-control-light", className)}+ >+ <rect width="18" height="18" x="3" y="3" rx="2" />+ <path d="M9 3v18" />+ </svg>+ );+}diff --git a/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx b/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsxindex 4e6b9fff6f..0ce95d761f 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/icons.tsx@@ -126,26 +126,6 @@ export function CheckConstraintIcon({ className }: IconProps) {return <Check className={cn("size-3.5 text-gray-500", className)} />;}-/**- * Vue's ColumnIcon is a hand-edited "lucide:columns-3" with the second- * gap line removed (single column instead of two). Reproduce the SVG.- */-export function ColumnIcon({ className }: IconProps) {- return (- <svg- xmlns="http://www.w3.org/2000/svg"- width="24"- height="24"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- className={cn(baseSize, "text-gray-500", className)}- >- <rect width="18" height="18" x="3" y="3" rx="2" />- <path d="M9 3v18" />- </svg>- );-}+// ColumnIcon is shared with SchemaEditorLite; both surfaces must render+// identical icons so users don't see drift across editors.+export { ColumnIcon } from "@/react/components/schema/icons";diff --git a/frontend/src/react/components/ui/combobox.tsx b/frontend/src/react/components/ui/combobox.tsxindex 03eac9262a..9f4a7ed3fa 100644--- a/frontend/src/react/components/ui/combobox.tsx+++ b/frontend/src/react/components/ui/combobox.tsx@@ -65,6 +65,8 @@ type ComboboxBaseProps = {className?: string;disabled?: boolean;clearable?: boolean;+ /** Trigger size — matches the Input component's tier names. Defaults to `md`. */+ size?: "sm" | "md";/** Render dropdown via portal (use when inside overflow:hidden containers like modals) */portal?: boolean;};@@ -98,6 +100,7 @@ export function Combobox(props: ComboboxProps) {className,disabled,clearable = true,+ size = "md",portal,} = props;const multiple = props.multiple === true;@@ -424,7 +427,10 @@ export function Combobox(props: ComboboxProps) {// wrap below a too-narrow label on a narrow container, which// looks broken. Keep the trigger on a single line in that case// and let the label truncate inside `renderTrigger`.- "flex items-center gap-1 min-h-9 w-full rounded-xs border border-control-border bg-background px-3 py-1 text-sm leading-5 cursor-pointer",+ "flex items-center gap-1 w-full rounded-xs border border-control-border bg-background py-1 cursor-pointer",+ size === "sm"+ ? "min-h-7 px-2 text-xs leading-4"+ : "min-h-9 px-3 text-sm leading-5",multiple && "flex-wrap",disabled && "opacity-50 cursor-not-allowed",open && "border-accent"diff --git a/frontend/src/react/components/ui/segmented-control.tsx b/frontend/src/react/components/ui/segmented-control.tsxindex 76e05257d3..a287d7e193 100644--- a/frontend/src/react/components/ui/segmented-control.tsx+++ b/frontend/src/react/components/ui/segmented-control.tsx@@ -18,6 +18,8 @@ interface SegmentedControlProps<T extends string> {ariaLabel: string;disabled?: boolean;className?: string;+ /** Segment size — matches the Input/Combobox size tier names. Defaults to `md`. */+ size?: "sm" | "md";}export function SegmentedControl<T extends string>({@@ -27,7 +29,10 @@ export function SegmentedControl<T extends string>({ariaLabel,disabled = false,className,+ size = "md",}: SegmentedControlProps<T>) {+ const segmentSizeClasses =+ size === "sm" ? "min-h-7 px-2 text-xs" : "min-h-8 px-3 text-sm";return (<BaseRadioGroupvalue={value}@@ -50,7 +55,8 @@ export function SegmentedControl<T extends string>({<labelkey={option.value}className={cn(- "relative inline-flex min-h-8 items-center justify-center px-3 text-sm transition-colors focus-within:outline-hidden focus-within:ring-2 focus-within:ring-accent focus-within:ring-inset",+ "relative inline-flex items-center justify-center transition-colors focus-within:outline-hidden focus-within:ring-2 focus-within:ring-accent focus-within:ring-inset",+ segmentSizeClasses,index > 0 &&!previousSelected &&"border-l border-control-border",diff --git a/frontend/src/react/components/ui/sheet.tsx b/frontend/src/react/components/ui/sheet.tsxindex 0e2ae1102f..cded2c4760 100644--- a/frontend/src/react/components/ui/sheet.tsx+++ b/frontend/src/react/components/ui/sheet.tsx@@ -1,7 +1,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 type { ComponentProps, ReactNode } from "react";import { useTranslation } from "react-i18next";import { cn } from "@/react/lib/utils";import {@@ -68,6 +68,10 @@ const sheetContentVariants = cva(wide: "w-[52rem]",large: "w-[64rem]",xlarge: "w-[70rem]",+ // Maximized editor surfaces (e.g. plan-detail schema editor). Leaves+ // a ~5vw strip on the left as a visual anchor; clicking the strip+ // closes the sheet like any other scrim click.+ huge: "w-[95vw]",workspace: "w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)]",},},@@ -112,8 +116,15 @@ function SheetContent({// Sticky top region with a bottom border, laid out as a row so the built-in// close button sits on the right. Typically contains a `SheetTitle` and an// 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">) {+// vertical stack layout while the close button remains flush right. `actions`+// renders secondary icon-buttons (maximize, settings, etc.) immediately+// before the close button.+function SheetHeader({+ className,+ children,+ actions,+ ...props+}: ComponentProps<"div"> & { actions?: ReactNode }) {const { t } = useTranslation();return (@@ -125,6 +136,9 @@ function SheetHeader({ className, children, ...props }: ComponentProps<"div">) {{...props}><div className="flex flex-col gap-y-1 min-w-0 flex-1">{children}</div>+ {actions ? (+ <div className="flex items-center gap-x-1 shrink-0">{actions}</div>+ ) : null}{/* Built-in close affordance. Callers should not render their own closebutton — Base UI's Close dismisses the Sheet via Root's onOpenChange. */}<BaseDialog.Closediff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex 5ce10b6a27..d45c62d442 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -323,6 +323,7 @@"logout": "Logout","manage": "Manage","manually-select": "Manually select",+ "maximize": "Maximize","members_one": "Member","members_other": "Members","minutes": "Minutes",@@ -2008,6 +2009,7 @@"default": "Default","foreign-key": "Foreign Key","name": "Name",+ "name-placeholder": "Column name","not-null": "Not Null","on-update": "On Update","operations": "Operations",@@ -2055,6 +2057,7 @@"name-placeholder": "Schema name","select": "Select schema"},+ "select-object-hint": "Select a database object from the tree to edit","self": "Schema editor","table": {"duplicate-name": "Table name already exists",diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex 59965e62a7..2a29728dff 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -318,6 +318,7 @@"logout": "Cerrar sesión","manage": "Administrar","manually-select": "Manually select",+ "maximize": "Maximizar","members_one": "Miembro","members_other": "Miembros","minutes": "Minutos",@@ -1997,6 +1998,7 @@"default": "Default","foreign-key": "Clave foránea","name": "Name",+ "name-placeholder": "Nombre de la columna","not-null": "Not Null","on-update": "En actualización","operations": "Operations",@@ -2044,6 +2046,7 @@"name-placeholder": "Schema name","select": "Seleccionar esquema"},+ "select-object-hint": "Selecciona un objeto de base de datos del árbol para editarlo","self": "Editor de esquema","table": {"duplicate-name": "Table name already exists",diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex 87c5515a3a..36edf7761e 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -318,6 +318,7 @@"logout": "サインアウト","manage": "管理","manually-select": "Manually select",+ "maximize": "最大化","members_one": "メンバー","members_other": "メンバー","minutes": "分",@@ -1997,6 +1998,7 @@"default": "Default","foreign-key": "外部キー","name": "Name",+ "name-placeholder": "カラム名","not-null": "Not Null","on-update": "アップデート時","operations": "Operations",@@ -2044,6 +2046,7 @@"name-placeholder": "Schema name","select": "スキーマの選択"},+ "select-object-hint": "編集するデータベースオブジェクトをツリーから選択してください","self": "スキーマエディタ","table": {"duplicate-name": "Table name already exists",diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 2fe92a7b9e..107ca9f2de 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -318,6 +318,7 @@"logout": "Đăng xuất","manage": "Quản lý","manually-select": "Manually select",+ "maximize": "Phóng to","members_one": "Thành viên","members_other": "Thành viên","minutes": "Phút",@@ -1997,6 +1998,7 @@"default": "Default","foreign-key": "Khóa ngoại","name": "Name",+ "name-placeholder": "Tên cột","not-null": "Not Null","on-update": "Khi cập nhật","operations": "Operations",@@ -2044,6 +2046,7 @@"name-placeholder": "Schema name","select": "Chọn lược đồ"},+ "select-object-hint": "Chọn một đối tượng cơ sở dữ liệu từ cây để chỉnh sửa","self": "Trình chỉnh sửa lược đồ","table": {"duplicate-name": "Table name already exists",diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex 04027e9e5d..80e7ffd899 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -318,6 +318,7 @@"logout": "登出","manage": "管理","manually-select": "Manually select",+ "maximize": "最大化","members_one": "成员","members_other": "成员","minutes": "分钟",@@ -1997,6 +1998,7 @@"default": "Default","foreign-key": "外键","name": "Name",+ "name-placeholder": "列名","not-null": "Not Null","on-update": "更新时","operations": "Operations",@@ -2044,6 +2046,7 @@"name-placeholder": "Schema name","select": "选择 schema"},+ "select-object-hint": "从左侧树中选择一个数据库对象进行编辑","self": "Schema 编辑器","table": {"duplicate-name": "Table name already exists",diff --git a/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx b/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsxindex 2b0c8fae25..034723ccf3 100644--- a/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx+++ b/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx@@ -1,5 +1,5 @@import { cloneDeep } from "lodash-es";-import { Loader2 } from "lucide-react";+import { Loader2, Maximize2, Minimize2, X } from "lucide-react";import { useCallback, useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { SchemaEditorLite } from "@/react/components/SchemaEditorLite";@@ -10,9 +10,9 @@ import { Button } from "@/react/components/ui/button";import { Combobox } from "@/react/components/ui/combobox";import {Sheet,+ SheetClose,SheetContent,SheetFooter,- SheetHeader,SheetTitle,} from "@/react/components/ui/sheet";import { useVueState } from "@/react/hooks/useVueState";@@ -41,19 +41,30 @@ export function SchemaEditorSheet({project,onInsert,}: Props) {- const { t } = useTranslation();+ // Resets on each open: every close path routes through handleOpenChange,+ // which clears the flag, so reopening always starts un-maximized.+ const [maximized, setMaximized] = useState(false);+ const handleOpenChange = useCallback(+ (next: boolean) => {+ if (!next) setMaximized(false);+ onOpenChange(next);+ },+ [onOpenChange]+ );return (- <Sheet open={open} onOpenChange={onOpenChange}>- <SheetContent width="xlarge" className="flex flex-col">- <SheetHeader>- <SheetTitle>{t("schema-editor.self")}</SheetTitle>- </SheetHeader>+ <Sheet open={open} onOpenChange={handleOpenChange}>+ <SheetContent+ width={maximized ? "huge" : "xlarge"}+ className="flex flex-col"+ >{open && (<SchemaEditorSheetBodydatabaseNames={databaseNames}project={project}onInsert={onInsert}- onCancel={() => onOpenChange(false)}+ onCancel={() => handleOpenChange(false)}+ maximized={maximized}+ onMaximizedChange={setMaximized}/>)}</SheetContent>@@ -66,6 +77,8 @@ interface BodyProps {project: Project;onInsert: (sql: string) => void;onCancel: () => void;+ maximized: boolean;+ onMaximizedChange: (next: boolean) => void;}function SchemaEditorSheetBody({@@ -73,6 +86,8 @@ function SchemaEditorSheetBody({project,onInsert,onCancel,+ maximized,+ onMaximizedChange,}: BodyProps) {const { t } = useTranslation();const dbSchemaStore = useDBSchemaV1Store();@@ -207,12 +222,21 @@ function SchemaEditorSheetBody({}}, [targets, onInsert, onCancel, t]);+ const MaximizeIcon = maximized ? Minimize2 : Maximize2;+ const maximizeLabel = maximized ? t("common.restore") : t("common.maximize");+return (<>- <div className="flex flex-1 flex-col gap-y-3 overflow-hidden px-4 pb-2">+ {/* Compact single-row toolbar — title, template-database picker, and+ window controls share one line so the editor below gets back the+ ~50px we used to spend on a separate combobox row. */}+ <div className="flex items-center gap-x-3 border-b border-control-border px-4 py-2">+ <SheetTitle className="text-base font-semibold">+ {t("schema-editor.self")}+ </SheetTitle>{databaseNames.length > 1 && (- <div className="flex items-center gap-x-2">- <span className="text-sm text-control-light">+ <div className="flex min-w-0 items-center gap-x-2">+ <span className="shrink-0 text-xs text-control-light">{t("schema-editor.template-database")}:</span><Combobox@@ -221,20 +245,38 @@ function SchemaEditorSheetBody({options={databaseOptions}disabled={isPreparingMetadata}clearable={false}- className="w-80"+ size="sm"+ className="w-56"portal/></div>)}- <div className="relative flex-1 overflow-hidden">- <SchemaEditorLite- ref={schemaEditorRef}- project={project}- targets={targets}- loading={isPreparingMetadata}- />+ <div className="ml-auto flex items-center gap-x-1">+ <button+ type="button"+ aria-label={maximizeLabel}+ title={maximizeLabel}+ onClick={() => onMaximizedChange(!maximized)}+ className="shrink-0 cursor-pointer rounded-xs p-1 text-control hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent"+ >+ <MaximizeIcon className="size-4" />+ </button>+ <SheetClose+ aria-label={t("common.close")}+ className="shrink-0 cursor-pointer rounded-xs p-1 text-control hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent"+ >+ <X className="size-4" />+ </SheetClose></div></div>+ <div className="relative flex-1 overflow-hidden px-4 pt-2 pb-2">+ <SchemaEditorLite+ ref={schemaEditorRef}+ project={project}+ targets={targets}+ loading={isPreparingMetadata}+ />+ </div><SheetFooter><div className="flex w-full items-center justify-end gap-x-2"><Button variant="outline" onClick={onCancel}>