Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
df59ceb
Initial plan
Copilot Jan 4, 2026
ed24e94
Initial plan
Copilot Jan 4, 2026
5d25c5e
Add GitHub Copilot instructions file
Copilot Jan 4, 2026
b94cdc4
Address code review feedback: clarify versions and tooling
Copilot Jan 4, 2026
de57ce1
Add comprehensive multi-user support specification and implementation…
Copilot Jan 4, 2026
1c5159c
Clarify Python tooling transition state
Copilot Jan 4, 2026
c227eb6
Add executive summary for multi-user support specification
Copilot Jan 4, 2026
488ced1
Merge pull request #4 from lstein/copilot/set-up-copilot-instructions
lstein Jan 4, 2026
34a1c27
Reorganize multiuser docs into subfolder and update with approved des…
Copilot Jan 4, 2026
ff3dadc
docs: fix mkdocs syntax issues
lstein Jan 4, 2026
8bd70c0
Merge pull request #2 from lstein/copilot/add-multiuser-support
lstein Jan 4, 2026
9ca69d8
Merge pull request #9 from invoke-ai/main
lstein Jan 5, 2026
4201d4c
Fix Z-Image VAE operations not reserving working memory for OOM preve…
Copilot Jan 5, 2026
df68fb2
Merge remote-tracking branch 'upstream/main' into lstein-master
lstein Jan 7, 2026
45d76d5
Phase 1: Add multi-user database schema and authentication foundation…
Copilot Jan 7, 2026
48232a2
Implement Phase 2: Authentication Service with JWT and FastAPI Integr…
Copilot Jan 8, 2026
8d0cd1e
Add Phase 3 integration tests and documentation for authentication mi…
Copilot Jan 8, 2026
9e11f54
chore: fix merge conflicts
lstein Jan 8, 2026
4d45fc1
chore: fix unresolved merged conflict markers
lstein Jan 8, 2026
0f970a0
Phase 4: Add multi-tenancy to boards and session queue services (#17)
Copilot Jan 10, 2026
e654342
Merge branch 'invoke-ai:main' into lstein-master
lstein Jan 10, 2026
fa1deae
feat: Implement Phase 5 of multiuser plan - Frontend authentication (…
Copilot Jan 12, 2026
7418e3e
feat: Implement Phase 6 frontend UI updates - UserMenu and admin rest…
Copilot Jan 12, 2026
e115060
feat: Add user management script for testing multiuser features
Copilot Jan 12, 2026
54adf97
feat: Implement read-only model manager access for non-admin users
Copilot Jan 12, 2026
e515096
Merge branch 'invoke-ai:main' into lstein-master
lstein Jan 12, 2026
80c2bb7
Phase 7: Comprehensive testing and security validation for multiuser …
Copilot Jan 13, 2026
495cdac
Merge branch 'invoke-ai:main' into lstein-master
lstein Jan 13, 2026
c9f01ad
Merge branch 'invoke-ai:main' into lstein-master
lstein Jan 17, 2026
d83fb9f
Backend: Add admin board filtering and uncategorized board isolation
Copilot Jan 13, 2026
cdd593f
Fix intermittent token service test failures caused by Base64 padding…
Copilot Jan 18, 2026
6ae8a74
Implement user isolation for session queue and socket events (WIP - d…
Copilot Jan 18, 2026
05c293e
Fix Queue tab not updating for other users in real-time (#34)
Copilot Jan 19, 2026
174a6c3
Fix multiuser information leakage in Queue panel detail view (#38)
Copilot Jan 20, 2026
a8b6cf7
fix(queue): Enforce user permissions for queue operations in multiuse…
Copilot Jan 20, 2026
e493a9a
Merge branch 'invoke-ai:main' into lstein-master
lstein Jan 21, 2026
4200421
fix(multiuser): Isolate client state per user to prevent data leakage…
Copilot Jan 21, 2026
ab5fa5d
feat(queue): show user/total pending jobs in multiuser mode badge (#43)
Copilot Jan 21, 2026
7955631
Convert session queue isolation logs from info to debug level
Copilot Jan 21, 2026
1068277
Add JWT secret storage in database and app_settings service
Copilot Jan 21, 2026
c9233c2
Add multiuser configuration option with default false
Copilot Jan 21, 2026
5660f43
Update token service tests to initialize JWT secret
Copilot Jan 21, 2026
ee65751
Fix app_settings_service to use proper database transaction pattern
Copilot Jan 21, 2026
79a6d80
chore(backend): typegen and ruff
lstein Jan 21, 2026
fedf076
chore(docs): update docstrings
lstein Jan 21, 2026
d9e51a1
Fix frontend to bypass authentication in single-user mode
Copilot Jan 21, 2026
7ff2093
Fix auth tests to enable multiuser mode
Copilot Jan 21, 2026
e5a8724
Fix model manager UI visibility in single-user mode
Copilot Jan 21, 2026
013c495
chore(backend): ruff
lstein Jan 21, 2026
0234ac8
chore(frontend): typegen
lstein Jan 21, 2026
930d23d
Fix TypeScript lint errors
Copilot Jan 21, 2026
d0798a4
Fix test_data_isolation to enable multiuser mode
Copilot Jan 21, 2026
65a1093
Redirect login and setup pages to app in single-user mode
Copilot Jan 21, 2026
e4b043b
Fix test_auth.py to initialize JWT secret
Copilot Jan 21, 2026
08b5e8d
Prevent login form flash in single-user mode
Copilot Jan 21, 2026
e3d17b7
Fix board and queue operations in single-user mode
Copilot Jan 21, 2026
32771df
Add user management utilities and rename add_user.py
Copilot Jan 21, 2026
9ba6a1b
Fix ESLint errors in frontend code
Copilot Jan 22, 2026
9dc956e
Add userlist.py script for viewing database users
Copilot Jan 22, 2026
23e3486
Fix test_boards_multiuser.py test failures
Copilot Jan 22, 2026
1098fae
chore(backend): ruff
lstein Jan 22, 2026
e8a54a2
Fix userlist.py SqliteDatabase initialization
Copilot Jan 22, 2026
8f6f64a
Fix test_boards_multiuser.py by adding app_settings service to mock
Copilot Jan 22, 2026
2490eb6
bugfix(scripts): fix crash in userlist.py script
lstein Jan 22, 2026
4a5e91d
Fix test_boards_multiuser.py JWT secret initialization
Copilot Jan 22, 2026
5a9da1b
Fix CurrentUserOrDefault to require auth in multiuser mode
Copilot Jan 22, 2026
2786b7d
chore(front & backend): ruff and lint
lstein Jan 22, 2026
a413580
Add AdminUserOrDefault and fix model settings in single-user mode
Copilot Jan 22, 2026
d3d0c9a
Fix model manager operations in single-user mode
Copilot Jan 22, 2026
eae1eba
Fix syntax error in model_manager.py
Copilot Jan 22, 2026
2acb320
Fix FastAPI dependency injection syntax error
Copilot Jan 22, 2026
2ae67e1
Fix delete_model endpoint parameter annotation
Copilot Jan 22, 2026
ea7a12a
Fix parameter annotations for all AdminUserOrDefault endpoints
Copilot Jan 22, 2026
df5482a
Revert to correct AdminUserOrDefault usage pattern
Copilot Jan 22, 2026
1a3218b
Fix parameter order for AdminUserOrDefault in model manager
Copilot Jan 22, 2026
0393a59
chore(frontend): typegen
lstein Jan 22, 2026
4a0e4f4
chore(frontend): typegen again
lstein Jan 22, 2026
3ebc6bb
Docs(app): Comprehensive Documentation of Multiuser Features (#50)
lstein Jan 23, 2026
a359b62
docs(app): update multiuser documentation
lstein Jan 23, 2026
98bab15
chore: resolve conflicts with remote merge
lstein Jan 28, 2026
1ff8b07
bugfix(app): fix misaligned database migration calls
lstein Jan 28, 2026
5363e4a
Merge branch 'main' into lstein-master
lstein Jan 28, 2026
62edbf2
chore(tests): update migration test to accommodate resequencing of mi…
lstein Jan 28, 2026
0c00a14
Merge branch 'invoke-ai:main' into feature/multiuser
lstein Feb 1, 2026
46e4f45
Merge branch 'main' into feature/multiuser
JPPhoto Feb 1, 2026
3d483f6
Merge branch 'main' into feature/multiuser
JPPhoto Feb 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 324 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
# InvokeAI Copilot Instructions

## Project Overview

InvokeAI is a leading creative engine built to empower professionals and enthusiasts alike. It's a full-featured AI-assisted image generation environment designed for creatives and enthusiasts, with an industry-leading web-based UI. The project serves as the foundation for multiple commercial products and is free to use under a commercially-friendly license.

**Key Technologies:**
- Backend: Python 3.11-3.12, FastAPI, Socket.IO, PyTorch
- Frontend: React, TypeScript, Vite, Redux
- AI/ML: Stable Diffusion (SD1.5, SD2.0, SDXL, FLUX), Diffusers, Transformers
- Database: SQLite
- Package Management: uv (backend), pnpm (frontend)

## Repository Structure

```
invokeai/
├── app/ # Main application code
│ ├── api/ # FastAPI routes and API endpoints
│ ├── invocations/ # Node-based invocation system
│ └── services/ # Core services (model management, image storage, etc.)
├── backend/ # AI/ML core functionality
│ ├── image_util/ # Image processing utilities
│ ├── model_management/ # Model loading and management
│ └── stable_diffusion/ # SD pipeline implementations
├── frontend/web/ # React web UI
│ └── src/
│ ├── app/ # App setup and configuration
│ ├── common/ # Shared utilities and types
│ ├── features/ # Feature-specific components and logic
│ └── services/ # API clients and services
├── configs/ # Configuration files
└── tests/ # Test suite
```

## Development Environment Setup

### Prerequisites
- Python 3.11 or 3.12 (as specified in pyproject.toml: `>=3.11, <3.13`)
- Node.js v22.14.0 or compatible v22.x LTS version (see .nvmrc)
- pnpm v10.x (minimum v10 required, see package.json)
- Git LFS
- uv (Python package manager)

### Initial Setup

1. **Clone and configure Git LFS:**
```bash
git clone https://github.com/invoke-ai/InvokeAI.git
cd InvokeAI
git config lfs.fetchinclude "*"
git lfs pull
```

2. **Backend Setup:**
```bash
# Install Python dependencies with dev extras (adjust --python version as needed: 3.11 or 3.12)
uv pip install -e ".[dev,test,docs,xformers]" --python 3.12 --python-preference only-managed --index=https://download.pytorch.org/whl/cu128 --reinstall
```

3. **Frontend Setup:**
```bash
cd invokeai/frontend/web
pnpm install
pnpm build # For production build
# OR
pnpm dev # For development mode (hot reload on localhost:5173)
```

4. **Database:** Use an ephemeral in-memory database for development by setting `use_memory_db: true` and `scan_models_on_startup: true` in your `invokeai.yaml` file.

### Common Development Commands

**Backend:**
```bash
make ruff # Run ruff linter and formatter
make ruff-unsafe # Run ruff with unsafe fixes
make mypy # Run type checker
make test # Run unit tests
pytest tests/ # Run fast tests only
pytest tests/ -m slow # Run slow tests
```

**Frontend:**
```bash
cd invokeai/frontend/web
pnpm lint # Run all linters
pnpm lint:eslint # Check ESLint issues
pnpm lint:prettier # Check formatting
pnpm lint:tsc # Check TypeScript issues
pnpm fix # Auto-fix issues
pnpm test:no-watch # Run tests
```

**Documentation:**
```bash
make docs # Serve mkdocs with live reload
mkdocs serve # Alternative command
```

## Code Style and Conventions

### Python (Backend)

**Style Guidelines:**
- Use **uv tool run ruff@0.11.2 check** for linting and formatting (replaces Black, isort, flake8)
- Line length: 120 characters
- Type hints are required (mypy strict mode with Pydantic plugin)
- Use absolute imports (no relative imports allowed)
- Follow PEP 8 conventions

**Key Conventions:**
- All invocations must inherit from `BaseInvocation`
- Use the `@invocation` decorator for invocation classes
- Invocation class names should end with "Invocation" (e.g., `ResizeImageInvocation`)
- Use `InputField()` for invocation inputs and `OutputField()` for outputs
- All invocations must have a docstring
- Services should provide an abstract base class interface

**Import Style:**
```python
# Use absolute imports from invokeai
from invokeai.invocation_api import BaseInvocation, invocation, InputField
from invokeai.app.services.image_records.image_records_common import ImageCategory
```

**Example Invocation:**
```python
from invokeai.invocation_api import (
BaseInvocation,
invocation,
InputField,
OutputField,
)

@invocation('my_invocation', title='My Invocation', tags=['image'], category='image')
class MyInvocation(BaseInvocation):
"""Does something with an image."""

image: ImageField = InputField(description="The input image")
width: int = InputField(default=512, description="Output width")

def invoke(self, context: InvocationContext) -> ImageOutput:
# Implementation
pass
```

### TypeScript/JavaScript (Frontend)

**Style Guidelines:**
- Use **ESLint** and **Prettier** for linting and formatting
- Prefer TypeScript over JavaScript
- Use functional components with hooks
- Use Redux Toolkit for state management
- Colocate tests with source files using `.test.ts` suffix
- If pydantic schema has changed run `cd invokeai/frontend/web && python ../../../scripts/generate_openapi_schema.py | pnpm typegen`

**Key Conventions:**
- Tests should use Vitest
- No tests needed for trivial code (type definitions, re-exports)
- UI tests are not currently implemented
- Keep components focused and composable

**Import Organization:**
```typescript
// External imports first
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';

// Internal app imports
import { setActiveTab } from 'features/ui/store/uiSlice';
import type { AppDispatch } from 'app/store/store';
```

## Architecture

### Backend Architecture

**Invocation System:**
- **Invocations**: Modular nodes that represent single operations with inputs and outputs
- **Sessions**: Maintain graphs of linked invocations and execution history
- **Invoker**: Manages sessions and the invocation queue
- **Services**: Provide functionality to invocations (model management, image storage, etc.)

**Key Principles:**
- Invocations form directed acyclic graphs (no loops)
- All invocations are auto-discovered from `invokeai/app/invocations/`
- Services use abstract base classes for flexibility
- Applications interact through the invoker, not directly with core code

### Frontend Architecture

**State Management:**
- Redux Toolkit for global state
- Feature-based organization
- Slices for different app areas (ui, gallery, generation, etc.)

**API Communication:**
- REST API via FastAPI
- Real-time updates via Socket.IO
- OpenAPI-generated TypeScript types

## Testing Practices

### Backend Testing

**Test Organization:**
- All tests in `tests/` directory, mirroring `invokeai/` structure
- Use pytest with markers: `@pytest.mark.slow` for tests >1s
- Default: fast tests only (`-m "not slow"`)
- Coverage target: 85%

**Test Commands:**
```bash
pytest tests/ # Fast tests
pytest tests/ -m slow # Slow tests
pytest tests/ -m "" # All tests
pytest tests/ --cov # With coverage report
```

**Model Testing:**
- Auto-download models if not present
- Avoid re-downloading existing models
- Reuse models across tests when possible
- Use fixtures: `model_installer`, `torch_device`

### Frontend Testing

**Test Guidelines:**
- Use Vitest for unit tests
- Colocate tests with source files (`.test.ts`)
- No UI/integration tests currently
- Skip tests for trivial code

## Common Tasks

### Adding a New Invocation

1. Create a new file in `invokeai/app/invocations/`
2. Define class inheriting from `BaseInvocation`
3. Add `@invocation` decorator with unique ID
4. Define inputs with `InputField()`
5. Implement `invoke()` method
6. Return appropriate output type
7. Add to `__init__.py` in the invocations directory

### Adding a New Service

1. Create abstract base class interface in `invokeai/app/services/`
2. Implement default local implementation
3. Register service in invoker setup
4. Avoid loading heavy dependencies unless implementation is used

### Frontend Development

1. Make changes in `invokeai/frontend/web/src/`
2. Run linters: `pnpm lint`
3. Fix issues: `pnpm fix`
4. Test in dev mode: `pnpm dev` (localhost:5173)
5. Build for production: `pnpm build`

### Updating OpenAPI Types

When backend API changes:
```bash
cd invokeai/frontend/web
python ../../../scripts/generate_openapi_schema.py | pnpm typegen
```

## Build and Deployment

**Backend Build:**
```bash
# Build wheel
cd scripts && ./build_wheel.sh
```

**Frontend Build:**
```bash
make frontend-build
# OR
cd invokeai/frontend/web && pnpm build
```

**Running the Application:**
```bash
invokeai-web # Starts server on localhost:9090
```

## Contributing Guidelines

1. **Before starting:** Check in with maintainers to ensure alignment with project vision
2. **Development:**
- Fork and clone the repository
- Create a feature branch
- Make changes following style guidelines
- Add/update tests as needed
- Run linters and tests
3. **Pull Requests:**
- Use the PR template
- Provide clear summary and QA instructions
- Link related issues (use "Closes #123" to auto-close)
- Check all items in the PR checklist
- Update documentation if needed
- Update migration if redux slice changes
4. **Code Review:** Be responsive to feedback and ready to iterate

## Important Notes

- **Database Migrations:** Redux slice changes require corresponding migrations
- **Python Linting/Formatting:** The project uses **Ruff** for new code (via `make ruff`), which replaces black, flake8, and isort. However, pre-commit hooks still reference the older tools - this is a known transition state.
- **Model Management:** Models are auto-registered on startup if configured
- **External Code:** Some directories contain external code (mediapipe_face, mlsd, normal_bae, etc.) and are excluded from linting
- **Platform Support:** Cross-platform (Linux, macOS, Windows) with GPU support (CUDA, ROCm)
- **Localization:** UI supports 20+ languages via Weblate

## Resources

- [Documentation](https://invoke-ai.github.io/InvokeAI/)
- [Discord Community](https://discord.gg/ZmtBAhwWhy)
- [GitHub Issues](https://github.com/invoke-ai/InvokeAI/issues)
- [Contributing Guide](https://invoke-ai.github.io/InvokeAI/contributing/)
- [Architecture Overview](docs/contributing/ARCHITECTURE.md)
- [Invocations Guide](docs/contributing/INVOCATIONS.md)
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ help:
@echo "frontend-build Build the frontend in order to run on localhost:9090"
@echo "frontend-dev Run the frontend in developer mode on localhost:5173"
@echo "frontend-typegen Generate types for the frontend from the OpenAPI schema"
@echo "wheel Build the wheel for the current version"
@echo "frontend-prettier Format the frontend using lint:prettier"
@echo "wheel Build the wheel for the current version"
@echo "tag-release Tag the GitHub repository with the current version (use at release time only!)"
@echo "openapi Generate the OpenAPI schema for the app, outputting to stdout"
@echo "docs Serve the mkdocs site with live reload"

# Runs ruff, fixing any safely-fixable errors and formatting
ruff:
ruff check . --fix
ruff format .
cd invokeai && uv tool run ruff@0.11.2 format

# Runs ruff, fixing all errors it can fix and formatting
ruff-unsafe:
ruff check . --fix --unsafe-fixes
ruff format .
ruff format

# Runs mypy, using the config in pyproject.toml
mypy:
Expand Down Expand Up @@ -64,6 +64,13 @@ frontend-dev:
frontend-typegen:
cd invokeai/frontend/web && python ../../../scripts/generate_openapi_schema.py | pnpm typegen

frontend-lint:
cd invokeai/frontend/web/src && \
pnpm lint:tsc && \
pnpm lint:dpdm && \
pnpm lint:eslint --fix && \
pnpm lint:prettier --write

# Tag the release
wheel:
cd scripts && ./build_wheel.sh
Expand All @@ -79,4 +86,4 @@ openapi:
# Serve the mkdocs site w/ live reload
.PHONY: docs
docs:
mkdocs serve
mkdocs serve
Loading