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: sql editor ux issues (#20303)
ecmadao43711e83cc24
diff --git a/frontend/src/react/components/AdvancedSearch.tsx b/frontend/src/react/components/AdvancedSearch.tsxindex c78d3be0df..ed8cdeca8a 100644--- a/frontend/src/react/components/AdvancedSearch.tsx+++ b/frontend/src/react/components/AdvancedSearch.tsx@@ -636,7 +636,18 @@ export function AdvancedSearch({className="flex min-w-0 items-center h-9 overflow-hidden border border-control-border rounded-xs bg-background transition-colors"onClick={() => inputRef.current?.focus()}>- <div className="flex min-w-0 max-w-[60%] items-center shrink">+ {/*+ * No hard `max-w-[60%]` here on purpose. The tags container is a+ * flex item with `shrink` and the input sibling already declares+ * `min-w-[120px] flex-1`, so flexbox guarantees the input keeps+ * its minimum typing width and the tags only have to shrink (and+ * scroll horizontally) when their natural size truly exceeds+ * what's left. A 60% cap forced the tags to clip even when the+ * bar had plenty of unused space on the right — visible in the+ * AccessPane where two short scope tags read as "status: 开启+ * × stat…".+ */}+ <div className="flex min-w-0 items-center shrink"><div className="shrink-0 pl-2"><Filter className="h-4 w-4 text-control-placeholder" /></div>@@ -695,10 +706,24 @@ export function AdvancedSearch({</div></div>- {/* Input */}+ {/*+ * Input min-width is conditional on whether any tags are+ * present:+ * - No tags: reserve 120px so the placeholder text is fully+ * legible.+ * - Has tags: the placeholder is hidden anyway (see below),+ * so we only need room for the cursor — 40px. Without this+ * the previous fixed `min-w-[120px]` forced the tags+ * container to shrink even when the bar had visible empty+ * space, which is what made scope tags clip in panels like+ * AccessPane.+ */}<inputref={inputRef}- className="min-w-[120px] flex-1 bg-transparent border-none px-2 text-sm text-main placeholder:text-control-placeholder focus:outline-none focus:border-none focus:ring-0 focus:shadow-none"+ className={cn(+ "flex-1 bg-transparent border-none px-2 text-sm text-main placeholder:text-control-placeholder focus:outline-none focus:border-none focus:ring-0 focus:shadow-none",+ visibleTags.length > 0 ? "min-w-[40px]" : "min-w-[120px]"+ )}value={inputText}placeholder={visibleTags.length > 0 ? "" : placeholder}onClick={handleInputClick}diff --git a/frontend/src/react/components/SchemaDiagram/Navigator/Navigator.tsx b/frontend/src/react/components/SchemaDiagram/Navigator/Navigator.tsxindex d9c1cbc3a2..c518e14065 100644--- a/frontend/src/react/components/SchemaDiagram/Navigator/Navigator.tsx+++ b/frontend/src/react/components/SchemaDiagram/Navigator/Navigator.tsx@@ -1,5 +1,5 @@import { ChevronLeft } from "lucide-react";-import { useMemo, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { PanelSearchBox } from "@/react/components/sql-editor/Panels/common/PanelSearchBox";import { cn } from "@/react/lib/utils";import { getInstanceResource, hasSchemaProperty } from "@/utils";@@ -8,16 +8,22 @@ import { SchemaSelector } from "./SchemaSelector";import { NavigatorTree } from "./Tree";interface NavigatorProps {- /** Override the tree's default height. */+ /**+ * Optional explicit override for the virtualized tree height. Leave+ * unset to let the tree fill the available vertical space inside the+ * Navigator panel.+ */treeHeight?: number;}+const FALLBACK_TREE_HEIGHT = 480;+/*** React port of `Navigator/Navigator.vue`. Collapsible left sidebar* holding the schema selector (Postgres-style multi-schema only), a* search input, and the schema → table tree.*/-export function Navigator({ treeHeight = 480 }: NavigatorProps) {+export function Navigator({ treeHeight }: NavigatorProps) {const ctx = useSchemaDiagramContext();const {databaseMetadata,@@ -34,6 +40,27 @@ export function Navigator({ treeHeight = 480 }: NavigatorProps) {[database]);+ // react-arborist needs a numeric height for virtualization. Measure+ // the tree's flex container so the list fills the panel rather than+ // sitting at a hardcoded 480px (which leaves empty space on tall+ // viewports and clips on short ones).+ const treeContainerRef = useRef<HTMLDivElement | null>(null);+ const [measuredHeight, setMeasuredHeight] = useState<number | null>(null);+ useEffect(() => {+ if (!expanded) return;+ const el = treeContainerRef.current;+ if (!el) return;+ const observer = new ResizeObserver((entries) => {+ const entry = entries[0];+ if (entry) setMeasuredHeight(entry.contentRect.height);+ });+ observer.observe(el);+ return () => observer.disconnect();+ }, [expanded]);++ const effectiveTreeHeight =+ treeHeight ?? measuredHeight ?? FALLBACK_TREE_HEIGHT;+return (<div className="relative h-full"><div@@ -56,23 +83,43 @@ export function Navigator({ treeHeight = 480 }: NavigatorProps) {className="max-w-none"/></div>- <div className="w-full flex-1 overflow-x-hidden overflow-y-auto p-1 pr-2">- <NavigatorTree keyword={keyword} height={treeHeight} />+ <div+ ref={treeContainerRef}+ className="w-full flex-1 overflow-x-hidden overflow-y-auto p-1 px-3 min-h-0"+ >+ <NavigatorTree keyword={keyword} height={effectiveTreeHeight} /></div></div>+ {/*+ * The toggle is absolutely positioned and visually crosses the+ * boundary between the Navigator and the Canvas. Two stacking+ * pitfalls to keep in mind:+ * - `Canvas` is the next flex sibling of `Navigator` inside a+ * `SchemaDiagram` parent with `overflow-hidden`, so without+ * `z-10` the half of the button that overhangs into Canvas+ * gets painted UNDER Canvas (auto z-index + later-DOM-order+ * wins for siblings in the same stacking context). The+ * button effectively disappeared into the canvas.+ * - When collapsed, Navigator's width is 0 so `-left-3` placed+ * the button at x = -12..+12 relative to the parent's left+ * edge — the left half got clipped by `overflow-hidden` and+ * the right 12px was covered by Canvas, leaving the user no+ * way to re-open. Anchoring the collapsed button at `left-1`+ * keeps the whole 24px visible inside Canvas, on top.+ */}<buttontype="button"onClick={() => setExpanded((prev) => !prev)}className={cn(- "absolute rounded-full shadow-lg w-6 h-6 top-16 flex items-center justify-center bg-background hover:bg-control-bg cursor-pointer transition-all",- expanded ? "left-full -translate-x-3" : "-left-3"+ "absolute z-10 rounded-full shadow-lg w-6 h-6 top-16 flex items-center justify-center bg-background hover:bg-control-bg cursor-pointer transition-all",+ expanded ? "left-full -translate-x-3" : "left-1")}><ChevronLeftclassName={cn("size-4 transition-transform",- !expanded && "-scale-100 translate-x-[3px]"+ !expanded && "-scale-100")}/></button>diff --git a/frontend/src/react/components/header/HeaderBreadcrumb.tsx b/frontend/src/react/components/header/HeaderBreadcrumb.tsxindex e6154a4515..6efb39bd61 100644--- a/frontend/src/react/components/header/HeaderBreadcrumb.tsx+++ b/frontend/src/react/components/header/HeaderBreadcrumb.tsx@@ -24,7 +24,6 @@ import {useNavigate,WORKSPACE_ROUTE_LANDING,} from "@/react/router";-import { useAppStore } from "@/react/stores/app";import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";import { ProjectCreateDialog } from "./ProjectCreateDialog";import { ProjectSwitchPanel } from "./ProjectSwitchPanel";@@ -63,7 +62,6 @@ function planVariant(// ---------------------------------------------------------------------------function WorkspaceSegment() {const { t } = useTranslation();- const isSaaSMode = useAppStore((state) => state.isSaaSMode());const workspace = useWorkspace();const workspaceList = useWorkspaceList();const currentWorkspaceName = workspace?.name ?? "";@@ -73,12 +71,6 @@ function WorkspaceSegment() {const hasMultiple = workspaceList.length > 1;const switchWorkspace = useSwitchWorkspace();const navigate = useNavigate();-- // Self-host has a single workspace — no need to show the workspace segment.- if (!isSaaSMode) {- return null;- }-const [open, setOpen] = useState(false);const onSwitch = useCallback(@@ -229,11 +221,10 @@ function ProjectSegment({ showSeparator }: { showSeparator: boolean }) {// HeaderBreadcrumb — the assembled breadcrumb bar// ---------------------------------------------------------------------------export function HeaderBreadcrumb() {- const isSaaSMode = useAppStore((state) => state.isSaaSMode());return (<div className="flex items-center gap-x-1"><WorkspaceSegment />- <ProjectSegment showSeparator={isSaaSMode} />+ <ProjectSegment showSeparator /></div>);}diff --git a/frontend/src/react/components/sql-editor/AccessGrantItem.tsx b/frontend/src/react/components/sql-editor/AccessGrantItem.tsxindex 84ef2d8330..6b0524bd12 100644--- a/frontend/src/react/components/sql-editor/AccessGrantItem.tsx+++ b/frontend/src/react/components/sql-editor/AccessGrantItem.tsx@@ -93,8 +93,19 @@ export function AccessGrantItem({: "transition-colors duration-1000")}>- <div className="w-full flex flex-row justify-between items-center gap-x-2">- <div className="flex items-center gap-x-1">+ {/*+ * `flex-wrap` + `justify-between` keeps the original "badges left,+ * expiration right" layout when both fit on the row, but lets the+ * row wrap when the panel is narrow. Pairing it with `shrink-0`+ * on the badges container preserves each pill at its natural size+ * so the label never wraps inside the pill (`脱敏豁免` → "脱敏豁+ * \n免"). When the expiration wraps to a second row it falls back+ * to the row's start alignment (justify-between has no effect on+ * a single-item row), so it reads naturally left-to-right under+ * the badges instead of being stranded on the right.+ */}+ <div className="w-full flex flex-wrap items-center justify-between gap-x-2 gap-y-1">+ <div className="flex items-center gap-x-1 shrink-0"><Badgevariant={badgeVariant}className="text-[10px] px-1.5 py-0 rounded-full"@@ -111,7 +122,7 @@ export function AccessGrantItem({)}</div>{expirationText && (- <span className="text-xs text-control-placeholder shrink-0 truncate">+ <span className="text-xs text-control-placeholder shrink-0">{expirationText}</span>)}diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsxindex 4e3c78fbf1..965ceef415 100644--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx@@ -145,7 +145,7 @@ function AccessGrantRequestDrawerInner({const durationOptions = useMemo(() => [- { value: "1", label: t("sql-editor.duration-hours", { hours: 1 }) },+ { value: "1", label: t("sql-editor.duration-hour", { hours: 1 }) },{ value: "4", label: t("sql-editor.duration-hours", { hours: 4 }) },{ value: "24", label: t("sql-editor.duration-day", { days: 1 }) },{ value: "168", label: t("sql-editor.duration-days", { days: 7 }) },diff --git a/frontend/src/react/components/sql-editor/AccessPane.tsx b/frontend/src/react/components/sql-editor/AccessPane.tsxindex 34bf4e3195..51cbf47c43 100644--- a/frontend/src/react/components/sql-editor/AccessPane.tsx+++ b/frontend/src/react/components/sql-editor/AccessPane.tsx@@ -290,7 +290,7 @@ export function AccessPane() {>{({ disabled }) => (<Button- variant="outline"+ variant="default"size="sm"style={{ width: useSmallLayout ? "100%" : "auto" }}disabled={!hasJITFeature || disabled}diff --git a/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.tsx b/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.tsxindex bd7ad3a030..96698262d3 100644--- a/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.tsx+++ b/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.tsx@@ -582,7 +582,14 @@ function ConnectionPaneInner({ show, onMissingFeature }: Props) {</TabsTrigger></TabsList>- <TabsPanel value="DATABASE">+ {/*+ `keepMounted` keeps the inactive Tabs.Panel attached to the DOM+ instead of unmounting it. Without this, switching to the+ "Database Group" tab unmounts `EnvironmentTreeSection`s and+ tabbing back remounts them — which re-runs their mount-effect+ and fires fresh `listDatabases` RPCs every time.+ */}+ <TabsPanel value="DATABASE" keepMounted><div className="flex flex-col gap-y-1"><AdvancedSearchparams={searchParams}@@ -628,18 +635,29 @@ function ConnectionPaneInner({ show, onMissingFeature }: Props) {</div></TabsPanel>- <TabsPanel value="DATABASE-GROUP">- <DatabaseGroupTable- projectName={projectName}- view={DatabaseGroupView.FULL}- leadingLabel={t("database-group.select")}- showSelection- showExternalLink- selectedDatabaseGroupNames={selectedDatabaseGroupNames}- onSelectedDatabaseGroupNamesChange={handleSelectedGroupsChange}- onRowClick={(_, group) => handleSelectDatabaseGroup(group.name)}- />- </TabsPanel>+ {/*+ Only mount the DATABASE-GROUP panel when the user's plan+ actually allows the tab. The trigger above is `disabled` for+ plans missing either feature flag, but `keepMounted` on the+ panel would otherwise still mount `DatabaseGroupTable`, whose+ mount effect fires `fetchDBGroupListByProjectName` — wasted+ API traffic on every ConnectionPane open and a chance to+ surface 403s for an inaccessible UI path.+ */}+ {hasBatchQueryFeature && hasDatabaseGroupFeature && (+ <TabsPanel value="DATABASE-GROUP" keepMounted>+ <DatabaseGroupTable+ projectName={projectName}+ view={DatabaseGroupView.FULL}+ leadingLabel={t("database-group.select")}+ showSelection+ showExternalLink+ selectedDatabaseGroupNames={selectedDatabaseGroupNames}+ onSelectedDatabaseGroupNamesChange={handleSelectedGroupsChange}+ onRowClick={(_, group) => handleSelectDatabaseGroup(group.name)}+ />+ </TabsPanel>+ )}</Tabs><ConnectionContextMenu ref={contextMenuRef} />@@ -951,9 +969,14 @@ function EnvironmentTreeSection(props: {isDatabase && groupCoveredDatabaseTitles.has(databaseName)? groupCoveredDatabaseTitles.get(databaseName): undefined;- const checked =- isDatabase &&- (selectedSet.has(databaseName) || matchedGroupTitle !== undefined);+ // Distinguish "user explicitly selected this row" from+ // "implicitly included because the row belongs to a selected+ // group". Only the explicit case should tint the row blue —+ // group-implied entries are locked-on and need to read as+ // disabled, not as an active user choice.+ const userSelected = isDatabase && selectedSet.has(databaseName);+ const groupImplied = matchedGroupTitle !== undefined;+ const checkDisabled = switchingConnection || groupImplied;return (<TreeRowstyle={style}@@ -962,10 +985,9 @@ function EnvironmentTreeSection(props: {isOpen={!!node.isOpen}hasChildren={!!data.children && data.children.length > 0}query={query}- selected={checked}- checkDisabled={- switchingConnection || matchedGroupTitle !== undefined- }+ rowTinted={userSelected}+ checkboxChecked={userSelected || groupImplied}+ checkDisabled={checkDisabled}checkTooltip={matchedGroupTitle !== undefined ? matchedGroupTitle : undefined}@@ -978,6 +1000,10 @@ function EnvironmentTreeSection(props: {}}}onToggleChecked={(next) => {+ // Belt-and-suspenders: even if BaseUI Checkbox somehow+ // fires `onCheckedChange` while disabled, drop the+ // toggle so a group-implied row can't be unchecked.+ if (checkDisabled) return;if (isDatabase) {onToggleDatabase(databaseName, next);}@@ -1009,7 +1035,8 @@ function TreeRow({isOpen,hasChildren,query,- selected,+ rowTinted,+ checkboxChecked,checkDisabled,checkTooltip,onClick,@@ -1024,9 +1051,13 @@ function TreeRow({hasChildren: boolean;depth: number;query: string;- /** Whether the row is "checked" (batch-query selection or implicit- * via group). Doubles as the row tint condition. */- selected: boolean;+ /** Whether the row should render the active-selection tint. Only set+ * when the user explicitly selected the row — NOT for group-implied+ * membership, which should read as locked-on (gray) not active. */+ rowTinted: boolean;+ /** Whether the inline batch-mode checkbox renders as checked. True for+ * user-explicit selection AND for group-implied membership. */+ checkboxChecked: boolean;/** True when the checkbox should be locked, e.g. mid-connection-switch* or when membership is forced by a selected group. */checkDisabled: boolean;@@ -1072,7 +1103,7 @@ function TreeRow({className={cn("bb-conn-pane-row flex items-center gap-x-1 w-full pr-2 cursor-pointer rounded-sm","hover:bg-control-bg/70",- selected && "bg-accent/10"+ rowTinted && "bg-accent/10")}data-node-key={node.key}onMouseDown={(e) => {@@ -1128,7 +1159,7 @@ function TreeRow({<Labelnode={node}keyword={query}- checked={selected}+ checked={checkboxChecked}checkDisabled={checkDisabled}checkTooltip={checkTooltip}onCheckedChange={onToggleChecked}diff --git a/frontend/src/react/components/sql-editor/ResultPanel/ResultPanel.tsx b/frontend/src/react/components/sql-editor/ResultPanel/ResultPanel.tsxindex ef0340f84f..b6f9123fb0 100644--- a/frontend/src/react/components/sql-editor/ResultPanel/ResultPanel.tsx+++ b/frontend/src/react/components/sql-editor/ResultPanel/ResultPanel.tsx@@ -189,31 +189,38 @@ export function ResultPanel() {isBatchQuery ? "pt-0" : "pt-2")}>- <TabsList className="shrink-0 gap-x-1 border-b border-control-border">+ <TabsList className="shrink-0 gap-x-1 border-b border-control-border overflow-x-auto overflow-y-hidden">{queryContexts.map((context) => (- <TabContextMenu- key={context.id}- onSelect={(action) => {- switch (action) {- case "CLOSE":- closeTab(context.id);- break;- case "CLOSE_OTHERS":- closeOthers(context.id);- break;- case "CLOSE_TO_THE_RIGHT":- closeToTheRight(context.id);- break;- case "CLOSE_ALL":- closeAll();- break;- }- }}- >- <Tooltip content={context.params.statement}>+ // Order matters: `Tooltip` MUST wrap `TabContextMenu`, not the+ // other way around. `ContextMenuTrigger` uses Base UI's+ // `render` prop, which clones the given element and attaches+ // `onContextMenu` / `ref` to it — that only works when the+ // rendered element forwards unknown props onto its DOM+ // (`TabsTrigger` does, our `Tooltip` wrapper doesn't). With+ // Tooltip on the outside, the trigger renders `TabsTrigger`+ // directly and the right-click handler reaches the DOM.+ <Tooltip key={context.id} content={context.params.statement}>+ <TabContextMenu+ onSelect={(action) => {+ switch (action) {+ case "CLOSE":+ closeTab(context.id);+ break;+ case "CLOSE_OTHERS":+ closeOthers(context.id);+ break;+ case "CLOSE_TO_THE_RIGHT":+ closeToTheRight(context.id);+ break;+ case "CLOSE_ALL":+ closeAll();+ break;+ }+ }}+ ><TabsTriggervalue={context.id}- className="flex items-center gap-x-2 px-3 py-1"+ className="flex items-center gap-x-2 px-3 py-1 shrink-0"><span className="truncate">{tabName(context)}</span>{context.resultSet?.error && (@@ -232,8 +239,8 @@ export function ResultPanel() {/>)}</TabsTrigger>- </Tooltip>- </TabContextMenu>+ </TabContextMenu>+ </Tooltip>))}</TabsList>{queryContexts.map((context, i) => (diff --git a/frontend/src/react/components/sql-editor/ResultView/SelectionCopyTooltips.tsx b/frontend/src/react/components/sql-editor/ResultView/SelectionCopyTooltips.tsxindex 3003c2eed4..08215f8980 100644--- a/frontend/src/react/components/sql-editor/ResultView/SelectionCopyTooltips.tsx+++ b/frontend/src/react/components/sql-editor/ResultView/SelectionCopyTooltips.tsx@@ -1,8 +1,30 @@import { CopyIcon, InfoIcon } from "lucide-react";-import { Trans, useTranslation } from "react-i18next";+import { useTranslation } from "react-i18next";import { Button } from "@/react/components/ui/button";import { useSelectionContext } from "./context";+// react-i18next's `Trans` wipes children when placeholder tags are empty+// (`<action></action>` calls `React.cloneElement(component, {}, ...[])`,+// which replaces the original children with nothing). The Vue `i18n-t`+// preserved slot content; react-i18next doesn't. We split the localized+// template manually at the placeholder positions so the React Buttons+// keep their own children.+function splitTemplate(template: string) {+ const tokens: Array<string | "action" | "button"> = [];+ const regex = /<action><\/action>|<button><\/button>/g;+ let lastIndex = 0;+ let match: RegExpExecArray | null;+ while ((match = regex.exec(template)) !== null) {+ if (match.index > lastIndex) {+ tokens.push(template.slice(lastIndex, match.index));+ }+ tokens.push(match[0] === "<action></action>" ? "action" : "button");+ lastIndex = regex.lastIndex;+ }+ if (lastIndex < template.length) tokens.push(template.slice(lastIndex));+ return tokens;+}+export function SelectionCopyTooltips() {const { t } = useTranslation();const {@@ -14,6 +36,7 @@ export function SelectionCopyTooltips() {if (rows.length === 0 && columns.length === 0) return null;const isMac = /mac/i.test(navigator.platform);+ const tokens = splitTemplate(t("sql-editor.copy-selected-results"));return (<div@@ -25,11 +48,11 @@ export function SelectionCopyTooltips() {><InfoIcon size={16} className="mr-2 text-control" /><p className="text-sm flex flex-row justify-start items-center gap-1">- <Trans- i18nKey="sql-editor.copy-selected-results"- components={{- action: (+ {tokens.map((token, i) => {+ if (token === "action") {+ return (<Button+ key={i}size="sm"variant="outline"className="h-6 px-2 gap-x-1"@@ -44,9 +67,12 @@ export function SelectionCopyTooltips() {)}C</Button>- ),- button: (+ );+ }+ if (token === "button") {+ return (<Button+ key={i}size="sm"variant="default"className="h-6 px-2 gap-x-1"@@ -55,9 +81,10 @@ export function SelectionCopyTooltips() {<CopyIcon className="size-3" />{t("common.copy")}</Button>- ),- }}- />+ );+ }+ return <span key={i}>{token}</span>;+ })}</p><div className="ml-1"><Button size="sm" variant="ghost" onClick={deselect}>diff --git a/frontend/src/react/components/sql-editor/ResultView/TableCell.tsx b/frontend/src/react/components/sql-editor/ResultView/TableCell.tsxindex ae61d55c84..1cee0d9b5b 100644--- a/frontend/src/react/components/sql-editor/ResultView/TableCell.tsx+++ b/frontend/src/react/components/sql-editor/ResultView/TableCell.tsx@@ -133,7 +133,7 @@ export function TableCell({onClick={handleClick}onDoubleClick={showDetail}className={cn(- "px-2 py-1 flex items-center",+ "w-full h-full px-2 py-1 flex items-center",allowSelect ? "cursor-pointer hover:bg-accent/10" : "select-none",selected && "bg-accent/20!")}diff --git a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsxindex 83b6ddf9d4..9e8e7f8199 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.tsx@@ -187,18 +187,18 @@ function SchemaPaneInner() {return () => cancelAnimationFrame(raf);}, [isFetching, metadata, totalTableCount, database, tabStore]);- // Reactive proxy for `tab.treeState.keys`. Reads via useVueState +- // deep watch (Pinia mutates in place); writes go through a thin- // setter so the store mutation triggers the watch.- const expandedKeys = useVueState<string[]>(- () => {- const tab = tabStore.currentTab;- if (!tab) return [];- if (tab.treeState.database !== database.name) return [];- return tab.treeState.keys ?? [];- },- { deep: true }- );+ // Reactive proxy for `tab.treeState.keys`. Writes via `setExpandedKeys`+ // always REPLACE the whole array (`tab.treeState.keys = keys`), so a+ // shallow watch on the getter is enough — the getter's read of+ // `tab.treeState.keys` registers as a dep, and array replacement+ // triggers the watch. Deep traversal over an array of plain strings+ // would just add per-element overhead with no extra reactivity.+ const expandedKeys = useVueState<string[]>(() => {+ const tab = tabStore.currentTab;+ if (!tab) return [];+ if (tab.treeState.database !== database.name) return [];+ return tab.treeState.keys ?? [];+ });const setExpandedKeys = useCallback((keys: string[]) => {@@ -279,7 +279,6 @@ function SchemaPaneInner() {}, [tree, expandedKeySet, searchKeyword]);// ---- Click discriminator (single vs double) ------------------------------ const { events: clickEvents, handleClick } = useClickEvents();const { selectAllFromTableOrView } = useSchemaActionsForClick();const toggleNode = useCallback(@@ -293,10 +292,8 @@ function SchemaPaneInner() {[expandedKeys, removeExpandedKeys, upsertExpandedKeys]);- useEffect(() => {- const offSingle = clickEvents.on("single-click", ({ node }) => {- // Toggle expand for non-leaf rows. For schema, also push the- // selected schema into the tab's connection.+ const { handleClick } = useClickEvents({+ onSingleClick: (node) => {if (node.meta.type === "schema") {const tab = tabStore.currentTab;if (tab) {@@ -306,24 +303,19 @@ function SchemaPaneInner() {}}toggleNode(node);- });- const offDouble = clickEvents.on("double-click", ({ node }) => {+ },+ onDoubleClick: (node) => {const type = node.meta.type;if (type === "table" || type === "view") {void selectAllFromTableOrView(node);- } else if (type === "schema" || type === "expandable-text") {- toggleNode(node);} else {- // Leaf nodes: mirror single-click toggle behavior so the tree- // state matches what the user expects after a fast double-tap.+ // schema / expandable-text / leaf nodes: mirror single-click+ // toggle behavior so the tree state matches what the user+ // expects after a fast double-tap.toggleNode(node);}- });- return () => {- offSingle();- offDouble();- };- }, [clickEvents, selectAllFromTableOrView, tabStore, toggleNode]);+ },+ });// ---- Context menu (right-click) -----------------------------------------const contextMenuRef = useRef<SchemaContextMenuHandle>(null);diff --git a/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/ColumnNode.tsx b/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/ColumnNode.tsxindex 97e8d8eabb..6114e11c40 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/ColumnNode.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/TreeNode/ColumnNode.tsx@@ -1,5 +1,6 @@-import { useVueState } from "@/react/hooks/useVueState";+import { useMemo } from "react";import { useDBSchemaV1Store } from "@/store";+import type { ColumnMetadata } from "@/types/proto-es/v1/database_service_pb";import type { TreeNode } from "../schemaTree";import { CommonNode } from "./CommonNode";import { ColumnIcon, IndexIcon, PrimaryKeyIcon } from "./icons";@@ -9,6 +10,26 @@ type Props = {readonly keyword: string;};+// Per-table caches: each entry is a `Map<columnName, ColumnMetadata>` keyed+// by the table-like metadata object that owns the columns. Two reasons for+// the WeakMap-of-Maps pattern:+// 1. The previous implementation did `tableMetadata.columns.find(...)`+// from every ColumnNode, which is O(columns-per-table) per row. For a+// 200-column table with ~30 virtualized rows, that's 6,000 reactive+// proxy reads per expand — and every read goes through Vue's tracker+// because the metadata is a Pinia/Vue reactive proxy.+// 2. WeakMap keys (the parent metadata reference) drop their cache entry+// automatically when the metadata refreshes — no manual invalidation.+const tableColumnIndex = new WeakMap<object, Map<string, ColumnMetadata>>();+function findColumn(parent: { columns: ColumnMetadata[] }, name: string) {+ let map = tableColumnIndex.get(parent);+ if (!map) {+ map = new Map(parent.columns.map((c) => [c.name, c]));+ tableColumnIndex.set(parent, map);+ }+ return map.get(name);+}+/*** Replaces `TreeNode/ColumnNode.vue`. The icon and trailing type-tag both* depend on the column's resolved metadata:@@ -18,51 +39,58 @@ type Props = {* - The trailing type-tag (`int`, `varchar(255)`, …) is rendered when* the metadata fetch has resolved.*- * Reads from `dbSchemaStore.getTableMetadata` / `getSchemaMetadata`- * through `useVueState` so cache hydration triggers a re-render.+ * Lookups use `useMemo` (not `useVueState`). The schema tree is rebuilt+ * by `SchemaPane` whenever the database metadata changes, which produces+ * fresh `target` objects and remounts these rows with current metadata —+ * a Vue watch per ColumnNode is unnecessary subscription overhead, and+ * `flush: "sync"` watch setup was the dominant cost of expanding a+ * Columns folder with hundreds of children.*/export function ColumnNode({ node, keyword }: Props) {const dbSchema = useDBSchemaV1Store();const target = (node as TreeNode<"column">).meta.target;- const tableMetadata = useVueState(() => {+ const tableMetadata = useMemo(() => {if ("table" in target) {const { database, schema, table } = target;return dbSchema.getTableMetadata({ database, schema, table });}return undefined;- });+ }, [target, dbSchema]);- const columnMetadata = useVueState(() => {+ const columnMetadata = useMemo(() => {const { database, schema, column } = target;- const schemaMetadata = dbSchema.getSchemaMetadata({ database, schema });-- if ("table" in target) {- return tableMetadata?.columns.find((c) => c.name === column);- } else if ("externalTable" in target) {- return schemaMetadata?.externalTables- .find((t) => t.name === target.externalTable)- ?.columns.find((c) => c.name === column);- } else if ("view" in target) {- return schemaMetadata?.views- .find((v) => v.name === target.view)- ?.columns.find((c) => c.name === column);+ if ("table" in target && tableMetadata) {+ return findColumn(tableMetadata, column);+ }+ if ("externalTable" in target) {+ const schemaMetadata = dbSchema.getSchemaMetadata({ database, schema });+ const ext = schemaMetadata?.externalTables.find(+ (t) => t.name === target.externalTable+ );+ return ext ? findColumn(ext, column) : undefined;+ }+ if ("view" in target) {+ const schemaMetadata = dbSchema.getSchemaMetadata({ database, schema });+ const view = schemaMetadata?.views.find((v) => v.name === target.view);+ return view ? findColumn(view, column) : undefined;}return undefined;- });+ }, [target, tableMetadata, dbSchema]);- let isPrimaryKey = false;- let isIndex = false;- if ("table" in target) {- const { column } = target;- const pk = tableMetadata?.indexes.find((idx) => idx.primary);- isPrimaryKey = pk ? pk.expressions.includes(column) : false;- if (!isPrimaryKey) {- isIndex = !!tableMetadata?.indexes.some((idx) =>- idx.expressions.includes(column)- );+ const { isPrimaryKey, isIndex } = useMemo(() => {+ if (!("table" in target) || !tableMetadata) {+ return { isPrimaryKey: false, isIndex: false };}- }+ const { column } = target;+ const pk = tableMetadata.indexes.find((idx) => idx.primary);+ const inPk = pk ? pk.expressions.includes(column) : false;+ if (inPk) return { isPrimaryKey: true, isIndex: false };+ const inIdx = tableMetadata.indexes.some((idx) =>+ idx.expressions.includes(column)+ );+ return { isPrimaryKey: false, isIndex: inIdx };+ }, [target, tableMetadata]);const icon = isPrimaryKey ? (<PrimaryKeyIcon />diff --git a/frontend/src/react/components/sql-editor/SchemaPane/click.ts b/frontend/src/react/components/sql-editor/SchemaPane/click.tsindex f4990fc18d..b24ad2b579 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/click.ts+++ b/frontend/src/react/components/sql-editor/SchemaPane/click.ts@@ -1,35 +1,50 @@-import Emittery from "emittery";-import { useMemo } from "react";+import { useMemo, useRef } from "react";import type { TreeNode } from "./schemaTree";-const DELAY = 250;--type ClickEvents = Emittery<{- "single-click": { node: TreeNode };- "double-click": { node: TreeNode };-}>;+const DOUBLE_CLICK_WINDOW_MS = 250;type PendingState = {timeout: ReturnType<typeof setTimeout>;node: TreeNode;};+export type ClickHandlers = {+ readonly onSingleClick: (node: TreeNode) => void;+ readonly onDoubleClick: (node: TreeNode) => void;+};+export type UseClickEventsResult = {- events: ClickEvents;handleClick: (node: TreeNode) => void;};/**- * React port of `src/views/sql-editor/AsidePanel/SchemaPane/click.ts`.+ * Single/double-click discriminator for the schema tree.*- * 250ms single/double-click discriminator. Same Emittery API surface,- * but the timing state lives in a closure (returned via `useMemo`) so- * it persists across renders without resubscribing.+ * Previously this routed clicks through an `Emittery` instance and the+ * consumer subscribed via `useEffect`. Emittery's `emit` is async — its+ * implementation `await resolvedPromise` before invoking listeners, so the+ * actual `toggleNode` work was deferred to a microtask after every click.+ * Combined with the downstream Vue-watch / React-render / react-arborist+ * recompute, that microtask hop pushed the paint out far enough that+ * users saw "no response until I move the mouse" (the next input event+ * was what gave the browser a chance to flush). Plain callbacks invoked+ * synchronously from `handleClick` keep all the work in the same tick.+ *+ * For most node types both single- and double-click do the same thing+ * (`toggleNode`), so we skip the discriminator and fire the single-click+ * handler immediately. Only `table` and `view` rows have a distinct+ * double-click action (`selectAllFromTableOrView`) — those keep the+ * 250ms timer.*/-export function useClickEvents(): UseClickEventsResult {+export function useClickEvents(handlers: ClickHandlers): UseClickEventsResult {+ // Refresh-on-render ref so the discriminator always invokes the latest+ // handlers (which capture the latest `expandedKeys`, etc.) without+ // having to re-create the discriminator state on every parent render.+ const handlersRef = useRef(handlers);+ handlersRef.current = handlers;+return useMemo(() => {let pending: PendingState | undefined;- const events: ClickEvents = new Emittery();const clear = () => {if (!pending) return;@@ -37,26 +52,35 @@ export function useClickEvents(): UseClickEventsResult {pending = undefined;};- const queue = (node: TreeNode) => {+ const queueSingle = (node: TreeNode) => {pending = {timeout: setTimeout(() => {- events.emit("single-click", { node });- clear();- }, DELAY),+ pending = undefined;+ handlersRef.current.onSingleClick(node);+ }, DOUBLE_CLICK_WINDOW_MS),node,};};const handleClick = (node: TreeNode) => {+ const type = node.meta.type;+ const hasDistinctDoubleClick = type === "table" || type === "view";++ if (!hasDistinctDoubleClick) {+ clear();+ handlersRef.current.onSingleClick(node);+ return;+ }+if (pending && pending.node.key === node.key) {- events.emit("double-click", { node });clear();+ handlersRef.current.onDoubleClick(node);return;}clear();- queue(node);+ queueSingle(node);};- return { events, handleClick };+ return { handleClick };}, []);}diff --git a/frontend/src/react/components/sql-editor/SheetTree.tsx b/frontend/src/react/components/sql-editor/SheetTree.tsxindex f16aebf6f0..53598067cf 100644--- a/frontend/src/react/components/sql-editor/SheetTree.tsx+++ b/frontend/src/react/components/sql-editor/SheetTree.tsx@@ -1332,6 +1332,7 @@ export function SheetTree({}}><PopoverTrigger+ nativeButton={false}render={<divaria-hiddendiff --git a/frontend/src/react/components/sql-editor/WorksheetPane.tsx b/frontend/src/react/components/sql-editor/WorksheetPane.tsxindex ddd4a0a133..0c089fb7b1 100644--- a/frontend/src/react/components/sql-editor/WorksheetPane.tsx+++ b/frontend/src/react/components/sql-editor/WorksheetPane.tsx@@ -161,7 +161,7 @@ export function WorksheetPane() {<div className="relative flex-1 flex flex-col gap-y-2 overflow-y-auto worksheet-scroll">{showMultiSelectToolbar && (- <div className="sticky top-0 z-10 flex flex-wrap items-center justify-start gap-y-1 gap-x-1 bg-accent/10 py-2 px-1">+ <div className="sticky top-0 z-10 flex flex-wrap items-center justify-start gap-y-1 gap-x-1 bg-control-bg py-2 px-1"><Buttonvariant="ghost"size="xs"diff --git a/frontend/src/react/components/ui/checkbox.tsx b/frontend/src/react/components/ui/checkbox.tsxindex d80c787b51..7c73b9c956 100644--- a/frontend/src/react/components/ui/checkbox.tsx+++ b/frontend/src/react/components/ui/checkbox.tsx@@ -50,7 +50,17 @@ function Checkbox({"data-[checked]:bg-accent data-[checked]:border-accent","data-[indeterminate]:bg-accent data-[indeterminate]:border-accent","focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",- "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-control-border",+ "data-disabled:cursor-not-allowed data-disabled:hover:border-control-border",+ // Disabled + checked: render in a muted gray instead of the+ // accent so it reads as "locked-on". Base UI sets the+ // `data-disabled` attribute when `disabled` is true — using+ // `data-disabled:` instead of `disabled:` matches the+ // convention used elsewhere in this directory and is+ // independent of whether the rendered element supports the+ // `:disabled` pseudo-class.+ "data-disabled:data-[checked]:bg-control-light data-disabled:data-[checked]:border-control-light",+ "data-disabled:data-[indeterminate]:bg-control-light data-disabled:data-[indeterminate]:border-control-light",+ "data-disabled:not-data-[checked]:not-data-[indeterminate]:opacity-50",!onClick && className)}>diff --git a/frontend/src/react/components/ui/tree.tsx b/frontend/src/react/components/ui/tree.tsxindex 9d293e198c..2d985c8431 100644--- a/frontend/src/react/components/ui/tree.tsx+++ b/frontend/src/react/components/ui/tree.tsx@@ -1,5 +1,5 @@import type { CSSProperties, ReactNode } from "react";-import { useEffect, useRef } from "react";+import { useLayoutEffect, useRef } from "react";import type { MoveHandler, NodeApi, TreeApi } from "react-arborist";import { Tree as ArboristTree } from "react-arborist";import { cn } from "@/react/lib/utils";@@ -73,19 +73,45 @@ export function Tree<T>({// The flag below suppresses consumer notifications during the// programmatic batch so the consumer's state stays stable.const programmaticToggleRef = useRef(false);-- // Sync expandedIds to the arborist tree programmatically- useEffect(() => {+ // When the user clicks the chevron, react-arborist toggles its INTERNAL+ // open state synchronously AND fires onToggle. The consumer then mirrors+ // that change in `expandedIds`, which fires the sync effect below — but+ // a re-applied `tree.open(id)` / `tree.close(id)` on the same id forces+ // react-arborist to recompute its visible-rows list a second time. For+ // a "Columns" node with hundreds of descendants that doubled the cost+ // of every collapse. Track the id the user just toggled and skip+ // syncing it on the next effect pass — react-arborist's internal state+ // is already in sync for that node.+ const userToggledIdRef = useRef<string | null>(null);++ // Sync expandedIds to the arborist tree programmatically.+ //+ // We use `useLayoutEffect` (not `useEffect`) deliberately: when the+ // consumer flips `expandedIds`, the FIRST commit shows the tree with+ // the new `expandedIds` prop but arborist's internal open-state is+ // still the OLD value, so the rendered rows haven't changed yet. The+ // sync below calls `tree.open(id)` / `tree.close(id)` which triggers+ // a SECOND commit inside arborist. With `useEffect` (passive), the+ // browser can paint the first (stale) commit before the second one+ // runs, and on some interactions only the next input event seemed to+ // give the browser a chance to flush the second paint — users saw+ // "click did nothing until I moved the mouse." `useLayoutEffect`+ // runs after commit but BEFORE paint, so the sync happens between+ // the two commits and the browser paints the final state in one go.+ useLayoutEffect(() => {const tree = treeRef.current;if (!tree) return;const prev = new Set(prevExpandedRef.current ?? []);const next = new Set(expandedIds ?? []);+ const skipId = userToggledIdRef.current;+ userToggledIdRef.current = null;programmaticToggleRef.current = true;try {// Close nodes that were previously open but no longer in expandedIdsfor (const id of prev) {+ if (id === skipId) continue;if (!next.has(id)) {tree.close(id);}@@ -93,6 +119,7 @@ export function Tree<T>({// Open nodes that are in expandedIds but not previously openfor (const id of next) {+ if (id === skipId) continue;if (!prev.has(id)) {tree.open(id);}@@ -106,6 +133,7 @@ export function Tree<T>({const handleArboristToggle = (id: string) => {if (programmaticToggleRef.current) return;+ userToggledIdRef.current = id;onToggle?.(id);};diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex 8f675602e1..c400b3a29a 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -2719,7 +2719,8 @@"download-as-file": "Download as {{file}}","duration-day": "{{days}} day","duration-days": "{{days}} days",- "duration-hours": "{{hours}} hour | {{hours}} hours",+ "duration-hour": "{{hours}} hour",+ "duration-hours": "{{hours}} hours","execute-query": "Execute query","executing-query": "Executing query","expire-at": "Expire at {{time}}",diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex 79401edf1c..cf1aae2620 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -2707,7 +2707,8 @@"download-as-file": "Descargar como {{file}}","duration-day": "{{days}} day","duration-days": "{{days}} days",- "duration-hours": "{{hours}} hour | {{hours}} hours",+ "duration-hour": "{{hours}} hora",+ "duration-hours": "{{hours}} horas","execute-query": "Ejecutar consulta","executing-query": "Ejecutando consulta","expire-at": "Expire at {{time}}",diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex e79981ce40..99cdc949de 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -2707,7 +2707,8 @@"download-as-file": "{{file}} 形式でダウンロード","duration-day": "{{days}} day","duration-days": "{{days}} days",- "duration-hours": "{{hours}} hour | {{hours}} hours",+ "duration-hour": "{{hours}} 時間",+ "duration-hours": "{{hours}} 時間","execute-query": "クエリを実行する","executing-query": "クエリの実行","expire-at": "Expire at {{time}}",diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 278f3e10fe..5bb65615b4 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -2707,7 +2707,8 @@"download-as-file": "Tải xuống dưới dạng {{file}}","duration-day": "{{days}} day","duration-days": "{{days}} days",- "duration-hours": "{{hours}} hour | {{hours}} hours",+ "duration-hour": "{{hours}} giờ",+ "duration-hours": "{{hours}} giờ","execute-query": "Thực hiện truy vấn","executing-query": "Đang thực hiện truy vấn","expire-at": "Expire at {{time}}",diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex 711927f581..7c97e323e1 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -2707,6 +2707,7 @@"download-as-file": "下载为 {{file}} 格式","duration-day": "{{days}} 天","duration-days": "{{days}} 天",+ "duration-hour": "{{hours}} 小时","duration-hours": "{{hours}} 小时","execute-query": "执行查询","executing-query": "执行查询",