Repository navigation
feat(api): mark which of my collections hold a title - #1907
Conversation
Add to collection needs to tick the collections that already hold the title. Until now a client had to read every collection's items to find out. listCollections takes an optional contains_item content id. Each of the acting profile's own manual collections then carries contains, true or false; smart collections, synced lists and collections another profile shares carry no flag. One query answers it for every collection. A title the profile can't access, or one that doesn't exist, reports false everywhere, so the answer reveals nothing about hidden titles. The collection capabilities report contains_item. The flag lives on the /api/v2 mapping only; /api/v1 ignores the parameter and its list is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 897f80bfff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // PersonalCollectionListInput is the listCollections request. | ||
| type PersonalCollectionListInput struct { | ||
| ContainsItem string `query:"contains_item" doc:"A title's content id. Each of the acting profile's own manual collections then carries contains. Accepted when getCollectionCapabilities reports contains_item" example:"01J9Z8C3W4R5T6Y7U8I9O0P1Q5"` |
There was a problem hiding this comment.
File the required mobile client follow-ups
This introduces a client-visible API parameter and response field, but the commit description explicitly says the silo-apple and silo-android follow-ups have not been filed. Create or complete both platform follow-ups before treating this change as done so neither client is left without the collection-membership behavior.
AGENTS.md reference: AGENTS.md:L146-L152
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed that the follow-ups are still open, but this is a process item rather than a code defect, so there is no commit for it. The silo-apple and silo-android issues (tick collections in Add to collection from contains when getCollectionCapabilities reports contains_item) are drafted and wait on the maintainer before they are filed. The PR body already lists them as not filed, and the change is not done until both exist.
|
Major change — #193 S3: Minor changes — #193 S1 and S2: the same query adds owner-scoped membership data to the list and a new membership read for the add/remove workflow. Re-check profile/account ownership boundaries and that Suggested replacement: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…log' into feat/api-collections-contains-item # Conflicts: # contracts/api/v2/fixtures/get_collection_capabilities_ok.json # contracts/api/v2/fixtures/get_system_info_ok.json # contracts/api/v2/fixtures/index.json # contracts/api/v2/openapi.json # internal/apiv2/personal_collections.go # internal/apiv2/personal_collections_test.go
|
Updated the PR body: the Validation tasks line now reads |
…log' into feat/api-collections-contains-item Brings in login-wide personal collection sharing (#1875), the scrobble lock fix (#1887), and the earlier phase-1 collection PRs. The contains_item tests now create shared collections with is_shared alone, since allowed_profile_ids is gone. The capability test expects both login_sharing and contains_item. The fixture list carries the shared collection, which gets no contains flag. Contract artifacts were regenerated. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c3b0eb47c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| reader, ok := store.(userstore.CollectionMembershipReader) | ||
| if !ok { | ||
| return nil, apiError(http.StatusNotImplemented, "unsupported", "This store cannot report collection membership") |
There was a problem hiding this comment.
Preserve collection membership through the store wrapper
In normal integrated/API startup, cmd/silo/main.go wraps the user-store provider with notifications.WrapUserStoreProvider, whose returned decorators embed only the userstore.UserStore interface and do not forward the new optional CollectionMembershipReader. Consequently this assertion fails for both PostgreSQL and SQLite in production, and every listCollections?contains_item=... request returns 501 capability_unsupported even though getCollectionCapabilities advertises contains_item: true. Forward this capability through the notification wrapper and cover the wrapped-provider path in a test.
Useful? React with 👍 / 👎.
…at/api-collections-contains-item # Conflicts: # contracts/api/v2/fixtures/get_system_info_ok.json # internal/apiv2/fixtures_test.go # internal/apiv2/personal_collections_test.go # web/src/api/v2/schema.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 745470c674
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Only the profile's own manual collections take a title from Add | ||
| // to collection; every other collection leaves contains out. | ||
| if marking && c.CreatorProfileID == profileID && c.CollectionType == collectionTypeManual { | ||
| item.Contains = new(holding[c.ID]) |
There was a problem hiding this comment.
Allocate a pointer to the membership value correctly
This expression does not compile because new requires a type argument, while holding[c.ID] is a boolean value. As a result, the package cannot build; create a bool variable (or use a helper that returns *bool) and assign its address instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a defect: go.mod sets go 1.26.4, and since Go 1.26 new accepts an expression and returns a pointer to a copy of its value, so new(holding[c.ID]) is a *bool holding the membership flag. The package builds and "ci / CI result" passed on 3131f36; go build ./... and TestContractFixtures (which pins contains: true/false in list_collections_contains_item_ok.json) also pass locally.
…tore wrapper Production wraps every user store in the notification decorator, which embeds only userstore.UserStore. The new CollectionMembershipReader was lost there, so listCollections?contains_item answered 501 on both backends. Forward it like the decorator's other optional reads, and run the handler test through the wrapped provider. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: #192
Validation tasks: changes #193 S1, S2, S3
Stacked on #1904 (
fix/sections-missing-collection-log).The Add to collection dialog on a title's page can't show which of the profile's collections already hold that title.
GET /api/v2/collectionslists the collections but not their members, so a client would have to read every collection's items to find out. The redesigned dialog shows one checkbox per collection, ticked when the collection already holds the title, so it needs that answer from the list it already loads.listCollectionsnow accepts an optionalcontains_item, a title's content id. When a client sends it, each of the acting profile's own manual collections carriescontains: trueorfalse.getCollectionCapabilitiesreportscontains_item: trueso clients can check before sending the parameter.Approach
contains, using the same ownership test as the routes that change a collection. Smart collections, synced lists and collections another profile shares leave it out, because Add to collection can't add titles to them. This follows the maintainer's decision for the collections redesign that Add to collection lists only the profile's own collections.falseon every collection, even one that still stores it. The parameter can't be used to learn that a hidden title exists.EXISTSlookup on the collection item table's primary key. The PostgreSQL and SQLite user stores both implement it. Without the parameter the query doesn't run and the list request is unchanged./api/v1is unchanged.containsis set only in the/api/v2mapping, and the v1 list ignores the parameter.containsis an optional member of the sharedPersonalCollectionschema, so the contract diff also lists it on the create, get, update, poster and import responses. Those responses never set it.docs/catalog-api.mddocuments the parameter and the flag next to the other personal collection sections (there is no separate collections API doc). The OpenAPI document, fixtures, system-info digest and web types are regenerated. The new fixture is added at the end of the list, so no existing fixture's request id changes.No web code sends the parameter yet; the redesigned Add to collection dialog will. jellycompat needs no change, and the user manual doesn't describe API fields. The
silo-appleandsilo-androidfollow-up is not filed yet: tick collections in Add to collection fromcontainswhencontains_itemis true.This changes validated behavior in #193. S3 needs re-validation after merge:
contains_itemis a new read path on the collection list, and its recorded pass predates it. The path still meets the S3 criterion: before reporting membership, the server runs the same title access check as an add, so a title in a hidden library or above the profile's rating limit reportsfalseon every collection, including on a direct request. S1 and S2 need a re-check: the list now carries membership data, only on the acting profile's own manual collections, andcontainsshould follow adds and removals. Without the parameter the list is unchanged.Validation
make lint-changedagainstfix/sections-missing-collection-logare clean.make test-goandmake test-db-pinspass.apiv2,userdb,userstoreandapi/handlersran against a freshly migrated PostgreSQL database. The tests covercontainson own manual collections, no flag and no membership read without the parameter, no flag on smart, synced or shared-with-me collections, and a membership read error failing the request instead of reportingfalse. A store test runs on both user stores. Restating Collections — Server #193 S1 to S3: another profile on the same login sees only its own collection, another login gets nothing, and a title in a hidden library, above the profile's rating limit, or unknown reportsfalseeverywhere. The v1 list is byte-identical with and without the parameter. With the access check removed, the hidden-library case fails.TestAdminSubtitleListPageDBandTestCatalogTransferPersistsJobsAndSignedLink.verify-apiv2-openapi,verify-apiv2-contract(11 additive changes, none breaking),verify-apiv2-fixtures,verify-apiv2-web-types,verify-route-inventory,verify-migration-ledger,verify-offline-routesandTestCommittedArtifactMatchesRouterpass. So doverify-settings-bindings-all,verify-playback-fixturesandverify-scenario-catalogs.tsc -bandmake test-webpass.make verify-local-pathspasses.Risks
getCollectionCapabilitiesreportscontains_item: trueunconditionally. A user store without the membership read would answer the parameter with 501; both stores Silo ships implement it.contains_itemruns the title access check and one membership query on top of the list. Requests without it are unchanged.Checklist
AI Disclosure
apiv2package on its own freshly migrated database and confirmed the generated files were current. It did not run mutation tests itself; the implementer removed the access check and saw the hidden-library case fail. The reviewer found nothing to fix.🤖 Generated with Claude Code
Note
Add
contains_itemquery tolistCollectionsv2 APIGET /api/v2/collectionsaccepts acontains_itemtitle ID and returns acontainsboolean on each of the acting profile's own manual collections. The member is omitted for shared, smart, synced, and other-profile collections, and when the query is absent.CollectionMembershipReaderstore interface with aManualCollectionsHoldingmethod, implemented for SQLite and Postgres, and delegated through the notification interest-tracking store wrapper.GET /api/v2/collections/capabilitiesnow reportscontains_item: truewhen the personal collection service is configured.contains_itemand never emitscontains, verified in collections_contains_item_test.go.Macroscope summarized 3131f36.