Skip to content

fix(web): keep a Home row's collection when it isn't in the picker list - #1884

Merged
Quick104 merged 3 commits into
feat/collections-revampfrom
fix/home-rows-collection-key
Oct 4, 2026
Merged

Quick104 merged 3 commits into
feat/collections-revampfrom
fix/home-rows-collection-key

Conversation

@Quick104

@Quick104 Quick104 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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 without library_collection_id, so the editor makes the admin pick a library collection before saving.

The profile save chose between user_collection_id and library_collection_id by looking the selected id up in the picker options, then built the config from that one key. A missed lookup fell through to library_collection_id. #1615 changes which collections the picker lists, so the miss would get more common. The admin save always rewrote user_collection_id to library_collection_id, whatever the selection.

Approach

  • buildProfileSectionSaveEntry and buildAdminSectionPayload now 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's source on profiles, always library_collection_id on admin rows.
  • Admin rows read only library_collection_id as their stored collection. A legacy admin row holding just user_collection_id opens with no collection selected, and Save stays disabled until the admin picks a library collection, which replaces the legacy key.
  • Whether the selection changed is worked out from the stored and selected ids rather than passed in as a flag, so the builders and their callers keep their signatures. Picking another collection and then the original again counts as unchanged.
  • The editor drawer disables Save on collection rows while the collection list loads, when nothing is selected, and when a newly picked id is not in the list. The Collection label is now tied to the picker, so screen readers announce it by name.
  • The Add/Edit row dialog from feat(web): add and edit ready-made Home rows in one dialog #1883 opens this drawer for collection rows, so the fix covers both entry points.
  • No deviations from the Home rows design spec. This PR adds no redesigned UI.

Validation

  • Unit and RTL tests were written first and failed on the base branch (5 payload tests, 6 drawer tests); all pass now. The three it.fails collection pins from test(web): pin what every Home row kind saves before the redesign #1876 are now ordinary passing tests.
  • The tests cover a profile rename and a hero toggle on a row whose collection is missing from the list, picking a new collection on both surfaces, an admin rename of a library collection row missing from the list, an admin legacy user_collection_id row 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: within perf-budget.json.
  • pnpm run lint: 0 errors. The 3 warnings on the drawer come from its existing re-exports.
  • make verify-local-paths: passed.
  • Not checked in a browser.

Risks

  • Stored-data change, intended: when a profile picks a different collection, the row now keeps its other config keys instead of saving the new id alone. An unchanged selection saves exactly what was stored.
  • Admin rows that still carry a legacy user_collection_id can't be saved until the admin picks a library collection. Before this change the editor rewrote the personal collection's id into library_collection_id, which the server accepted but which pointed at no library collection.
  • Known gap: when the stored collection is missing from the list, the picker shows "Choose collection" while Save stays enabled. Saving keeps the row's collection, but the placeholder suggests nothing is selected. The "Collection no longer available" state belongs to the follow-up that moves collection rows into the Add/Edit row dialog.
  • For that follow-up: buildRowUpdateRequest passes 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.
  • No API, Go, persisted section_type, preset, or layout export/import changes.

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 and every caller of the two builders, and ran the new tests against the base code to confirm they fail there. Verdict: approve, with no blocking findings. It raised two, both deferred to the follow-up that moves collection rows into the Add/Edit row dialog and listed under Risks: the misleading "Choose collection" placeholder when the stored collection is missing from the list, and buildRowUpdateRequest emptying 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

  • Fixes profile and admin Home section saves so an unchanged collection id that is not in the picker options is kept, along with its other configuration fields.
  • Adds a shared collectionIdOf resolver and collectionRowConfig helper 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.
  • The drawer in SectionEditorDrawer.tsx disables save while collection options are loading, when the selection is empty, or when a newly picked id is not in the allowed options. Admin rows with a legacy personal-only reference cannot be saved until a library collection is picked.
  • Labels the collection picker and passes a trigger id to CollectionSearchableSelect so the label names the combobox. Adds collection tests in SectionEditorDrawer.collection.test.tsx and expands golden payload coverage in payloads.golden.test.ts.
  • Behavioral Change: buildAdminSectionPayload no 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. Check collectionRowConfig and the admin golden tests if downstream consumers depend on the old admin payload shape.

Macroscope summarized 51f0970.

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]>
@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: 5b5909fe-20b7-4c52-aa68-af64371fa748

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-04T12:36:24.816532Z 51f0970 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: 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".

Comment on lines +255 to +259
config = collectionRowConfig(
section?.section_type === "collection" ? base : undefined,
selectedCollectionId,
"library_collection_id",
);

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 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 👍 / 👎.

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.

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.

@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown

The Validation tasks line should be corrected. #1142 C2 tests profile row reordering through buildSectionOverrides and PUT /api/v2/profile/sections, not the changed collection-row save builder. #195 W1 covers collection browsing and member access, which this Home-row edit does not change. The blocked collection-sharing cases (#193 S7 and #195 W7) still depend on #1615; this PR does not implement that sharing model. No recorded validation result is affected.

Suggested line: Validation tasks: none

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

Posted via Macroscope — v1 validation impact

Quick104 and others added 2 commits October 4, 2026 08:29
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]>
@Quick104

Quick104 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Changed the PR body to Validation tasks: none: no validation case covers editing a Home collection row (#1142 C2 tests profile row reordering and #195 W1 tests collection browsing).

Base automatically changed from feat/home-rows-dialog to feat/collections-revamp October 4, 2026 13:44
@Quick104
Quick104 merged commit 8fd0339 into feat/collections-revamp Oct 4, 2026
16 checks passed
@Quick104
Quick104 deleted the fix/home-rows-collection-key branch October 4, 2026 13:45
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