Skip to content

feat(emoji): rank typed suggestions by shared picker usage - #4156

Merged
kalvinnchau merged 16 commits into
mainfrom
peon/emoji-frequency
Nov 23, 2026
Merged

kalvinnchau merged 16 commits into
mainfrom
peon/emoji-frequency

Conversation

@kalvinnchau

@kalvinnchau kalvinnchau commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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.add and FrequentlyUsed.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:

    • from suggestions, after the composer applies it by click, Tab, Enter or a terminator such as the closing colon;
    • from the composer picker, after the host accepts the insertion, including after a confirmed first-pick tone prompt;
    • from the avatar editor's picker, when the emoji is chosen, even if the avatar is not saved. The product decision is one shared history;
    • from a reaction picker, only when the choice adds a reaction. Choosing an emoji you already reacted with removes that reaction and does not count. ReactionToolProps gains an optional reacted(emoji) so the picker can tell; select still returns true for 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 than true.

  • Completion contract: CompletionSuggestion gains an optional onSelect, 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.frequently without the 15 ids in Mart's FrequentlyUsed.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

  • Unit tests cover:
    • ranking within each match group, that the typed shortcode leads a more often chosen separator-insensitive namesake, and that alias and keyword matches stay ahead of frequently chosen fuzzy matches;
    • whole-choice reads;
    • starting from a history Mart 5.6 wrote and then pruned at a narrower picker: real picks carry over, defaults read as unused, the first pick writes Buzz's key, and Mart's key is left unchanged;
    • counting against the latest stored history while another window writes;
    • recovery from unreadable history;
    • the row's order, latest choice and default fill, including when Mart drops an emoji the client cannot render;
    • Mart's own add no longer writing;
    • the host calling onSelect once for an applied choice from a bundled provider, and never for a rejected or terminator-only choice or a non-bundled provider.
  • Browser cases added in tests/browser/emoji-frequency.spec.mjs, run in Chromium and WebKit:
    • The picker and suggestions learn from each other, including after a reload.
      • The case checks new-user order, that highlighting a suggestion teaches nothing, a picker choice followed by Tab and terminator choices, a keyboard choice of a community emoji, the Frequently used row, stored counts, and persistence after reload.
      • It needs a browser because it depends on the real Emoji Mart web component, its click handling, and localStorage across reloads.
      • It fails on the base branch, where suggestions do not learn, and passes with this change.
    • Choices made in two windows of one profile keep each other.
      • It uses two pages, each with its own Emoji Mart instance, that share storage.
      • With Mart's cached history, a choice made in one page dropped the other page's choice: the test failed because rocket was missing. It passes with this change.
    • Emoji a full composer cannot insert teach nothing.
      • At the length limit, a closing colon lands without its flag, and a picker choice is rejected with the "too long" alert. Neither counts. The same picker choice into an empty composer counts once.
      • It needs a browser for the real editor, length limit and Emoji Mart picker. It fails on the previous head, with flag-wales and rocket counted.
    • Choosing an existing reaction removes it and teaches nothing.
      • Both reaction pickers, the message actions plus and the plus beside the reactions, add 🚀 once and then remove it without counting it again.
      • It fails without the fix, with rocket counted twice.
  • Browser case extended: the first toned pick asks for a default skin tone now asserts that a dismissed prompt records no use and a confirmed one records one. With Mart's own add restored, it fails with "+1": 1 after dismissal.
  • The emoji-frequency spec was trimmed of checks covered by unit tests: the picker-width reload case, which guarded a default-row seeding step this PR no longer has, and a repeated community ranking after reload.
  • Passing locally: typecheck, design checks, and biome on the changed files; Vitest for src/bundled/emoji, src/features/conversation and src/features/profiles; the emoji browser specs in Chromium and WebKit.

🤖 Generated with Claude Code

@kalvinnchau
kalvinnchau marked this pull request as ready for review November 22, 2026 16:17
@kalvinnchau
kalvinnchau requested a review from a team as a code owner November 22, 2026 16:17

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.

Comment thread src/bundled/emoji/emoji-usage.ts Resolved
Comment thread src/bundled/emoji/emoji-usage.ts Resolved
Comment thread docs/buzz-help.md Resolved
Comment thread src/features/conversation/contracts.ts Resolved
@kalvinnchau
kalvinnchau marked this pull request as draft November 22, 2026 16:41
@kalvinnchau
kalvinnchau marked this pull request as ready for review November 22, 2026 21:54

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.

Comment thread src/bundled/emoji/emoji-search.ts Resolved
Comment thread src/bundled/emoji/emoji-mart.ts Resolved
Comment thread src/bundled/emoji/emoji-mart.ts Resolved
@kalvinnchau
kalvinnchau marked this pull request as draft November 22, 2026 22:11
@kalvinnchau
kalvinnchau force-pushed the peon/emoji-frequency branch 2 times, most recently from 8f4b333 to e6bfa25 Compare November 23, 2026 00:32
@kalvinnchau
kalvinnchau marked this pull request as ready for review November 23, 2026 15:54
kalvinnchau and others added 8 commits November 23, 2026 07:56
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>
@kalvinnchau kalvinnchau changed the title feat(emoji): rank colon suggestions by shared picker usage feat(emoji): rank typed suggestions by shared picker usage Nov 23, 2026

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.

Comment thread src/bundled/emoji/emoji-mart.ts Resolved
kalvinnchau and others added 4 commits November 23, 2026 08:21
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 wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.select now returns false after a successful removal.

Non-blocking:

  • onSelect becomes 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.

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.

Comment thread src/bundled/emoji/emoji-usage.ts Resolved
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>
kalvinnchau and others added 2 commits November 23, 2026 09:37
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 wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.select means success again. The new optional reacted lets the bundled picker skip counting removals.
  • onSelect is forwarded only from bundled providers, the same way completion.ts already 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.

Comment thread src/bundled/emoji/emoji-usage.ts Resolved
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 wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 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.

Comment thread src/bundled/emoji/emoji-usage.ts Resolved
Comment thread src/bundled/emoji/emoji-usage.ts Resolved
@kalvinnchau
kalvinnchau merged commit 47fa0d6 into main Nov 23, 2026
74 checks passed
@kalvinnchau
kalvinnchau deleted the peon/emoji-frequency branch November 23, 2026 18:15
LordMelkor added a commit to LordMelkor/buzz-app that referenced this pull request Nov 23, 2026
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>
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.

2 participants