feat: Add lightweight web UI for monitoring, activity history & runtime control#337
feat: Add lightweight web UI for monitoring, activity history & runtime control#337lolimmlost wants to merge 16 commits intoManiMatter:latestfrom
Conversation
Added note about Decluttar V2 release and breaking changes.
AttributeError: 'Response' object has no attribute 'get'
…ntime control
Adds a FastAPI-based web interface that runs alongside the existing job loop
as a sibling asyncio task. Zero new required config — defaults to enabled on
port 9999 and can be disabled via `web.enabled: false` or `WEB_ENABLED=false`.
Key features:
- Dashboard with real-time queue view, instance cards, and live activity feed
- Activity log with search, filtering (by job/arr/action/date), and pagination
- Runtime settings editor (toggle test_run, enable/disable jobs, adjust strikes)
- Download protection via UI (supplements qBit "Keep" tag)
- "Run Now" button to manually trigger a cycle
- SSE-powered live updates — no polling needed for real-time state
- Full REST API with auto-generated OpenAPI docs at /api/docs
Architecture:
- EventBus decouples job system from web layer (no-op when web disabled)
- SQLite via aiosqlite for activity history and config overrides
- Jinja2 + HTMX + Alpine.js frontend — no build step, no Node tooling
- Pico CSS for dark-theme styling
New files: src/web/ (events, database, app, routes, config_manager, templates)
Modified: main.py, job_manager, removal_job, removal_handler, strikes_handler,
settings (_general, _user_config, _instances), Dockerfile, requirements
All 192 existing tests pass unchanged.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ponent Inline Jinja2 tojson in @click attributes was getting double-escaped, causing raw JS to render as button text. Moved to a queueRow() Alpine component function instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Can we get this reviewed and merged please? |
I appreciate your enthusiasm but definitively needs testing as I'm getting webui errors after a weeklong usage. I'll review the code once again this weekend. |
|
Amazing, thanks 🙏 |
|
I'm attempting this fix for the crashing. |
Wrap per-instance job runs and download client jobs in try/except so a Sonarr/Radarr timeout logs an error and continues instead of crashing. Add main_with_restart() wrapper so even unexpected failures auto-recover after 30s while the web server stays up independently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pushed a fix for a crash that was happening after ~1 week of uptime. Root cause: When Sonarr/Radarr timed out (read timeout=15s), the unhandled exception propagated up through Fix (commit 25f3e2f):
Verified running 24hrs+ on production with multiple Sonarr/Radarr timeouts — all recovered cleanly on the next cycle, no crashes. |
When qBittorrent times out during startup, retry up to 5 times (30s apart) instead of immediately calling sys.exit() which kills the web UI too. Only exit after all retries are exhausted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…og cleanup - Add Cache-Control headers to API responses (status, queue, config) to reduce unnecessary browser re-requests - Replace hard-coded ALLOWED_GENERAL_KEYS and ALLOWED_JOB_ATTRS with dynamic derivation from General and JobParams classes so they stay in sync automatically when settings change - Add automatic activity log cleanup (entries older than 90 days) on startup and daily to prevent disk space exhaustion - Refactor queue fetching into reusable _fetch_queue helper Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I have tested the new fixes with 100% uptime after 48 hours. Ill be working on ui improvements; log pruning and api cache control. |
…able wait_and_exit() called time.sleep() (blocking the async event loop) then sys.exit() which raised SystemExit — a BaseException that main_with_restart() didn't catch. This killed the entire process including the web UI. Now main_with_restart() catches non-zero SystemExit and restarts gracefully, and wait_and_exit() no longer blocks the event loop with time.sleep(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Partials now return "Waiting for first cycle to complete…" instantly during startup instead of calling arr APIs that may hang. SSE cycle_end already triggers auto-refresh so no manual page reload is needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Protected rows now have a green left border and subtle green background. Protected badge and Unprotect button use green (#2e7d32) instead of blue for clear visual feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The inline <script> in the queue_table partial wasn't executing after HTMX swaps, so Alpine couldn't find protect()/unprotect(). Moving the function to the persistent dashboard script block fixes this. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Alpine x-data="queueRow({{ item | tojson }})" broke because tojson
double quotes conflicted with the HTML attribute quotes, and HTMX
swaps don't reinitialize Alpine components. Switched to plain
onclick handlers that work reliably with HTMX partial swaps.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a setting is saved, its label flashes green briefly (1.5s ease-out). On error, it flashes red instead. Replaces the generic top-of-page "Saved" text with per-field visual feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The label background-color alone left visible gaps on the left/right since labels tightly wrap their content. Added a box-shadow ring in the same color to fill the surrounding area for a cleaner flash effect. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
hi, I am truly sorry I haven't looked into your PR in such a long time. I do appreciate very much that you took the time to contribute. Unfortunately, I don't have the time to look into it still. Would you be willing to act as a formal contributor? If yes, I will add you, and if I find others (from open PRs), hopefully you can review each others PR and they can be merged. Thanks for letting me know, and apologies again for my radio silence. |
Summary
Decluttarr currently has zero visibility into what it's doing — all config is YAML, all output is logs. This PR adds a lightweight web UI for monitoring, activity history, and runtime control without changing the existing daemon behavior.
test_run, enable/disable jobs, adjustmax_strikes/min_speedat runtime without editing YAML or restarting/api/docsTech Choices
Architecture
The web server runs as a sibling asyncio task alongside the existing main loop — both share the same event loop and process memory. An
EventBusclass decouples the job system from the UI: jobs emit events at decision points, the web layer (ActivityRecorder + SSE) consumes them. When web is disabled, aNoOpEventBusis used with zero overhead.Database Schema (SQLite)
Three tables:
activity_log(action history),protected_downloads(UI-managed protection),config_overrides(runtime config layered on top of YAML). Auto-created at./data/decluttarr.db.API Endpoints
/api/status/api/queue/api/activity/api/strikes/api/protected/{id}/api/config/api/config/test-run/api/config/reload/api/events/api/triggerConfiguration
Zero new required config. Defaults to enabled on port 9999.
Migration / Backward Compatibility
New Dependencies
Files Changed
New (15 files in
src/web/): events.py, database.py, app.py, routes.py, config_manager.py, templates (base, dashboard, activity, settings, 4 partials), static/style.cssModified (11 files): main.py, job_manager.py, removal_job.py, removal_handler.py, strikes_handler.py, _general.py, _user_config.py, _instances.py, Dockerfile, requirements.txt, config_example.yaml
Screenshots
The UI uses Pico CSS dark theme with color-coded badges for arr instances (Sonarr=blue, Radarr=yellow, etc.), action types (removed=red, recovered=green, flagged=amber), and strike counts.
Test Plan
pytest tests/— all 192 existing tests passhttp://localhost:9999test_runtoggle via settings page takes immediate effectEXPOSE 9999WEB_ENABLED=falsethat web is fully disabled🤖 Generated with Claude Code