anomalyco / anomalyco/opencode
PTY replay chunking corrupts Unicode at frame boundaries
@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
- Create replay text containing 65,535 ASCII characters followed by
😀. - Pass it to the PTY replay chunking helper.
- UTF-8 encode and decode each returned chunk separately, as separate text frames are handled.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.