Skip to content

feat(collections): Add to collection never dead-ends - #1947

Merged
Quick104 merged 6 commits into
feat/collections-revampfrom
feat/add-to-collection-inline
Oct 5, 2026
Merged

Quick104 merged 6 commits into
feat/collections-revampfrom
feat/add-to-collection-inline

Conversation

@Quick104

@Quick104 Quick104 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #990, #192
Validation tasks: changes #193 S1–S3 (Pass on builds 927 and 1012; re-validate after merge, since the dialog now reads GET /api/v2/collections?contains_item= and its contains marks), #195 W2 and #194 A1 (Not run; need a first walk on a running build); #990 ready for human re-test with #195 W2; #192 AC6 remains unvalidated

When a profile with no manual collection opens Add to collection on a title, the dialog tells it to "Create one in Collections first" and gives no way to do that from there (#990). The dialog also doesn't show which collections already hold the title. This PR rebuilds the dialog to match the collections redesign. It lists the profile's own manual collections as checkboxes, ticked when a collection already holds the title, and each tick or untick saves at once. A New manual collection row is always there. With no collection yet, the dialog opens on that row: name a collection and the title goes in.

Acting admins no longer see server collections in this dialog. The owner decided the dialog lists only the profile's own collections. Admins add titles to a server collection from that collection's editor, which #1939 added.

Stacked on #1944 (feat(api): offer only creatable admin templates). It uses contains_item from #1907 and the collection scope adapter from #1914, both lower in the stack.

Approach

  • Ownership uses the editor's check, PERSONAL_SCOPE.isReadOnly. The dialog lists nothing until the current profile is known, so another profile's shared collection never appears. Smart collections and synced lists are left out because they fill themselves. The footnote reads "Only manual collections take titles by hand. Ticking saves right away."
  • Ticks come from one GET /api/v2/collections?contains_item=<id> read. Ticking sends PUT /api/v2/collections/{id}/items/{item_id} and unticking sends DELETE; the row then shows "Added" or "Removed" for two seconds in a status region. A failed save puts the tick back and shows the error in a toast. While a save runs, the checkbox keeps keyboard focus and ignores further presses.
  • Each row shows the collection's poster, "Manual · N titles", and a Shared pill when the profile shares it. A search box filters the list, and the New manual collection row stays visible while searching. The footer counts the collections that hold the title.
  • Create and add makes the collection through the personal create route, for acting admins too, then PUTs the title. If that PUT fails, the collection is kept and a toast reads "Made X, but couldn't add Y" with Try again, which sends only the PUT, and Open it, which opens the new collection's editor at its title search.
  • If the list can't be read, the dialog shows "Couldn't load your collections" with Try again rather than the empty state, so a profile that already has collections isn't invited to make a duplicate.
  • useAddItemToCollection now writes only to personal collections. Its "Added to collection" toast is gone, because the row says "Added". The item page passes the title's name to the dialog.

Left out against the mockup: the title chip shows the name and an icon, not the poster and year, because the item page passes only the name. The item page's menu entry still reads "Add to Collection". The web sends contains_item without checking the capability, because the web ships with the server it talks to.

No API change. jellycompat reads stored collection items and needs no change. The Apple and Android follow-up draft gets a line to pre-tick their Add to collection from contains_item. The user manual's Collections page needs lines saying Add to collection can make a collection and lists only your own, and that admins add titles to server collections from the collection's editor; that siloserver.org issue is not filed yet.

Validation

  • Web: lint (no errors; the changed files add no warnings), format:check, build, budget:check (within perf-budget.json, unchanged), tsc -b and make test-web (809 files, 7,547 tests) pass.
  • The dialog tests record the /api/v2 requests the dialog sends. They cover ticks from contains, the tick and untick requests, a failed tick, which collections are listed, the Shared pill, search, the wait for the profile, the load error, keyboard focus during a save, inline create for a regular profile and for an acting admin (personal route, no admin or library-collection reads), a failed PUT after create with Try again and Open it, an open dialog moving to another title (its ticks reset), and Done. They fail against the old dialog.
  • One golden from test(web): pin what the collection pages and editors save today #1912 changes on purpose: the acting admin now lists the same collections as a regular profile, with one contains_item read and no per-library reads, and the server-route add golden is removed.
  • Removing the manual-type filter, the rollback on a failed tick, the PUT-only retry, the profile wait, the saving guard or the load-error branch each fails a test.
  • make verify-local-paths, verify-route-inventory, verify-offline-routes, verify-scenario-catalogs and verify-settings-bindings-all pass. No Go, contract or migration files changed, so the other Go and contract checks were not run.
  • Not checked: the dialog has not been opened on a running build. Collections — Web #195 W2 and W3, and Collections — Web admin #194 A1 (add a title to a server manual collection from its editor, reopen it, and check it is still there), have not been walked, and [bug] Web cannot create manual collections but “Add to Collection” requires one #990's steps have not been repeated on this branch. That is why [bug] Web cannot create manual collections but “Add to Collection” requires one #990 is listed as related rather than closed.

Risks

  • Admins who added titles to server collections from a title's page now have to open the collection's editor.
  • fix(web): hide collection actions on seasons and episodes #1755 (TV seasons in personal collections) changes the same dialog to offer "This season" or "Whole series". Whichever PR merges second has to carry that choice over.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents (implementer, independent reviewer)
  • Model(s): claude-opus-5-5[1m]
  • Involvement: Fully AI-generated, human review pending
  • Adversarial review: an independent reviewer subagent read the diff against the collections redesign and its mockup and ran the tests. It confirmed the new tests fail on the old dialog, then removed guards one at a time to check that a test catches each. It found three problems, all fixed here with tests: a failed list read showed "Start your first collection" to a profile that already had collections; disabling the checkbox during a save dropped keyboard focus to the page body; and the unknown-profile test still passed with the profile wait removed.

🤖 Generated with Claude Code

Note

Rework Add to collection dialog with immediate checkbox toggles and inline creation

  • Rebuilds the Add to collection dialog as a checkbox list of the profile's own manual collections, with current membership (contains marks), instant save on toggle, search, and a Done action. Read-only, smart, and other users' collections are excluded; library collections are not offered to acting admins.
  • Adds an inline create-and-add form so a profile with no manual collection can create one and add the title in one step. If the collection is created but the title add fails, a warning toast offers retry or opening the new collection.
  • Adds useCollectionsContaining in collections.ts to fetch the collection list with membership marks for a content ID; useAddItemToCollection now always writes to the personal endpoint and no longer supports admin writes. The detail-page action bars pass the item title to the dialog.
  • Behavior Change: useAddItemToCollection drops its source and position inputs and removes the admin route branch; any caller relying on the old signature or admin adds will break.

Macroscope summarized 2772459.

Quick104 and others added 4 commits October 4, 2026 17:42
The dialog is about to list only the profile's own manual collections, take
initial ticks from contains_item, save each tick at once and offer an inline
New collection. These tests describe that; the Add to collection golden drops
the acting admin's server collections group on purpose.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Add to collection now lists only the profile's own manual collections, for
acting admins too, with each tick read from contains_item and saved at once.
A New collection row is always there, and with no manual collection the
dialog opens on it, so a title can always go somewhere. If the new
collection is made but the title can't be added, the collection is kept and
the toast offers Try again (the add only) and Open it.

Admins no longer add titles to server collections here; they do it from the
collection's editor.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nd profile wait

A failed list read must not look like having no collections, a tick must
keep keyboard focus while it saves, and an unknown profile must keep the
dialog waiting after the list has loaded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…d-friendly

A failed list read showed "Start your first collection" to profiles that
already had collections; it now says the list couldn't load and offers
Try again. A saving tick used the disabled prop, which dropped keyboard
focus to the body; it now stays focusable with aria-disabled and ignores
presses until the save lands.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 82fd1232-5a9d-4139-ab7f-8cf8bd249bf9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · 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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T00:06:27.699486Z 2772459 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77dd554bff

ℹ️ 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".

Comment on lines +98 to +100
// Ticks changed in this dialog, ahead of the list's next read.
const [ticks, setTicks] = useState<ReadonlyMap<string, boolean>>(new Map());
const [flash, setFlash] = useState<Flash | null>(null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset local ticks when the item changes

When the same open dialog is reused for a different mediaItemId (for example, while navigating between detail items), this ticks map is retained and isTicked gives it precedence over the newly fetched collection.contains value. The checkboxes and collection count can therefore show the previous title's membership until each collection is manually toggled; clear the map or key the panel by the item/profile when those inputs change.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2772459: the panel is keyed by mediaItemId, so a dialog that moves to another title starts from that title's contains marks. A test covers rerendering the open dialog with a new title.

@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown

The #193 S1–S3 passes need re-validation after merge. This diff makes the dialog send GET /api/v2/collections?contains_item=... and consume the contains field; the S1/S3 passes on build 927 and S2 pass on build 1012 predate this membership-bearing read. It adds an access-sensitive read for S3 and profile-scoped membership data for S1/S2. The PR must explain this change in the tested path; these cases need re-validation after merge rather than being described as unchanged routes.

#195 W2 and #194 A1 are Not run, so no prior pass is at risk; their changed inline-create/add and acting-admin server-collection workflows need first running-build walks. #195 W3 is unaffected: its ManualContentsPanel/TitleSearch member picker and authorization path are unchanged. #990 is a candidate finding, not a recorded blocked case; with W2 Not run, describe it as ready for human re-test rather than saying #192 AC6 is unblocked.

Suggested fix: Validation tasks: changes #193 S1–S3, #195 W2, and #194 A1; #990 ready for human re-test with #195 W2; #192 AC6 remains unvalidated.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

Base automatically changed from feat/api-admin-creatable-templates to feat/collections-revamp October 4, 2026 23:26
Quick104 and others added 2 commits October 4, 2026 20:02
…at/add-to-collection-inline

# Conflicts:
#	web/src/lib/collections/copy.ts
An open dialog that moved to another title kept the ticks made for the
previous one, so its checkboxes and count showed stale membership. Key
the panel by the title so each title starts from the server's marks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104

Quick104 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Updated the Validation tasks line: #193 S1–S3 now need re-validation after merge because the dialog reads contains_item; #195 W3 dropped as unaffected; #990 is ready for re-test with #195 W2 and #192 AC6 stays unvalidated.

@Quick104
Quick104 merged commit 5381dd3 into feat/collections-revamp Oct 5, 2026
17 checks passed
@Quick104
Quick104 deleted the feat/add-to-collection-inline branch October 5, 2026 00:12
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