Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preserve emoji in whitespace-heavy thread search snippets #42165

Mergedonly21mil(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/42165/headmerged by juliusmarminge View on GitHub

Problem

buildSearchSnippet (apps/server/src/orchestration-v2/ThreadSearch.ts) reads a raw window of 480 UTF-16 code units before collapsing whitespace and cutting to the 240-character display budget. When an emoji's two code units straddle that raw cut after a long whitespace run, the window keeps only the first half. Whitespace collapse pulls that half next to the match, so search results show a replacement glyph (�) instead of the emoji.

Example: searching needle in Rocket checklist needle + 456 spaces + 🚀 tail returned Rocket checklist needle \ud83d… instead of keeping 🚀.

Change

  • In apps/server/src/orchestration-v2/ThreadSearch.ts, move rawEnd one unit forward when it lands on a low surrogate (isLowSurrogate(text.charCodeAt(rawEnd))), matching the guard already used for the start and visible end cuts (2 non-test lines). The visible 240-character cap is unchanged.
  • In apps/server/src/orchestration-v2/ThreadSearch.test.ts, add one assertion to "starts snippets a few words before the match so one line shows it": needle + 473 spaces + 🚀 tail now gives needle 🚀….

Scope

Small fix for an obvious bug, so no issue is filed; the repro is in Problem and the unit test.

Verification

Setup: Web dev server from source, fresh isolated data, Chromium 1280×800 viewport, light theme, server labelled "Test machine" (run by Claude Opus 5.5 in T3 Code).

Steps: Send the example message in a thread → search needle in the command palette (Ctrl+K) → search needle in the sidebar search (same on both commits).

Before (3b829b6)After (3c2c165)
Command palette at 3b829b6: the snippet shows needle followed by a replacement glyph
Command palette at 3b829b6: the snippet shows needle followed by a replacement glyph
Command palette at 3c2c165: the snippet shows needle followed by the rocket emoji
Command palette at 3c2c165: the snippet shows needle followed by the rocket emoji
Sidebar search at 3b829b6: the snippet shows needle followed by a replacement glyph
Sidebar search at 3b829b6: the snippet shows needle followed by a replacement glyph
Sidebar search at 3c2c165: the snippet shows needle followed by the rocket emoji
Sidebar search at 3c2c165: the snippet shows needle followed by the rocket emoji
  • An AI agent (Claude Opus 5.5, T3 Code) ran ThreadSearch.test.ts three times in a row: 32/32 passed each time; the new assertion fails on 3b829b6 ('needle \ud83d…').
  • An AI agent (Claude Opus 5.5, T3 Code) ran vp run check:changed: exit 0 (format, lint, knip, typecheck, tests).

Not shown: mobile (the same server snippet feeds its search rows; no client code changed); desktop shell (same web UI).

Generated with Gemini 4 Neon in T3 Code Nightly

    1. Pushedde288ac

    2. Evidence

      Sent Rocket checklist needle + exactly 456 spaces + 🚀 tail in a Replay thread titled Launch prep, then searched needle through Ctrl+K and sidebar Search threads. Both runs used fresh databases, Chromium, 1280×800, and light theme. The scenario seeded the nonmatching title directly and used Replay multi-turn.

      Proven: base snippets contain lone U+D83D; head snippets retain the complete rocket. This browser lacks an emoji font: intact emoji render as a box, while the broken base snippet shows a replacement diamond. The runner exited 0.

      Before — 94190c63f9After — de288acd0e
      ResultFails: observed needle \ud83d…Passes: both search results contain needle 🚀
      Command paletteBefore: broken rocket in command paletteAfter: complete rocket in command palette
      Sidebar searchBefore: broken rocket in sidebar searchAfter: complete rocket in sidebar search
      RecordingBefore recordingAfter recording

      Scenario source

      Not shown:

      • The broader display-budget boundary was not separately exercised; this proof covers the reported 456-space surrogate split in both web search entry points.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged this20b97f2

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.