Skip to content

fix(web): cut a Message tab's name between code points - #806

Open
XiaoBinGan wants to merge 1 commit into
simplexai-labs:mainfrom
XiaoBinGan:fix/panel-tab-title-characters
Open

XiaoBinGan wants to merge 1 commit into
simplexai-labs:mainfrom
XiaoBinGan:fix/panel-tab-title-characters

Conversation

@XiaoBinGan

@XiaoBinGan XiaoBinGan commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 took normalized.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:

panelTabTitle("a".repeat(23) + "\u{1F600}" + "tail")
  before: "aaaaaaaaaaaaaaaaaaaaaaa\ud83d…"   ← a lone high surrogate
  now:    "aaaaaaaaaaaaaaaaaaaaaaa…"          (the emoji needs both units, so the cut moves one character left)

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 (firstCodePoints in room-document-readonly-selection.ts and room-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 main at 6a511c1545bb0ac16c81184f0c2b59c2de1b0a5a. Node.js 26.5.0, pnpm 11.7.0.

  • New 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.
  • Negative control: with the unit-based slice restored, 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 typecheck reports nothing for the touched file.

Boundary

  • No contract, env or migration change: one pure function and its test.
  • The 24-character budget and the trailing ellipsis are unchanged, so a tab name that already fit keeps exactly the same text.
  • Nothing on the message → provider_ready path is touched; this runs when a tab is saved.

Not verified here

  • No browser render: the case asserts the string, which is what the tab shows and stores.
  • Right-to-left text and combining marks were not exercised; the cut respects code point boundaries, so a base character and its combining marks can still be separated.
  • A ZWJ family or a flag keeps whole code points but can lose the rest of the sequence; a test pins the well-formedness, not the glyph.
  • The panel store's own persistence was not driven, so the saved-name path is checked through the function only.

Author readiness

  • Focused tests for the changed behavior, with the negative control run both ways
  • The fast checks of the touched app (typecheck, the task-sidebar suite, Prettier)
  • Contracts regenerated if contracts/openapi/ changed (not applicable)

Human owner: @XiaoBinGan

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 with Intl.Segmenter grapheme 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:171 and apps/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_CHARACTERS is 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 old slice(0, 24).trimEnd().
  • The repo already cuts by code point this way: firstCodePoints in apps/web/src/features/rooms/documents/room-document-readonly-selection.ts:59 and room-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.
@XiaoBinGan
XiaoBinGan force-pushed the fix/panel-tab-title-characters branch from 9ef8fb2 to 93e07f2 Compare November 26, 2026 19:06
@XiaoBinGan XiaoBinGan changed the title fix(web): cut a Message tab's name between characters fix(web): cut a Message tab's name between code points Nov 26, 2026

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-7 now says code points and states that ZWJ sequences and flags can still be cut short; the new test at panel-tab-title.test.ts:33-41 covers 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.

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