Skip to content

Fix: multi-byte text decoding in stdout and stderr streams#2

Open
Revi1337 wants to merge 2 commits into
reallygood83:mainfrom
Revi1337:fix-encoding-issue
Open

Fix: multi-byte text decoding in stdout and stderr streams#2
Revi1337 wants to merge 2 commits into
reallygood83:mainfrom
Revi1337:fix-encoding-issue

Conversation

@Revi1337

@Revi1337 Revi1337 commented Jun 15, 2026

Copy link
Copy Markdown

When streaming child process output, using chunk.toString() directly on Buffer chunks splits multi-byte characters (like Korean, Japanese, etc.) if the chunk boundary falls in the middle of a character sequence.

This replaces chunk.toString() with a TextDecoder initialized with { stream: true }, allowing it to safely buffer and decode incomplete bytes across stream chunks.

Korean Explanation (한국어 설명): 터미널에서 데이터를 받아올 때 청크(Chunk) 단위로 바이트가 끊겨서 한글이 `` 마크로 깨지는 문제를 해결하기 위해, TextDecoder에 { stream: true } 옵션을 추가했습니다! 좋은 플러그인 감사합니다.

Before (수정 전)

image

After (수정 후)

image

Summary by CodeRabbit

  • Refactor
    • Enhanced streaming output decoding in process execution with improved UTF-8 character handling, ensuring more robust capture and processing of child process output.

When streaming child process output, using chunk.toString() directly on Buffer chunks splits multi-byte characters (like Korean, Japanese, etc.) if the chunk boundary falls in the middle of a character sequence.

This replaces chunk.toString() with a TextDecoder initialized with { stream: true }, allowing it to safely buffer and decode incomplete bytes across stream chunks.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Revi1337, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f11d247-c756-4012-8e57-717d52496fd9

📥 Commits

Reviewing files that changed from the base of the PR and between f633632 and a6beea9.

📒 Files selected for processing (2)
  • src/core/agent/AntigravityProvider.ts
  • src/core/cli/ExternalCliRunner.ts
📝 Walkthrough

Walkthrough

Two runProcess implementations — AntigravityProvider and ExternalCliRunner — replace per-chunk Buffer.toString() calls with TextDecoder('utf-8') instances that decode streamed chunks using { stream: true }. All other process lifecycle logic remains unchanged.

Changes

TextDecoder streaming decode for child process output

Layer / File(s) Summary
TextDecoder streaming decode in runProcess
src/core/agent/AntigravityProvider.ts, src/core/cli/ExternalCliRunner.ts
Both runProcess methods create TextDecoder('utf-8') instances for stdout and stderr, then decode each data event chunk with { stream: true } instead of calling chunk.toString(). The stdout/stderr accumulation and line-buffering logic downstream are unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop hop, the chunks come streaming in,
No more .toString() — let the decoder begin!
UTF-8 flows cleanly, byte by byte,
Multi-chunk glyphs now rendered right.
This rabbit approves — the encoding's tight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing chunk.toString() with TextDecoder for proper multi-byte character handling in stdout/stderr streams.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/agent/AntigravityProvider.ts`:
- Around line 120-121: TextDecoder objects created with stream mode keep
buffered bytes that must be explicitly flushed when the stream ends. In
src/core/agent/AntigravityProvider.ts at lines 143-151 in the child.on('close')
handler, add calls to stdoutDecoder.decode() and stderrDecoder.decode() without
arguments before using stdoutFull and stderrFull to flush any remaining buffered
bytes from the decoders created at lines 120-121. Apply the same fix in
src/core/cli/ExternalCliRunner.ts at lines 172-179 in the child.on('close')
handler by adding calls to stdoutDecoder.decode() and stderrDecoder.decode()
without arguments before the resolve/reject logic to flush remaining bytes from
the decoders created at lines 154-155.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 591ca732-3cd4-4683-b4a8-47f10e917f85

📥 Commits

Reviewing files that changed from the base of the PR and between c9d4237 and f633632.

📒 Files selected for processing (2)
  • src/core/agent/AntigravityProvider.ts
  • src/core/cli/ExternalCliRunner.ts

Comment thread src/core/agent/AntigravityProvider.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant