Skip to content

feat(sync): give separate profiles their own encrypted collections - #48

Merged
D3SOX merged 1 commit into
mainfrom
separate-profile-collections
Nov 18, 2026
Merged

D3SOX merged 1 commit into
mainfrom
separate-profile-collections

Conversation

@D3SOX

@D3SOX D3SOX commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

OpenTubeX is getting separate profiles (OpenTubeX#3291). A separate profile keeps its own subscriptions, history, playlists and watch statistics, and each device syncs them while that profile is active. Clients need a place on the server for that data that older clients never read, so they can't mix it into their own.

The server now accepts history.<scope>, playlists.<scope>, subscriptions.<scope> and watchStats.<scope>, where <scope> is the profile ID in lowercase hex (up to 128 digits). Each has the size limit of its base collection. A new separateProfiles collection (8 MiB) holds the profiles' names and colors. DELETE /v1/encrypted_sync/{collection} (and its alias) deletes one of these scoped collections with its pending changes after the profile is deleted. It returns 204 even when the collection is already gone, and 400 for any shared collection. /health advertises separate_profiles: 1. The README documents the collections, the endpoint and the capability; prettier rewrapped the two tables it touched.

Proof: new tests check the scoped limits, which names are refused (uppercase, odd length, nested dots, slashes, other bases, too long), the capability, and the DELETE behavior against SQLite. cargo fmt --check, cargo clippy and cargo test (107 tests) pass. I also ran this branch locally and pointed the OpenTubeX network sync E2E tests from the app PR at it: 12 passed, including the new separate profile case, and 1 skipped because the server doesn't advertise playlist_thumbnails.

Reviewed with sol-loop: 3 rounds with gpt-6.1-sol on xhigh.
Sol verdict: approved

Changes made by Claude Opus 5.5 in Claude Code (T3 Code).

View guided diff Turn on auto-fix

Accept history, playlists, subscriptions and watchStats collections scoped to a profile as <name>.<hex profile ID>, a separateProfiles collection for their names and colors, and DELETE for a scoped collection once its profile is deleted. Advertise this as separate_profiles.
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Sorry @D3SOX, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 8 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The server now advertises separate-profile support and accepts deletion requests for scoped encrypted-sync collections. Scoped collections inherit size limits from their base collections. Deletion removes the collection and its change history.

Changes: Separate profile collections

Layer / File(s) Summary
Scoped collection capability and rules
src/dto.rs, src/handlers/encrypted_sync.rs, src/handlers/health.rs, README.md
The capability response includes separate_profiles. Scoped collection names are validated against supported base names and lowercase hexadecimal scopes. Scoped collections inherit their base collection’s size limits. Tests and README document the capability and validation rules.
Scoped collection deletion
src/database/encrypted_sync.rs, src/handlers/encrypted_sync.rs, README.md
The delete endpoint removes a scoped collection and its change history in one transaction. It rejects shared collection names and notifies account listeners only when a collection row is deleted. Tests cover repeated deletion and preservation of the shared collection. The README documents the endpoint.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant EncryptedSyncHandler
  participant EncryptedSyncDatabase
  participant AccountListeners
  Client->>EncryptedSyncHandler: DELETE scoped collection
  EncryptedSyncHandler->>EncryptedSyncDatabase: Delete collection and change history
  EncryptedSyncDatabase-->>EncryptedSyncHandler: Return whether collection row was deleted
  opt Collection row was deleted
    EncryptedSyncHandler->>AccountListeners: Notify account listeners
  end
  EncryptedSyncHandler-->>Client: Return no content
Loading

Possibly related PRs

Suggested reviewers: bnyro

Merge Risk: Minimal · up to 70a6d

This adds per-profile encrypted collections, the separateProfiles collection, and a delete endpoint for scoped collections. The changed paths are validated and tested, and I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: separate profiles get their own encrypted sync collections. The changeset adds scoped collections (history, playlists, subscriptions, watchStats with a profile scope),…
Description check Passed The description explains the purpose (separate profiles need server-side storage that older clients do not read), lists the accepted scoped collection names, the separateProfiles collection, the DELET…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: separate profiles get their own encrypted sync collections. The changeset adds scoped collections (history, playlists, subscriptions, watchStats with a profile scope), a separateProfiles collection, a DELETE endpoint, and the separate_profiles capability, all of which fit under this title. The title is conventional-commit formatted and specific.

Full details: Description check

Explanation

The description explains the purpose (separate profiles need server-side storage that older clients do not read), lists the accepted scoped collection names, the separateProfiles collection, the DELETE endpoint and its status codes, the health capability, the README update, and the tests run. It matches the changeset closely.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 624f3e24-1160-40fc-80c5-da0be074feb7
Commits

Reviewing files that changed from the base of the PR and between 3e061d8 and 70a6de2.

Files selected for processing: 5

  • README.md
  • src/database/encrypted_sync.rs
  • src/dto.rs
  • src/handlers/encrypted_sync.rs
  • src/handlers/health.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@D3SOX
D3SOX merged commit 389d21e into main Nov 18, 2026
19 checks passed
@D3SOX
D3SOX deleted the separate-profile-collections branch November 18, 2026 00:33
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