Skip to content

Automatic port forwarding #9

Closed

Description

@ado11231

What

A server started on the Agent, such as npm run dev on port 5173, opens at localhost:5173 on the Client with no setup.

Today

  • ssh shares one connection across calls only over iroh, through RemoteCommand.shared in crates/ally-cli/src/ssh.rs. Direct routes open a new connection each time.
  • RemoteCommand.forward forwards one fixed port for a whole command, used only to sign in to tools.
  • Nothing lists the ports work on the Agent listens on.

How

  1. Share the ssh connection on every route, not only iroh, so ports can be added to it while it runs.
  2. The Agent reports listening ports. A new Request::Ports returns each TCP port that a process in an Ally job listens on: port, bind address, job, and program. It wraps ss on Linux and lsof on a macOS Agent, and matches processes to jobs through their process tree. Ports that Docker containers publish are included, labeled Docker. Raises control::VERSION.
  3. Automatic forwarding during ally run and ally attach.
    • The Client asks for ports every 2 seconds over the open control connection, adds each new one with ssh -O forward -L, and removes it with ssh -O cancel when it closes.
    • Forwards last only while run or attach is connected.
    • Forwards listen on 127.0.0.1 only, and target the address the server listens on (127.0.0.1 or [::1]).
    • If the port is taken on the Client, the next free one is used and named.
    • run prints ▶ Forwarding archbox:5173 to localhost:5173 once.
    • In attach, the session bar lists the ports, and a short tmux message appears when one is added.
  4. ally forward <port> forwards any Agent port until Ctrl C, for a server left running after detaching. ally ports lists what is forwarded.
  5. Menu bar. Lists forwarded ports, and a click opens the browser. Notifies the first time a job listens on a port, with the address to open.

The waiting for input notification moved to #136.

Done When

  • A server started in a run or a session opens in the Client's browser over the local network, tailnet, and iroh.
  • A port a Docker container publishes opens on the Client.
  • Ollama's port 11434 opens on the Client.
  • Starting npm run dev in a session notifies with the address to open.

Folds in #21.

Activity

  1. ado11231 commented on Oct 1, 2026

    @ado11231
    OwnerAuthor

    Notes From October 1, 2026

    • Docker ports. The plan finds ports opened by processes inside Slingshot jobs. A container started with docker run -p 5432:5432 opens its port from Docker's own processes, which are not in any job, so it would be missed. Forward the ports Docker publishes too, for example from docker ps --format '{{.Ports}}', run on the Agent like any other command.
    • Local models need this. Ollama listens on 127.0.0.1:11434 on the Agent. Any tool on the Client that talks to Ollama, and a browser UI such as Open WebUI, needs this forward. Tools run inside slingshot attach do not, because there localhost is the Agent.
    • Done when should also cover a Docker container's published port, and port 11434.
  2. added this to the Everyday Use milestone on Oct 16, 2026
  3. ado11231 commented on Oct 18, 2026

    @ado11231
    OwnerAuthor

    Status On October 18, 2026

    All five steps are built and merged:

    Step Pull Request
    Share the ssh connection on every route #137
    The Agent reports listening ports #138, then every port with its owner in #140
    Forwarding during run and attach #139
    ally forward and ally ports #140
    Menu bar port list and server ready notice #141

    Left Before Closing

    • See the menu bar's Ports section and the server ready notice on screen. The helper's output is tested; the panel is not.
    • A server opening over tailnet and over iroh. Everything so far ran over the local network.
    • A Docker container's published port.
    • Ollama's port 11434. On archbox Ollama runs as its own account, so run and attach do not forward it; ally forward 11434 does.

    Known Behavior

    • With several Ally commands open, the first to see a new port forwards it and prints its line, which can be in a different terminal than the server. The forward works either way. Fixing it needs the Client to know its own run's job ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions