Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor(react): sql editor (#20063)

ecmadao675a9dffcf57
diff --git a/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-2.md b/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-2.md
new file mode 100644
index 0000000000..1c96a34687
--- /dev/null
+++ b/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-2.md
@@ -0,0 +1,938 @@
+# SQL Editor React Migration — Stage 2 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:** Migrate `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue` (33 lines) to React and establish the `useSQLEditorContext` → Pinia bridge by extracting 6 UI state refs + `editorPanelSize` computed + `handleEditorPanelResize` setter into a new `useSQLEditorUIStore`. Vue's `useSQLEditorContext()` API shape stays unchanged — React leaves read/write the Pinia store directly.
+
+**Architecture:** A new Pinia setup-store (`modules/sqlEditor/uiState.ts`) owns the 7 fields; `provideSQLEditorContext` delegates to it via `storeToRefs` while keeping its existing return shape; React `ConnectionHolder.tsx` writes `showConnectionPanel` directly through the store with no prop callback.
+
+**Tech Stack:** Pinia setup-stores, Vue 3 `storeToRefs`, `@vueuse/core` `useLocalStorage`, React 18, `@base-ui/react`, shadcn `Button`, `lucide-react`, vitest.
+
+**Reference spec:** `docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-2-design.md`
+
+**Workflow note:** **Do not auto-commit** — user commits manually. Each task ends with "Stop for user review."
+
+---
+
+## File Structure
+
+| File | Action | Responsibility |
+|---|---|---|
+| `frontend/src/store/modules/sqlEditor/uiState.ts` | Create | New `useSQLEditorUIStore` Pinia setup-store: 6 reactive UI state refs + `editorPanelSize` computed + `handleEditorPanelResize` setter + internal `aiPanelSize` LocalStorage ref. |
+| `frontend/src/store/modules/sqlEditor/uiState.test.ts` | Create | Store smoke tests: initial values, `handleEditorPanelResize` behavior, `editorPanelSize` computed transitions when `showAIPanel` toggles. |
+| `frontend/src/store/modules/sqlEditor/index.ts` | Modify | Append `export * from "./uiState"` to match sibling export pattern. |
+| `frontend/src/views/sql-editor/context.ts` | Modify | Refactor `provideSQLEditorContext`: delegate 7 fields to `useSQLEditorUIStore` via `storeToRefs`, remove inline `aiPanelSize` / `editorPanelSize` / `handleEditorPanelResize` / `showConnectionPanel` / `showAIPanel` / `schemaViewer` / `pendingInsertAtCaret` / `highlightAccessGrantName` / `asidePanelTab` definitions. `SQLEditorContext` return shape unchanged. |
+| `frontend/src/react/components/sql-editor/ConnectionHolder.tsx` | Create | React leaf replacing the Vue `ConnectionHolder.vue`. Primary ghost button with `LinkIcon` + `sql-editor.connect-to-a-database` label. Click → `useSQLEditorUIStore().showConnectionPanel = true`. |
+| `frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx` | Create | Unit tests: renders button with expected label + icon; click invokes the store setter. |
+| `frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue` | Modify | Line 75: replace `<ConnectionHolder v-else />` with `<div v-else class="flex-1 flex flex-col min-h-0"><ReactPageMount page="ConnectionHolder" /></div>`. Line 97-101: remove `ConnectionHolder` from the `"../../EditorCommon"` named import; add `import ReactPageMount from "@/react/ReactPageMount.vue"`. |
+| `frontend/src/views/sql-editor/EditorCommon/index.ts` | Modify | Remove `import ConnectionHolder from "./ConnectionHolder.vue"` (line 1) and the `ConnectionHolder,` entry in the `export` block (line 12). |
+| `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue` | Delete | Orphaned after the swap and barrel removal. |
+
+---
+
+## Task 1: Create `useSQLEditorUIStore` (TDD)
+
+**Goal:** New Pinia setup-store owning the 7 fields that React leaves need to bridge. Test-first to lock the public surface.
+
+**Files:**
+- Create: `frontend/src/store/modules/sqlEditor/uiState.ts`
+- Create: `frontend/src/store/modules/sqlEditor/uiState.test.ts`
+
+- [ ] **Step 1: Write the failing test**
+
+Create `frontend/src/store/modules/sqlEditor/uiState.test.ts`:
+
+```ts
+import { createPinia, setActivePinia } from "pinia";
+import { beforeEach, describe, expect, test } from "vitest";
+
+let useSQLEditorUIStore: typeof import("./uiState").useSQLEditorUIStore;
+
+beforeEach(async () => {
+ // Fresh pinia + fresh module each test so LocalStorage reactivity doesn't leak.
+ localStorage.clear();
+ setActivePinia(createPinia());
+ ({ useSQLEditorUIStore } = await import("./uiState"));
+});
+
+describe("useSQLEditorUIStore", () => {
+ test("initial state has documented defaults", () => {
+ const store = useSQLEditorUIStore();
+ expect(store.asidePanelTab).toBe("WORKSHEET");
+ expect(store.showConnectionPanel).toBe(false);
+ expect(store.showAIPanel).toBe(false);
+ expect(store.schemaViewer).toBeUndefined();
+ expect(store.pendingInsertAtCaret).toBeUndefined();
+ expect(store.highlightAccessGrantName).toBeUndefined();
+ });
+
+ test("editorPanelSize returns full-width when AI panel is hidden", () => {
+ const store = useSQLEditorUIStore();
+ expect(store.showAIPanel).toBe(false);
+ expect(store.editorPanelSize).toEqual({ size: 1, max: 1, min: 1 });
+ });
+
+ test("editorPanelSize returns clamped split when AI panel is shown", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ // Default aiPanelSize LocalStorage value is 0.3 → editor gets 1 - 0.3 = 0.7
+ // which is above the 0.5 minimum, so 0.7 is used.
+ expect(store.editorPanelSize).toEqual({ size: 0.7, max: 0.9, min: 0.5 });
+ });
+
+ test("editorPanelSize clamps to minimum 0.5 when AI panel is huge", () => {
+ // Pre-seed LocalStorage with an oversized AI panel so the editor would be < 0.5.
+ localStorage.setItem(
+ "bb.sql-editor.ai-panel-size",
+ JSON.stringify(0.8)
+ );
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ // 1 - 0.8 = 0.2, clamped up to the 0.5 minimum.
+ expect(store.editorPanelSize.size).toBe(0.5);
+ });
+
+ test("handleEditorPanelResize writes complement to aiPanelSize LocalStorage", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ store.handleEditorPanelResize(0.6);
+ // editor=0.6 → aiPanelSize=0.4 → editor size = max(1 - 0.4, 0.5) = 0.6
+ expect(store.editorPanelSize.size).toBe(0.6);
+ });
+
+ test("handleEditorPanelResize no-ops when size is >= 1", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ store.handleEditorPanelResize(1);
+ // aiPanelSize stays at 0.3 default → editor size = 0.7
+ expect(store.editorPanelSize.size).toBe(0.7);
+ });
+});
+```
+
+- [ ] **Step 2: Run the test to verify it fails**
+
+Run:
+```bash
+pnpm --dir frontend test -- uiState.test --run
+```
+
+Expected: FAIL with `Cannot find module './uiState'`.
+
+- [ ] **Step 3: Verify the LocalStorage key value**
+
+The test uses the string `"bb.sql-editor.ai-panel-size"` for one seed. Before writing the store, confirm that matches `STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE`:
+
+Run:
+```bash
+grep -n "STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE" /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/utils/*.ts
+```
+
+Expected output identifies the constant's value. If the actual key string differs from `"bb.sql-editor.ai-panel-size"`, update the test's `localStorage.setItem(...)` call to use the actual value.
+
+- [ ] **Step 4: Write the implementation**
+
+Create `frontend/src/store/modules/sqlEditor/uiState.ts`:
+
+```ts
+import { useLocalStorage } from "@vueuse/core";
+import { defineStore } from "pinia";
+import { computed, ref } from "vue";
+import type { GetSchemaStringRequest_ObjectType } from "@/types/proto-es/v1/database_service_pb";
+import { STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE } from "@/utils";
+import type { AsidePanelTab } from "@/views/sql-editor/context";
+
+const minimumEditorPanelSize = 0.5;
+
+/**
+ * UI state for the SQL Editor shell.
+ *
+ * Extracted from `useSQLEditorContext` so React leaves can access the same
+ * reactive state that Vue consumers read via inject. Vue's
+ * `useSQLEditorContext()` wraps this store via `storeToRefs` and preserves
+ * its existing API shape.
+ */
+export const useSQLEditorUIStore = defineStore("sqlEditorUI", () => {
+ const asidePanelTab = ref<AsidePanelTab>("WORKSHEET");
+ const showConnectionPanel = ref(false);
+ const showAIPanel = ref(false);
+ const schemaViewer = ref<
+ | {
+ schema?: string;
+ object?: string;
+ type?: GetSchemaStringRequest_ObjectType;
+ }
+ | undefined
+ >(undefined);
+ const pendingInsertAtCaret = ref<string | undefined>();
+ const highlightAccessGrantName = ref<string | undefined>();
+
+ const aiPanelSize = useLocalStorage(
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ 0.3
+ );
+
+ const editorPanelSize = computed(() => {
+ if (!showAIPanel.value) {
+ return { size: 1, max: 1, min: 1 };
+ }
+ return {
+ size: Math.max(1 - aiPanelSize.value, minimumEditorPanelSize),
+ max: 0.9,
+ min: minimumEditorPanelSize,
+ };
+ });
+
+ const handleEditorPanelResize = (size: number) => {
+ if (size >= 1) return;
+ aiPanelSize.value = 1 - size;
+ };
+
+ return {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ handleEditorPanelResize,
+ };
+});
+```
+
+- [ ] **Step 5: Run the test to verify it passes**
+
+Run:
+```bash
+pnpm --dir frontend test -- uiState.test --run
+```
+
+Expected: PASS (6 tests).
+
+If the tests fail with "Cannot set property asidePanelTab... (setter only)" or similar, the test is accessing a `storeToRefs` wrapped object. The direct `store.xxx = value` pattern works against a raw Pinia store instance — which is what `useSQLEditorUIStore()` returns. Confirm the test file calls the store directly (not `storeToRefs`).
+
+- [ ] **Step 6: Stop for user review**
+
+Report: "`useSQLEditorUIStore` store + 6 tests created and passing. Ready for commit."
+
+---
+
+## Task 2: Export the store from the sqlEditor barrel
+
+**Goal:** Make `useSQLEditorUIStore` reachable via `@/store` so both Vue `context.ts` and React `ConnectionHolder.tsx` can import it with a clean path.
+
+**Files:**
+- Modify: `frontend/src/store/modules/sqlEditor/index.ts`
+
+- [ ] **Step 1: Read current state**
+
+Current file content (5 lines):
+
+```ts
+export * from "./editor";
+export * from "./tab";
+export * from "./tree";
+export * from "./queryHistory";
+export * from "./webTerminal";
+```
+
+- [ ] **Step 2: Add the uiState export**
+
+Change to:
+
+```ts
+export * from "./editor";
+export * from "./tab";
+export * from "./tree";
+export * from "./queryHistory";
+export * from "./uiState";
+export * from "./webTerminal";
+```
+
+(Alphabetical ordering; `uiState` sits between `queryHistory` and `webTerminal`.)
+
+- [ ] **Step 3: Verify the import path resolves**
+
+Run:
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. No new "cannot find export" errors.
+
+- [ ] **Step 4: Stop for user review**
+
+Report: "Store barrel updated. Ready for commit."
+
+---
+
+## Task 3: Refactor `context.ts` to delegate to the store
+
+**Goal:** Replace the inline UI-state construction in `provideSQLEditorContext` with delegation to `useSQLEditorUIStore` via `storeToRefs`, preserving the `SQLEditorContext` shape so the ~30 Vue consumers keep working unchanged.
+
+**File:**
+- Modify: `frontend/src/views/sql-editor/context.ts`
+
+- [ ] **Step 1: Read the current file end-to-end**
+
+Open and read `frontend/src/views/sql-editor/context.ts`. Identify the three blocks to modify:
+
+1. **Imports** (lines 1-32): `useLocalStorage` is imported; `STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE` is imported. Both become unused after the refactor. `storeToRefs` from `pinia` needs to be added; `useSQLEditorUIStore` from `@/store` needs to be added.
+2. **`provideSQLEditorContext` top** (around lines 122-148): the `showConnectionPanel = ref(false)`, `aiPanelSize = useLocalStorage(...)`, `showAIPanel = ref(false)`, `editorPanelSize = computed(...)` blocks and the `minimumEditorPanelSize` constant all move away.
+3. **`context` object construction** (around lines 304-324): the 7 inlined fields (`asidePanelTab: ref("WORKSHEET")`, `showConnectionPanel`, `showAIPanel`, `editorPanelSize`, `schemaViewer: ref(undefined)`, `pendingInsertAtCaret: ref()`, `highlightAccessGrantName: ref<string | undefined>()`, `handleEditorPanelResize: (size) => { ... }`) are replaced with the `storeToRefs`-destructured fields and `uiStore.handleEditorPanelResize`.
+
+- [ ] **Step 2: Update the imports**
+
+Change:
+```ts
+import { create } from "@bufbuild/protobuf";
+import { useLocalStorage, watchDebounced } from "@vueuse/core";
+import Emittery from "emittery";
+import { isUndefined } from "lodash-es";
+```
+
+To:
+```ts
+import { create } from "@bufbuild/protobuf";
+import { watchDebounced } from "@vueuse/core";
+import Emittery from "emittery";
+import { isUndefined } from "lodash-es";
+import { storeToRefs } from "pinia";
+```
+
+Remove `useLocalStorage` from the `@vueuse/core` import; add the `storeToRefs` import from `pinia`.
+
+Find the existing `@/store` import:
+```ts
+import {
+ pushNotification,
+ useProjectIamPolicyStore,
+ useProjectV1Store,
+ useSQLEditorStore,
+ useSQLEditorTabStore,
+ useWorkSheetStore,
+} from "@/store";
+```
+
+Add `useSQLEditorUIStore` alphabetically:
+```ts
+import {
+ pushNotification,
+ useProjectIamPolicyStore,
+ useProjectV1Store,
+ useSQLEditorStore,
+ useSQLEditorTabStore,
+ useSQLEditorUIStore,
+ useWorkSheetStore,
+} from "@/store";
+```
+
+Find the `@/utils` import. Remove `STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE` from it (the store now owns the LocalStorage key). Keep every other named import on that line. If `STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE` was the only import, remove the entire import line — but check first: the current line in `context.ts` is:
+
+```ts
+import {
+ extractWorksheetConnection,
+ isSimilarDefaultSQLEditorTabTitle,
+ isWorksheetWritableV1,
+ NEW_WORKSHEET_TITLE,
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ suggestedTabTitleForSQLEditorConnection,
+} from "@/utils";
+```
+
+Remove the `STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,` line; leave the others.
+
+- [ ] **Step 3: Remove the top-of-function UI-state construction**
+
+Find the block starting at `export const provideSQLEditorContext = () => {`. Remove:
+
+```ts
+ const showConnectionPanel = ref(false);
+
+ const aiPanelSize = useLocalStorage(
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ 0.3 /* panel size should in [0.1, 1-minimumEditorPanelSize]*/
+ );
+ const showAIPanel = ref(false);
+ const editorPanelSize = computed(() => {
+ if (!showAIPanel.value) {
+ return {
+ size: 1,
+ max: 1,
+ min: 1,
+ };
+ }
+ return {
+ size: Math.max(1 - aiPanelSize.value, minimumEditorPanelSize),
+ max: 0.9,
+ min: minimumEditorPanelSize,
+ };
+ });
+```
+
+Also remove the module-scope `const minimumEditorPanelSize = 0.5;` declaration (currently above `provideSQLEditorContext`) — it's now a constant inside the store.
+
+- [ ] **Step 4: Add store destructure near the other store calls**
+
+At the top of `provideSQLEditorContext` where the existing `const editorStore = useSQLEditorStore();` etc. appear, add:
+
+```ts
+ const uiStore = useSQLEditorUIStore();
+ const {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ } = storeToRefs(uiStore);
+```
+
+Place it right after the last existing store call (e.g. after `const worksheetStore = useWorkSheetStore();`).
+
+- [ ] **Step 5: Replace the `context` object fields**
+
+Find the `const context: SQLEditorContext = { ... };` block (around lines 304-324). The current shape:
+
+```ts
+ const context: SQLEditorContext = {
+ asidePanelTab: ref("WORKSHEET"),
+ showConnectionPanel,
+ showAIPanel,
+ editorPanelSize,
+ schemaViewer: ref(undefined),
+ pendingInsertAtCaret: ref(),
+ highlightAccessGrantName: ref<string | undefined>(),
+ events: new Emittery(),
+
+ maybeSwitchProject,
+ handleEditorPanelResize: (size: number) => {
+ if (size >= 1) {
+ return;
+ }
+ aiPanelSize.value = 1 - size;
+ },
+ createWorksheet,
+ maybeUpdateWorksheet,
+ abortAutoSave,
+ };
+```
+
+Replace with:
+
+```ts
+ const context: SQLEditorContext = {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ editorPanelSize,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ events: new Emittery(),
+
+ maybeSwitchProject,
+ handleEditorPanelResize: uiStore.handleEditorPanelResize,
+ createWorksheet,
+ maybeUpdateWorksheet,
+ abortAutoSave,
+ };
+```
+
+Note: `asidePanelTab`, `showConnectionPanel`, `showAIPanel`, `editorPanelSize`, `schemaViewer`, `pendingInsertAtCaret`, `highlightAccessGrantName` are all the `Ref<T>` values from `storeToRefs` — they match the existing `Ref<T>` / `ComputedRef<T>` types in `SQLEditorContext`.
+
+- [ ] **Step 6: Verify unused imports are gone**
+
+Run:
+```bash
+pnpm --dir frontend exec eslint src/views/sql-editor/context.ts 2>&1 | tail -15
+```
+
+Expected: no errors. If ESLint flags `ref` or `computed` as unused imports (because their uses moved into the store), remove those from the `vue` import list — but only remove `ref` / `computed` if they're genuinely no longer used in `context.ts` (they might still be used elsewhere in the file for non-UI refs). Grep within the file first to verify:
+
+```bash
+grep -n "\bref\b\|\bcomputed\b" /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/views/sql-editor/context.ts
+```
+
+- [ ] **Step 7: Type-check**
+
+Run:
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. Zero new errors. If the `SQLEditorContext` type mismatch shows up (e.g. `Ref<AsidePanelTab>` expected but received `WritableComputedRef` or similar), it likely means `storeToRefs` wasn't applied correctly — re-check Step 4.
+
+- [ ] **Step 8: Run the full test suite**
+
+Run:
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: 1152+ tests pass; no regressions from the context refactor.
+
+- [ ] **Step 9: Stop for user review**
+
+Report: "`context.ts` refactored — 7 fields delegated to `useSQLEditorUIStore`, `SQLEditorContext` shape unchanged, type-check clean, tests pass. Ready for commit."
+
+---
+
+## Task 4: Create React `ConnectionHolder.tsx` (TDD)
+
+**Goal:** React leaf that renders a primary ghost button (visual parity with Vue naive-ui `NButton type="primary" ghost`) + `LinkIcon` + the migrated `sql-editor.connect-to-a-database` label. Click reaches directly into `useSQLEditorUIStore().showConnectionPanel`.
+
+**Files:**
+- Create: `frontend/src/react/components/sql-editor/ConnectionHolder.tsx`
+- Create: `frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx`
+
+- [ ] **Step 1: Write the failing test**
+
+Create `frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx`:
+
+```tsx
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useSQLEditorUIStore: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+let ConnectionHolder: typeof import("./ConnectionHolder").ConnectionHolder;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ ({ ConnectionHolder } = await import("./ConnectionHolder"));
+});
+
+describe("ConnectionHolder", () => {
+ test("renders the Connect-to-database label", () => {
+ const store = { showConnectionPanel: false };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(
+ <ConnectionHolder />
+ );
+ render();
+ expect(container.textContent).toContain("sql-editor.connect-to-a-database");
+ expect(container.querySelector("button")).not.toBeNull();
+ unmount();
+ });
+
+ test("click sets showConnectionPanel to true on the store", () => {
+ const store = { showConnectionPanel: false };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(
+ <ConnectionHolder />
+ );
+ render();
+ const button = container.querySelector("button");
+ act(() => {
+ button?.click();
+ });
+ expect(store.showConnectionPanel).toBe(true);
+ unmount();
+ });
+});
+```
+
+- [ ] **Step 2: Run the test to verify it fails**
+
+Run:
+```bash
+pnpm --dir frontend test -- ConnectionHolder.test --run
+```
+
+Expected: FAIL with `Cannot find module './ConnectionHolder'`.
+
+- [ ] **Step 3: Write the implementation**
+
+Create `frontend/src/react/components/sql-editor/ConnectionHolder.tsx`:
+
+```tsx
+import { LinkIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import { useSQLEditorUIStore } from "@/store";
+
+/**
+ * Replaces frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue.
+ * Rendered as the v-else fallback inside the admin-mode Terminal panel when
+ * there is no active database connection. Click opens the connection panel
+ * via the SQL Editor UI store.
+ */
+export function ConnectionHolder() {
+ const { t } = useTranslation();
+ const uiStore = useSQLEditorUIStore();
+
+ const handleClick = () => {
+ uiStore.showConnectionPanel = true;
+ };
+
+ return (
+ <div className="flex items-center justify-center w-full h-full">
+ <Button variant="outline" onClick={handleClick}>
+ <LinkIcon className="size-5" />
+ {t("sql-editor.connect-to-a-database")}
+ </Button>
+ </div>
+ );
+}
+```
+
+Note on variant: the Vue original uses naive-ui `NButton type="primary" ghost` which renders as a bordered-accent button (accent border + text, transparent fill). The shadcn `outline` variant is the closest match in the project's current button surface (`border border-control-border bg-transparent text-control hover:bg-control-bg`). This is functionally equivalent — the exact hover/focus hue may differ slightly; confirm in the manual UX check (Task 7) and iterate if the difference is visible.
+
+- [ ] **Step 4: Run the test to verify it passes**
+
+Run:
+```bash
+pnpm --dir frontend test -- ConnectionHolder.test --run
+```
+
+Expected: PASS (2 tests).
+
+- [ ] **Step 5: Stop for user review**
+
+Report: "`ConnectionHolder.tsx` + 2 tests created and passing. Ready for commit."
+
+---
+
+## Task 5: Swap `TerminalPanel.vue` to use `<ReactPageMount>`
+
+**Goal:** Replace the Vue `<ConnectionHolder v-else />` with an inline-mounted React version at line 75 of `TerminalPanel.vue`. Remove the Vue `ConnectionHolder` named import; add the `ReactPageMount` import.
+
+**File:**
+- Modify: `frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue`
+
+- [ ] **Step 1: Read current state**
+
+Open the file and confirm:
+- Line 75: `<ConnectionHolder v-else />`
+- Lines 97-101:
+```ts
+import {
+ ConnectionHolder,
+ EditorAction,
+ ResultViewV1,
+} from "../../EditorCommon";
+```
+
+If line numbers differ slightly (whitespace changes), adjust but make the same semantic edits.
+
+- [ ] **Step 2: Replace the template**
+
+Change line 75 from:
+```vue
+<ConnectionHolder v-else />
+```
+
+To:
+```vue
+<div v-else class="flex-1 flex flex-col min-h-0">
+ <ReactPageMount page="ConnectionHolder" />
+</div>
+```
+
+(The `flex-1 flex flex-col min-h-0` wrapper comes from the Stage 1 learning — inline `ReactPageMount` needs a flex-grow wrapper so its `h-full` root has a height to fill.)
+
+- [ ] **Step 3: Update the script imports**
+
+Change:
+```ts
+import {
+ ConnectionHolder,
+ EditorAction,
+ ResultViewV1,
+} from "../../EditorCommon";
+```
+
+To:
+```ts
+import ReactPageMount from "@/react/ReactPageMount.vue";
+import { EditorAction, ResultViewV1 } from "../../EditorCommon";
+```
+
+Keep the existing `@/react/ReactPageMount.vue` import placed in the `@/...` absolute-path group (Vue file convention: absolute paths before relative paths).
+
+- [ ] **Step 4: Type-check**
+
+Run:
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. If you see `Cannot find name 'ConnectionHolder'` anywhere, there's a stray reference — search for it in the file and remove.
+
+- [ ] **Step 5: Run the test suite**
+
+Run:
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: all tests pass.
+
+- [ ] **Step 6: Stop for user review**
+
+Report: "`TerminalPanel.vue` swapped to `<ReactPageMount page=\"ConnectionHolder\" />` with flex-wrapper; imports updated; type-check clean. Ready for commit."
+
+---
+
+## Task 6: Remove the Vue `ConnectionHolder` barrel export and delete the Vue file
+
+**Goal:** The Vue file and its barrel entry are orphaned after Task 5's swap. Verify zero callers, then delete.
+
+**Files:**
+- Modify: `frontend/src/views/sql-editor/EditorCommon/index.ts`
+- Delete: `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue`
+
+- [ ] **Step 1: Search for remaining callers**
+
+Run these three patterns from `/Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/`:
+
+```bash
+grep -rn "from.*EditorCommon/ConnectionHolder" frontend/src/
+grep -rn "import.*ConnectionHolder.*from.*EditorCommon" frontend/src/
+grep -rn "<ConnectionHolder" frontend/src/
+```
+
+**Expected:** Each pattern should return zero matches OUTSIDE the files being deleted (`EditorCommon/index.ts` and `EditorCommon/ConnectionHolder.vue` themselves). The React `ConnectionHolder.tsx` at `frontend/src/react/components/sql-editor/ConnectionHolder.tsx` is the replacement, not a caller — its own imports don't match any of these patterns.
+
+If any match appears outside the files to delete, STOP and report BLOCKED with the caller details.
+
+- [ ] **Step 2: Remove the barrel entry**
+
+Open `frontend/src/views/sql-editor/EditorCommon/index.ts`. Current content:
+
+```ts
+import ConnectionHolder from "./ConnectionHolder.vue";
+import DisconnectedIcon from "./DisconnectedIcon.vue";
+import EditorAction from "./EditorAction.vue";
+import ExecutingHintModal from "./ExecutingHintModal.vue";
+import OpenAIButton from "./OpenAIButton/OpenAIButton.vue";
+import { ResultViewV1 } from "./ResultView";
+import SaveSheetModal from "./SaveSheetModal.vue";
+import SharePopover from "./SharePopover.vue";
+import SheetConnectionIcon from "./SheetConnectionIcon.vue";
+
+export {
+ ConnectionHolder,
+ EditorAction,
+ ExecutingHintModal,
+ SaveSheetModal,
+ SharePopover,
+ ResultViewV1,
+ DisconnectedIcon,
+ SheetConnectionIcon,
+ OpenAIButton,
+};
+
+export * from "./hover-state";
+export * from "./utils";
+```
+
+Change to (two deletions — the import line and the export-block entry):
+
+```ts
+import DisconnectedIcon from "./DisconnectedIcon.vue";
+import EditorAction from "./EditorAction.vue";
+import ExecutingHintModal from "./ExecutingHintModal.vue";
+import OpenAIButton from "./OpenAIButton/OpenAIButton.vue";
+import { ResultViewV1 } from "./ResultView";
+import SaveSheetModal from "./SaveSheetModal.vue";
+import SharePopover from "./SharePopover.vue";
+import SheetConnectionIcon from "./SheetConnectionIcon.vue";
+
+export {
+ EditorAction,
+ ExecutingHintModal,
+ SaveSheetModal,
+ SharePopover,
+ ResultViewV1,
+ DisconnectedIcon,
+ SheetConnectionIcon,
+ OpenAIButton,
+};
+
+export * from "./hover-state";
+export * from "./utils";
+```
+
+- [ ] **Step 3: Delete the Vue file**
+
+Run:
+```bash
+rm /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
+```
+
+- [ ] **Step 4: Verify**
+
+Run:
+```bash
+ls /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue 2>&1
+```
+
+Expected: `No such file or directory`.
+
+Then:
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. If you see a `Cannot find module "./ConnectionHolder.vue"` error, an import somewhere wasn't updated — revisit Task 5 or Step 2 here.
+
+- [ ] **Step 5: Run tests**
+
+Run:
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: 1152+ tests pass.
+
+- [ ] **Step 6: Stop for user review**
+
+Report: "Vue `ConnectionHolder.vue` deleted, barrel updated, type-check clean, tests pass. Ready for commit."
+
+---
+
+## Task 7: Final verification
+
+**Goal:** Run the full frontend verification suite before the Stage 2 PR is ready. Capture the manual UX + bridge integration checks for the user to perform in the browser.
+
+- [ ] **Step 1: Run auto-fix**
+
+Run:
+```bash
+pnpm --dir frontend fix
+```
+
+Expected: no changes, or only trivial formatting adjustments to the new files. If it produces non-trivial changes, report the diff.
+
+- [ ] **Step 2: Run check (CI-equivalent)**
+
+Run:
+```bash
+pnpm --dir frontend check
+```
+
+Expected: pass. ESLint + Biome + React i18n consistency + i18n sort — all clean.
+
+- [ ] **Step 3: Run type-check and confirm baseline-only errors**
+
+Run:
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -30
+```
+
+Expected: exactly the 6 pre-existing `SchemaEditorLite` errors (missing `react-arborist` / `react-resizable-panels` module declarations). Zero new errors.
+
+If a new error appears, STOP — the error must be fixed before marking Stage 2 complete.
+
+- [ ] **Step 4: Run the full test suite**
+
+Run:
+```bash
+pnpm --dir frontend test --run
+```
+
+Expected: all tests pass — existing 1152 plus new: 6 store tests + 2 ConnectionHolder tests = 1160+. Zero failures.
+
+- [ ] **Step 5: Summarize file changes**
+
+Run:
+```bash
+cd /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase
+git status
+```
+
+Expected changes:
+- **New (untracked):**
+ - `frontend/src/store/modules/sqlEditor/uiState.ts`
+ - `frontend/src/store/modules/sqlEditor/uiState.test.ts`
+ - `frontend/src/react/components/sql-editor/ConnectionHolder.tsx`
+ - `frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx`
+- **Modified:**
+ - `frontend/src/store/modules/sqlEditor/index.ts`
+ - `frontend/src/views/sql-editor/context.ts`
+ - `frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue`
+ - `frontend/src/views/sql-editor/EditorCommon/index.ts`
+- **Deleted:**
+ - `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue`
+
+Any other modifications indicate scope creep — flag them.
+
+- [ ] **Step 6: Bridge integration — user runs these manually in the browser**
+
+Report the following checks for the user to perform in a dev server (`pnpm --dir frontend dev`). These are the critical checks that the `context.ts` refactor didn't break reactive data flow for existing Vue consumers:
+
+1. **Open the SQL Editor landing screen** (no connection) → Welcome renders (the Stage 1 React leaf still works).
+2. **Click "Connect to database" on Welcome** → connection panel opens and the aside switches to the SCHEMA tab. This exercises `showConnectionPanel` + `asidePanelTab` bidirectionally through the store.
+3. **Toggle the OpenAI panel** → the editor panel width animates. This exercises `showAIPanel` + `editorPanelSize` through the store.
+4. **Resize the OpenAI split** → the new split size persists to LocalStorage (reload the page — the split stays where you left it). This exercises `handleEditorPanelResize` through the store.
+5. **Click through the aside tabs** (Worksheet ↔ Schema ↔ History ↔ Access) → each tab activates. This exercises `asidePanelTab` reactivity through the Vue consumers that read it (`AsidePanel`, `GutterBar`, etc.).
+6. **Open the admin-mode Terminal panel with no connection** → React `ConnectionHolder` renders (the new Stage 2 React leaf). Click it → connection panel opens.
+7. **Workspace with custom logo / fallback SVG** → Welcome's BytebaseLogo still renders correctly (regression check for the Stage 1 work).
+
+- [ ] **Step 7: Final report**
+
+Report the Stage 2 completion summary:
+
+```
+Stage 2 complete.
+
+Summary:
+- New Pinia store `useSQLEditorUIStore` with 7 fields (6 refs + 1 computed) + handleEditorPanelResize action
+- `useSQLEditorContext` refactored to delegate via storeToRefs; API shape preserved
+- New React ConnectionHolder.tsx replacing the Vue version
+- TerminalPanel.vue swapped to ReactPageMount with flex wrapper
+- Vue ConnectionHolder.vue deleted
+
+Verification:
+- pnpm fix: clean
+- pnpm check: pass
+- pnpm type-check: baseline only (6 pre-existing SchemaEditorLite errors)
+- pnpm test: 1160+ tests pass, zero regressions
+
+Deferred to user:
+- Manual UX-parity screenshot for React ConnectionHolder vs Vue original
+- Bridge integration smoke tests (listed above)
+
+Ready for PR.
+```
diff --git a/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-3.md b/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-3.md
new file mode 100644
index 0000000000..bc37fddb56
--- /dev/null
+++ b/docs/superpowers/plans/2026-04-20-sql-editor-react-migration-stage-3.md
@@ -0,0 +1,849 @@
+# SQL Editor React Migration — Stage 3 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:** Migrate the `AsidePanel/GutterBar/` Vue subsystem (136 lines across 3 files) to a single React component pair (`GutterBar.tsx` + `TabItem.tsx`). First consumer that reactively reads `useSQLEditorUIStore().asidePanelTab` from React via `useVueState`.
+
+**Architecture:** One React mount at `AsidePanel.vue:8`. React `GutterBar` renders 4 inline `TabItem` components. `TabItem` subscribes to `asidePanelTab` via `useVueState` for active-state styling; clicking writes `asidePanelTab` directly through the Pinia store. No new bridge infrastructure — reuses the Stage 2 `useSQLEditorUIStore`.
+
+**Tech Stack:** React 18, `@base-ui/react`, shadcn `Button`, `Tooltip` primitive, `lucide-react`, `react-i18next`, Pinia via `useVueState`, `class-variance-authority` / `cn()`, vitest.
+
+**Reference spec:** `docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-3-design.md`
+
+**Workflow note:** **Do not auto-commit** — user commits manually. Each task ends with "Stop for user review."
+
+---
+
+## File Structure
+
+| File | Action | Responsibility |
+|---|---|---|
+| `frontend/src/react/locales/en-US.json` | Modify | Add 3 missing keys: `worksheet.self`, `common.history`, `sql-editor.jit`. |
+| `frontend/src/react/locales/zh-CN.json` | Modify | Same 3 keys with zh-CN translations. |
+| `frontend/src/react/locales/es-ES.json` | Modify | Same 3 keys with es-ES translations. |
+| `frontend/src/react/locales/ja-JP.json` | Modify | Same 3 keys with ja-JP translations. |
+| `frontend/src/react/locales/vi-VN.json` | Modify | Same 3 keys with vi-VN translations. |
+| `frontend/src/react/components/sql-editor/TabItem.tsx` | Create | Single icon+tooltip button. Props: `{ tab: AsidePanelTab; onClick: () => void }`. Reads `asidePanelTab` via `useVueState`. Applies active/inactive classes to shadcn `Button variant="ghost"`. |
+| `frontend/src/react/components/sql-editor/TabItem.test.tsx` | Create | Tests: icon + label render, active class applied when matching, onClick fires. |
+| `frontend/src/react/components/sql-editor/GutterBar.tsx` | Create | Container: logo link + divider + 4 `TabItem`s (ACCESS conditional on `project.allowJustInTimeAccess`). Zero props. Writes `asidePanelTab` via `uiStore.asidePanelTab = target`. |
+| `frontend/src/react/components/sql-editor/GutterBar.test.tsx` | Create | Tests: 3 tabs when no JIT, 4 tabs when JIT, click writes store, logo `href` computed correctly. |
+| `frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue` | Modify | Line 8: `<GutterBar size="medium" />` → `<ReactPageMount page="GutterBar" />`. Line 81: `import GutterBar from "./GutterBar";` → `import ReactPageMount from "@/react/ReactPageMount.vue";`. |
+| `frontend/src/views/sql-editor/AsidePanel/GutterBar/` (entire dir) | Delete | `GutterBar.vue`, `TabItem.vue`, `common.ts`, `index.ts` — all orphaned after the swap. |
+
+---
+
+## Task 1: Add missing i18n keys
+
+**Goal:** Add `worksheet.self`, `common.history`, `sql-editor.jit` to all 5 React locale files with byte-exact values copied from Vue locales. `check-react-i18n.mjs` enforces 1:1 parity.
+
+**Files:**
+- Modify: `frontend/src/react/locales/{en-US,zh-CN,es-ES,ja-JP,vi-VN}.json`
+
+### Exact values (copy from Vue locales)
+
+| Locale | `worksheet.self` | `common.history` | `sql-editor.jit` |
+|---|---|---|---|
+| en-US | `Worksheet` | `History` | `Just-In-Time Access` |
+| zh-CN | `工作表` | `历史记录` | `即时访问` |
+| es-ES | `Hoja de trabajo` | `Historial` | `Just-In-Time Access` |
+| ja-JP | `ワークシート` | `履歴` | `Just-In-Time Access` |
+| vi-VN | `Bảng tính` | `Lịch sử` | `Just-In-Time Access` |
+
+### Steps
+
+- [ ] **Step 1: Cross-check values against Vue locales**
+
+Run:
+```bash
+for loc in en-US zh-CN es-ES ja-JP vi-VN; do
+ echo "=== $loc ==="
+ for key in "worksheet.self" "common.history" "sql-editor.jit"; do
+ parent="${key%.*}"
+ leaf="${key##*.}"
+ python3 -c "import json; d=json.load(open('/Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/locales/$loc.json')); print(f'$key:', d.get('$parent', {}).get('$leaf', 'MISSING'))"
+ done
+done
+```
+
+Confirm the output matches the table above. If any value differs, use the actual source value (not the table).
+
+- [ ] **Step 2: Add each key in alphabetical position**
+
+In each React locale file, add the keys alphabetically inside their respective parent blocks:
+
+- `worksheet.self` → inside `"worksheet"` block, first alphabetically (before sibling keys).
+- `common.history` → inside `"common"` block, alphabetically (between `hash` and `id` or wherever the natural position is — use the sort script to fix).
+- `sql-editor.jit` → inside `"sql-editor"` block, alphabetically (between `invite` and `key`, roughly).
+
+The exact positions don't need to be manually optimal — the next step re-sorts.
+
+- [ ] **Step 3: Run the sort script**
+
+Run:
+```bash
+node /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/scripts/sort_i18n_keys.mjs
+```
+
+Expected: re-sorts in place. Inspect the diff — only the 3 new keys should be repositioned.
+
+- [ ] **Step 4: Run the consistency check**
+
+Run:
+```bash
+node /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/scripts/check-react-i18n.mjs
+```
+
+Expected outcome at this point: the 3 new keys are flagged as "unused" warnings (consumer lands in Task 2 and 3). NO missing-key or cross-locale consistency errors. If the script hard-fails on unused-only errors, that is acceptable for now — report it and move on.
+
+- [ ] **Step 5: Stop for user review**
+
+Report: "3 i18n keys added to 5 React locale files. Sort script ran. Consistency check shows only the expected 'unused' warnings. Ready for commit."
+
+---
+
+## Task 2: Create `TabItem.tsx` (TDD)
+
+**Goal:** Single icon+tooltip button. Accepts `tab` and `onClick` props. Reads `asidePanelTab` via `useVueState` to compute active state; applies active/inactive classNames to shadcn `Button variant="ghost"`.
+
+**Files:**
+- Create: `frontend/src/react/components/sql-editor/TabItem.tsx`
+- Create: `frontend/src/react/components/sql-editor/TabItem.test.tsx`
+
+### Step 1: Write the failing test
+
+Create `frontend/src/react/components/sql-editor/TabItem.test.tsx`:
+
+```tsx
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useVueState: vi.fn<(getter: () => unknown) => unknown>(),
+ useSQLEditorUIStore: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/react/hooks/useVueState", () => ({
+ useVueState: mocks.useVueState,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+// Stub out Tooltip to render children directly — tooltip positioning is a
+// primitive concern, not this component's.
+vi.mock("@/react/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+}));
+
+let TabItem: typeof import("./TabItem").TabItem;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ // Default: WORKSHEET is active.
+ mocks.useVueState.mockReturnValue(false);
+ mocks.useSQLEditorUIStore.mockReturnValue({ asidePanelTab: "WORKSHEET" });
+ ({ TabItem } = await import("./TabItem"));
+});
+
+describe("TabItem", () => {
+ test("renders label for WORKSHEET tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="WORKSHEET" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("worksheet.self");
+ expect(container.querySelector("button")).not.toBeNull();
+ unmount();
+ });
+
+ test("renders label for SCHEMA tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("common.schema");
+ unmount();
+ });
+
+ test("renders label for HISTORY tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="HISTORY" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("common.history");
+ unmount();
+ });
+
+ test("renders label for ACCESS tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="ACCESS" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("sql-editor.jit");
+ unmount();
+ });
+
+ test("applies active class when asidePanelTab matches", () => {
+ mocks.useVueState.mockReturnValue(true);
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ const button = container.querySelector("button");
+ expect(button?.className).toContain("bg-accent/10");
+ expect(button?.className).toContain("text-accent");
+ unmount();
+ });
+
+ test("does NOT apply active class when asidePanelTab differs", () => {
+ mocks.useVueState.mockReturnValue(false);
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ const button = container.querySelector("button");
+ expect(button?.className).not.toContain("bg-accent/10");
+ unmount();
+ });
+
+ test("calls onClick when button is clicked", () => {
+ const handler = vi.fn();
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={handler} />
+ );
+ render();
+ act(() => {
+ container.querySelector("button")?.click();
+ });
+ expect(handler).toHaveBeenCalledTimes(1);
+ unmount();
+ });
+});
+```
+
+### Step 2: Run the test to verify it fails
+
+```bash
+pnpm --dir frontend test -- TabItem.test --run
+```
+
+Expected: FAIL with `Cannot find module './TabItem'`.
+
+### Step 3: Write the implementation
+
+Create `frontend/src/react/components/sql-editor/TabItem.tsx`:
+
+```tsx
+import { Database, FileCode, History, ShieldCheck } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import { Tooltip } from "@/react/components/ui/tooltip";
+import { useVueState } from "@/react/hooks/useVueState";
+import { cn } from "@/react/lib/utils";
+import type { AsidePanelTab } from "@/store";
+import { useSQLEditorUIStore } from "@/store";
+
+type TabItemProps = {
+ readonly tab: AsidePanelTab;
+ readonly onClick: () => void;
+};
+
+const iconByTab = {
+ WORKSHEET: FileCode,
+ SCHEMA: Database,
+ HISTORY: History,
+ ACCESS: ShieldCheck,
+} as const;
+
+const i18nKeyByTab = {
+ WORKSHEET: "worksheet.self",
+ SCHEMA: "common.schema",
+ HISTORY: "common.history",
+ ACCESS: "sql-editor.jit",
+} as const;
+
+/**
+ * Single tab button in the SQL Editor aside panel's left gutter.
+ * Replaces `frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue`.
+ * Active state reflects `useSQLEditorUIStore().asidePanelTab`; click handler
+ * is supplied by the GutterBar parent (which writes the store).
+ */
+export function TabItem({ tab, onClick }: TabItemProps) {
+ const { t } = useTranslation();
+ const uiStore = useSQLEditorUIStore();
+ const isActive = useVueState(() => uiStore.asidePanelTab === tab);
+
+ const Icon = iconByTab[tab];
+ const label = t(i18nKeyByTab[tab]);
+
+ return (
+ <Tooltip content={label} side="right" delayDuration={300}>
+ <Button
+ variant="ghost"
+ className={cn(
+ "size-10 p-0",
+ isActive &&
+ "bg-accent/10 text-accent hover:bg-accent/10 hover:text-accent"
+ )}
+ onClick={onClick}
+ aria-label={label}
+ >
+ <Icon className="size-5" />
+ </Button>
+ </Tooltip>
+ );
+}
+```
+
+### Step 4: Run the test to verify it passes
+
+```bash
+pnpm --dir frontend test -- TabItem.test --run
+```
+
+Expected: PASS (7 tests).
+
+### Step 5: Stop for user review
+
+Report: "`TabItem.tsx` + 7 tests created and passing. Ready for commit."
+
+---
+
+## Task 3: Create `GutterBar.tsx` (TDD)
+
+**Goal:** Container that renders the logo link + divider + 4 conditional `<TabItem>`s. Reads project from Pinia to gate ACCESS. Writes `asidePanelTab` on click. Zero props (size dropped — only caller passed `"medium"`).
+
+**Files:**
+- Create: `frontend/src/react/components/sql-editor/GutterBar.tsx`
+- Create: `frontend/src/react/components/sql-editor/GutterBar.test.tsx`
+
+### Step 1: Write the failing test
+
+Create `frontend/src/react/components/sql-editor/GutterBar.test.tsx`:
+
+```tsx
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useVueState: vi.fn<(getter: () => unknown) => unknown>(),
+ useSQLEditorStore: vi.fn(),
+ useProjectV1Store: vi.fn(),
+ useSQLEditorUIStore: vi.fn(),
+ routerResolve: vi.fn(() => ({ href: "/project/test-project" })),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/react/hooks/useVueState", () => ({
+ useVueState: mocks.useVueState,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorStore: mocks.useSQLEditorStore,
+ useProjectV1Store: mocks.useProjectV1Store,
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+vi.mock("@/router", () => ({
+ router: {
+ resolve: mocks.routerResolve,
+ currentRoute: { value: { params: {} } },
+ },
+}));
+
+vi.mock("@/router/dashboard/projectV1", () => ({
+ PROJECT_V1_ROUTE_DETAIL: "project.detail",
+}));
+
+vi.mock("@/router/dashboard/workspaceRoutes", () => ({
+ WORKSPACE_ROUTE_LANDING: "workspace.landing",
+}));
+
+vi.mock("@/assets/logo-icon.svg", () => ({
+ default: "/assets/logo-icon.svg",
+}));
+
+vi.mock("@/react/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+}));
+
+let GutterBar: typeof import("./GutterBar").GutterBar;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ // useVueState is called 3 times in GutterBar: project, routeProjectParam,
+ // and once per TabItem's isActive check (4 TabItems rendered when JIT on).
+ // The test uses mockImplementation with a counter for project-related calls.
+ mocks.useSQLEditorStore.mockReturnValue({ project: "projects/test" });
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ mocks.useSQLEditorUIStore.mockReturnValue({ asidePanelTab: "WORKSHEET" });
+ mocks.routerResolve.mockReturnValue({ href: "/workspace/home" });
+ ({ GutterBar } = await import("./GutterBar"));
+});
+
+describe("GutterBar", () => {
+ test("renders 3 tabs when project does not allow JIT access", () => {
+ // All useVueState calls: first returns project (no JIT), second returns
+ // route project param, rest are tab active-state booleans (all false).
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ expect(buttons).toHaveLength(3);
+ unmount();
+ });
+
+ test("renders 4 tabs when project allows JIT access", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: true }),
+ });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ expect(buttons).toHaveLength(4);
+ unmount();
+ });
+
+ test("click writes asidePanelTab on the store", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ const store = { asidePanelTab: "WORKSHEET" as const };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ // Click the second tab (SCHEMA).
+ act(() => {
+ (buttons[1] as HTMLButtonElement).click();
+ });
+ expect(store.asidePanelTab).toBe("SCHEMA");
+ unmount();
+ });
+
+ test("logo link uses project route when route has project param", () => {
+ mocks.useVueState.mockImplementation((getter) => {
+ // Return "test-proj" for the route-param getter call.
+ const result = getter();
+ if (result === undefined) return "test-proj";
+ return result;
+ });
+ mocks.routerResolve.mockReturnValue({ href: "/projects/test-proj" });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const link = container.querySelector("a");
+ expect(link?.getAttribute("href")).toBe("/projects/test-proj");
+ expect(link?.getAttribute("target")).toBe("_blank");
+ unmount();
+ });
+});
+```
+
+### Step 2: Run the test to verify it fails
+
+```bash
+pnpm --dir frontend test -- GutterBar.test --run
+```
+
+Expected: FAIL with `Cannot find module './GutterBar'`.
+
+### Step 3: Write the implementation
+
+Create `frontend/src/react/components/sql-editor/GutterBar.tsx`:
+
+```tsx
+import logoIcon from "@/assets/logo-icon.svg";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
+import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
+import {
+ type AsidePanelTab,
+ useProjectV1Store,
+ useSQLEditorStore,
+ useSQLEditorUIStore,
+} from "@/store";
+import { TabItem } from "./TabItem";
+
+/**
+ * Left gutter of the SQL Editor aside panel. Shows the Bytebase logo at
+ * the top and 4 tab buttons (WORKSHEET, SCHEMA, HISTORY, and optionally
+ * ACCESS when the current project allows JIT).
+ *
+ * Replaces `frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue`.
+ */
+export function GutterBar() {
+ const editorStore = useSQLEditorStore();
+ const projectStore = useProjectV1Store();
+ const uiStore = useSQLEditorUIStore();
+
+ const project = useVueState(() => {
+ const name = editorStore.project;
+ return name ? projectStore.getProjectByName(name) : undefined;
+ });
+
+ const routeProjectParam = useVueState(
+ () => router.currentRoute.value.params.project as string | undefined
+ );
+
+ const logoHref = routeProjectParam
+ ? router.resolve({
+ name: PROJECT_V1_ROUTE_DETAIL,
+ params: { projectId: routeProjectParam },
+ }).href
+ : router.resolve({ name: WORKSPACE_ROUTE_LANDING }).href;
+
+ const handleClickTab = (target: AsidePanelTab) => {
+ uiStore.asidePanelTab = target;
+ };
+
+ return (
+ <div className="h-full flex flex-col items-stretch justify-between overflow-hidden text-sm p-1">
+ <div className="flex flex-col gap-y-1">
+ <div className="flex flex-col justify-center items-center pb-1">
+ <a href={logoHref} target="_blank" rel="noopener noreferrer">
+ <img className="w-9 h-auto" src={logoIcon} alt="Bytebase" />
+ </a>
+ </div>
+ <div className="w-full h-0 border-t" />
+ <TabItem tab="WORKSHEET" onClick={() => handleClickTab("WORKSHEET")} />
+ <TabItem tab="SCHEMA" onClick={() => handleClickTab("SCHEMA")} />
+ <TabItem tab="HISTORY" onClick={() => handleClickTab("HISTORY")} />
+ {project?.allowJustInTimeAccess && (
+ <TabItem tab="ACCESS" onClick={() => handleClickTab("ACCESS")} />
+ )}
+ </div>
+ <div className="flex flex-col justify-end items-center"></div>
+ </div>
+ );
+}
+```
+
+### Step 4: Run the test to verify it passes
+
+```bash
+pnpm --dir frontend test -- GutterBar.test --run
+```
+
+Expected: PASS (4 tests).
+
+### Step 5: Run the React i18n consistency check
+
+```bash
+node /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/scripts/check-react-i18n.mjs
+```
+
+Expected: PASS with no missing / unused / consistency errors. The 3 keys added in Task 1 now have a consumer via `TabItem`.
+
+### Step 6: Stop for user review
+
+Report: "`GutterBar.tsx` + 4 tests created and passing. React i18n check clean (0 unused, 0 missing). Ready for commit."
+
+---
+
+## Task 4: Swap `AsidePanel.vue` to use `<ReactPageMount>`
+
+**Goal:** Replace the Vue `<GutterBar>` mount at line 8 of `AsidePanel.vue` with `<ReactPageMount page="GutterBar" />`. Update the import at line 81.
+
+**File:**
+- Modify: `frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue`
+
+### Step 1: Read the current state
+
+Open `frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue`. Confirm:
+
+- Line 8: `<GutterBar size="medium" />`
+- Line 81: `import GutterBar from "./GutterBar";`
+
+If line numbers drift slightly from whitespace changes, adjust the edit but preserve semantics.
+
+### Step 2: Replace the template
+
+Change line 8 from:
+```vue
+<GutterBar size="medium" />
+```
+To:
+```vue
+<ReactPageMount page="GutterBar" />
+```
+
+### Step 3: Replace the import
+
+Change line 81 from:
+```ts
+import GutterBar from "./GutterBar";
+```
+To:
+```ts
+import ReactPageMount from "@/react/ReactPageMount.vue";
+```
+
+Place the new import in the `@/...` absolute-path group (Vue file import convention: absolute paths before relative paths). In this file, that means it should go near the other `@/...` imports such as `PROJECT_V1_ROUTE_DASHBOARD`, `useActuatorV1Store`, etc.
+
+### Step 4: Type-check
+
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. Zero new errors.
+
+### Step 5: Run the test suite
+
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: all tests pass.
+
+### Step 6: Stop for user review
+
+Report: "`AsidePanel.vue` swapped to `<ReactPageMount page=\"GutterBar\" />`. Type-check clean, tests pass. Ready for commit."
+
+---
+
+## Task 5: Delete the Vue `AsidePanel/GutterBar/` directory
+
+**Goal:** Verify zero remaining callers, then delete the entire orphaned Vue subsystem.
+
+**Files to delete:**
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/` (directory itself, after files gone)
+
+### Step 1: Search for remaining callers
+
+From `/Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/`, run these 4 patterns (one per file/directory):
+
+```bash
+grep -rn "from.*AsidePanel/GutterBar" frontend/src/
+grep -rn "import.*GutterBar.*from.*AsidePanel" frontend/src/
+grep -rn "<GutterBar" frontend/src/views/
+grep -rn "from.*GutterBar/common" frontend/src/
+```
+
+**Expected:** each pattern returns zero matches OUTSIDE the files being deleted.
+
+The React `GutterBar.tsx` at `frontend/src/react/components/sql-editor/GutterBar.tsx` is the REPLACEMENT — not a caller. Its imports do not match these patterns.
+
+If any pattern matches outside the files to delete, STOP and report BLOCKED with the caller details.
+
+### Step 2: Delete the directory
+
+Run:
+```bash
+rm -rf /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/views/sql-editor/AsidePanel/GutterBar
+```
+
+### Step 3: Verify
+
+Run:
+```bash
+ls /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase/frontend/src/views/sql-editor/AsidePanel/GutterBar 2>&1
+```
+Expected: "No such file or directory".
+
+### Step 4: Type-check
+
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -15
+```
+
+Expected: only the 6 pre-existing `SchemaEditorLite` errors. If a new error like `Cannot find module "./GutterBar"` appears, Task 4's import swap was missed — revisit.
+
+### Step 5: Test suite
+
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: all tests pass.
+
+### Step 6: Stop for user review
+
+Report: "Vue `AsidePanel/GutterBar/` directory deleted (4 files). Type-check clean, tests pass. Ready for commit."
+
+---
+
+## Task 6: Final verification
+
+**Goal:** Full frontend verification suite + user-facing manual verification checklist.
+
+### Step 1: Auto-fix
+
+```bash
+pnpm --dir frontend fix
+```
+
+Expected: no changes or trivial format-only changes to the new files.
+
+### Step 2: Check
+
+```bash
+pnpm --dir frontend check
+```
+
+Expected: pass (ESLint + Biome + React i18n + i18n sort).
+
+### Step 3: Type-check with baseline confirmation
+
+```bash
+pnpm --dir frontend type-check 2>&1 | tail -20
+```
+
+Expected: exactly the 6 pre-existing `SchemaEditorLite` errors. Zero new.
+
+### Step 4: Full test suite
+
+```bash
+pnpm --dir frontend test --run 2>&1 | tail -8
+```
+
+Expected: existing 1160 tests + new Stage 3 tests (7 from `TabItem.test.tsx`, 4 from `GutterBar.test.tsx` = 11 new) → 1171+ pass. Zero failures.
+
+### Step 5: File change summary
+
+Run:
+```bash
+cd /Users/ecmadao/Develop/Bytebase/ecmadao/bytebase
+git status
+```
+
+Expected Stage 3 changes (additional to the Stage 1 + 2 files already in the tree):
+
+**New untracked:**
+- `frontend/src/react/components/sql-editor/TabItem.tsx`
+- `frontend/src/react/components/sql-editor/TabItem.test.tsx`
+- `frontend/src/react/components/sql-editor/GutterBar.tsx`
+- `frontend/src/react/components/sql-editor/GutterBar.test.tsx`
+
+**Modified:**
+- `frontend/src/react/locales/en-US.json`
+- `frontend/src/react/locales/zh-CN.json`
+- `frontend/src/react/locales/es-ES.json`
+- `frontend/src/react/locales/ja-JP.json`
+- `frontend/src/react/locales/vi-VN.json`
+- `frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue`
+
+**Deleted:**
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts`
+- `frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts`
+
+Any other modifications indicate scope creep — flag them.
+
+### Step 6: Manual UX verification — user runs in dev server
+
+Output these checks for the user to run through with `pnpm --dir frontend dev`:
+
+**Visual parity:**
+1. Open the SQL Editor. Left gutter shows: Bytebase logo at top, thin divider, then 3 tab buttons (WORKSHEET/SCHEMA/HISTORY) in medium size (40×40 px). Tab icons match Vue: `FileCode` for Worksheet, `Database` for Schema, `History` for History.
+2. Switch to a project with `allowJustInTimeAccess=true` → 4th tab appears (ACCESS with `ShieldCheck` icon, labeled "Just-In-Time Access" in tooltip).
+3. Active tab has accent-tinted background (`bg-accent/10`) and accent-colored icon. Inactive tabs use default control coloring with hover tint.
+4. Hover each tab → tooltip appears to the right after ~300ms with the correct localized label.
+5. Click the logo at the top → opens the project detail page (or workspace landing when no project context) in a new tab.
+6. Locale switch (English ↔ Chinese) → tooltips update.
+
+**Bridge reactivity (critical):**
+7. From the Welcome screen's "Connect to database" button (Stage 1): click it. Expected: connection panel opens AND the SCHEMA tab in the gutter immediately shows active styling. This confirms `useVueState` subscribes to external writes of `useSQLEditorUIStore().asidePanelTab`.
+8. Click any tab in the gutter → the aside panel's right side content switches to that pane (`WorksheetPane`, `SchemaPane`, etc.). This confirms the store write propagates to Vue consumers that read `asidePanelTab`.
+
+### Step 7: Final report
+
+Report template:
+
+```
+Stage 3 complete.
+
+Summary:
+- 3 i18n keys added to 5 React locale files
+- New TabItem.tsx + 7 tests
+- New GutterBar.tsx + 4 tests
+- AsidePanel.vue swapped to <ReactPageMount page="GutterBar" />
+- Vue AsidePanel/GutterBar/ directory (4 files) deleted
+
+Verification:
+- pnpm fix: clean
+- pnpm check: pass
+- pnpm type-check: baseline only (6 pre-existing SchemaEditorLite errors)
+- pnpm test: 1171+ tests pass, zero regressions
+
+Deferred to user:
+- Manual UX parity (8 items listed above)
+- Bridge reactivity check (first real React-subscribed store read)
+
+Ready for PR.
+```
diff --git a/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-2-design.md b/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-2-design.md
new file mode 100644
index 0000000000..64a0ec01dd
--- /dev/null
+++ b/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-2-design.md
@@ -0,0 +1,285 @@
+# SQL Editor React Migration — Stage 2 Design
+
+**Date:** 2026-04-20
+**Author:** [email protected]
+**Status:** Draft
+
+## 1. Goal & non-goals
+
+**Goal:** Migrate `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue` (33 lines) to React, and establish the `useSQLEditorContext` → Pinia bridge pattern by lifting the context's 6 UI state refs + `editorPanelSize` computed + `handleEditorPanelResize` action into a new `useSQLEditorUIStore`. Vue consumers keep the same `useSQLEditorContext()` API; React leaves use the Pinia store directly.
+
+**Non-goals (Stage 2):**
+- Migrating any `EditorPanel/Panels/*` panel, Monaco, AsidePanel, or TabList.
+- Moving the `Emittery` event bus (`events`) out of `context.ts`.
+- Moving the async actions (`maybeSwitchProject`, `createWorksheet`, `maybeUpdateWorksheet`, `abortAutoSave`) or the auto-save `watchDebounced` composable — they stay in `provideSQLEditorContext`.
+- Changing any of the ~30 Vue files that call `useSQLEditorContext()`.
+
+## 2. Architecture
+
+Create `frontend/src/store/modules/sqlEditor/uiState.ts` exporting `useSQLEditorUIStore` — a Pinia setup-store holding the 6 UI state refs, the `editorPanelSize` computed, and the `handleEditorPanelResize` action. Refactor `frontend/src/views/sql-editor/context.ts` so `provideSQLEditorContext`'s returned `SQLEditorContext` object gets those 7 fields from the store instead of constructing them inline — the shape Vue consumers see stays identical. React leaves skip the inject entirely and call `useSQLEditorUIStore()` directly, subscribing to reactive fields via `useVueState` and writing via direct store mutations.
+
+**Single source of truth:** one Pinia store instance per tab (SQL Editor mount). Vue's `provideSQLEditorContext` wraps the store call; React's `useSQLEditorUIStore()` resolves to the same singleton via Pinia's standard global instance. No state duplication.
+
+**The `aiPanelSize` LocalStorage ref** (currently `useLocalStorage(STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE, 0.3)` inside `provideSQLEditorContext`) moves into the store. The store uses `useLocalStorage` internally to preserve the persistence key and default value — byte-for-byte compatible with existing user preferences.
+
+## 3. The `useSQLEditorUIStore` shape
+
+```ts
+// frontend/src/store/modules/sqlEditor/uiState.ts
+import { useLocalStorage } from "@vueuse/core";
+import { defineStore } from "pinia";
+import { computed, ref } from "vue";
+import type { GetSchemaStringRequest_ObjectType } from "@/types/proto-es/v1/database_service_pb";
+import { STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE } from "@/utils";
+import type { AsidePanelTab } from "@/views/sql-editor/context";
+
+const minimumEditorPanelSize = 0.5;
+
+export const useSQLEditorUIStore = defineStore("sqlEditorUI", () => {
+ const asidePanelTab = ref<AsidePanelTab>("WORKSHEET");
+ const showConnectionPanel = ref(false);
+ const showAIPanel = ref(false);
+ const schemaViewer = ref<
+ | {
+ schema?: string;
+ object?: string;
+ type?: GetSchemaStringRequest_ObjectType;
+ }
+ | undefined
+ >(undefined);
+ const pendingInsertAtCaret = ref<string | undefined>();
+ const highlightAccessGrantName = ref<string | undefined>();
+
+ const aiPanelSize = useLocalStorage(
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ 0.3
+ );
+
+ const editorPanelSize = computed(() => {
+ if (!showAIPanel.value) return { size: 1, max: 1, min: 1 };
+ return {
+ size: Math.max(1 - aiPanelSize.value, minimumEditorPanelSize),
+ max: 0.9,
+ min: minimumEditorPanelSize,
+ };
+ });
+
+ const handleEditorPanelResize = (size: number) => {
+ if (size >= 1) return;
+ aiPanelSize.value = 1 - size;
+ };
+
+ return {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ handleEditorPanelResize,
+ };
+});
+```
+
+**`AsidePanelTab` type:** stays exported from `context.ts` (it's a shared alias). The store imports it from there; the consumer surface doesn't change.
+
+**`STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE`:** already exported from `@/utils`. Same key → same user preference.
+
+**Setup-store vs. options-store:** setup-style matches the project's existing SQL editor stores (e.g. `useSQLEditorStore` in `modules/sqlEditor/editor.ts`, `useSQLEditorTabStore` in `modules/sqlEditor/tab.ts`) and supports `ref` / `computed` composition cleanly. Must return all exposed fields (Pinia requirement).
+
+**Not in the store:** `events` (Emittery), the async action methods, the auto-save `watchDebounced` — all stay in `provideSQLEditorContext` per §1.
+
+## 4. `useSQLEditorContext` wrapper — preserving Vue API
+
+In `frontend/src/views/sql-editor/context.ts`, `provideSQLEditorContext()` currently constructs all 12 fields of the `SQLEditorContext` object inline. The refactor: delegate the 7 state/action fields to the store, keep the remaining 5 inline.
+
+```ts
+// frontend/src/views/sql-editor/context.ts (relevant diff only)
+import { storeToRefs } from "pinia";
+import { useSQLEditorUIStore } from "@/store";
+// ... other imports unchanged ...
+
+export const provideSQLEditorContext = () => {
+ const editorStore = useSQLEditorStore();
+ const tabStore = useSQLEditorTabStore();
+ const projectStore = useProjectV1Store();
+ const projectIamPolicyStore = useProjectIamPolicyStore();
+ const worksheetStore = useWorkSheetStore();
+ const uiStore = useSQLEditorUIStore();
+
+ // Unchanged: async actions, auto-save watcher, Emittery events
+ const maybeSwitchProject = async (projectName: string) => {
+ /* unchanged body */
+ };
+ const maybeUpdateWorksheet = async (/* unchanged */) => {
+ /* unchanged body */
+ };
+ const createWorksheet = async (/* unchanged */) => {
+ /* unchanged body */
+ };
+ let autoSaveController: AbortController | null = null;
+ const abortAutoSave = () => {
+ /* unchanged body */
+ };
+
+ // storeToRefs preserves reactivity when destructuring Pinia setup-stores
+ const {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ } = storeToRefs(uiStore);
+
+ const context: SQLEditorContext = {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ handleEditorPanelResize: uiStore.handleEditorPanelResize,
+ events: new Emittery(),
+ maybeSwitchProject,
+ createWorksheet,
+ maybeUpdateWorksheet,
+ abortAutoSave,
+ };
+
+ // Auto-save watchDebounced — unchanged, still in Vue setup phase
+ watchDebounced(
+ () => currentTab.value?.statement,
+ async () => {
+ /* unchanged body */
+ },
+ { debounce: 2000 }
+ );
+
+ provide(KEY, context);
+ return context;
+};
+```
+
+**Key invariants:**
+
+1. **The returned `SQLEditorContext` shape is unchanged** — same 12 fields, same types. The 30 Vue consumer files keep working without edits.
+2. **`storeToRefs` preserves reactivity.** Destructuring a Pinia setup-store directly loses reactivity; `storeToRefs` keeps the fields as `Ref<T>`, matching the existing `Ref<boolean>` etc. signatures in `SQLEditorContext`.
+3. **The local `aiPanelSize` LocalStorage binding moves with `editorPanelSize` into the store.** The old inline `useLocalStorage` call in `context.ts` is removed — it's now in the store's setup function and initializes lazily on first `useSQLEditorUIStore()` call.
+4. **Pinia store export.** Add `export * from "./uiState"` to `frontend/src/store/modules/sqlEditor/index.ts` following the sibling files' export pattern. The root `store/index.ts` already re-exports everything under `modules/` so no further barrel edits are needed.
+
+## 5. ConnectionHolder migration
+
+### 5.1 New React files
+
+| File | Purpose |
+|---|---|
+| `frontend/src/react/components/sql-editor/ConnectionHolder.tsx` | React leaf replacing the Vue `ConnectionHolder.vue`. Renders a single button (shadcn `Button` variant matching the Vue ghost-primary visual) with a `LinkIcon` and the `sql-editor.connect-to-a-database` label (already in React locales from Stage 1). On click: `useSQLEditorUIStore().showConnectionPanel = true`. |
+| `frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx` | Unit tests: renders button with correct label + icon; click sets `showConnectionPanel` via the store. |
+
+### 5.2 Data flow
+
+| What ConnectionHolder needs | Source | How React gets it |
+|---|---|---|
+| i18n label `sql-editor.connect-to-a-database` | already in React locales (Stage 1) | `useTranslation()` |
+| `LinkIcon` | `lucide-react` | direct import |
+| Open connection panel | `showConnectionPanel.value = true` | `useSQLEditorUIStore().showConnectionPanel = true` — direct Pinia write, NO prop callback needed. This is the whole point of Stage 2's bridge. |
+
+**No `onConnect` prop** — the React leaf reaches directly into the Pinia store. This is the pattern every future `useSQLEditorContext`-consuming React leaf will use.
+
+### 5.3 Vue caller modified
+
+`frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue` — one call site at line 75 (`<ConnectionHolder v-else />`) with the import at line 98 (`import { ConnectionHolder, ... } from "../../EditorCommon"`).
+
+Swap pattern mirrors Stage 1's `StandardPanel.vue` swap:
+
+```vue
+<!-- template -->
+<div v-else class="flex-1 flex flex-col min-h-0">
+ <ReactPageMount page="ConnectionHolder" />
+</div>
+
+<!-- script -->
+import ReactPageMount from "@/react/ReactPageMount.vue";
+// Remove ConnectionHolder from the "../../EditorCommon" named import, keeping
+// the other named imports on that line.
+```
+
+The `flex-1 flex flex-col min-h-0` wrapper div comes from the Stage 1 learning — inline `ReactPageMount` needs a flex-grow wrapper when the Vue original used `h-full` inside a flex column parent. ConnectionHolder's Vue original uses `h-full` so the same wrapper applies.
+
+### 5.4 Vue file deletion
+
+After the swap, verify with `rg ConnectionHolder` scoped to `frontend/src`. Expected remaining references after the swap: only `EditorCommon/index.ts` (the barrel re-export) and the file itself. Remove the `ConnectionHolder` entry from `EditorCommon/index.ts`'s named exports and delete `EditorCommon/ConnectionHolder.vue`.
+
+### 5.5 Mount infrastructure
+
+No new infrastructure — `frontend/src/react/mount.ts`'s `./components/sql-editor/*.tsx` glob from Stage 1 Task 5 already picks up `ConnectionHolder.tsx`.
+
+## 6. Verification & UX parity
+
+### 6.1 Per-leaf verification (run before Stage 2 PR)
+
+- `pnpm --dir frontend fix` — auto-format + lint
+- `pnpm --dir frontend check` — CI-equivalent (ESLint + Biome + React i18n consistency)
+- `pnpm --dir frontend type-check` — Vue + React. No new errors beyond the 6 pre-existing `SchemaEditorLite` ones.
+- `pnpm --dir frontend test` — existing 1152 tests pass, plus new tests:
+ - `sqlEditorUI.test.ts` — store smoke test: initial values, `handleEditorPanelResize` behavior, `editorPanelSize` computed transitions when `showAIPanel` toggles.
+ - `ConnectionHolder.test.tsx` — renders button with correct label and icon; click sets `showConnectionPanel` via the store.
+
+### 6.2 UX parity verification (manual, dev server)
+
+ConnectionHolder renders inside the admin-mode Terminal panel as the v-else fallback — when the terminal panel has no connection.
+
+1. Open SQL Editor, switch current tab to Admin mode, and disconnect → React ConnectionHolder should render: a primary ghost button with a LinkIcon and label "Connect to database".
+2. Button click → connection panel opens — exactly as the Vue original.
+3. Locale switch (English ↔ Chinese) → label updates.
+4. Hover, focus ring, active style should match the Vue naive-ui `type="primary" ghost` visual. Take side-by-side screenshots vs. the pre-change Vue version.
+
+### 6.3 Bridge integration verification (the critical check for Stage 2)
+
+Vue consumers of `useSQLEditorContext()` must still work after the refactor. Specifically verify these read+write flows still function after the lift:
+
+- Opening the connection panel from any Vue caller (e.g. `Welcome`'s `changeConnection` in `StandardPanel.vue`, which sets `showConnectionPanel.value = true` + `asidePanelTab.value = "SCHEMA"`) still opens the panel and switches tabs.
+- AI panel toggle (via the OpenAI button) still animates `editorPanelSize` and persists `aiPanelSize` to LocalStorage.
+- Aside tab switching (Worksheet ↔ Schema ↔ History ↔ Access) still persists via `asidePanelTab`.
+- Schema viewer (when a user clicks a table/view) still opens via `schemaViewer`.
+
+If any of these breaks, the lift broke reactivity — likely a `storeToRefs` miss. Fix before proceeding.
+
+## 7. Out of scope for Stage 2 (explicit deferrals)
+
+- **Migrating the `events` Emittery bus to React consumers.** First needed when a React leaf emits or listens to an editor event — none yet.
+- **Async action bridge** (`maybeSwitchProject`, `createWorksheet`, `maybeUpdateWorksheet`, `abortAutoSave`). These stay Vue-side until a React leaf needs them.
+- **Auto-save composable move.** The `watchDebounced` stays in `provideSQLEditorContext` because it needs Vue setup phase.
+- **Full-lift C3 refactor.** Per-consumer Vue edits come when/if the remaining context fields need bridging.
+- **Vue-in-React mount infrastructure.** Deferred until a panel migration actually requires it.
+
+## 8. Future stage sketch (informational only — each gets its own brainstorm + spec + plan)
+
+| Stage | Scope | Why next |
+|---|---|---|
+| **1 (DONE)** | `Welcome` leaf | Smallest leaf; established React-in-Vue mount + Pinia-from-React + permission-check patterns. |
+| **2 (this spec)** | `ConnectionHolder` leaf + `useSQLEditorUIStore` bridge | Establishes the Pinia bridge for `useSQLEditorContext` UI state; sized to a 33-line write-only consumer. |
+| **3** | `AsidePanel/GutterBar/TabItem.vue` (57 lines) + `GutterBar.vue` (79 lines) | First real READ consumer of `useSQLEditorUIStore().asidePanelTab` from React (reactive subscription, active-state rendering). |
+| **4** | `EditorCommon/DatabaseChooser.vue`, `SaveSheetModal.vue`, similar small `EditorCommon/*` leaves | Continues bridge exercise; each is a single responsibility. |
+| **5** | Small panels under `EditorPanel/Panels/*` (e.g. `TablesPanel.vue` + its `TablesTable.vue`) | Forces the Vue-in-React or cascade-migrate question to be answered. |
+| **6** | Remaining panels, `AsidePanel/*`, `ConnectionPanel/*`, `TabList/*`, `EditorCommon/ResultView/*` | Bulk middle of the migration. |
+| **7** | Monaco wrapper | Behind a stable integration seam per playbook. |
+| **8** | `SQLEditorPage` shell flip | React owns the route. |
+| **9** | Delete dead Vue. | After `rg` confirms zero callers. |
+
+## 9. Practical checklist for Stage 2
+
+- [ ] `frontend/src/store/modules/sqlEditor/uiState.ts` created with `useSQLEditorUIStore` + test.
+- [ ] Store re-exported from `frontend/src/store/modules/sqlEditor/index.ts` (add `export * from "./uiState"` alongside existing sibling exports).
+- [ ] `frontend/src/views/sql-editor/context.ts` refactored — 7 fields delegated to the store via `storeToRefs`; rest unchanged.
+- [ ] `frontend/src/react/components/sql-editor/ConnectionHolder.tsx` + test created.
+- [ ] `frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue` swapped to `<ReactPageMount page="ConnectionHolder" />` inside a `flex-1 flex flex-col min-h-0` wrapper; `ConnectionHolder` removed from the `"../../EditorCommon"` named import.
+- [ ] `frontend/src/views/sql-editor/EditorCommon/index.ts` — `ConnectionHolder` export removed.
+- [ ] `frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue` deleted after `rg ConnectionHolder` confirms zero remaining callers.
+- [ ] `pnpm --dir frontend fix && check && type-check && test` all pass.
+- [ ] Manual UX parity verified: admin terminal no-connection state, click opens connection panel, locale switch, visual style matches ghost-primary naive button.
+- [ ] Bridge integration verified: all existing Vue flows using `showConnectionPanel`, `asidePanelTab`, `showAIPanel`, `editorPanelSize`, `schemaViewer` still work.
diff --git a/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-3-design.md b/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-3-design.md
new file mode 100644
index 0000000000..ae9f90e31f
--- /dev/null
+++ b/docs/superpowers/specs/2026-04-20-sql-editor-react-migration-stage-3-design.md
@@ -0,0 +1,150 @@
+# SQL Editor React Migration — Stage 3 Design
+
+**Date:** 2026-04-20
+**Author:** [email protected]
+**Status:** Draft
+
+## 1. Goal & non-goals
+
+**Goal:** Migrate the `AsidePanel/GutterBar/` subsystem (`GutterBar.vue` 79 lines + `TabItem.vue` 57 lines + `common.ts`) to React as a single unit. Exercises the **READ** direction of the Stage 2 Pinia bridge: `asidePanelTab` is subscribed via `useVueState` for active-state rendering, and written via direct store mutation on click.
+
+**Non-goals (Stage 3):**
+- Migrating `AsidePanel.vue` itself (the parent shell) — stays Vue.
+- Migrating any other aside-panel subtree (`SchemaPane`, `WorksheetPane`, `HistoryPane`, `AccessPane`).
+- Porting the `useButton` composable as a React hook — inline the styling (Q2a).
+- Supporting `small`/`large` sizes — medium-only (no other callers).
+- Porting the custom `DatabaseIcon.vue` to React — use `lucide-react`'s stock `Database` icon (§3.2).
+
+## 2. Architecture
+
+The entire `GutterBar/` subsystem becomes a single React mount. `AsidePanel.vue:8`'s `<GutterBar size="medium" />` swaps to `<ReactPageMount page="GutterBar" />` (no props — size dropped, only caller). The React `GutterBar.tsx` renders an inline `TabItem` React component for each of the 4 tabs. No React-Vue boundary below the mount point.
+
+**State flow:**
+- `asidePanelTab` — READ via `useVueState(() => uiStore.asidePanelTab)` for active class. WRITE via `uiStore.asidePanelTab = target` on click.
+- Project for JIT gate — READ via `useVueState` on a getter that reads both `useSQLEditorStore` and `useProjectV1Store`.
+- Route params — READ via `useVueState(() => router.currentRoute.value.params.project)` for the logo link target.
+
+**Module-level store instances:** Pinia store factories lifted to component top level (per Stage 1 learning — can't call `use*Store()` inside `useVueState` callbacks because of the `react-hooks/rules-of-hooks` lint).
+
+## 3. React file structure
+
+### 3.1 New files
+
+| File | Purpose |
+|---|---|
+| `frontend/src/react/components/sql-editor/GutterBar.tsx` | Container. Renders: logo link (`<a>` wrapping `@/assets/logo-icon.svg`), a thin horizontal separator, then 4 conditionally-rendered `<TabItem>` components. Reads the project from the SQL Editor stores to gate the ACCESS tab. Exports a zero-prop `GutterBar` function. |
+| `frontend/src/react/components/sql-editor/TabItem.tsx` | A single icon+tooltip button. Accepts `{ tab: AsidePanelTab; onClick: () => void }` props. Reads `asidePanelTab` via `useVueState` to compute `isActive`. Applies inline active/inactive classNames to shadcn `Button variant="ghost"`. Tooltip wraps the button using the existing `Tooltip` primitive from `@/react/components/ui/tooltip`. |
+| `frontend/src/react/components/sql-editor/GutterBar.test.tsx` | Tests: renders logo + 3 tabs (WORKSHEET/SCHEMA/HISTORY) when `allowJustInTimeAccess=false`; renders 4 tabs when true; clicking a tab writes `asidePanelTab` on the store. |
+| `frontend/src/react/components/sql-editor/TabItem.test.tsx` | Tests: renders correct icon + label per tab type; applies active className when `asidePanelTab` matches; calls `onClick` on click. |
+
+### 3.2 Icons
+
+Vue uses `FileCodeIcon`, `HistoryIcon`, `ShieldCheckIcon` from `lucide-vue-next` plus a custom `DatabaseIcon` from `@/components/Icon/DatabaseIcon.vue`. React swaps:
+- `FileCodeIcon` → `FileCode` from `lucide-react`
+- `HistoryIcon` → `History` from `lucide-react`
+- `ShieldCheckIcon` → `ShieldCheck` from `lucide-react`
+- `DatabaseIcon` (custom) → **`Database` from `lucide-react`** (per §Q3.2a — YAGNI, don't port the custom icon for one consumer).
+
+### 3.3 Logo link
+
+Vue uses `<router-link :to="linkTarget" target="_blank">` with `linkTarget` computed from `route.params.project`. React approach: render a plain `<a href={href} target="_blank" rel="noopener noreferrer">` where `href` is computed via `router.resolve({ name, params }).href` — matches the existing pattern in `react/components/DashboardSidebar.tsx`.
+
+### 3.4 Tooltip
+
+`@/react/components/ui/tooltip` exposes `<Tooltip content={...} side="right">children</Tooltip>`. Vue uses `side="right" delay={300}`. React: pass `side="right" delayDuration={300}`.
+
+### 3.5 Button styling (Q2a inline)
+
+shadcn `Button variant="ghost"` with a `className` override. Active state: `bg-accent/10 text-accent hover:bg-accent/10 hover:text-accent`. Inactive state: default ghost (`hover:bg-control-bg text-control`). Medium size matches the Vue composable's intent: `h-10 w-10` (40×40 px), icon `size-5` (20 px).
+
+## 4. Data flow & bridge usage
+
+| What GutterBar/TabItem needs | Source | How React gets it |
+|---|---|---|
+| `asidePanelTab` (READ for active state in TabItem) | `useSQLEditorUIStore().asidePanelTab` (Stage 2 store) | `useVueState(() => uiStore.asidePanelTab)` — reactive subscription. |
+| `asidePanelTab` (WRITE on tab click in GutterBar) | Same | Direct assignment `uiStore.asidePanelTab = target` (Pinia setup-store auto-unwraps refs on the store instance). |
+| Project for JIT check | `useSQLEditorStore().project` (string name) → `useProjectV1Store().getProjectByName(name)` | `useVueState(() => projectStore.getProjectByName(editorStore.project))`. Store instances lifted to component top level. |
+| Current route's project param (for logo link) | `router.currentRoute.value.params.project` | `useVueState(() => router.currentRoute.value.params.project as string \| undefined)`. |
+| Route name constants | `PROJECT_V1_ROUTE_DETAIL`, `WORKSPACE_ROUTE_LANDING` | Direct imports from `@/router/dashboard/projectV1` and `@/router/dashboard/workspaceRoutes`. |
+| i18n labels | 4 keys (see §6.3) | `useTranslation()`. |
+
+**Stage 3 is the first real reactive READ of `useSQLEditorUIStore` from React.** The test suite verifies this end-to-end: mocking the store as a plain object and asserting that changing `asidePanelTab` triggers a re-render of TabItem's active class. This validates that `useVueState` on a Pinia setup-store field subscribes correctly.
+
+## 5. Vue caller swap
+
+**One call site:** `frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue`:
+
+- Line 8: `<GutterBar size="medium" />`
+- Line 81: `import GutterBar from "./GutterBar";`
+
+**Swap:**
+- Line 8 → `<ReactPageMount page="GutterBar" />`
+- Line 81 → `import ReactPageMount from "@/react/ReactPageMount.vue";`
+
+**No flex-wrapper div needed** — the Vue GutterBar's root is already `h-full flex flex-col ... p-1` and the parent in `AsidePanel.vue` is a sized container. The `ReactPageMount`'s default `<div class="h-full">` fills the parent directly. If the height collapses during manual UX verification, fall back to the Stage 1 `<div class="flex-1 flex flex-col min-h-0">` wrapper.
+
+**`size="medium"` prop dropped.** Only caller, only value (YAGNI).
+
+## 6. Verification
+
+### 6.1 Per-leaf verification
+
+- `pnpm --dir frontend fix`
+- `pnpm --dir frontend check`
+- `pnpm --dir frontend type-check`
+- `pnpm --dir frontend test` — existing 1160 + new: 3 `TabItem` tests + 3 `GutterBar` tests (~6 new).
+
+### 6.2 UX parity (manual, dev server)
+
+1. Open the SQL Editor. The left gutter shows the logo + 3 tabs (WORKSHEET active by default, SCHEMA, HISTORY) for a project without JIT access.
+2. Switch to a project with `allowJustInTimeAccess = true` → 4th tab (ACCESS / "JIT" label) appears.
+3. Click each tab → aside panel content changes AND the clicked tab gains active-state tint (`bg-accent/10 text-accent`). Inactive tabs keep ghost styling.
+4. Hover each tab → tooltip appears on the right with the correct label.
+5. Click the logo at the top → opens the project detail page in a new tab (or workspace landing if no project context).
+6. Locale switch (English ↔ Chinese) → all labels update without remount.
+
+### 6.3 Bridge reactivity check (critical)
+
+Trigger `asidePanelTab` writes from elsewhere (e.g., Welcome's "Connect to database" button sets `asidePanelTab = "SCHEMA"`). The React GutterBar's SCHEMA tab should immediately gain active styling without any manual re-render. This confirms `useVueState` subscribes to store writes made outside the React subtree.
+
+### 6.4 i18n
+
+4 keys used: `common.schema`, `worksheet.self`, `common.history`, `sql-editor.jit`. Pre-Stage-3 state of React locales:
+
+- `common.schema` — EXISTS
+- `worksheet.self` — MISSING
+- `common.history` — MISSING
+- `sql-editor.jit` — MISSING
+
+All missing keys must be added to all 5 React locales (`en-US`, `zh-CN`, `es-ES`, `ja-JP`, `vi-VN`) with values copied byte-exact from the corresponding Vue locale (`frontend/src/locales/*.json`). `check-react-i18n.mjs` enforces 1:1 parity.
+
+## 7. Out of scope (deferred)
+
+- **Custom `DatabaseIcon.vue` React port.** Using `lucide-react`'s stock `Database` icon (§3.2). Port only when a visual-parity requirement arises.
+- **`AsidePanel.vue` migration.** Shell stays Vue; GutterBar is just a child.
+- **`useButton` React hook.** Inline styling sufficient; only one consumer (§Q2a).
+- **Size variants (small/large).** Medium-only.
+- **Vue-in-React mount infrastructure.** Still deferred until a panel migration requires it.
+
+## 8. Future stage sketch
+
+| Stage | Scope |
+|---|---|
+| 1 ✅ | `Welcome` leaf (React island mount pattern) |
+| 2 ✅ | `ConnectionHolder` + `useSQLEditorUIStore` Pinia bridge |
+| **3 (this spec)** | `GutterBar` + `TabItem` (first reactive READ of store from React) |
+| 4 | Remaining small `EditorCommon/*` leaves (`DatabaseChooser`, `DisconnectedIcon`, `ReadonlyDatasourceHint`, `OpenAIButton`) |
+| 5 | First `EditorPanel/Panels/*` panel — forces Vue-in-React vs cascade-migrate decision |
+| 6+ | Bulk panels, AsidePanel subtrees, ConnectionPanel, TabList, ResultView |
+| 7+ | Monaco wrapper, shell flip, cleanup |
+
+## 9. Practical checklist
+
+- [ ] 3 missing i18n keys (`worksheet.self`, `common.history`, `sql-editor.jit`) added to all 5 React locale files with byte-exact values from Vue locales.
+- [ ] `frontend/src/react/components/sql-editor/TabItem.tsx` + test created.
+- [ ] `frontend/src/react/components/sql-editor/GutterBar.tsx` + test created.
+- [ ] `AsidePanel.vue:8` swapped to `<ReactPageMount page="GutterBar" />`; `./GutterBar` import replaced with `ReactPageMount` import.
+- [ ] Entire Vue `AsidePanel/GutterBar/` directory (`GutterBar.vue`, `TabItem.vue`, `common.ts`, `index.ts`) deleted after `rg` confirms no callers remain.
+- [ ] `pnpm --dir frontend fix && check && type-check && test` all pass.
+- [ ] Manual UX parity verified (5 visual states + logo link + locale switch).
+- [ ] Bridge reactivity verified (external `asidePanelTab` write flips React tab).
diff --git a/frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx b/frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx
new file mode 100644
index 0000000000..9e6e9baf6b
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/ConnectionHolder.test.tsx
@@ -0,0 +1,77 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useSQLEditorUIStore: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+let ConnectionHolder: typeof import("./ConnectionHolder").ConnectionHolder;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ ({ ConnectionHolder } = await import("./ConnectionHolder"));
+});
+
+describe("ConnectionHolder", () => {
+ test("renders the Connect-to-database label", () => {
+ const store = { showConnectionPanel: false };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(
+ <ConnectionHolder />
+ );
+ render();
+ expect(container.textContent).toContain("sql-editor.connect-to-a-database");
+ expect(container.querySelector("button")).not.toBeNull();
+ unmount();
+ });
+
+ test("click sets showConnectionPanel to true on the store", () => {
+ const store = { showConnectionPanel: false };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(
+ <ConnectionHolder />
+ );
+ render();
+ const button = container.querySelector("button");
+ act(() => {
+ button?.click();
+ });
+ expect(store.showConnectionPanel).toBe(true);
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/sql-editor/ConnectionHolder.tsx b/frontend/src/react/components/sql-editor/ConnectionHolder.tsx
new file mode 100644
index 0000000000..c3358f89c6
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/ConnectionHolder.tsx
@@ -0,0 +1,32 @@
+import { LinkIcon } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import { useSQLEditorUIStore } from "@/store";
+
+/**
+ * Replaces frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue.
+ * Rendered as the v-else fallback inside the admin-mode Terminal panel when
+ * there is no active database connection. Click opens the connection panel
+ * via the SQL Editor UI store.
+ */
+export function ConnectionHolder() {
+ const { t } = useTranslation();
+ const uiStore = useSQLEditorUIStore();
+
+ const handleClick = () => {
+ uiStore.showConnectionPanel = true;
+ };
+
+ return (
+ <div className="flex items-center justify-center w-full h-full">
+ <Button
+ variant="outline"
+ className="border-accent text-accent hover:bg-accent/5 hover:text-accent"
+ onClick={handleClick}
+ >
+ <LinkIcon className="size-5" />
+ {t("sql-editor.connect-to-a-database")}
+ </Button>
+ </div>
+ );
+}
diff --git a/frontend/src/react/components/sql-editor/GutterBar.test.tsx b/frontend/src/react/components/sql-editor/GutterBar.test.tsx
new file mode 100644
index 0000000000..b4503e41d6
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/GutterBar.test.tsx
@@ -0,0 +1,145 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useVueState: vi.fn<(getter: () => unknown) => unknown>(),
+ useSQLEditorStore: vi.fn(),
+ useProjectV1Store: vi.fn(),
+ useSQLEditorUIStore: vi.fn(),
+ routerResolve: vi.fn(() => ({ href: "/project/test-project" })),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/react/hooks/useVueState", () => ({
+ useVueState: mocks.useVueState,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorStore: mocks.useSQLEditorStore,
+ useProjectV1Store: mocks.useProjectV1Store,
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+vi.mock("@/router", () => ({
+ router: {
+ resolve: mocks.routerResolve,
+ currentRoute: { value: { params: {} } },
+ },
+}));
+
+vi.mock("@/router/dashboard/projectV1", () => ({
+ PROJECT_V1_ROUTE_DETAIL: "project.detail",
+}));
+
+vi.mock("@/router/dashboard/workspaceRoutes", () => ({
+ WORKSPACE_ROUTE_LANDING: "workspace.landing",
+}));
+
+vi.mock("@/assets/logo-icon.svg", () => ({
+ default: "/assets/logo-icon.svg",
+}));
+
+vi.mock("@/react/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+}));
+
+let GutterBar: typeof import("./GutterBar").GutterBar;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ mocks.useSQLEditorStore.mockReturnValue({ project: "projects/test" });
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ mocks.useSQLEditorUIStore.mockReturnValue({ asidePanelTab: "WORKSHEET" });
+ mocks.routerResolve.mockReturnValue({ href: "/workspace/home" });
+ ({ GutterBar } = await import("./GutterBar"));
+});
+
+describe("GutterBar", () => {
+ test("renders 3 tabs when project does not allow JIT access", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ expect(buttons).toHaveLength(3);
+ unmount();
+ });
+
+ test("renders 4 tabs when project allows JIT access", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: true }),
+ });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ expect(buttons).toHaveLength(4);
+ unmount();
+ });
+
+ test("click writes asidePanelTab on the store", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ const store = { asidePanelTab: "WORKSHEET" as string };
+ mocks.useSQLEditorUIStore.mockReturnValue(store);
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const buttons = container.querySelectorAll("button");
+ act(() => {
+ (buttons[1] as HTMLButtonElement).click();
+ });
+ expect(store.asidePanelTab).toBe("SCHEMA");
+ unmount();
+ });
+
+ test("logo link has target=_blank and rel=noopener noreferrer", () => {
+ mocks.useVueState.mockImplementation((getter) => getter());
+ mocks.useProjectV1Store.mockReturnValue({
+ getProjectByName: () => ({ allowJustInTimeAccess: false }),
+ });
+ mocks.routerResolve.mockReturnValue({ href: "/workspace/home" });
+ const { container, render, unmount } = renderIntoContainer(<GutterBar />);
+ render();
+ const link = container.querySelector("a");
+ expect(link?.getAttribute("href")).toBe("/workspace/home");
+ expect(link?.getAttribute("target")).toBe("_blank");
+ expect(link?.getAttribute("rel")).toBe("noopener noreferrer");
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/sql-editor/GutterBar.tsx b/frontend/src/react/components/sql-editor/GutterBar.tsx
new file mode 100644
index 0000000000..4dd911dc91
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/GutterBar.tsx
@@ -0,0 +1,66 @@
+import logoIcon from "@/assets/logo-icon.svg";
+import { Separator } from "@/react/components/ui/separator";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
+import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
+import {
+ type AsidePanelTab,
+ useProjectV1Store,
+ useSQLEditorStore,
+ useSQLEditorUIStore,
+} from "@/store";
+import { TabItem } from "./TabItem";
+
+/**
+ * Left gutter of the SQL Editor aside panel. Shows the Bytebase logo at
+ * the top and 4 tab buttons (WORKSHEET, SCHEMA, HISTORY, and optionally
+ * ACCESS when the current project allows JIT).
+ *
+ * Replaces frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue.
+ */
+export function GutterBar() {
+ const editorStore = useSQLEditorStore();
+ const projectStore = useProjectV1Store();
+ const uiStore = useSQLEditorUIStore();
+
+ const project = useVueState(() => {
+ const name = editorStore.project;
+ return name ? projectStore.getProjectByName(name) : undefined;
+ });
+
+ const routeProjectParam = useVueState(
+ () => router.currentRoute.value.params.project as string | undefined
+ );
+
+ const logoHref = routeProjectParam
+ ? router.resolve({
+ name: PROJECT_V1_ROUTE_DETAIL,
+ params: { projectId: routeProjectParam },
+ }).href
+ : router.resolve({ name: WORKSPACE_ROUTE_LANDING }).href;
+
+ const handleClickTab = (target: AsidePanelTab) => {
+ uiStore.asidePanelTab = target;
+ };
+
+ return (
+ <div className="h-full flex flex-col items-stretch justify-between overflow-hidden text-sm p-1">
+ <div className="flex flex-col gap-y-1">
+ <div className="flex flex-col justify-center items-center pb-1">
+ <a href={logoHref} target="_blank" rel="noopener noreferrer">
+ <img className="w-9 h-auto" src={logoIcon} alt="Bytebase" />
+ </a>
+ </div>
+ <Separator />
+ <TabItem tab="WORKSHEET" onClick={() => handleClickTab("WORKSHEET")} />
+ <TabItem tab="SCHEMA" onClick={() => handleClickTab("SCHEMA")} />
+ <TabItem tab="HISTORY" onClick={() => handleClickTab("HISTORY")} />
+ {project?.allowJustInTimeAccess && (
+ <TabItem tab="ACCESS" onClick={() => handleClickTab("ACCESS")} />
+ )}
+ </div>
+ <div className="flex flex-col justify-end items-center" />
+ </div>
+ );
+}
diff --git a/frontend/src/react/components/sql-editor/TabItem.test.tsx b/frontend/src/react/components/sql-editor/TabItem.test.tsx
new file mode 100644
index 0000000000..6800ac79af
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/TabItem.test.tsx
@@ -0,0 +1,134 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ useTranslation: vi.fn(() => ({ t: (key: string) => key })),
+ useVueState: vi.fn<(getter: () => unknown) => unknown>(),
+ useSQLEditorUIStore: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: mocks.useTranslation,
+}));
+
+vi.mock("@/react/hooks/useVueState", () => ({
+ useVueState: mocks.useVueState,
+}));
+
+vi.mock("@/store", () => ({
+ useSQLEditorUIStore: mocks.useSQLEditorUIStore,
+}));
+
+vi.mock("@/react/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+}));
+
+let TabItem: typeof import("./TabItem").TabItem;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ const root = createRoot(container);
+ document.body.appendChild(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () => {
+ act(() => {
+ root.unmount();
+ });
+ container.remove();
+ },
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ mocks.useVueState.mockReturnValue(false);
+ mocks.useSQLEditorUIStore.mockReturnValue({ asidePanelTab: "WORKSHEET" });
+ ({ TabItem } = await import("./TabItem"));
+});
+
+describe("TabItem", () => {
+ test("renders label for WORKSHEET tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="WORKSHEET" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("worksheet.self");
+ expect(container.querySelector("button")).not.toBeNull();
+ unmount();
+ });
+
+ test("renders label for SCHEMA tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("common.schema");
+ unmount();
+ });
+
+ test("renders label for HISTORY tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="HISTORY" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("common.history");
+ unmount();
+ });
+
+ test("renders label for ACCESS tab", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="ACCESS" onClick={() => {}} />
+ );
+ render();
+ expect(container.textContent).toContain("sql-editor.jit");
+ unmount();
+ });
+
+ test("applies active class when asidePanelTab matches", () => {
+ mocks.useVueState.mockReturnValue(true);
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ const button = container.querySelector("button");
+ expect(button?.className).toContain("bg-accent/10");
+ expect(button?.className).toContain("text-accent");
+ unmount();
+ });
+
+ test("does NOT apply active class when asidePanelTab differs", () => {
+ mocks.useVueState.mockReturnValue(false);
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={() => {}} />
+ );
+ render();
+ const button = container.querySelector("button");
+ expect(button?.className).not.toContain("bg-accent/10");
+ unmount();
+ });
+
+ test("calls onClick when button is clicked", () => {
+ const handler = vi.fn();
+ const { container, render, unmount } = renderIntoContainer(
+ <TabItem tab="SCHEMA" onClick={handler} />
+ );
+ render();
+ act(() => {
+ container.querySelector("button")?.click();
+ });
+ expect(handler).toHaveBeenCalledTimes(1);
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/sql-editor/TabItem.tsx b/frontend/src/react/components/sql-editor/TabItem.tsx
new file mode 100644
index 0000000000..6bde71012a
--- /dev/null
+++ b/frontend/src/react/components/sql-editor/TabItem.tsx
@@ -0,0 +1,58 @@
+import { Database, FileCode, History, ShieldCheck } from "lucide-react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/react/components/ui/button";
+import { Tooltip } from "@/react/components/ui/tooltip";
+import { useVueState } from "@/react/hooks/useVueState";
+import { cn } from "@/react/lib/utils";
+import type { AsidePanelTab } from "@/store";
+import { useSQLEditorUIStore } from "@/store";
+
+type TabItemProps = {
+ readonly tab: AsidePanelTab;
+ readonly onClick: () => void;
+};
+
+const iconByTab = {
+ WORKSHEET: FileCode,
+ SCHEMA: Database,
+ HISTORY: History,
+ ACCESS: ShieldCheck,
+} as const;
+
+/**
+ * Single tab button in the SQL Editor aside panel's left gutter.
+ * Replaces frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue.
+ * Active state reflects useSQLEditorUIStore().asidePanelTab; click handler
+ * is supplied by the GutterBar parent (which writes the store).
+ */
+export function TabItem({ tab, onClick }: TabItemProps) {
+ const { t } = useTranslation();
+ const uiStore = useSQLEditorUIStore();
+ const isActive = useVueState(() => uiStore.asidePanelTab === tab);
+
+ const Icon = iconByTab[tab];
+ const labelByTab = {
+ WORKSHEET: t("worksheet.self"),
+ SCHEMA: t("common.schema"),
+ HISTORY: t("common.history"),
+ ACCESS: t("sql-editor.jit"),
+ } as const;
+ const label = labelByTab[tab];
+
+ return (
+ <Tooltip content={label} side="right" delayDuration={300}>
+ <Button
+ variant="ghost"
+ className={cn(
+ "size-10 p-0",
+ isActive &&
+ "bg-accent/10 text-accent hover:bg-accent/10 hover:text-accent"
+ )}
+ onClick={onClick}
+ >
+ <Icon className="size-5" />
+ <span className="sr-only">{label}</span>
+ </Button>
+ </Tooltip>
+ );
+}
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 2dd9f860a6..303ce600dd 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -223,6 +223,7 @@
"general": "General",
"group": "Group",
"groups": "Groups",
+ "history": "History",
"home": "Home",
"id": "ID",
"import": "Import",
@@ -2169,6 +2170,7 @@
"expired": "Expired",
"format-sql": "Format SQL",
"grant-type-unmask": "Unmask",
+ "jit": "Just-In-Time Access",
"revoke-access": "Revoke",
"revoke-confirm": "Are you sure you want to revoke this access grant?",
"self": "SQL Editor",
@@ -3155,5 +3157,8 @@
"description": "Copy the code and enter it in your TOTP app manually.",
"self": "Your two-factor secret"
}
+ },
+ "worksheet": {
+ "self": "Worksheet"
}
}
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index d6ff429a34..08eca25c33 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -223,6 +223,7 @@
"general": "General",
"group": "Grupo",
"groups": "Grupos",
+ "history": "Historial",
"home": "Inicio",
"id": "ID",
"import": "Importar",
@@ -2169,6 +2170,7 @@
"expired": "Expired",
"format-sql": "Format SQL",
"grant-type-unmask": "Unmask",
+ "jit": "Just-In-Time Access",
"revoke-access": "Revoke",
"revoke-confirm": "Are you sure you want to revoke this access grant?",
"self": "Editor de SQL",
@@ -3155,5 +3157,8 @@
"description": "Copie el código e ingréselo manualmente en su aplicación TOTP.",
"self": "Su secreto de dos factores"
}
+ },
+ "worksheet": {
+ "self": "Hoja de trabajo"
}
}
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 005870807c..e155cd164f 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -223,6 +223,7 @@
"general": "全般",
"group": "グループ",
"groups": "グループ",
+ "history": "履歴",
"home": "ホームページ",
"id": "ID",
"import": "インポート",
@@ -2169,6 +2170,7 @@
"expired": "Expired",
"format-sql": "Format SQL",
"grant-type-unmask": "Unmask",
+ "jit": "Just-In-Time Access",
"revoke-access": "Revoke",
"revoke-confirm": "Are you sure you want to revoke this access grant?",
"self": "SQLエディタ",
@@ -3155,5 +3157,8 @@
"description": "キーをコピーし、アプリケーションに手動で入力します。",
"self": "二要素認証キー"
}
+ },
+ "worksheet": {
+ "self": "ワークシート"
}
}
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index e46c48e85d..3292d54a79 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -223,6 +223,7 @@
"general": "Chung",
"group": "Nhóm",
"groups": "Nhóm",
+ "history": "Lịch sử",
"home": "Trang chủ",
"id": "ID",
"import": "Nhập",
@@ -2169,6 +2170,7 @@
"expired": "Expired",
"format-sql": "Format SQL",
"grant-type-unmask": "Unmask",
+ "jit": "Just-In-Time Access",
"revoke-access": "Revoke",
"revoke-confirm": "Are you sure you want to revoke this access grant?",
"self": "Trình soạn thảo SQL",
@@ -3155,5 +3157,8 @@
"description": "Sao chép mã và nhập nó vào ứng dụng TOTP của bạn theo cách thủ công.",
"self": "Bí mật hai yếu tố của bạn"
}
+ },
+ "worksheet": {
+ "self": "Bảng tính"
}
}
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index a088651b34..a3de8502ea 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -223,6 +223,7 @@
"general": "通用",
"group": "组",
"groups": "分组",
+ "history": "历史记录",
"home": "主页",
"id": "ID",
"import": "导入",
@@ -2169,6 +2170,7 @@
"expired": "已过期",
"format-sql": "格式化 SQL",
"grant-type-unmask": "脱敏豁免",
+ "jit": "即时访问",
"revoke-access": "撤销",
"revoke-confirm": "确定要撤销此访问授权吗?",
"self": "SQL 编辑器",
@@ -3155,5 +3157,8 @@
"description": "复制密钥并在您的应用程序中手动输入。",
"self": "双重认证密钥"
}
+ },
+ "worksheet": {
+ "self": "工作表"
}
}
diff --git a/frontend/src/store/modules/sqlEditor/index.ts b/frontend/src/store/modules/sqlEditor/index.ts
index 8f62bc4914..d3bb1d239a 100644
--- a/frontend/src/store/modules/sqlEditor/index.ts
+++ b/frontend/src/store/modules/sqlEditor/index.ts
@@ -2,4 +2,5 @@ export * from "./editor";
export * from "./tab";
export * from "./tree";
export * from "./queryHistory";
+export * from "./uiState";
export * from "./webTerminal";
diff --git a/frontend/src/store/modules/sqlEditor/uiState.test.ts b/frontend/src/store/modules/sqlEditor/uiState.test.ts
new file mode 100644
index 0000000000..8de6a09992
--- /dev/null
+++ b/frontend/src/store/modules/sqlEditor/uiState.test.ts
@@ -0,0 +1,59 @@
+import { createPinia, setActivePinia } from "pinia";
+import { beforeEach, describe, expect, test } from "vitest";
+import { STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE } from "@/utils/storage-keys";
+
+let useSQLEditorUIStore: typeof import("./uiState").useSQLEditorUIStore;
+
+beforeEach(async () => {
+ localStorage.clear();
+ setActivePinia(createPinia());
+ ({ useSQLEditorUIStore } = await import("./uiState"));
+});
+
+describe("useSQLEditorUIStore", () => {
+ test("initial state has documented defaults", () => {
+ const store = useSQLEditorUIStore();
+ expect(store.asidePanelTab).toBe("WORKSHEET");
+ expect(store.showConnectionPanel).toBe(false);
+ expect(store.showAIPanel).toBe(false);
+ expect(store.schemaViewer).toBeUndefined();
+ expect(store.pendingInsertAtCaret).toBeUndefined();
+ expect(store.highlightAccessGrantName).toBeUndefined();
+ });
+
+ test("editorPanelSize returns full-width when AI panel is hidden", () => {
+ const store = useSQLEditorUIStore();
+ expect(store.showAIPanel).toBe(false);
+ expect(store.editorPanelSize).toEqual({ size: 1, max: 1, min: 1 });
+ });
+
+ test("editorPanelSize returns clamped split when AI panel is shown", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ expect(store.editorPanelSize).toEqual({ size: 0.7, max: 0.9, min: 0.5 });
+ });
+
+ test("editorPanelSize clamps to minimum 0.5 when AI panel is huge", () => {
+ localStorage.setItem(
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ JSON.stringify(0.8)
+ );
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ expect(store.editorPanelSize.size).toBe(0.5);
+ });
+
+ test("handleEditorPanelResize writes complement to aiPanelSize LocalStorage", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ store.handleEditorPanelResize(0.6);
+ expect(store.editorPanelSize.size).toBe(0.6);
+ });
+
+ test("handleEditorPanelResize no-ops when size is >= 1", () => {
+ const store = useSQLEditorUIStore();
+ store.showAIPanel = true;
+ store.handleEditorPanelResize(1);
+ expect(store.editorPanelSize.size).toBe(0.7);
+ });
+});
diff --git a/frontend/src/store/modules/sqlEditor/uiState.ts b/frontend/src/store/modules/sqlEditor/uiState.ts
new file mode 100644
index 0000000000..83f0ba756e
--- /dev/null
+++ b/frontend/src/store/modules/sqlEditor/uiState.ts
@@ -0,0 +1,65 @@
+import { useLocalStorage } from "@vueuse/core";
+import { defineStore } from "pinia";
+import { computed, ref } from "vue";
+import type { GetSchemaStringRequest_ObjectType } from "@/types/proto-es/v1/database_service_pb";
+import { STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE } from "@/utils/storage-keys";
+
+export type AsidePanelTab = "SCHEMA" | "WORKSHEET" | "HISTORY" | "ACCESS";
+
+const minimumEditorPanelSize = 0.5;
+
+/**
+ * UI state for the SQL Editor shell.
+ *
+ * Extracted from `useSQLEditorContext` so React leaves can access the same
+ * reactive state that Vue consumers read via inject. Vue's
+ * `useSQLEditorContext()` wraps this store via `storeToRefs` and preserves
+ * its existing API shape.
+ */
+export const useSQLEditorUIStore = defineStore("sqlEditorUI", () => {
+ const asidePanelTab = ref<AsidePanelTab>("WORKSHEET");
+ const showConnectionPanel = ref(false);
+ const showAIPanel = ref(false);
+ const schemaViewer = ref<
+ | {
+ schema?: string;
+ object?: string;
+ type?: GetSchemaStringRequest_ObjectType;
+ }
+ | undefined
+ >(undefined);
+ const pendingInsertAtCaret = ref<string | undefined>();
+ const highlightAccessGrantName = ref<string | undefined>();
+
+ const aiPanelSize = useLocalStorage(
+ STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
+ 0.3
+ );
+
+ const editorPanelSize = computed(() => {
+ if (!showAIPanel.value) {
+ return { size: 1, max: 1, min: 1 };
+ }
+ return {
+ size: Math.max(1 - aiPanelSize.value, minimumEditorPanelSize),
+ max: 0.9,
+ min: minimumEditorPanelSize,
+ };
+ });
+
+ const handleEditorPanelResize = (size: number) => {
+ if (size >= 1) return;
+ aiPanelSize.value = 1 - size;
+ };
+
+ return {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ handleEditorPanelResize,
+ };
+});
diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
index ca9d4edc48..7a4d7a7dc6 100644
--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
@@ -5,7 +5,7 @@
:data-width="containerWidth"
>
<div class="h-full border-r shrink-0">
- <GutterBar size="medium" />
+ <ReactPageMount page="GutterBar" />
</div>
<div
v-if="asidePanelTab === 'SCHEMA' && !isDisconnected"
@@ -67,6 +67,7 @@ import { useElementSize } from "@vueuse/core";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { ProjectSelect } from "@/components/v2";
+import ReactPageMount from "@/react/ReactPageMount.vue";
import { PROJECT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import {
useActuatorV1Store,
@@ -78,7 +79,6 @@ import { hasProjectPermissionV2, hasWorkspacePermissionV2 } from "@/utils";
import { useSQLEditorContext } from "../context";
import AccessPane from "./AccessPane";
import ActionBar from "./ActionBar";
-import GutterBar from "./GutterBar";
import HistoryPane from "./HistoryPane";
import SchemaPane from "./SchemaPane";
import WorksheetPane from "./WorksheetPane";
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
deleted file mode 100644
index 9b5b88e8fc..0000000000
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
+++ /dev/null
@@ -1,79 +0,0 @@
-<template>
- <div
- ref="containerRef"
- class="h-full flex flex-col items-stretch justify-between overflow-hidden text-sm p-1"
- >
- <div class="flex flex-col gap-y-1">
- <div class="flex flex-col justify-center items-center pb-1">
- <router-link target="_blank" rel="noopener noreferrer" :to="linkTarget">
- <img
- class="w-9 h-auto"
- src="@/assets/logo-icon.svg"
- alt="Bytebase"
- />
- </router-link>
- </div>
- <div class="w-full h-0 border-t" />
- <TabItem
- tab="WORKSHEET"
- :size="size"
- @click="handleClickTab('WORKSHEET')"
- />
- <TabItem tab="SCHEMA" :size="size" @click="handleClickTab('SCHEMA')" />
- <TabItem tab="HISTORY" :size="size" @click="handleClickTab('HISTORY')" />
- <TabItem v-if="project.allowJustInTimeAccess" tab="ACCESS" :size="size" @click="handleClickTab('ACCESS')" />
- </div>
-
- <div class="flex flex-col justify-end items-center"></div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import { useRoute } from "vue-router";
-import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
-import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
-import { useProjectV1Store, useSQLEditorStore } from "@/store";
-import { type AsidePanelTab, useSQLEditorContext } from "../../context";
-import { type Size } from "./common";
-import TabItem from "./TabItem.vue";
-
-withDefaults(
- defineProps<{
- size?: Size;
- }>(),
- {
- size: "medium",
- }
-);
-
-const route = useRoute();
-const { asidePanelTab } = useSQLEditorContext();
-const editorStore = useSQLEditorStore();
-const projectStore = useProjectV1Store();
-
-const project = computed(() =>
- projectStore.getProjectByName(editorStore.project)
-);
-
-const linkTarget = computed(() => {
- // If we have a project in the route, navigate to that project's detail page
- const project = route.params.project as string | undefined;
- if (project) {
- return {
- name: PROJECT_V1_ROUTE_DETAIL,
- params: {
- projectId: project,
- },
- };
- }
- // Otherwise fallback to workspace landing
- return {
- name: WORKSPACE_ROUTE_LANDING,
- };
-});
-
-const handleClickTab = (target: AsidePanelTab) => {
- asidePanelTab.value = target;
-};
-</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
deleted file mode 100644
index 57025ae39a..0000000000
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-<template>
- <NTooltip placement="right" :delay="300" :disabled="disabled">
- <template #trigger>
- <NButton :style="buttonStyle" v-bind="{ ...buttonProps, ...$attrs }">
- <template #icon>
- <FileCodeIcon v-if="tab === 'WORKSHEET'" />
- <DatabaseIcon v-else-if="tab === 'SCHEMA'" />
- <HistoryIcon v-else-if="tab === 'HISTORY'" />
- <ShieldCheckIcon v-else-if="tab === 'ACCESS'" />
- </template>
- </NButton>
- </template>
- <template #default>
- {{ text }}
- </template>
- </NTooltip>
-</template>
-
-<script setup lang="ts">
-import { FileCodeIcon, HistoryIcon, ShieldCheckIcon } from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { computed, toRef } from "vue";
-import { useI18n } from "vue-i18n";
-import DatabaseIcon from "@/components/Icon/DatabaseIcon.vue";
-import { type AsidePanelTab, useSQLEditorContext } from "../../context";
-import { type Size, useButton } from "./common";
-
-const props = defineProps<{
- tab: AsidePanelTab;
- size: Size;
- disabled?: boolean;
-}>();
-
-const { t } = useI18n();
-const { asidePanelTab } = useSQLEditorContext();
-
-const { props: buttonProps, style: buttonStyle } = useButton({
- size: toRef(props, "size"),
- active: computed(() => props.tab === asidePanelTab.value),
- disabled: toRef(props, "disabled"),
-});
-
-const text = computed(() => {
- switch (props.tab) {
- case "SCHEMA":
- return t("common.schema");
- case "WORKSHEET":
- return t("worksheet.self");
- case "HISTORY":
- return t("common.history");
- case "ACCESS":
- return t("sql-editor.jit");
- }
- console.assert(false, "should never reach this line");
- return "";
-});
-</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts b/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts
deleted file mode 100644
index 629cec786d..0000000000
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/common.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import type { ButtonProps } from "naive-ui";
-import { computed, type MaybeRef, unref } from "vue";
-
-export type Size = "small" | "medium" | "large";
-
-export const useButton = (options: {
- size: MaybeRef<Size>;
- active: MaybeRef<boolean>;
- disabled: MaybeRef<boolean>;
-}) => {
- const props = computed(() => {
- const props: ButtonProps = {
- tag: "div",
- disabled: unref(options.disabled),
- size: unref(options.size),
- };
- if (unref(options.active)) {
- props.secondary = true;
- props.type = "primary";
- } else {
- props.quaternary = true;
- props.type = "default";
- }
- props.disabled = unref(options.disabled);
-
- return props;
- });
- const style = computed(() => {
- const parts: string[] = [];
- const size = unref(options.size);
-
- if (size === "small") {
- parts.push("--n-height: 32px");
- parts.push("--n-padding: 4px 8px");
- parts.push("--n-icon-size: 16px");
- } else if (size === "medium") {
- parts.push("--n-height: 40px");
- parts.push("--n-padding: 6px 10px");
- parts.push("--n-icon-size: 20px");
- } else if (size === "large") {
- parts.push("--n-height: 48px");
- parts.push("--n-padding: 12px 12px");
- parts.push("--n-icon-size: 24px");
- }
- return parts.join("; ");
- });
- return { props, style };
-};
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts b/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts
deleted file mode 100644
index 0873d44b9a..0000000000
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import GutterBar from "./GutterBar.vue";
-
-export * from "./common";
-export default GutterBar;
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
deleted file mode 100644
index 20951ed622..0000000000
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
+++ /dev/null
@@ -1,33 +0,0 @@
-<template>
- <div class="flex items-center justify-center w-full h-full">
- <div class="flex items-start text-info cursor-pointer">
- <NButton
- type="primary"
- ghost
- style="
- --n-color-hover: rgb(var(--color-accent) / 0.05);
- --n-color-pressed: rgb(var(--color-accent) / 0.05);
- --n-color-focus: rgb(var(--color-accent) / 0.05);
- "
- @click="changeConnection"
- >
- <template #icon>
- <LinkIcon class="w-5 h-5" />
- </template>
- {{ $t("sql-editor.connect-to-a-database") }}
- </NButton>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { LinkIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { useSQLEditorContext } from "../context";
-
-const { showConnectionPanel } = useSQLEditorContext();
-
-const changeConnection = () => {
- showConnectionPanel.value = true;
-};
-</script>
diff --git a/frontend/src/views/sql-editor/EditorCommon/index.ts b/frontend/src/views/sql-editor/EditorCommon/index.ts
index b122293309..d31005d463 100644
--- a/frontend/src/views/sql-editor/EditorCommon/index.ts
+++ b/frontend/src/views/sql-editor/EditorCommon/index.ts
@@ -1,4 +1,3 @@
-import ConnectionHolder from "./ConnectionHolder.vue";
import DisconnectedIcon from "./DisconnectedIcon.vue";
import EditorAction from "./EditorAction.vue";
import ExecutingHintModal from "./ExecutingHintModal.vue";
@@ -9,7 +8,6 @@ import SharePopover from "./SharePopover.vue";
import SheetConnectionIcon from "./SheetConnectionIcon.vue";
export {
- ConnectionHolder,
EditorAction,
ExecutingHintModal,
SaveSheetModal,
diff --git a/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue b/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue
index 0189d89afc..381e5e91f4 100644
--- a/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/TerminalPanel/TerminalPanel.vue
@@ -72,7 +72,9 @@
</div>
</div>
</div>
- <ConnectionHolder v-else />
+ <div v-else class="flex-1 flex flex-col min-h-0">
+ <ReactPageMount page="ConnectionHolder" />
+ </div>
</div>
</template>
@@ -88,17 +90,14 @@ import {
} from "vue";
import { BBSpin } from "@/bbkit";
import type { IStandaloneCodeEditor } from "@/components/MonacoEditor";
+import ReactPageMount from "@/react/ReactPageMount.vue";
import {
useDatabaseV1Store,
useSQLEditorTabStore,
useWebTerminalStore,
} from "@/store";
import type { SQLEditorQueryParams, WebTerminalQueryItemV1 } from "@/types";
-import {
- ConnectionHolder,
- EditorAction,
- ResultViewV1,
-} from "../../EditorCommon";
+import { EditorAction, ResultViewV1 } from "../../EditorCommon";
import { useHistory } from "./useHistory";
const CompactSQLEditor = defineAsyncComponent(
diff --git a/frontend/src/views/sql-editor/context.ts b/frontend/src/views/sql-editor/context.ts
index f26ec19cda..d4e44c3824 100644
--- a/frontend/src/views/sql-editor/context.ts
+++ b/frontend/src/views/sql-editor/context.ts
@@ -1,17 +1,18 @@
import { create } from "@bufbuild/protobuf";
-import { useLocalStorage, watchDebounced } from "@vueuse/core";
+import { watchDebounced } from "@vueuse/core";
import Emittery from "emittery";
import { isUndefined } from "lodash-es";
import { type IRange } from "monaco-editor";
import { storeToRefs } from "pinia";
import type { ComputedRef, InjectionKey, Ref } from "vue";
-import { computed, inject, nextTick, provide, ref } from "vue";
+import { inject, nextTick, provide } from "vue";
import {
pushNotification,
useProjectIamPolicyStore,
useProjectV1Store,
useSQLEditorStore,
useSQLEditorTabStore,
+ useSQLEditorUIStore,
useWorkSheetStore,
} from "@/store";
import type { SQLEditorTab } from "@/types";
@@ -26,7 +27,6 @@ import {
isSimilarDefaultSQLEditorTabTitle,
isWorksheetWritableV1,
NEW_WORKSHEET_TITLE,
- STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
suggestedTabTitleForSQLEditorConnection,
} from "@/utils";
import { openWorksheetByName } from "@/views/sql-editor/Sheet";
@@ -39,8 +39,6 @@ export const ASIDE_PANEL_TABS = [
] as const;
export type AsidePanelTab = (typeof ASIDE_PANEL_TABS)[number];
-const minimumEditorPanelSize = 0.5;
-
export type SQLEditorEvents = Emittery<{
"save-sheet": {
tab: SQLEditorTab;
@@ -125,27 +123,16 @@ export const provideSQLEditorContext = () => {
const projectStore = useProjectV1Store();
const projectIamPolicyStore = useProjectIamPolicyStore();
const worksheetStore = useWorkSheetStore();
- const showConnectionPanel = ref(false);
-
- const aiPanelSize = useLocalStorage(
- STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE,
- 0.3 /* panel size should in [0.1, 1-minimumEditorPanelSize]*/
- );
- const showAIPanel = ref(false);
- const editorPanelSize = computed(() => {
- if (!showAIPanel.value) {
- return {
- size: 1,
- max: 1,
- min: 1,
- };
- }
- return {
- size: Math.max(1 - aiPanelSize.value, minimumEditorPanelSize),
- max: 0.9,
- min: minimumEditorPanelSize,
- };
- });
+ const uiStore = useSQLEditorUIStore();
+ const {
+ asidePanelTab,
+ showConnectionPanel,
+ showAIPanel,
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
+ editorPanelSize,
+ } = storeToRefs(uiStore);
const maybeUpdateWorksheet = async ({
tabId,
@@ -302,22 +289,17 @@ export const provideSQLEditorContext = () => {
};
const context: SQLEditorContext = {
- asidePanelTab: ref("WORKSHEET"),
+ asidePanelTab,
showConnectionPanel,
showAIPanel,
editorPanelSize,
- schemaViewer: ref(undefined),
- pendingInsertAtCaret: ref(),
- highlightAccessGrantName: ref<string | undefined>(),
+ schemaViewer,
+ pendingInsertAtCaret,
+ highlightAccessGrantName,
events: new Emittery(),
maybeSwitchProject,
- handleEditorPanelResize: (size: number) => {
- if (size >= 1) {
- return;
- }
- aiPanelSize.value = 1 - size;
- },
+ handleEditorPanelResize: uiStore.handleEditorPanelResize,
createWorksheet,
maybeUpdateWorksheet,
abortAutoSave,