Skip to content

fix: command center socket.io auto-detect host instead of hardcoded localhost#1470

Open
aphexcx wants to merge 1 commit intodimensionalOS:devfrom
aphexcx:fix/command-center-auto-detect-host
Open

fix: command center socket.io auto-detect host instead of hardcoded localhost#1470
aphexcx wants to merge 1 commit intodimensionalOS:devfrom
aphexcx:fix/command-center-auto-detect-host

Conversation

@aphexcx
Copy link

@aphexcx aphexcx commented Mar 7, 2026

Problem

The command center's Socket.IO connection is hardcoded to ws://localhost:7779 in Connection.ts. When the command center is accessed remotely (e.g., via NAT from a different machine), the browser tries to connect back to localhost — which points to the browser's own machine, not the server. This silently breaks all command center functionality (costmap display, keyboard control, etc.).

Fix

Changed io("ws://localhost:7779")io() in Connection.ts:22.

io() with no arguments auto-detects the host from the page URL, which is the correct behavior for both:

  • Local dev: page served from localhost:7779, connects to localhost:7779
  • Remote access: page served from 10.x.x.x:7779, connects to 10.x.x.x:7779

Rebuilt data/command_center.html with the fix.

Files changed

  • dimos/web/command-center-extension/src/Connection.ts — one-line change
  • data/command_center.html — rebuilt
  • data/.lfs/command_center.html.tar.gz — rebuilt

…ocalhost

Changes io("ws://localhost:7779") to io() which auto-detects the host
from the page URL. This fixes the command center when accessed remotely
(e.g. via NAT from a different machine), where localhost points to the
browser's machine instead of the server.

Rebuilt data/command_center.html with the fix.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a one-line bug in the Command Center's Socket.IO connection setup that caused silent failures when the UI was accessed remotely (e.g., via NAT). The hardcoded ws://localhost:7779 URL was replaced with a no-argument io() call, which auto-resolves the host from window.location — the standard Socket.IO pattern for serving client and server from the same origin. The rebuilt data/command_center.html artifact and its LFS-tracked archive are also updated.

Key changes:

  • Connection.ts: io("ws://localhost:7779")io() — correct fix; websocket_vis_module.py already binds uvicorn to 0.0.0.0 and serves both HTTP and Socket.IO on the same port, so auto-detection works for both local and remote access.
  • data/command_center.html: Rebuilt artifact verified to contain zero occurrences of the old hardcoded URL.
  • data/.lfs/command_center.html.tar.gz: LFS pointer updated to the new archive with the expected size increase.
  • Minor: data/command_center.html is tracked as a plain git object while the equivalent .tar.gz is LFS-tracked — both copies must be kept in sync on every rebuild.

Confidence Score: 5/5

  • Safe to merge — minimal, well-scoped fix with no regressions for local usage and a clear improvement for remote access.
  • The source change is a single line that applies the canonical Socket.IO pattern for origin auto-detection. The server already binds to 0.0.0.0 and co-hosts Socket.IO on the same port as HTTP, making io() the correct call. The compiled output was verified to contain no residual hardcoded URLs. The only note is a minor artifact-management concern (plain-git vs LFS copy) that doesn't affect runtime behaviour.
  • No files require special attention.

Important Files Changed

Filename Overview
dimos/web/command-center-extension/src/Connection.ts One-line fix replacing hardcoded ws://localhost:7779 with io() (no-args) so Socket.IO auto-detects the host from the page URL; correct and safe.
data/command_center.html Rebuilt frontend artifact with the io() fix applied; verified to contain no hardcoded localhost:7779 references, though the file is tracked directly in git rather than via LFS.
data/.lfs/command_center.html.tar.gz LFS pointer updated to the newly rebuilt archive; OID and size both changed as expected.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant UvicornServer as Uvicorn Server (0.0.0.0:7779)
    participant SocketIO as Socket.IO (same port)

    Note over Browser,SocketIO: Before fix — remote access broken
    Browser->>UvicornServer: GET http://10.x.x.x:7779/command-center
    UvicornServer-->>Browser: command_center.html
    Browser->>Browser: io("ws://localhost:7779")
    Browser--xBrowser: connects to browser's own localhost (wrong host!)

    Note over Browser,SocketIO: After fix — remote access works
    Browser->>UvicornServer: GET http://10.x.x.x:7779/command-center
    UvicornServer-->>Browser: command_center.html
    Browser->>Browser: io() — auto-detects host from window.location
    Browser->>SocketIO: ws://10.x.x.x:7779 (correct host)
    SocketIO-->>Browser: full_state, costmap, robot_pose, path, …
    Browser->>SocketIO: click, move_command, gps_goal, …
Loading

Last reviewed commit: 09707c2

@@ -0,0 +1,129 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built artifact committed alongside LFS archive

data/command_center.html is now tracked as a plain git object (it is not in .gitattributes for LFS treatment), while data/.lfs/command_center.html.tar.gz is tracked via LFS. This creates two separate copies of the same generated file. Every future frontend rebuild will add a large (~137 KB) blob directly to the git history.

Since inline-html.js already creates and manages both outputs, consider adding data/command_center.html to .gitattributes for LFS tracking to avoid growing the regular git object store, or — if the plain file is needed for convenience — explicitly document that both copies must be kept in sync on every rebuild.

@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html lang="en">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aphexcx delete this then should be quick merge

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.

2 participants