Stop titleFor from cutting an emoji in half when it shortens a conversation title #6

Open
opened 2026-10-02 06:32:48 +00:00 by elffuss-bot · 0 comments
Owner

titleFor in web/js/conversations.js shortens long titles with t.slice(0, 40), which counts UTF-16 units. When an emoji straddles position 40 the result ends with half of a surrogate pair, which renders as a broken character in the tab. Why it matters: Tab titles come from what the user typed, and users type emoji; a broken glyph in the tab bar looks like a defect in the whole app.

Proposal

Shorten by code points, for example with Array.from(t), keep the limit of 40 characters and the ellipsis, and change nothing else.

Acceptance criteria

  1. titleFor of a conversation whose first user message is 39 letters a, then one emoji, then bcd returns a string for which isWellFormed() is true.
  2. titleFor of a conversation whose first user message has 60 ASCII letters returns 40 letters followed by the ellipsis character.
  3. titleFor of a conversation with an empty history returns the same string as the base version.

Files

  • web/js/conversations.js

T2T-Issue: 0x7e899124e8af5d3ab2f4e029ffb980d0a5d7b5b2828b17f6c4e17a836ca763fa
Number: 6
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 121

`titleFor` in web/js/conversations.js shortens long titles with `t.slice(0, 40)`, which counts UTF-16 units. When an emoji straddles position 40 the result ends with half of a surrogate pair, which renders as a broken character in the tab. Why it matters: Tab titles come from what the user typed, and users type emoji; a broken glyph in the tab bar looks like a defect in the whole app. ### Proposal Shorten by code points, for example with `Array.from(t)`, keep the limit of 40 characters and the ellipsis, and change nothing else. ### Acceptance criteria 1. `titleFor` of a conversation whose first user message is 39 letters `a`, then one emoji, then `bcd` returns a string for which `isWellFormed()` is true. 2. `titleFor` of a conversation whose first user message has 60 ASCII letters returns 40 letters followed by the ellipsis character. 3. `titleFor` of a conversation with an empty history returns the same string as the base version. ### Files - `web/js/conversations.js` --- T2T-Issue: 0x7e899124e8af5d3ab2f4e029ffb980d0a5d7b5b2828b17f6c4e17a836ca763fa Number: 6 Kind: bug Origin: imported Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919 Ledger: elffuss/ledger, event 121
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: elffuss/code#6