Skip to content

fix(ui): Turbo init markers, torrent and command pollers, Prowlarr/Seerr/Discover/qBittorrent fixes, 502 envelopes (review 3/7) - #137

Open
ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/review-1106-3-ui
Open

ndandan wants to merge 3 commits into
Shoshuo:mainfrom
ndandan:pr/review-1106-3-ui

Conversation

@ndandan

@ndandan ndandan commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Third PR of the review-2026-11-06 series (stacked on the deployment-posture PR).

What this fixes (user-visible breakage)

  • Search box and sidebar toggle work after Back/Forward. Turbo restored a snapshot that carried the data-init "already initialised" marker, so nothing was attached. Init state is tracked per element (window._prismarrBound WeakSet), duplicate document listeners are removed, and a stale quick-search answer cannot overwrite a newer one.
  • qBittorrent behind an auth-injecting proxy ([Bug] qui reverse proxy authentication fails when username/password are left empty (requires dummy credentials) #10 setups): the route guard required a username the login path does not, so every qBittorrent page bounced to the settings.
  • Prowlarr Enabled/Disabled filter showed no rows (it read a data attribute the rows no longer had); a failed toggle shows Prowlarr's reason as a toast and reverts the button.
  • Dashboard layout Save keeps earlier-hidden sections hidden.
  • Torrent pages render on a slow backend. The 3 s tick aborted an in-flight refresh every tick, so a backend slower than the interval never rendered; a tick during an in-flight fetch is now skipped, user-driven refreshes still cancel the stale one and a stale answer is dropped (sequence counter). The usenet page's visibility handler no longer sticks to the first page instance.
  • Films page no longer marks a torrent "Downloaded" on a queue blip; it re-checks the movie first. Command pollers end on every *arr terminal state (aborted, cancelled, orphaned), are capped, are torn down on navigation, and never reload another page. A registerPageLifecycle() helper in base.html.twig carries the teardown.
  • Health "Retry" on an instance banner clears that instance's breaker; the Seerr banner posts the right service id.
  • Seerr: auto-generated passwords and usernames work when creating a local user; the request edit modal loads the right server's profiles; the logs page caps its page number; a transport failure opens the breaker.
  • Discover links open the instance that owns the item and watchlist toggles send an explicit add or remove; add-movie/series lookups ignore stale answers; quick-look fetches carry a sequence token.
  • qBittorrent completed count, seeds sort key, Transmission and Deluge tracker seed/leech counts; qBittorrent ≤ 5.1's 200 Fails. on a rejected action is now a failure (postAction() through an exec() seam).
  • The "service not configured" page renders (it extended a block the base template does not have: an empty 503).
  • Download-client pages say "unreachable" instead of showing an empty list when the client is down (ApiClientErrorTrait::clientFailed() → 502 envelope).

Tests

Controller tests for each JSON path, JellyseerrClientWriteContractTest and QBittorrentPostActionTest through the clients' exec() seams, and ReviewSection3TemplateGuardTest for the inline-JS shapes (Turbo markers, in-flight guards, poller caps, stale-response tokens).

Notes for upstream

The quick-look sequence token was applied to upstream's inline trigger handler (the fork has a separate qlOpenUrl()); the Prowlarr toggle adaptation targets upstream's button markup.

… §1)

H1  Sonarr library import sends the scanned folder as `path` (template +
    seriesAdd) so Sonarr adopts the existing files instead of creating an
    empty folder named after its own format. AC-9: one raw lookup instead
    of two SkyHook round trips.
H2  Collection "Follow" uses the null-safe bulk endpoint; updateCollection()
    itself now GET-merge-PUTs (a partial PUT wiped profile/root/tags).
H3  Radarr queue "Import" goes through the manual-import preview by
    downloadId (RadarrClient::manualImportFromQueueItem, mirroring Sonarr),
    and the page only deletes the queue item once Radarr reports it
    imported (or removed it); otherwise it shows Radarr's state.
H4  File managers read /films/languages and /series/languages (each app's
    own /api/v3/language) instead of a literal table that mapped 7 of 12
    names to the wrong id.
H5  Every stored language / releaseType (unknown, multiSeasonPack) /
    combined indexerFlags is representable in the row, so "Save all" no
    longer rewrites untouched rows; an empty language list is never stored.
AC-10 "Move files" (default on) on films/series path edits, update-path
    buttons and bulk-edit modals → `?moveFiles=true` / editor `moveFiles`.
AC-7 Radarr/Sonarr write helpers share get()'s connected-then-timed-out
    breaker exemption, through a new protected exec() cURL seam (same
    pattern as BazarrClient) that the new contract tests drive.

Tests: ArrClientWriteContractTest, RadarrClientManualImportTest,
MediaArrWritePathsTest, ArrWriteTemplateGuardTest. PHPStan baseline:
stale curl_setopt_array/json_decode entries removed (errors gone).

