Skip to content

fix(downloads): retarget store on profile and server switch - #181

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-e6a8
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-e6a8

Conversation

@cursor

@cursor cursor Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

In-app profile or server switches left DownloadManager pointed at the previous (server, profile) scope. The Downloads UI, on-disk paths, and offline progress queue kept writing into the outgoing identity.

Trigger: Sign in as Profile A, download something, then pick Profile B from Who's Watching without backgrounding the app. Profile B sees A's downloads; new downloads and offline watch progress persist into A's store.json and media directory.

This is data corruption and cross-profile leakage on a shared device.

Root cause

DownloadManager.onScopeChanged() was implemented but never called. ContentView only hydrates downloads on authenticated launch / foreground. Profile selection and server switch keep authState == .authenticated, so that path never re-runs.

Fix

  • Persist the outgoing scope before loading the destination, and flush the save chain so a rapid A→B→A switch cannot reload a stale snapshot.
  • Hold unmatched background URLSession completions instead of deleting staged media as orphans — a transfer started as A can finish while B is active.
  • Call onScopeChanged() after AuthService commits a profile activate/deactivate and after ServerRegistry finishes a server switch (including pairing).

Validation

  • Added DownloadScopePolicyTests for the reload and unmatched-finish contracts.
  • Full xcodebuild test run was not executed from this Linux host (no Xcode).
Open in Web View Automation 

DownloadManager.onScopeChanged() existed but was never called, so an in-app
profile or server switch kept the previous scope's registry, paths, and
offline progress. New downloads and watch progress were written into the
outgoing identity's store.

Persist the outgoing scope before loading the destination, hold unmatched
background completions instead of deleting them as orphans, and hook
identity commits in AuthService and ServerRegistry.

Co-authored-by: Quick <[email protected]>

Quick104 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Silo's pull request guidance changed today (#658). A PR that changes what a user sees now needs before-and-after evidence in its Evidence section, and a PR with no visible change says Evidence: none, no user-visible change. This PR was opened before the rule existed, so it hasn't had a chance to meet it yet.

Missing here: Before-and-after screenshots of the Downloads screen after switching profile or server, showing the right downloads.

The rules are in Show visible changes, and the PR template shows the Evidence section layout. This PR is already a draft, so I've left it that way. Please fill in the Evidence section before marking it ready for review.


Generated by Claude Code

@Quick104 Quick104 closed this Oct 7, 2026
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