Skip to content

fix(workspaces): use the emojibase shortcode preset for emoji suggestions - #11888

Merged
nwparker merged 2 commits into
mainfrom
nwparker/emoji2
Aug 1, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/emoji2

Conversation

@nwparker

@nwparker nwparker commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The worktree-name emoji picker loaded emojibase-data's github shortcode preset. That preset names flags only by ISO code (kr, de, fr) or bare country name, and contains zero flag_* aliases — the only shortcode starting with flag is flags → 🎏.

Combined with prefix-only search matching, flags were near-undiscoverable:

":korea"      => []                      # north_korea exists, prefix-only hid it
":germany"    => []                      # 🇩🇪 was reachable only as ":de:"
":france"     => []                      # 🇫🇷 was reachable only as ":fr:"
":flag_kr"    => []
":japan"      => 🗾 japan, 👹 japanese_ogre, ...   # the map, never the flag 🇯🇵
":united"     => 🇺🇳, 🇦🇪                  # no 🇺🇸 / 🇬🇧

: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

  • Swap the catalog to the emojibase preset: 2590 aliases over 1949 emoji (vs 1870), with both flag_kr and south_korea style names.
  • Delete the hardcoded WORKSPACE_EMOJI_SHORTCODE_ADDITIONS list.
  • Filter skin-tone aliases (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 derive woman-technologist-tone5 for branch names.
  • Search now matches anywhere in the shortcode, ranked exact > prefix > word-start > substring.
  • Pick spelled-out aliases for emoji-derived names (second commit): emojibase lists cryptic stubs next to real names, so skip aliases under three characters and the flag_xx namespacing prefix when a real name exists.

After:

":korea"      => 🇰🇵 north_korea  |  🇰🇷 south_korea
":kr"         => 🇰🇷 flag_kr  |  🇺🇦 ukraine  |  🪳 cockroach
":germany"    => 🇩🇪 germany
":japan"      => 🇯🇵 japan  |  🗾 japan_map  |  👹 japanese_ogre
":united"     => 🇺🇸 united_states  |  🇬🇧 united_kingdom  |  🇺🇳 united_nations  |  🇦🇪 united_arab_emirates

Behavior changes worth reviewing

  • :kr: no longer auto-replaces on the closing colon. kr isn't an emojibase alias — it was the hardcode. Typing :kr still surfaces 🇰🇷 as the top suggestion (selectable with Enter), and :flag_kr: / :south_korea: auto-replace.
  • Emoji-derived branch and directory names change via sanitizeWorktreeName. Flags now use country names (🇯🇵 jp → japan, 🇩🇪 → germany, 🇰🇷 → south-korea), and eight non-flag emoji gain readable names (👎 thumbsdown instead of no, ✌ victory instead of v, ™ trade-mark, 💿 optical-disk). Other preset differences: ✅ white_check_mark → check-mark-button, 🐈 cat2 → cat. Genuinely short names like heart, ocean, and atom are unchanged. Existing worktrees are unaffected; this applies only to newly derived names.
  • 75 emoji gain a shortcode they previously lacked and no longer fall back to 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: 🇯🇵 → japan and 👎 → thumbsdown. The "emoji newer than the catalog" fallback test now uses U+1FAEB — every emoji in emojibase-data 17's data.json has a shortcode, so U+1FAE9 no longer exercises that path.
  • worktree.spec.ts e2e retyped to :flag_kr.
  • 364 related unit tests pass; pnpm typecheck and oxlint clean. E2E not run locally.

…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`.
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The emoji shortcode catalog now uses filtered emojibase data and excludes skin-tone aliases. Workspace search supports ranked exact, prefix, word-start, and substring matches. Flag searches and replacements now use standard flag shortcodes. Unit and end-to-end tests were updated for these behaviors and for the Unicode fallback case.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes and tests, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, state whether visual changes exist, document cross-platform review, and summarize security risks and follow-up work.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: switching workspace emoji suggestions to the emojibase shortcode preset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR replaces the github emojibase shortcode preset with the emojibase preset, adding country-name and flag_xx-style aliases for all 258 flags, and upgrades the emoji picker's search from prefix-only to ranked substring matching (exact → prefix → word-start → substring).

  • Catalog overhaul (emoji-shortcode-catalog.ts): switches presets, filters skin-tone aliases (_toneN) that would otherwise dominate suggestions, and introduces primaryShortcode() to prefer descriptive branch-safe names (e.g. germany over flag_de, thumbsdown over no).
  • Search upgrade (workspace-emoji-shortcodes.ts): removes the hardcoded { emoji: '🇰🇷', shortcode: 'kr' } patch, adds matchTier() for ranked substring search, and updates deduplication to keep the best-ranked alias per emoji.
  • Breaking UX note: :kr: no longer auto-replaces on the closing colon (:flag_kr: and :south_korea: do); 592 emoji derive a different sanitizeWorktreeName result for newly-created worktrees.

Confidence Score: 5/5

Safe 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

Comment on lines +26 to +35
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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.
@nwparker
nwparker merged commit 340faaa into main Aug 1, 2026
45 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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).
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.

1 participant