feat: add auto-update system with release checking, notification UI, and install-type-aware apply

- Abstract ReleaseProvider interface (Gitea impl, swappable for GitHub/GitLab)
- Background UpdateService with periodic checks, debounce, dismissed version persistence
- Install type detection (installer/portable/docker/dev) with platform-aware asset matching
- Download with progress events, silent NSIS reinstall, portable ZIP/tarball swap scripts
- Version badge pulse animation, dismissible banner with icon buttons, Settings > Updates tab
- Single source of truth: pyproject.toml version via importlib.metadata, CI stamps tag with sed
- API: GET/POST status, check, dismiss, apply, GET/PUT settings
- i18n: en, ru, zh (27+ keys each)
This commit is contained in:
2026-03-25 13:16:18 +03:00
parent d2b3fdf786
commit 382a42755d
30 changed files with 1750 additions and 44 deletions

62
TODO.md
View File

@@ -1,42 +1,26 @@
# SQLite Migration
# Auto-Update Phase 1: Check & Notify
## Phase 1: Infrastructure
- [x] Create `storage/database.py` — SQLite connection wrapper (WAL mode, thread-safe)
- [x] Create `storage/base_sqlite_store.py` — same public API as BaseJsonStore, backed by SQLite
- [x] Create `storage/migration.py` — auto-migrate JSON files to SQLite on first run
- [x] Add `database_file` to `StorageConfig` in config.py
- [x] Update demo mode path rewriting for database_file
## Backend
- [ ] Add `packaging` to pyproject.toml dependencies
- [ ] Create `core/update/__init__.py`
- [ ] Create `core/update/release_provider.py` — ABC + data models
- [ ] Create `core/update/gitea_provider.py` — Gitea REST API implementation
- [ ] Create `core/update/version_check.py` — semver normalization + comparison
- [ ] Create `core/update/update_service.py` — background service + state machine
- [ ] Create `api/schemas/update.py` — Pydantic request/response models
- [ ] Create `api/routes/update.py` — REST endpoints
- [ ] Wire into `api/__init__.py`, `dependencies.py`, `main.py`
## Phase 2: Convert stores (one-by-one)
- [x] SyncClockStore
- [x] GradientStore
- [x] WeatherSourceStore
- [x] AutomationStore
- [x] ScenePresetStore
- [x] TemplateStore
- [x] PostprocessingTemplateStore
- [x] PatternTemplateStore
- [x] AudioTemplateStore
- [x] ColorStripProcessingTemplateStore
- [x] PictureSourceStore
- [x] AudioSourceStore
- [x] ValueSourceStore
- [x] DeviceStore
- [x] OutputTargetStore
- [x] ColorStripStore
## Frontend
- [ ] Add update banner HTML to `index.html`
- [ ] Add Updates tab to `settings.html`
- [ ] Add `has-update` CSS styles for version badge in `layout.css`
- [ ] Add update banner CSS styles in `components.css`
- [ ] Create `features/update.ts` — update check/settings/banner logic
- [ ] Wire exports in `app.ts`
- [ ] Add i18n keys to `en.json`, `ru.json`, `zh.json`
## Phase 3: Update backup/restore
- [x] Refactor backup.py to read from SQLite (export/import/backup/restore)
- [x] Keep JSON backup format identical for compatibility
- [x] Update AutoBackupEngine to read from SQLite
- [x] Add Database to dependency injection
## Phase 4: Cleanup
- [ ] Remove individual `*_file` fields from StorageConfig (keep `database_file` only)
- [ ] Remove `atomic_write_json` usage from stores (still used by auto_backup settings)
- [ ] Remove `freeze_saves` from base_store (only `freeze_writes` needed)
- [ ] Remove BaseJsonStore (keep EntityNotFoundError — move to shared location)
- [ ] Update _save_all_stores to use _save_all() instead of _save(force=True)
- [ ] Update CLAUDE.md and server/CLAUDE.md documentation
- [ ] Remove `_json_key`/`_legacy_json_keys` references from old code
- [ ] Clean up test files to use Database fixture instead of file paths
## Verification
- [ ] Lint check: `ruff check src/ tests/ --fix`
- [ ] TypeScript check: `npx tsc --noEmit && npm run build`
- [ ] Tests pass: `py -3.13 -m pytest tests/ --no-cov -q`