|
| 1 | +# GitHub Copilot Instructions for YDB Embedded UI |
| 2 | + |
| 3 | +> **Note**: This file contains project-specific instructions for GitHub Copilot code review and assistance. |
| 4 | +> These instructions are derived from AGENTS.md but formatted specifically for Copilot's consumption. |
| 5 | +> When updating project conventions, update both AGENTS.md (for human developers) and this file (for Copilot). |
| 6 | +
|
| 7 | +## Project Overview |
| 8 | + |
| 9 | +This is a React-based monitoring and management interface for YDB clusters. The codebase follows specific patterns and conventions that must be maintained. |
| 10 | + |
| 11 | +## Tech Stack Requirements |
| 12 | + |
| 13 | +- Use React 18.3 with TypeScript 5.x |
| 14 | +- Use Redux Toolkit 2.x with RTK Query for state management |
| 15 | +- Use Gravity UI (@gravity-ui/uikit) 7.x for UI components |
| 16 | +- Use React Router v5 (NOT v6) for routing |
| 17 | +- Use Monaco Editor 0.52 for code editing features |
| 18 | + |
| 19 | +## Critical Coding Rules |
| 20 | + |
| 21 | +### API Architecture |
| 22 | + |
| 23 | +- NEVER call APIs directly - always use `window.api.module.method()` pattern |
| 24 | +- Use RTK Query's `injectEndpoints` pattern for API endpoints |
| 25 | +- Wrap `window.api` calls in RTK Query for proper state management |
| 26 | + |
| 27 | +### Component Patterns |
| 28 | + |
| 29 | +- Use BEM naming with `cn()` utility: `const b = cn('component-name')` |
| 30 | +- Use `PaginatedTable` component for all data tables |
| 31 | +- Tables require: columns, fetchData function, and unique tableName |
| 32 | +- Use virtual scrolling for large datasets |
| 33 | + |
| 34 | +### Internationalization (MANDATORY) |
| 35 | + |
| 36 | +- NEVER hardcode user-facing strings |
| 37 | +- ALWAYS create i18n entries in component's `i18n/` folder |
| 38 | +- Follow key format: `<context>_<content>` (e.g., `action_save`, `field_name`) |
| 39 | +- Register keysets with `registerKeysets()` using unique component name |
| 40 | + |
| 41 | +### State Management |
| 42 | + |
| 43 | +- Use Redux Toolkit with domain-based organization |
| 44 | +- NEVER mutate state in RTK Query - return new objects/arrays |
| 45 | +- Clear errors on user input in forms |
| 46 | +- Always handle loading states in UI |
| 47 | + |
| 48 | +### UI Components |
| 49 | + |
| 50 | +- Prefer Gravity UI components over custom implementations |
| 51 | +- Use `createToast` for notifications |
| 52 | +- Use `ResponseError` component for API errors |
| 53 | +- Use `Loader` and `TableSkeleton` for loading states |
| 54 | + |
| 55 | +### Form Handling |
| 56 | + |
| 57 | +- Always use controlled components with validation |
| 58 | +- Clear errors on user input |
| 59 | +- Validate before submission |
| 60 | +- Use Gravity UI form components with error states |
| 61 | + |
| 62 | +### Dialog/Modal Patterns |
| 63 | + |
| 64 | +- Use `@ebay/nice-modal-react` for complex modals |
| 65 | +- Use Gravity UI `Dialog` for simple dialogs |
| 66 | +- Always include loading states |
| 67 | + |
| 68 | +### Type Conventions |
| 69 | + |
| 70 | +- API types prefixed with 'T' (e.g., `TTenantInfo`, `TClusterInfo`) |
| 71 | +- Types located in `src/types/api/` directory |
| 72 | + |
| 73 | +### Performance Requirements |
| 74 | + |
| 75 | +- Use React.memo for expensive renders |
| 76 | +- Lazy load Monaco Editor |
| 77 | +- Batch API requests when possible |
| 78 | +- Use virtual scrolling for tables |
| 79 | + |
| 80 | +### Testing Patterns |
| 81 | + |
| 82 | +- Unit tests colocated in `__test__` directories |
| 83 | +- E2E tests use Playwright with page objects pattern |
| 84 | +- Use CSS class selectors for E2E element selection |
| 85 | + |
| 86 | +### Navigation (React Router v5) |
| 87 | + |
| 88 | +- Use React Router v5 hooks (`useHistory`, `useParams`) |
| 89 | +- Always validate route params exist before use |
| 90 | + |
| 91 | +## Common Utilities |
| 92 | + |
| 93 | +- Formatters: `formatBytes()`, `formatDateTime()` from `src/utils/dataFormatters/` |
| 94 | +- Time parsing: utilities in `src/utils/timeParsers/` |
| 95 | +- Query utilities: `src/utils/query.ts` for SQL/YQL helpers |
| 96 | + |
| 97 | +## Before Making Changes |
| 98 | + |
| 99 | +- Run `npm run lint` and `npm run typecheck` before committing |
| 100 | +- Follow conventional commit message format |
| 101 | +- Ensure all user-facing text is internationalized |
| 102 | +- Test with a local YDB instance when possible |
| 103 | + |
| 104 | +## Debugging Helpers |
| 105 | + |
| 106 | +- `window.api` - Access API methods in browser console |
| 107 | +- `window.ydbEditor` - Monaco editor instance |
| 108 | +- Enable request tracing with `DEV_ENABLE_TRACING_FOR_ALL_REQUESTS` |
0 commit comments