Repository navigation
fix(web): keep a Home row's collection when it isn't in the picker list - #1884
Conversation
Saving a collection row picked its id key by looking the id up in the collection options. When the row's collection was missing from the list (still loading, or a shared collection that has since left it), a rename or hero toggle rewrote a personal-collection row into a broken library_collection_id row and dropped every other config key. An unchanged selection now keeps the stored config byte for byte on both the profile and admin builders. Only a newly picked collection writes a key, taken from that option's source, replacing both id keys and keeping the rest. The drawer disables Save while the options load and when a picked id has no option, and its Collection label now names the picker. 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: bf6d80b07c
ℹ️ 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".
| config = collectionRowConfig( | ||
| section?.section_type === "collection" ? base : undefined, | ||
| selectedCollectionId, | ||
| "library_collection_id", | ||
| ); |
There was a problem hiding this comment.
Keep legacy admin collection rows saveable
When an admin edits an older collection row containing only user_collection_id without choosing another collection, this unchanged-selection path preserves that key and sends it in the PATCH. The admin endpoint's validateSectionConfig requires every collection section to contain a nonempty library_collection_id, so renaming the row or toggling Featured still fails with HTTP 400—the exact legacy-admin scenario this change intends to repair. Require the admin to select a valid library collection or provide a server-supported repair path instead of submitting the preserved user-only config.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 51f0970. The admin PATCH validates the merged row, so a row holding only user_collection_id failed on rename no matter what the client sent. Admin rows now read only library_collection_id as their stored selection. A legacy row opens with no collection selected, and Save stays disabled until the admin picks a library collection, which then replaces the legacy key. The new payload and drawer tests failed before the change.
|
The Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…home-rows-collection-key
The admin sections endpoint rejects a collection row without library_collection_id, and it validates the merged row on every PATCH. Keeping a legacy admin row's user_collection_id on rename therefore failed with 400. Admin rows now read only library_collection_id as their stored selection, so a legacy row opens with no collection and Save stays disabled until the admin picks a library collection. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: #1137, #1615
Validation tasks: none
Stacked on #1883. Against
feat/home-rows-dialog, the diff holds only this fix.Editing a collection row on Home could break it. If the row's collection was not in the editor's collection list (the list was still loading, or the row pointed at a shared collection that had left the list), renaming the row or turning its hero setting on or off saved it as a library-collection row holding a personal collection's id, and dropped the rest of its config. This hit profiles editing their collection rows in Settings > Home Screen. On the admin Home rows page it hit only older rows that still stored a
user_collection_id. With this change a row keeps its collection unless the user picks a different one. Those older admin rows are the exception: the admin endpoint rejects any collection row withoutlibrary_collection_id, so the editor makes the admin pick a library collection before saving.The profile save chose between
user_collection_idandlibrary_collection_idby looking the selected id up in the picker options, then built the config from that one key. A missed lookup fell through tolibrary_collection_id. #1615 changes which collections the picker lists, so the miss would get more common. The admin save always rewroteuser_collection_idtolibrary_collection_id, whatever the selection.Approach
buildProfileSectionSaveEntryandbuildAdminSectionPayloadnow follow one rule. If the row was already a collection row and the selected id equals its stored id, the stored config is saved unchanged. Otherwise both id keys are removed, the other config keys stay, and the new key is written: from the picked option'ssourceon profiles, alwayslibrary_collection_idon admin rows.library_collection_idas their stored collection. A legacy admin row holding justuser_collection_idopens with no collection selected, and Save stays disabled until the admin picks a library collection, which replaces the legacy key.Validation
it.failscollection pins from test(web): pin what every Home row kind saves before the redesign #1876 are now ordinary passing tests.user_collection_idrow that needs a library collection picked before Save, and Save staying disabled while the list loads. They do not cover the Add/Edit row dialog path beyond its existing hand-off to the drawer.make test-web: 773 files, 7081 tests passed.pnpm exec tsc -b,pnpm run format:check,pnpm run build: clean.pnpm run budget:check: withinperf-budget.json.pnpm run lint: 0 errors. The 3 warnings on the drawer come from its existing re-exports.make verify-local-paths: passed.Risks
user_collection_idcan't be saved until the admin picks a library collection. Before this change the editor rewrote the personal collection's id intolibrary_collection_id, which the server accepted but which pointed at no library collection.buildRowUpdateRequestpasses an empty config and selection for collection rows. Nothing reaches it today because collection rows open the drawer, but it must pass the stored config once the dialog edits collection rows.section_type, preset, or layout export/import changes.Checklist
AI Disclosure
buildRowUpdateRequestemptying the config of collection rows, which nothing reaches today.🤖 Generated with Claude Code
Note
Preserve a Home collection row's stored collection when it is missing from the picker
collectionIdOfresolver andcollectionRowConfighelper in payloads.ts. Profile rows prefer the personal id then the library id; admin rows read only the library id. Changing a selection removes both id keys and writes the destination key.CollectionSearchableSelectso the label names the combobox. Adds collection tests in SectionEditorDrawer.collection.test.tsx and expands golden payload coverage in payloads.golden.test.ts.buildAdminSectionPayloadno longer unconditionally removes the personal id and rewrites the library id on unchanged rows; admin payloads now preserve stored library configuration and never retain legacy personal keys. CheckcollectionRowConfigand the admin golden tests if downstream consumers depend on the old admin payload shape.Macroscope summarized 51f0970.