Skip to content

Fixed tweet sizes#1874

Merged
simo6529 merged 10 commits intomainfrom
fixed-tweet-sizes
Feb 3, 2026
Merged

Fixed tweet sizes#1874
simo6529 merged 10 commits intomainfrom
fixed-tweet-sizes

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Feb 3, 2026

Summary by CodeRabbit

  • New Features

    • Expandable tweet previews with toggle control to view full content
    • Auto-collapse feature for tweet previews in drops and waves based on configurable settings
    • Tweet preview mode system enabling adaptive display behavior across components
  • UI/Styling

    • Enhanced visual presentation with fade gradient overlays on compact tweet views
    • Improved layout states for compact versus expanded tweet display modes
    • Added visual toggle control for expanding collapsed tweet previews

Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Tweet Preview Mode Context
components/tweets/TweetPreviewModeContext.tsx
New context provider and hook for managing tweet preview modes ("auto" | "never"); enables components to control preview behavior.
Expandable Tweet Preview Components
components/tweets/ExpandableTweetPreview.tsx, components/tweets/ExpandableTweetPreview.types.ts, components/tweets/ExpandableTweetPreviewCompactContent.tsx, components/tweets/ExpandableTweetPreviewExpandedContent.tsx, components/tweets/ExpandableTweetPreviewCompactControls.tsx, components/tweets/ExpandableTweetPreviewMeasurementShell.tsx, components/tweets/ExpandableTweetPreview.module.css
New expandable tweet preview system supporting auto-compact mode via height measurement, with compact/expanded rendering states, toggle controls, and CSS-driven layout transitions.
Drop List Auto-Collapse
components/drops/view/DropsList.tsx, components/waves/drops/wave-drops-all/index.tsx, components/waves/drops/wave-drops-all/subcomponents/WaveDropsContent.tsx, components/waves/drops/wave-drops-all/subcomponents/WaveDropsMessageListSection.tsx
Added autoCollapseSerials prop to control which drops auto-collapse previews via TweetPreviewModeProvider wrapping; wired context through drop rendering pipeline.
Link Rendering with Preview Mode
components/drops/view/part/DropPartMarkdown.tsx, components/drops/view/part/dropPartMarkdown/linkHandlers.tsx, components/drops/view/part/dropPartMarkdown/handlers/index.ts, components/drops/view/part/dropPartMarkdown/handlers/twitter.tsx, components/drops/view/part/dropPartMarkdown/renderers.tsx
Threaded tweetPreviewMode through markdown link rendering pipeline; replaced TweetEmbed with ExpandableTweetPreview for dynamic tweet loading and preview control.
Tweet Embedding Updates
components/home/boosted/BoostedTweetPreview.tsx, components/home/boosted/BoostedTweetPreview.module.css
Replaced static TweetEmbed rendering with ExpandableTweetPreview; removed custom CSS overrides now handled by expandable component.
Scroll-Based Auto-Collapse
components/waves/drops/wave-drops-all/hooks/useWaveDropsSerialScroll.ts
Added baseline tracking and frozen auto-collapse state to compute which drops auto-collapse during scrolling; supports finalization and baseline pinning across scroll lifecycle.
Minor Styling
components/drops/view/item/content/media/MediaDisplayImage.tsx
Removed horizontal margin utility from media display container.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • prevent nesting #1605: Both PRs modify link rendering plumbing to thread contextual options (tweetPreviewMode vs. currentDropId) through createLinkRenderer and handlers.
  • Collapsible drop #1866: Both PRs implement collapsible/preview wrapping for drops and modify Wave/Drop render paths by adding props like autoCollapseSerials and wrapContentOnly.
  • Touch devices fix, scroll to fist unread update #1788: Both PRs modify WaveDropsAll, WaveDropsContent, and WaveDropsMessageListSection by adding/propagating new props (autoCollapseSerials vs. onScrollToUnread) to control drop rendering behavior.

Suggested reviewers

  • prxt6529

🐰 A tweet preview dance, expandable with care,
Auto-collapse cascades through the scrolling air,
Compact then expanded, at the user's command,
Context now flows where the drops once stood.
Measurement shells guide what should unfold! 📱✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fixed tweet sizes' is vague and does not clearly convey the main changes. The PR introduces substantial new functionality including TweetPreviewMode context, ExpandableTweetPreview component, auto-collapse feature for drops, and significant refactoring of tweet rendering, none of which is reflected in the generic title. Consider a more specific title that captures the primary change, such as 'Add expandable tweet preview with auto-collapse support in drops' or 'Refactor tweet rendering with collapsible preview mode'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fixed-tweet-sizes

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 } : undefined can be simplified since createLinkHandlers accepts an optional options object where tweetPreviewMode is also optional.

♻️ Suggested simplification
-  const handlers = createLinkHandlers(
-    tweetPreviewMode ? { tweetPreviewMode } : undefined
-  );
+  const handlers = createLinkHandlers({ tweetPreviewMode });

Comment thread components/tweets/ExpandableTweetPreview.tsx
Comment thread components/waves/drops/wave-drops-all/index.tsx Outdated
* add contract remove for emma

Signed-off-by: Simo <simo@6529.io>

---------

Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 3, 2026

@simo6529 simo6529 merged commit 86fcbed into main Feb 3, 2026
7 checks passed
@simo6529 simo6529 deleted the fixed-tweet-sizes branch February 3, 2026 18:21
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