Skip to content

Conversation

@jonathan-vella
Copy link

@jonathan-vella jonathan-vella commented Feb 4, 2026

Summary

This PR adds a comprehensive web-based interface for managing preview generation, replacing the need for manual environment variable configuration.

Features

Web UI

  • Setup Wizard - 5-step guided configuration with Plex OAuth authentication
    • Step 1: Sign in with Plex
    • Step 2: Select Server
    • Step 3: Configure Paths
    • Step 4: Processing Options
    • Step 5: Security (custom access token)
  • Dashboard - Real-time job progress with worker status and ETA
  • Job Queue - Start, cancel, and view logs for jobs
  • Scheduling - Cron expression support for automated runs
  • Settings Page - Configure libraries, path mappings, and processing options
  • Browser Notifications - Get notified when jobs complete

Authentication

  • Custom Access Token - Users can set their own token during setup (like a password)
  • Auto-generated Token - Falls back to secure random token if not customized
  • Environment Variable Override - WEB_AUTH_TOKEN still works for Docker power users

Processing Improvements

  • Headless mode for web-based job execution
  • Worker status callbacks for live progress display
  • Log capture from processing to web UI
  • Proper ETA calculation based on items/second

Documentation

  • Consolidated docs (12 → 8 files, DRY principle)
  • Added architecture diagrams (Python diagrams library)
  • Merged networking guide into docker.md
  • Merged path-mappings into configuration.md
  • Merged troubleshooting into faq.md

Technical Details

  • Flask + Flask-SocketIO for real-time updates
  • Token-based authentication with set_auth_token(), get_token_info() APIs
  • Settings persistence to /config/settings.json
  • E2E tests with Playwright
  • 295 tests passing

Screenshots

The web UI provides:

  • Worker status cards showing GPU/CPU activity
  • Progress bars with percentage and ETA
  • Logs viewer modal for debugging
  • Multi-library selection with checkboxes

Testing

Tested on Unraid with:

  • Intel UHD 770 GPU (VAAPI acceleration)
  • Multiple libraries (TV Shows, Movies)
  • Verified previews generated correctly in Plex

Files Changed

  • 62 files changed
  • +11,585 / -1,153 lines
  • New: plex_generate_previews/web/ module
  • New: docs/ consolidated documentation
  • New: unraid-templates/ for Unraid Community Apps

@jonathan-vella jonathan-vella force-pushed the main branch 2 times, most recently from f36309c to b974c48 Compare February 4, 2026 16:38
@stevezau
Copy link
Owner

stevezau commented Feb 4, 2026

@jonathan-vella wow, thank you! I will review this ASAP.

@stevezau
Copy link
Owner

stevezau commented Feb 5, 2026

Hey @jonathan-vella this is a large PR. I assume it was vibe coded? Not sure ill be able to review all of it but happy to do a quick one. + test and merge it in..

LMK when it's complete? Do you have any screenshots you can share? Also, it supports dockerfile right? (edit, nevermind i see it does)

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 42.01110% with 940 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.69%. Comparing base (497c361) to head (6bc2cf1).

Files with missing lines Patch % Lines
plex_generate_previews/web/routes.py 31.56% 425 Missing ⚠️
plex_generate_previews/web/jobs.py 39.24% 161 Missing ⚠️
plex_generate_previews/web/scheduler.py 30.93% 125 Missing ⚠️
plex_generate_previews/worker.py 1.42% 69 Missing ⚠️
plex_generate_previews/web/settings_manager.py 79.41% 42 Missing ⚠️
plex_generate_previews/web/app.py 63.15% 35 Missing ⚠️
plex_generate_previews/cli.py 2.85% 34 Missing ⚠️
plex_generate_previews/web/auth.py 70.96% 27 Missing ⚠️
plex_generate_previews/config.py 60.00% 22 Missing ⚠️

