[PR #12178] fix(app): derive terminal WebSocket URL from browser origin instead o… #14105

Closed
opened 2026-02-16 18:18:55 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12178

State: closed
Merged: Yes


What does this PR do?

Fixes #5844.

Terminal WebSocket URLs were built from sdk.url (often localhost:4096), which breaks when the web UI is opened from a network host (LAN/Tailscale IP). --mdns helps discovery by publishing a LAN hostname, but it does not change this WebSocket URL construction path.

This PR extracts terminal URL construction into a testable ptySocketUrl() helper and uses the browser origin (window.location host + protocol) so the terminal WebSocket connects to the same host/port that served the UI.

while this bothers me, maybe it was not changd upstream for a reason? If that's the case, will close.

How did you verify your code works?

  • Added unit tests in terminal-url.test.ts covering: localhost -> LAN host replacement, https -> wss, port preservation, and / base URL edge case
  • Manual verification on dev VM (proxmox nixos vm + tailscale).
    image
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12178 **State:** closed **Merged:** Yes --- ### What does this PR do? Fixes #5844. Terminal WebSocket URLs were built from `sdk.url` (often `localhost:4096`), which breaks when the web UI is opened from a network host (LAN/Tailscale IP). `--mdns` helps discovery by publishing a LAN hostname, but it does not change this WebSocket URL construction path. This PR extracts terminal URL construction into a testable `ptySocketUrl()` helper and uses the browser origin (`window.location` host + protocol) so the terminal WebSocket connects to the same host/port that served the UI. while this bothers me, maybe it was not changd upstream for a reason? If that's the case, will close. ### How did you verify your code works? - Added unit tests in `terminal-url.test.ts` covering: localhost -> LAN host replacement, `https` -> `wss`, port preservation, and `/` base URL edge case - Manual verification on dev VM (proxmox nixos vm + tailscale). <img width="1800" height="600" alt="image" src="https://github.com/user-attachments/assets/417bf8bf-e69b-48b8-b3f8-705f53dcd764" />
yindo added the pull-request label 2026-02-16 18:18:55 -05:00
yindo closed this issue 2026-02-16 18:18:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14105