fix(server): device hub error diagnostics keep emoji whole at the 2,000-character limit #48287
main fromrefs/pull/48287/head·opened View on GitHubProblem#
Long Expo Device Hub diagnostics can split a UTF-16 surrogate pair at the 2,000-unit limit. A boot failure then carries a lone high surrogate before the ellipsis, which survives JSON and can display as a replacement character in the Device panel.
Deterministic repro on origin/main (4b8199987cb63f82912b8f3dbe9de6a96cdb057b): Open an unbooted Android AVD through the Device panel (device.open → DeviceService.open → POST /api/devices/boot). For the regression fixture, have the hub respond with ok: false and error: "a".repeat(1_998) + "🚀" + "b".repeat(10). Apply only the added test to base and run vp test run apps/server/src/device/DeviceService.test.ts -t 'keeps hub boot diagnostics well-formed when truncating at an emoji'.
- Observed: the decoded
DeviceBootErrorends in\uD83D…;message.isWellFormed()isfalse. - Expected: the decoded diagnostic is
"a".repeat(1_998) + "…";message.isWellFormed()istrue.
Change#
Drop a trailing high surrogate from the truncated prefix before appending the ellipsis; keep the existing 2,000-unit cap and leave shorter messages alone. The shared server helper handles both boot errors and discovery warnings from local and SSH hubs, so web, desktop, mobile, and MCP consumers need no client or protocol changes.
Scope#
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification#
- Base failed with
AssertionError: expected false to be true // Object.is equality; the same focused case passed on head.vp run check:changedexited 0, including 82 passing tests. - Real hub before/after transcript: an Android emulator executable permission error supplied an emoji at UTF-16 index 1,998. The decoded error changed from malformed (2,000 units) to well-formed (1,999 units).
- Not shown: Web, desktop, and mobile rendering; live MCP transport; SSH and iOS hosts; discovery warnings in the runtime transcript.
Authored by GPT-6.2 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
a7883efMacroscope's review found this PR approvable — Device Hub diagnostics avoid leaving a split emoji at the truncation boundary while retaining the existing length limit. The change is confined to error and warning text, with no change to device operations or product defaults.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Walkthrough
-
When diagnostics exceed 2,000 characters,
boundDiagnosticsremoves a trailing unmatched high surrogate from the truncated prefix before adding an ellipsis. A regression test checks the decoded boot error message and the resulting diagnostics.Changes: Boot diagnostics
Layer / File(s) Summary Truncation and regression test
apps/server/src/device/DeviceHubOperations.ts,apps/server/src/device/DeviceService.test.tsboundDiagnosticsremoves a trailing unmatched high surrogate before adding an ellipsis. The test checks that diagnostics truncated at an emoji boundary produce a well-formed decoded message and the expected 1,998-character prefix followed by an ellipsis.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk:
Minimal · up toa7883-
Device Hub diagnostics truncated at the 2,000-character limit no longer end in a broken emoji character. The change is small and covered by a regression test, so no merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: the device hub diagnostic truncation at the 2,000-character limit now keeps surrogate pairs (emoji) whole. The raw summary confirms the change drops a trailing unmatch… Description check The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the cause and a deterministic repro. The Change section explains the fix and w… 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 device hub diagnostic truncation at the 2,000-character limit now keeps surrogate pairs (emoji) whole. The raw summary confirms the change drops a trailing unmatched high surrogate before the ellipsis. The title is specific, follows conventional commit style, and matches the objectives.
Full details: Description check
-
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the cause and a deterministic repro. The Change section explains the fix and why no client changes are needed. Scope links no issue but explains why none is needed for a small obvious bug. Verification gives focused test results, a before/after transcript, and lists what was not checked. The optional agent-model line is present. The description does not include a UI screenshot, but the change has no UI rendering diff, so this is not required. The Scope section does not link an issue, which the template asks for unless an exception is stated, and the author states the exception.
-
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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 4b81999
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6933c7dc-7753-4a3a-a090-56907e6693b6
Commits-
Reviewing files that changed from the base of the PR and between 4b8199987cb63f82912b8f3dbe9de6a96cdb057b and a7883efa776ebc6660bbc91adb7fe4e300bd5993.
Files selected for processing: 2-
apps/server/src/device/DeviceHubOperations.tsapps/server/src/device/DeviceService.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
-
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes