Skip to content

feat: collection card enhancements#5894

Merged
nimrodkra merged 7 commits intomainfrom
feat/collection-card-enhancements
Apr 21, 2026
Merged

feat: collection card enhancements#5894
nimrodkra merged 7 commits intomainfrom
feat/collection-card-enhancements

Conversation

@nimrodkra
Copy link
Copy Markdown
Member

@nimrodkra nimrodkra commented Apr 20, 2026

Summary

  • Collection grid and list cards now show the number of sources after read time.
  • When a collection post was edited after creation, cards and the post page show an Updated label using updatedAt instead of createdAt.
  • For updates within today/yesterday, the timestamp uses a relative short format (e.g. 11h ago, 45m ago, 1d ago). Older updates keep the absolute date (e.g. Mar 15).
  • The collection post page mirrors the same source count and Last updated prefix.

Shared helpers isPostUpdated (graphql/posts.ts) and a new TimeFormatType.PostUpdated / postUpdatedDateFormat (lib/dateFormat.ts) keep the logic in one place across cards and the post page.

Test plan

  • On / and /sources/collections, collection cards show N source(s) after read time.
  • When updatedAt !== createdAt, the date label becomes Updated <…>; otherwise the original created date is shown with no prefix.
  • Recently-updated collection (same day or yesterday) renders Updated 11h ago / Updated 1d ago; older updates render Updated Mar 15.
  • Collection post detail page shows Last updated <…> only when edited, with the relative format for today/yesterday, plus N source(s) next to it.

Preview domain

https://feat-collection-card-enhancement.preview.app.daily.dev

Gate new collection card behavior behind the `collection_card_enhancements`
GrowthBook flag:

- Show number of sources after the read time on grid and list cards
- Use `updatedAt` with an "Updated" label when the post was edited after creation
- Surface a `HIGHLIGHT` raised label on cards featured in Happening Now
- Mirror the same source count, "Last updated" prefix, and "Featured in
  Happening Now" pill on the collection post page

The flag is evaluated once in `Feed.tsx` and propagated through
`FeedCardContext` so feed cards do not re-evaluate per render. The
`majorHeadlines` query only runs when the flag is enabled.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-webapp Ready Ready Preview Apr 21, 2026 5:43am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
storybook Ignored Ignored Apr 21, 2026 5:43am

Request Review

@nimrodkra
Copy link
Copy Markdown
Member Author

@claude please review this pr

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 20, 2026

Claude finished @nimrodkra's task in 3m 6s —— View job


PR Review: feat/collection-card-enhancements

Tasks

  • Understand the request
  • Read changed files
  • Analyze code quality, bugs, and patterns
  • Post review feedback

Overall this is a clean, well-scoped implementation. The flag propagation pattern via FeedCardContext is the right approach, and gating the majorHeadlines query behind the flag avoids extra requests in the control arm. A few things to call out:

Issues

1. Logic duplication: wasUpdated calculated in 3 places

The same expression appears independently in CollectionGrid.tsx:40-43, CollectionList.tsx:43-46, and CollectionPostContent.tsx:65-66:

const wasUpdated =
  collectionEnhancementsEnabled &&
  !!post.updatedAt &&
  post.updatedAt !== post.createdAt;

Per the codebase's no-duplication guideline this should be a shared utility. Consider adding isCollectionUpdated(post, enabled) to packages/shared/src/lib/posts.ts or similar. Fix this →

2. Duplicated description string

'Featured in Happening Now' appears verbatim in both FeedItemContainer.tsx:50 (grid) and list/FeedItemContainer.tsx:58. Extract to a named constant to avoid drift. Fix this →

3. Arbitrary Tailwind value text-[0.5rem] in RaisedLabel.tsx:25

'feed-highlights-title-gradient text-[0.5rem] leading-none'

This uses an arbitrary value outside the design system token set. The no-custom-color ESLint rule won't catch this since it's a size token. If 0.5rem maps to an existing typo-* scale step, use that token instead. If it doesn't, this is worth flagging with the design system owner.

Observations / non-blocking

4. Copy inconsistency between card and post page

Cards show "Updated <date>" (CollectionGrid.tsx:84, CollectionList.tsx:86) while the post page shows "Last updated <date>" (CollectionPostContent.tsx:205). Whether this is intentional UX or an oversight is worth confirming.

5. Dual-source highlightedPostIds build in Feed.tsx:471-489

The set is populated from both FeedItemType.Highlight feed slots AND the majorHeadlines API response. The motivation for checking both sources isn't obvious from reading the code — a short comment explaining why both sources are needed would help future maintainers avoid accidentally removing one.

6. source count rendering duplicated in three components

The "N source/sources" plural rendering appears in PostMetadata.tsx:85-93, list/PostMetadata.tsx:47-51, and CollectionPostContent.tsx:210-213. This is lower priority but follows the same no-duplication pattern as item 1.

What looks good ✓

  • Flag evaluated once per feed render, propagated through context — no per-card re-evaluation
  • majorHeadlines query properly gated: enabled: isCollectionEnhancementsEnabled
  • collectionEnhancementsEnabled && highlighted in flagProps correctly short-circuits when the flag is off — non-collection card types are unaffected
  • Feature flag defaults to false in featureManagement.ts
  • React Query key for majorHeadlines is identical between Feed.tsx and CollectionPostContent.tsx, so the second call is served from cache
  • wasUpdated guards correctly against equal timestamps and missing updatedAt

Resolve pre-existing strict-mode errors in files modified by the
collection card enhancements so `typecheck_strict_changed` passes on CI.

Made-with: Cursor
- Remove featureCollectionCardEnhancements flag; collection card/date/source
  enhancements are always on.
- Drop highlight cross-referencing in Feed.tsx and the majorHeadlines query
  on the collection post page. This removes two extra API calls.
- Remove RaisedLabelType.Highlight variant and the "Featured in Happening
  Now" pill on the collection post page.
- Extract isPostUpdated helper in graphql/posts for the updated-date check.
- Reuse shared pluralize helper for the "N source(s)" label.

Made-with: Cursor
Use comment-style short format (e.g. "11h ago", "45m ago") for collection
"Updated" timestamps that fall on today or yesterday. Older updates keep
the absolute date format. Applies to collection grid/list cards and the
collection post page.

Made-with: Cursor
@nimrodkra nimrodkra requested a review from idoshamun April 20, 2026 17:29
@nimrodkra nimrodkra changed the title feat: collection card enhancements behind feature flag feat: collection card enhancements Apr 20, 2026
@nimrodkra nimrodkra enabled auto-merge (squash) April 21, 2026 05:39
@nimrodkra nimrodkra merged commit c71ed7c into main Apr 21, 2026
13 checks passed
@nimrodkra nimrodkra deleted the feat/collection-card-enhancements branch April 21, 2026 05:44
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.

2 participants