fix(#1265): accept keycap emoji reactions

Gemini 2.5 review: keycaps (1, #, * followed by U+FE0F U+20E3) are one grapheme but start with an ASCII base, so the first-rune range check rejected them. MeshCore One accepts them: its first scalar has the Emoji property and the grapheme has more than one scalar. A bare digit, # or * is still text. Pre-existing gap, fixed here because this epic's aim is MeshCore One parity.

Agent: JadePond (session ccf4efac)
pull/1349/head
diffwireauto 3 days ago
parent 19270a781f
commit c6f67ffdad

@ -136,9 +136,15 @@ class PocketMeshReaction {
static bool _isReactionEmoji(String text) {
if (text.characters.length != 1) return false;
final first = text.runes.first;
// Keycaps (`1️⃣`, `#️⃣`) start with an ASCII base, so they need their own
// check. A bare digit is text; the combining keycap U+20E3 makes it emoji.
if (_isKeycapBase(first)) return text.runes.contains(0x20E3);
for (final range in _emojiRanges) {
if (first >= range[0] && first <= range[1]) return true;
}
return false;
}
static bool _isKeycapBase(int rune) =>
rune == 0x23 || rune == 0x2A || (rune >= 0x30 && rune <= 0x39);
}

@ -275,6 +275,39 @@ void main() {
expect(PocketMeshReaction.parse('\ndyps6yf0', isDm: true), isNull);
});
test('accepts keycap emoji, which start with a digit, # or *', () {
// One grapheme of base + U+FE0F + U+20E3. MeshCore One accepts these.
for (final keycap in [
'#\u{FE0F}\u{20E3}',
'*\u{FE0F}\u{20E3}',
'1\u{FE0F}\u{20E3}',
'0\u{20E3}',
]) {
expect(
PocketMeshReaction.parse('$keycap\ndyps6yf0', isDm: true)?.emoji,
keycap,
reason: 'should accept $keycap',
);
}
expect(
PocketMeshReaction.parse(
'@[Bob]1\u{FE0F}\u{20E3}\ndyps6yf0',
isDm: false,
),
isNotNull,
);
});
test('a bare digit, # or * is not an emoji', () {
for (final plain in ['1', '#', '*']) {
expect(
PocketMeshReaction.parse('$plain\ndyps6yf0', isDm: true),
isNull,
reason: '$plain alone is text',
);
}
});
test('a sentence starting with an arrow is not a reaction', () {
// Arrows carry the Unicode Emoji property but are ordinary punctuation.
// A live capture from this mesh had U+2192 mid-sentence in a normal

Loading…
Cancel
Save

Powered by TurnKey Linux.