Conversation
Signed-off-by: Simo <simo@6529.io>
📝 WalkthroughWalkthroughThis PR implements a tweet preview mode system with expandable tweet previews in drops. It introduces a context-based mode ("auto" or "never"), adds auto-collapse functionality triggered by scroll position, creates new ExpandableTweetPreview components with compact/expanded modes, and threads preview mode through link rendering to control tweet embedding behavior in markdown. Changes
Sequence DiagramsequenceDiagram
participant User
participant DropsList
participant TweetPreviewModeProvider as TweetPreviewModeProvider<br/>(mode: "auto" | "never")
participant ExpandableTweetPreview
participant MeasurementShell
participant useTweetPreviewMode as useTweetPreviewMode<br/>(hook)
participant LinkHandlers
User->>DropsList: Render drops with autoCollapseSerials
DropsList->>DropsList: Compute dropContent (full/light)
DropsList->>TweetPreviewModeProvider: Wrap with mode="auto" if serial in set
TweetPreviewModeProvider->>ExpandableTweetPreview: Provide preview mode context
ExpandableTweetPreview->>ExpandableTweetPreview: useTweet(tweetId) - fetch data
ExpandableTweetPreview->>MeasurementShell: Measure height in "auto" mode
MeasurementShell->>ExpandableTweetPreview: Return measured height
ExpandableTweetPreview->>ExpandableTweetPreview: Decide compact vs expanded
ExpandableTweetPreview->>User: Render with toggle controls
User->>ExpandableTweetPreview: Click "Show full tweet"
ExpandableTweetPreview->>ExpandableTweetPreview: Set expanded = true
ExpandableTweetPreview->>User: Re-render in expanded state
LinkHandlers->>useTweetPreviewMode: Read current mode in link handler
LinkHandlers->>ExpandableTweetPreview: Pass mode to renderTweetEmbed
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@components/tweets/ExpandableTweetPreview.tsx`:
- Around line 45-53: Reset isExpanded and measuredHeight whenever tweetId
changes to avoid carrying expansion/measurement state across tweets: add an
effect that watches tweetId and calls setIsExpanded(false) and
setMeasuredHeight(null) (and optionally clears measureRef.current) when tweetId
updates; update the component that declares isExpanded/setIsExpanded,
measuredHeight/setMeasuredHeight, and measureRef so the new tweet is re-measured
and starts collapsed.
In `@components/waves/drops/wave-drops-all/index.tsx`:
- Around line 226-256: The render currently performs state updates
(setJumpBaseline, setAutoCollapseSerials) based on
isScrolling/renderedWaveMessages, which must be moved out of the render phase;
refactor by computing derived values with useMemo or by moving the existing
logic into a useEffect that runs when isScrolling or renderedWaveMessages
change: compute the baseline set from renderedWaveMessages.drops and compute the
next autoCollapseSerials set (based on jumpBaseline and drops) inside the effect
or memo, then call setJumpBaseline/setAutoCollapseSerials only when the computed
values differ from current state (guard with equality checks) to avoid extra
renders; keep references to isScrolling, renderedWaveMessages, jumpBaseline,
autoCollapseSerials, setJumpBaseline and setAutoCollapseSerials when wiring the
effect/memo.
🧹 Nitpick comments (1)
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (1)
64-69: Consider simplifying options object creation.The conditional
tweetPreviewMode ? { tweetPreviewMode } : undefinedcan be simplified sincecreateLinkHandlersaccepts an optional options object wheretweetPreviewModeis also optional.♻️ Suggested simplification
- const handlers = createLinkHandlers( - tweetPreviewMode ? { tweetPreviewMode } : undefined - ); + const handlers = createLinkHandlers({ tweetPreviewMode });
* add contract remove for emma Signed-off-by: Simo <simo@6529.io> --------- Signed-off-by: Simo <simo@6529.io>
|



Summary by CodeRabbit
New Features
UI/Styling