In-app GIF Picker (Tenor) — Design¶
Date: 2026-06-25 Status: Approved (design); ready for implementation planning Topic: Let users search and insert GIFs into posts, comments, and chat from an in-app picker instead of pasting URLs.
Problem¶
Today a user can only attach a GIF by pasting a URL (a Tenor/Giphy share link or a
direct image URL) into the compose box’s “Add Image” field (ComposeBox.tsx). The app
already renders Tenor/Giphy GIFs well — components/feed/GifEmbed.tsx parses share and
direct-media URLs, and components/shared/ChatMediaEmbed.tsx auto-embeds media URLs found
in chat text. What’s missing is a way to discover and pick a GIF in-app.
This adds a searchable GIF picker, powered by Tenor (Google), and wires it into every surface that can carry a GIF.
Provider decision¶
Tenor, not Giphy:
Free API with a generous quota; no billing setup.
GifEmbedalready resolvesmedia*.tenor.comandtenor.com/view/...URLs, so picked GIFs render with zero rendering changes.Single Google API key.
Architecture¶
One picker component + one server proxy, reused across all surfaces. The picker’s entire
contract is onSelect(url: string) — the caller decides what to do with the returned
direct GIF URL. This single abstraction is what lets posts, comments, and chat all reuse it
despite carrying GIFs differently.
How each surface carries a GIF (existing behavior — do not change)¶
Surface |
Mechanism |
Renderer |
|---|---|---|
Post compose / modal |
structured |
|
Edit post |
not supported today (edit only sends |
— |
Comments |
only |
|
rmhtube chat |
URL inline in message |
|
DMs |
URL inline in |
plain text |
The picker returns a URL; for structured surfaces the caller sets gifUrl, for text
surfaces the caller inserts the URL into the message/comment text.
Components¶
1. Server proxy — app/routes/api/gif/search.ts¶
GET /api/gif/search?q=<query>&pos=<cursor>Empty
q→ Tenor/v2/featured(trending on open). Non-empty →/v2/search.Server-side call to Tenor v2 using
TENOR_API_KEY(+ optionalTENOR_CLIENT_KEY,locale). Key never reaches the client.Query params sent to Tenor:
media_filter=tinygif,gif,contentfilter=high(SFW),limit=24.Normalizes each result to
{ id, description, preview, url, width, height }wherepreview=tinygifURL (grid thumbnail) andurl=gifURL (inserted on select).Returns
{ results, next };nextis Tenor’s pagination cursor for infinite scroll.Per-user rate limiting reusing the limiter pattern in
app/routes/api/feed/mention-search.ts/hashtag-search.ts.If
TENOR_API_KEYis unset: respond503with{ error: "GIF search unavailable" }. The picker treats this as “feature off” and hides its trigger.
2. Picker component — components/feed/GifPicker.tsx¶
Props:
onSelect(url: string) => void, optionalonClose?(), optionalclassName?.Behavior:
On open: fetch trending (
/api/gif/searchwith noq).Debounced (~300ms) search input.
2-column preview grid of
previewthumbnails (lazy-loaded<img>).Infinite scroll via
nextcursor (IntersectionObserver sentinel).Loading skeletons, empty state, error state.
“Powered by Tenor” attribution badge (Tenor TOS requirement).
i18n via
useTranslation('feed'), matching surrounding components.Click a GIF →
onSelect(result.url)thenonClose?.().
Self-contained panel; each caller positions it (popover above an input, or inline in the attachment area).
3. Env / config¶
Add
TENOR_API_KEYandTENOR_CLIENT_KEYto.env.examplewith comments and a link to the Tenor key console (Google Cloud → Tenor API). Setup is an operational step, documented in the spec; the feature degrades gracefully when the key is absent.
Integration per surface¶
A. Post composer — ComposeBox.tsx + ComposeModal.tsx¶
Replace the gif URL
<input>(andisValidMediaUrlgating) with<GifPicker onSelect={(u) => setGifUrl(u)} />.Show the selected GIF via the existing
GifEmbedwith a remove (×) button (already the pattern for the current preview).gifUrlstate,buildBody().gifUrl, and the server endpoint are unchanged.
B. Edit post — EditPostModal.tsx¶
Add the picker + selected-GIF preview.
Extend the post-update endpoint and the modal’s PATCH body to accept and persist
gifUrl(currently onlycontentis sent). Supports add / swap / remove on existing posts.
C. Comments — CommentThread.tsx reply box + CommentItem.tsx reply box + render¶
Add a GIF button next to the reply input; on select, insert the URL into the comment text.
Add an auto-embed render path: in
CommentItem, run commentcontentthroughextractMediaEmbeds+stripEmbedUrls(fromcomponents/shared/ChatMediaEmbed.tsx), render the embed(s), and pass the stripped text toRMHarkContent. No comment schema change — the GIF rides incontent, matching the chat pattern.
D. Chat — components/rmhtube/ChatPanel.tsx + DMs components/feed/ConversationView.tsx¶
Add the GIF button to both message inputs; insert the URL on select.
rmhtube already renders media via
ChatMediaEmbed— no render change.DMs do not auto-embed today: add the same
ChatMediaEmbedrender path (extractMediaEmbeds+stripEmbedUrls) to the DM message renderer.
Error handling¶
Endpoint: missing key →
503“unavailable” (picker hides); Tenor error/timeout →502with empty results; rate limit exceeded →429(picker shows a brief “slow down” state).Picker: network/JSON failure → inline error with retry; empty results → “No GIFs found”.
Selected GIF that 404s at render time is already handled by
GifEmbed/ChatMediaEmbederror states (broken-image fallback).
Testing¶
Endpoint unit tests: trending (no
q) vs search (q) routing; Tenor response → normalized shape; missing key → 503; rate-limit path → 429. Tenor HTTP mocked.Picker component tests: renders trending on open; debounced search refetches; clicking a result calls
onSelectwith thegifURL; error and empty states render.Integration smoke: ComposeBox sets
gifUrlfrom picker and submits; comment insert +stripEmbedUrlsremoves the raw URL from rendered text while the embed shows.Follow existing test conventions (vitest; see
vitest.config.ts).
Out of scope (YAGNI)¶
Giphy as a second provider / provider toggle.
Keeping the manual URL-paste field (the picker replaces it).
GIF categories/emoji-trending tabs, favorites, or recently-used history.
Animated stickers, video, or non-GIF Tenor media types.
Rollout / phasing¶
Single plan, but implement in this order so the core ask lands first and de-risks the rest:
Core: endpoint +
GifPicker+ env (Section 1–3).Posts: ComposeBox + ComposeModal (Section A).
Edit / Comments / Chat / DMs: Sections B–D, each a thin reuse of 1–2.