Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(frontend): introduce sibling React app, empty /components/ (#20353)
boojack5880e26cb366
diff --git a/docs/superpowers/plans/2026-05-14-react-app-and-empty-components.md b/docs/superpowers/plans/2026-05-14-react-app-and-empty-components.mdnew file mode 100644index 0000000000..a53c247bec--- /dev/null+++ b/docs/superpowers/plans/2026-05-14-react-app-and-empty-components.md@@ -0,0 +1,1128 @@+# Introduce React App + Empty `frontend/src/components/` — 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:** Stand up a sibling React app in `frontend/index.html` to host `AgentWindow` and `SessionExpiredSurface`, then relocate every remaining file under `frontend/src/components/` to its natural home and delete the directory.++**Architecture:** New `<div id="react-app">` in `index.html` mounted from `src/main.ts` after the Vue app. Three new files under `src/react/app/` (`ReactApp.tsx`, `SessionExpiredSurfaceGate.tsx`, `mount.tsx`). Both initial residents already `createPortal` to `getLayerRoot(...)`, so the React app has no visible DOM of its own. Validation is batched at the end per repo convention.++**Tech Stack:** Vue 3 (host), React 18, vue-i18n + react-i18next, Vite, Pinia, Base UI, Tailwind v4.++**Companion spec:** [`docs/superpowers/specs/2026-05-14-react-app-and-empty-components-design.md`](../specs/2026-05-14-react-app-and-empty-components-design.md)++**Validation cadence:** Per repo memory — agents skip per-file `check` / `type-check` / `test`. Validation runs once at the end of the PR (Task 18). Each commit just needs the diff to be coherent.++---++## File Map++**Create:**+- `frontend/src/react/app/ReactApp.tsx`+- `frontend/src/react/app/SessionExpiredSurfaceGate.tsx`+- `frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx`+- `frontend/src/react/app/mount.tsx`+- `frontend/src/utils/v1/member.ts`+- `frontend/src/types/v1/member.ts`+- `frontend/src/utils/v1/databaseResource.ts`+- `frontend/src/utils/v1/issue/task.ts`+- `frontend/src/bbkit/OverlayStackManager.vue` (moved from `src/components/misc/`)++**Modify:**+- `frontend/index.html` — add `<div id="react-app">`+- `frontend/src/main.ts` — call `mountReactApp("#react-app")` after the Vue app mounts+- `frontend/src/App.vue` — update import path for `OverlayStackManager`+- `frontend/src/AuthContext.vue` — remove `<SessionExpiredSurfaceMount>` element + import+- `frontend/src/layouts/BodyLayout.vue` — remove `<AgentWindowMount />` element + import+- `frontend/src/layouts/layout-bridge.test.ts` — drop `vi.mock("@/components/AgentWindowMount.vue", ...)`+- `frontend/src/shell-bridge.test.ts` — update `vi.mock` path for `OverlayStackManager`+- `frontend/src/bbkit/BBModal.vue` — update import path for `useOverlayStack`+- `frontend/src/utils/v1/instance.ts` — append `defaultPortForEngine` + `EngineIconPath`+- `frontend/src/utils/v1/issue/rollout.ts` — update import path for `TASK_STATUS_FILTERS`+- `frontend/src/react/components/EngineIcon.tsx` — update import path+- `frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx` — update import path+- `frontend/src/react/components/sql-editor/RequestQueryButton.tsx` — update import path+- `frontend/src/react/pages/settings/MembersPage.tsx` — update three import paths+- 8 `*.test.tsx` files under `frontend/src/react/components/sql-editor/` and `frontend/src/react/pages/project/export-center/` — update `vi.mock` paths for `InstanceForm/constants`++**Delete:**+- `frontend/src/components/AdvancedSearch/types.ts` (orphan)+- `frontend/src/components/AgentWindowMount.vue`+- `frontend/src/components/SessionExpiredSurfaceMount.vue`+- `frontend/src/components/misc/OverlayStackManager.vue` (after move)+- `frontend/src/components/InstanceForm/constants.ts` (after merge)+- `frontend/src/components/Member/utils.ts` (after merge)+- `frontend/src/components/Member/projectRoleBindings.ts` (after merge)+- `frontend/src/components/Member/types.ts` (after move)+- `frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.ts` (after move)+- `frontend/src/components/RolloutV1/constants/task.ts` (after move)+- `frontend/src/components/` (entire directory at the end)++---++## Task 1: Add the React app mount point to `index.html`++**Files:**+- Modify: `frontend/index.html`++- [ ] **Step 1: Add `<div id="react-app">` after `<div id="app">`**++Edit `frontend/index.html`. Find:++```html+ <div id="app"></div>+ <!-- React Toaster root: hosts the persistent toast renderer.+ Visually empty; toasts portal into getLayerRoot("overlay"). -->+ <div id="bb-toaster-root"></div>+```++Replace with:++```html+ <div id="app"></div>+ <!-- React App root: hosts long-lived React surfaces that portal globally+ (AgentWindow, SessionExpiredSurface). Mounted by mountReactApp() in+ src/main.ts. Visually empty; children portal into getLayerRoot(...). -->+ <div id="react-app"></div>+ <!-- React Toaster root: hosts the persistent toast renderer.+ Visually empty; toasts portal into getLayerRoot("overlay"). -->+ <div id="bb-toaster-root"></div>+```++- [ ] **Step 2: Commit**++```bash+git add frontend/index.html+git commit -m "feat(frontend): add #react-app mount point for sibling React app"+```++---++## Task 2: Create `SessionExpiredSurfaceGate.tsx` with a test++**Files:**+- Create: `frontend/src/react/app/SessionExpiredSurfaceGate.tsx`+- Create: `frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx`++The gate replaces the `v-if="authStore.unauthenticatedOccurred"` guard that lives in `AuthContext.vue` today, and supplies the `currentPath` prop that `SessionExpiredSurfaceMount.vue` derived from Vue's `useRoute().fullPath`.++- [ ] **Step 1: Write the failing test**++Create `frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx`:++```tsx+import { act } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, describe, expect, test, vi } from "vitest";+import { ref } from "vue";++// useVueState wraps Vue reactive sources for React. Mock it so the test+// drives the gate's branching purely from refs we control.+const unauthenticatedOccurredRef = ref(false);+const fullPathRef = ref("/");++vi.mock("@/react/hooks/useVueState", () => ({+ useVueState: <T,>(getter: () => T) => {+ // Subscribe via a tiny effect-free pull each render. The gate only re-runs+ // when React re-renders, which is enough for these assertions.+ return getter();+ },+}));++vi.mock("@/store", () => ({+ useAuthStore: () => ({+ get unauthenticatedOccurred() {+ return unauthenticatedOccurredRef.value;+ },+ }),+}));++vi.mock("@/router", () => ({+ router: {+ currentRoute: {+ get value() {+ return { fullPath: fullPathRef.value };+ },+ },+ },+}));++vi.mock("@/react/components/auth/SessionExpiredSurface", () => ({+ SessionExpiredSurface: ({ currentPath }: { currentPath: string }) => (+ <div data-testid="surface" data-path={currentPath} />+ ),+}));++import { SessionExpiredSurfaceGate } from "./SessionExpiredSurfaceGate";++describe("SessionExpiredSurfaceGate", () => {+ let container: HTMLDivElement;+ let root: Root;++ afterEach(() => {+ act(() => root.unmount());+ container.remove();+ unauthenticatedOccurredRef.value = false;+ fullPathRef.value = "/";+ });++ test("renders nothing when unauthenticatedOccurred is false", () => {+ container = document.createElement("div");+ document.body.appendChild(container);+ root = createRoot(container);+ act(() => root.render(<SessionExpiredSurfaceGate />));+ expect(container.querySelector("[data-testid='surface']")).toBeNull();+ });++ test("renders SessionExpiredSurface with current path when true", () => {+ unauthenticatedOccurredRef.value = true;+ fullPathRef.value = "/projects/sample/plans/123";+ container = document.createElement("div");+ document.body.appendChild(container);+ root = createRoot(container);+ act(() => root.render(<SessionExpiredSurfaceGate />));+ const surface = container.querySelector("[data-testid='surface']");+ expect(surface).not.toBeNull();+ expect(surface?.getAttribute("data-path")).toBe("/projects/sample/plans/123");+ });+});+```++- [ ] **Step 2: Run the test to verify it fails**++Run from the repo root:++```bash+pnpm --dir frontend test -- src/react/app/SessionExpiredSurfaceGate.test.tsx+```++Expected: FAIL — `Cannot find module './SessionExpiredSurfaceGate'`.++- [ ] **Step 3: Create the gate component**++Create `frontend/src/react/app/SessionExpiredSurfaceGate.tsx`:++```tsx+import { SessionExpiredSurface } from "@/react/components/auth/SessionExpiredSurface";+import { useVueState } from "@/react/hooks/useVueState";+import { router } from "@/router";+import { useAuthStore } from "@/store";++export function SessionExpiredSurfaceGate() {+ const unauthenticatedOccurred = useVueState(+ () => useAuthStore().unauthenticatedOccurred+ );+ const currentPath = useVueState(() => router.currentRoute.value.fullPath);+ if (!unauthenticatedOccurred) return null;+ return <SessionExpiredSurface currentPath={currentPath} />;+}+```++- [ ] **Step 4: Run the test to verify it passes**++Run:++```bash+pnpm --dir frontend test -- src/react/app/SessionExpiredSurfaceGate.test.tsx+```++Expected: PASS — both test cases green.++- [ ] **Step 5: Commit**++```bash+git add frontend/src/react/app/SessionExpiredSurfaceGate.tsx \+ frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx+git commit -m "feat(react): add SessionExpiredSurfaceGate for the React app"+```++---++## Task 3: Create `ReactApp.tsx`++**Files:**+- Create: `frontend/src/react/app/ReactApp.tsx`++`ReactApp` is the top-level tree. It does not own an `I18nextProvider` itself — `mount.tsx` (Task 4) wraps it, so tests of `ReactApp` can render it without setting up i18n.++- [ ] **Step 1: Create the component**++Create `frontend/src/react/app/ReactApp.tsx`:++```tsx+import { AgentWindow } from "@/react/plugins/agent/components/AgentWindow";+import { SessionExpiredSurfaceGate } from "./SessionExpiredSurfaceGate";++export function ReactApp() {+ return (+ <>+ <AgentWindow />+ <SessionExpiredSurfaceGate />+ </>+ );+}+```++- [ ] **Step 2: Commit**++```bash+git add frontend/src/react/app/ReactApp.tsx+git commit -m "feat(react): add ReactApp top-level tree (AgentWindow + session-expired gate)"+```++---++## Task 4: Create `mount.tsx`++**Files:**+- Create: `frontend/src/react/app/mount.tsx`++This file is `.tsx` (not `.ts`) because it renders JSX. It owns the `<I18nextProvider>` wrapper and the one-time Vue→React locale sync that replaces the per-shim `watch(locale, ...)` blocks.++- [ ] **Step 1: Create the mount entrypoint**++Create `frontend/src/react/app/mount.tsx`:++```tsx+import { StrictMode } from "react";+import { createRoot, type Root } from "react-dom/client";+import { I18nextProvider } from "react-i18next";+import { watch } from "vue";+import { locale } from "@/plugins/i18n";+import i18n, { i18nReady } from "@/react/i18n";+import { ReactApp } from "./ReactApp";++export async function mountReactApp(selector: string): Promise<Root> {+ const container = document.querySelector(selector);+ if (!container) {+ throw new Error(`mountReactApp: missing container ${selector}`);+ }+ await i18nReady;+ // Sync initial locale before first paint.+ if (i18n.language !== locale.value) {+ await i18n.changeLanguage(locale.value);+ }+ const root = createRoot(container);+ root.render(+ <StrictMode>+ <I18nextProvider i18n={i18n}>+ <ReactApp />+ </I18nextProvider>+ </StrictMode>+ );+ // One-time Vue→React locale sync. Replaces the per-shim watch(locale, ...).+ watch(locale, async (next) => {+ if (i18n.language !== next) {+ await i18n.changeLanguage(next);+ }+ });+ return root;+}+```++- [ ] **Step 2: Commit**++```bash+git add frontend/src/react/app/mount.tsx+git commit -m "feat(react): add mountReactApp entrypoint"+```++---++## Task 5: Wire `main.ts` to mount the React app++**Files:**+- Modify: `frontend/src/main.ts`++Boot order: Vue app mounts first, React app is fire-and-forget after. Use dynamic `import()` so the React-app chunk stays off the Vue boot critical path.++- [ ] **Step 1: Read the existing `main.ts` to locate the Vue mount call**++Run:++```bash+grep -n "app.mount\|createApp" frontend/src/main.ts+```++Expected: finds the `app.mount("#app")` call near the end of the bootstrap IIFE.++- [ ] **Step 2: Add the React app mount after the Vue mount**++Edit `frontend/src/main.ts`. Find the `app.mount("#app");` line and add a new statement immediately after it:++```ts+ app.mount("#app");++ // Mount the sibling React app for surfaces that portal globally+ // (AgentWindow, SessionExpiredSurface). Fire-and-forget so any boot work+ // that follows is not blocked on i18nReady.+ void (async () => {+ const { mountReactApp } = await import("./react/app/mount");+ await mountReactApp("#react-app");+ })();+```++If `app.mount(...)` is the last statement before the IIFE closes, the new block is the last statement; either way the order is "Vue first, then React".++- [ ] **Step 3: Commit**++```bash+git add frontend/src/main.ts+git commit -m "feat(frontend): boot React app after the Vue app in main.ts"+```++---++## Task 6: Remove `<AgentWindowMount />` from `BodyLayout.vue`++**Files:**+- Modify: `frontend/src/layouts/BodyLayout.vue`+- Modify: `frontend/src/layouts/layout-bridge.test.ts`++- [ ] **Step 1: Remove the element and its import from `BodyLayout.vue`**++Edit `frontend/src/layouts/BodyLayout.vue`. Delete line 43 (the `<AgentWindowMount />` element) and the corresponding import:++```vue+import AgentWindowMount from "@/components/AgentWindowMount.vue";+```++The agent keyboard shortcut handler (`agentShortcutHandler` and its `onMounted`/`onUnmounted` registrations) stays — it just toggles the agent store. The agent is now rendered by the React app rather than by this layout's child element.++- [ ] **Step 2: Drop the `vi.mock` for `AgentWindowMount` in `layout-bridge.test.ts`**++Edit `frontend/src/layouts/layout-bridge.test.ts`. Delete this block (currently at lines 118–128):++```ts+vi.mock("@/components/AgentWindowMount.vue", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ default: defineComponent({+ name: "MockAgentWindowMount",+ setup() {+ return () => h("div", { "data-testid": "agent-window" });+ },+ }),+ };+});+```++- [ ] **Step 3: Commit**++```bash+git add frontend/src/layouts/BodyLayout.vue frontend/src/layouts/layout-bridge.test.ts+git commit -m "refactor(layouts): drop AgentWindowMount from BodyLayout (React app hosts it)"+```++---++## Task 7: Remove `<SessionExpiredSurfaceMount />` from `AuthContext.vue`++**Files:**+- Modify: `frontend/src/AuthContext.vue`++The previous template was:++```vue+<template v-if="!isAuthRoute && authStore.isLoggedIn">+ <SessionExpiredSurfaceMount v-if="authStore.unauthenticatedOccurred" />+ <ReactPageMount v-else page="InactiveRemindModal" />+</template>+```++The session-expired branch now lives in `SessionExpiredSurfaceGate` inside the React app. `InactiveRemindModal` stays here because it still mounts via `ReactPageMount` and depends on Vue-side route state.++- [ ] **Step 1: Update the template**++Edit `frontend/src/AuthContext.vue`. Replace lines 6–10 with:++```vue+<template v-if="!isAuthRoute && authStore.isLoggedIn">+ <!-- Session-expired surface is rendered by the React app+ (see src/react/app/SessionExpiredSurfaceGate.tsx). -->+ <ReactPageMount+ v-if="!authStore.unauthenticatedOccurred"+ page="InactiveRemindModal"+ />+</template>+```++- [ ] **Step 2: Remove the import**++In the same file, delete:++```vue+import SessionExpiredSurfaceMount from "@/components/SessionExpiredSurfaceMount.vue";+```++- [ ] **Step 3: Commit**++```bash+git add frontend/src/AuthContext.vue+git commit -m "refactor(auth): drop SessionExpiredSurfaceMount from AuthContext (React app hosts it)"+```++---++## Task 8: Delete the two `*Mount.vue` shim files and their shim-only tests++**Files:**+- Delete: `frontend/src/components/AgentWindowMount.vue`+- Delete: `frontend/src/components/SessionExpiredSurfaceMount.vue`+- Modify: `frontend/src/react/components/auth/SessionExpiredSurface.test.tsx` — delete shim-only test cases+- Modify (optional): `frontend/src/react/mount.ts` — prune unused glob entries++The first `grep` in Step 1 will still match `SessionExpiredSurface.test.tsx` until that file's shim-specific tests are removed. Handle that here, then re-run the grep.++- [ ] **Step 1: Snapshot remaining importers**++Run:++```bash+grep -rnE "AgentWindowMount|SessionExpiredSurfaceMount" frontend/src 2>/dev/null+```++Expected matches (after Tasks 6 + 7):+- `frontend/src/react/components/auth/SessionExpiredSurface.test.tsx` — five test cases that mount `SessionExpiredSurfaceMount` directly to verify the shim's lifecycle. These tests no longer apply (the shim is going away) and must be deleted.++If anything else still matches, halt and triage — the shim is still load-bearing.++- [ ] **Step 2: Remove the shim-only tests from `SessionExpiredSurface.test.tsx`**++Tests 1–4 in this file (`mounts into the critical root`, `moves focus into the critical dialog`, `does not let Escape dismiss lower-layer dialogs`, `keeps the agent layer inert while the critical surface is open`) render `<SessionExpiredSurface currentPath="..." />` directly and exercise the React component itself — keep these.++Tests 5–9 (`syncs React i18n before the initial mount`, `reconciles the latest route after async mount resolves`, `unmounts late-mounted roots when the Vue bridge is already gone`, `keeps the newest route when async syncs finish out of order`, `keeps the newest locale when async locale syncs finish out of order`) all call `mount(SessionExpiredSurfaceMount)` and validate the shim's async mount + locale/route reconciliation. Delete them. The new architecture (single long-lived React root + `useVueState` subscription) has no shim to reconcile against, so the behaviors they test cannot exist.++Concretely, edit `frontend/src/react/components/auth/SessionExpiredSurface.test.tsx`:++1. Delete line 81: `import SessionExpiredSurfaceMount from "@/components/SessionExpiredSurfaceMount.vue";`+2. Delete the entire `test(...)` blocks for the five shim tests (currently lines 230–416 inclusive — the `test("syncs React i18n before the initial mount", ...)` through the closing brace of `test("keeps the newest locale when async locale syncs finish out of order", ...)`).+3. Delete the `vi.mock` blocks that are now unused by the four remaining tests:+ - The `vi.hoisted` `mountMocks` block (lines 23–46), plus the `vi.mock("@/react/i18n", ...)` and `vi.mock("@/react/mount", ...)` that reference it.+ - `vi.mock("vue-i18n", ...)` (lines 53–62) and `vi.mock("vue-router", ...)` (lines 64–79).+4. Delete the `import { flushPromises, mount } from "@vue/test-utils";` and `import { nextTick } from "vue";` imports at the top — only the shim tests used them.+5. Remove `mountMocks.changeLanguage.mockClear()`, `mountMocks.mountReactPage.mockClear()`, `mountMocks.updateReactPage.mockClear()`, the `mountMocks.locale!.value = "zh-CN"` reset, the `mountMocks.reactI18nLanguage.value = "en-US"` reset, and the `routePath` reset from the `afterEach` block (lines 90–102). What remains in `afterEach` should be:++```ts+afterEach(() => {+ document.body.innerHTML = "";+});+```++After these edits, the file's surviving content is: imports, the `vi.mock("@/react/pages/auth/SigninPage", ...)` mock, the `vi.mock("@/store", ...)` mock, the `vi.mock("react-i18next", ...)` mock, the import of `Dialog` / `DialogContent` / `SessionExpiredSurface`, the `IS_REACT_ACT_ENVIRONMENT` flag, and the four React-component tests (1–4).++- [ ] **Step 3: Re-verify no remaining importers of the shims**++```bash+grep -rnE "AgentWindowMount|SessionExpiredSurfaceMount" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 4: Delete the shim files**++```bash+git rm frontend/src/components/AgentWindowMount.vue \+ frontend/src/components/SessionExpiredSurfaceMount.vue+```++- [ ] **Step 5 (optional): Prune unused glob entries in `mount.ts`**++After the shims are gone, `mountReactPage` is no longer used to load `AgentWindow` or `SessionExpiredSurface`. They are now imported statically by `ReactApp.tsx` and `SessionExpiredSurfaceGate.tsx`.++Verify:++```bash+grep -nE "AgentWindow|SessionExpiredSurface" frontend/src/react/mount.ts+```++If the only matches are inside `import.meta.glob([...])` arrays (no other code references `"AgentWindow"` or `"SessionExpiredSurface"` as `mountReactPage` page names), edit `frontend/src/react/mount.ts`:++- Delete the entire `const pluginComponentLoaders = import.meta.glob("./plugins/agent/components/AgentWindow.tsx");` declaration.+- Remove `"./components/auth/SessionExpiredSurface.tsx"` from the `authComponentLoaders` array (but keep `InactiveRemindModal.tsx` — `AuthContext.vue` still mounts it via `ReactPageMount`).+- Remove `...pluginComponentLoaders` from the `pageLoaders` spread.+- Remove `"./plugins/agent/components"` from the `pageDirs` array.++Skip this step if a grep elsewhere shows a remaining `mountReactPage(..., "AgentWindow"|"SessionExpiredSurface", ...)` call site — leave the glob entries in that case.++- [ ] **Step 6: Commit**++```bash+git add frontend/src/react/components/auth/SessionExpiredSurface.test.tsx \+ frontend/src/react/mount.ts+git commit -m "chore(frontend): delete *Mount.vue shims and their shim-only tests"+```++---++## Task 9: Delete the orphan `AdvancedSearch/types.ts`++**Files:**+- Delete: `frontend/src/components/AdvancedSearch/types.ts`++- [ ] **Step 1: Re-confirm zero importers**++Run:++```bash+grep -rnE "@/components/AdvancedSearch" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 2: Delete the file**++```bash+git rm frontend/src/components/AdvancedSearch/types.ts+```++- [ ] **Step 3: Commit**++```bash+git commit -m "chore(frontend): drop orphan AdvancedSearch/types.ts"+```++---++## Task 10: Move `OverlayStackManager.vue` to `src/bbkit/`++**Files:**+- Create: `frontend/src/bbkit/OverlayStackManager.vue`+- Delete: `frontend/src/components/misc/OverlayStackManager.vue`+- Modify: `frontend/src/App.vue`+- Modify: `frontend/src/bbkit/BBModal.vue`+- Modify: `frontend/src/shell-bridge.test.ts`++- [ ] **Step 1: Move the file (preserves git history)**++```bash+git mv frontend/src/components/misc/OverlayStackManager.vue \+ frontend/src/bbkit/OverlayStackManager.vue+```++- [ ] **Step 2: Update `App.vue` import**++Edit `frontend/src/App.vue` line 32. Replace:++```ts+import OverlayStackManager from "./components/misc/OverlayStackManager.vue";+```++with:++```ts+import OverlayStackManager from "./bbkit/OverlayStackManager.vue";+```++- [ ] **Step 3: Update `BBModal.vue` import**++Edit `frontend/src/bbkit/BBModal.vue` line 55. Replace:++```ts+import { useOverlayStack } from "@/components/misc/OverlayStackManager.vue";+```++with:++```ts+import { useOverlayStack } from "@/bbkit/OverlayStackManager.vue";+```++- [ ] **Step 4: Update `shell-bridge.test.ts` mock path**++Edit `frontend/src/shell-bridge.test.ts` line 78. Replace:++```ts+vi.mock("./components/misc/OverlayStackManager.vue", async () => {+```++with:++```ts+vi.mock("./bbkit/OverlayStackManager.vue", async () => {+```++- [ ] **Step 5: Commit**++```bash+git add frontend/src/bbkit/OverlayStackManager.vue \+ frontend/src/App.vue \+ frontend/src/bbkit/BBModal.vue \+ frontend/src/shell-bridge.test.ts+git commit -m "refactor(frontend): move OverlayStackManager.vue from components/misc to bbkit"+```++---++## Task 11: Merge `InstanceForm/constants.ts` into `src/utils/v1/instance.ts`++**Files:**+- Modify: `frontend/src/utils/v1/instance.ts`+- Delete: `frontend/src/components/InstanceForm/constants.ts`+- Modify: `frontend/src/react/components/EngineIcon.tsx`+- Modify: `frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx`+- Modify (8 test files): update `vi.mock` paths++- [ ] **Step 1: Read the full content of `InstanceForm/constants.ts`**++Run:++```bash+cat frontend/src/components/InstanceForm/constants.ts+```++Confirm the file exports `defaultPortForEngine` (function) and `EngineIconPath` (const). Note its imports — they must merge cleanly with `instance.ts`'s existing imports (`computed`, `Engine`, `supportedEngineV1List`).++- [ ] **Step 2: Append both exports to `src/utils/v1/instance.ts`**++Edit `frontend/src/utils/v1/instance.ts`. Append the entire body of `InstanceForm/constants.ts` to the end of the file, EXCEPT for its import block (its imports — `computed` from "vue", `Engine` from proto-es, `supportedEngineV1List` from `@/utils` — are already present in `instance.ts`; verify and only add any missing import).++- [ ] **Step 3: Delete the source file**++```bash+git rm frontend/src/components/InstanceForm/constants.ts+```++- [ ] **Step 4: Update the two real importers**++Edit `frontend/src/react/components/EngineIcon.tsx` line 2. Replace:++```tsx+import { EngineIconPath } from "@/components/InstanceForm/constants";+```++with:++```tsx+import { EngineIconPath } from "@/utils/v1/instance";+```++Edit `frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx` line 7. Replace:++```tsx+import { EngineIconPath } from "@/components/InstanceForm/constants";+```++with:++```tsx+import { EngineIconPath } from "@/utils/v1/instance";+```++- [ ] **Step 5: Update the 8 test mock paths**++Each of the following files contains `vi.mock("@/components/InstanceForm/constants", ...)`. Replace that string in each with `vi.mock("@/utils/v1/instance", ...)`. If a file mocks more than `EngineIconPath` (e.g. unrelated `instance.ts` exports), only the mocked exports need to be defined — but check that the `vi.mock` factory still returns every export the test reads. If `@/utils/v1/instance` already had a real export used elsewhere in the test, hoist it into the mock as well.++Files to update:+- `frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsx:48`+- `frontend/src/react/components/sql-editor/DatabaseChooser.test.tsx:51`+- `frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsx:25`+- `frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsx:28`+- `frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsx:185`+- `frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsx:19`+- `frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsx:197`+- `frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsx:139`++For each file, run `grep -n "vi.mock(\"@/components/InstanceForm/constants\"" <file>` to locate the exact line, then change only the path string. The mock factory body remains unchanged.++- [ ] **Step 6: Verify no remaining importers**++```bash+grep -rnE "@/components/InstanceForm" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 7: Commit**++```bash+git add frontend/src/utils/v1/instance.ts \+ frontend/src/react/components/EngineIcon.tsx \+ frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx \+ frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsx \+ frontend/src/react/components/sql-editor/DatabaseChooser.test.tsx \+ frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsx \+ frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsx \+ frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsx \+ frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsx \+ frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsx \+ frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsx+git commit -m "refactor(frontend): merge InstanceForm/constants into utils/v1/instance"+```++---++## Task 12: Move Member binding types to `src/types/v1/member.ts`++**Files:**+- Create: `frontend/src/types/v1/member.ts`+- Delete: `frontend/src/components/Member/types.ts`+- Modify: `frontend/src/react/pages/settings/MembersPage.tsx`++- [ ] **Step 1: Create the new types file**++Create `frontend/src/types/v1/member.ts` with the full body of the source file (no edits to the type contents):++```ts+import type { Group } from "@/types/proto-es/v1/group_service_pb";+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";+import { type User } from "@/types/proto-es/v1/user_service_pb";++export interface MemberRole {+ workspaceLevelRoles: Set<string>;+ projectRoleBindings: Binding[];+}++export interface GroupBinding extends Group {+ deleted?: boolean;+}++export interface MemberBinding extends MemberRole {+ title: string;+ // binidng is the fullname for binding member,+ // like user:{email} or group:{email}+ binding: string;+ type: "users" | "groups";+ user?: User;+ group?: GroupBinding;+ // True when the email is in the IAM policy but has no principal (user hasn't+ // signed up yet). Only set when the current user has permission to list/get+ // users — otherwise we can't tell and this stays undefined.+ pending?: boolean;+}+```++- [ ] **Step 2: Delete the source file**++```bash+git rm frontend/src/components/Member/types.ts+```++- [ ] **Step 3: Update the importer in `MembersPage.tsx`**++Edit `frontend/src/react/pages/settings/MembersPage.tsx` line 22. Replace:++```tsx+import type { GroupBinding, MemberBinding } from "@/components/Member/types";+```++with:++```tsx+import type { GroupBinding, MemberBinding } from "@/types/v1/member";+```++- [ ] **Step 4: Commit**++```bash+git add frontend/src/types/v1/member.ts \+ frontend/src/react/pages/settings/MembersPage.tsx+git commit -m "refactor(types): move Member binding types to types/v1/member"+```++---++## Task 13: Combine `Member/utils.ts` + `Member/projectRoleBindings.ts` into `src/utils/v1/member.ts`++**Files:**+- Create: `frontend/src/utils/v1/member.ts`+- Delete: `frontend/src/components/Member/utils.ts`+- Delete: `frontend/src/components/Member/projectRoleBindings.ts`+- Modify: `frontend/src/react/pages/settings/MembersPage.tsx`++The two source files share no helpers and import disjoint sets — combine by concatenation, with `utils.ts` content first, then `projectRoleBindings.ts` content. Both files reference types from `@/types/v1/member` (after Task 12) — verify the imports.++- [ ] **Step 1: Read both source files in full**++```bash+cat frontend/src/components/Member/utils.ts+echo "---"+cat frontend/src/components/Member/projectRoleBindings.ts+```++Confirm:+- `utils.ts` exports `getMemberBindings` and any internal helpers (export-only what callers use).+- `projectRoleBindings.ts` exports `ProjectRoleBindingGroup` (type), `getProjectRoleBindingKey`, and `groupProjectRoleBindings`.++- [ ] **Step 2: Create the combined file**++Create `frontend/src/utils/v1/member.ts`. Write the combined content:++1. Merge imports (deduplicate). Any reference inside the bodies to local types (`MemberRole`, `GroupBinding`, `MemberBinding`) that previously came from `./types` must now come from `@/types/v1/member`.+2. Paste the export bodies from `utils.ts` first, then `projectRoleBindings.ts`, in that order. Preserve all comments.+3. Do not rename any exported symbol.++If `utils.ts` had a local relative import like `from "./types"`, change it to `from "@/types/v1/member"` in the combined file.++- [ ] **Step 3: Delete the source files**++```bash+git rm frontend/src/components/Member/utils.ts \+ frontend/src/components/Member/projectRoleBindings.ts+```++- [ ] **Step 4: Update `MembersPage.tsx`**++Edit `frontend/src/react/pages/settings/MembersPage.tsx`. Replace both lines:++```tsx+import { groupProjectRoleBindings } from "@/components/Member/projectRoleBindings";+import { getMemberBindings } from "@/components/Member/utils";+```++with a single combined import:++```tsx+import {+ getMemberBindings,+ groupProjectRoleBindings,+} from "@/utils/v1/member";+```++- [ ] **Step 5: Commit**++```bash+git add frontend/src/utils/v1/member.ts \+ frontend/src/react/pages/settings/MembersPage.tsx+git commit -m "refactor(utils): combine Member helpers into utils/v1/member"+```++---++## Task 14: Move `RoleGrantPanel/DatabaseResourceForm/common.ts` to `src/utils/v1/databaseResource.ts`++**Files:**+- Create: `frontend/src/utils/v1/databaseResource.ts`+- Delete: `frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.ts`+- Modify: `frontend/src/react/components/sql-editor/RequestQueryButton.tsx`++The second importer was `MembersPage.tsx`'s reference to a different file path — re-verify before editing.++- [ ] **Step 1: Re-confirm the importer set**++Run:++```bash+grep -rnE "@/components/RoleGrantPanel" frontend/src 2>/dev/null+```++Expected: matches in `frontend/src/react/components/sql-editor/RequestQueryButton.tsx` and (if it exists) any other location. The earlier survey showed two — confirm them here.++- [ ] **Step 2: Move the file with git mv**++```bash+git mv frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.ts \+ frontend/src/utils/v1/databaseResource.ts+```++The contents do not need to change — its existing imports (`@/store`, `@/types`, `@/utils`, proto-es) all resolve identically from the new location.++- [ ] **Step 3: Update every importer found in Step 1**++For each importer file, replace:++```ts+from "@/components/RoleGrantPanel/DatabaseResourceForm/common"+```++with:++```ts+from "@/utils/v1/databaseResource"+```++Known importer: `frontend/src/react/components/sql-editor/RequestQueryButton.tsx:4`.++- [ ] **Step 4: Re-grep to confirm no stale paths**++```bash+grep -rnE "@/components/RoleGrantPanel" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 5: Commit**++```bash+git add frontend/src/utils/v1/databaseResource.ts \+ frontend/src/react/components/sql-editor/RequestQueryButton.tsx+git commit -m "refactor(utils): move DatabaseResourceForm/common to utils/v1/databaseResource"+```++---++## Task 15: Move `RolloutV1/constants/task.ts` to `src/utils/v1/issue/task.ts`++**Files:**+- Create: `frontend/src/utils/v1/issue/task.ts`+- Delete: `frontend/src/components/RolloutV1/constants/task.ts`+- Modify: `frontend/src/utils/v1/issue/rollout.ts`++- [ ] **Step 1: Move the file**++```bash+git mv frontend/src/components/RolloutV1/constants/task.ts \+ frontend/src/utils/v1/issue/task.ts+```++Contents do not change.++- [ ] **Step 2: Update the importer**++Edit `frontend/src/utils/v1/issue/rollout.ts` line 1. Replace:++```ts+import { TASK_STATUS_FILTERS } from "@/components/RolloutV1/constants/task";+```++with:++```ts+import { TASK_STATUS_FILTERS } from "./task";+```++- [ ] **Step 3: Confirm no other importers**++```bash+grep -rnE "@/components/RolloutV1" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 4: Commit**++```bash+git add frontend/src/utils/v1/issue/task.ts \+ frontend/src/utils/v1/issue/rollout.ts+git commit -m "refactor(utils): move RolloutV1/constants/task to utils/v1/issue/task"+```++---++## Task 16: Delete the now-empty `frontend/src/components/` directory++**Files:**+- Delete: `frontend/src/components/` (directory)++- [ ] **Step 1: List what's left**++```bash+find frontend/src/components -type f 2>/dev/null+```++Expected: no files (every individual file was deleted or moved in prior tasks).++- [ ] **Step 2: Confirm no remaining references anywhere**++```bash+grep -rnE "@/components/|\"./components/|'\\./components/" frontend/src 2>/dev/null+```++Expected: no matches.++- [ ] **Step 3: Remove the directory**++```bash+rm -rf frontend/src/components+```++(Empty directories don't appear in git; once the contents were `git rm`'d in earlier commits, the directory ceases to exist in the working tree as well. `rm -rf` is a no-op safety net.)++- [ ] **Step 4: Commit (if there is any tracked change)**++```bash+git status frontend/src/components 2>&1 | head -5+```++If the prior task commits already removed the last tracked file in `components/`, there is nothing to commit here — proceed to Task 17. Otherwise:++```bash+git add -A frontend/src/components+git commit -m "chore(frontend): remove empty components directory"+```++---++## Task 17: Validate the full PR++Per repo memory, all per-file checks were skipped during implementation; validation runs once now.++- [ ] **Step 1: Auto-fix lint + format**++```bash+pnpm --dir frontend fix+```++Expected: completes cleanly; if it modifies any file, stage the result.++- [ ] **Step 2: Run the static check (no modifications, CI-equivalent)**++```bash+pnpm --dir frontend check+```++Expected: PASS — ESLint + Biome + import-sort + the layering scanner all green. No new lint warnings introduced.++- [ ] **Step 3: Run the type checks**++```bash+pnpm --dir frontend type-check+```++Expected: PASS — both vue-tsc and the React tsconfig succeed. Common cause of failure here: an import path that pointed at the old `@/components/...` location was missed. If so, the type error message includes the bad path; fix and re-run.++- [ ] **Step 4: Run the test suite**++```bash+pnpm --dir frontend test+```++Expected: PASS. Critical tests to monitor:++- `src/react/app/SessionExpiredSurfaceGate.test.tsx` — the new gate test (Task 2)+- `src/layouts/layout-bridge.test.ts` — no longer mocks `AgentWindowMount`; the rendered BodyLayout should no longer contain `data-testid="agent-window"` (that assertion, if present, must be removed in Task 6)+- `src/react/components/auth/SessionExpiredSurface.test.tsx` — 4 component tests remain after Task 8 surgery+- `src/shell-bridge.test.ts` — `vi.mock` path updated in Task 10+- Every `vi.mock("@/utils/v1/instance", ...)` test from Task 11+- `src/react/no-react-to-vue-imports.test.ts` and `src/react/no-legacy-vue-deps.test.ts` — cross-framework import guards. The new `mount.tsx` imports `watch` from "vue" and `locale` from `@/plugins/i18n` (Vue side). These guards specifically allow boot/lifecycle code under `src/react/app/` to bridge into Vue — verify by reading the guard's allowlist. If `src/react/app/` is not allowlisted, the guard test will fail and you must add the directory to the allowlist (one-line edit) as part of this PR.++- [ ] **Step 5: Fix anything that breaks**++If any of the above fail:+- Type errors: read the path in the message; if it's a stale `@/components/...` reference, repoint to the new home from this plan's File Map.+- Test failures: the most common cause is a `vi.mock` path still pointing at `@/components/...`. Re-run `grep -rnE "@/components/" frontend/src` to find stragglers.+- Layering scanner: this PR does not add any `z-index` or portal — should not trigger.++After fixing, re-run all four commands in order until each is green. Commit the fixes:++```bash+git add -A frontend/src+git commit -m "chore(frontend): post-relocation validation fixes"+```++(Skip this commit if no fixes were needed.)++- [ ] **Step 6: Manual smoke test**++Start the dev server:++```bash+pnpm --dir frontend dev+```++Open the app in a browser. Verify:++1. The app boots without console errors.+2. `Cmd+Shift+A` (or `Ctrl+Shift+A`) opens the AgentWindow.+3. The AgentWindow renders at the bottom-right floating position and behaves identically to before (chat list, input, minimize/close).+4. In DevTools → Application → Storage, clear the auth cookie/token, then trigger any API call (navigate to another page). The `SessionExpiredSurface` modal should appear with the current path preserved as `currentPath`.+5. The `<div id="react-app">` element in DOM is present but visually empty; the agent UI lives inside `#bb-react-layer-agent`.++If anything misbehaves, halt and diagnose before opening the PR. The most likely failure mode is the Vue→React i18n sync — confirm by switching locale via the Vue UI and verifying the AgentWindow's `t(...)` strings update.++- [ ] **Step 7: Open the PR**++Follow the project's standard PR flow (see `docs/pre-pr-checklist.md`). Suggested PR title:++> `refactor(frontend): introduce sibling React app, empty /components/ directory`++The PR description should link to both the spec and this plan, summarize the React-app introduction (with the rationale that AgentWindow + SessionExpiredSurface already portal globally), and list the seven relocations.diff --git a/docs/superpowers/specs/2026-05-14-react-app-and-empty-components-design.md b/docs/superpowers/specs/2026-05-14-react-app-and-empty-components-design.mdnew file mode 100644index 0000000000..6a3e85c97f--- /dev/null+++ b/docs/superpowers/specs/2026-05-14-react-app-and-empty-components-design.md@@ -0,0 +1,169 @@+# Introduce React App + Empty `frontend/src/components/` — Design++Date: 2026-05-14+Status: design (pre-implementation)+Delivery: single PR++## Context++`frontend/src/components/` has been steadily emptied during the Vue→React migration. Only 10 files remain — a mix of three Vue files and seven non-component utility / type / constants files that ended up under `components/` for historical reasons. The directory's name no longer reflects what lives in it.++Two of the three remaining Vue files — `AgentWindowMount.vue` and `SessionExpiredSurfaceMount.vue` — exist as Vue shims that own a `<div>` and call `mountReactPage(container, ...)` from `src/react/mount.ts` in `onMounted`. Both render React components (`AgentWindow`, `SessionExpiredSurface`) that already `createPortal(..., getLayerRoot(...))` to `document.body`-level layer roots. Their visible DOM never lives inside the Vue subtree; the Vue mount is just a lifecycle anchor for the React root.++That means these shims are not load-bearing on their Vue parents. They are deletable today — if there is somewhere outside the Vue tree to hold the React root.++This design introduces that somewhere: a **sibling React app**, mounted at app boot alongside the existing Vue app, dedicated to React surfaces that already portal globally and don't need to be positioned inside the Vue layout DOM. Initial residents: `AgentWindow` and `SessionExpiredSurface`. The same PR also relocates the seven utility files to their natural homes and removes `frontend/src/components/` entirely.++## Goals++1. Stand up a long-lived React root in `index.html` at `<div id="react-app">`, mounted from `src/main.ts` after the Vue app mounts.+2. Move `AgentWindow` and `SessionExpiredSurface` into that React app. Delete both `*Mount.vue` shims.+3. Relocate every remaining file under `frontend/src/components/` to a natural home.+4. Delete `frontend/src/components/` entirely.++## Non-goals++- No visual or behavioral change to `AgentWindow` or `SessionExpiredSurface`.+- No migration of `OverlayStackManager.vue` to React — it remains Vue infrastructure for `BBModal.vue` (still Vue). It just relocates.+- No migration of `BodyLayout.vue` or `AuthContext.vue` to React. Both stay Vue; they just lose one child element each.+- No changes to existing `ReactPageMount.vue` / `mountReactPage` usage elsewhere. Those continue to be the right tool for React surfaces that must be positioned inside the Vue layout DOM.++## React app++### `index.html`++Add a sibling mount point:++```html+<div id="app"></div>+<div id="react-app"></div> <!-- NEW -->+<div id="bb-toaster-root"></div>+```++`#react-app` has no visible DOM of its own — its children portal to `getLayerRoot("agent")` and `getLayerRoot("critical")`. Layout position is irrelevant.++### `src/react/app/`++Three new files:++**`ReactApp.tsx`** — top-level tree:++```tsx+export function ReactApp() {+ return (+ <I18nextProvider i18n={i18n}>+ <AgentWindow />+ <SessionExpiredSurfaceGate />+ </I18nextProvider>+ );+}+```++**`SessionExpiredSurfaceGate.tsx`** — the conditional + route-path wiring that previously lived in the Vue shim:++```tsx+export function SessionExpiredSurfaceGate() {+ const unauthenticatedOccurred = useVueState(+ () => useAuthStore().unauthenticatedOccurred+ );+ const currentPath = useVueState(() => router.currentRoute.value.fullPath);+ if (!unauthenticatedOccurred) return null;+ return <SessionExpiredSurface currentPath={currentPath} />;+}+```++`useAuthStore` and `router` are imported directly per the codebase convention.++**`mount.tsx`** — boot + Vue→React i18n sync (`.tsx` because it renders JSX):++```tsx+import { watch } from "vue";+import { createRoot } from "react-dom/client";+import { StrictMode } from "react";+import i18n, { i18nReady } from "@/react/i18n";+import { locale } from "@/plugins/i18n";+import { ReactApp } from "./ReactApp";++export async function mountReactApp(selector: string) {+ const container = document.querySelector(selector);+ if (!container) throw new Error(`Missing React app mount point: ${selector}`);+ await i18nReady;+ const root = createRoot(container);+ root.render(+ <StrictMode>+ <ReactApp />+ </StrictMode>+ );+ // One-time Vue→React locale sync. Replaces the per-shim watch(locale, ...).+ watch(locale, async (next) => {+ if (i18n.language !== next) await i18n.changeLanguage(next);+ });+ return root;+}+```++### `src/main.ts`++After the existing `createApp(App).mount("#app")`:++```ts+const { mountReactApp } = await import("./react/app/mount");+void mountReactApp("#react-app"); // fire-and-forget; boot continues+```++Fire-and-forget is intentional — `mountReactApp` resolves only after `i18nReady`, and we don't want to delay any subsequent Vue boot steps on it. The React app initializing in the background is fine because both its initial residents (`AgentWindow`, `SessionExpiredSurface`) are user-triggered or auth-state-triggered, not boot-time-visible.++Dynamic import keeps the React bundle off the Vue boot critical path.++### Knock-on edits++- `src/layouts/BodyLayout.vue:43` — remove `<AgentWindowMount />` from template; remove the `import AgentWindowMount from "@/components/AgentWindowMount.vue"`.+- `src/AuthContext.vue:8` — remove `<SessionExpiredSurfaceMount v-if="authStore.unauthenticatedOccurred" />`; remove the import.+- `src/layouts/layout-bridge.test.ts:118` — drop the `vi.mock("@/components/AgentWindowMount.vue", ...)` block; the surface is no longer mounted by `BodyLayout`.+- `src/react/components/auth/SessionExpiredSurface.test.tsx` — update import path if it references the old shim (component itself is unchanged).+- `src/react/mount.ts` — `pageLoaders` no longer needs `AgentWindow.tsx` or `SessionExpiredSurface.tsx` for the `mountReactPage` path. Verify and prune the glob entries if unused.++## File relocations++| Source | Destination | Notes |+|---|---|---|+| `AdvancedSearch/types.ts` | 🗑️ delete | 0 importers; orphan |+| `AgentWindowMount.vue` | 🗑️ delete | Replaced by React app |+| `SessionExpiredSurfaceMount.vue` | 🗑️ delete | Replaced by `SessionExpiredSurfaceGate` |+| `misc/OverlayStackManager.vue` | `src/bbkit/OverlayStackManager.vue` | Vue infra for `BBModal`; one importer |+| `InstanceForm/constants.ts` | merge into `src/utils/v1/instance.ts` | 10 importers; engine port/icon helpers |+| `Member/utils.ts` | `src/utils/v1/member.ts` (new) | 1 importer (`MembersPage.tsx`) |+| `Member/projectRoleBindings.ts` | append to `src/utils/v1/member.ts` | 1 importer; combined for density |+| `Member/types.ts` | `src/types/v1/member.ts` (new) | 1 importer; matches existing `src/types/v1/{database,project,user}.ts` pattern (the existing top-level `src/types/member.ts` is unrelated — it holds `DatabaseResource`) |+| `RoleGrantPanel/DatabaseResourceForm/common.ts` | `src/utils/v1/databaseResource.ts` (new) | 2 importers; pure helpers |+| `RolloutV1/constants/task.ts` | `src/utils/v1/issue/task.ts` (new) | 1 importer; sibling `rollout.ts` exists |++All import sites are updated in the same PR. Total importer count across the seven .ts files: ~18 import statements to rewrite.++### Destination rationale++- **`src/utils/v1/instance.ts`** already exists and contains `supportedEngineV1List` and related helpers. The engine port / icon constants belong with them.+- **`src/types/v1/member.ts`** is new; matches the sibling pattern of `src/types/v1/{database,project,user}.ts`. The existing top-level `src/types/member.ts` only holds `DatabaseResource` (unrelated) — not extended in this PR.+- **`src/utils/v1/member.ts`** is new but mirrors the existing sibling pattern (`src/utils/v1/{database,user,project}.ts`).+- **`src/utils/v1/databaseResource.ts`** is new; `parseStringToResource` and friends are pure DatabaseResource helpers with no UI dependency.+- **`src/utils/v1/issue/task.ts`** is new but `src/utils/v1/issue/rollout.ts` already exists in the same folder; task-status constants belong alongside.+- **`src/bbkit/OverlayStackManager.vue`** sits with the other `BB*` Vue primitives. The component's internal `name` is already `BBOverlayStack`.++## Validation++- `pnpm --dir frontend check` — ESLint + Biome + import sort+- `pnpm --dir frontend type-check` — both Vue (vue-tsc) and React (tsconfig.react.json)+- `pnpm --dir frontend test` — including `layout-bridge.test.ts` (updated), `SessionExpiredSurface.test.tsx`, `no-react-to-vue-imports.test.ts`, `no-legacy-vue-deps.test.ts`+- Manual smoke: open the app, confirm AgentWindow toggles via `Cmd/Ctrl+Shift+A`, confirm SessionExpired surface appears on forced 401 (e.g. revoke token in DevTools).+- Confirm the `frontend/src/components/` directory is absent at the end.++## Risks++- **Boot order race.** `mountReactApp` is awaited after Vue mounts; until it resolves, `AgentWindow` and `SessionExpiredSurface` are not present. AgentWindow is user-triggered so latency is invisible; SessionExpiredSurface only matters once an authenticated request fails, which happens long after boot. Acceptable.+- **Vue→React i18n sync coverage.** The existing shims each ran their own `watch(locale, ...)`. The new app runs one. If a future React-app resident needs to react to locale beyond `i18next.changeLanguage`, it must subscribe via `useTranslation()` (already standard).+- **`useVueState` re-render churn.** `SessionExpiredSurfaceGate` subscribes to two Vue reactive sources. Both update infrequently. No expected perf issue.+- **Layer ordering.** The React app's residents continue using `getLayerRoot("agent" | "critical")`. Layer ordering is unaffected because the layer roots live at `document.body`, not inside `#react-app` or `#app`.++## Out of scope, but enabled++Future React surfaces that already portal globally can move into `ReactApp.tsx` and drop their Vue mount shims. Candidates to consider in follow-up work: any future agent-related panels, body-level toasts that don't depend on Vue notification state, global keyboard-shortcut overlays. None of these are in this PR.diff --git a/frontend/index.html b/frontend/index.htmlindex f9ef082687..b41146d27a 100644--- a/frontend/index.html+++ b/frontend/index.html@@ -18,9 +18,10 @@></div><div id="app"></div>- <!-- React Toaster root: hosts the persistent toast renderer.- Visually empty; toasts portal into getLayerRoot("overlay"). -->- <div id="bb-toaster-root"></div>+ <!-- React app root for globally-portaled surfaces (AgentWindow,+ SessionExpiredSurface, Toaster). Visually empty; children portal+ into getLayerRoot(...). -->+ <div id="react-app"></div><script type="module" src="/src/main.ts"></script></body></html>diff --git a/frontend/src/App.vue b/frontend/src/App.vueindex 8aecafded8..780f2f6346 100644--- a/frontend/src/App.vue+++ b/frontend/src/App.vue@@ -4,13 +4,9 @@:date-locale="dateLang":theme-overrides="themeOverrides">- <ReactPageMount page="Watermark" container-class="contents" />-- <OverlayStackManager>- <AuthContext>- <router-view />- </AuthContext>- </OverlayStackManager>+ <AuthContext>+ <router-view />+ </AuthContext></NConfigProvider></template>@@ -26,10 +22,8 @@ import {watchEffect,} from "vue";import { useRoute, useRouter } from "vue-router";-import ReactPageMount from "@/react/ReactPageMount.vue";import { dateLang, generalLang, themeOverrides } from "../naive-ui.config";import AuthContext from "./AuthContext.vue";-import OverlayStackManager from "./components/misc/OverlayStackManager.vue";import { overrideAppProfile } from "./customAppProfile";import { locale, t } from "./plugins/i18n";import {diff --git a/frontend/src/AuthContext.vue b/frontend/src/AuthContext.vueindex 053849a522..d4938f74ea 100644--- a/frontend/src/AuthContext.vue+++ b/frontend/src/AuthContext.vue@@ -4,9 +4,15 @@<BBSpin /></div><template v-if="!isAuthRoute && authStore.isLoggedIn">- <!-- Do not show the modal when the user is in auth related pages. -->- <SessionExpiredSurfaceMount v-if="authStore.unauthenticatedOccurred" />- <ReactPageMount v-else page="InactiveRemindModal" />+ <!-- Session-expired surface lives in the React app+ (src/react/app/SessionExpiredSurfaceGate.tsx).+ InactiveRemindModal stays mounted here because it reads Vue router+ state via the bridged provide/inject context, which the sibling+ React app doesn't carry. -->+ <ReactPageMount+ v-if="!authStore.unauthenticatedOccurred"+ page="InactiveRemindModal"+ /></template></template>@@ -14,7 +20,6 @@import { computed, onMounted, onUnmounted, ref, watch } from "vue";import { useRouter } from "vue-router";import { BBSpin } from "@/bbkit";-import SessionExpiredSurfaceMount from "@/components/SessionExpiredSurfaceMount.vue";import ReactPageMount from "@/react/ReactPageMount.vue";import { isAuthRelatedRoute } from "@/utils/auth";import { t } from "./plugins/i18n";diff --git a/frontend/src/bbkit/BBModal.vue b/frontend/src/bbkit/BBModal.vuedeleted file mode 100644index d346d63f20..0000000000--- a/frontend/src/bbkit/BBModal.vue+++ /dev/null@@ -1,162 +0,0 @@-<template>- <NModal- :show="show"- :auto-focus="false"- :trap-focus="trapFocus"- :close-on-esc="false"- :mask-closeable="maskClosable"- @mask-click="maskClosable && upmost && tryClose()"- >- <div- v-bind="$attrs"- class="bg-white shadow-lg rounded-md py-3 flex pointer-events-auto flex-col gap-3"- :style="{- maxWidth: 'calc(100vw - 80px)',- maxHeight: 'calc(100vh - 80px)',- }"- :data-overlay-stack-id="id"- :data-overlay-stack-upmost="upmost"- >- <div- class="relative mx-4 pb-2 flex items-center justify-between border-b border-block-border"- :class="headerClass"- >- <div class="text-lg text-main mr-2 flex-1 overflow-hidden">- <slot name="title"><component :is="renderTitle" /></slot>- <slot name="subtitle"><component :is="renderSubtitle" /></slot>- </div>- <NButton- v-if="showClose"- quaternary- size="small"- aria-label="close"- @click.prevent="tryClose()"- >- <span class="sr-only">Close</span>- <XIcon class="w-5 h-auto hover:opacity-80" />- </NButton>- </div>-- <div- class="px-4 max-h-screen overflow-auto w-full h-full"- :class="containerClass"- >- <slot />- </div>- </div>- </NModal>-</template>--<script lang="ts">-import { XIcon } from "lucide-vue-next";-import { NButton, NModal } from "naive-ui";-import type { PropType, RenderFunction } from "vue";-import { defineComponent, h, toRef } from "vue";-import { useOverlayStack } from "@/components/misc/OverlayStackManager.vue";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import type { VueClass } from "@/utils";--export default defineComponent({- name: "BBModalV2",- components: {- NModal,- NButton,- XIcon,- },- inheritAttrs: false,- props: {- show: {- type: Boolean,- default: true,- },- title: {- default: "",- type: [String, Function] as PropType<string | RenderFunction>,- },- subtitle: {- default: "",- type: [String, Function] as PropType<string | RenderFunction>,- },- showClose: {- type: Boolean,- default: true,- },- headerClass: {- type: [String, Object, Array] as PropType<VueClass>,- default: undefined,- },- containerClass: {- type: [String, Object, Array] as PropType<VueClass>,- default: undefined,- },- closeOnEsc: {- type: Boolean,- default: true,- },- maskClosable: {- type: Boolean,- // Default to `false` to make it behaves consistent with legacy BBModal- default: false,- },- beforeClose: {- type: Function as PropType<() => Promise<boolean>>,- default: undefined,- },- trapFocus: {- type: Boolean,- default: undefined,- },- },- emits: ["close", "update:show"],- setup(props, { emit }) {- const { id, upmost, events } = useOverlayStack(toRef(props, "show"));-- useEmitteryEventListener(events, "esc", () => {- if (upmost.value && props.closeOnEsc) {- tryClose();- }- });-- const tryClose = async () => {- const { beforeClose } = props;- if (beforeClose) {- const pass = await beforeClose();- if (!pass) return;- }- emit("close");- emit("update:show", false);- };-- const renderTitle = () => {- if (typeof props.title === "function") {- return props.title();- }- return props.title;- };-- const renderSubtitle = () => {- if (typeof props.subtitle === "function") {- return props.subtitle();- }- if (props.subtitle) {- return h(- "div",- {- class: "text-sm text-control whitespace-nowrap",- },- [h("span", { class: "inline-block" }, props.subtitle)]- );- }- return null;- };-- return {- tryClose,- renderTitle,- renderSubtitle,- id,- upmost,- };- },-});-</script>diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.tsindex 8c45fb5b4a..02c0dd1190 100644--- a/frontend/src/bbkit/index.ts+++ b/frontend/src/bbkit/index.ts@@ -1,10 +1,9 @@import BBAlert from "./BBAlert.vue";import BBAttention from "./BBAttention.vue";import BBButtonConfirm from "./BBButtonConfirm.vue";-import BBModal from "./BBModal.vue";import BBSpin from "./BBSpin.vue";import BBTextField from "./BBTextField.vue";export * from "./types";-export { BBAlert, BBAttention, BBButtonConfirm, BBModal, BBSpin, BBTextField };+export { BBAlert, BBAttention, BBButtonConfirm, BBSpin, BBTextField };diff --git a/frontend/src/components/AdvancedSearch/types.ts b/frontend/src/components/AdvancedSearch/types.tsdeleted file mode 100644index 9d190e5d01..0000000000--- a/frontend/src/components/AdvancedSearch/types.ts+++ /dev/null@@ -1,21 +0,0 @@-import type { RenderFunction } from "vue";-import type { SearchScopeId } from "@/utils";--export type ScopeOption = {- id: SearchScopeId;- title: string;- options?: ValueOption[];- description?: string;- allowMultiple?: boolean;- search?: (op: {- keyword: string;- nextPageToken?: string;- }) => Promise<{ nextPageToken?: string; options: ValueOption[] }>;-};--export type ValueOption = {- value: string;- keywords: string[];- custom?: boolean;- render?: RenderFunction;-};diff --git a/frontend/src/components/AgentWindowMount.vue b/frontend/src/components/AgentWindowMount.vuedeleted file mode 100644index 78a91ad489..0000000000--- a/frontend/src/components/AgentWindowMount.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <div ref="container" />-</template>--<script lang="ts" setup>-import { onMounted, onUnmounted, ref, watch } from "vue";-import { useI18n } from "vue-i18n";-import { mountReactPage } from "@/react/mount";--const { locale } = useI18n();-const container = ref<HTMLElement>();-// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import-let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any--onMounted(async () => {- if (!container.value) return;- root = await mountReactPage(container.value, "AgentWindow");-});--watch(locale, async () => {- const i18nModule = await import("@/react/i18n");- await i18nModule.default.changeLanguage(locale.value);-});--onUnmounted(() => {- root?.unmount();- root = null;-});-</script>diff --git a/frontend/src/components/InstanceForm/constants.ts b/frontend/src/components/InstanceForm/constants.tsdeleted file mode 100644index 6c7a0e5b76..0000000000--- a/frontend/src/components/InstanceForm/constants.ts+++ /dev/null@@ -1,112 +0,0 @@-import { computed } from "vue";-import { Engine } from "@/types/proto-es/v1/common_pb";-import { supportedEngineV1List } from "@/utils";--export const defaultPortForEngine = (engine: Engine) => {- switch (engine) {- case Engine.CLICKHOUSE:- return "9000";- case Engine.MYSQL:- return "3306";- case Engine.POSTGRES:- return "5432";- case Engine.SNOWFLAKE:- return "";- case Engine.SQLITE:- return "";- case Engine.TIDB:- return "4000";- case Engine.MONGODB:- return "27017";- case Engine.REDIS:- return "6379";- case Engine.ORACLE:- return "1521";- case Engine.SPANNER:- return "";- case Engine.MSSQL:- return "1433";- case Engine.REDSHIFT:- return "5439";- case Engine.MARIADB:- return "3306";- case Engine.OCEANBASE:- return "2883";- case Engine.STARROCKS:- return "9030";- case Engine.DORIS:- return "9030";- case Engine.HIVE:- return "10000";- case Engine.ELASTICSEARCH:- return "9200";- case Engine.BIGQUERY:- return "";- case Engine.DYNAMODB:- return "";- case Engine.DATABRICKS:- return "";- case Engine.COCKROACHDB:- return "26257";- case Engine.COSMOSDB:- return "";- case Engine.CASSANDRA:- return "9042";- case Engine.TRINO:- return "8080";- }- throw new Error("engine port unknown");-};--export const EngineList = computed(() => {- return supportedEngineV1List();-});--export const EngineIconPath: Record<string, string> = {- [Engine.MYSQL]: new URL("@/assets/db/mysql.png", import.meta.url).href,- [Engine.POSTGRES]: new URL("@/assets/db/postgres.png", import.meta.url).href,- [Engine.TIDB]: new URL("@/assets/db/tidb.png", import.meta.url).href,- [Engine.SNOWFLAKE]: new URL("@/assets/db/snowflake.png", import.meta.url)- .href,- [Engine.CLICKHOUSE]: new URL("@/assets/db/clickhouse.png", import.meta.url)- .href,- [Engine.MONGODB]: new URL("@/assets/db/mongodb.png", import.meta.url).href,- [Engine.SPANNER]: new URL("@/assets/db/spanner.png", import.meta.url).href,- [Engine.REDIS]: new URL("@/assets/db/redis.png", import.meta.url).href,- [Engine.ORACLE]: new URL("@/assets/db/oracle.svg", import.meta.url).href,- [Engine.MSSQL]: new URL("@/assets/db/mssql.svg", import.meta.url).href,- [Engine.REDSHIFT]: new URL("@/assets/db/redshift.svg", import.meta.url).href,- [Engine.MARIADB]: new URL("@/assets/db/mariadb.png", import.meta.url).href,- [Engine.OCEANBASE]: new URL(- "@/assets/db/oceanbase-mysql.svg",- import.meta.url- ).href,- [Engine.STARROCKS]: new URL("@/assets/db/starrocks.png", import.meta.url)- .href,- [Engine.DORIS]: new URL("@/assets/db/doris.png", import.meta.url).href,- [Engine.HIVE]: new URL("@/assets/db/hive.svg", import.meta.url).href,- [Engine.ELASTICSEARCH]: new URL(- "@/assets/db/elasticsearch.svg",- import.meta.url- ).href,- [Engine.BIGQUERY]: new URL("@/assets/db/bigquery.svg", import.meta.url).href,- [Engine.DYNAMODB]: new URL("@/assets/db/dynamodb.svg", import.meta.url).href,- [Engine.DATABRICKS]: new URL("@/assets/db/databricks.svg", import.meta.url)- .href,- [Engine.COCKROACHDB]: new URL("@/assets/db/cockroachdb.png", import.meta.url)- .href,- [Engine.COSMOSDB]: new URL("@/assets/db/cosmosdb.svg", import.meta.url).href,- [Engine.CASSANDRA]: new URL("@/assets/db/cassandra.svg", import.meta.url)- .href,- [Engine.TRINO]: new URL("@/assets/db/trino.svg", import.meta.url).href,-};--export const MongoDBConnectionStringSchemaList = [- "mongodb://",- "mongodb+srv://",-];--export const RedisConnectionType = ["Standalone", "Sentinel", "Cluster"];--export const SnowflakeExtraLinkPlaceHolder =- "https://us-west-1.console.aws.amazon.com/rds/home?region=us-west-1#database:id=mysql-instance-foo;is-cluster=false";diff --git a/frontend/src/components/Member/projectRoleBindings.ts b/frontend/src/components/Member/projectRoleBindings.tsdeleted file mode 100644index e5f15bae23..0000000000--- a/frontend/src/components/Member/projectRoleBindings.ts+++ /dev/null@@ -1,48 +0,0 @@-import { PRESET_ROLES } from "@/types/iam/role";-import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";--export interface ProjectRoleBindingGroup {- role: string;- bindings: Binding[];-}--export const getProjectRoleBindingKey = (- binding: Binding,- index: number-): string => {- return [- binding.role,- binding.condition?.expression ?? "",- binding.condition?.description ?? "",- index,- ].join("::");-};--export const groupProjectRoleBindings = (- bindings: Binding[]-): ProjectRoleBindingGroup[] => {- const roleMap = new Map<string, Binding[]>();-- for (const binding of bindings) {- if (!roleMap.has(binding.role)) {- roleMap.set(binding.role, []);- }- roleMap.get(binding.role)?.push(binding);- }-- return [...roleMap.keys()]- .sort((a, b) => {- const priority = (role: string) => {- const presetRoleIndex = PRESET_ROLES.indexOf(role);- if (presetRoleIndex !== -1) {- return presetRoleIndex;- }- return PRESET_ROLES.length;- };- return priority(a) - priority(b);- })- .map((role) => ({- role,- bindings: roleMap.get(role) ?? [],- }));-};diff --git a/frontend/src/components/SessionExpiredSurfaceMount.vue b/frontend/src/components/SessionExpiredSurfaceMount.vuedeleted file mode 100644index 4c3d939ba2..0000000000--- a/frontend/src/components/SessionExpiredSurfaceMount.vue+++ /dev/null@@ -1,85 +0,0 @@-<template>- <div ref="container" />-</template>--<script lang="ts" setup>-import { computed, onMounted, onUnmounted, ref, watch } from "vue";-import { useI18n } from "vue-i18n";-import { useRoute } from "vue-router";-import { mountReactPage, updateReactPage } from "@/react/mount";--const { locale } = useI18n();-const route = useRoute();-const container = ref<HTMLElement>();-// biome-ignore lint/suspicious/noExplicitAny: React Root type from dynamic import-let root: any = null; // eslint-disable-line @typescript-eslint/no-explicit-any-let isUnmounted = false;-let syncVersion = 0;-let syncChain = Promise.resolve();--const props = computed(() => ({ currentPath: route.fullPath }));-let latestLocale = locale.value;-let latestProps = props.value;--const syncMountedPage = async (- nextLocale: string,- nextProps: { currentPath: string }-) => {- const currentSyncVersion = ++syncVersion;- syncChain = syncChain- .catch(() => {})- .then(async () => {- if (isUnmounted || currentSyncVersion !== syncVersion) return;- const i18nModule = await import("@/react/i18n");- if (isUnmounted || currentSyncVersion !== syncVersion) return;- if (i18nModule.default.language !== nextLocale) {- await i18nModule.default.changeLanguage(nextLocale);- }- if (isUnmounted || !root || currentSyncVersion !== syncVersion) return;- await updateReactPage(root, "SessionExpiredSurface", nextProps);- });- await syncChain;-};--onMounted(async () => {- if (!container.value) return;- isUnmounted = false;- latestLocale = locale.value;- latestProps = props.value;- const mountedLocale = latestLocale;- const mountedProps = latestProps;- const i18nModule = await import("@/react/i18n");- if (i18nModule.default.language !== mountedLocale) {- await i18nModule.default.changeLanguage(mountedLocale);- }- if (isUnmounted || !container.value) return;- const mountedRoot = await mountReactPage(- container.value,- "SessionExpiredSurface",- mountedProps- );- if (isUnmounted) {- mountedRoot.unmount();- return;- }- root = mountedRoot;- if (latestLocale !== mountedLocale || latestProps !== mountedProps) {- await syncMountedPage(latestLocale, latestProps);- }-});--watch([locale, props], async ([nextLocale, nextProps]) => {- latestLocale = nextLocale;- latestProps = nextProps;- if (!root) return;- await syncMountedPage(nextLocale, nextProps);-});--onUnmounted(() => {- isUnmounted = true;- syncVersion++;- syncChain = Promise.resolve();- root?.unmount();- root = null;-});-</script>diff --git a/frontend/src/components/misc/OverlayStackManager.vue b/frontend/src/components/misc/OverlayStackManager.vuedeleted file mode 100644index 5b1c6ba309..0000000000--- a/frontend/src/components/misc/OverlayStackManager.vue+++ /dev/null@@ -1,125 +0,0 @@-<template>- <slot />-</template>--<script lang="ts">-import { useEventListener } from "@vueuse/core";-import Emittery from "emittery";-import { last, pullAt } from "lodash-es";-import type { Ref } from "vue";-import {- computed,- defineComponent,- inject,- onUnmounted,- provide,- ref,- unref,- watch,-} from "vue";-import type { MaybeRef } from "@/types";--export type OverlayStackEvents = Emittery<{- esc: KeyboardEvent;-}>;--export type OverlayStackContext = {- stack: Ref<number[]>;- serial: number;- events: OverlayStackEvents;-};--const CONTEXT_KEY = Symbol("bb.overlay-stack-manager");--export function useOverlayStackContext() {- const context = inject<OverlayStackContext>(CONTEXT_KEY)!;- return context;-}--export function useOverlayStack(show: MaybeRef<boolean> = true) {- const context = inject<OverlayStackContext>(CONTEXT_KEY)!;- const { stack, events } = context;-- const id = context.serial++;- const index = computed(() => stack.value.indexOf(id));- const upmost = computed(() => id === last(stack.value));-- const push = () => {- const index = stack.value.indexOf(id);- if (index >= 0) {- pullAt(stack.value, index);- }- stack.value.push(id);- };- const pop = () => {- const index = stack.value.indexOf(id);- if (index >= 0) {- pullAt(stack.value, index);- }- };-- useEventListener(- "keyup",- (e) => {- const el = document.activeElement;- if (!el) return;- if (e.defaultPrevented) return;-- const EXCLUDED_SELECTORS = [- "input",- "textarea",- ".bb-overlay-stack-ignore-esc",- ".n-input",- ".n-base-selection-input",- ".n-base-selection-tags",- ".n-base-selection-label",- ];- const selector = EXCLUDED_SELECTORS.join(",");- if (el.matches(selector)) return;-- if (e.key === "Escape" && upmost.value) {- e.stopPropagation();- e.stopImmediatePropagation();- e.preventDefault();- console.debug(- "<OverlayStackManager> esc handled, if you don't want to handle esc event when focusing this kind of element, please check the element",- el- );-- context.events.emit("esc", e);- }- },- {- capture: true,- }- );-- watch(- () => unref(show),- (show) => {- if (show) push();- else pop();- },- { immediate: true }- );-- onUnmounted(() => {- pop();- });-- return { stack, id, index, upmost, push, pop, events };-}--export default defineComponent({- name: "BBOverlayStack",- setup() {- const context: OverlayStackContext = {- stack: ref([]),- serial: 0,- events: new Emittery(),- };-- provide<OverlayStackContext>(CONTEXT_KEY, context);- },-});-</script>diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex 2eaeb29155..2429bbb217 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -40,14 +40,12 @@<ReactPageMount page="Quickstart" container-class="w-full" /></teleport>- <AgentWindowMount /></template><script lang="ts" setup>import { useWindowSize } from "@vueuse/core";import { computed, onMounted, onUnmounted, ref, shallowRef, watch } from "vue";import { useRoute, useRouter } from "vue-router";-import AgentWindowMount from "@/components/AgentWindowMount.vue";import { t } from "@/plugins/i18n";import type { DashboardShellTargets } from "@/react/dashboard-shell";import ReactPageMount from "@/react/ReactPageMount.vue";diff --git a/frontend/src/layouts/layout-bridge.test.ts b/frontend/src/layouts/layout-bridge.test.tsindex e45f6473ad..01b5ec12ea 100644--- a/frontend/src/layouts/layout-bridge.test.ts+++ b/frontend/src/layouts/layout-bridge.test.ts@@ -115,31 +115,6 @@ vi.mock("@/react/ReactPageMount.vue", async () => {};});-vi.mock("@/components/AgentWindowMount.vue", async () => {- const { defineComponent, h } = await import("vue");- return {- default: defineComponent({- name: "MockAgentWindowMount",- setup() {- return () => h("div", { "data-testid": "agent-window" });- },- }),- };-});--vi.mock("@/components/ReleaseRemindModal.vue", async () => {- const { defineComponent, h } = await import("vue");- return {- default: defineComponent({- name: "MockReleaseRemindModal",- emits: ["cancel"],- setup() {- return () => h("div", { "data-testid": "release-remind-modal" });- },- }),- };-});-vi.mock("@/plugins/i18n", () => ({t: (key: string) => key,}));diff --git a/frontend/src/main.ts b/frontend/src/main.tsindex dcee965d68..339f30f111 100644--- a/frontend/src/main.ts+++ b/frontend/src/main.ts@@ -65,13 +65,13 @@ migrateStorageKeys();app.mount("#app");- // Boot the React toaster after Vue is mounted. Importing mountToaster- // pulls in @/react/lib/toast as a side effect, which registers the- // bb.vue-notification window listener at module-eval time. Any- // subsequent pushNotification reaches the React renderer.- const toasterRoot = document.getElementById("bb-toaster-root");- if (toasterRoot) {- const { mountToaster } = await import("./react/mountToaster");- void mountToaster(toasterRoot);- }+ // Mount the sibling React app hosting AgentWindow, SessionExpiredSurface,+ // and Toaster. The bb.vue-notification listener that routes pushNotification+ // into the React renderer is registered by the `./react/lib/toast`+ // side-effect import at the top of this file, so toasts queued before this+ // mount completes still render once it does.+ void (async () => {+ const { mountReactApp } = await import("./react/app/mount");+ await mountReactApp("#react-app");+ })();})();diff --git a/frontend/src/react/app/ReactApp.tsx b/frontend/src/react/app/ReactApp.tsxnew file mode 100644index 0000000000..f1be4f0272--- /dev/null+++ b/frontend/src/react/app/ReactApp.tsx@@ -0,0 +1,15 @@+import { Toaster } from "@/react/components/ui/toaster";+import { Watermark } from "@/react/components/Watermark";+import { AgentWindow } from "@/react/plugins/agent/components/AgentWindow";+import { SessionExpiredSurfaceGate } from "./SessionExpiredSurfaceGate";++export function ReactApp() {+ return (+ <>+ <Watermark />+ <Toaster />+ <AgentWindow />+ <SessionExpiredSurfaceGate />+ </>+ );+}diff --git a/frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx b/frontend/src/react/app/SessionExpiredSurfaceGate.test.tsxnew file mode 100644index 0000000000..45bee04d68--- /dev/null+++ b/frontend/src/react/app/SessionExpiredSurfaceGate.test.tsx@@ -0,0 +1,110 @@+import { act } from "react";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, describe, expect, test, vi } from "vitest";+import { ref } from "vue";++const unauthenticatedOccurredRef = ref(false);+const isLoggedInRef = ref(true);+const fullPathRef = ref("/");+const routeNameRef = ref("workspace.dashboard");++vi.mock("@/react/hooks/useVueState", () => ({+ // Passthrough — calls getter() synchronously on each render. Does NOT+ // re-render when Vue state changes after mount; set state on the refs+ // above BEFORE rendering in each test.+ useVueState: <T,>(getter: () => T) => getter(),+}));++vi.mock("@/store", () => ({+ useAuthStore: () => ({+ get unauthenticatedOccurred() {+ return unauthenticatedOccurredRef.value;+ },+ get isLoggedIn() {+ return isLoggedInRef.value;+ },+ }),+}));++vi.mock("@/router", () => ({+ router: {+ currentRoute: {+ get value() {+ return { fullPath: fullPathRef.value, name: routeNameRef.value };+ },+ },+ },+}));++vi.mock("@/utils/auth", () => ({+ isAuthRelatedRoute: (name: string) =>+ [+ "auth.signin",+ "auth.signin.admin",+ "auth.signup",+ "auth.mfa",+ "auth.password.reset",+ "auth.password.forgot",+ "auth.oauth.callback",+ "auth.oidc.callback",+ ].includes(name),+}));++vi.mock("@/react/components/auth/SessionExpiredSurface", () => ({+ SessionExpiredSurface: ({ currentPath }: { currentPath: string }) => (+ <div data-testid="surface" data-path={currentPath} />+ ),+}));++import { SessionExpiredSurfaceGate } from "./SessionExpiredSurfaceGate";++describe("SessionExpiredSurfaceGate", () => {+ let container: HTMLDivElement;+ let root: Root;++ afterEach(() => {+ act(() => root.unmount());+ container.remove();+ unauthenticatedOccurredRef.value = false;+ isLoggedInRef.value = true;+ fullPathRef.value = "/";+ routeNameRef.value = "workspace.dashboard";+ });++ const render = () => {+ container = document.createElement("div");+ document.body.appendChild(container);+ root = createRoot(container);+ act(() => root.render(<SessionExpiredSurfaceGate />));+ };++ test("renders nothing when unauthenticatedOccurred is false", () => {+ render();+ expect(container.querySelector("[data-testid='surface']")).toBeNull();+ });++ test("renders SessionExpiredSurface with current path when triggered", () => {+ unauthenticatedOccurredRef.value = true;+ fullPathRef.value = "/projects/sample/plans/123";+ render();+ const surface = container.querySelector("[data-testid='surface']");+ expect(surface).not.toBeNull();+ expect(surface?.getAttribute("data-path")).toBe(+ "/projects/sample/plans/123"+ );+ });++ test("renders nothing while on an auth-related route", () => {+ unauthenticatedOccurredRef.value = true;+ routeNameRef.value = "auth.signin";+ render();+ expect(container.querySelector("[data-testid='surface']")).toBeNull();+ });++ test("renders nothing when user is not logged in", () => {+ unauthenticatedOccurredRef.value = true;+ isLoggedInRef.value = false;+ render();+ expect(container.querySelector("[data-testid='surface']")).toBeNull();+ });+});diff --git a/frontend/src/react/app/SessionExpiredSurfaceGate.tsx b/frontend/src/react/app/SessionExpiredSurfaceGate.tsxnew file mode 100644index 0000000000..834f3d8130--- /dev/null+++ b/frontend/src/react/app/SessionExpiredSurfaceGate.tsx@@ -0,0 +1,22 @@+import { SessionExpiredSurface } from "@/react/components/auth/SessionExpiredSurface";+import { useVueState } from "@/react/hooks/useVueState";+import { router } from "@/router";+import { useAuthStore } from "@/store";+import { isAuthRelatedRoute } from "@/utils/auth";++export function SessionExpiredSurfaceGate() {+ const isAuthRoute = useVueState(() =>+ isAuthRelatedRoute(String(router.currentRoute.value.name ?? ""))+ );+ const isLoggedIn = useVueState(() => useAuthStore().isLoggedIn);+ const unauthenticatedOccurred = useVueState(+ () => useAuthStore().unauthenticatedOccurred+ );+ const currentPath = useVueState(() => router.currentRoute.value.fullPath);+ // Match the guards that previously lived in AuthContext.vue: the+ // surface is only shown for an already-signed-in user on a non-auth+ // route who just lost their session — otherwise the modal would block+ // signin/signup flows.+ if (isAuthRoute || !isLoggedIn || !unauthenticatedOccurred) return null;+ return <SessionExpiredSurface currentPath={currentPath} />;+}diff --git a/frontend/src/react/app/mount.ts b/frontend/src/react/app/mount.tsnew file mode 100644index 0000000000..42e0533c48--- /dev/null+++ b/frontend/src/react/app/mount.ts@@ -0,0 +1,44 @@+import { watch } from "vue";+import { locale } from "@/plugins/i18n";+import { buildTree, loadCoreDeps, type ReactComponent } from "@/react/mount";++// import.meta.glob keeps vue-tsc from following into the .tsx file. Vite+// resolves the glob at build time and produces a lazy chunk.+const reactAppLoaders = import.meta.glob("./ReactApp.tsx");++async function loadReactApp(): Promise<ReactComponent> {+ const loader = reactAppLoaders["./ReactApp.tsx"] as+ | (() => Promise<Record<string, unknown>>)+ | undefined;+ if (!loader) {+ throw new Error("mountReactApp: ReactApp loader not registered");+ }+ const mod = await loader();+ return mod.ReactApp as ReactComponent;+}++export async function mountReactApp(selector: string) {+ const container = document.querySelector(selector);+ if (!container) {+ throw new Error(`mountReactApp: missing container ${selector}`);+ }++ const [deps, ReactApp] = await Promise.all([loadCoreDeps(), loadReactApp()]);++ // Sync initial locale before first paint.+ if (deps.i18n.language !== locale.value) {+ await deps.i18n.changeLanguage(locale.value);+ }++ const root = deps.createRoot(container);+ root.render(buildTree(deps, ReactApp));++ // Ongoing Vue→React locale sync for the long-lived React app.+ watch(locale, async (next) => {+ if (deps.i18n.language !== next) {+ await deps.i18n.changeLanguage(next);+ }+ });++ return root;+}diff --git a/frontend/src/react/components/EngineIcon.tsx b/frontend/src/react/components/EngineIcon.tsxindex 0a9e4fd4da..1ea13da458 100644--- a/frontend/src/react/components/EngineIcon.tsx+++ b/frontend/src/react/components/EngineIcon.tsx@@ -1,5 +1,5 @@import type { ComponentPropsWithoutRef } from "react";-import { EngineIconPath } from "@/components/InstanceForm/constants";+import { EngineIconPath } from "@/react/components/instance/constants";import { cn } from "@/react/lib/utils";import type { Engine } from "@/types/proto-es/v1/common_pb";diff --git a/frontend/src/react/components/auth/SessionExpiredSurface.test.tsx b/frontend/src/react/components/auth/SessionExpiredSurface.test.tsxindex b7f9140854..9743072c41 100644--- a/frontend/src/react/components/auth/SessionExpiredSurface.test.tsx+++ b/frontend/src/react/components/auth/SessionExpiredSurface.test.tsx@@ -1,8 +1,6 @@-import { flushPromises, mount } from "@vue/test-utils";import { act } from "react";import { createRoot } from "react-dom/client";import { afterEach, describe, expect, test, vi } from "vitest";-import { nextTick } from "vue";vi.mock("@/react/pages/auth/SigninPage", () => ({SigninPage: () => <button data-testid="signin-bridge">Sign in</button>,@@ -20,65 +18,6 @@ vi.mock("react-i18next", () => ({}),}));-const mountMocks = vi.hoisted(() => ({- reactI18nLanguage: { value: "en-US" },- changeLanguage: vi.fn(async (locale: string) => {- mountMocks.reactI18nLanguage.value = locale;- }),- mountReactPage: vi.fn(async () => ({ unmount: vi.fn() })),- routePath: null as unknown,- updateReactPage: vi.fn(async () => {}),- locale: null as { value: string } | null,- reactI18n: {- get language() {- return mountMocks.reactI18nLanguage.value;- },- changeLanguage: vi.fn(async (locale: string) => {- mountMocks.reactI18nLanguage.value = locale;- }),- },-}));--mountMocks.reactI18n.changeLanguage = mountMocks.changeLanguage;--vi.mock("@/react/i18n", () => ({- default: mountMocks.reactI18n,-}));--vi.mock("@/react/mount", () => ({- mountReactPage: mountMocks.mountReactPage,- updateReactPage: mountMocks.updateReactPage,-}));--vi.mock("vue-i18n", async () => {- const { ref } = await import("vue");- mountMocks.locale ||= ref("zh-CN");-- return {- useI18n: () => ({- locale: mountMocks.locale,- }),- };-});--vi.mock("vue-router", async () => {- const { ref } = await import("vue");- mountMocks.routePath ||= ref("/instances");-- return {- useRoute: () => ({- get fullPath() {- return (- mountMocks.routePath as {- value: string;- }- ).value;- },- }),- };-});--import SessionExpiredSurfaceMount from "@/components/SessionExpiredSurfaceMount.vue";import { Dialog, DialogContent } from "@/react/components/ui/dialog";import { SessionExpiredSurface } from "./SessionExpiredSurface";@@ -89,16 +28,6 @@ import { SessionExpiredSurface } from "./SessionExpiredSurface";describe("SessionExpiredSurface", () => {afterEach(() => {document.body.innerHTML = "";- mountMocks.changeLanguage.mockClear();- mountMocks.mountReactPage.mockClear();- mountMocks.updateReactPage.mockClear();- mountMocks.locale!.value = "zh-CN";- mountMocks.reactI18nLanguage.value = "en-US";- (- mountMocks.routePath as {- value: string;- }- ).value = "/instances";});test("mounts into the critical root", async () => {@@ -226,192 +155,4 @@ describe("SessionExpiredSurface", () => {root.unmount();});});-- test("syncs React i18n before the initial mount", async () => {- const calls: string[] = [];- mountMocks.changeLanguage.mockImplementation(async () => {- calls.push("changeLanguage");- });- mountMocks.mountReactPage.mockImplementation(async () => {- calls.push("mountReactPage");- return { unmount: vi.fn() };- });-- const wrapper = mount(SessionExpiredSurfaceMount);- await flushPromises();-- await vi.waitFor(() => {- expect(mountMocks.changeLanguage).toHaveBeenCalledWith("zh-CN");- expect(mountMocks.mountReactPage).toHaveBeenCalledTimes(1);- expect(calls).toEqual(["changeLanguage", "mountReactPage"]);- });-- wrapper.unmount();- });-- test("reconciles the latest route after async mount resolves", async () => {- let resolveMount: ((root: unknown) => void) | undefined;- const mountedRoot = { unmount: vi.fn(() => {}) };- mountMocks.mountReactPage.mockImplementation(- () =>- new Promise((resolve) => {- resolveMount = (root) => {- resolve(root as { unmount: typeof mountedRoot.unmount });- };- })- );-- const wrapper = mount(SessionExpiredSurfaceMount);- await flushPromises();-- expect(mountMocks.mountReactPage).toHaveBeenCalledWith(- expect.any(HTMLDivElement),- "SessionExpiredSurface",- { currentPath: "/instances" }- );-- (- mountMocks.routePath as {- value: string;- }- ).value = "/projects/demo";- await nextTick();- await flushPromises();-- expect(mountMocks.updateReactPage).not.toHaveBeenCalled();-- resolveMount?.(mountedRoot);- await flushPromises();-- await vi.waitFor(() => {- expect(mountMocks.updateReactPage).toHaveBeenCalledWith(- mountedRoot,- "SessionExpiredSurface",- { currentPath: "/projects/demo" }- );- });-- wrapper.unmount();- });-- test("unmounts late-mounted roots when the Vue bridge is already gone", async () => {- let resolveMount: ((root: unknown) => void) | undefined;- const mountedRoot = { unmount: vi.fn(() => {}) };- mountMocks.mountReactPage.mockImplementation(- () =>- new Promise((resolve) => {- resolveMount = (root) => {- resolve(root as { unmount: typeof mountedRoot.unmount });- };- })- );-- const wrapper = mount(SessionExpiredSurfaceMount);- await flushPromises();-- wrapper.unmount();- resolveMount?.(mountedRoot);- await flushPromises();-- expect(mountedRoot.unmount).toHaveBeenCalledTimes(1);- });-- test("keeps the newest route when async syncs finish out of order", async () => {- const mountedRoot = { unmount: vi.fn(() => {}) };- const pendingLanguageChanges: Array<() => void> = [];- let changeLanguageCall = 0;-- mountMocks.changeLanguage.mockImplementation(async () => {- changeLanguageCall++;- if (changeLanguageCall === 1) {- return;- }- await new Promise<void>((resolve) => {- pendingLanguageChanges.push(resolve);- });- });- mountMocks.mountReactPage.mockResolvedValue(mountedRoot);-- const wrapper = mount(SessionExpiredSurfaceMount);- await flushPromises();-- (- mountMocks.routePath as {- value: string;- }- ).value = "/projects/first";- await nextTick();- await flushPromises();-- (- mountMocks.routePath as {- value: string;- }- ).value = "/projects/second";- await nextTick();- await flushPromises();-- expect(pendingLanguageChanges).toHaveLength(1);-- await flushPromises();- pendingLanguageChanges[0]?.();- await flushPromises();-- expect(pendingLanguageChanges).toHaveLength(2);-- pendingLanguageChanges[1]?.();- await flushPromises();-- expect(mountMocks.updateReactPage).toHaveBeenLastCalledWith(- mountedRoot,- "SessionExpiredSurface",- { currentPath: "/projects/second" }- );-- wrapper.unmount();- });-- test("keeps the newest locale when async locale syncs finish out of order", async () => {- const mountedRoot = { unmount: vi.fn(() => {}) };- const pendingLanguageChanges = new Map<string, () => void>();-- mountMocks.mountReactPage.mockResolvedValue(mountedRoot);- mountMocks.changeLanguage.mockImplementation(async (locale: string) => {- if (locale === "zh-CN") {- mountMocks.reactI18nLanguage.value = locale;- return;- }- await new Promise<void>((resolve) => {- pendingLanguageChanges.set(locale, () => {- mountMocks.reactI18nLanguage.value = locale;- resolve();- });- });- });-- const wrapper = mount(SessionExpiredSurfaceMount);- await flushPromises();-- mountMocks.locale!.value = "fr-FR";- await nextTick();- await flushPromises();-- mountMocks.locale!.value = "de-DE";- await nextTick();- await flushPromises();-- expect(pendingLanguageChanges.size).toBe(1);-- pendingLanguageChanges.get("fr-FR")?.();- await flushPromises();-- expect(pendingLanguageChanges.size).toBe(2);-- pendingLanguageChanges.get("de-DE")?.();- await flushPromises();-- expect(mountMocks.reactI18n.language).toBe("de-DE");-- wrapper.unmount();- });});diff --git a/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsx b/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsxindex e11d15c57b..d8f95ebe3a 100644--- a/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsx+++ b/frontend/src/react/components/sql-editor/ConnectionPane/ConnectionPane.test.tsx@@ -192,7 +192,7 @@ vi.mock("@/utils", () => ({instanceV1Name: (i: { title: string }) => i.title,}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: { MYSQL: "/mysql.svg" },}));diff --git a/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsx b/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsxindex ad215a0e9f..27587ae237 100644--- a/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsx+++ b/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/DatabaseNode.test.tsx@@ -25,7 +25,7 @@ vi.mock("@/react/hooks/useVueState", () => ({useVueState: mocks.useVueState,}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: { MYSQL: "/icon/mysql.svg" },}));diff --git a/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsx b/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsxindex 4b15b86d1e..c8e31b57b8 100644--- a/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsx+++ b/frontend/src/react/components/sql-editor/ConnectionPane/TreeNode/InstanceNode.test.tsx@@ -16,7 +16,7 @@ vi.mock("@/utils", () => ({instanceV1Name: (inst: { title: string }) => inst.title,}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: {MYSQL: "/icon/mysql.svg",UNSUPPORTED: "",diff --git a/frontend/src/react/components/sql-editor/DatabaseChooser.test.tsx b/frontend/src/react/components/sql-editor/DatabaseChooser.test.tsxindex c706716294..602fd2f4db 100644--- a/frontend/src/react/components/sql-editor/DatabaseChooser.test.tsx+++ b/frontend/src/react/components/sql-editor/DatabaseChooser.test.tsx@@ -58,7 +58,7 @@ vi.mock("@/utils", () => ({getInstanceResource: mocks.getInstanceResource,}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: mocks.EngineIconPath,}));diff --git a/frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsx b/frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsxindex 4bb96726a6..b1b3cebe81 100644--- a/frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsx+++ b/frontend/src/react/components/sql-editor/ReadonlyModeNotSupported.test.tsx@@ -45,7 +45,7 @@ vi.mock("@/store", () => ({})),}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: {[Engine.POSTGRES]: "/icons/postgres.svg",} as Record<string, string>,diff --git a/frontend/src/react/components/sql-editor/RequestQueryButton.test.tsx b/frontend/src/react/components/sql-editor/RequestQueryButton.test.tsxindex 8a29f714f5..ae38501bf1 100644--- a/frontend/src/react/components/sql-editor/RequestQueryButton.test.tsx+++ b/frontend/src/react/components/sql-editor/RequestQueryButton.test.tsx@@ -37,7 +37,7 @@ vi.mock("@/store", () => ({hasFeature: mocks.hasFeature,}));-vi.mock("@/components/RoleGrantPanel/DatabaseResourceForm/common", () => ({+vi.mock("@/utils/v1/databaseResource", () => ({parseStringToResource: mocks.parseStringToResource,}));diff --git a/frontend/src/react/components/sql-editor/RequestQueryButton.tsx b/frontend/src/react/components/sql-editor/RequestQueryButton.tsxindex 7ff0d7adfb..8c6a42b136 100644--- a/frontend/src/react/components/sql-editor/RequestQueryButton.tsx+++ b/frontend/src/react/components/sql-editor/RequestQueryButton.tsx@@ -1,7 +1,6 @@import { ShieldUser } from "lucide-react";import { useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import { parseStringToResource } from "@/components/RoleGrantPanel/DatabaseResourceForm/common";import { FeatureBadge } from "@/react/components/FeatureBadge";import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";@@ -20,6 +19,7 @@ import { PRESET_ROLES, PresetRoleType } from "@/types";import type { PermissionDeniedDetail } from "@/types/proto-es/v1/common_pb";import type { Role } from "@/types/proto-es/v1/role_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";+import { parseStringToResource } from "@/utils/v1/databaseResource";import { AccessGrantRequestDrawer } from "./AccessGrantRequestDrawer";import { useRequestDrawerHost } from "./RequestDrawerHost";diff --git a/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx b/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsxindex 4df181e88b..b54b6dc4fe 100644--- a/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx+++ b/frontend/src/react/components/sql-editor/ResultPanel/BatchQuerySelect.tsx@@ -4,13 +4,13 @@ import { head } from "lodash-es";import { CircleAlert, Eye, EyeOff, X } from "lucide-react";import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import { EngineIconPath } from "@/components/InstanceForm/constants";import {DataExportButton,type DataExportRequest,type DownloadContent,} from "@/react/components/DataExportButton";import { DatabaseTableView } from "@/react/components/database";+import { EngineIconPath } from "@/react/components/instance/constants";import { Button } from "@/react/components/ui/button";import { Tooltip } from "@/react/components/ui/tooltip";import { useVueState } from "@/react/hooks/useVueState";diff --git a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsx b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsxindex e98e688a76..b04cc98495 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/SchemaPane.test.tsx@@ -123,6 +123,9 @@ vi.mock("@/utils/v1/instance", () => ({instanceV1SupportsPackage: () => false,instanceV1SupportsSequence: () => false,}));+vi.mock("@/react/components/instance/constants", () => ({+ EngineIconPath: { MYSQL: "/mysql.svg" } as Record<string, string>,+}));vi.mock("@/router", () => ({ router: { resolve: () => ({ href: "/" }) } }));vi.mock("@/router/sqlEditor", () => ({@@ -194,10 +197,6 @@ vi.mock("@/react/components/TableSchemaViewer", () => ({TableSchemaViewer: () => <div data-testid="table-schema-viewer" />,}));-vi.mock("@/components/InstanceForm/constants", () => ({- EngineIconPath: { MYSQL: "/mysql.svg" } as Record<string, string>,-}));-vi.mock("@base-ui/react/menu", () => ({Menu: { Trigger: () => null },}));diff --git a/frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsx b/frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsxindex b48001a1df..9a2621b922 100644--- a/frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsx+++ b/frontend/src/react/components/sql-editor/SheetConnectionIcon.test.tsx@@ -22,7 +22,7 @@ vi.mock("@/utils", () => ({getConnectionForSQLEditorTab: mocks.getConnectionForSQLEditorTab,}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: {[Engine.POSTGRES]: "/icons/postgres.svg",} as Record<string, string>,diff --git a/frontend/src/react/mount.test.ts b/frontend/src/react/mount.test.tsindex f31c7fdf37..0f4bf22c46 100644--- a/frontend/src/react/mount.test.ts+++ b/frontend/src/react/mount.test.ts@@ -2,13 +2,21 @@ import { describe, expect, test } from "vitest";import { resolveReactPagePath } from "./mount";describe("resolveReactPagePath", () => {- test("resolves the session expired surface entry", () => {- expect(resolveReactPagePath("SessionExpiredSurface")).toBe(- "./components/auth/SessionExpiredSurface.tsx"+ test("resolves the InactiveRemindModal entry", () => {+ expect(resolveReactPagePath("InactiveRemindModal")).toBe(+ "./components/auth/InactiveRemindModal.tsx");});+ test("does not resolve AgentWindow (now in the React app)", () => {+ expect(resolveReactPagePath("AgentWindow")).toBeUndefined();+ });++ test("does not resolve SessionExpiredSurface (now in the React app)", () => {+ expect(resolveReactPagePath("SessionExpiredSurface")).toBeUndefined();+ });+test("does not resolve auth test modules as runtime pages", () => {- expect(resolveReactPagePath("SessionExpiredSurface.test")).toBeUndefined();+ expect(resolveReactPagePath("InactiveRemindModal.test")).toBeUndefined();});});diff --git a/frontend/src/react/mount.ts b/frontend/src/react/mount.tsindex b12b75fdfb..f99d1f8ba5 100644--- a/frontend/src/react/mount.ts+++ b/frontend/src/react/mount.ts@@ -5,13 +5,9 @@ const projectPageLoaders = import.meta.glob(["./pages/project/*.tsx","./pages/project/plan-detail/ProjectPlanDetailPage.tsx",]);-const pluginComponentLoaders = import.meta.glob(- "./plugins/agent/components/AgentWindow.tsx"-);const workspacePageLoaders = import.meta.glob("./pages/workspace/*.tsx");const authPageLoaders = import.meta.glob("./pages/auth/*.tsx");const authComponentLoaders = import.meta.glob([- "./components/auth/SessionExpiredSurface.tsx","./components/auth/InactiveRemindModal.tsx",]);const sqlEditorComponentLoaders = import.meta.glob(@@ -24,7 +20,6 @@ const sharedComponentLoaders = import.meta.glob([const pageLoaders = {...settingsPageLoaders,...projectPageLoaders,- ...pluginComponentLoaders,...workspacePageLoaders,...authPageLoaders,...authComponentLoaders,@@ -33,14 +28,14 @@ const pageLoaders = {};// biome-ignore lint/suspicious/noExplicitAny: React types conflict with Vue JSX in vue-tsc-type ReactDeps = any; // eslint-disable-line @typescript-eslint/no-explicit-any+export type ReactDeps = any; // eslint-disable-line @typescript-eslint/no-explicit-any// biome-ignore lint/suspicious/noExplicitAny: Component type checked by tsconfig.react.json-type ReactComponent = (props: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-any+export type ReactComponent = (props: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-anylet cachedDeps: ReactDeps | null = null;const cachedPages = new Map<string, ReactComponent>();-async function loadCoreDeps() {+export async function loadCoreDeps() {if (cachedDeps) return cachedDeps;const [{ createElement, StrictMode },@@ -68,7 +63,6 @@ const pageDirs = ["./pages/settings","./pages/project","./pages/project/plan-detail",- "./plugins/agent/components","./pages/workspace","./pages/auth","./components/auth",@@ -109,7 +103,7 @@ async function loadPage(name: string): Promise<ReactComponent> {*/// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-ignore -- React createElement types conflict with Vue JSX in vue-tsc-function buildTree(+export function buildTree(deps: ReactDeps,Component: ReactComponent,// biome-ignore lint/suspicious/noExplicitAny: Props type varies per pagediff --git a/frontend/src/react/mountToaster.ts b/frontend/src/react/mountToaster.tsdeleted file mode 100644index c32caa473f..0000000000--- a/frontend/src/react/mountToaster.ts+++ /dev/null@@ -1,62 +0,0 @@-// Use import.meta.glob so vue-tsc does not follow the import into React .tsx files.-// Vite resolves the glob at build time and creates a lazy chunk for the matched module.-const toasterLoader = import.meta.glob("./components/ui/toaster.tsx");--// biome-ignore lint/suspicious/noExplicitAny: React types conflict with Vue JSX in vue-tsc-type ReactDeps = any; // eslint-disable-line @typescript-eslint/no-explicit-any--let cachedDeps: ReactDeps | null = null;--async function loadCoreDeps() {- if (cachedDeps) return cachedDeps;- const [- { createElement, StrictMode },- { createRoot },- { I18nextProvider },- i18nModule,- ] = await Promise.all([- import("react"),- import("react-dom/client"),- import("react-i18next"),- import("@/react/i18n"),- ]);- await i18nModule.i18nReady;- cachedDeps = {- createElement,- StrictMode,- createRoot,- I18nextProvider,- i18n: i18nModule.default,- };- return cachedDeps;-}--async function loadToaster() {- const loader = toasterLoader["./components/ui/toaster.tsx"];- if (!loader) throw new Error("Toaster not found");- const mod = (await loader()) as Record<string, unknown>;- return mod.Toaster as ReactDeps;-}--/**- * Mount the persistent <Toaster /> into the given container. Called once- * at app bootstrap; the root lives until page unload. The bb.vue-notification- * listener is already registered (main.ts side-effect-imports- * @/react/lib/toast); this function only attaches the Provider so queued- * toasts can render.- */-export async function mountToaster(container: HTMLElement) {- const [deps, Toaster] = await Promise.all([loadCoreDeps(), loadToaster()]);- const tree = deps.createElement(- deps.StrictMode,- null,- deps.createElement(- deps.I18nextProvider,- { i18n: deps.i18n },- deps.createElement(Toaster)- )- );- const root = deps.createRoot(container);- root.render(tree);- return root;-}diff --git a/frontend/src/react/no-legacy-vue-deps.test.ts b/frontend/src/react/no-legacy-vue-deps.test.tsindex 0aa4f6c0c2..d6705df2e5 100644--- a/frontend/src/react/no-legacy-vue-deps.test.ts+++ b/frontend/src/react/no-legacy-vue-deps.test.ts@@ -56,7 +56,6 @@ describe("React Project and Settings legacy Vue dependencies", () => {const bannedImports = ["@/components/Permission/RoutePermissionGuard.vue","@/components/Permission/ComponentPermissionGuard.vue",- "@/components/RoleGrantPanel","./RoleGrantPanel.vue","@/components/FeatureGuard","@/components/IssueV1/components/Sidebar/IssueLabels",diff --git a/frontend/src/react/no-react-to-vue-imports.test.ts b/frontend/src/react/no-react-to-vue-imports.test.tsindex 11d06c144b..db9fb10d76 100644--- a/frontend/src/react/no-react-to-vue-imports.test.ts+++ b/frontend/src/react/no-react-to-vue-imports.test.ts@@ -11,10 +11,7 @@ const sources = import.meta.glob("./**/*.{ts,tsx}", {// Mount-bridge Vue files that React code is permitted to import until Phase B// retires the Vue app shell. Adding new entries here requires explicit review.-const allowedVueImports = new Set([- "@/components/SessionExpiredSurfaceMount.vue",- "@/components/AgentWindowMount.vue",-]);+const allowedVueImports = new Set<string>();const vueImportPattern = /from\s+["']([^"']+\.vue)["']/g;diff --git a/frontend/src/react/pages/project/ProjectDatabaseDetailPage.test.tsx b/frontend/src/react/pages/project/ProjectDatabaseDetailPage.test.tsxindex 5bd5ca1aac..b142505fe2 100644--- a/frontend/src/react/pages/project/ProjectDatabaseDetailPage.test.tsx+++ b/frontend/src/react/pages/project/ProjectDatabaseDetailPage.test.tsx@@ -290,10 +290,6 @@ vi.mock("@/connect", () => ({},}));-vi.mock("@/components/SchemaDiagram", () => ({- default: mocks.schemaDiagram,-}));-vi.mock("@/plugins/highlight", () => ({default: mocks.highlightPlugin,}));diff --git a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsxindex f3304dbce5..305d61831d 100644--- a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx+++ b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx@@ -45,8 +45,6 @@ vi.mock("react-i18next", () => ({}),}));-vi.mock("@/components/ExprEditor/context", () => ({}));-vi.mock("@/react/lib/sensitive-data/components-utils", () => ({getClassificationLevelOptions: () => [],}));diff --git a/frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsx b/frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsxindex d954609df1..9b9e7cd6a5 100644--- a/frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsx+++ b/frontend/src/react/pages/project/export-center/DataExportPrepSheet.test.tsx@@ -136,7 +136,7 @@ vi.mock("@/router/dashboard/projectV1", () => ({PROJECT_V1_ROUTE_ISSUE_DETAIL: "issue-detail",}));-vi.mock("@/components/InstanceForm/constants", () => ({+vi.mock("@/react/components/instance/constants", () => ({EngineIconPath: {},}));diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsxindex 68a3c812bf..d7b9dfa40b 100644--- a/frontend/src/react/pages/settings/MembersPage.tsx+++ b/frontend/src/react/pages/settings/MembersPage.tsx@@ -18,9 +18,6 @@ import React, {useState,} from "react";import { useTranslation } from "react-i18next";-import { groupProjectRoleBindings } from "@/components/Member/projectRoleBindings";-import type { GroupBinding, MemberBinding } from "@/components/Member/types";-import { getMemberBindings } from "@/components/Member/utils";import { AccountMultiSelect } from "@/react/components/AccountMultiSelect";import { DatabaseResourceSelector as DatabaseResourceSelectorComponent } from "@/react/components/DatabaseResourceSelector";import { EnvironmentMultiSelect } from "@/react/components/EnvironmentMultiSelect";@@ -96,6 +93,7 @@ import { type Binding, BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import type { User } from "@/types/proto-es/v1/user_service_pb";+import type { GroupBinding, MemberBinding } from "@/types/v1/member";import { AccountType, getAccountTypeByEmail } from "@/types/v1/user";import {displayRoleTitle,@@ -110,6 +108,7 @@ import {convertFromExpr,stringifyConditionExpression,} from "@/utils/issue/cel";+import { getMemberBindings, groupProjectRoleBindings } from "@/utils/v1/member";import { MemberBindingEnvironmentBanner } from "./MemberBindingEnvironmentBanner";import { MemberDatabaseResourceName } from "./MemberDatabaseResourceName";import { getSetIamPolicyPermissionGuardConfig } from "./membersPageActions";diff --git a/frontend/src/react/pages/settings/general/SecuritySection.tsx b/frontend/src/react/pages/settings/general/SecuritySection.tsxindex 9278cc74e8..437ad8ab2f 100644--- a/frontend/src/react/pages/settings/general/SecuritySection.tsx+++ b/frontend/src/react/pages/settings/general/SecuritySection.tsx@@ -19,6 +19,7 @@ import {import { Checkbox } from "@/react/components/ui/checkbox";import { Input } from "@/react/components/ui/input";import { usePlanFeature } from "@/react/hooks/useAppState";+import { useAppStore } from "@/react/stores/app";import { useSettingV1Store } from "@/store/modules/v1/setting";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import type { SectionHandle } from "./useSettingSection";@@ -165,6 +166,12 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(}),});}++ // Pinia and the React app store both cache the workspace profile.+ // Pinia's computed updates automatically; the React store is a+ // load-once cache, so we refresh it here so consumers like+ // <Watermark /> and <BannersWrapper /> pick up the new values.+ await useAppStore.getState().loadWorkspaceProfile(true);}, [state, domainInput, settingV1Store, getInitialState]);useImperativeHandle(ref, () => ({ isDirty, revert, update }));diff --git a/frontend/src/react/stores/app/types.ts b/frontend/src/react/stores/app/types.tsindex 4c91916d78..a6e08b1de0 100644--- a/frontend/src/react/stores/app/types.ts+++ b/frontend/src/react/stores/app/types.ts@@ -56,7 +56,9 @@ export type WorkspaceSlice = {loadWorkspace: () => Promise<Workspace | undefined>;loadWorkspaceList: () => Promise<Workspace[]>;switchWorkspace: (workspaceName: string) => Promise<void>;- loadWorkspaceProfile: () => Promise<WorkspaceProfileSetting | undefined>;+ loadWorkspaceProfile: (+ force?: boolean+ ) => Promise<WorkspaceProfileSetting | undefined>;loadEnvironmentList: (force?: boolean) => Promise<Environment[]>;refreshEnvironmentList: () => Promise<Environment[]>;loadSubscription: () => Promise<Subscription | undefined>;diff --git a/frontend/src/react/stores/app/workspace.ts b/frontend/src/react/stores/app/workspace.tsindex d618c29c2b..26b281e948 100644--- a/frontend/src/react/stores/app/workspace.ts+++ b/frontend/src/react/stores/app/workspace.ts@@ -189,11 +189,14 @@ export const createWorkspaceSlice: AppSliceCreator<WorkspaceSlice> = (window.location.href = "/";},- loadWorkspaceProfile: async () => {+ loadWorkspaceProfile: async (force = false) => {const existing = get().workspaceProfile;- if (existing) return existing;+ if (!force && existing) return existing;const pending = get().workspaceProfileRequest;- if (pending) return pending;+ if (!force && pending) return pending;+ // request is captured so .then handlers can identity-check against+ // the latest in-flight request before writing — protects against an+ // older in-flight request resolving after a newer forced reload.const request = settingServiceClientConnect.getSetting(createProto(GetSettingRequestSchema, {@@ -201,6 +204,9 @@ export const createWorkspaceSlice: AppSliceCreator<WorkspaceSlice> = (})).then((setting) => {+ if (get().workspaceProfileRequest !== request) {+ return get().workspaceProfile;+ }const settingValue = setting.value?.value;const profile =settingValue?.case === "workspaceProfile"@@ -216,7 +222,9 @@ export const createWorkspaceSlice: AppSliceCreator<WorkspaceSlice> = (return profile;}).catch(() => {- set({ workspaceProfileRequest: undefined });+ if (get().workspaceProfileRequest === request) {+ set({ workspaceProfileRequest: undefined });+ }return undefined;});set({ workspaceProfileRequest: request });diff --git a/frontend/src/shell-bridge.test.ts b/frontend/src/shell-bridge.test.tsindex d3fc1f598e..cd49bec886 100644--- a/frontend/src/shell-bridge.test.ts+++ b/frontend/src/shell-bridge.test.ts@@ -75,18 +75,6 @@ vi.mock("./AuthContext.vue", async () => {};});-vi.mock("./components/misc/OverlayStackManager.vue", async () => {- const { defineComponent, h } = await import("vue");- return {- default: defineComponent({- name: "MockOverlayStackManager",- setup(_, { slots }) {- return () => h("div", slots.default?.());- },- }),- };-});-vi.mock("./customAppProfile", () => ({overrideAppProfile: mocks.overrideAppProfile,}));diff --git a/frontend/src/components/Member/types.ts b/frontend/src/types/v1/member.tssimilarity index 89%rename from frontend/src/components/Member/types.tsrename to frontend/src/types/v1/member.tsindex 2741f6b7bd..5e4371dfb1 100644--- a/frontend/src/components/Member/types.ts+++ b/frontend/src/types/v1/member.ts@@ -13,8 +13,7 @@ export interface GroupBinding extends Group {export interface MemberBinding extends MemberRole {title: string;- // binidng is the fullname for binding member,- // like user:{email} or group:{email}+ // The fullname for the binding member: `user:{email}` or `group:{email}`.binding: string;type: "users" | "groups";user?: User;diff --git a/frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.ts b/frontend/src/utils/v1/databaseResource.tssimilarity index 96%rename from frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.tsrename to frontend/src/utils/v1/databaseResource.tsindex 7791ac11ec..8985ac48d5 100644--- a/frontend/src/components/RoleGrantPanel/DatabaseResourceForm/common.ts+++ b/frontend/src/utils/v1/databaseResource.ts@@ -35,11 +35,11 @@ export interface DatabaseTreeOption<L = DatabaseResourceType>export const mapTreeOptions = ({databaseList,filterValueList,- includeCloumn,+ includeColumn,}: {databaseList: Database[];filterValueList?: string[];- includeCloumn: boolean;+ includeColumn: boolean;}) => {const databaseNodes: DatabaseTreeOption<"databases">[] = [];const filteredDatabaseList = filterValueList@@ -58,7 +58,7 @@ export const mapTreeOptions = ({children: getSchemaOrTableTreeOptions({database,filterValueList,- includeCloumn,+ includeColumn,}),};if (!isUndefined(databaseNode.children)) {@@ -74,12 +74,12 @@ const getTableTreeOptions = ({prefix,tableList,filterValueList,- includeCloumn,+ includeColumn,}: {prefix: string;tableList: TableMetadata[];filterValueList?: string[];- includeCloumn: boolean;+ includeColumn: boolean;}): DatabaseTreeOption<"tables">[] => {const tableNodes = tableList.map((table): DatabaseTreeOption<"tables"> => {const option: DatabaseTreeOption<"tables"> = {@@ -88,7 +88,7 @@ const getTableTreeOptions = ({label: table.name,isLeaf: true,};- if (includeCloumn) {+ if (includeColumn) {option.children = table.columns.map((column): DatabaseTreeOption<"columns"> => ({level: "columns",@@ -120,11 +120,11 @@ const getTableTreeOptions = ({export const getSchemaOrTableTreeOptions = ({database,filterValueList,- includeCloumn,+ includeColumn,}: {database: Database;filterValueList?: string[];- includeCloumn: boolean;+ includeColumn: boolean;}) => {if (getInstanceResource(database).engine === Engine.MONGODB) {// do not support table level select for MongoDB.@@ -149,7 +149,7 @@ export const getSchemaOrTableTreeOptions = ({prefix: value,tableList: schema.tables,filterValueList,- includeCloumn,+ includeColumn,}),isLeaf: true,};@@ -173,7 +173,7 @@ export const getSchemaOrTableTreeOptions = ({databaseMetadata.schemas.map((schema) => schema.tables)),filterValueList,- includeCloumn,+ includeColumn,});}};diff --git a/frontend/src/utils/v1/issue/rollout.ts b/frontend/src/utils/v1/issue/rollout.tsindex 32bbe53de1..339f4ed8e6 100644--- a/frontend/src/utils/v1/issue/rollout.ts+++ b/frontend/src/utils/v1/issue/rollout.ts@@ -1,4 +1,3 @@-import { TASK_STATUS_FILTERS } from "@/components/RolloutV1/constants/task";import { t as translate } from "@/plugins/i18n";import { useDatabaseV1Store } from "@/store";import { isValidDatabaseName, UNKNOWN_ID, unknownDatabase } from "@/types";@@ -16,6 +15,7 @@ import {extractCoreDatabaseInfoFromDatabaseCreateTask,mockDatabase,} from "./issue";+import { TASK_STATUS_FILTERS } from "./task";export const extractPlanUIDFromRolloutName = (name: string) => {const pattern = /(?:^|\/)plans\/([^/]+)\/rollout(?:$|\/)/;diff --git a/frontend/src/components/RolloutV1/constants/task.ts b/frontend/src/utils/v1/issue/task.tssimilarity index 100%rename from frontend/src/components/RolloutV1/constants/task.tsrename to frontend/src/utils/v1/issue/task.tsdiff --git a/frontend/src/components/Member/utils.test.ts b/frontend/src/utils/v1/member.test.tssimilarity index 94%rename from frontend/src/components/Member/utils.test.tsrename to frontend/src/utils/v1/member.test.tsindex efc821320b..5fe15ef2a3 100644--- a/frontend/src/components/Member/utils.test.ts+++ b/frontend/src/utils/v1/member.test.ts@@ -2,10 +2,7 @@ import { create } from "@bufbuild/protobuf";import { describe, expect, test } from "vitest";import { ExprSchema as ConditionExprSchema } from "@/types/proto-es/google/type/expr_pb";import { BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";-import {- getProjectRoleBindingKey,- groupProjectRoleBindings,-} from "./projectRoleBindings";+import { getProjectRoleBindingKey, groupProjectRoleBindings } from "./member";describe("groupProjectRoleBindings", () => {test("groups repeated roles without dropping distinct bindings", () => {diff --git a/frontend/src/components/Member/utils.ts b/frontend/src/utils/v1/member.tssimilarity index 79%rename from frontend/src/components/Member/utils.tsrename to frontend/src/utils/v1/member.tsindex 1eaa5db4f3..efba094099 100644--- a/frontend/src/components/Member/utils.ts+++ b/frontend/src/utils/v1/member.ts@@ -20,11 +20,12 @@ import {groupBindingPrefix,unknownUser,} from "@/types";+import { PRESET_ROLES } from "@/types/iam/role";import { GroupSchema } from "@/types/proto-es/v1/group_service_pb";-import type { IamPolicy } from "@/types/proto-es/v1/iam_policy_pb";+import type { Binding, IamPolicy } from "@/types/proto-es/v1/iam_policy_pb";import { type User, UserSchema } from "@/types/proto-es/v1/user_service_pb";+import type { GroupBinding, MemberBinding } from "@/types/v1/member";import { convertMemberToFullname, hasWorkspacePermissionV2 } from "@/utils";-import type { GroupBinding, MemberBinding } from "./types";const getMemberBinding = (member: string,@@ -170,3 +171,49 @@ export const getMemberBindings = ({["asc", "desc"]);};++export interface ProjectRoleBindingGroup {+ role: string;+ bindings: Binding[];+}++export const getProjectRoleBindingKey = (+ binding: Binding,+ index: number+): string => {+ return [+ binding.role,+ binding.condition?.expression ?? "",+ binding.condition?.description ?? "",+ index,+ ].join("::");+};++export const groupProjectRoleBindings = (+ bindings: Binding[]+): ProjectRoleBindingGroup[] => {+ const roleMap = new Map<string, Binding[]>();++ for (const binding of bindings) {+ if (!roleMap.has(binding.role)) {+ roleMap.set(binding.role, []);+ }+ roleMap.get(binding.role)?.push(binding);+ }++ return [...roleMap.keys()]+ .sort((a, b) => {+ const priority = (role: string) => {+ const presetRoleIndex = PRESET_ROLES.indexOf(role);+ if (presetRoleIndex !== -1) {+ return presetRoleIndex;+ }+ return PRESET_ROLES.length;+ };+ return priority(a) - priority(b);+ })+ .map((role) => ({+ role,+ bindings: roleMap.get(role) ?? [],+ }));+};