(cherry picked from commit bd7d2cb)
S1  TrustedProxiesSubscriber re-resolves the REMOTE_ADDR placeholder of
    TRUSTED_PROXIES on every request (priority 1024, before the router):
    Kernel::preBoot() resolved it once per FrankenPHP worker, pinning each
    worker to whoever hit it first (the healthcheck). Default value kept so
    LAN + cloudflared-on-the-docker-network deployments keep working; README,
    .env and compose example now say what REMOTE_ADDR implies and when to
    pin a CIDR. ProfilerGuardSubscriber checks the raw peer as well as the
    forwarded client ip.
S2  Settings import: only keys the app knows (form fields, kill switches,
    display options, sidebar/dashboard families, Wokeometer switches); a
    *_url that moves to another host clears that service's stored secrets
    (flat keys and instances — ServiceInstanceProvider::clearApiKey());
    display preferences go through the same normalizer as the form (AS-10).
S3  HealthService::urlBlockedReason() refuses hosts with anything but
    hostname characters / a bracketed IPv6 literal; the settings form and
    the import refuse such *_url values; CspHeaderSubscriber::extractOrigin()
    accepts only http(s) + a syntactically valid host + numeric port, so a
    stored URL can no longer inject a script-src directive.
S4  Escaped the remaining innerHTML sinks: collections overview/poster/title,
    series episode title / history badges / add-modal tag label / lookup
    network, films tpl() banners (command messages, lookup titles, indexer
    names), films_missing command messages, Radarr library-import names and
    titles, Seerr Jellyfin username (|raw), Seerr services field values.
    TemplateEscapingGuardTest covers each sink; its header no longer claims
    'unsafe-inline'.
S5  ServiceRouteGuardSubscriber (7) and MultiInstanceBinderSubscriber (6)
    now run after the firewall (8); an unknown instance slug is no longer
    health-probed (bogus status pooled forever).
DD-15 Discover loadDetail() validates type (movie|tv) and a numeric id.

(cherry picked from commit cdd38f9)
H6  Topbar search / sidebar toggle init markers are a WeakSet on the live
    element (a Turbo snapshot clones data-init but not the listeners), and
    the search's document-level handlers are replaced per init.
H7  qBittorrent route-guard rules are URL-only (issue #10 proxy setups).
MS-3 Prowlarr Enabled/Disabled filter reads the form-switch state.
AS-5 HomeController's last-visited pre-check delegates to the route guard's
    own service list (ServiceRouteGuardSubscriber::serviceIdForRoute).
DD-1 Dashboard edit-mode Save only touches sections the client listed.
DC-3 Torrent pages skip a timer tick while a fetch is in flight.
DC-2 Usenet visibility handler bound per page instance, torn down on Turbo.
MT-6 Films: a movie leaving the queue is verified via /info before being
    painted "Downloaded"; /films/queue answers 502 on an outage.
MT-7 Command pollers end on aborted/cancelled/orphaned, cap at 240 polls,
    give up after 5 "unknown" answers, are cleared on Turbo navigation, and
    reload only while their page is still on screen.
MT-8 Films warnings poll pauses while the tab is hidden.
MT-9 Sequence tokens on the add lookups, quick-add resolve and quick-look
    open (a stale failure no longer navigates away); Clear aborts the
    in-flight search; the series Import button stays disabled mid-POST.
MT-10 series/bulk/refresh (one RefreshSeries) and series/bulk/search (one
    endpoint issuing SeriesSearch per id, counting rejections).
AS-6/HC-4 Banner Retry maps labels (Seerr, Radarr 4K) to a service id and
    HealthService::invalidate() clears the per-instance breaker keys.
AS-8 service_not_configured renders into base's `body` block.
MS-2 Seerr user creation: no password = Seerr generates one; username kept.
MS-7 Prowlarr toggle PUTs with forceSave=true and surfaces the error.
MS-8 Seerr request edit modal loads the request's own server profiles.
DD-5 Discover links carry the owning instance slug (lib_slug).
DD-7 Watchlist toggle honours an explicit add/remove, survives a race,
    rejects non-string title/notes.
DC-4 qBittorrent "200 Fails." is a failure (exec() seam on postAction).
DC-5 qBittorrent "Completed" = 100 %; DC-6 Seeds column sortable;
    DC-11 tracker seed/leech counts (Transmission real, Deluge "—").
MS-13 Seerr logs page capped at 10 000.  MS-12 Tautulli Load more counts
    rows and ignores a double-click.
Also: JellyseerrClient exec() seam + recordError() on the breaker branch
(C1), TQ-6 PollerVisibilityGuardTest no longer accepts an inverted check.

(cherry picked from commit 89f9612)
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.

1 participant