Skip to content

fix(server): long worktree setup details no longer end in half an emoji - #41629

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/server-worktree-setup-surrogate-clamp
Nov 23, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/server-worktree-setup-surrogate-clamp

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

The worktree setup card can show a stray replacement character (�) right before the … of a cut-off line. The server's WorktreeSetupTracker caps a stage's detail at 200 UTF-16 code units and the failure error at 1000 by slicing at maxLength - 1. When an emoji or another non-BMP character sits on that boundary, the cut keeps only its first half. Both texts can carry user paths: a submodule's path comes from git's output, and a failed setup's error includes the project folder and git's stderr. The client then receives a lone surrogate. The web and mobile cards show the error in full, so the broken character is visible there.

#40701 fixed the same cut in ProjectSetupScriptRunner but left this helper alone.

Change

clampText in WorktreeSetupTracker.ts now uses the same splitsSurrogatePair check as #40701 and stops one code unit earlier when the cut would split a pair. The result still fits the contract's limit. Stage details, setup output lines and the failure error all go through this one helper. One test is added to WorktreeSetupTracker.test.ts.

Verification

An AI agent ran each check on Linux with no accounts.

Setup: Linux x86_64, Node 26.13.1, git 2.53.0, a throwaway repository in a temp folder.
Steps: a small script that runs real git and passes its output through the same steps the server uses, into a real WorktreeSetupTracker, then reads the snapshot back through JSON the way the WebSocket sends it.

  • The submodule-path detail comes from git submodule update --init --progress, with the submodule at a 206-unit path that has 🚀 at units 198–199.
  • The failure error comes from a git worktree add that fails into an existing folder named 🚀 release. Its stderr is wrapped the way GitCommandError and the launch failure do, giving 1024 units with 🚀 at 998–999.
e86a9c51696d (main) 005abe037809 (this PR)
Stage detail (200) …ee\ud83d…, well-formed: false …eee…, well-formed: true
Failure error (1000) …y/\ud83d…, well-formed: false …yy/…, well-formed: true
  • vp test run src/project/WorktreeSetupTracker.test.ts: the new case fails on main (\ud83d before …) and passes here (6/6).
  • vp run check:changed: passes.

Generated with Gemini 4 Neon in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 005abe0 and 3a045a0.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

WorktreeSetupTracker now avoids splitting a UTF-16 surrogate pair when it truncates text. A test checks the behavior for stage details and finish errors.

Changes: Surrogate-safe text truncation

Layer / File(s) Summary
Safe clamping and tests
apps/server/src/project/WorktreeSetupTracker.ts, apps/server/src/project/WorktreeSetupTracker.test.ts
clampText moves the truncation boundary back one code unit when it would split a surrogate pair. Tests check truncated stage details and finish errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: bugfix

Suggested reviewers: macroscopeapp, juliusmarminge

Merge Risk: Minimal · previous review 005ab

This change prevents truncated setup text from ending with a broken character before the ellipsis. The change is small and tested, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (a truncated worktree setup detail no longer ends in a broken surrogate character) and the component (server). It matches the main change in WorktreeSetupTracker's clampText, s…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the lone surrogate and the replacement character, with the expected behavio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (a truncated worktree setup detail no longer ends in a broken surrogate character) and the component (server). It matches the main change in WorktreeSetupTracker's clampText, so it passes. It is conventional-commit style and specific. The phrase 'half an emoji' is informal but still accurate.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the lone surrogate and the replacement character, with the expected behavior. The Change section explains the clampText update and the shared helper, and it cites the related PR #40701. The Scope section is missing. It does not link an issue that shows the bug, and it does not say why no issue is needed. The Verification section is strong. It lists the environment, steps, before and after results, and the test run. It also names the model and harness used, as the template asks. The template asks for an agent's model and harness, and the author gives 'Gemini 4 Neon in T3 Code Nightly', so that requirement is met.

Resolution

Add a Scope section. Link the issue that shows the bug, or explain in one sentence why this small obvious fix needs no issue.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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 0fd87d3 and 005abe0.

Files selected for processing: 2

  • apps/server/src/project/WorktreeSetupTracker.test.ts
  • apps/server/src/project/WorktreeSetupTracker.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created the reported 204-unit submodule path, configured an automatic blocking Slow setup action, and started a Replay thread in a new worktree on both commits. Captured Init submodules while setup ran. Both captures use Chromium, 1280×800, light theme, fresh synthetic state, and identical RTL/outline/enlargement to reveal the normally clipped tail; terminal output is hidden for privacy.

Proven: the scenario fails on base and passes on head. The base renders a replacement glyph and its detail is not well-formed Unicode. The head truncates cleanly, ends with an ellipsis, and stays within 200 UTF-16 units.

Before After
Commit 4328d9c95c 3a045a0958
Submodule detail tail Before: broken surrogate After: clean truncation
Recording, cropped to setup card Before recording After recording

Scenario source.

Not shown:

  • The 1000-unit failed-worktree error path was not exercised; this proof covers the reported 200-unit submodule setup detail path.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 221bc8a into pingdotgg:main Nov 23, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants