Skip to content

fix: track collection membership provenance#2616

Closed
enoch85 wants to merge 7 commits into
developmentfrom
poc/collection-membership-provenance
Closed

fix: track collection membership provenance#2616
enoch85 wants to merge 7 commits into
developmentfrom
poc/collection-membership-provenance

Conversation

@enoch85

@enoch85 enoch85 commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2611 by tracking rule-owned and manual collection membership separately. When multiple rules target the same manual media server collection, each Maintainerr collection now keeps its own rule-owned membership while still showing genuinely shared manual items.

Root cause

The old model stored a single isManual flag per CollectionMedia row. During media server sync, items discovered in a shared server collection but not tracked locally were imported as manual, even when they actually belonged to another rule targeting the same media server collection. That erased provenance and caused unrelated items to appear permanently pinned as manual.

What this changes

  • Replaces the single isManual flag with two independent fields:
    • includedByRule
    • manualMembershipSource (legacy, local, shared)
  • Preserves rule and manual membership independently so one can be removed without deleting the other.
  • Reconciles shared manual collections without re-importing rule-owned sibling items as manual.
  • Preserves local and legacy manual provenance during sync instead of collapsing everything into shared membership.
  • Applies scoped membership removal (rule, manual, all) so rule execution and media server sync only clear the intended membership.

Backward compatibility

isManual remains a derived field via entity hooks, so existing read paths continue to behave correctly while the new provenance fields drive collection membership behavior. The migration backfills includedByRule and manualMembershipSource from existing rows and remains reversible.

Validation

  • yarn format:changed
  • yarn check-types
  • yarn lint (4 existing UI warnings only)
  • yarn test
  • yarn build

@enoch85 enoch85 marked this pull request as draft April 6, 2026 20:21
@enoch85 enoch85 added this to the 3.5.0 milestone Apr 7, 2026
@Simon-Eklundh

Simon-Eklundh commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

I gave this a quick test with my simple ruleset, and it looks correct. will test with my complicated ruleset and give the code a proper onceover (eventually)

edit:

complicated ruleset technically works, but because of the bug with media item resolution in main, it won't fill any show related collections

@enoch85

enoch85 commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

I gave this a quick test with my simple ruleset, and it looks correct. will test with my complicated ruleset and give the code a proper onceover (eventually)

edit:

complicated ruleset technically works, but because of the bug with media item resolution in main, it won't fill any show related collections

Ok, so it works - it's just that your bug is stopping it from working - but it would work on a system without your specific bug?

@Simon-Eklundh

Copy link
Copy Markdown
Contributor

It should work, yes.

My bug is already in main, so this shouldn't make anything worse

Mind you, I haven't reviewed the actual code

@enoch85

enoch85 commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator Author

It should work, yes.

My bug is already in main, so this shouldn't make anything worse

Mind you, I haven't reviewed the actual code

Please do a real code review. Would help a lot!

This will be in 3.5.0 anyway, so no rush. :)

@Simon-Eklundh

Copy link
Copy Markdown
Contributor

Will do (eventually, probably not tonight)

Will test with my advanced rules this evening Tho (as soon as my libraries are done refreshing metadata)

@enoch85 enoch85 force-pushed the development branch 2 times, most recently from fed35fc to 0d78268 Compare April 7, 2026 17:41
@enoch85 enoch85 modified the milestones: 3.5.0, 3.6.0 Apr 9, 2026 — with GitHub Codespaces
@enoch85

enoch85 commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

Will do (eventually, probably not tonight)

Will test with my advanced rules this evening Tho (as soon as my libraries are done refreshing metadata)

Any update here? Looking to merge to development this weekend.

@Simon-Eklundh

Copy link
Copy Markdown
Contributor

I believe I tested it

But I'll want to run a second test since I don't remember the result etc properly...

@Simon-Eklundh

Copy link
Copy Markdown
Contributor

And I got through some of the code review, just got stuck on other things like sleep ;)

@Simon-Eklundh

Simon-Eklundh commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@enoch85
image

seems to be an issue on latest version

it worked before tho, so maybe a bad merge.

I've tested with multiple manual collections. it seems to be specifically a problem with manual collections

EDIT: checked out oldest commit and it seems I was wrong. it fails on that too....

Dug further into this; it seems to be a bug on main. somewhere between current main and 40 commits back

@Simon-Eklundh

Copy link
Copy Markdown
Contributor

#2657

this is a combination of both the fixes I did for collections being deleted, and what happens here.

enoch85 added 2 commits April 11, 2026 22:44
…-membership-provenance

# Conflicts:
#	apps/server/src/modules/api/plex-api/plex-api.service.ts
@enoch85 enoch85 marked this pull request as ready for review April 11, 2026 22:56
@enoch85 enoch85 closed this Apr 11, 2026
@enoch85 enoch85 deleted the poc/collection-membership-provenance branch April 11, 2026 23:02
@enoch85 enoch85 changed the title fix: POC for manual collection provenance fix: track collection membership provenance Apr 11, 2026
@enoch85 enoch85 restored the poc/collection-membership-provenance branch April 11, 2026 23:04
@enoch85 enoch85 reopened this Apr 11, 2026

enoch85 commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #2663 (#2663) after renaming the branch from poc/collection-membership-provenance to fix/collection-membership-provenance. Closing this PR so review continues on the renamed branch PR.

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.

reused manual collection ui bug

2 participants