|
| 1 | +# Copilot React Review Instruction |
| 2 | + |
| 3 | +## Purpose |
| 4 | +This document outlines the review guidelines Copilot should follow when evaluating changes under the `/react` directory. The React SPA powers the latest Backend.AI Web UI features and ships web component wrappers that integrate with the legacy Lit-based shell. |
| 5 | + |
| 6 | +## Review Focus Areas |
| 7 | +- **Structure & Patterns** |
| 8 | + - New components must be loaded via `React.lazy`, rendered inside `DefaultProviders`, and registered with `reactToWebComponent` using the `backend-ai-react-*` naming convention in `customElements.define`. |
| 9 | + - When slotting Lit web components into React wrappers, ensure the README-documented `<slot>` pattern is respected. |
| 10 | +- **Data & State Management** |
| 11 | + - GraphQL updates require matching Relay compiler artifacts. Confirm `pnpm run relay` output is committed whenever fragments or queries change. |
| 12 | + - For TanStack Query, Jotai, and custom hooks, verify cache keys/atom names are stable and avoid unnecessary re-renders. |
| 13 | + - Backend.AI client access should go through provided hooks such as `useSuspendedBackendaiClient`. |
| 14 | +- **Styling & Theme** |
| 15 | + - Disallow direct CSS imports. Prefer inline styles, CSS-in-JS, or `?raw` string imports injected via `<style>` tags. |
| 16 | + - Ant Design v5 theme tokens and `resources/theme.json` must be respected to prevent leaking global styles. |
| 17 | +- **Static Assets** |
| 18 | + - Images/fonts should live under `/resources` and be referenced by path—avoid bundling assets via import statements. |
| 19 | +- **Internationalization** |
| 20 | + - Wrap new user-facing strings with `react-i18next` utilities and provide translation keys in `resources/i18n/*.json`. |
| 21 | +- **Validation & Quality** |
| 22 | + - Maintain strict TypeScript typing with minimal `any` usage and honor ESLint rules (`import/no-duplicates`, unused vars suppression via `_` prefix, etc.). |
| 23 | + - Update Jest specs (`react/__test__`) or Storybook stories when behavior changes warrant it. |
| 24 | + - Ensure asynchronous flows supply loading and error UI consistent with `Suspense`/`ErrorBoundary` patterns. |
| 25 | +- **Build & Dependencies** |
| 26 | + - New dependencies belong in `react/package.json` using `workspace:*` or appropriate semver ranges. |
| 27 | + - Changes to CRACO or build setup must pass `pnpm run build:only`. |
| 28 | +- **Accessibility & UX** |
| 29 | + - Confirm ARIA attributes, keyboard navigation, and focus handling meet accessibility expectations. |
| 30 | + |
| 31 | +## Review Checklist |
| 32 | +1. Style: `pnpm --filter react lint` passes without violations. |
| 33 | +2. Format: `pnpm --filter react format` (or `format-fix`) succeeds. |
| 34 | +3. Types/Relay: Run `pnpm run relay` and, if needed, `pnpm dlx tsc`. |
| 35 | +4. Tests: Execute `pnpm --filter react test` or other relevant suites. |
| 36 | +5. Build: For major UI updates, run `pnpm run build:react-only` to verify bundling. |
| 37 | +6. Resources: Confirm i18n JSON, theme files, static paths, and docs are updated when required. |
| 38 | + |
| 39 | +## Reference Commands |
| 40 | +- Dev server: `pnpm run server:d` |
| 41 | +- Lint: `pnpm --filter react lint` |
| 42 | +- Format: `pnpm --filter react format` |
| 43 | +- Test: `pnpm --filter react test` |
| 44 | +- Relay compile: `pnpm run relay` |
| 45 | +- Storybook: `pnpm --filter react storybook` |
| 46 | + |
| 47 | +Copilot should recommend fixes whenever changes fail to meet these standards. |
0 commit comments