Repository navigation
fix(workspaces): use the emojibase shortcode preset for emoji suggestions - #11888
Conversation
…ions The picker loaded emojibase-data's `github` preset, which names flags only by ISO code (`kr`, `de`) or bare country name and has no `flag_*` aliases at all. Combined with prefix-only search that made every flag near-undiscoverable: `:korea`, `:germany`, `:france`, `:flag_kr` all returned nothing, and `:japan` returned the map 🗾 rather than 🇯🇵. Switch to the `emojibase` preset (2590 aliases over 1949 emoji, vs 1870) and drop the hand-maintained `kr` entry that patched around the gap. Skin-tone aliases are filtered out; they are ~40% of the preset and would otherwise crowd the eight suggestion slots and clobber base-emoji branch names. Search now matches anywhere in the shortcode, ranked exact > prefix > word-start > substring, so `:korea` surfaces both Koreas. Emoji-derived branch names change for 592 emoji, e.g. 🇯🇵 `jp` -> `flag-jp`.
📝 WalkthroughWalkthroughThe emoji shortcode catalog now uses filtered 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR replaces the
Confidence Score: 5/5Safe to merge — the change is additive (more aliases, better search), and all 364 unit tests pass. The catalog swap, skin-tone filtering, and ranked search are well-covered by new and updated unit tests. The primaryShortcode() logic is deterministic and verified against the test assertions. The only open issue (matchTier using indexOf and missing multi-occurrence word-starts) was surfaced in the previous review thread and does not block correct results. Files Needing Attention: No files require special attention. Reviews (2): Last reviewed commit: "fix(workspaces): prefer spelled-out alia..." | Re-trigger Greptile |
| function matchTier(shortcode: string, query: string): number | null { | ||
| const index = shortcode.indexOf(query) | ||
| if (index < 0) { | ||
| return null | ||
| } | ||
| if (index === 0) { | ||
| return shortcode.length === query.length ? MATCH_TIER.exact : MATCH_TIER.prefix | ||
| } | ||
| return /[_-]/.test(shortcode[index - 1]) ? MATCH_TIER.wordStart : MATCH_TIER.substring | ||
| } |
There was a problem hiding this comment.
matchTier uses indexOf (first occurrence), which can assign a worse tier than the best available match when the query appears twice in one shortcode — once mid-word and once after a delimiter.
Consider the shortcode crane_antenna with query an. indexOf returns position 2 (inside crane), where the preceding character is r → MATCH_TIER.substring. The word-start occurrence at position 6 (after _) is never examined, so the shortcode is ranked lower than it should be. The fix is to scan all occurrences and return the minimum (best) tier found.
Emojibase lists cryptic stubs alongside real names, and the "first alias starting with a letter" rule picked the stub: 👎 derived the branch name `no`, ✌ derived `v`, and every flag derived `flag-de` rather than `germany`. Skip aliases under three characters and the `flag_xx` namespacing prefix when a spelled-out alias exists. All 258 flags have a country name, and the eight affected non-flag emoji all gain a readable name (`thumbsdown`, `victory`, `trade-mark`, `optical-disk`). Genuinely short names such as `heart`, `ocean`, and `atom` are unchanged.
…ions (stablyai#11888) Swap the worktree-name emoji picker from emojibase-data's `github` shortcode preset to `emojibase`, which carries both `flag_kr` and `south_korea` style flag names, and drop the hand-maintained `kr` entry that patched around the gap. Filter skin-tone aliases so they neither crowd the suggestion list nor clobber base-emoji branch names. Search now matches anywhere in the shortcode, ranked exact > prefix > word-start > substring, so `:korea` surfaces both Koreas. Emoji-derived branch names now prefer spelled-out aliases: flags use country names (japan, germany, south-korea) and cryptic stubs are skipped (thumbsdown over no, victory over v).
Problem
The worktree-name emoji picker loaded emojibase-data's
githubshortcode preset. That preset names flags only by ISO code (kr,de,fr) or bare country name, and contains zeroflag_*aliases — the only shortcode starting withflagisflags→ 🎏.Combined with prefix-only search matching, flags were near-undiscoverable:
:kr:worked only because #11845 / #11858 hand-added{ emoji: '🇰🇷', shortcode: 'kr' }to paper over the gap — a per-country patch that doesn't scale to 258 flags.Change
emojibasepreset: 2590 aliases over 1949 emoji (vs 1870), with bothflag_krandsouth_koreastyle names.WORKSPACE_EMOJI_SHORTCODE_ADDITIONSlist.wave_tone3). They're ~40% of the preset; without this they crowd out the eight suggestion slots, and the last tone variant clobbers the base emoji's primary shortcode so👩💻would derivewoman-technologist-tone5for branch names.exact > prefix > word-start > substring.flag_xxnamespacing prefix when a real name exists.After:
Behavior changes worth reviewing
:kr:no longer auto-replaces on the closing colon.krisn't an emojibase alias — it was the hardcode. Typing:krstill surfaces 🇰🇷 as the top suggestion (selectable with Enter), and:flag_kr:/:south_korea:auto-replace.sanitizeWorktreeName. Flags now use country names (🇯🇵jp→japan, 🇩🇪 →germany, 🇰🇷 →south-korea), and eight non-flag emoji gain readable names (👎thumbsdowninstead ofno, ✌victoryinstead ofv, ™trade-mark, 💿optical-disk). Other preset differences: ✅white_check_mark→check-mark-button, 🐈cat2→cat. Genuinely short names likeheart,ocean, andatomare unchanged. Existing worktrees are unaffected; this applies only to newly derived names.workspace.Test
workspace-emoji-shortcodes.test.ts: added coverage for country-name lookup, substring/word-start ranking, and skin-tone exclusion.worktree-logic.test.ts: 🇯🇵 →japanand 👎 →thumbsdown. The "emoji newer than the catalog" fallback test now usesU+1FAEB— every emoji in emojibase-data 17'sdata.jsonhas a shortcode, soU+1FAE9no longer exercises that path.worktree.spec.tse2e retyped to:flag_kr.pnpm typecheckandoxlintclean. E2E not run locally.