Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Thread search does extra work to build message previews #47457

ClosedUtkarshUsername(GitHub profile, opens in a new tab) opened this issue 0 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On the affected commit, isolate buildSearchSnippet and its constants and helpers from apps/server/src/orchestration-v2/ThreadSearch.ts.
  2. Make a 9,372-character ASCII message with zebraquokka near the middle. For a second message, use "漢".repeat(10_000) + "zebraquokka". Both messages fit under the 120,000-character limit.
  3. For each message, call buildSearchSnippet(text, text.indexOf("zebraquokka")). Count calls to Intl.Segmenter.prototype.segment and String.prototype.charCodeAt during that call. Compare the returned snippets with #47404.

Expected behavior

Thread search should build the preview using the text near the cut when that text establishes a safe boundary. Flags and joined emoji should stay whole.

Actual behavior

The ASCII case calls the segmenter twice. The Han case makes 9,978 character reads as it walks back looking for an ASCII boundary. The fix in #47404 returns identical snippets with zero segmenter calls in the ASCII case and three character reads in the Han case.

Impact

Minor bug or occasional failure

This adds server work when building thread search previews. The test measures the snippet builder directly. A full-search slowdown has yet to be demonstrated.

Version or commit

Affected base: e573bc473e2a45cc414d430cc157760d1fbd4717. Compared with 70168c3a18ee02e9d14f6fd504d8e9c5b11e1018 in #47404.

Environment

Windows x64, Node.js 26.13.1. The reproduction calls the server helper directly.

Logs or stack traces

                              Affected base   PR #47404
ASCII: segmenter calls                    2           0
Han: character reads                  9,978           3

Fix PR: https://github.com/pingdotgg/t3code/pull/47404

  1. tanstack-source added labelsbug

Sign in to join this conversation.