Repository navigation
feat(emoji): rank typed suggestions by shared picker usage - #4156
Conversation
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord — Changes needed at 2c5cb83. In this source-only review, recording a choice can overwrite Huddle history, and dismissing the first-pick tone menu can change suggestion rankings. Please confirm the scope of the public callback and which pickers should train the composer.
2c5cb83 to
8c9e6d5
Compare
8c9e6d5 to
29c2c95
Compare
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord. Changes needed at 29c2c95. The source review found that usage can reorder a literal shortcode match and can count edits the composer never applied. Whether unsaved avatar previews should train suggestions is still open in the existing thread.
8f4b333 to
e6bfa25
Compare
e6bfa25 to
fca7f21
Compare
colon suggestions read emoji mart's frequently used counts, the store the picker already maintains, and order more-used emoji first within exact, prefix and other matches. ties and new users keep the query order. accepted suggestions record through emoji mart's own frequentlyused.add, so the picker's cached counts and frequently used row include them. completion suggestions gain an optional onselect that the host calls once after a successful insertion (click, tab, enter or terminator), never on highlight. custom emoji share the picker's scoped id helper. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
fuzzy-only matches get their own lowest relevance group, so a frequent subsequence match cannot outrank an alias or keyword match. buzz seeds emoji mart's default frequently used row with weights below one choice before mart reads an empty store, from the picker or a suggestion, and usage counts only whole choices. defaults keep filling the picker row without ranking as picks. help notes the bounded history. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
the default row seed is one picker row wide, as emoji mart seeds it. a first suggestion choice, which has no picker width, seeds the widest picker row. stores emoji mart cannot read as counts are seeded as empty. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
a store holding only defaults seeded for a narrower picker row is reseeded at the wider width, as emoji mart regrows its in-memory defaults. array stores are treated as empty. the picker's maximum row width is one shared constant. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
a store holding only defaults is reseeded when its row differs from the picker width, so a narrower picker shows one row like emoji mart. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
…ctly emoji mart caches usage history per window and saves that copy whole, so a choice in one window dropped choices made in another. its picker also counted an emoji before the first-pick tone prompt was confirmed. buzz now replaces mart's frequently used add and get. history is read from storage on every use, a choice counts when buzz inserts it, and the frequently used row fills an unused first row with mart's defaults without storing them. this removes the fractional default seeding. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
a literal exact shortcode now ranks ahead of separator-insensitive exact matches before usage, so choosing ice_cream no longer reorders icecream. the composer distinguishes a typed terminator that landed alone from an applied edit. at the length limit the closing colon still lands, but the completion is no longer counted. picker hosts report rejected insertions, and the picker counts only accepted ones, including after a tone prompt. the frequently used row offers only emoji that the picker's other categories still show, so emoji the client cannot render no longer take slots from the default fill. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
a picker pick focuses the editor, and prosemirror restores its own selection 20 ms after focus when the dom selection differs. playwright's fill selects all with a dom range, so a fill landing in that window was undone and its text appended to the draft. press the composer's own select-all, which updates prosemirror's selection, then insert the text. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
fca7f21 to
804dede
Compare
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Star Lord. Changes needed at 804dede. Source review confirms the four prior fixes and found one remaining path that counts a reaction removal. Please also confirm whether unsaved avatar previews should train composer suggestions in the existing product-scope thread.
choosing an emoji you already reacted with removes that reaction, and the toggle reported success, so the removal counted as a use. the toggle now reports added or removed, and the reaction pickers count only additions. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
remove the picker-width reload test, which guarded the removed default seeding; the row-filling rule is unit tested. drop the hate keyword checks, which repeat the unit ranking test and the stored-defaults check, and the repeated community ranking after reload. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
…ults the removal regression now makes its second pick from the plus beside the reactions, so both reaction picker wrappers are tested. the reaction tool and emoji picker contracts say which results count as a use. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
the reaction regression removed only through the inline picker, so the action bar wrapper could count a removal again unnoticed. re-add and remove through the action bar as well. the keyword ranking test compared results with and without usage but never stated the answer; assert rage and hankey. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.
Changes requested at 87a8debd. I reviewed it with three independent lanes: product behavior, composer and plugin contracts, and Emoji Mart integration and persistence. This was a source review plus small jsdom probes. I left the suites to CI.
Blocking (details inline):
- Existing histories store Mart's seeded defaults as counts. Those counts now rank colon suggestions for every existing user.
ReactionToolProps.selectnow returnsfalseafter a successful removal.
Non-blocking:
onSelectbecomes a public completion hook without handling async callbacks (inline).- Updates across windows still read and rewrite the whole map. If two picks interleave between one window's read and its write, one is still lost. The two-window browser case awaits each pick in turn, so it covers the stale-cache fix only. That may be the intended guarantee, but the body's "no longer drops choices made in another" claims more.
- PR body vs. this head:
- The 240/1440/240 default-row browser case it lists is not in
tests/browser. - The reaction-removal browser case is present, but the body does not mention it.
- Avatar editor picks now train colon suggestions, even when the user tries an emoji and then cancels. The avatar editor inserts nothing, so "after the host accepts the insertion" does not describe it. Please decide whether that is intended, and say so in the body.
- A new user's first pick now leads the Frequently used row. Before, it landed after the stored defaults. So "ordered as before" is not accurate for new users.
- The 240/1440/240 default-row browser case it lists is not in
To merge: Mart's seeded defaults no longer rank as choices, with a test that starts from a history Mart wrote. A successful reaction removal reports success to contributed pickers again.
emoji mart 5.6 seeded a new history with its defaults at perline - i and saved them with the first pick, so existing histories rank defaults as choices. subtract the widest seed run every count can contain, once, recorded with a marker, and keep the picks made on top of it. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
choosing an existing reaction again reports success to reaction pickers. the host tells pickers which emoji the viewer already reacted with, so the bundled picker skips counting a removal. completion onselect is forwarded only from bundled providers. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
the counts write could succeed while the marker write failed at quota, so the next read subtracted the seed again from real picks. write the marker first: a later failed counts write leaves the seed counted instead. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.
Changes requested at b9e455e8. This re-review was a source read plus simulations of Mart 5.6.0's add/get (copied from dist/module.js:486-531) feeding this PR's removeMartSeed. Two reviewers checked independently. CI was partly pending at my last check, so I'm leaving the suites to it.
Resolved since my last review:
ReactionToolProps.selectmeans success again. The new optionalreactedlets the bundled picker skip counting removals.onSelectis forwarded only from bundled providers, the same waycompletion.tsalready handles tokens.- The marker is now written before the counts are rewritten, so a failed write can no longer subtract the seed twice.
Still blocking: the one-time seed cleanup guesses the seed's width from the counts, and real Mart histories make that guess wrong in both directions (inline). The original finding still stands: seeded defaults rank colon suggestions.
Non-blocking, carried over: the PR body still lists the 240/1440/240 browser case, and this head doesn't have it.
To merge: Mart-seeded defaults don't rank suggestions, and no genuine pick is deleted. Add a test built from histories Mart actually writes after pruning, not only an intact seed.
guessing the seed width from counts fails on histories mart pruned, and cannot tell seeds from real picks. keep buzz usage under its own key; until the first buzz pick, read mart history without the 15 defaults mart seeded. mart history is never rewritten, so no marker is needed. Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
wesbillman
left a comment
There was a problem hiding this comment.
🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.
No blockers at 5cb445bb. This is a comment, not an approval. Moving the counts to buzz.emoji-usage.v1, and reading Mart's history without its 15 defaults until Buzz records a pick, resolves the seed problem without guessing a width. Mart's map is never rewritten, and the trade-offs are spelled out in the body. Every earlier finding is resolved.
This was a source review plus simulations of Mart 5.6.0's add/get, and two reviewers checked independently. CI was mostly pending at my last check.
Two non-blocking edge cases around emoji-mart.last are inline. Both have one small fix: keep Buzz's latest choice in its own record.
Main at 47fa0d6 includes block#4156, which ranks typed emoji suggestions by picker usage. A completion item from a bundled provider can carry `onSelect`, which runs only when its edit is accepted, and `insertText` returns "typed" when only the typed key landed. The merge has no textual conflicts. A group chip goes in as a recipient, and `insertText` drops the typed key for a recipient, so the group path still returns only true or false. `completionResult` keeps this branch's group `label` on the edit and main's `onSelect` on the item. The group chip tests in EditableInput.test.tsx kept `insertText`'s result in a variable typed `boolean`, which no longer type-checks. The merge types it as `boolean | "typed"`, so a group chip that returned "typed" would fail their `toBe(true)` and `toBe(false)`. Apart from that line, every file this branch changes carries the same added and removed lines against main as it did against 4820bfd. Co-Authored-By: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: LordMelkor <kray@squareup.com>
Summary
Colon emoji suggestions now rank the emoji a user chooses often. They read the same usage history as the emoji picker's Frequently used row. A choice in either place teaches both, in every window, and the history persists across reloads.
History owner: Buzz replaces Emoji Mart's
FrequentlyUsed.addandFrequentlyUsed.get, which the picker calls through Mart's exported object. The history is read from storage each time it is used, under Buzz's own key (buzz.emoji-usage.v1) in Mart's format. Buzz no longer relies on Mart's cached copy, which is per window and is saved whole. A choice made in one window therefore keeps choices made earlier in another. Two choices that land in two windows within the same read and write can still lose one count.Recording boundary: a choice counts once, when Buzz inserts the emoji:
ReactionToolPropsgains an optionalreacted(emoji)so the picker can tell;selectstill returnstruefor a successful removal.Highlighting, rendering, dismissed suggestions and a dismissed tone prompt do not count. Neither does a choice the composer rejects at its length limit, including a closing colon that lands without its emoji: the editor reports that case as
"typed"rather thantrue.Completion contract:
CompletionSuggestiongains an optionalonSelect, forwarded only from bundled providers. The host calls it once after it inserts the choice, and errors in it cannot undo the edit.Ranking: matches are grouped in this order: the typed shortcode itself, a separator-insensitive exact shortcode, shortcode prefix, name, keyword or alias, then fuzzy-only. Within each group, the emoji chosen more often comes first. Ties and unused emoji keep the existing query order, so new users see the same results as before.
Identity: Unicode emoji count under Mart's base id, so skin tones and aliases share one count. Community emoji count by scope and shortcode.
Frequently used row: most chosen first, ties by id, with the latest choice always shown. It offers only emoji the picker still shows, so emoji newer than the client renders do not take slots. Mart's defaults fill an unused first row, but they are never stored, so they never rank as choices. A new user's first pick now leads the row; before, Mart placed it after its stored defaults.
Existing histories: users keep their picks. Until the first pick Buzz records, the history is Mart's
emoji-mart.frequentlywithout the 15 ids in Mart'sFrequentlyUsed.DEFAULTS. Mart 5.6 stored those defaults as if chosen, and its pruning makes them indistinguishable from real picks. Every other emoji carries over exactly. Real legacy counts for those 15 are dropped and rebuild with use. The first pick writes the imported history plus that pick under Buzz's key. Mart's history is never rewritten.Testing
addno longer writing;onSelectonce for an applied choice from a bundled provider, and never for a rejected or terminator-only choice or a non-bundled provider.tests/browser/emoji-frequency.spec.mjs, run in Chromium and WebKit:rocketwas missing. It passes with this change.flag-walesandrocketcounted.rocketcounted twice.the first toned pick asks for a default skin tonenow asserts that a dismissed prompt records no use and a confirmed one records one. With Mart's ownaddrestored, it fails with"+1": 1after dismissal.src/bundled/emoji,src/features/conversationandsrc/features/profiles; the emoji browser specs in Chromium and WebKit.🤖 Generated with Claude Code