[codex] fix(input): buffer Windows console decoder bytes#29
Merged
Conversation
tonyfettes
commented
Jun 10, 2026
tonyfettes
left a comment
Contributor
Author
There was a problem hiding this comment.
- Don't eats up error without testing for @async.is_being_cancelled.
- Use if ... is, don't use match on Option
- Use guard to de-indent code.
Contributor
Author
|
Addressed the latest review feedback in Notes on the non-literal bits:
|
tonyfettes
commented
Jun 10, 2026
| } noraise { | ||
| byte => byte | ||
| } | ||
| @async.protect_from_cancel() <| () => { |
Contributor
Author
There was a problem hiding this comment.
Why we protected from cancel here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
internal/io.ByteQueue, an internal byte source that implements@async/io.Readerand supports synchronous byte enqueueing.ByteQueueso key-record bytes are buffered before the shared input decoder consumes them.try_put.examples/rawto show printable ASCII characters next to raw byte values.Why
Windows
ReadConsoleInputWkey records can represent VT mouse sequences as individual UTF-16 characters. The previous unbuffered pipe write could suspend inside the short-lived record producer; if a direct event won the read race, the producer could be cancelled before the tail of the VT sequence reached the decoder. That made examples/input display fragments such as[3;20Mas key events.Buffering bytes in an internal queue makes producer-side enqueueing synchronous, while preserving the existing shared input decoder and direct native event queue.
Validation
moon fmtmoon test internal/io --target-dir .moon-test-internal-io-bytequeue-buildmoon test . --filter "win32*" --target-dir .moon-test-win32-bytequeue-shape-buildmoon test internal/input --filter "decode delayed *mouse*" --target-dir .moon-test-input-delayed-mouse-bytequeue-shape-buildmoon check --target-dir .moon-check-bytequeue-shape-buildmoon info --target-dir .moon-info-bytequeue-shape-buildgit diff --check