Skip to content

πŸ› End port share cleanly on Ctrl+C and hide the editor's ports - #36

Merged
bdsoha merged 1 commit into
mainfrom
feature/port-share-ctrl-c
Dec 2, 2026
Merged

bdsoha merged 1 commit into
mainfrom
feature/port-share-ctrl-c

Conversation

@bdsoha

@bdsoha bdsoha commented Dec 2, 2026

Copy link
Copy Markdown
Member

Description

Two fixes to ws-cli port, found while recording the docs' port-share GIF.

port share on Ctrl+C: the command exited without printing anything, so the shell showed ^C%.
It now ends the line and confirms the share ended:

Press Ctrl+C to stop
^C
βœ“ Port 8000 is private again

The port already went private when the stream closed (ws-server releases the share on close); only the output changes.
If Ctrl+C comes before the server confirms the share, the line just ends: nothing claims a port went private that never went public.
serve current --share shares the same output.

port list showed the editor's own ports: the server port and the extension host's random ports were listed beside the user's.
A port is now left out when it is the configured server port (server.port), or when every socket listening on it belongs to a process whose executable is under /usr/lib/workspace/ (the editor, its extension host and helpers).
Processes started from the integrated terminal run other executables, so they stay listed; a socket whose owner cannot be read counts as the user's.
The MCP port_list tool runs the same command, so it gets the same list.

What type of PR is this? (check all that apply)

  • πŸ› Bug Fix
  • ✨ New Feature
  • 🧼 Refactor (non-breaking change)
  • πŸ“„ Help Text or CLI Docs Update
  • πŸ§ͺ Test Update or Coverage Improvement
  • 🎨 Style (formatting, naming, etc.)
  • πŸ— Build or Dependency
  • πŸ”„ Revert

How to test this PR

  1. go test ./...: includes SIGINT/SIGTERM after a confirmed share, Ctrl+C before confirmation, and editor-port detection against a fake /proc.
  2. In a workspace with public ports enabled, run ws-cli port share 8000 and press Ctrl+C: the last line is βœ“ Port 8000 is private again.
  3. Run ws-cli port list: 8080 and the extension host's ports are gone, ports opened from the terminal remain.

Step 2 needs a workspace image whose editor supports /ports/share; it was checked against ws-server's source and a fake server, not a live share.

@bdsoha
bdsoha merged commit d862718 into main Dec 2, 2026
3 checks passed
@bdsoha
bdsoha deleted the feature/port-share-ctrl-c branch December 2, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant