# Phase 2: interface and bounded status reads Implementation and verification date: 23 October 2026. **Historical baseline:** this report describes the first Phase 2 ZIP, which the user installed and confirmed worked for both series and single episodes. The subsequent [Phase 2 refinements](phase-2-refinements.md) add the dashboard, worker attribution, season naming, quick-add, and token caching. Use the newer deployment instructions for that update; it requires restarting workers as well as the web process. The user authorized this phase after confirming that the Phase 1 resolution fix paused downloads, retained the affected episode, waited for confirmation, retried successfully, and completed the queue. That execution baseline remains intact. ## What changes ### Navigation and shared status A responsive top bar links New download, Queue, and Workers, with active-page indication, a pending-count badge, and a queue readiness/verification indicator. The interface uses local CSS and JavaScript without the previous Bootstrap CDN dependency. It includes keyboard focus styling, a skip link, labeled controls, and layouts that adapt to narrow screens. The existing verification banner is available on every page. It retains the cautious resolution/authentication messages and the existing **Resume after verification** action. A status refresh failure keeps a known pause visible and marks the status unavailable. Non-queue pages poll the lightweight summary endpoint. The queue page updates the shared status from its own result, avoiding a second history request. Polling is bounded, avoids overlapping reads, and pauses when the document is hidden. ### Download submission Series and Single episode use native radio controls. Fields for the inactive mode are disabled, so hidden fields cannot interfere with browser validation or submission. A no-JavaScript mode switch is available through ordinary links. The form previews the actual legacy filename convention, episode count, and configured destination. Series padding follows the width of the last requested episode. Single-episode language comes from its URL. Client-side range/name checks provide immediate feedback; server validation remains authoritative. The token starts as a password field and has an optional show/hide button. It is not written to local/session storage or query parameters. Validation errors retain safe non-secret fields and require the token again. Successfully queued batches redirect to the queued tab with an episode-count notice. ### Queue and history The four state cards select Queued, Active, Completed, or Failed attempts. The selected state has literal case-insensitive filename search, 10/25/50 items per page, stable ordering, and previous/next navigation. Filter state is represented in the URL and works with browser back/forward navigation. Automatic refresh preserves unsent search input, existing row nodes, expanded logs, and log scroll positions. Manual refresh and an auto-refresh toggle support close inspection. File sizes use readable binary units; no guessed percentage or transfer rate is shown. Failed attempts are labeled as attempts: the verification flow can keep an episode queued and later complete it while its earlier failure remains in history. History/queue clearing controls are grouped below the list and confirm their complete scope. They affect all records in the named state, including records outside the selected filter or page. History clearing leaves media files on disk. Active downloads remain protected from blanket flag clearing. ### Workers The worker page provides named worker creation, a selectable worker list, CPU/memory/uptime details, and the existing start/stop/restart/delete operations. Controls show action results and prevent concurrent commands. Stop, restart, and delete ask for confirmation because they can interrupt work. Keyed row updates preserve worker selection and focus during polling. The log viewer supports following output, holding the scroll position while inspecting older lines, clearing only the visible log, and reconnecting. Logs are rendered as text, bounded to 64 KiB of UTF-8 content. Switching workers closes the previous subscription and rejects delayed events from an obsolete socket. These controls use the established server restriction to this checkout's managed workers. This phase does not introduce worker limits, bandwidth caps, new persisted settings, or automatic recovery. ## Status API `GET /status-data` and the server-rendered `/status` accept: | Parameter | Accepted values | Default | |---|---|---| | `state` | `queued`, `processing`, `done`, `failed` | `queued` | | `q` | Literal filename text, at most 100 characters, no control characters | Empty | | `page` | Positive whole number, at most 100000 | `1` | | `pageSize` | `10`, `25`, `50` | `25` | Arrays/objects and malformed values are rejected with a safe HTTP 400 response before querying the database. Search text is escaped before use in the MongoDB regex and searches only filenames. The JSON response shape is: ```json { "items": [], "counts": { "queued": 0, "processing": 0, "done": 0, "failed": 0 }, "pagination": { "page": 1, "pageSize": 25, "total": 0, "totalPages": 1 }, "filters": { "state": "queued", "q": "" }, "global": { "captcha_blocked": false, "pause_reason": null } } ``` `items` contains only the selected page of public jobs. `counts` covers all records in each state; `pagination.total` reflects the selected state's filename filter. An out-of-range page is clamped after counting. Empty results have page 1 of 1. `GET /status-summary` returns only `counts` and `global`. It does not load job records, output logs, cookies, or filesystem metadata. Both JSON endpoints use `Cache-Control: no-store`. Only the selected processing/completed page receives file-size checks. Records retain the Phase 1 public projection and exact-value credential redaction. The pause reason remains restricted to `authentication`, `resolution`, or null. This replaces the previous four-array `/status-data` shape. The bundled frontend is updated together; any external client using `queued`, `processing`, `done`, and `failed` arrays must adapt to the paginated contract. Each MongoDB read is bounded to five seconds. Sorting uses the existing state timestamp with `_id` as a deterministic tie-breaker. Bounded page retrieval reduces response size and file reads; exact counts, case-insensitive substring search, and high-offset `skip` can still become expensive on very large legacy collections. Index/cursor planning remains part of Phase 4. No migration or background index build is performed. ## Automated verification `npm test` passed **183 tests: 139 Node and 44 Python**, with no failures, skips, or cancellations. The entire protected tree matched the original baseline before and after the run. | Suite | Passed | |---|---:| | Python downloader | 44 | | Node-to-Python integration | 5 | | Protected-library guard | 10 | | Runtime services | 25 | | HTTP and WebSocket services | 19 | | Submission, public status, and safe templates | 19 | | Worker execution lifecycle | 36 | | Status query/pagination and form model | 16 | | Worker interface behavior | 9 | | **Total** | **183** | New query tests cover literal-search escaping, malformed query shapes, stable sorts, skip/limit bounds, page clamping, selected-page-only reads, summary isolation, token redaction, symlink refusal, and form retention without credentials. New worker UI tests cover safe DOM text, bounded Unicode logs, selection/socket races, command serialization, cancellation, named creation, errors, and page cleanup. Local test runtimes are Node.js 24.19.0 and Python 3.12.14. Database, PM2, and stream dependencies in tests are synthetic interfaces. No test contacts production MongoDB or downloads authenticated media. ## Browser and visual verification A separate Playwright run in Chrome 151.0.7922.34 passed **27 browser checks with no failures**. It served the real application factory, queue controller, EJS templates, and browser scripts with synthetic database records and local worker/log simulators. The checks exercised real form POSTs for both modes, native keyboard mode selection, filename padding and language derivation, client range validation, server validation with credential removal, literal filename search, bounded page reads, pagination/browser Back, and refresh preservation of open logs, focus, scroll position, and unsent search input. They also exercised the resolution banner and resume action while retaining the affected queued record, safe HTML rendering, worker selection and refresh, log follow/scroll, scoped stop confirmation, named creation, and shared-summary isolation. No JavaScript errors or external/CDN requests occurred. The deliberately invalid form POST produced its expected HTTP 400 response. Desktop screenshots at 1440 × 1000 and all three pages at 390 × 844 and 320 × 844 were visually inspected. Navigation, controls, forms, rows, process details, and logs fit without horizontal overflow. These are local fixture checks; the user will validate the new interface in the existing Debian deployment. ## Deployment scope Apply the Phase 2 ZIP over the installed Phase 1 update **including the resolution fix**. The archive contains a read-only preflight checker, a per-file manifest, checksums, installation instructions, and only the changed/new project files. The Node worker, Python entrypoints, `scripts/requirements.txt`, Node dependencies, environment-variable contract, and every file under `scripts/lib/` are unchanged from the installed fix. Keep `.env`, the Python environment, dependencies, and media in place. Stop the web process while copying the complete update and restart that web process after verification. Existing downloader workers do not need a code restart for this phase. Reload already-open browser tabs so they use the new API/frontend pair. No database migration is required. The production web entrypoint remains `server.js`. The worker entrypoint remains `queue_worker.js`. Run both under the download account with its existing media access; Phase 2 requires no additional privilege or sudoers rule. For rollback, stop the web process, restore all replaced web files from the backup, and remove the Phase 2 additions identified by the manifest before restarting it. Keep the installed Phase 1 worker/resolution fix. Restore a matching frontend/API pair together.