GeezerVison is showing github.com — fix(server): avoid broken emoji in project search previews during indexing by saphid · Pull Request #44531 · pingdotgg/t3code
Conversation
Problem
While the native content search index is still warming up, WorkspaceSearchIndex.searchContentsWithGit truncates matched lines with line.slice(0, 512), which can cut a UTF-16 surrogate pair in half and return an ill-formed lineContent string containing a lone high surrogate.
Deterministic repro on origin/main (2e2af395f6268c3b840b4a0995fcf6c7e0771dfa): Write 'needle' + 'a'.repeat(505) + '😀\n' to long.txt in a temporary Git repo and call WorkspaceSearchIndex.make(dir, "content").searchContents({ query: "needle", limit: 10, caseSensitive: false, wholeWord: false, useRegex: false }) while the native content finder reports { isScanning: false, isWarmupComplete: false }.
- Observed:
lineContent has length 512, ends in lone high surrogate U+D83D, and returns false from lineContent.isWellFormed().
- Expected:
lineContent keeps the complete 511-unit prefix (isWellFormed() === true), omits the split emoji, and keeps matchRanges: [{ start: 0, end: 6 }].
Change
Check splitsSurrogatePair(line, CONTENT_LINE_MAX_LENGTH) from @t3tools/shared/assistantCitations before slicing lineContent in apps/server/src/workspace/WorkspaceSearchIndex.ts, backing the slice endpoint up by one code unit when the 512-unit boundary would split a surrogate pair. Existing range filtering (range.end <= lineContent.length) already clips against the actual returned prefix, and the native fff search path slices on UTF-8 boundaries in Rust, so web and desktop clients receive well-formed previews without client-side changes.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
- Base failure (
2e2af395f6268c3b840b4a0995fcf6c7e0771dfa): Extended the long-line fixture in apps/server/src/workspace/WorkspaceSearchIndex.test.ts (answers content searches with git grep while a slow content index builds); vp test run apps/server/src/workspace/WorkspaceSearchIndex.test.ts -t "answers content searches with git grep while a slow content index builds" failed with line 5 returning length 512 instead of 511.
- Head pass (
b976ab751fc15109755dba5d24e31b55c53dae02): vp test run apps/server/src/workspace/WorkspaceSearchIndex.test.ts passed 2/2 consecutive runs (18/18 tests each).
- Changed checks:
vp run check:changed exited 0 (format, lint, knip, graphql, typecheck across 3 packages, and 20/20 affected tests).
- Before/after runtime transcript: https://gist.github.com/saphid/e9725c6a681c5d0fd51d2f8677ba85de
- Not shown: Interactive web/desktop/mobile UI rendering (server-only preview truncation fix with no client code changes) and full repo-wide test suite (owned by CI).
Authored by Gemini 4 Neon (Antigravity); reviewed by Kimi K3.1 Pro (Model Hub).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
Git-backed content search now avoids ending displayed line content in the middle of a surrogate pair. Tests cover whole-word and regex searches for a long line where the 512-code-unit cap falls inside an emoji.
Changes: Content search results
| Layer / File(s) |
Summary |
Safe line truncation and test coverage apps/server/src/workspace/WorkspaceSearchIndex.ts, apps/server/src/workspace/WorkspaceSearchIndex.test.ts |
Search results return 511 code units when the 512-code-unit boundary splits a surrogate pair. Tests cover whole-word and regex matches and assert the 511-character display and match range. |
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix
Possibly related PRs
Suggested labels: bugfix
Suggested reviewers: only21mil
Merge Risk: Minimal · up to a572c
-
This change stops Git-backed project search previews from ending in the middle of an emoji while the content index warms up. The test is deterministic and covers the case. No merge-blocking risk remains.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: the server search preview no longer ends in a broken emoji during indexing. It follows the conventional commit form and matches the WorkspaceSearchIndex surrogate-pair… |
| Description check |
 |
The description follows the template. It has a Problem section with a deterministic repro and expected behavior, a Change section explaining the surrogate-pair backoff, a Scope section explaining why … |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the main change: the server search preview no longer ends in a broken emoji during indexing. It follows the conventional commit form and matches the WorkspaceSearchIndex surrogate-pair fix in the summary and objectives.
Full details: Description check
-
Explanation
The description follows the template. It has a Problem section with a deterministic repro and expected behavior, a Change section explaining the surrogate-pair backoff, a Scope section explaining why no issue is needed, and a Verification section with a base failure, head passes, check results, and a runtime transcript link. It names the model and harness used. The description does not reproduce the template's HTML comments, which is acceptable.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between dff00e7 and a572c94.
Files selected for processing: 1
-
apps/server/src/workspace/WorkspaceSearchIndex.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Evidence
Created a committed repository containing long.txt (needle + 505 ASCII a characters + 😀) and 30,000 filler files. On fresh databases, opened the real web client, pressed Ctrl+Shift+F, searched for needle, and captured the first result and its DOM text. Chromium 156, Linux, 1280×800, light theme. scenarios:prove exited 0: fails on base, passes on head.
The dialog's CSS ellipsis hides the malformed ending visually; the DOM measurements establish the difference. DOM measurements. Scenario source and seed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XS
0-9 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|