Repository navigation
fix(web): cut a Message tab's name between code points - #806
XiaoBinGan wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Approve with nits (1 P3)
Scope: base main, merge base 6a511c15; 1 commit, 2 files reviewed (panel-tab-title.ts, its new test). Loaded ponytail-review (sections 1–3); coderbook and karpathy-guidelines were applied from the review recipe without loading them separately. Ran in a separate session.
Findings
P3
apps/web/src/features/rooms/task-sidebar/panel-tab-title.ts:5: the doc comment says "an emoji is one character", but the cut is by code point.[...normalized]splits by code point, so ZWJ sequences and flags are still several "characters". Example:"a".repeat(23) + "\u{1F468}\u{1F469}\u{1F467}"keeps only\u{1F468}, so the tab shows a man instead of the family emoji. Flags (\u{1F1EF}\u{1F1F5}) can lose their second regional indicator in the same way. The string stays well-formed, which is the bug this PR fixes. The PR's "Not verified here" section names combining marks, but it says nothing about ZWJ sequences or flags, and the comment overstates the guarantee. Fix: say "code points" in the comment, or cut withIntl.Segmentergrapheme segments if whole glyphs matter. Optional.
Verified as fine
- Both callers pass a plain string and use the result only as a tab title:
apps/web/src/features/rooms/task-sidebar/room-task-sidebar-impl.tsx:171andapps/web/src/features/rooms/use-room-panel-sidebar.ts:42. The return type and the 24-unit budget are unchanged, so ASCII and BMP titles come out byte-for-byte the same as before. MAX_PANEL_TAB_CHARACTERSis declared after the function. This is safe because it is only read when the function is called, after the module has evaluated.trimEnd()still runs on the joined prefix before the ellipsis, the same as the oldslice(0, 24).trimEnd().- The repo already cuts by code point this way:
firstCodePointsinapps/web/src/features/rooms/documents/room-document-readonly-selection.ts:59androom-document-blocknote-editor.tsx:774. Both are private module helpers, so the inline[...s].slice().join()here is consistent with them and does not duplicate a shared export. - The tests cover the surrogate-split case at position 24 and the exact 24/25 astral boundary. With the old
slice, the second and third cases would fail. I checked this by reading the code; I did not run the old version. - No CJK in the added lines or the commit message. Commit subject and type follow convention.
Process notes
- None. One conventional commit, no merge or fixup commits. The author is linked to GitHub (
XiaoBinGan).
CI
changes and repository-gate pass. web tests (1/2, 2/2) and web-static were still pending at review time; the other checks are skipped by path. I did not run the focused test locally because this worktree has no node_modules, so it relies on the pending web tests.
Automated review by Claude Code
Automated review of 9ef8fb2 by Claude Code.
A saved Message tab took the first 24 UTF-16 units of its text, so a name whose 24th unit is the first half of an emoji kept half a character and rendered as a broken glyph. It now counts characters.
9ef8fb2 to
93e07f2
Compare
There was a problem hiding this comment.
Approve (0 findings)
Follow-up on 9ef8fb2. Merge base 6a511c1, 1 commit, 2 files reviewed.
- Resolved: comment called an emoji one character (
apps/web/src/features/rooms/task-sidebar/panel-tab-title.ts:4-7now says code points and states that ZWJ sequences and flags can still be cut short; the new test atpanel-tab-title.test.ts:33-41covers this)
Verified as fine
- The cut counts code points (
[...normalized]), and because the budget and ellipsis are unchanged, ASCII names come out exactly as before (panel-tab-title.ts:11-17). Both callers (room-task-sidebar-impl.tsx:171,use-room-panel-sidebar.ts:42) only store or show the returned string. - The tests pin the astral boundary (23 ASCII characters + 1 emoji), the ZWJ family case and the 24/25-emoji case without relying on lone surrogates (
panel-tab-title.test.ts:24-47).
CI: all required checks pass (web tests 1/2 and 2/2, web-static, repository-gate). I ran nothing locally.
Automated review by Claude Code
Automated review of 93e07f2 by Claude Code.
Problem and outcome
A Message tab is saved under the start of its text (
panelTabTitle,apps/web/src/features/rooms/task-sidebar/panel-tab-title.ts). It tooknormalized.slice(0, 24), which counts UTF-16 units, so a name whose 24th unit is the first half of an astral character kept half a character:That saved name is what the tab shows and what persists in the panel store, so the broken glyph outlives the session. The cut now counts code points (
[...normalized]), which is what the repository's other cut helpers do (firstCodePointsinroom-document-readonly-selection.tsandroom-document-blocknote-editor.tsx).A sequence several code points make up — a ZWJ family, a flag — can still be shortened to fewer of them, so the glyph may be incomplete; the string stays well-formed, which is what this change guarantees.
Evidence and validation
Base
mainat6a511c1545bb0ac16c81184f0c2b59c2de1b0a5a. Node.js 26.5.0, pnpm 11.7.0.panel-tab-title.test.ts: a short name keeps its collapsed spacing; a name of 23 ASCII characters plus one emoji is cut without a lone surrogate; 24 emoji stay whole and 25 are cut to 24 plus the ellipsis.slicerestored, two of the three cases fail (Tests 2 failed | 1 passed); with the character-based cut they pass.vitest run src/features/rooms/task-sidebar— 26 files, 178 tests pass.pnpm --filter @linger/web typecheckreports nothing for the touched file.Boundary
provider_readypath is touched; this runs when a tab is saved.Not verified here
Author readiness
typecheck, thetask-sidebarsuite, Prettier)contracts/openapi/changed (not applicable)Human owner: @XiaoBinGan