❌ Your patch check has failed because the patch coverage (42.01%) is below the target coverage (65.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (55.69%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #134       +/-   ##
===========================================
- Coverage   70.82%   55.69%   -15.14%     
===========================================
  Files          11       18        +7     
  Lines        2314     3896     +1582     
===========================================
+ Hits         1639     2170      +531     
- Misses        675     1726     +1051     
Flag Coverage Δ
unittests 55.69% <42.01%> (-15.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
plex_generate_previews/web/__init__.py 100.00% <100.00%> (ø)
plex_generate_previews/config.py 44.80% <60.00%> (-39.48%) ⬇️
plex_generate_previews/web/auth.py 70.96% <70.96%> (ø)
plex_generate_previews/cli.py 51.02% <2.85%> (-2.38%) ⬇️
plex_generate_previews/web/app.py 63.15% <63.15%> (ø)
plex_generate_previews/web/settings_manager.py 79.41% <79.41%> (ø)
plex_generate_previews/worker.py 66.92% <1.42%> (-14.33%) ⬇️
plex_generate_previews/web/scheduler.py 30.93% <30.93%> (ø)
plex_generate_previews/web/jobs.py 39.24% <39.24%> (ø)
plex_generate_previews/web/routes.py 31.56% <31.56%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathan-vella
Copy link
Author

Latest Update: Security Step Added to Setup Wizard

Added a new Step 5 (Security) to the setup wizard that allows users to:

  • View their current access token (with copy-to-clipboard functionality)
  • Set a custom access token (acts like a password, min 8 characters)
  • Skip and keep auto-generated token (default behavior)

Changes in this commit:

  • Added set_auth_token(), get_token_info(), is_token_env_controlled() to auth.py
  • Added /api/setup/token-info and /api/setup/set-token API endpoints
  • Updated setup wizard UI with Step 5
  • Updated all documentation (web-interface, quickstart, configuration, changelog)
  • Updated Unraid template description for WEB_AUTH_TOKEN

User Experience:

  1. Users who want simplicity can skip Step 5 → auto-generated token is used
  2. Users who want a memorable password can set their own token
  3. Docker users can still use WEB_AUTH_TOKEN env var (overrides wizard setting)

All 295 tests passing.

@jonathan-vella
Copy link
Author

jonathan-vella commented Feb 5, 2026

Hey @jonathan-vella this is a large PR. I assume it was vibe coded? Not sure ill be able to review all of it but happy to do a quick one. + test and merge it in.. > Hi. Yes, it's vibe coded but not only :-)

LMK when it's complete? Do you have any screenshots you can share? Also, it supports dockerfile right? (edit, nevermind i see it does)

BTW. It's complete.

dashboard settings

@jonathan-vella
Copy link
Author

Tests & Documentation Added

Added comprehensive test coverage and API documentation for the new Security step:

Unit Tests (14 new)

  • test_is_token_env_controlled_false / _true
  • test_set_auth_token_success / _too_short / _env_locked
  • test_get_token_info_structure / _config_source / _env_source
  • test_setup_token_info_endpoint / _requires_auth
  • test_setup_set_token_success / _mismatch / _too_short / _requires_auth

E2E Tests (5 new)

  • test_setup_wizard_has_5_steps - Verifies 5 progress steps
  • test_step5_has_security_label - Verifies "Security" label
  • test_step5_shows_token_display - Verifies token input exists
  • test_step5_has_custom_token_checkbox - Verifies checkbox exists
  • test_step5_has_finish_button - Verifies Complete Setup button exists

Documentation

  • Updated docs/API.md with:
    • GET /api/setup/token-info - full request/response docs
    • POST /api/setup/set-token - full request/response docs with error cases

Test Results

314 passed in 32.36s

Before: 295 tests → After: 314 tests (+19)

@stevezau
Copy link
Owner

stevezau commented Feb 8, 2026

@jonathan-vella is this ready?

Copy link
Author

@jonathan-vella jonathan-vella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: Ready for Review ✅

All planned work is complete. Two critical fixes have been implemented:

1. ETA Stuck at "1s" Bug - FIXED

Root Cause: Two compounding issues prevented accurate ETA calculation:

  • progress_callback only fired on task completion (minutes apart) — during long FFmpeg runs, stale ETA was never recalculated
  • Sliding window approach treated fast-skipped items (existing BIF files) identically to real work, permanently inflating the rate

Solution:

  • Burst detection algorithm (routes.py): Classifies items by completion time (>2s = real work, <2s = skipped), measures rate only from real work, requires ≥10s of sustained processing before showing ETA
  • Periodic progress emission (worker.py): on_poll() now calls progress_callback every 3s to keep ETA fresh even during long FFmpeg processing

Files Modified:

  • plex_generate_previews/web/routes.py - Replaced sliding window with burst detection
  • plex_generate_previews/worker.py - Added 3s polling interval for progress updates

Expected Behavior After Deploy:

  • ETA shows "Calculating..." during initial skip burst
  • Transitions to realistic times once real FFmpeg work established
  • Updates every 3 seconds instead of only on task completion

2. Additional Work Completed

Status: ✅ READY FOR MERGE

@jonathan-vella
Copy link
Author

jonathan-vella commented Feb 8, 2026

@jonathan-vella is this ready?

Yes. It is. Tested for a week on Unraid.
Some additional notes:
I'm using Docker commands, not CA tools.
the provided CA template for Unraid is nottested.
We can explore improvements later on.

@stevezau
Copy link
Owner

stevezau commented Feb 8, 2026

ok, please give me some time and ill get this reviewed as best i can, thanks!

…tation

Add a full-featured web interface for managing Plex preview generation:

Web UI & Dashboard:
- Setup wizard with 5-step guided configuration and Plex OAuth sign-in
- Real-time dashboard with job progress, worker status cards, and log viewer
- Settings page with live save to /config/settings.json
- Multi-library selection, browser notifications, connection status display
- Rate-limited auth endpoints (Flask-Limiter) and CSRF protection (Flask-WTF)

Production Server:
- gunicorn with gthread workers and simple-websocket for WebSocket support
- Dedicated wsgi.py entry point; wrapper.sh launches gunicorn

Security:
- Path traversal protection with PLEX_DATA_ROOT/MEDIA_ROOT constraints
- Secret file permissions, input sanitization, XSS prevention
- Token-based authentication with @login_required / @api_token_required

ETA Algorithm:
- Dual-track ETA calculation (burst-filtered rate + simple elapsed fallback)
- Stall detection suppresses misleading near-zero ETA when most items skip

Testing & CI:
- 530+ pytest tests covering auth, routes, settings, scheduler, workers, ETA
- GitHub Actions workflow for ruff lint, pytest, and Docker image builds
- Pre-commit hooks for ruff check + format

Documentation & Tooling:
- Consolidated docs: quickstart, configuration, GPU support, API, FAQ, web UI
- Unraid Community Applications template with networking guidance
- Windows dev bootstrap script (scripts/setup-windows-dev.ps1)
- CONTRIBUTING.md with development setup and PR guidelines
- CHANGELOG.md following Keep a Changelog format
@stevezau
Copy link
Owner

@jonathan-vella will also support "scheduling" like a cron job?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants