Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
ea39bb3
update copyright (#21485)
blakeblackshear Jan 1, 2026
7e5d98d
fix: Correctly apply API filter for "reviewed" (#21600)
dermotduffy Jan 11, 2026
7b5a1b7
ensure cloudflare pages are indexed by google (#21606)
blakeblackshear Jan 11, 2026
91cc674
i18n miscellaneous fixes (#21614)
ZhaiSoul Jan 12, 2026
2c34e1e
Miscellaneous fixes (0.17 beta) (#21607)
NickM-27 Jan 13, 2026
b2d1fdf
Translated using Weblate (Turkish)
weblate Jan 13, 2026
8a52d83
Translated using Weblate (Lithuanian)
weblate Jan 13, 2026
4188eed
Translated using Weblate (Thai)
weblate Jan 13, 2026
8d26d2d
Translated using Weblate (Portuguese (Brazil))
weblate Jan 13, 2026
c13a47f
Translated using Weblate (German)
weblate Jan 13, 2026
68fee3e
Translated using Weblate (Greek)
weblate Jan 13, 2026
1c7f68b
Translated using Weblate (Estonian)
weblate Jan 13, 2026
849677c
Translated using Weblate (Romanian)
weblate Jan 13, 2026
067de06
Translated using Weblate (Bulgarian)
weblate Jan 13, 2026
6572fa8
Translated using Weblate (Ukrainian)
weblate Jan 13, 2026
91f9a01
Translated using Weblate (Japanese)
weblate Jan 13, 2026
a326ecd
Translated using Weblate (Catalan)
weblate Jan 13, 2026
820fc6e
Translated using Weblate (Portuguese)
weblate Jan 13, 2026
cd3d088
Translated using Weblate (Croatian)
weblate Jan 13, 2026
e2353e5
Translated using Weblate (Hungarian)
weblate Jan 13, 2026
2b345bd
Translated using Weblate (Hebrew)
weblate Jan 13, 2026
ace1173
Translated using Weblate (Polish)
weblate Jan 13, 2026
3115495
Translated using Weblate (Italian)
weblate Jan 13, 2026
d1a184d
Translated using Weblate (Arabic)
weblate Jan 13, 2026
0a24e3c
Translated using Weblate (Dutch)
weblate Jan 13, 2026
53a5923
Translated using Weblate (Spanish)
weblate Jan 13, 2026
85bc988
Translated using Weblate (French)
weblate Jan 13, 2026
da75481
Translated using Weblate (Swedish)
weblate Jan 13, 2026
7d02220
Translated using Weblate (Persian)
weblate Jan 13, 2026
bd568ab
Translated using Weblate (Chinese (Traditional Han script))
weblate Jan 13, 2026
5e57dbe
Translated using Weblate (Chinese (Simplified Han script))
weblate Jan 13, 2026
cd37af4
Translated using Weblate (Norwegian Bokmål)
weblate Jan 13, 2026
c222aa0
Bump form-data from 4.0.0 to 4.0.4 in /web (#19242)
dependabot[bot] Jan 14, 2026
90d857a
Bump vite from 6.2.0 to 6.4.1 in /web (#20593)
dependabot[bot] Jan 14, 2026
43c8f68
Bump qs from 6.14.0 to 6.14.1 in /docs (#21504)
dependabot[bot] Jan 14, 2026
2e1706b
Bump @remix-run/router and react-router-dom in /web (#21580)
dependabot[bot] Jan 14, 2026
bf099c3
Miscellaneous fixes (0.17 beta) (#21655)
NickM-27 Jan 15, 2026
cfeb866
fix(recording): handle unexpected filenames in cache maintainer to pr…
kirill578 Jan 17, 2026
0a8f499
Miscellaneous fixes (0.17 beta) (#21683)
hawkeye217 Jan 18, 2026
d633c7d
Miscellaneous fixes (0.17 beta) (#21699)
hawkeye217 Jan 20, 2026
90b14f1
Bump lodash from 4.17.21 to 4.17.23 in /web (#21749)
dependabot[bot] Jan 22, 2026
a75f694
Miscellaneous fixes (0.17 beta) (#21737)
hawkeye217 Jan 22, 2026
50ac5a1
Miscellaneous fixes (0.17 beta) (#21764)
hawkeye217 Jan 26, 2026
4131252
Port go2rtc check (#21808)
blakeblackshear Jan 28, 2026
338d85a
Fix i18n keys (#21814)
Marijn0 Jan 28, 2026
3b6814f
Revert "Miscellaneous fixes (0.17 beta) (#21764)" (#21825)
hawkeye217 Jan 29, 2026
b4520d9
Miscellaneous fixes (0.17 beta) (#21826)
hawkeye217 Jan 29, 2026
e4fe021
Merge remote-tracking branch 'origin/master' into dev
blakeblackshear Jan 31, 2026
2d83992
Miscellaneous fixes (0.17 beta) (#21867)
NickM-27 Feb 3, 2026
59a9594
Translated using Weblate (Turkish)
weblate Feb 3, 2026
0a307ed
Translated using Weblate (Lithuanian)
weblate Feb 3, 2026
e6e2b74
Translated using Weblate (Portuguese (Brazil))
weblate Feb 3, 2026
9267d00
Translated using Weblate (German)
weblate Feb 3, 2026
9d572ba
Translated using Weblate (Danish)
weblate Feb 3, 2026
fee3050
Translated using Weblate (Greek)
weblate Feb 3, 2026
9413f1c
Translated using Weblate (Estonian)
weblate Feb 3, 2026
2f06cfe
Translated using Weblate (Russian)
weblate Feb 3, 2026
74ac45d
Translated using Weblate (Romanian)
weblate Feb 3, 2026
9285c5e
Translated using Weblate (Ukrainian)
weblate Feb 3, 2026
2cd1434
Translated using Weblate (Catalan)
weblate Feb 3, 2026
a407f08
Translated using Weblate (Czech)
weblate Feb 3, 2026
a394d37
Translated using Weblate (Portuguese)
weblate Feb 3, 2026
5984346
Added translation using Weblate (Icelandic)
weblate Feb 3, 2026
62b880a
Translated using Weblate (Croatian)
weblate Feb 3, 2026
b6e5894
Translated using Weblate (Hungarian)
weblate Feb 3, 2026
4d63a74
Translated using Weblate (Polish)
weblate Feb 3, 2026
e9db966
Translated using Weblate (Italian)
weblate Feb 3, 2026
2fe5e06
Translated using Weblate (Arabic)
weblate Feb 3, 2026
8b3c8a0
Translated using Weblate (Indonesian)
weblate Feb 3, 2026
b17e5a3
Translated using Weblate (Dutch)
weblate Feb 3, 2026
00c8c40
Translated using Weblate (Spanish)
weblate Feb 3, 2026
c34fd3b
Translated using Weblate (French)
weblate Feb 3, 2026
7339961
Translated using Weblate (Swedish)
weblate Feb 3, 2026
77eb5d6
Translated using Weblate (Finnish)
weblate Feb 3, 2026
5226304
Translated using Weblate (Serbian)
weblate Feb 3, 2026
87da12c
Translated using Weblate (Korean)
weblate Feb 3, 2026
7fcce67
Translated using Weblate (Arabic)
weblate Feb 3, 2026
7d8d2c5
Translated using Weblate (French)
weblate Feb 3, 2026
3b79b34
Update translation files
weblate Feb 3, 2026
81d5e80
Update translation files
weblate Feb 3, 2026
011e7a1
Update translation files
weblate Feb 3, 2026
06141b9
Update translation files
weblate Feb 3, 2026
21e4b36
Add languages (#21870)
hawkeye217 Feb 3, 2026
a8ab829
Update hailo installation instructions and script (#21882)
Pops0n Feb 5, 2026
c9ba851
Fix event getting stuck due to only checking current clip / snapshot …
NickM-27 Feb 5, 2026
c9055ea
fix: fix delete zone type i18n (#21894)
ZhaiSoul Feb 5, 2026
41b983a
Set log to debug (#21898)
NickM-27 Feb 5, 2026
ea1533f
Miscellaneous Fixes (0.17 beta) (#21912)
hawkeye217 Feb 7, 2026
e1c273b
Translated using Weblate (German)
weblate Feb 6, 2026
2cfb118
Translated using Weblate (Danish)
weblate Feb 6, 2026
11576e9
Translated using Weblate (Estonian)
weblate Feb 6, 2026
ecd7d04
Translated using Weblate (Romanian)
weblate Feb 6, 2026
92c5030
Translated using Weblate (Japanese)
weblate Feb 6, 2026
334acd6
Translated using Weblate (Catalan)
weblate Feb 6, 2026
9fbc854
Translated using Weblate (Polish)
weblate Feb 6, 2026
44e6953
Translated using Weblate (French)
weblate Feb 6, 2026
fc3f798
Translated using Weblate (Swedish)
weblate Feb 6, 2026
ff20be5
Translated using Weblate (Chinese (Simplified Han script))
weblate Feb 6, 2026
6accc38
Translated using Weblate (Norwegian Bokmål)
weblate Feb 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
387 changes: 385 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,385 @@
Never write strings in the frontend directly, always write to and reference the relevant translations file.
Always conform new and refactored code to the existing coding style in the project.
# GitHub Copilot Instructions for Frigate NVR

This document provides coding guidelines and best practices for contributing to Frigate NVR, a complete and local NVR designed for Home Assistant with AI object detection.

## Project Overview

Frigate NVR is a realtime object detection system for IP cameras that uses:

- **Backend**: Python 3.13+ with FastAPI, OpenCV, TensorFlow/ONNX
- **Frontend**: React with TypeScript, Vite, TailwindCSS
- **Architecture**: Multiprocessing design with ZMQ and MQTT communication
- **Focus**: Minimal resource usage with maximum performance

## Code Review Guidelines

When reviewing code, do NOT comment on:

- Missing imports - Static analysis tooling catches these
- Code formatting - Ruff (Python) and Prettier (TypeScript/React) handle formatting
- Minor style inconsistencies already enforced by linters

## Python Backend Standards

### Python Requirements

- **Compatibility**: Python 3.13+
- **Language Features**: Use modern Python features:
- Pattern matching
- Type hints (comprehensive typing preferred)
- f-strings (preferred over `%` or `.format()`)
- Dataclasses
- Async/await patterns

### Code Quality Standards

- **Formatting**: Ruff (configured in `pyproject.toml`)
- **Linting**: Ruff with rules defined in project config
- **Type Checking**: Use type hints consistently
- **Testing**: unittest framework - use `python3 -u -m unittest` to run tests
- **Language**: American English for all code, comments, and documentation

### Logging Standards

- **Logger Pattern**: Use module-level logger

```python
import logging

logger = logging.getLogger(__name__)
```

- **Format Guidelines**:
- No periods at end of log messages
- No sensitive data (keys, tokens, passwords)
- Use lazy logging: `logger.debug("Message with %s", variable)`
- **Log Levels**:
- `debug`: Development and troubleshooting information
- `info`: Important runtime events (startup, shutdown, state changes)
- `warning`: Recoverable issues that should be addressed
- `error`: Errors that affect functionality but don't crash the app
- `exception`: Use in except blocks to include traceback

### Error Handling

- **Exception Types**: Choose most specific exception available
- **Try/Catch Best Practices**:
- Only wrap code that can throw exceptions
- Keep try blocks minimal - process data after the try/except
- Avoid bare exceptions except in background tasks

Bad pattern:

```python
try:
data = await device.get_data() # Can throw
# ❌ Don't process data inside try block
processed = data.get("value", 0) * 100
result = processed
except DeviceError:
logger.error("Failed to get data")
```

Good pattern:

```python
try:
data = await device.get_data() # Can throw
except DeviceError:
logger.error("Failed to get data")
return

# ✅ Process data outside try block
processed = data.get("value", 0) * 100
result = processed
```

### Async Programming

- **External I/O**: All external I/O operations must be async
- **Best Practices**:
- Avoid sleeping in loops - use `asyncio.sleep()` not `time.sleep()`
- Avoid awaiting in loops - use `asyncio.gather()` instead
- No blocking calls in async functions
- Use `asyncio.create_task()` for background operations
- **Thread Safety**: Use proper synchronization for shared state

### Documentation Standards

- **Module Docstrings**: Concise descriptions at top of files
```python
"""Utilities for motion detection and analysis."""
```
- **Function Docstrings**: Required for public functions and methods

```python
async def process_frame(frame: ndarray, config: Config) -> Detection:
"""Process a video frame for object detection.

Args:
frame: The video frame as numpy array
config: Detection configuration

Returns:
Detection results with bounding boxes
"""
```

- **Comment Style**:
- Explain the "why" not just the "what"
- Keep lines under 88 characters when possible
- Use clear, descriptive comments

### File Organization

- **API Endpoints**: `frigate/api/` - FastAPI route handlers
- **Configuration**: `frigate/config/` - Configuration parsing and validation
- **Detectors**: `frigate/detectors/` - Object detection backends
- **Events**: `frigate/events/` - Event management and storage
- **Utilities**: `frigate/util/` - Shared utility functions

## Frontend (React/TypeScript) Standards

### Internationalization (i18n)

- **CRITICAL**: Never write user-facing strings directly in components
- **Always use react-i18next**: Import and use the `t()` function

```tsx
import { useTranslation } from "react-i18next";

function MyComponent() {
const { t } = useTranslation(["views/live"]);
return <div>{t("camera_not_found")}</div>;
}
```

- **Translation Files**: Add English strings to the appropriate json files in `web/public/locales/en`
- **Namespaces**: Organize translations by feature/view (e.g., `views/live`, `common`, `views/system`)

### Code Quality

- **Linting**: ESLint (see `web/.eslintrc.cjs`)
- **Formatting**: Prettier with Tailwind CSS plugin
- **Type Safety**: TypeScript strict mode enabled
- **Testing**: Vitest for unit tests

### Component Patterns

- **UI Components**: Use Radix UI primitives (in `web/src/components/ui/`)
- **Styling**: TailwindCSS with `cn()` utility for class merging
- **State Management**: React hooks (useState, useEffect, useCallback, useMemo)
- **Data Fetching**: Custom hooks with proper loading and error states

### ESLint Rules

Key rules enforced:

- `react-hooks/rules-of-hooks`: error
- `react-hooks/exhaustive-deps`: error
- `no-console`: error (use proper logging or remove)
- `@typescript-eslint/no-explicit-any`: warn (always use proper types instead of `any`)
- Unused variables must be prefixed with `_`
- Comma dangles required for multiline objects/arrays

### File Organization

- **Pages**: `web/src/pages/` - Route components
- **Views**: `web/src/views/` - Complex view components
- **Components**: `web/src/components/` - Reusable components
- **Hooks**: `web/src/hooks/` - Custom React hooks
- **API**: `web/src/api/` - API client functions
- **Types**: `web/src/types/` - TypeScript type definitions

## Testing Requirements

### Backend Testing

- **Framework**: Python unittest
- **Run Command**: `python3 -u -m unittest`
- **Location**: `frigate/test/`
- **Coverage**: Aim for comprehensive test coverage of core functionality
- **Pattern**: Use `TestCase` classes with descriptive test method names
```python
class TestMotionDetection(unittest.TestCase):
def test_detects_motion_above_threshold(self):
# Test implementation
```

### Test Best Practices

- Always have a way to test your work and confirm your changes
- Write tests for bug fixes to prevent regressions
- Test edge cases and error conditions
- Mock external dependencies (cameras, APIs, hardware)
- Use fixtures for test data

## Development Commands

### Python Backend

```bash
# Run all tests
python3 -u -m unittest

# Run specific test file
python3 -u -m unittest frigate.test.test_ffmpeg_presets

# Check formatting (Ruff)
ruff format --check frigate/

# Apply formatting
ruff format frigate/

# Run linter
ruff check frigate/
```

### Frontend (from web/ directory)

```bash
# Start dev server (AI agents should never run this directly unless asked)
npm run dev

# Build for production
npm run build

# Run linter
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run prettier:write
```

### Docker Development

AI agents should never run these commands directly unless instructed.

```bash
# Build local image
make local

# Build debug image
make debug
```

## Common Patterns

### API Endpoint Pattern

```python
from fastapi import APIRouter, Request
from frigate.api.defs.tags import Tags

router = APIRouter(tags=[Tags.Events])

@router.get("/events")
async def get_events(request: Request, limit: int = 100):
"""Retrieve events from the database."""
# Implementation
```

### Configuration Access

```python
# Access Frigate configuration
config: FrigateConfig = request.app.frigate_config
camera_config = config.cameras["front_door"]
```

### Database Queries

```python
from frigate.models import Event

# Use Peewee ORM for database access
events = (
Event.select()
.where(Event.camera == camera_name)
.order_by(Event.start_time.desc())
.limit(limit)
)
```

## Common Anti-Patterns to Avoid

### ❌ Avoid These

```python
# Blocking operations in async functions
data = requests.get(url) # ❌ Use async HTTP client
time.sleep(5) # ❌ Use asyncio.sleep()

# Hardcoded strings in React components
<div>Camera not found</div> # ❌ Use t("camera_not_found")

# Missing error handling
data = await api.get_data() # ❌ No exception handling

# Bare exceptions in regular code
try:
value = await sensor.read()
except Exception: # ❌ Too broad
logger.error("Failed")
```

### ✅ Use These Instead

```python
# Async operations
import aiohttp
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data = await response.json()

await asyncio.sleep(5) # ✅ Non-blocking

# Translatable strings in React
const { t } = useTranslation();
<div>{t("camera_not_found")}</div> # ✅ Translatable

# Proper error handling
try:
data = await api.get_data()
except ApiException as err:
logger.error("API error: %s", err)
raise

# Specific exceptions
try:
value = await sensor.read()
except SensorException as err: # ✅ Specific
logger.exception("Failed to read sensor")
```

## Project-Specific Conventions

### Configuration Files

- Main config: `config/config.yml`

### Directory Structure

- Backend code: `frigate/`
- Frontend code: `web/`
- Docker files: `docker/`
- Documentation: `docs/`
- Database migrations: `migrations/`

### Code Style Conformance

Always conform new and refactored code to the existing coding style in the project:

- Follow established patterns in similar files
- Match indentation and formatting of surrounding code
- Use consistent naming conventions (snake_case for Python, camelCase for TypeScript)
- Maintain the same level of verbosity in comments and docstrings

## Additional Resources

- Documentation: https://docs.frigate.video
- Main Repository: https://github.com/blakeblackshear/frigate
- Home Assistant Integration: https://github.com/blakeblackshear/frigate-hass-integration
Loading
Loading