Skip to content

Add Windows twemoji fallback and use in picker - #79

Merged
willianpm merged 3 commits into
masterfrom
bugfix/77-emoji-cross-platform-font
May 18, 2026
Merged

Add Windows twemoji fallback and use in picker#79
willianpm merged 3 commits into
masterfrom
bugfix/77-emoji-cross-platform-font

Conversation

@willianpm

@willianpm willianpm commented May 18, 2026

Copy link
Copy Markdown
Owner

This pull request improves emoji rendering across the application, especially for Windows users, by introducing Twemoji SVG image rendering for Unicode emojis when appropriate. It also enhances emoji picker consistency and error handling for emoji image fallbacks. The main changes are grouped below.

Emoji Rendering Enhancements:

  • Added a new utility module emoji-rendering.ts that detects the user's platform and determines whether Unicode emojis should be rendered as images (using Twemoji SVGs) on Windows, along with helpers to generate Twemoji image URLs.
  • Updated EmojiRenderer.tsx to render Unicode emojis as images on Windows, fall back to text if the image fails to load, and reset error state when emoji props change. [1] [2] [3] [4] [5]

Emoji Picker Improvements:

  • Modified PollEmojiPickerField.tsx to use Twemoji images in the emoji picker on Windows, show a Unicode emoji preview as an image when appropriate, and handle image load errors gracefully. [1] [2] [3] [4] [5] [6]
  • Updated emoji picker mocks in tests to support the new TWITTER emoji style. [1] [2]

Testing Improvements:

  • Added and updated tests in EmojiRenderer.test.tsx to simulate different platforms by overriding the user agent, ensuring correct fallback and image rendering behavior on Windows. [1] [2]

Summary by CodeRabbit

  • New Features

    • Enhanced emoji rendering with platform-aware display logic and automatic fallback to text when images cannot load.
    • Improved emoji preview functionality in poll creation with better cross-platform compatibility support.
  • Bug Fixes

    • Fixed emoji rendering to gracefully handle image load failures with text fallback.
  • Tests

    • Updated test suite to validate emoji rendering behavior across different platforms and edge cases.

Review Change Stack

@willianpm willianpm self-assigned this May 18, 2026
@willianpm willianpm linked an issue May 18, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@willianpm has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 40 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d6401b0-341d-4392-bf11-461dc8b58a31

📥 Commits

Reviewing files that changed from the base of the PR and between f5404a3 and e166a71.

📒 Files selected for processing (1)
  • dashboard/frontend/src/app/lib/emoji-rendering.ts
📝 Walkthrough

Walkthrough

This PR implements Windows-specific Twemoji image rendering for Unicode emojis with native emoji fallback. A new utility module detects the Windows platform and generates Twemoji CDN URLs. EmojiRenderer refactors failure tracking into separate flags for custom and Unicode emoji images, and PollEmojiPickerField integrates Unicode image rendering with dynamic picker style selection.

Changes

Windows emoji rendering with fallback

Layer / File(s) Summary
Emoji rendering utilities and platform detection
dashboard/frontend/src/app/lib/emoji-rendering.ts
New utility module provides Windows detection and Twemoji CDN URL generation for valid Discord Unicode emojis; exports three functions for conditional image URL retrieval, image rendering decisions, and picker style selection.
EmojiRenderer component refactoring for split failure tracking
dashboard/frontend/src/app/components/EmojiRenderer.tsx
Replaces single imageFailed flag with separate customImageFailed and unicodeImageFailed state; adds useEffect to reset both on emoji prop changes; updates all rendering branches to gate on and set the appropriate failure flag.
EmojiRenderer test coverage for Windows emoji rendering
dashboard/frontend/src/app/components/EmojiRenderer.test.tsx
Adds user agent mocking setup and teardown; new test simulates Windows platform, asserts Unicode emoji renders as SVG image with expected codepoint pattern, and verifies fallback to text after triggering image load error.
PollEmojiPickerField integration with Twemoji utilities
dashboard/frontend/src/app/components/PollEmojiPickerField.tsx
Imports emoji utilities; adds unicodePreviewFailed state and effect to reset on Unicode change; derives image URL and conditionally renders image or text fallback; computes pickerEmojiStyle from platform detection and wires it to EmojiPicker component.
Test mock updates for EmojiStyle.TWITTER
dashboard/frontend/src/app/pages/CreatePoll.test.tsx, dashboard/frontend/src/app/pages/PollDrafts.test.tsx
Adds TWITTER entry to mocked EmojiStyle enum to support dynamic picker style selection based on Windows platform detection.

Sequence Diagram

sequenceDiagram
  participant User
  participant PollEmojiPickerField
  participant EmojiRendering
  participant Browser
  participant TwemojiCDN
  
  User->>PollEmojiPickerField: Select Unicode emoji on Windows
  PollEmojiPickerField->>EmojiRendering: getUnicodeEmojiImageUrl(emoji)
  EmojiRendering->>Browser: Detect Windows platform
  Browser-->>EmojiRendering: Platform is Windows
  EmojiRendering-->>PollEmojiPickerField: Return Twemoji CDN URL
  PollEmojiPickerField->>TwemojiCDN: Request emoji SVG image
  alt Image loads successfully
    TwemojiCDN-->>PollEmojiPickerField: SVG image data
    PollEmojiPickerField->>User: Render Twemoji image
  else Image load fails
    TwemojiCDN--xPollEmojiPickerField: Load error
    PollEmojiPickerField->>User: Fallback to native emoji text
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • willianpm/LittleBoatPoll#72: Both PRs implement the custom/Discord-emoji feature on the frontend—specifically the emoji rendering and picking pipeline (EmojiRenderer, PollEmojiPickerField, and related emoji metadata handling).

Poem

🐰 Windows users grin with glee,
Twemoji renders SVG,
SVG breaks? No matter, friend—
Native emoji saves the day in the end!
Fallback flows, like autumn leaves. 🍃

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the primary change: adding Windows Twemoji fallback support and integrating it into the emoji picker.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/77-emoji-cross-platform-font

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@dashboard/frontend/src/app/lib/emoji-rendering.ts`:
- Around line 26-31: The function toTwemojiCodepoints is producing zero-padded
4-digit hex codepoints which breaks Twemoji CDN URLs; update it so that after
mapping code points to hex (codepoint.toString(16)) you do not call .padStart(4,
'0') — just use the raw hex strings joined with '-' (preserve the existing
Array.from/map/filter flow in toTwemojiCodepoints and remove only the padStart
call) so low-range codepoints like U+00A9 become "a9" instead of "00a9".
🪄 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

Run ID: 9169d405-9dc3-490a-84dd-b517cbcee8aa

📥 Commits

Reviewing files that changed from the base of the PR and between 06a3a8d and f5404a3.

📒 Files selected for processing (6)
  • dashboard/frontend/src/app/components/EmojiRenderer.test.tsx
  • dashboard/frontend/src/app/components/EmojiRenderer.tsx
  • dashboard/frontend/src/app/components/PollEmojiPickerField.tsx
  • dashboard/frontend/src/app/lib/emoji-rendering.ts
  • dashboard/frontend/src/app/pages/CreatePoll.test.tsx
  • dashboard/frontend/src/app/pages/PollDrafts.test.tsx

Comment thread dashboard/frontend/src/app/lib/emoji-rendering.ts
@willianpm
willianpm merged commit 9b449a3 into master May 18, 2026
4 checks passed
@willianpm
willianpm deleted the bugfix/77-emoji-cross-platform-font branch May 18, 2026 20:08
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.

Some emojis render correctly on mobile but not on desktop browsers

1 participant