Text chat 8: Inline-flow text and emoji images (#258) #296

Manually merged
charles merged 4 commits from textchat-8-ui-inline-flow-emoji into textchat 2026-11-12 13:49:39 +00:00
Owner

Stacked on: textchat-4-emoji-crate, textchat-7-platform-files-clipboard

What

  • fluxer-core::media_urls: custom_emoji(&endpoints, id, animated, size), sticker(&endpoints, id, animated, size), twemoji(&endpoints, surrogates) (strings of buildCustomEmojiURL, getStickerURL, EmojiUtils.getEmojiURL). fluxer-core gains the fluxer-emoji dependency (the one the plan allows) for Twemoji code points.
  • fluxer-ui::widgets::inline_flow: InlineFlow::new(runs) with Run::{Text, Box, Break}; breaks at word boundaries and between CJK characters, cuts overlong words, boxes on the baseline (vertical-align: -0.4em), lines grow to hold them, layout cached per width (LayoutCache), word widths cached for the paragraph's life. Clickable text runs (links, spoilers).
  • fluxer-ui::widgets::emoji: EmojiRef, view, url, wanted, and parser_context(content), a port of buildEmojiContext (S/C/K lines from the fluxer-emoji dataset) so the fork's parser makes :name:, :name::skin-tone-N: and Unicode emoji into Node::Emoji (©/™/® stay text).
  • rich_text: SpanModel::emoji, is_jumbo, wanted / wanted_animated, flow_shapes; paragraphs with emoji are drawn by the flow at 1.5 em (3 rem jumbo) when RenderCtx::emoji is set; media::wanted requests the open channel's emoji (animated ones when animate_emoji).
  • Spike: docs/superpowers/research/2026-11-12-textchat-spikes.md §1. 120 basic messages lay out in < 2 ms cold (median 12 µs, p99 59 µs), ~0.2 ms after a resize; no fallback needed.

Deviations from the plan

  • emoji::view(&EmojiRef, size, &EmojiImages, animate): the third argument is EmojiImages { images, endpoints, elapsed } instead of &Images, because the URL needs the endpoints and an animated frame needs the clock.
  • Run::Text has extra fields underline, strikethrough, on_press (links/spoilers) and color: Option<Color>; Run::text(..) builds a plain one.
  • RenderCtx gains emoji: Option<EmojiImages> and animate_emoji: bool (callers updated).
  • RTL paragraphs and profile bios still draw emoji as system glyphs: follow-up #295.

Tests

  • crates/fluxer-ui/tests/inline_flow.rs: wraps_text_and_boxes_at_width, box_baseline_aligns_with_text, layout_cached_per_width, custom_and_unicode_emoji_become_boxes, shortcode_in_text_becomes_emoji_node, jumbo_only_for_emoji_only_messages, wanted_lists_twemoji_and_custom_urls, mention_pill_has_background; ignored spike_layout_cost (measurement).
  • crates/fluxer-core/tests/media_urls.rs: custom emoji, sticker and Twemoji URL tests.
  • Screenshots rich_text_emoji, rich_text_jumbo (stand-in SVGs for Twemoji). Goldens were written on this machine's GPU, not lavapipe (not installed); existing goldens are unchanged and passed here. No Electron side-by-side attached: reviewer please compare with an Electron message containing emoji.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No desktop-only tests in this task.

#40

Verified on the base: LinkClicked -> UserAction::OpenUrl -> Effect::OpenUrl (runtime opens it), SpoilerToggled toggles per-message state in messages::State, utc_offset/now_unix set by the shell. Nothing left to do.

Closes #258
Closes #40

🤖 Generated with Claude Code

Stacked on: textchat-4-emoji-crate, textchat-7-platform-files-clipboard ## What - `fluxer-core::media_urls`: `custom_emoji(&endpoints, id, animated, size)`, `sticker(&endpoints, id, animated, size)`, `twemoji(&endpoints, surrogates)` (strings of `buildCustomEmojiURL`, `getStickerURL`, `EmojiUtils.getEmojiURL`). fluxer-core gains the `fluxer-emoji` dependency (the one the plan allows) for Twemoji code points. - `fluxer-ui::widgets::inline_flow`: `InlineFlow::new(runs)` with `Run::{Text, Box, Break}`; breaks at word boundaries and between CJK characters, cuts overlong words, boxes on the baseline (`vertical-align: -0.4em`), lines grow to hold them, layout cached per width (`LayoutCache`), word widths cached for the paragraph's life. Clickable text runs (links, spoilers). - `fluxer-ui::widgets::emoji`: `EmojiRef`, `view`, `url`, `wanted`, and `parser_context(content)`, a port of `buildEmojiContext` (S/C/K lines from the `fluxer-emoji` dataset) so the fork's parser makes `:name:`, `:name::skin-tone-N:` and Unicode emoji into `Node::Emoji` (©/™/® stay text). - `rich_text`: `SpanModel::emoji`, `is_jumbo`, `wanted` / `wanted_animated`, `flow_shapes`; paragraphs with emoji are drawn by the flow at 1.5 em (3 rem jumbo) when `RenderCtx::emoji` is set; `media::wanted` requests the open channel's emoji (animated ones when `animate_emoji`). - Spike: `docs/superpowers/research/2026-11-12-textchat-spikes.md` §1. 120 `basic` messages lay out in < 2 ms cold (median 12 µs, p99 59 µs), ~0.2 ms after a resize; **no fallback needed**. ## Deviations from the plan - `emoji::view(&EmojiRef, size, &EmojiImages, animate)`: the third argument is `EmojiImages { images, endpoints, elapsed }` instead of `&Images`, because the URL needs the endpoints and an animated frame needs the clock. - `Run::Text` has extra fields `underline`, `strikethrough`, `on_press` (links/spoilers) and `color: Option<Color>`; `Run::text(..)` builds a plain one. - `RenderCtx` gains `emoji: Option<EmojiImages>` and `animate_emoji: bool` (callers updated). - RTL paragraphs and profile bios still draw emoji as system glyphs: follow-up #295. ## Tests - `crates/fluxer-ui/tests/inline_flow.rs`: wraps_text_and_boxes_at_width, box_baseline_aligns_with_text, layout_cached_per_width, custom_and_unicode_emoji_become_boxes, shortcode_in_text_becomes_emoji_node, jumbo_only_for_emoji_only_messages, wanted_lists_twemoji_and_custom_urls, mention_pill_has_background; ignored `spike_layout_cost` (measurement). - `crates/fluxer-core/tests/media_urls.rs`: custom emoji, sticker and Twemoji URL tests. - Screenshots `rich_text_emoji`, `rich_text_jumbo` (stand-in SVGs for Twemoji). Goldens were written on this machine's GPU, not lavapipe (not installed); existing goldens are unchanged and passed here. No Electron side-by-side attached: reviewer please compare with an Electron message containing emoji. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No desktop-only tests in this task. ## #40 Verified on the base: `LinkClicked` -> `UserAction::OpenUrl` -> `Effect::OpenUrl` (runtime opens it), `SpoilerToggled` toggles per-message state in `messages::State`, `utc_offset`/`now_unix` set by the shell. Nothing left to do. Closes #258 Closes #40 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #254

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
custom_emoji, sticker and twemoji in media_urls, the strings of the web
app's buildCustomEmojiURL (CustomEmojiImageUrl.ts), getStickerURL
(AvatarUtils.ts:583-603) and getEmojiURL (EmojiUtils.ts:27-53).
fluxer-core gains fluxer-emoji for the Twemoji code points.

Refs #258

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
widgets::inline_flow lays out text runs and fixed boxes on shared lines
(word breaks, CJK breaks, overlong words cut, boxes on the baseline,
layout cached per width). widgets::emoji draws Twemoji SVGs and custom
emoji WebP and builds the parser's emoji context from fluxer-emoji
(buildEmojiContext of MarkdownParserWasm.ts), so :name: and Unicode
emoji become emoji nodes. rich_text draws paragraphs with emoji through
the flow (1.5 em, 3 rem jumbo), lists their URLs (rich_text::wanted) and
media::wanted requests them. Spike findings in the textchat spikes doc
section 1; screenshots rich_text_emoji and rich_text_jumbo.

Refs #258

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Independent review: Text chat 8 (inline flow and emoji images)

Scope: git diff 5c3660d..origin/textchat-8-ui-inline-flow-emoji (commits c7cd884 and 9fe1330). The branch merges cleanly into the current origin/textchat.

Verdict: approved. 0 blocking findings, 4 minor. Local FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green (exit 0).

Checks

  1. Plan tests: all 8 named tests are in crates/fluxer-ui/tests/inline_flow.rs and assert what the plan describes. The screenshots rich_text_emoji and rich_text_jumbo have goldens and rows in docs/screenshots/README.md. spike_layout_cost is #[ignore] (it measures). I checked the values against the fork. --emoji-size-emoji: 1.5em and --emoji-size-jumbo-emoji: 3rem come from globals.css:198-199. --markup-inline-emoji-baseline-shift: -0.4em comes from Markup.module.css:9, which is 6.4 px at 16 px. CUSTOM_EMOJI_IMAGE_RUNG is 128 and CUSTOM_EMOJI_ENLARGED_IMAGE_RUNG is 240. The sticker size is 320 or 160 and size comes before animated. The Twemoji URL is {static}/emoji/{cp}.svg?v=2. All match.
  2. Interfaces: InlineFlow::new(Vec<Run>) exists. Run::{Text, Box{width,height,baseline_shift,content}, Break} exists. EmojiRef::{Unicode(String), Custom{id,name,animated}} exists. rich_text::wanted(&nodes, &endpoints) -> Vec<Url> exists. media_urls::{custom_emoji, sticker, twemoji} take (&endpoints, id, animated, size) and (&endpoints, surrogates). Each of these is written as the plan states. The deviations are documented in the PR, the README and spikes §1, and later tasks will build on the merged code. See minor 1.
  3. Invariants:
    • fluxer-core gains only fluxer-emoji, and the core-isolation check passes.
    • fluxer-ui adds no I/O. Emoji images go through the existing Images/ImageLoader.
    • No fixtures were added. well_known.json is reused.
    • No secrets, paths or signed URLs.
    • Panic review: match_surrogates and shortcodes slice only on char boundaries. In place_word, the long-word cut always makes progress, and bounds is never empty. Custom emoji ids that fail to parse are dropped. parse_message still falls back to plain text when it fails. In the widget, runs[fragment.run] is protected by the shape-key reset in diff.
  4. Review Focus: no item belongs to Task 8. On item 7 (server data never panics), I found no panic path: see the panic review above.
  5. #40: confirmed on the base. messages.rs:206-209 and profile_popout.rs:345 handle LinkClicked and SpoilerToggled.
  6. Port of buildEmojiContext: it uses byte offsets and lengths like MarkdownParserWasm.ts:244-294 (Utf8OffsetTracker). It handles PLAINTEXT_SYMBOLS, SPECIAL_SHORTCODES, the C/K lines and the shortcode regex scan the same way.

Findings

  • minor: emoji::view takes &EmojiImages{images,endpoints,elapsed} instead of the plan's &Images, and Run::Text has extra fields. Both are documented and reasonable. Tasks 22/24/25/27 must use the merged signatures.
  • minor: fluxer_ui::widgets::emoji::EmojiRef will exist next to the core EmojiRef that Text chat 10 introduces (used by PickEmoji and ReactionModel). The UI cannot depend on a core type that does not exist yet, so this is expected. Text chat 10/24 should add a From conversion, or have the UI re-export the core type once it lands, so there are not two diverging enums.
  • minor (unverified): the goldens rich_text_emoji.png and rich_text_jumbo.png were drawn on a local GPU, not on lavapipe. This machine has no lavapipe ICD either, so I could not check them. The existing lavapipe goldens pass on GPU within tolerance, so these probably pass on the runner. The integrator must confirm on the Linux runner, and regenerate them there with UPDATE_GOLDEN=1 if they fail.
  • minor: is_shortcode_char uses char::is_alphanumeric (Alphabetic + Numeric). That is slightly broader than [\p{L}\p{N}_-], because it also accepts Other_Alphabetic marks. The only effect is an extra C-line lookup that finds nothing. It cannot affect output for real emoji names.

No Electron side-by-side is attached (the PR says so). Follow-up #295 (RTL and bios) is linked.

CI

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a clean review worktree at 9fe1330 exited 0. That covers fmt, clippy, deny, core isolation, parity, all tests and the screenshot tests, including the two new ones. I did not check the remote runners.

## Independent review: Text chat 8 (inline flow and emoji images) Scope: `git diff 5c3660d..origin/textchat-8-ui-inline-flow-emoji` (commits c7cd884 and 9fe1330). The branch merges cleanly into the current `origin/textchat`. **Verdict: approved. 0 blocking findings, 4 minor. Local `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is green (exit 0).** ### Checks 1. **Plan tests:** all 8 named tests are in `crates/fluxer-ui/tests/inline_flow.rs` and assert what the plan describes. The screenshots `rich_text_emoji` and `rich_text_jumbo` have goldens and rows in `docs/screenshots/README.md`. `spike_layout_cost` is `#[ignore]` (it measures). I checked the values against the fork. `--emoji-size-emoji: 1.5em` and `--emoji-size-jumbo-emoji: 3rem` come from `globals.css:198-199`. `--markup-inline-emoji-baseline-shift: -0.4em` comes from `Markup.module.css:9`, which is 6.4 px at 16 px. `CUSTOM_EMOJI_IMAGE_RUNG` is 128 and `CUSTOM_EMOJI_ENLARGED_IMAGE_RUNG` is 240. The sticker size is 320 or 160 and `size` comes before `animated`. The Twemoji URL is `{static}/emoji/{cp}.svg?v=2`. All match. 2. **Interfaces:** `InlineFlow::new(Vec<Run>)` exists. `Run::{Text, Box{width,height,baseline_shift,content}, Break}` exists. `EmojiRef::{Unicode(String), Custom{id,name,animated}}` exists. `rich_text::wanted(&nodes, &endpoints) -> Vec<Url>` exists. `media_urls::{custom_emoji, sticker, twemoji}` take `(&endpoints, id, animated, size)` and `(&endpoints, surrogates)`. Each of these is written as the plan states. The deviations are documented in the PR, the README and spikes §1, and later tasks will build on the merged code. See minor 1. 3. **Invariants:** - fluxer-core gains only `fluxer-emoji`, and the core-isolation check passes. - fluxer-ui adds no I/O. Emoji images go through the existing `Images`/`ImageLoader`. - No fixtures were added. `well_known.json` is reused. - No secrets, paths or signed URLs. - Panic review: `match_surrogates` and `shortcodes` slice only on char boundaries. In `place_word`, the long-word cut always makes progress, and `bounds` is never empty. Custom emoji ids that fail to parse are dropped. `parse_message` still falls back to plain text when it fails. In the widget, `runs[fragment.run]` is protected by the shape-key reset in `diff`. 4. **Review Focus:** no item belongs to Task 8. On item 7 (server data never panics), I found no panic path: see the panic review above. 5. **#40:** confirmed on the base. `messages.rs:206-209` and `profile_popout.rs:345` handle `LinkClicked` and `SpoilerToggled`. 6. **Port of `buildEmojiContext`:** it uses byte offsets and lengths like `MarkdownParserWasm.ts:244-294` (`Utf8OffsetTracker`). It handles `PLAINTEXT_SYMBOLS`, `SPECIAL_SHORTCODES`, the C/K lines and the shortcode regex scan the same way. ### Findings - **minor:** `emoji::view` takes `&EmojiImages{images,endpoints,elapsed}` instead of the plan's `&Images`, and `Run::Text` has extra fields. Both are documented and reasonable. Tasks 22/24/25/27 must use the merged signatures. - **minor:** `fluxer_ui::widgets::emoji::EmojiRef` will exist next to the core `EmojiRef` that Text chat 10 introduces (used by `PickEmoji` and `ReactionModel`). The UI cannot depend on a core type that does not exist yet, so this is expected. Text chat 10/24 should add a `From` conversion, or have the UI re-export the core type once it lands, so there are not two diverging enums. - **minor (unverified):** the goldens `rich_text_emoji.png` and `rich_text_jumbo.png` were drawn on a local GPU, not on lavapipe. This machine has no lavapipe ICD either, so I could not check them. The existing lavapipe goldens pass on GPU within tolerance, so these probably pass on the runner. The integrator must confirm on the Linux runner, and regenerate them there with `UPDATE_GOLDEN=1` if they fail. - **minor:** `is_shortcode_char` uses `char::is_alphanumeric` (Alphabetic + Numeric). That is slightly broader than `[\p{L}\p{N}_-]`, because it also accepts Other_Alphabetic marks. The only effect is an extra C-line lookup that finds nothing. It cannot affect output for real emoji names. No Electron side-by-side is attached (the PR says so). Follow-up #295 (RTL and bios) is linked. ### CI `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a clean review worktree at 9fe1330 exited 0. That covers fmt, clippy, deny, core isolation, parity, all tests and the screenshot tests, including the two new ones. I did not check the remote runners.
charles manually merged commit 75adadb616 into textchat 2026-11-12 13:49:39 +00:00
Sign in to join this conversation.
No description provided.