Text chat 4: fluxer-emoji crate (#254) #290
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-4-emoji-crate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
New pure crate
crates/fluxer-emoji(Text chat 4, spec §4 and §7), depending only onserde/serde_json, no I/O:data.rs: the fork'sfluxer_app/src/media/data/emojis.jsonvendored unchanged (attribution in the README) and parsed once intodataset() -> &'static Dataset(OnceLock). Object order is kept (an order-preserving map visitor, nopreserve_order/indexmap), so categories and the 128 shortcuts keep the original's order.Category(8,label(),icon_name()= Phosphor component names from the spec table, pluskey()/from_key/ALL),Emoji,SkinVariant,SkinTone(6, plusmodifier()/from_modifierfor the synced preference),Emoji::with_skin -> Cow<str>,diversity() -> Option<[&str; 5]>.Dataset::{by_name, by_surrogate, in_category, all, shortcuts};by_nameincludes the keyword aliasesUnicodeEmojis.tsadds (a keyword only one emoji has),by_surrogateignores FE0F and maps skin-toned spellings to the base emoji.search.rs:search(query, limit)with the six tiers offeat/emoji/state/EmojiSearchIndex.ts(exact name, name prefix, name word boundary incl. plurals/camel case, name contains, keyword prefix, keyword contains), then frecency, thenlocaleCompareof the unique name (approximated: punctuation < digits < letters, accent-insensitive first), then dataset order; query normalised asnormalizeEmojiSearchQuery(colons, spaces,+1/?… aliases).twemoji.rs:twemoji_codepoints(FE0F rule incl. the eye-in-speech-bubble exception) andtwemoji_url.frecency.rs:Frecency { record, score, top, load, dump, merge }asUsageFrecency.ts(formula, 200 keys, tie-breaks, count cap 100 000, key length 256, clamping).emoticons.rs:emoticon_at(text) -> Option<(name, byte_len)>, first shortcut in dataset order, anchored.jumbo.rs:is_jumbo(tokens)withJumboToken::{Emoji, Text(&str), Other}(≤ 30, whitespace-only text, a text starting with:shortcode:counts as an emoji as inJumboDetector.ts).How it was tested
tests/{data,search,twemoji,frecency}.rs(emoticon and jumbo tests live indata.rs, as the Files list has no separate test files for them), plusnames_and_aliases_resolve,tiers_never_go_backwards,match_tiers,query_normalisation,limits_and_frecency,load_sanitises_like_the_original,merge_takes_the_larger_count_and_latest_use,every_dataset_emoji_has_codepoints.EmojiSearchIndex.ts+normalizeEmojiSearchQueryunder Node 22 (--experimental-strip-types) over the same JSON; the Rust output matches all of them.dataset_loads_fast(#[cfg_attr(debug_assertions, ignore)]) passes withcargo test --release -p fluxer-emoji --test data -- --include-ignored.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations from the plan
Cargo.tomlneeded no change:members = ["crates/*", …]already picks the crate up (onlyCargo.lockchanges).Emojihas public fields (names: Vec<String>,surrogates: String,keywords,category,skins) and same-named accessors (names() -> &[String],surrogates() -> &str, …), so either spelling of the Interfaces block compiles;diversity()is a method.is_jumbotakesimpl IntoIterator<Item = JumboToken>(accepts any iterator, as specified, and arrays). Compact mode (never jumbo in the original) is left to the caller.Dataset::by_shortcode(name::skin-tone-N),search_with(frecency callback),normalize_query/match_tier/compare_names(to rank guild emoji the same way),Frecency::merge(mergeWireUsageMaps),SkinTone::{modifier, from_modifier}.searchwithlimit == 0returns everything, as the original'scount0.Closes #254
🤖 Generated with Claude Code
Independent review: Text chat 4 (fluxer-emoji), commit
2d87335Scope:
git diff 0283642..origin/textchat-4-emoji-crate(cratecrates/fluxer-emoji+ Cargo.lock only).What I checked
every_surrogate_maps_back_to_its_first_name,categories_in_original_order,skin_tone_variants,search_ranks_exact_then_prefix_then_keyword,twemoji_codepoints_caseswith the six spec cases ❤️ 👨👩👧 🏳️🌈 👍🏽 🇫🇷 ©️,frecency_matches_formula_and_tie_breaks,frecency_keeps_200_keys,emoticons_match_original_list,jumbo_rule_30_and_text,dataset_loads_fastignored in debug). Labels and icons match spec §3.4 (Smiley, Leaf, BowlFood, GameController, Bicycle, Magnet, Heart, Flag); formula, 200 keys and the 30-emoji jumbo limit match.Category+label()/icon_name(),Emojifields/accessors (names,surrogates,keywords,category,diversity() -> Option<[&str; 5]>),dataset()(OnceLock),Dataset::{by_name, by_surrogate, in_category, all, shortcuts},SkinTone(6),with_skin -> Cow<str>,search(query, limit),twemoji_codepoints,twemoji_url({cdn}/emoji/{cp}.svg?v=2),Frecency::{record, score, top}+ load/dump overBTreeMap<String, (u32, i64)>,emoticon_at -> Option<(&str, usize)>,is_jumbo(takesIntoIterator, so anIteratorworks). All present.emojis.jsonis byte-identical tofluxer_app/src/media/data/emojis.json. Match tiers and boundary rule followEmojiSearchIndex.ts, the query normaliser followsnormalizeEmojiSearchQuery, codepoints followEmojiCodepointUtils.ts(including the eye-in-speech-bubble exception), frecency sanitising and tie-breaks followUsageFrecency.ts(compareStrings = UTF-16 order), and keyword aliases followbuildEmojiIndex. The emoticon order matches the JSObject.keysorder: no integer-like keys, no duplicates, and no shortcut is a prefix of a later one.compare_names(the implementer's flagged approximation): I sorted all 1940 unique names with Node 22localeCompareand withcompare_names. The two orders are identical.include_str!); no paths, URLs or secrets in code. On server-sourced input (frecency maps, shortcodes, surrogates, queries) I found no panic path: clamp bounds are safe, and indexing is guarded.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green in a clean review worktree.cargo test --release -p fluxer-emoji -- --include-ignoredalso passes (dataset_loads_fast < 50 ms).Findings
search("", n)returns the firstnemoji. The original'sEmojiSearchIndex.searchreturns every emoji for an empty query and ignorescount. This is harmless for the picker (it does not search with an empty query), but it is a small divergence. Either document it or drop the cap.by_surrogatemaps every skin-toned spelling to the base emoji, including the 20 non-uniform multi-person combinations, for which the original'ssurrogateToNamegives the variant's own name. This is documented. Task 8 needs to know about it: when rendering, it must build the Twemoji URL from the source text, not fromemoji.surrogates, or toned emoji will draw untoned.Frecency::load(map, now_ms)sanitises likesanitizeUsageMap: it clampslast_usedtonow, drops entries with count 0 or an invalid key, and prunes to 200. Soloadthendumpis not the identity. This matches the original, but Task 14 must write frecency back only through the picker-field edit of the Task 3 codec, so the byte-for-byte round-trip of the other fields still holds.No blocking findings.
Verdict: approve (0 blocking, 3 minor; ci green locally).