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 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 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
Evidence#
Sent
Rocket checklist needle+ exactly 456 spaces +🚀 tailin a Replay thread titledLaunch prep, then searchedneedlethrough 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.
needle \ud83d…needle 🚀Scenario source
Not shown: