anomalyco / anomalyco/opencode

PTY replay chunking corrupts Unicode at frame boundaries

Open
#48,303 1 comment 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Sep 10, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

PTY replay is split into string frames by UTF-16 code-unit count. When a non-BMP character crosses the 64 KiB boundary, one frame ends with its high surrogate and the next starts with its low surrogate. WebSocket encoding processes the frames separately, turning both halves into replacement characters, so reconnected terminal output is corrupted. Chunk boundaries should never split a surrogate pair.

Plugins

None

OpenCode version

1.18.30

Steps to reproduce
  1. Create replay text containing 65,535 ASCII characters followed by 😀.
  2. Pass it to the PTY replay chunking helper.
  3. UTF-8 encode and decode each returned chunk separately, as separate text frames are handled.
  4. Join the decoded frames.

Expected: the joined output equals the original replay text.

Actual: the emoji becomes two replacement characters because its surrogate pair was split across frames.

Screenshot and/or share link

Not applicable; the steps above reproduce the protocol-level corruption directly.

Operating System

All

Terminal

All

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.