Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@s0up4200
Copy link
Collaborator

@s0up4200 s0up4200 commented Dec 31, 2025

Fixes tracker health support (supportsTrackerHealth) not being detected after upgrading qBittorrent until qui restarts.

Changes

  1. Moved capability detection to qui - TrackerManager no longer checks version internally. Instead, qui determines the capability and tells TrackerManager via SetUseIncludeTrackers().

  2. RefreshCapabilities updates TrackerManager - When a version change is detected, the TrackerManager's include capability is updated immediately.

  3. Reduced staleTime - Capabilities cache reduced from 5 minutes to 1 minute so upgrades are detected faster through normal user interaction.

Requires: autobrr/go-qbittorrent#102

Summary by CodeRabbit

  • Improvements
    • Instance capability data now refreshes more frequently, keeping interface information more current.
    • Tracker include handling enhanced for more consistent and reliable tracker-related behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

staleTime was 5 minutes, meaning after upgrading qBittorrent the new
capabilities wouldn't be detected until restart or cache expiry.

Reduced to 1 minute so normal user interaction (window focus, navigation)
triggers a refresh within a reasonable timeframe.
@s0up4200 s0up4200 added this to the v1.12.0 milestone Dec 31, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

Walkthrough

Reduced client-side cache freshness for instance capabilities, updated a Go dependency version, and added internal tracker-include capability tracking and propagation within the qBittorrent client implementation.

Changes

Cohort / File(s) Summary
Web hook
web/src/hooks/useInstanceCapabilities.ts
Reduced staleTime from 300000ms to 60000ms; no signature or refetch-condition changes.
Go module
go.mod
Updated github.com/autobrr/go-qbittorrent dependency to a newer commit/version; no other go.mod edits.
qBittorrent client internals
internal/qbittorrent/client.go
Added trackerIncludeMinVersion and trackerIncludeSupported fields; compute and store tracker-include support in applyCapabilitiesLocked; propagate support to TrackerManager via SetUseIncludeTrackers during RefreshCapabilities; replaced runtime capability check with stored flag under lock; minor logging/reordering changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant qBittorrentAPI as qBittorrent API
    participant TrackerMgr as TrackerManager

    Note over Client,qBittorrentAPI: capability refresh flow (periodic / triggered)
    Client->>qBittorrentAPI: RefreshCapabilities() — fetch capabilities
    qBittorrentAPI-->>Client: capabilities (includes tracker include version)
    Client->>Client: applyCapabilitiesLocked(capabilities)
    alt tracker include version present
        Client->>Client: compute trackerIncludeSupported (compare versions)
        Client-->>TrackerMgr: SetUseIncludeTrackers(trackerIncludeSupported)
        Note right of TrackerMgr: TrackerManager updates behavior based on flag
    else not present
        Note right of Client: trackerIncludeSupported = false
    end
    Client-->>Client: log previousVersion -> newVersion
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • KyleSanderson
  • Audionut

Poem

🐰 I nibbled staleTime down to something spry,

deps hopped forward, versions caught my eye.
Tracker-include now tucked into my pouch,
Managers listen — no need to slouch.
Freshness served, I bounce — a grateful little sigh. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: detect tracker health support after qBit upgrade' accurately describes the main objective of the PR, which is to fix the detection of tracker include/health support after qBittorrent upgrades without requiring a qui restart.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/capabilities-cache-stale-after-qbit-upgrade

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc691ea and 0f7ee1f.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Move tracker include capability detection from go-qbittorrent to qui.
When RefreshCapabilities() detects a new version, it now updates the
TrackerManager's include capability via SetUseIncludeTrackers().

