Repository navigation
Find dev-server ports in Git Bash and WSL panes on Windows - #1348
Merged
Merged
Conversation
Git Bash: an MSYS exec replaces the Windows process, so a program like `winpty node.exe` named a parent that had exited and the walk from the pane never reached it. MSYS ps keeps those links; a Git Bash root's owned set now grows through them. WSL: a Linux listener is no Windows process, and with mirrored networking not even a Windows socket. A root running wsl.exe now has its listeners read inside each running distro, from the processes whose environment carries the pane's DORMOUSE_SURFACE_ID. Each read runs beside a step the scan already waits for, within its budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying mouseterm with
|
| Latest commit: |
8454f3a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://65939c22.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-port-detection-wsl-gitba.mouseterm.pages.dev |
dormouse-bot
left a comment
Collaborator
There was a problem hiding this comment.
ptySurfaces stores a value that is always the PTY id. spawn calls resolveSpawnConfig({ ...options, id, surfaceId: id }, …), which sets DORMOUSE_SURFACE_ID: surfaceId || options?.id || '', so the map's value always equals its key. surfaceOf can return idAtPid(pid) directly. That drops the map and its three cleanup sites, which would otherwise need to stay in step with ptyShells. The suggestions below make that change.
…SURFACE_ID Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dormouse-bot
approved these changes
Oct 21, 2026
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.
Dev-server port detection (Dev-Server Chip,
dor agent-browser open surface:N,dor list --ports) worked for cmd and PowerShell panes on Windows but not for Git Bash or WSL.Git Bash. Ports come from walking the Windows process tree down from the pane's shell. An MSYS exec replaces the Windows process, so
node(which Git runs aswinpty node.exeunderTERM=xterm*) hung off awinpty.exewhose Windows parent had already exited, and the walk never reached it. For a root whose shell is Git Bash, the scan now also reads MSYS's ownps -a(which keeps the parent links and names each Windows pid). Each owned set then grows from its MSYS processes to their MSYS descendants, and from those to their Windows descendants.psruns beside the process-table read.WSL. With mirrored networking, a Linux listener on 127.0.0.1 is reachable from Windows but appears in neither
Get-NetTCPConnectionnornetstat, so no Windows-side walk can find it. For a root withwsl.exeanywhere beneath it (a WSL pane, orwsltyped into PowerShell), the scan lists running distros and runs oneshscript in each. The script finds processes whose environment carries the pane'sDORMOUSE_SURFACE_ID(which already crosses in throughWSLENV) with a singlegrep -zover/proc/*/environ, lists their sockets, and reads/proc/net/tcp{,6}. That runs beside the Windows socket scan, within its allowance. Surface ids are validated before they reach the script.Specs:
docs/specs/transport.md→ "Message protocol" (pty:getOpenPorts) and "Port scan deadlines", with the measurements in the rationale.Testing
node.exehangs off an orphanedwinpty.exe(found through MSYSps) and whose WSL listener is found in the distro, attributed only to its Surface. A cmd-only scan runs neither extra read.create()on Windows 11 with mirrored networking: Git Bash runningnode -e "...listen(43123)"reports 43123 (node.exe); a WSL pane runningpython3 -m http.server 43124reports 43124 (python3);wsltyped into a PowerShell pane does too. OnegetOpenPortsManyfor both took ~0.9 s.Limits: bash typed inside a PowerShell or cmd pane gets no MSYS read (the trigger is the pane's own shell). A Linux process that drops its environment, or a daemon outside the pane's tree, isn't found.
🤖 Generated with Claude Code