Skip to content

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

perf(ci): collapse frontend PR checks into one test gate (#21388)

Danny Xub6da3e5b6913
diff --git a/.github/workflows/frontend-tests-default.yml b/.github/workflows/frontend-tests-default.yml
index 38c9c7acbd..2b5952db3e 100644
--- a/.github/workflows/frontend-tests-default.yml
+++ b/.github/workflows/frontend-tests-default.yml
@@ -12,11 +12,6 @@ on:
permissions: {}
jobs:
- static-checks:
- runs-on: ubuntu-latest
- steps:
- - run: 'echo "Not required"'
-
frontend-tests:
runs-on: ubuntu-latest
steps:
diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml
index 9cd4071961..139f15b6a3 100644
--- a/.github/workflows/frontend-tests.yml
+++ b/.github/workflows/frontend-tests.yml
@@ -16,30 +16,6 @@ concurrency:
cancel-in-progress: true
jobs:
- static-checks:
- runs-on: self-hosted
- timeout-minutes: 30
- steps:
- - uses: actions/checkout@v7
- - uses: actions/setup-node@v7
- with:
- node-version: '24.18.1'
- # The runner's pnpm store persists between runs, so the Actions
- # cache adds nothing and downloading it is slow.
- cache: ''
- - uses: pnpm/setup@v2
- with:
- version: '11.17.0'
- - name: Install dependencies
- run: pnpm install --frozen-lockfile
- working-directory: frontend
- - name: Check (ESLint + Biome)
- run: pnpm check
- working-directory: frontend
- - name: TypeScript type check
- run: pnpm type-check
- working-directory: frontend
-
frontend-tests:
runs-on: self-hosted
timeout-minutes: 30
@@ -57,9 +33,8 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: frontend
- - name: Run unit tests
+ # Single gate, identical to what contributors run locally. The stages
+ # it runs are listed in frontend/scripts/run-gate.mjs.
+ - name: Test
run: pnpm test
working-directory: frontend
- - name: Build for production
- run: pnpm release-docker
- working-directory: frontend
diff --git a/AGENTS.md b/AGENTS.md
index 7a4891cb30..e038442420 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -53,7 +53,7 @@ go test -v -count=1 ./backend/store/ -run '^(TestFunctionName|TestFunctionNameTw
### Frontend changes
-Run `pnpm --dir frontend fix`, `pnpm --dir frontend check`, `pnpm --dir frontend type-check`, and `pnpm --dir frontend test`.
+Run `pnpm --dir frontend fix`, then `pnpm --dir frontend test` — the single gate CI runs. To iterate, `pnpm --dir frontend vitest run <path>` runs one file; `pnpm --dir frontend run prepare` refreshes generated sources.
For browser verification, read [frontend/tests/e2e/README.md](frontend/tests/e2e/README.md); before writing tests, read its [AGENTS.md](frontend/tests/e2e/AGENTS.md).
diff --git a/docs/agents/frontend-ux.md b/docs/agents/frontend-ux.md
index 26d0554c95..68946bf58e 100644
--- a/docs/agents/frontend-ux.md
+++ b/docs/agents/frontend-ux.md
@@ -459,7 +459,7 @@ Before considering a UI workflow complete, verify:
Run the full frontend check after UI changes:
```bash
-pnpm --dir frontend check
+pnpm --dir frontend test
```
The UX ratchet can be run directly:
diff --git a/frontend/.gitignore b/frontend/.gitignore
index 9de6a19ae9..3349d4e3fe 100644
--- a/frontend/.gitignore
+++ b/frontend/.gitignore
@@ -2,6 +2,9 @@
.eslintcache
node_modules
/dist
+# Throwaway output from `pnpm build-check`; kept out of /dist so it never
+# shadows a real release build.
+/dist-check
components.d.ts
src/types/plan.yaml
src/types/iam/*.yaml
diff --git a/frontend/AGENTS.md b/frontend/AGENTS.md
index 1db4d0d090..32f2f3fc43 100644
--- a/frontend/AGENTS.md
+++ b/frontend/AGENTS.md
@@ -20,7 +20,7 @@ This file provides additional guidance to AI coding assistants working under `./
- New shared UI and every UI element directly modified by a change MUST follow the guideline. Do not copy an adjacent legacy pattern merely because it is already present.
- Existing feature violations in `scripts/ui-guideline-legacy-debt.json` are temporary incremental exceptions, not permission for new debt. A change may leave unrelated fingerprints in place, but MUST NOT add, mutate, or increase them.
- Repeated measurements belong in `src/components/ui/styles.stylex.ts`; semantic colors belong in `src/assets/css/tailwind.css`; variants belong in the shared primitive's CVA definition.
-- Run `pnpm --dir frontend check` or `node frontend/scripts/check-ui-guideline.mjs` after UI work. When a change removes legacy debt, run `node frontend/scripts/check-ui-guideline.mjs --write-baseline`; the updater accepts reductions only.
+- Run `node frontend/scripts/check-ui-guideline.mjs` after UI work. When a change removes legacy debt, run `node frontend/scripts/check-ui-guideline.mjs --write-baseline`; the updater accepts reductions only.
## Source ownership
@@ -53,7 +53,7 @@ Use route ownership as the primary organization axis. Do not add a generic `feat
- Prefer direct owner imports such as `@/modules/sql-editor/store` over broad barrels when the owner is known.
- Historical migration plans under `docs/` describe old paths and are not current architecture guidance.
- `CLAUDE.md` files only import their adjacent `AGENTS.md`; update `AGENTS.md` as the source of truth.
-- `pnpm --dir frontend check` runs the structure guard. Do not bypass failures by recreating retired framework, view, or singular-store namespaces.
+- `node frontend/scripts/check-frontend-structure.mjs` runs the structure guard. Do not bypass failures by recreating retired framework, view, or singular-store namespaces.
## shadcn Skill
@@ -83,7 +83,7 @@ React UI components live in `src/components/ui/` and follow shadcn-style pattern
- Menus, popovers, dropdowns, and custom floating panels should use shared `DropdownMenu`, `Popover`, `Combobox`, `Select`, `Dialog`, or `Sheet` primitives rather than ad hoc `absolute top-full z-*` markup.
- Do not portal feature UI directly to `document.body` or a `document.body` alias. Use the shared overlay primitives, or explicitly mount into the correct semantic root with `getLayerRoot(<family>)`.
- Do not hide raw global overlay classes in constants, imported helpers, `cn()` inputs, or interpolated template literals. A value like `fixed inset-0 z-50` is still forbidden even when it is not written directly in `className`.
- - When adding or changing React overlays, run `pnpm --dir frontend check` or `node frontend/scripts/check-react-layering.mjs` before handing off. The scanner is intended to catch raw high-z overlays, forbidden body portals, and policy drift in feature code.
+ - When adding or changing React overlays, run `node frontend/scripts/check-react-layering.mjs` before handing off. The scanner is intended to catch raw high-z overlays, forbidden body portals, and policy drift in feature code.
- The scanner is a guardrail, not proof of policy compliance. It intentionally avoids full static analysis, so imported, dynamic, shadowed, or complex expressions may be unresolved; passing the check does not permit raw global z-index overlays or body portals.
### Component Patterns
diff --git a/frontend/i18n.ts b/frontend/i18n.ts
index 75841e8f69..3d1a6b9d1f 100644
--- a/frontend/i18n.ts
+++ b/frontend/i18n.ts
@@ -1,4 +1,3 @@
-import { unknown } from './src/types/common';
import { config } from "dotenv";
import { promises as fs } from "fs";
diff --git a/frontend/package.json b/frontend/package.json
index ade4159c85..ac039039d5 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -3,26 +3,16 @@
"license": "SEE LICENSE IN LICENSE",
"packageManager": "[email protected]",
"scripts": {
- "copy:config-files": "sh ./scripts/copy_config_files.sh",
- "prepare:artifacts": "pnpm run copy:config-files && pnpm run generate:openapi-index",
- "dev": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite --mode dev-local",
- "release": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
- "release-docker": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite build --mode release",
- "release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare:artifacts && vite build --mode release-aws",
- "precheck": "pnpm run prepare:artifacts",
- "check": "biome ci . && node scripts/check-frontend-structure.mjs && node scripts/check-ui-guideline.mjs && node scripts/check-no-crypto-randomuuid.mjs && node scripts/check-react-i18n.mjs && node scripts/check-react-layering.mjs && node scripts/sort_i18n_keys.mjs --check",
- "fix": "pnpm run sort:i18n && biome check --write .",
+ "prepare": "sh ./scripts/copy_config_files.sh && node scripts/generate_openapi_index.js",
+ "dev": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare && vite --mode dev-local",
+ "release": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare && vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
+ "release-docker": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare && vite build --mode release",
+ "release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && pnpm run prepare && vite build --mode release-aws",
+ "test": "node scripts/run-gate.mjs",
+ "fix": "node scripts/sort_i18n_keys.mjs && biome check --write .",
+ "i18n": "node i18n.ts && pnpm fix",
"bundle-visualize": "export NODE_OPTIONS=--max_old_space_size=80000 && vite-bundle-visualizer -c vite.config.ts",
- "pretype-check": "pnpm run prepare:artifacts",
- "type-check": "export NODE_OPTIONS=--max_old_space_size=8000 && tsc --build --force",
- "pretest": "pnpm run prepare:artifacts",
- "test": "vitest run --passWithNoTests",
- "test:e2e:install": "playwright install chromium",
- "precoverage": "pnpm run prepare:artifacts",
- "coverage": "vitest --coverage",
- "i18n": "TS_NODE_PROJECT='./tsconfig.i18n.json' ts-node --compiler typescript-6 i18n.ts && pnpm fix",
- "sort:i18n": "node scripts/sort_i18n_keys.mjs",
- "generate:openapi-index": "node scripts/generate_openapi_index.js"
+ "test:e2e:install": "playwright install chromium"
},
"dependencies": {
"@base-ui/react": "^1.3.0",
@@ -137,7 +127,6 @@
"remark-parse": "^11.0.0",
"rollup": "4.62.2",
"tailwindcss": "4.3.3",
- "ts-node": "^10.9.2",
"typescript": "7.0.2",
"typescript-6": "npm:[email protected]",
"unified": "^11.0.5",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 2a3b59737f..9928fcf6ab 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -342,9 +342,6 @@ importers:
tailwindcss:
specifier: 4.3.3
version: 4.3.3
- ts-node:
- specifier: ^10.9.2
- version: 10.9.2(@types/[email protected])([email protected])
typescript:
specifier: 7.0.2
version: 7.0.2
@@ -1096,10 +1093,6 @@ packages:
peerDependencies:
'@bufbuild/protobuf': ^2.7.0
- '@cspotcode/[email protected]':
- resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
- engines: {node: '>=12'}
-
'@csstools/[email protected]':
resolution: {integrity: sha512-064IFJdjTfUqnjpCVpMOdbr8FLQBhinbZj6yRv2An2E41O/pLEXqfFRWqGq/SxlE5PEUYTlvWsG2r8MswAVvkg==}
engines: {node: '>=20.19.0'}
@@ -1398,9 +1391,6 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
- '@jridgewell/[email protected]':
- resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
-
'@markdoc/[email protected]':
resolution: {integrity: sha512-U0II9ix5O96VWZXurdsw9uxwPFTurWcQyeNVTH5P7Q6kuIfTzjEy7IPJMTTmFefK7V6nRzIARi5+G6kTjuFeCQ==}
engines: {node: '>=14.7.0'}
@@ -1857,18 +1847,6 @@ packages:
'@types/react-dom':
optional: true
- '@tsconfig/[email protected]':
- resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==}
-
- '@tsconfig/[email protected]':
- resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
-
- '@tsconfig/[email protected]':
- resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
-
- '@tsconfig/[email protected]':
- resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
-
'@tsconfig/[email protected]':
resolution: {integrity: sha512-DWC54fGPuhZgg3Ighg4Y/A/bA3ZdB5hnzAuv/MkQ/X85sVsBsMQxu8t7khutdYeiNksBbFdDyeqv1HSW2Zl8aA==}
@@ -2197,10 +2175,6 @@ packages:
peerDependencies:
vue: ^3.5.0
- resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==}
- engines: {node: '>=0.4.0'}
-
resolution: {integrity: sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==}
engines: {node: '>=0.4.0'}
@@ -2218,9 +2192,6 @@ packages:
resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
-
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
@@ -2396,9 +2367,6 @@ packages:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
- resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
-
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
deprecated: Active development of CryptoJS has been discontinued. This library is no longer maintained.
@@ -2600,10 +2568,6 @@ packages:
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
- resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
- engines: {node: '>=0.3.1'}
-
resolution: {integrity: sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==}
@@ -3082,9 +3046,6 @@ packages:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
- resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
-
resolution: {integrity: sha512-RCEsPjR+sr0x+AuYp601tKTkgFG4YEPLCzHST3cQ/fhlJkqAkz1L2/Qbp1j9qw5SBwQHFBoW8+hoN5xssOF0Tw==}
hasBin: true
@@ -3803,20 +3764,6 @@ packages:
resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}
- resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
- hasBin: true
- peerDependencies:
- '@swc/core': '>=1.2.50'
- '@swc/wasm': '>=1.2.50'
- '@types/node': '*'
- typescript: '>=2.7'
- peerDependenciesMeta:
- '@swc/core':
- optional: true
- '@swc/wasm':
- optional: true
-
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -3899,9 +3846,6 @@ packages:
resolution: {integrity: sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew==}
hasBin: true
- resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
-
resolution: {integrity: sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==}
@@ -4106,10 +4050,6 @@ packages:
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
engines: {node: '>=12'}
- resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
- engines: {node: '>=6'}
-
resolution: {integrity: sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==}
engines: {node: '>=12.20.0'}
@@ -5063,10 +5003,6 @@ snapshots:
dependencies:
'@bufbuild/protobuf': 2.13.0
- '@cspotcode/[email protected]':
- dependencies:
- '@jridgewell/trace-mapping': 0.3.9
-
'@csstools/[email protected]': {}
'@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':
@@ -5278,11 +5214,6 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
- '@jridgewell/[email protected]':
- dependencies:
- '@jridgewell/resolve-uri': 3.1.2
- '@jridgewell/sourcemap-codec': 1.5.5
-
optionalDependencies:
'@types/linkify-it': 3.0.5
@@ -5617,14 +5548,6 @@ snapshots:
'@types/react': 19.2.17
'@types/react-dom': 19.2.3(@types/[email protected])
- '@tsconfig/[email protected]': {}
-
- '@tsconfig/[email protected]': {}
-
- '@tsconfig/[email protected]': {}
-
- '@tsconfig/[email protected]': {}
-
'@tsconfig/[email protected]': {}
@@ -5945,10 +5868,6 @@ snapshots:
dependencies:
vue: 3.5.40([email protected])
- dependencies:
- acorn: 8.17.0
-
@@ -5959,8 +5878,6 @@ snapshots:
-
@@ -6144,8 +6061,6 @@ snapshots:
-
@@ -6358,8 +6273,6 @@ snapshots:
dependencies:
dequal: 2.0.3
-
@@ -6788,8 +6701,6 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
-
dependencies:
argparse: 2.0.1
@@ -7778,24 +7689,6 @@ snapshots:
- dependencies:
- '@cspotcode/source-map-support': 0.8.1
- '@tsconfig/node10': 1.0.11
- '@tsconfig/node12': 1.0.11
- '@tsconfig/node14': 1.0.3
- '@tsconfig/node16': 1.0.4
- '@types/node': 24.13.3
- acorn: 8.17.0
- acorn-walk: 8.3.4
- arg: 4.1.3
- create-require: 1.1.1
- diff: 4.0.2
- make-error: 1.3.6
- typescript: 7.0.2
- v8-compile-cache-lib: 3.0.1
- yn: 3.1.1
-
@@ -7896,8 +7789,6 @@ snapshots:
-
dependencies:
'@types/unist': 3.0.3
@@ -8058,8 +7949,6 @@ snapshots:
y18n: 5.0.8
yargs-parser: 21.1.1
-
optionalDependencies:
'@types/react': 19.2.17
diff --git a/frontend/scripts/copy_config_files.sh b/frontend/scripts/copy_config_files.sh
index cc508b227a..cf52f3c896 100644
--- a/frontend/scripts/copy_config_files.sh
+++ b/frontend/scripts/copy_config_files.sh
@@ -1,4 +1,16 @@
#!/bin/sh
-cp ../backend/enterprise/plan.yaml ./src/types/
-cp ../backend/common/permission/permission.yaml ./src/types/iam/
+set -e
+
+# Copy-then-rename rather than a plain cp: the frontend gate refreshes these
+# while tsc and the bundler are already reading them, and cp truncates in
+# place, so a reader can observe a half-written file. mv within a directory is
+# a rename(2) and therefore atomic.
+copy_atomic() {
+ tmp="$2.$$.tmp"
+ cp "$1" "$tmp"
+ mv "$tmp" "$2"
+}
+
+copy_atomic ../backend/enterprise/plan.yaml ./src/types/plan.yaml
+copy_atomic ../backend/common/permission/permission.yaml ./src/types/iam/permission.yaml
node ./scripts/generate_permissions.js
diff --git a/frontend/scripts/generate_openapi_index.js b/frontend/scripts/generate_openapi_index.js
index 07b13a72e5..f9c4de78ec 100644
--- a/frontend/scripts/generate_openapi_index.js
+++ b/frontend/scripts/generate_openapi_index.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// Generates a compact TypeScript index from the OpenAPI spec.
-// Run: pnpm --dir frontend run generate:openapi-index
+// Run: pnpm --dir frontend run prepare
const fs = require("fs");
const path = require("path");
@@ -251,7 +251,7 @@ for (const [schemaName, schemaDef] of Object.entries(componentSchemas)) {
const lines = [];
lines.push(
"// Auto-generated from openapi.yaml. DO NOT EDIT manually.",
- "// Run 'pnpm --dir frontend run generate:openapi-index' to regenerate.",
+ "// Run 'pnpm --dir frontend run prepare' to regenerate.",
""
);
@@ -299,7 +299,13 @@ lines.push(
""
);
-fs.writeFileSync(OUTPUT_FILE, lines.join("\n"), "utf8");
+// Write-then-rename: the frontend gate regenerates this while tsc and the
+// bundler are already reading it, and an in-place write is observable
+// half-finished. rename(2) within a directory is atomic, so a reader sees
+// either the old file or the new one.
+const tempFile = `${OUTPUT_FILE}.${process.pid}.tmp`;
+fs.writeFileSync(tempFile, lines.join("\n"), "utf8");
+fs.renameSync(tempFile, OUTPUT_FILE);
const schemaCount = Object.keys(schemas).length;
const enumCount = Object.values(schemas).filter(
diff --git a/frontend/scripts/generate_permissions.js b/frontend/scripts/generate_permissions.js
index 34de969178..5882ba0ae2 100755
--- a/frontend/scripts/generate_permissions.js
+++ b/frontend/scripts/generate_permissions.js
@@ -26,7 +26,11 @@ export type Permission =
${permissions.map(p => ` | "${p}"`).join('\n')};
`;
-// Write the generated TypeScript file
-fs.writeFileSync(OUTPUT_FILE, tsContent, 'utf8');
+// Write the generated TypeScript file. Write-then-rename, because the frontend
+// gate regenerates this while tsc and the bundler are already reading it and an
+// in-place write is observable half-finished.
+const tempFile = `${OUTPUT_FILE}.${process.pid}.tmp`;
+fs.writeFileSync(tempFile, tsContent, 'utf8');
+fs.renameSync(tempFile, OUTPUT_FILE);
console.log(`✅ Generated ${OUTPUT_FILE} with ${permissions.length} permissions`);
diff --git a/frontend/scripts/run-gate.mjs b/frontend/scripts/run-gate.mjs
new file mode 100644
index 0000000000..15b0c2a741
--- /dev/null
+++ b/frontend/scripts/run-gate.mjs
@@ -0,0 +1,87 @@
+// The frontend gate, and exactly what CI runs: `pnpm test`.
+//
+// The four stages below are independent, so they run concurrently rather than
+// in a serial `&&` chain. vitest saturates most of the box on its own while the
+// other three are largely single-core, so overlapping them costs little and
+// takes the gate from ~92s to ~70s.
+//
+// Each stage's output is buffered and printed in a fixed order once every stage
+// has finished, so a failure reads the same as it did serially -- interleaved
+// live output from four concurrent stages would not.
+import { spawn } from "node:child_process";
+
+const GUARDS = [
+ "check-frontend-structure",
+ "check-ui-guideline",
+ "check-no-crypto-randomuuid",
+ "check-react-i18n",
+ "check-react-layering",
+];
+
+const BIG_HEAP = { NODE_OPTIONS: "--max_old_space_size=8000" };
+
+// Ordered cheapest-first: how the results are reported, not how they are run.
+const STAGES = [
+ { name: "biome", argv: ["pnpm", "exec", "biome", "ci", "."] },
+ {
+ name: "guards",
+ argv: [
+ "sh",
+ "-c",
+ [...GUARDS.map((g) => `node scripts/${g}.mjs`), "node scripts/sort_i18n_keys.mjs --check"].join(" && "),
+ ],
+ },
+ { name: "tsc", argv: ["pnpm", "exec", "tsc", "--build", "--force"], env: BIG_HEAP },
+ {
+ name: "bundle",
+ argv: ["pnpm", "exec", "vite", "build", "--mode", "release", "--outDir=dist-check", "--emptyOutDir"],
+ // The legacy browser pass doubles the build and proves nothing about
+ // whether the app compiles; see the plugin comment in vite.config.ts.
+ env: { ...BIG_HEAP, BB_SKIP_LEGACY: "1" },
+ },
+ { name: "vitest", argv: ["pnpm", "exec", "vitest", "run", "--passWithNoTests"] },
+];
+
+function run({ name, argv, env }) {
+ return new Promise((resolve) => {
+ const started = Date.now();
+ const child = spawn(argv[0], argv.slice(1), {
+ env: { ...process.env, ...env },
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ const chunks = [];
+ child.stdout.on("data", (c) => chunks.push(c));
+ child.stderr.on("data", (c) => chunks.push(c));
+ child.on("error", (error) => {
+ chunks.push(Buffer.from(`failed to spawn ${argv[0]}: ${error.message}\n`));
+ resolve({ name, code: 1, seconds: 0, output: Buffer.concat(chunks).toString() });
+ });
+ child.on("close", (code) => {
+ const seconds = (Date.now() - started) / 1000;
+ process.stderr.write(`${code === 0 ? "ok " : "FAIL"} ${name} (${seconds.toFixed(1)}s)\n`);
+ resolve({ name, code: code ?? 1, seconds, output: Buffer.concat(chunks).toString() });
+ });
+ });
+}
+
+// Every stage reads the generated sources copied from the backend, so this one
+// runs first and on its own.
+const prepare = await run({ name: "prepare", argv: ["pnpm", "run", "prepare"] });
+if (prepare.code !== 0) {
+ process.stdout.write(prepare.output);
+ process.exit(prepare.code);
+}
+
+const results = await Promise.all(STAGES.map(run));
+
+for (const { name, output } of results) {
+ process.stdout.write(`\n${"=".repeat(60)}\n${name}\n${"=".repeat(60)}\n${output}`);
+}
+
+// Each stage already reported itself as it finished, so only restate things
+// when something failed and the list is worth having next to the exit.
+const failed = results.filter((r) => r.code !== 0);
+if (failed.length > 0) {
+ process.stdout.write(`\n${failed.length} stage(s) failed: ${failed.map((r) => r.name).join(", ")}\n`);
+ process.exit(1);
+}
diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts
index e8ce86cb36..32559146fc 100644
--- a/frontend/src/api/index.ts
+++ b/frontend/src/api/index.ts
@@ -41,7 +41,11 @@ import {
import { protobufJsonRegistry } from "@/types/protobufJsonRegistry";
import { isDev } from "@/utils/util";
-const address = import.meta.env.BB_GRPC_LOCAL || window.location.origin;
+// Read defensively: this module is imported at the top of many module
+// graphs, including from tests that run without a DOM.
+const address =
+ import.meta.env.BB_GRPC_LOCAL ||
+ (typeof window === "undefined" ? "http://localhost" : window.location.origin);
// Registry for decoding google.protobuf.Any fields in JSON responses
const transport = createConnectTransport({
diff --git a/frontend/src/api/middlewares/errorNotificationMiddleware.test.ts b/frontend/src/api/middlewares/errorNotificationMiddleware.test.ts
index f3d3a221b1..d3d06116e9 100644
--- a/frontend/src/api/middlewares/errorNotificationMiddleware.test.ts
+++ b/frontend/src/api/middlewares/errorNotificationMiddleware.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { Code, ConnectError, createContextValues } from "@connectrpc/connect";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { ignoredCodesContextKey, silentContextKey } from "../context-key";
diff --git a/frontend/src/app/analytics/behavior.test.ts b/frontend/src/app/analytics/behavior.test.ts
index 7b2f73e0c0..64b1d126bf 100644
--- a/frontend/src/app/analytics/behavior.test.ts
+++ b/frontend/src/app/analytics/behavior.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
buildBehaviorAnalyticsConfig,
diff --git a/frontend/src/app/analytics/feature-gate.test.ts b/frontend/src/app/analytics/feature-gate.test.ts
index 4e7682b4f6..6b47b10400 100644
--- a/frontend/src/app/analytics/feature-gate.test.ts
+++ b/frontend/src/app/analytics/feature-gate.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
PlanFeature,
diff --git a/frontend/src/app/analytics/provider.test.ts b/frontend/src/app/analytics/provider.test.ts
index f11608a4a3..f0aa3fc6c2 100644
--- a/frontend/src/app/analytics/provider.test.ts
+++ b/frontend/src/app/analytics/provider.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import type { BehaviorAnalyticsConfig } from "./behavior";
import { createBehaviorAnalytics } from "./provider";
diff --git a/frontend/src/app/router/canonicalRedirect.test.ts b/frontend/src/app/router/canonicalRedirect.test.ts
index 6f105ad6a0..dc9f263cff 100644
--- a/frontend/src/app/router/canonicalRedirect.test.ts
+++ b/frontend/src/app/router/canonicalRedirect.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { createMemoryRouter } from "react-router";
import { afterEach, describe, expect, test } from "vitest";
import { canonicalRedirect } from "./canonicalRedirect";
diff --git a/frontend/src/app/router/currentRouteSnapshot.test.ts b/frontend/src/app/router/currentRouteSnapshot.test.ts
index 716cf36869..0c91d9ce66 100644
--- a/frontend/src/app/router/currentRouteSnapshot.test.ts
+++ b/frontend/src/app/router/currentRouteSnapshot.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
import {
PROJECT_V1_ROUTE_WEBHOOK_CREATE,
diff --git a/frontend/src/app/router/issueDetailRedirect.test.ts b/frontend/src/app/router/issueDetailRedirect.test.ts
index 723ebafcff..69a430c3bd 100644
--- a/frontend/src/app/router/issueDetailRedirect.test.ts
+++ b/frontend/src/app/router/issueDetailRedirect.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import type { LoaderFunctionArgs } from "react-router";
import { beforeEach, describe, expect, test, vi } from "vitest";
diff --git a/frontend/src/app/router/planDetailRouteQuery.test.ts b/frontend/src/app/router/planDetailRouteQuery.test.ts
index ea1aa9e744..793fd3a43a 100644
--- a/frontend/src/app/router/planDetailRouteQuery.test.ts
+++ b/frontend/src/app/router/planDetailRouteQuery.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
buildPlanDetailLegacySearch,
diff --git a/frontend/src/architecture/cel-filter-literals.test.ts b/frontend/src/architecture/cel-filter-literals.test.ts
index 0abd0b3f1a..3ae45d8e9b 100644
--- a/frontend/src/architecture/cel-filter-literals.test.ts
+++ b/frontend/src/architecture/cel-filter-literals.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readdirSync, readFileSync } from "node:fs";
import { join, relative } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/architecture/legacy-boundaries.test.ts b/frontend/src/architecture/legacy-boundaries.test.ts
index 8a842c65dd..f3a59f8598 100644
--- a/frontend/src/architecture/legacy-boundaries.test.ts
+++ b/frontend/src/architecture/legacy-boundaries.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
const sources = import.meta.glob(
diff --git a/frontend/src/architecture/no-vue-imports.test.ts b/frontend/src/architecture/no-vue-imports.test.ts
index 65ef431a8a..ddccabc9db 100644
--- a/frontend/src/architecture/no-vue-imports.test.ts
+++ b/frontend/src/architecture/no-vue-imports.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
// Scan the entire application source tree. The only remaining Vue runtime is
diff --git a/frontend/src/architecture/vue-boundary.test.ts b/frontend/src/architecture/vue-boundary.test.ts
index 47f1b61d43..7acbafa3bd 100644
--- a/frontend/src/architecture/vue-boundary.test.ts
+++ b/frontend/src/architecture/vue-boundary.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { join, relative } from "node:path";
import { describe, expect, test } from "vitest";
@@ -80,7 +81,13 @@ describe("Vue build tooling", () => {
const dependencyNames = Object.keys(packageJson.dependencies ?? {});
const devDependencyNames = Object.keys(packageJson.devDependencies ?? {});
- expect(packageJson.scripts?.["type-check"]).not.toContain("vue-tsc");
+ // Asserted across every script rather than one name, so consolidating or
+ // renaming the gate cannot silently retire this policy.
+ expect(
+ Object.values(packageJson.scripts ?? {}).some((script) =>
+ /\bvue-tsc\b/.test(script)
+ )
+ ).toBe(false);
expect(dependencyNames.filter((name) => name.startsWith("@vue/"))).toEqual(
[]
);
@@ -132,8 +139,16 @@ describe("frontend lint tooling", () => {
expect(
existsSync(join(repoRoot, "scripts", "check-no-crypto-randomuuid.mjs"))
).toBe(true);
- expect(packageJson.scripts?.["check"]).toContain(
- "node scripts/check-no-crypto-randomuuid.mjs"
- );
+ // The guard must be wired into the gate. That wiring lives in the gate
+ // runner now rather than in a package.json script string, so search both.
+ const gateSources = [
+ ...Object.values(packageJson.scripts ?? {}),
+ readFileSync(join(repoRoot, "scripts", "run-gate.mjs"), "utf-8"),
+ ];
+ expect(
+ gateSources.some((source) =>
+ source.includes("check-no-crypto-randomuuid")
+ )
+ ).toBe(true);
});
});
diff --git a/frontend/src/components/CustomApproval/RuleEditSheetLayout.test.ts b/frontend/src/components/CustomApproval/RuleEditSheetLayout.test.ts
index 0a858158ea..94f72dca62 100644
--- a/frontend/src/components/CustomApproval/RuleEditSheetLayout.test.ts
+++ b/frontend/src/components/CustomApproval/RuleEditSheetLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/components/CustomApproval/utils.test.ts b/frontend/src/components/CustomApproval/utils.test.ts
index 9aca943b96..c34a1ffe09 100644
--- a/frontend/src/components/CustomApproval/utils.test.ts
+++ b/frontend/src/components/CustomApproval/utils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";
import { CEL_ATTRIBUTE_ISSUE_LABELS } from "@/utils/cel-attributes";
diff --git a/frontend/src/components/IssueTable.i18n.test.ts b/frontend/src/components/IssueTable.i18n.test.ts
index b8f466f79b..061453837c 100644
--- a/frontend/src/components/IssueTable.i18n.test.ts
+++ b/frontend/src/components/IssueTable.i18n.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import i18next from "i18next";
import { describe, expect, test } from "vitest";
import enUS from "@/locales/en-US.json";
diff --git a/frontend/src/components/database/CreateDatabaseSheetLayout.test.ts b/frontend/src/components/database/CreateDatabaseSheetLayout.test.ts
index 697ac5644a..b852464549 100644
--- a/frontend/src/components/database/CreateDatabaseSheetLayout.test.ts
+++ b/frontend/src/components/database/CreateDatabaseSheetLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/components/header/ProjectCreateDialogLayout.test.ts b/frontend/src/components/header/ProjectCreateDialogLayout.test.ts
index 4f9e3bbb85..87ba0180ab 100644
--- a/frontend/src/components/header/ProjectCreateDialogLayout.test.ts
+++ b/frontend/src/components/header/ProjectCreateDialogLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/components/header/no-vue-deps.test.ts b/frontend/src/components/header/no-vue-deps.test.ts
index 044fa5a474..8b3bd55f42 100644
--- a/frontend/src/components/header/no-vue-deps.test.ts
+++ b/frontend/src/components/header/no-vue-deps.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
const sources = import.meta.glob(
diff --git a/frontend/src/components/instance/InstanceDashboard.test.ts b/frontend/src/components/instance/InstanceDashboard.test.ts
index e0366ebb69..839a3cd91c 100644
--- a/frontend/src/components/instance/InstanceDashboard.test.ts
+++ b/frontend/src/components/instance/InstanceDashboard.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/components/instance/InstanceFormBody.i18n.test.ts b/frontend/src/components/instance/InstanceFormBody.i18n.test.ts
index 4e61dc0e37..b2d25e0904 100644
--- a/frontend/src/components/instance/InstanceFormBody.i18n.test.ts
+++ b/frontend/src/components/instance/InstanceFormBody.i18n.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import i18next from "i18next";
import { describe, expect, test } from "vitest";
import enUS from "@/locales/en-US.json";
diff --git a/frontend/src/components/instance/InstanceFormBody.test.ts b/frontend/src/components/instance/InstanceFormBody.test.ts
index 1ed93ab6e3..28403e4648 100644
--- a/frontend/src/components/instance/InstanceFormBody.test.ts
+++ b/frontend/src/components/instance/InstanceFormBody.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/components/instance/common.test.ts b/frontend/src/components/instance/common.test.ts
index f3589a81c4..60225326cb 100644
--- a/frontend/src/components/instance/common.test.ts
+++ b/frontend/src/components/instance/common.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create, type MessageInitShape } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/components/instance/constants.test.ts b/frontend/src/components/instance/constants.test.ts
index 067cfb4755..396b3a0bec 100644
--- a/frontend/src/components/instance/constants.test.ts
+++ b/frontend/src/components/instance/constants.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
import { effectivePortForEngine } from "./constants";
diff --git a/frontend/src/components/instance/permission.test.ts b/frontend/src/components/instance/permission.test.ts
index 7a17238a4f..cd6ef156d5 100644
--- a/frontend/src/components/instance/permission.test.ts
+++ b/frontend/src/components/instance/permission.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { ProjectSchema } from "@/types/proto-es/v1/project_service_pb";
diff --git a/frontend/src/components/mcp/mcpPolicy.test.ts b/frontend/src/components/mcp/mcpPolicy.test.ts
index 4472413c7f..8f814e5a6d 100644
--- a/frontend/src/components/mcp/mcpPolicy.test.ts
+++ b/frontend/src/components/mcp/mcpPolicy.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/components/monaco/height.test.ts b/frontend/src/components/monaco/height.test.ts
index 49a0297fba..c36cb0dd07 100644
--- a/frontend/src/components/monaco/height.test.ts
+++ b/frontend/src/components/monaco/height.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { clampEditorHeight } from "./height";
diff --git a/frontend/src/components/role-grant/DDLWarningCallout.locale.test.ts b/frontend/src/components/role-grant/DDLWarningCallout.locale.test.ts
index e26d953969..1c7ffb6b5b 100644
--- a/frontend/src/components/role-grant/DDLWarningCallout.locale.test.ts
+++ b/frontend/src/components/role-grant/DDLWarningCallout.locale.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import enReact from "@/locales/en-US.json";
import esReact from "@/locales/es-ES.json";
diff --git a/frontend/src/components/task-run-log/TaskRunLogViewer.i18n.test.ts b/frontend/src/components/task-run-log/TaskRunLogViewer.i18n.test.ts
index 30ed0d350c..439f0652aa 100644
--- a/frontend/src/components/task-run-log/TaskRunLogViewer.i18n.test.ts
+++ b/frontend/src/components/task-run-log/TaskRunLogViewer.i18n.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import i18next from "i18next";
import { describe, expect, test } from "vitest";
import enUS from "@/locales/en-US.json";
diff --git a/frontend/src/components/ui/tree-utils.test.ts b/frontend/src/components/ui/tree-utils.test.ts
index 528538ecfc..ba76d702a3 100644
--- a/frontend/src/components/ui/tree-utils.test.ts
+++ b/frontend/src/components/ui/tree-utils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { countVisibleRows } from "./tree-utils";
diff --git a/frontend/src/hooks/pagedDataCache.test.ts b/frontend/src/hooks/pagedDataCache.test.ts
index 5d82bff4f7..909b6ab04c 100644
--- a/frontend/src/hooks/pagedDataCache.test.ts
+++ b/frontend/src/hooks/pagedDataCache.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, describe, expect, test, vi } from "vitest";
import {
clearPagedDataCache,
diff --git a/frontend/src/lib/i18n/canonical-locales.test.ts b/frontend/src/lib/i18n/canonical-locales.test.ts
index 034e5064bc..eb713a149a 100644
--- a/frontend/src/lib/i18n/canonical-locales.test.ts
+++ b/frontend/src/lib/i18n/canonical-locales.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/lib/i18n/index.ts b/frontend/src/lib/i18n/index.ts
index af40b87d49..eebedbfda2 100644
--- a/frontend/src/lib/i18n/index.ts
+++ b/frontend/src/lib/i18n/index.ts
@@ -24,6 +24,11 @@ import zhCN from "@/locales/zh-CN.json";
const STORAGE_KEY_LANGUAGE = "bb.language";
function getLocale(): string {
+ // Runs at module scope through i18n.init below, so it must not assume a DOM:
+ // any test that transitively imports this module would otherwise need jsdom.
+ if (typeof localStorage === "undefined") {
+ return "en-US";
+ }
const stored = localStorage.getItem(STORAGE_KEY_LANGUAGE) ?? "";
if (stored) {
try {
diff --git a/frontend/src/lib/i18n/messages.test.ts b/frontend/src/lib/i18n/messages.test.ts
index 78d6710cf8..6959e77e82 100644
--- a/frontend/src/lib/i18n/messages.test.ts
+++ b/frontend/src/lib/i18n/messages.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readdirSync, readFileSync } from "fs";
import { isEqual } from "lodash-es";
import { dirname, resolve } from "path";
diff --git a/frontend/src/lib/memberBindings.test.ts b/frontend/src/lib/memberBindings.test.ts
index 39f75bb130..fc3033001b 100644
--- a/frontend/src/lib/memberBindings.test.ts
+++ b/frontend/src/lib/memberBindings.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { ExprSchema as ConditionExprSchema } from "@/types/proto-es/google/type/expr_pb";
diff --git a/frontend/src/lib/plan/check.test.ts b/frontend/src/lib/plan/check.test.ts
index 5e90e187ea..ae4bb37dee 100644
--- a/frontend/src/lib/plan/check.test.ts
+++ b/frontend/src/lib/plan/check.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/lib/plan/diffPlanSpecs.test.ts b/frontend/src/lib/plan/diffPlanSpecs.test.ts
index 88135e4880..7c1cf23e7e 100644
--- a/frontend/src/lib/plan/diffPlanSpecs.test.ts
+++ b/frontend/src/lib/plan/diffPlanSpecs.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, it } from "vitest";
import {
diff --git a/frontend/src/lib/plan/events.test.ts b/frontend/src/lib/plan/events.test.ts
index f8bfcfa882..176c57452f 100644
--- a/frontend/src/lib/plan/events.test.ts
+++ b/frontend/src/lib/plan/events.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import { planEvents } from "./events";
diff --git a/frontend/src/lib/plan/title.test.ts b/frontend/src/lib/plan/title.test.ts
index 9f6b2be0a9..a67fcdb98f 100644
--- a/frontend/src/lib/plan/title.test.ts
+++ b/frontend/src/lib/plan/title.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it, vi } from "vitest";
import { applyPlanTitleToQuery, planQueryNameForProject } from "./title";
diff --git a/frontend/src/lib/plan/workflow.test.ts b/frontend/src/lib/plan/workflow.test.ts
index cd74cf2473..0671ad948e 100644
--- a/frontend/src/lib/plan/workflow.test.ts
+++ b/frontend/src/lib/plan/workflow.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test, vi } from "vitest";
import type {
diff --git a/frontend/src/lib/project-member/utils.test.ts b/frontend/src/lib/project-member/utils.test.ts
index 7ea5cae90e..fa57344ee5 100644
--- a/frontend/src/lib/project-member/utils.test.ts
+++ b/frontend/src/lib/project-member/utils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import { getRoleEnvironmentLimitationKind } from "./utils";
diff --git a/frontend/src/lib/projectPagedDataCache.test.ts b/frontend/src/lib/projectPagedDataCache.test.ts
index 9dfaef4066..b2be01e050 100644
--- a/frontend/src/lib/projectPagedDataCache.test.ts
+++ b/frontend/src/lib/projectPagedDataCache.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test } from "vitest";
import {
clearPagedDataCache,
diff --git a/frontend/src/lib/resourceName.test.ts b/frontend/src/lib/resourceName.test.ts
index 5aef0a9fed..b8c160c27b 100644
--- a/frontend/src/lib/resourceName.test.ts
+++ b/frontend/src/lib/resourceName.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { normalizeInstanceName } from "./resourceName";
diff --git a/frontend/src/lib/resourceStateFilter.test.ts b/frontend/src/lib/resourceStateFilter.test.ts
index 56808a6111..424999204a 100644
--- a/frontend/src/lib/resourceStateFilter.test.ts
+++ b/frontend/src/lib/resourceStateFilter.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { State } from "@/types/proto-es/v1/common_pb";
import {
diff --git a/frontend/src/lib/sensitive-data/exemptionDataUtils.test.ts b/frontend/src/lib/sensitive-data/exemptionDataUtils.test.ts
index 989a74c4de..e1a2494351 100644
--- a/frontend/src/lib/sensitive-data/exemptionDataUtils.test.ts
+++ b/frontend/src/lib/sensitive-data/exemptionDataUtils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
vi.mock("@/lib/i18n", () => ({
diff --git a/frontend/src/lib/sensitive-data/maskingExemption.test.ts b/frontend/src/lib/sensitive-data/maskingExemption.test.ts
index d6cda48038..13dfa73f02 100644
--- a/frontend/src/lib/sensitive-data/maskingExemption.test.ts
+++ b/frontend/src/lib/sensitive-data/maskingExemption.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { emptySimpleExpr, wrapAsGroup } from "@/modules/cel";
import type { DatabaseResource } from "@/types";
diff --git a/frontend/src/lib/sensitive-data/utils.test.ts b/frontend/src/lib/sensitive-data/utils.test.ts
index 9522e8e288..5fa215df48 100644
--- a/frontend/src/lib/sensitive-data/utils.test.ts
+++ b/frontend/src/lib/sensitive-data/utils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
diff --git a/frontend/src/lib/taskRun.test.ts b/frontend/src/lib/taskRun.test.ts
index 8f0b99f57a..2f6b08afc7 100644
--- a/frontend/src/lib/taskRun.test.ts
+++ b/frontend/src/lib/taskRun.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import type { MessageInitShape } from "@bufbuild/protobuf";
import { create } from "@bufbuild/protobuf";
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
diff --git a/frontend/src/lib/toast.test.ts b/frontend/src/lib/toast.test.ts
index 352ca9a430..9a3f6d657f 100644
--- a/frontend/src/lib/toast.test.ts
+++ b/frontend/src/lib/toast.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
const { addMock } = vi.hoisted(() => ({ addMock: vi.fn() }));
diff --git a/frontend/src/modules/access-control/requestRoleButton.test.ts b/frontend/src/modules/access-control/requestRoleButton.test.ts
index 7e1b175d00..6bc99d4d52 100644
--- a/frontend/src/modules/access-control/requestRoleButton.test.ts
+++ b/frontend/src/modules/access-control/requestRoleButton.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { getRequestRoleButtonState } from "./requestRoleButton";
diff --git a/frontend/src/modules/agent/AGENTS.md b/frontend/src/modules/agent/AGENTS.md
index 66ff73f2f5..81f36f139b 100644
--- a/frontend/src/modules/agent/AGENTS.md
+++ b/frontend/src/modules/agent/AGENTS.md
@@ -37,7 +37,7 @@ DOM refs such as `e1` are local to one `get_page_state(mode="dom")` snapshot. Re
Run:
```bash
-pnpm --dir frontend run generate:openapi-index
+pnpm --dir frontend run prepare
```
The generator reads `backend/api/mcp/gen/openapi.yaml` and writes `logic/tools/gen/openapi-index.ts`. Do not edit the generated file manually.
diff --git a/frontend/src/modules/agent/components/resize-capability.test.ts b/frontend/src/modules/agent/components/resize-capability.test.ts
index 5a5708e44a..4d5db297ac 100644
--- a/frontend/src/modules/agent/components/resize-capability.test.ts
+++ b/frontend/src/modules/agent/components/resize-capability.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
RESIZE_POINTER_MEDIA_QUERY,
diff --git a/frontend/src/modules/agent/components/window-resize.test.ts b/frontend/src/modules/agent/components/window-resize.test.ts
index 3f3fc6310b..0ac0c81666 100644
--- a/frontend/src/modules/agent/components/window-resize.test.ts
+++ b/frontend/src/modules/agent/components/window-resize.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
type ResizeBounds,
diff --git a/frontend/src/modules/agent/logic/agentLoop.test.ts b/frontend/src/modules/agent/logic/agentLoop.test.ts
index a154262931..2c86e5b979 100644
--- a/frontend/src/modules/agent/logic/agentLoop.test.ts
+++ b/frontend/src/modules/agent/logic/agentLoop.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import { aiServiceClientConnect } from "@/api";
import { AIChatMessageRole } from "@/types/proto-es/v1/ai_service_pb";
diff --git a/frontend/src/modules/agent/logic/aiConfiguration.test.ts b/frontend/src/modules/agent/logic/aiConfiguration.test.ts
index 7d8a88fb99..554330367f 100644
--- a/frontend/src/modules/agent/logic/aiConfiguration.test.ts
+++ b/frontend/src/modules/agent/logic/aiConfiguration.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { Code, ConnectError } from "@connectrpc/connect";
import { describe, expect, test } from "vitest";
import { isAgentAIConfigurationError } from "./aiConfiguration";
diff --git a/frontend/src/modules/agent/logic/context.test.ts b/frontend/src/modules/agent/logic/context.test.ts
index aac488387e..c5a5266d78 100644
--- a/frontend/src/modules/agent/logic/context.test.ts
+++ b/frontend/src/modules/agent/logic/context.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import type { ReactRoute } from "@/app/router";
import { Engine } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/modules/agent/logic/prompt.test.ts b/frontend/src/modules/agent/logic/prompt.test.ts
index f3e0e7e981..b85d58dadf 100644
--- a/frontend/src/modules/agent/logic/prompt.test.ts
+++ b/frontend/src/modules/agent/logic/prompt.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { buildSystemPrompt } from "./prompt";
diff --git a/frontend/src/modules/agent/logic/tools/domAction.test.ts b/frontend/src/modules/agent/logic/tools/domAction.test.ts
index 80d2daf4e1..1d0b21fc9c 100644
--- a/frontend/src/modules/agent/logic/tools/domAction.test.ts
+++ b/frontend/src/modules/agent/logic/tools/domAction.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import type { AppRouterInstance } from "@/app/router";
diff --git a/frontend/src/modules/agent/logic/tools/index.test.ts b/frontend/src/modules/agent/logic/tools/index.test.ts
index 1137797bc6..3a92830eb0 100644
--- a/frontend/src/modules/agent/logic/tools/index.test.ts
+++ b/frontend/src/modules/agent/logic/tools/index.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import type { AppRouterInstance } from "@/app/router";
diff --git a/frontend/src/modules/ai/components/HistoryPanel/HistoryPanelLayout.test.ts b/frontend/src/modules/ai/components/HistoryPanel/HistoryPanelLayout.test.ts
index 699df459cb..87ca14a36f 100644
--- a/frontend/src/modules/ai/components/HistoryPanel/HistoryPanelLayout.test.ts
+++ b/frontend/src/modules/ai/components/HistoryPanel/HistoryPanelLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/modules/cel/logic/build.test.ts b/frontend/src/modules/cel/logic/build.test.ts
index f74f63b85d..a7f9113f95 100644
--- a/frontend/src/modules/cel/logic/build.test.ts
+++ b/frontend/src/modules/cel/logic/build.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { ExprType, type SimpleExpr } from "@/modules/cel";
import {
diff --git a/frontend/src/modules/cel/logic/resolve.test.ts b/frontend/src/modules/cel/logic/resolve.test.ts
index 93ff0f94ec..7d78e5218c 100644
--- a/frontend/src/modules/cel/logic/resolve.test.ts
+++ b/frontend/src/modules/cel/logic/resolve.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { ExprType, type SimpleExpr } from "@/modules/cel";
import { CEL_ATTRIBUTE_ISSUE_LABELS } from "@/utils/cel-attributes";
diff --git a/frontend/src/modules/cel/logic/validate.test.ts b/frontend/src/modules/cel/logic/validate.test.ts
index e0300dc700..4d14c05284 100644
--- a/frontend/src/modules/cel/logic/validate.test.ts
+++ b/frontend/src/modules/cel/logic/validate.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { ExprType, type SimpleExpr } from "@/modules/cel";
import { CEL_ATTRIBUTE_ISSUE_LABELS } from "@/utils/cel-attributes";
diff --git a/frontend/src/modules/cel/types/values.test.ts b/frontend/src/modules/cel/types/values.test.ts
index 6d909ccb45..d6616cbbbc 100644
--- a/frontend/src/modules/cel/types/values.test.ts
+++ b/frontend/src/modules/cel/types/values.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { SQLTypeList } from "./values";
diff --git a/frontend/src/modules/schema-diagram/Canvas/libs/fitView.test.ts b/frontend/src/modules/schema-diagram/Canvas/libs/fitView.test.ts
index 9a3c0769b4..72cee390e6 100644
--- a/frontend/src/modules/schema-diagram/Canvas/libs/fitView.test.ts
+++ b/frontend/src/modules/schema-diagram/Canvas/libs/fitView.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { fitView } from "./fitView";
diff --git a/frontend/src/modules/schema-diagram/common/geometry.test.ts b/frontend/src/modules/schema-diagram/common/geometry.test.ts
index 9d55d05d35..ed9eddd7cf 100644
--- a/frontend/src/modules/schema-diagram/common/geometry.test.ts
+++ b/frontend/src/modules/schema-diagram/common/geometry.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import {
calcBBox,
diff --git a/frontend/src/modules/schema-editor/Modals/EditColumnForeignKeySheetLayout.test.ts b/frontend/src/modules/schema-editor/Modals/EditColumnForeignKeySheetLayout.test.ts
index e061c60b1b..8301dd0de8 100644
--- a/frontend/src/modules/schema-editor/Modals/EditColumnForeignKeySheetLayout.test.ts
+++ b/frontend/src/modules/schema-editor/Modals/EditColumnForeignKeySheetLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/modules/schema-editor/core/refreshEditStatus.test.ts b/frontend/src/modules/schema-editor/core/refreshEditStatus.test.ts
index 4cc05667a9..dc02521827 100644
--- a/frontend/src/modules/schema-editor/core/refreshEditStatus.test.ts
+++ b/frontend/src/modules/schema-editor/core/refreshEditStatus.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test, vi } from "vitest";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
diff --git a/frontend/src/modules/sql-editor/AGENTS.md b/frontend/src/modules/sql-editor/AGENTS.md
index d590262788..9f30ea7948 100644
--- a/frontend/src/modules/sql-editor/AGENTS.md
+++ b/frontend/src/modules/sql-editor/AGENTS.md
@@ -19,4 +19,4 @@ src/modules/sql-editor/
- `legacy/` may read old persisted formats but must not become a home for new runtime behavior.
- The current React and Zustand imports are authoritative. Some parity comments retain historical implementation context; they do not describe active framework boundaries.
- The AI module may consume SQL Editor hooks and state. Avoid the reverse dependency unless the UI is explicitly an AI integration surface.
-- Run focused tests under this module, then the standard frontend fix, check, type-check, and full test commands.
+- Run focused tests under this module, then `pnpm --dir frontend fix` and `pnpm --dir frontend test`.
diff --git a/frontend/src/modules/sql-editor/components/DataExplorer/query.test.ts b/frontend/src/modules/sql-editor/components/DataExplorer/query.test.ts
index d37e31bc4a..4be001ada1 100644
--- a/frontend/src/modules/sql-editor/components/DataExplorer/query.test.ts
+++ b/frontend/src/modules/sql-editor/components/DataExplorer/query.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
import {
diff --git a/frontend/src/modules/sql-editor/components/ResultView/copy-formats.test.ts b/frontend/src/modules/sql-editor/components/ResultView/copy-formats.test.ts
index 70e6445201..5d76abfce4 100644
--- a/frontend/src/modules/sql-editor/components/ResultView/copy-formats.test.ts
+++ b/frontend/src/modules/sql-editor/components/ResultView/copy-formats.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, it, vi } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/modules/sql-editor/components/ResultView/selection-math.test.ts b/frontend/src/modules/sql-editor/components/ResultView/selection-math.test.ts
index 845b58f4de..b2b601e1ea 100644
--- a/frontend/src/modules/sql-editor/components/ResultView/selection-math.test.ts
+++ b/frontend/src/modules/sql-editor/components/ResultView/selection-math.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import {
isSingleCellSelected,
diff --git a/frontend/src/modules/sql-editor/components/SQLEditorChromeLayout.test.ts b/frontend/src/modules/sql-editor/components/SQLEditorChromeLayout.test.ts
index 150761a3c1..30a31601ec 100644
--- a/frontend/src/modules/sql-editor/components/SQLEditorChromeLayout.test.ts
+++ b/frontend/src/modules/sql-editor/components/SQLEditorChromeLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/modules/sql-editor/components/SchemaPane/schemaTree.test.ts b/frontend/src/modules/sql-editor/components/SchemaPane/schemaTree.test.ts
index 4c05251621..4b01da786b 100644
--- a/frontend/src/modules/sql-editor/components/SchemaPane/schemaTree.test.ts
+++ b/frontend/src/modules/sql-editor/components/SchemaPane/schemaTree.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test, vi } from "vitest";
import {
diff --git a/frontend/src/modules/sql-editor/components/StandardPanel/appendSelection.test.ts b/frontend/src/modules/sql-editor/components/StandardPanel/appendSelection.test.ts
index 2428d5475b..7bd93e969f 100644
--- a/frontend/src/modules/sql-editor/components/StandardPanel/appendSelection.test.ts
+++ b/frontend/src/modules/sql-editor/components/StandardPanel/appendSelection.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { computeAppendedSelection } from "./appendSelection";
diff --git a/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts
index 8b3088439f..3560fd5a4c 100644
--- a/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts
+++ b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { prepareSnippetInsertion } from "./prepareSnippetInsertion";
diff --git a/frontend/src/modules/sql-editor/components/filterNode.test.ts b/frontend/src/modules/sql-editor/components/filterNode.test.ts
index 88bd74ebaa..6bfdb2bfe7 100644
--- a/frontend/src/modules/sql-editor/components/filterNode.test.ts
+++ b/frontend/src/modules/sql-editor/components/filterNode.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { SavedQueryFolderNode } from "@/modules/sql-editor/model/Sheet";
diff --git a/frontend/src/modules/sql-editor/components/theme/derive.test.ts b/frontend/src/modules/sql-editor/components/theme/derive.test.ts
index 3d9a0bd2ed..9db279f8c3 100644
--- a/frontend/src/modules/sql-editor/components/theme/derive.test.ts
+++ b/frontend/src/modules/sql-editor/components/theme/derive.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
deriveThemeFromAnchors,
diff --git a/frontend/src/modules/sql-editor/components/theme/presets/presets.test.ts b/frontend/src/modules/sql-editor/components/theme/presets/presets.test.ts
index 3b15cf2455..b4b8771f60 100644
--- a/frontend/src/modules/sql-editor/components/theme/presets/presets.test.ts
+++ b/frontend/src/modules/sql-editor/components/theme/presets/presets.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { validateTheme } from "../derive";
import {
diff --git a/frontend/src/modules/sql-editor/components/theme/useWorkspaceSQLEditorTheme.test.ts b/frontend/src/modules/sql-editor/components/theme/useWorkspaceSQLEditorTheme.test.ts
index 1262687a08..19d66df884 100644
--- a/frontend/src/modules/sql-editor/components/theme/useWorkspaceSQLEditorTheme.test.ts
+++ b/frontend/src/modules/sql-editor/components/theme/useWorkspaceSQLEditorTheme.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { hexToColor } from "@/utils";
import { deriveThemeFromAnchors } from "./derive";
diff --git a/frontend/src/modules/sql-editor/legacy/migration.test.ts b/frontend/src/modules/sql-editor/legacy/migration.test.ts
index eaeb604e86..1380dca4f9 100644
--- a/frontend/src/modules/sql-editor/legacy/migration.test.ts
+++ b/frontend/src/modules/sql-editor/legacy/migration.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, describe, expect, test, vi } from "vitest";
import { cleanupLegacyPouchDatabases } from "./migration";
diff --git a/frontend/src/modules/sql-editor/model/Sheet/folder.test.ts b/frontend/src/modules/sql-editor/model/Sheet/folder.test.ts
index 49e3eab590..f7bf404c16 100644
--- a/frontend/src/modules/sql-editor/model/Sheet/folder.test.ts
+++ b/frontend/src/modules/sql-editor/model/Sheet/folder.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { isSubFolder } from "./folder";
diff --git a/frontend/src/modules/sql-editor/model/events.test.ts b/frontend/src/modules/sql-editor/model/events.test.ts
index 3399b6b3dd..988e2cb214 100644
--- a/frontend/src/modules/sql-editor/model/events.test.ts
+++ b/frontend/src/modules/sql-editor/model/events.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import Emittery from "emittery";
import { describe, expect, test, vi } from "vitest";
import { sqlEditorEvents } from "./events";
diff --git a/frontend/src/modules/sql-editor/store/queryHistory.test.ts b/frontend/src/modules/sql-editor/store/queryHistory.test.ts
index f219910851..056d832c87 100644
--- a/frontend/src/modules/sql-editor/store/queryHistory.test.ts
+++ b/frontend/src/modules/sql-editor/store/queryHistory.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import { create, type StoreApi } from "zustand";
import {
diff --git a/frontend/src/modules/sql-editor/store/savedQuery.test.ts b/frontend/src/modules/sql-editor/store/savedQuery.test.ts
index 2ff03642b1..77d10d4560 100644
--- a/frontend/src/modules/sql-editor/store/savedQuery.test.ts
+++ b/frontend/src/modules/sql-editor/store/savedQuery.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import { create, type StoreApi } from "zustand";
import { getSQLEditorEditorState } from "./editor";
diff --git a/frontend/src/modules/sql-editor/store/uiState.test.ts b/frontend/src/modules/sql-editor/store/uiState.test.ts
index 88b9cf14bb..3e36112fdc 100644
--- a/frontend/src/modules/sql-editor/store/uiState.test.ts
+++ b/frontend/src/modules/sql-editor/store/uiState.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { create, type StoreApi } from "zustand";
import { STORAGE_KEY_SQL_EDITOR_AI_PANEL_SIZE } from "@/utils/storage-keys";
diff --git a/frontend/src/modules/workspace-setup-guide/progress.test.ts b/frontend/src/modules/workspace-setup-guide/progress.test.ts
index 3aa7e823a9..92f69f3cd4 100644
--- a/frontend/src/modules/workspace-setup-guide/progress.test.ts
+++ b/frontend/src/modules/workspace-setup-guide/progress.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
GUIDE_PROGRESS_KEYS,
diff --git a/frontend/src/modules/workspace-setup-guide/resolve.test.ts b/frontend/src/modules/workspace-setup-guide/resolve.test.ts
index 76c1b3951c..7ddee3add3 100644
--- a/frontend/src/modules/workspace-setup-guide/resolve.test.ts
+++ b/frontend/src/modules/workspace-setup-guide/resolve.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
resolveGuide,
diff --git a/frontend/src/modules/workspace-setup-guide/scenarios.test.ts b/frontend/src/modules/workspace-setup-guide/scenarios.test.ts
index 99a448f281..8ab5d2e0fe 100644
--- a/frontend/src/modules/workspace-setup-guide/scenarios.test.ts
+++ b/frontend/src/modules/workspace-setup-guide/scenarios.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { validateGuideJourney } from "./resolve";
import {
diff --git a/frontend/src/modules/workspace-setup-guide/steps.test.ts b/frontend/src/modules/workspace-setup-guide/steps.test.ts
index cfa875d070..effbfc86f4 100644
--- a/frontend/src/modules/workspace-setup-guide/steps.test.ts
+++ b/frontend/src/modules/workspace-setup-guide/steps.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
PROJECT_V1_ROUTE_DASHBOARD,
diff --git a/frontend/src/routes/project/ProjectIssueDashboardPage.creators.test.ts b/frontend/src/routes/project/ProjectIssueDashboardPage.creators.test.ts
index 1b27b828dd..ec0e86dd34 100644
--- a/frontend/src/routes/project/ProjectIssueDashboardPage.creators.test.ts
+++ b/frontend/src/routes/project/ProjectIssueDashboardPage.creators.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import source from "./ProjectIssueDashboardPage.tsx?raw";
diff --git a/frontend/src/routes/project/ProjectPageLayout.test.ts b/frontend/src/routes/project/ProjectPageLayout.test.ts
index 0fd5d9214e..9619ceaea3 100644
--- a/frontend/src/routes/project/ProjectPageLayout.test.ts
+++ b/frontend/src/routes/project/ProjectPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/routes/project/ProjectPlanDashboardPage.columns.test.ts b/frontend/src/routes/project/ProjectPlanDashboardPage.columns.test.ts
index b197510bd5..bda31976db 100644
--- a/frontend/src/routes/project/ProjectPlanDashboardPage.columns.test.ts
+++ b/frontend/src/routes/project/ProjectPlanDashboardPage.columns.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import source from "./ProjectPlanDashboardPage.tsx?raw";
diff --git a/frontend/src/routes/project/ProjectSettingsPageLayout.test.ts b/frontend/src/routes/project/ProjectSettingsPageLayout.test.ts
index 3e4e44eda4..6cc75cc7c8 100644
--- a/frontend/src/routes/project/ProjectSettingsPageLayout.test.ts
+++ b/frontend/src/routes/project/ProjectSettingsPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/routes/project/approvalEligibility.test.ts b/frontend/src/routes/project/approvalEligibility.test.ts
index 8f3bd55ea1..3af715c747 100644
--- a/frontend/src/routes/project/approvalEligibility.test.ts
+++ b/frontend/src/routes/project/approvalEligibility.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { getApprovalEligibility } from "./approvalEligibility";
diff --git a/frontend/src/routes/project/issue-detail/utils/databaseChange.test.ts b/frontend/src/routes/project/issue-detail/utils/databaseChange.test.ts
index f7463a847b..7b284669d9 100644
--- a/frontend/src/routes/project/issue-detail/utils/databaseChange.test.ts
+++ b/frontend/src/routes/project/issue-detail/utils/databaseChange.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
import { BACKUP_AVAILABLE_ENGINES } from "./databaseChange";
diff --git a/frontend/src/routes/project/plan-detail/components/SchemaEditorSheetLayout.test.ts b/frontend/src/routes/project/plan-detail/components/SchemaEditorSheetLayout.test.ts
index b624f72a15..999327d591 100644
--- a/frontend/src/routes/project/plan-detail/components/SchemaEditorSheetLayout.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/SchemaEditorSheetLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/routes/project/plan-detail/components/lifecycle/advanceState.test.ts b/frontend/src/routes/project/plan-detail/components/lifecycle/advanceState.test.ts
index 31ba15630b..5ffdfe6e4b 100644
--- a/frontend/src/routes/project/plan-detail/components/lifecycle/advanceState.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/lifecycle/advanceState.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
diff --git a/frontend/src/routes/project/plan-detail/components/lifecycle/frontierStage.test.ts b/frontend/src/routes/project/plan-detail/components/lifecycle/frontierStage.test.ts
index b2d1bb1931..e8660b73fb 100644
--- a/frontend/src/routes/project/plan-detail/components/lifecycle/frontierStage.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/lifecycle/frontierStage.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/routes/project/plan-detail/components/lifecycle/planLifecycleHeaderState.test.ts b/frontend/src/routes/project/plan-detail/components/lifecycle/planLifecycleHeaderState.test.ts
index 38847f0d2d..e55463e338 100644
--- a/frontend/src/routes/project/plan-detail/components/lifecycle/planLifecycleHeaderState.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/lifecycle/planLifecycleHeaderState.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/routes/project/plan-detail/components/lifecycle/planStatusLabel.test.ts b/frontend/src/routes/project/plan-detail/components/lifecycle/planStatusLabel.test.ts
index 8430461daf..72cb505f5f 100644
--- a/frontend/src/routes/project/plan-detail/components/lifecycle/planStatusLabel.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/lifecycle/planStatusLabel.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { getPlanStatusTone } from "./planStatusLabel";
diff --git a/frontend/src/routes/project/plan-detail/components/review/approvalFlowLayout.test.ts b/frontend/src/routes/project/plan-detail/components/review/approvalFlowLayout.test.ts
index a02d69aa08..71e53c3094 100644
--- a/frontend/src/routes/project/plan-detail/components/review/approvalFlowLayout.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/approvalFlowLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { ApprovalStepStatus } from "./approvalFlowLayout";
import {
diff --git a/frontend/src/routes/project/plan-detail/components/review/consolidateTimeline.test.ts b/frontend/src/routes/project/plan-detail/components/review/consolidateTimeline.test.ts
index c228aacd57..a2a445e1e8 100644
--- a/frontend/src/routes/project/plan-detail/components/review/consolidateTimeline.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/consolidateTimeline.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { IssueStatus } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/routes/project/plan-detail/components/review/foldTimeline.test.ts b/frontend/src/routes/project/plan-detail/components/review/foldTimeline.test.ts
index b394009e0a..4292bbbe4d 100644
--- a/frontend/src/routes/project/plan-detail/components/review/foldTimeline.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/foldTimeline.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { FOLD_HEAD, FOLD_TAIL, foldTimeline } from "./foldTimeline";
diff --git a/frontend/src/routes/project/plan-detail/components/review/readinessFooterState.test.ts b/frontend/src/routes/project/plan-detail/components/review/readinessFooterState.test.ts
index 6790afecfd..33b5c58ba3 100644
--- a/frontend/src/routes/project/plan-detail/components/review/readinessFooterState.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/readinessFooterState.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { ApprovalStatus, IssueStatus } from "@/types/proto-es/v1/common_pb";
import {
diff --git a/frontend/src/routes/project/plan-detail/components/review/reviewAction.test.ts b/frontend/src/routes/project/plan-detail/components/review/reviewAction.test.ts
index e7c8fcc258..a6270d89da 100644
--- a/frontend/src/routes/project/plan-detail/components/review/reviewAction.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/reviewAction.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { isReviewSubmitDisabled } from "./reviewAction";
diff --git a/frontend/src/routes/project/plan-detail/components/review/timelineEvents.test.ts b/frontend/src/routes/project/plan-detail/components/review/timelineEvents.test.ts
index 1e6a8d515d..aa07542d48 100644
--- a/frontend/src/routes/project/plan-detail/components/review/timelineEvents.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/review/timelineEvents.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/routes/project/plan-detail/components/rollbackDraft.test.ts b/frontend/src/routes/project/plan-detail/components/rollbackDraft.test.ts
index 83253c86f7..46beeb00b3 100644
--- a/frontend/src/routes/project/plan-detail/components/rollbackDraft.test.ts
+++ b/frontend/src/routes/project/plan-detail/components/rollbackDraft.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test, vi } from "vitest";
import { DraftReviewIssueCreationError } from "@/lib/plan/workflow";
diff --git a/frontend/src/routes/project/plan-detail/shell/__tests__/leaveGuard.test.ts b/frontend/src/routes/project/plan-detail/shell/__tests__/leaveGuard.test.ts
index 3a31c5f446..79cb40e1b4 100644
--- a/frontend/src/routes/project/plan-detail/shell/__tests__/leaveGuard.test.ts
+++ b/frontend/src/routes/project/plan-detail/shell/__tests__/leaveGuard.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { decideLeaveAction } from "../leaveGuard";
diff --git a/frontend/src/routes/project/plan-detail/shell/hooks/fetchPlanSnapshot.test.ts b/frontend/src/routes/project/plan-detail/shell/hooks/fetchPlanSnapshot.test.ts
index 4384c01db0..dc7b690cbe 100644
--- a/frontend/src/routes/project/plan-detail/shell/hooks/fetchPlanSnapshot.test.ts
+++ b/frontend/src/routes/project/plan-detail/shell/hooks/fetchPlanSnapshot.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { IssueStatus } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/routes/project/plan-detail/shell/hooks/useRedirects.test.ts b/frontend/src/routes/project/plan-detail/shell/hooks/useRedirects.test.ts
index 779a7fe3c2..f85e840012 100644
--- a/frontend/src/routes/project/plan-detail/shell/hooks/useRedirects.test.ts
+++ b/frontend/src/routes/project/plan-detail/shell/hooks/useRedirects.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { IssueSchema } from "@/types/proto-es/v1/issue_service_pb";
diff --git a/frontend/src/routes/project/plan-detail/utils/changeReference.test.ts b/frontend/src/routes/project/plan-detail/utils/changeReference.test.ts
index 528d7b993a..40be4f27bd 100644
--- a/frontend/src/routes/project/plan-detail/utils/changeReference.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/changeReference.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import type { TFunction } from "i18next";
import { describe, expect, it } from "vitest";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
diff --git a/frontend/src/routes/project/plan-detail/utils/directiveUtils.test.ts b/frontend/src/routes/project/plan-detail/utils/directiveUtils.test.ts
index d64ba857ef..9b02f0e148 100644
--- a/frontend/src/routes/project/plan-detail/utils/directiveUtils.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/directiveUtils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
getGhostConfig,
diff --git a/frontend/src/routes/project/plan-detail/utils/options.test.ts b/frontend/src/routes/project/plan-detail/utils/options.test.ts
index ff2323704d..ad66923878 100644
--- a/frontend/src/routes/project/plan-detail/utils/options.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/options.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
diff --git a/frontend/src/routes/project/plan-detail/utils/phaseSummary.test.ts b/frontend/src/routes/project/plan-detail/utils/phaseSummary.test.ts
index 553c4e5e39..37f6addf24 100644
--- a/frontend/src/routes/project/plan-detail/utils/phaseSummary.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/phaseSummary.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
ApprovalStatus,
diff --git a/frontend/src/routes/project/plan-detail/utils/spec.test.ts b/frontend/src/routes/project/plan-detail/utils/spec.test.ts
index 30346e5aa6..4d1f9e9c07 100644
--- a/frontend/src/routes/project/plan-detail/utils/spec.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/spec.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import { getSelectedSpec } from "./spec";
diff --git a/frontend/src/routes/project/plan-detail/utils/sqlAdvice.test.ts b/frontend/src/routes/project/plan-detail/utils/sqlAdvice.test.ts
index 643860c344..81cf8afc42 100644
--- a/frontend/src/routes/project/plan-detail/utils/sqlAdvice.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/sqlAdvice.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/routes/project/plan-detail/utils/targets.test.ts b/frontend/src/routes/project/plan-detail/utils/targets.test.ts
index f3fb220093..6855964776 100644
--- a/frontend/src/routes/project/plan-detail/utils/targets.test.ts
+++ b/frontend/src/routes/project/plan-detail/utils/targets.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
filterPlanTargets,
diff --git a/frontend/src/routes/project/utils/reviewBadge.test.ts b/frontend/src/routes/project/utils/reviewBadge.test.ts
index 26a7e21a14..832857dafc 100644
--- a/frontend/src/routes/project/utils/reviewBadge.test.ts
+++ b/frontend/src/routes/project/utils/reviewBadge.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { ApprovalStatus, IssueStatus } from "@/types/proto-es/v1/common_pb";
import { getPlanDraftState, getReviewBadge } from "./reviewBadge";
diff --git a/frontend/src/routes/project/webhookCreation.test.ts b/frontend/src/routes/project/webhookCreation.test.ts
index c8b890d7a3..26a611c0a0 100644
--- a/frontend/src/routes/project/webhookCreation.test.ts
+++ b/frontend/src/routes/project/webhookCreation.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { WebhookType } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/routes/workspace/EnvironmentsPageLayout.test.ts b/frontend/src/routes/workspace/EnvironmentsPageLayout.test.ts
index cbe99a48f0..bb8e23186e 100644
--- a/frontend/src/routes/workspace/EnvironmentsPageLayout.test.ts
+++ b/frontend/src/routes/workspace/EnvironmentsPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/IDPsPageLayout.test.ts b/frontend/src/routes/workspace/IDPsPageLayout.test.ts
index 26ab70509a..32843c4ce6 100644
--- a/frontend/src/routes/workspace/IDPsPageLayout.test.ts
+++ b/frontend/src/routes/workspace/IDPsPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/LandingPage.navigation.test.ts b/frontend/src/routes/workspace/LandingPage.navigation.test.ts
index ca0cad12e3..8a8547f57c 100644
--- a/frontend/src/routes/workspace/LandingPage.navigation.test.ts
+++ b/frontend/src/routes/workspace/LandingPage.navigation.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import source from "./LandingPage.tsx?raw";
diff --git a/frontend/src/routes/workspace/LearnMoreLinkLayout.test.ts b/frontend/src/routes/workspace/LearnMoreLinkLayout.test.ts
index 34023a0033..2c67dfd9f0 100644
--- a/frontend/src/routes/workspace/LearnMoreLinkLayout.test.ts
+++ b/frontend/src/routes/workspace/LearnMoreLinkLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/MCPPage.test.ts b/frontend/src/routes/workspace/MCPPage.test.ts
index 5a2c1121d9..d0c60d0666 100644
--- a/frontend/src/routes/workspace/MCPPage.test.ts
+++ b/frontend/src/routes/workspace/MCPPage.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/MyIssuesPage.creators.test.ts b/frontend/src/routes/workspace/MyIssuesPage.creators.test.ts
index 290bc0e508..5bf6227695 100644
--- a/frontend/src/routes/workspace/MyIssuesPage.creators.test.ts
+++ b/frontend/src/routes/workspace/MyIssuesPage.creators.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import source from "./MyIssuesPage.tsx?raw";
diff --git a/frontend/src/routes/workspace/ProjectsPage.navigation.test.ts b/frontend/src/routes/workspace/ProjectsPage.navigation.test.ts
index 9694de625d..e48dc98846 100644
--- a/frontend/src/routes/workspace/ProjectsPage.navigation.test.ts
+++ b/frontend/src/routes/workspace/ProjectsPage.navigation.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import source from "./ProjectsPage.tsx?raw";
diff --git a/frontend/src/routes/workspace/RolesPageLayout.test.ts b/frontend/src/routes/workspace/RolesPageLayout.test.ts
index af5e1d37f9..b452d311b5 100644
--- a/frontend/src/routes/workspace/RolesPageLayout.test.ts
+++ b/frontend/src/routes/workspace/RolesPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/SubscriptionPageLayout.test.ts b/frontend/src/routes/workspace/SubscriptionPageLayout.test.ts
index faa655d45c..80f2861b65 100644
--- a/frontend/src/routes/workspace/SubscriptionPageLayout.test.ts
+++ b/frontend/src/routes/workspace/SubscriptionPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/WorkspacePageLayout.test.ts b/frontend/src/routes/workspace/WorkspacePageLayout.test.ts
index a2d74c2a0b..7a8e12d36e 100644
--- a/frontend/src/routes/workspace/WorkspacePageLayout.test.ts
+++ b/frontend/src/routes/workspace/WorkspacePageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
diff --git a/frontend/src/routes/workspace/general/GeneralPageLayout.test.ts b/frontend/src/routes/workspace/general/GeneralPageLayout.test.ts
index 2f0f9a68f8..0607791ce2 100644
--- a/frontend/src/routes/workspace/general/GeneralPageLayout.test.ts
+++ b/frontend/src/routes/workspace/general/GeneralPageLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/general/aiProviderDefaults.test.ts b/frontend/src/routes/workspace/general/aiProviderDefaults.test.ts
index d0cd54df13..dd535d8383 100644
--- a/frontend/src/routes/workspace/general/aiProviderDefaults.test.ts
+++ b/frontend/src/routes/workspace/general/aiProviderDefaults.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { AISetting_Provider } from "@/types/proto-es/v1/setting_service_pb";
import {
diff --git a/frontend/src/routes/workspace/membersPageActions.test.ts b/frontend/src/routes/workspace/membersPageActions.test.ts
index 18f12024e3..8ccf7fdbb7 100644
--- a/frontend/src/routes/workspace/membersPageActions.test.ts
+++ b/frontend/src/routes/workspace/membersPageActions.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { ProjectSchema } from "@/types/proto-es/v1/project_service_pb";
diff --git a/frontend/src/routes/workspace/membersPageEnvironment.test.ts b/frontend/src/routes/workspace/membersPageEnvironment.test.ts
index 95043d0bbe..03b78a833e 100644
--- a/frontend/src/routes/workspace/membersPageEnvironment.test.ts
+++ b/frontend/src/routes/workspace/membersPageEnvironment.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { getProjectRoleBindingEnvironmentLimitationState } from "./membersPageEnvironment";
diff --git a/frontend/src/routes/workspace/users/UserFormSheetLayout.test.ts b/frontend/src/routes/workspace/users/UserFormSheetLayout.test.ts
index df8966ebe7..62e1b63606 100644
--- a/frontend/src/routes/workspace/users/UserFormSheetLayout.test.ts
+++ b/frontend/src/routes/workspace/users/UserFormSheetLayout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
diff --git a/frontend/src/routes/workspace/users/generatePassword.test.ts b/frontend/src/routes/workspace/users/generatePassword.test.ts
index c6fe5d37d2..228e91ae19 100644
--- a/frontend/src/routes/workspace/users/generatePassword.test.ts
+++ b/frontend/src/routes/workspace/users/generatePassword.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { getPasswordErrors } from "@/routes/workspace/profile/UserPasswordSection";
import type { WorkspaceProfileSetting_PasswordRestriction } from "@/types/proto-es/v1/setting_service_pb";
diff --git a/frontend/src/stores/app/accessGrant.test.ts b/frontend/src/stores/app/accessGrant.test.ts
index 2d9c1ff79d..1e13dd7b0c 100644
--- a/frontend/src/stores/app/accessGrant.test.ts
+++ b/frontend/src/stores/app/accessGrant.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
buildAccessGrantFilter,
diff --git a/frontend/src/stores/app/database.test.ts b/frontend/src/stores/app/database.test.ts
index 4d7739ae94..33a2799840 100644
--- a/frontend/src/stores/app/database.test.ts
+++ b/frontend/src/stores/app/database.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
diff --git a/frontend/src/stores/app/filterEscaping.test.ts b/frontend/src/stores/app/filterEscaping.test.ts
index 14f573005e..08f778eefe 100644
--- a/frontend/src/stores/app/filterEscaping.test.ts
+++ b/frontend/src/stores/app/filterEscaping.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { buildAccessGrantFilter } from "./accessGrant";
import { buildGroupFilter } from "./group";
diff --git a/frontend/src/stores/app/instance.test.ts b/frontend/src/stores/app/instance.test.ts
index 0ce88c37c1..07d3b243ad 100644
--- a/frontend/src/stores/app/instance.test.ts
+++ b/frontend/src/stores/app/instance.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
diff --git a/frontend/src/stores/app/issueComment.test.ts b/frontend/src/stores/app/issueComment.test.ts
index 811e2db3d7..a8cc37937c 100644
--- a/frontend/src/stores/app/issueComment.test.ts
+++ b/frontend/src/stores/app/issueComment.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { beforeEach, expect, test, vi } from "vitest";
import { PositionSchema } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/stores/app/utils.test.ts b/frontend/src/stores/app/utils.test.ts
index 85747e590c..ae7c724b92 100644
--- a/frontend/src/stores/app/utils.test.ts
+++ b/frontend/src/stores/app/utils.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create, type MessageInitShape } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/types/sqlReview.test.ts b/frontend/src/types/sqlReview.test.ts
index b479234fdd..8417924267 100644
--- a/frontend/src/types/sqlReview.test.ts
+++ b/frontend/src/types/sqlReview.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/types/v1/instance.test.ts b/frontend/src/types/v1/instance.test.ts
index 861550611d..bf9fc15f22 100644
--- a/frontend/src/types/v1/instance.test.ts
+++ b/frontend/src/types/v1/instance.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { isValidInstanceName, UNKNOWN_INSTANCE_NAME } from "./instance";
diff --git a/frontend/src/types/v1/projectWebhook.test.ts b/frontend/src/types/v1/projectWebhook.test.ts
index b061eadc10..0c4360e151 100644
--- a/frontend/src/types/v1/projectWebhook.test.ts
+++ b/frontend/src/types/v1/projectWebhook.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test, vi } from "vitest";
import { WebhookType } from "../proto-es/v1/common_pb";
diff --git a/frontend/src/utils/auto-route.test.ts b/frontend/src/utils/auto-route.test.ts
index 69d9e58467..beb945281e 100644
--- a/frontend/src/utils/auto-route.test.ts
+++ b/frontend/src/utils/auto-route.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import {
PROJECT_V1_ROUTE_DATABASE_CHANGELOG_DETAIL,
diff --git a/frontend/src/utils/css.test.ts b/frontend/src/utils/css.test.ts
index ed08f8e993..8562e84db6 100644
--- a/frontend/src/utils/css.test.ts
+++ b/frontend/src/utils/css.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { colorToHex, colorToRgbString, hexToColor } from "./css";
diff --git a/frontend/src/utils/datetime.test.ts b/frontend/src/utils/datetime.test.ts
index 764aecdc38..1aa16defee 100644
--- a/frontend/src/utils/datetime.test.ts
+++ b/frontend/src/utils/datetime.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
vi.mock("@/lib/i18n", () => ({
diff --git a/frontend/src/utils/migrate-user-storage.test.ts b/frontend/src/utils/migrate-user-storage.test.ts
index 3f24689075..a8c5b0f8d0 100644
--- a/frontend/src/utils/migrate-user-storage.test.ts
+++ b/frontend/src/utils/migrate-user-storage.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { migrateUserStorage } from "./storage-migrate";
diff --git a/frontend/src/utils/sqlResult.test.ts b/frontend/src/utils/sqlResult.test.ts
index f953f148a6..9bf8c3adae 100644
--- a/frontend/src/utils/sqlResult.test.ts
+++ b/frontend/src/utils/sqlResult.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create as createProto } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/utils/storage-migrate.test.ts b/frontend/src/utils/storage-migrate.test.ts
index fca964b801..60571bc750 100644
--- a/frontend/src/utils/storage-migrate.test.ts
+++ b/frontend/src/utils/storage-migrate.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import {
STORAGE_KEY_AI_DISMISS,
diff --git a/frontend/src/utils/string.test.ts b/frontend/src/utils/string.test.ts
index fea151cade..9be2e7bd97 100644
--- a/frontend/src/utils/string.test.ts
+++ b/frontend/src/utils/string.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, it } from "vitest";
import { normalizeTitle } from "./string";
diff --git a/frontend/src/utils/v1/celLiteral.test.ts b/frontend/src/utils/v1/celLiteral.test.ts
index 936dc1fefe..f0c96b9d10 100644
--- a/frontend/src/utils/v1/celLiteral.test.ts
+++ b/frontend/src/utils/v1/celLiteral.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { celMapField, celString, celStringList } from "./celLiteral";
diff --git a/frontend/src/utils/v1/database.test.ts b/frontend/src/utils/v1/database.test.ts
index e5fff9648d..6268322895 100644
--- a/frontend/src/utils/v1/database.test.ts
+++ b/frontend/src/utils/v1/database.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
import { extractDatabaseResourceName } from "./database";
diff --git a/frontend/src/utils/v1/databaseResource.test.ts b/frontend/src/utils/v1/databaseResource.test.ts
index f08a17667a..242e10b42c 100644
--- a/frontend/src/utils/v1/databaseResource.test.ts
+++ b/frontend/src/utils/v1/databaseResource.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { parseStringToResource } from "./databaseResource";
diff --git a/frontend/src/utils/v1/iam.test.ts b/frontend/src/utils/v1/iam.test.ts
index 224c6bf99b..e9498f847f 100644
--- a/frontend/src/utils/v1/iam.test.ts
+++ b/frontend/src/utils/v1/iam.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import {
diff --git a/frontend/src/utils/v1/instance.test.ts b/frontend/src/utils/v1/instance.test.ts
index beddd54fb9..e4d9ad2a78 100644
--- a/frontend/src/utils/v1/instance.test.ts
+++ b/frontend/src/utils/v1/instance.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
import { Engine } from "@/types/proto-es/v1/common_pb";
diff --git a/frontend/src/utils/v1/issue/rollout.test.ts b/frontend/src/utils/v1/issue/rollout.test.ts
index c38f14808e..9d10bc7436 100644
--- a/frontend/src/utils/v1/issue/rollout.test.ts
+++ b/frontend/src/utils/v1/issue/rollout.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { Plan_TaskStatusCountSchema } from "@/types/proto-es/v1/plan_service_pb";
diff --git a/frontend/src/utils/v1/queryHistory.test.ts b/frontend/src/utils/v1/queryHistory.test.ts
index 36e20e8b4c..c3a2d29f79 100644
--- a/frontend/src/utils/v1/queryHistory.test.ts
+++ b/frontend/src/utils/v1/queryHistory.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { describe, expect, test } from "vitest";
import { extractQueryHistoryUID } from "./queryHistory";
diff --git a/frontend/src/utils/v1/savedQuery.test.ts b/frontend/src/utils/v1/savedQuery.test.ts
index e981f06079..5983fcf6b1 100644
--- a/frontend/src/utils/v1/savedQuery.test.ts
+++ b/frontend/src/utils/v1/savedQuery.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { beforeEach, describe, expect, test, vi } from "vitest";
import type { SavedQuery } from "@/types/proto-es/v1/saved_query_service_pb";
import { SavedQueryBinding_Level } from "@/types/proto-es/v1/saved_query_service_pb";
diff --git a/frontend/src/utils/v1/sql.test.ts b/frontend/src/utils/v1/sql.test.ts
index 878f5ffaaa..cf71d8eed3 100644
--- a/frontend/src/utils/v1/sql.test.ts
+++ b/frontend/src/utils/v1/sql.test.ts
@@ -1,3 +1,4 @@
+// @vitest-environment node
import { create } from "@bufbuild/protobuf";
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
import { describe, expect, it, vi } from "vitest";
diff --git a/frontend/tsconfig.i18n.json b/frontend/tsconfig.i18n.json
deleted file mode 100644
index 90c5f25ad2..0000000000
--- a/frontend/tsconfig.i18n.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES2022"
- }
-}
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index a5b8607ba1..fbbc2a0dea 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -19,29 +19,39 @@ const extractHostPort = (url: string) => {
export default defineConfig({
plugins: [
- legacy({
- // Explicit version floors, matching what "> 0.08%, not dead" resolved
- // to as of caniuse-lite 1.0.30001792. Usage-based queries re-resolve
- // against every caniuse-lite/browserslist update; a 2026-07 data update
- // pulled Chrome 39-60 above the threshold, which made the babel pass
- // in plugin-legacy's renderChunk down-level every chunk to ES5 and
- // took the release build from ~2.5min to ~32min (13x).
- // (and_qq/and_uc from the old resolution are omitted: babel's
- // browserNameMap has no entry for them, so they never influenced
- // the transforms. ios 11 dominates the transform/polyfill union.)
- targets: [
- "chrome >= 103",
- "edge >= 100",
- "firefox >= 115",
- "safari >= 15",
- "ios >= 11",
- "android >= 103",
- "samsung >= 29",
- "opera >= 99",
- "op_mob >= 80",
- ],
- additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
- }),
+ // The legacy bundle is browser-compat output, not a correctness signal: it
+ // builds the whole app a second time and babel-down-levels every chunk,
+ // which is ~190s of a ~200s release build. The PR-time build check only
+ // needs to prove the app bundles, so the bundle stage of `pnpm test` opts
+ // out by setting BB_SKIP_LEGACY=1.
+ // Release builds (scripts/Dockerfile) leave BB_SKIP_LEGACY unset.
+ ...(process.env.BB_SKIP_LEGACY
+ ? []
+ : [
+ legacy({
+ // Explicit version floors, matching what "> 0.08%, not dead" resolved
+ // to as of caniuse-lite 1.0.30001792. Usage-based queries re-resolve
+ // against every caniuse-lite/browserslist update; a 2026-07 data
+ // update pulled Chrome 39-60 above the threshold, which made the
+ // babel pass in plugin-legacy's renderChunk down-level every chunk
+ // to ES5 and took the release build from ~2.5min to ~32min (13x).
+ // (and_qq/and_uc from the old resolution are omitted: babel's
+ // browserNameMap has no entry for them, so they never influenced
+ // the transforms. ios 11 dominates the transform/polyfill union.)
+ targets: [
+ "chrome >= 103",
+ "edge >= 100",
+ "firefox >= 115",
+ "safari >= 15",
+ "ios >= 11",
+ "android >= 103",
+ "samsung >= 29",
+ "opera >= 99",
+ "op_mob >= 80",
+ ],
+ additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
+ }),
+ ]),
{
name: "react-tsx-transform",
enforce: "pre",
diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts
index 58bf120b76..354b6de649 100644
--- a/frontend/vitest.config.ts
+++ b/frontend/vitest.config.ts
@@ -7,6 +7,10 @@ export default mergeConfig(
defineConfig({
test: {
globals: true,
+ // Worker threads reuse a V8 isolate per file instead of forking a
+ // process, which cuts ~10% off the suite (82s -> 74s). Each file still
+ // gets its own jsdom and module registry; only the process is shared.
+ pool: "threads",
environment: "jsdom",
// jsdom rejects localStorage / sessionStorage access when the document
// origin is opaque (the default for the about:blank URL), so give it a
@@ -23,9 +27,17 @@ export default mergeConfig(
// are still far below any real hang.
testTimeout: 15000,
hookTimeout: 30000,
+ // @stylexjs/unplugin (0.19.0, the current release) leaves a handle open
+ // that never lets the Vite server close, so every run -- including a
+ // single-file one -- used to sit for the default 10s on "close timed
+ // out" after the results were already reported. Tests need the StyleX
+ // transform (skipping the plugin fails 82 files), so bound the wait
+ // instead: vitest force-exits either way, this just stops it idling.
+ teardownTimeout: 1000,
exclude: [...configDefaults.exclude, "e2e/*", "tests/e2e/**"],
root: fileURLToPath(new URL("./", import.meta.url)),
setupFiles: ["./vitest.setup.ts"],
+ globalSetup: ["./vitest.globalSetup.ts"],
},
})
);
diff --git a/frontend/vitest.globalSetup.ts b/frontend/vitest.globalSetup.ts
new file mode 100644
index 0000000000..4b6935faeb
--- /dev/null
+++ b/frontend/vitest.globalSetup.ts
@@ -0,0 +1,15 @@
+import { execFileSync } from "node:child_process";
+import { fileURLToPath } from "node:url";
+
+// Several tests import generated sources that are gitignored and copied from
+// the backend -- src/modules/agent/logic/tools/gen/openapi-index.ts and the
+// permission schema behind src/types/iam/permission.ts. `pnpm test` and
+// `pnpm dev` regenerate them, but a focused `pnpm vitest run <path>` after
+// switching revisions would otherwise read a stale copy, or fail module
+// resolution if it was never generated. Regenerating here keeps every vitest
+// entry point self-sufficient without another package.json script.
+export default function setup() {
+ const cwd = fileURLToPath(new URL("./", import.meta.url));
+ execFileSync("sh", ["./scripts/copy_config_files.sh"], { cwd, stdio: "inherit" });
+ execFileSync("node", ["scripts/generate_openapi_index.js"], { cwd, stdio: "inherit" });
+}