This fixes the issue where supportsTrackerHealth wasn't detected after
upgrading qBittorrent until qui was restarted.
@s0up4200 s0up4200 changed the title fix(hooks): reduce capabilities cache to detect qBit upgrades faster fix: detect tracker health support after qBit upgrade Dec 31, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfee3c and cc691ea.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod
  • internal/qbittorrent/client.go
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Audionut
Repo: autobrr/qui PR: 553
File: internal/services/crossseed/service.go:1045-1082
Timestamp: 2025-11-06T12:11:04.963Z
Learning: The autobrr/qui project uses a custom go-qbittorrent client library (github.com/autobrr/go-qbittorrent) that supports both "paused" and "stopped" parameters when adding torrents via the options map. Both parameters should be set together when controlling torrent start state, as seen in internal/services/crossseed/service.go and throughout the codebase.
Learnt from: s0up4200
Repo: autobrr/qui PR: 746
File: internal/services/reannounce/service.go:480-481
Timestamp: 2025-12-11T08:40:01.329Z
Learning: In autobrr/qui's internal/services/reannounce/service.go, the hasHealthyTracker, getProblematicTrackers, and getHealthyTrackers functions intentionally match qbrr's lenient tracker health logic (skip unregistered trackers and check if any other tracker is healthy) rather than go-qbittorrent's strict isTrackerStatusOK logic (which treats unregistered as an immediate failure). For multi-tracker torrents, if one tracker is working, reannouncing won't help. The duplication of the health check logic across these three functions is acceptable as it's a simple one-liner, and extracting it would add unnecessary complexity.
📚 Learning: 2025-11-06T12:11:04.963Z
Learnt from: Audionut
Repo: autobrr/qui PR: 553
File: internal/services/crossseed/service.go:1045-1082
Timestamp: 2025-11-06T12:11:04.963Z
Learning: The autobrr/qui project uses a custom go-qbittorrent client library (github.com/autobrr/go-qbittorrent) that supports both "paused" and "stopped" parameters when adding torrents via the options map. Both parameters should be set together when controlling torrent start state, as seen in internal/services/crossseed/service.go and throughout the codebase.

Applied to files:

  • go.mod
📚 Learning: 2025-11-25T22:46:03.762Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 632
File: internal/backups/service.go:1401-1404
Timestamp: 2025-11-25T22:46:03.762Z
Learning: In qui's backup service (internal/backups/service.go), background torrent downloads initiated during manifest import intentionally use a fire-and-forget pattern with the shared service context (s.ctx). Per-run cancellation is not needed, as orphaned downloads completing after run deletion are considered harmless and acceptable. This design prioritizes simplicity over per-run lifecycle management for background downloads.

Applied to files:

  • go.mod
📚 Learning: 2025-12-11T08:40:01.329Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 746
File: internal/services/reannounce/service.go:480-481
Timestamp: 2025-12-11T08:40:01.329Z
Learning: In autobrr/qui's internal/services/reannounce/service.go, the hasHealthyTracker, getProblematicTrackers, and getHealthyTrackers functions intentionally match qbrr's lenient tracker health logic (skip unregistered trackers and check if any other tracker is healthy) rather than go-qbittorrent's strict isTrackerStatusOK logic (which treats unregistered as an immediate failure). For multi-tracker torrents, if one tracker is working, reannouncing won't help. The duplication of the health check logic across these three functions is acceptable as it's a simple one-liner, and extracting it would add unnecessary complexity.

Applied to files:

  • go.mod
  • internal/qbittorrent/client.go
📚 Learning: 2025-12-28T18:44:10.496Z
Learnt from: s0up4200
Repo: autobrr/qui PR: 876
File: internal/logstream/hub_test.go:188-192
Timestamp: 2025-12-28T18:44:10.496Z
Learning: In Go 1.25 (Aug 2025), use wg.Go(func()) to spawn a goroutine and automate the Add/Done lifecycle. Replace manual patterns like wg.Add(1); go func(){ defer wg.Done(); ... }() with wg.Go(func(){ ... }). Ensure the codebase builds with Go 1.25+ and apply this in relevant Go files (e.g., internal/logstream/hub_test.go). If targeting older Go versions, maintain the existing pattern.

Applied to files:

  • internal/qbittorrent/client.go
🔇 Additional comments (7)
go.mod (1)

13-13: LGTM!

The dependency version update aligns with the PR objectives to move tracker include capability detection into qui.

internal/qbittorrent/client.go (6)

25-25: LGTM!

The constant follows the established pattern and is consistent with other capability version checks in the file.


50-50: LGTM!

The field is well-placed and follows the naming convention of other capability flags in the struct.


221-227: LGTM!

The mutex handling is correct—capturing the capability flag under lock and then propagating it to TrackerManager after unlock. This properly addresses the PR's goal of detecting capability changes after qBittorrent upgrades.


229-235: LGTM!

The logging improvements enhance observability by showing both the previous and new versions, which will help debug capability detection issues after qBittorrent upgrades.


257-257: LGTM!

The capability flag assignment follows the same pattern as other capability checks and correctly uses the trackerIncludeMinVersion constant.


448-452: LGTM!

The change from dynamic version checking to returning a cached flag is more efficient and ensures the capability is properly refreshed when qBittorrent is upgraded, which addresses the core issue described in the PR.

@s0up4200 s0up4200 changed the base branch from main to develop January 2, 2026 07:20
@s0up4200 s0up4200 modified the milestones: v1.12.0, v1.13.0 Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants