Skip to content

fix(server): setup script output no longer ends in half an emoji - #40701

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
tiliakoos:fix/setup-output-split-emoji
Nov 22, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
tiliakoos:fix/setup-output-split-emoji

Conversation

@tiliakoos

Copy link
Copy Markdown
Contributor

Problem

In apps/server/src/project/ProjectSetupScriptRunner.ts, setup script output lines are capped with cleaned.slice(0, OUTPUT_LINE_MAX_LENGTH) (400 UTF-16 code units) and newline-free output is bounded with lineBuffer.slice(-PARTIAL_LINE_MAX_LENGTH) (4,096 UTF-16 code units). When either cut lands between the two halves of a UTF-16 surrogate pair, a lone surrogate reaches WorktreeSetupTracker.appendTail and shows as a replacement character (U+FFFD) in the worktree setup card.

Change

Both slices now check splitsSurrogatePair from @t3tools/shared/assistantCitations (already used by sibling AgentSessionScanner.ts) and step by one code unit when a cut would split a surrogate pair: the 400-unit line cap stops at 399 before a trailing high surrogate, and the 4,096-unit partial-line tail starts one unit later past a leading low surrogate. Limits, escape stripping, and script execution are unchanged.

This re-lands MarcoDotIO's #32217 (Macroscope-approved, self-closed as cosmetic with no maintainer objection), adapted to reuse splitsSurrogatePair on current main, with him as co-author.

Scope

A very small, focused fix for an obvious bug, so no issue is needed: capping valid terminal output should not leave lone surrogates. Both slices guard the same output line on the same path, so they are one underlying problem. Same bug class as merged #39548 and #29647.

Verification

Added ProjectSetupScriptRunner > keeps emoji whole when capping a long output line or partial-line buffer to apps/server/src/project/ProjectSetupScriptRunner.test.ts, emitting both a 400-unit boundary split (x + 250 🙂 + \r\n) and a 4,096-unit partial-line boundary split (2,100 🙂 + x, then \r\n).

On unmodified upstream/main (c1fbdf6cdb) with only the test added, vp test run apps/server/src/project/ProjectSetupScriptRunner.test.ts fails on the new test because the first line ends with a lone high surrogate (U+D83D) and the second line both starts with a lone low surrogate (U+DE42) and ends with a lone high surrogate (U+D83D).

With the fix, all 12 tests in ProjectSetupScriptRunner pass (including the new regression test) and 4 of 5 tests in POSIX setup completion pass; the one failure is reports a nonzero completion for a syntax error (expected exit code 2, received 1), which fails identically on unmodified upstream/main on this macOS machine because /bin/bash is GNU bash 3.2.57 (where eval "if then" exits 1).

Also ran:

  • vp lint apps/server/src/project/: 0 warnings, 0 errors (33 files)
  • vp fmt --check apps/server/src/project/: all matched files formatted (33 files)
  • vp run --filter t3 typecheck (effect-tsgo tsrs --noEmit): 0 errors (exit 0)

Not checked: rendering the worktree setup card in a live client on web, desktop, or mobile (server-only change; no contract or client code changed, and the unit test exercises ProjectSetupScriptRunner's onOutputLine output directly). WorktreeSetupTracker.clampText (used for stage details and launch errors) is left out of scope since setup output lines are already bounded to 400 units by the runner.

Gemini 4 Neon via T3 Code

The 400-unit output line cap and 4,096-unit partial-line tail cap could
cut inside a UTF-16 surrogate pair, leaving a lone surrogate that renders
as a replacement character. Re-lands pingdotgg#32217.

Co-authored-by: MarcoDotIO <20867620+MarcoDotIO@users.noreply.github.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 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 8163983 and 42ebe61.

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

Setup script output truncation now avoids splitting UTF-16 surrogate pairs in completed lines and oversized partial lines. A test covers long emoji-containing output.

Changes: Setup output truncation

Layer / File(s) Summary
Surrogate-safe output limits
apps/server/src/project/ProjectSetupScriptRunner.ts, apps/server/src/project/ProjectSetupScriptRunner.test.ts
Completed lines reduce the output cap when its boundary splits a surrogate pair. Partial-line truncation advances its start boundary when it splits a pair. A test checks long emoji-containing lines.

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

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#32217: Changes the same completed-line and partial-line truncation boundaries in ProjectSetupScriptRunner.

Suggested labels: bugfix

Suggested reviewers: macroscopeapp, juliusmarminge

Merge Risk: Minimal · previous review 81639

Setup script output truncation now keeps emoji whole at both length caps. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(server): setup script output no longer ends in half an emoji" matches the main change. The diff caps setup script output lines and partial-line buffers so a UTF-16 surrogate pair is not…
Description check Passed The description follows the template's sections: Problem, Change, Scope, and Verification. The Problem section explains the lone surrogate bug and the affected slices. The Change section explains the …
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 "fix(server): setup script output no longer ends in half an emoji" matches the main change. The diff caps setup script output lines and partial-line buffers so a UTF-16 surrogate pair is not split. The title is specific and follows the conventional commit style used in the repository template.

Full details: Description check

Explanation

The description follows the template's sections: Problem, Change, Scope, and Verification. The Problem section explains the lone surrogate bug and the affected slices. The Change section explains the fix and why it reuses splitsSurrogatePair. The Scope section explains why no issue is linked and why the change is small. The Verification section lists focused tests, lint, format, and typecheck results, plus the one failing test and what was not checked. The description does not link a bug issue, but it gives a reason for omitting one, as the template allows for small obvious fixes. The agent attribution line is present at the end.

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 3b3f880 and 8163983.

Files selected for processing: 2

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

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 22, 2026
…t-emoji

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created the reported Emoji setup action, imported it through Project actions, and started a new worktree thread. Captured the setup card while the script slept. Both runs used Chromium, 1280×800, light theme, fresh synthetic data, and /bin/sh. Base visibly starts with a replacement glyph and fails the DOM Unicode well-formedness check; head shows whole emoji and passes.

Before After
122d3bf853 42ebe61480
Before: broken emoji boundary After: whole emoji
Before recording After recording

Scenario source. Run with SHELL=/bin/sh and T3_SCENARIO_INHERIT_ENV=SHELL,T3CODE_DEV_SEED.

@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 22, 2026
@juliusmarminge
juliusmarminge merged commit 4e28da0 into pingdotgg:main Nov 22, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 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