fix(unhead): dedupe scalar Open Graph and Twitter metadata - #880
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughSocial metadata deduplication now treats scalar Open Graph and Twitter fields as single-valued while preserving repeatable structured image fields. Unit, client, SSR, snapshot, and documentation changes cover the updated rules. ChangesSocial metadata deduplication
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
📦 Bundle Size
All bundles (14)
⚡ Performance (directional)✅ No significant change (within CI noise) All benchmarks (14)
Baseline: main @ bf71e22 · 2026-07-23 · gzipped is the headline size metric · perf is directional (shared-runner, gated) |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/unhead/test/unit/client/duplicates.test.ts (1)
6-49: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winAvoid a fixed sleep for DOM synchronization.
The short timeout makes this test timing-dependent; slower CI may assert before the head update completes. Await the head’s actual update/flush promise instead of relying on elapsed time.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/unhead/test/unit/client/duplicates.test.ts` around lines 6 - 49, Replace the fixed setTimeout delay in the test around useSeoMeta with the head instance’s actual update or flush promise, awaiting the DOM synchronization mechanism exposed by useDOMHead. Keep the existing assertions unchanged and ensure they run only after the metadata update has completed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/unhead/test/unit/server/deduping.test.ts`:
- Around line 40-48: Update the deduping test assertions around the Open Graph
and Twitter image tags to validate serialized tag order or grouped
image-plus-alt pairs, rather than checking image and alt values as independent
lists. Preserve the expected first-image/first-alt and second-image/second-alt
associations for both og:image and twitter:image.
---
Outside diff comments:
In `@packages/unhead/test/unit/client/duplicates.test.ts`:
- Around line 6-49: Replace the fixed setTimeout delay in the test around
useSeoMeta with the head instance’s actual update or flush promise, awaiting the
DOM synchronization mechanism exposed by useDOMHead. Keep the existing
assertions unchanged and ensure they run only after the metadata update has
completed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c91a728-ea70-4a33-a23c-067fa76ab8cd
📒 Files selected for processing (6)
docs/head/1.guides/1.core-concepts/6.handling-duplicates.mdpackages/unhead/src/utils/const.tspackages/unhead/src/utils/dedupe.tspackages/unhead/test/unit/client/duplicates.test.tspackages/unhead/test/unit/dedupe.test.tspackages/unhead/test/unit/server/deduping.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/unhead/test/unit/dedupe.test.ts
🔗 Linked issue
Related to #842
❓ Type of change
📚 Description
Unhead kept duplicate
og:title,article:section, and other scalar properties because array handling applied to whole namespaces.Array handling now follows the schema: Open Graph media and alternate locales, article and book authors and tags, and deprecated Twitter image groups remain repeatable. Other duplicates use the existing last-tag-wins rule in SSR and the DOM.
Summary by CodeRabbit