Repository navigation
feat(term): decode SGR mouse reports in the wasm read-key - #1094
Merged
Merged
Conversation
Collaborator
Author
|
Self-review found nothing actionable at The extraction preserves native behavior and correctly adds mouse maps to WebAssembly Verified:
Local full-suite verification was limited by sandbox port restrictions and unrelated WebAssembly test compilation errors. |
nooga
approved these changes
Oct 26, 2026
nooga
left a comment
Owner
There was a problem hiding this comment.
Approving. Sharing keyValue between native and wasm read-key keeps the two from drifting.
Nit: pkg/rt/key_value.go has no copyright/SPDX header like its neighbours.
mparrett
force-pushed
the
wasm-mouse-decode
branch
from
October 28, 2026 06:18
54b5416 to
b5625a5
Compare
The wasm read-key returned mouse reports as raw escape strings, so a program that enables mouse reporting got a map on native and a string in the browser. Both read-keys now go through keyValue, which turns a report into the tagged map from nooga#313. mouseEventMap moves out of the native-only term.go so the wasm build can reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mparrett
force-pushed
the
wasm-mouse-decode
branch
from
October 28, 2026 06:41
b5625a5 to
a7b6789
Compare
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.
Why
#313 added SGR mouse decoding to the native
term/read-keyand left the wasmread-keyreturning the raw report string, noted there as a follow-up. A program that enables mouse reporting therefore gets{:type :mouse :action :press :button :left :x 10 :y 5 :mods #{}}in a terminal and"\e[<0;10;5M"in the browser. A game that steers by mouse works natively and silently ignores the mouse underlg -w.What
keyValue(inpkg/rt/key_value.go, no build tag) turns one key-source token into read-key's return: nil for"", the tagged map for an SGR mouse report, otherwise the string. The native and wasmread-keyboth call it, so the two can't drift apart.mouseEventMapmoves there unchanged from the native-onlyterm.go, which is why the wasm build couldn't use it.enable-mousecomment interm_wasm.gono longer says the decode is missing.Plan 9's
read-keyis unchanged.Verification
TestKeyValuecovers nil, plain keys, and a modified mouse release (:mods #{:shift :ctrl});go test -short ./pkg/rt/passes.GOOS=js GOARCH=wasm go build ./pkg/rt/and the Plan 9 build pass.lg -wagainst this branch, with 1003 + 1006 reporting on. The paddle follows the mouse to either side of the board; onmainit stays put while the same reports arrive as strings.🤖 Generated with Claude Code