Skip to content

feat: attach to the machines a host's Herdr saved - #30

Merged
nimrc merged 3 commits into
mainfrom
feat/saved-machines
Nov 16, 2026
Merged

nimrc merged 3 commits into
mainfrom
feat/saved-machines

Conversation

@nimrc

@nimrc nimrc commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Fixes #29.

Herdr's own client switches between Local and the SSH machines saved with herdr machine add. Each machine is a server of its own, which the client reaches over SSH. Running herdr --remote B inside a pane on A only shows B as that pane's terminal: A's server knows nothing about B, so Bellterm, attached to A, listed only A's workspaces.

Bellterm now does what Herdr's client does. The session drawer lists the host and the machines its Herdr saved, and tapping one attaches to that machine's server through the host.

What changed

  • herdr-client relay_command(target, command) builds ssh <bridge policy> -- <target> '<command>' for the host's own /bin/sh. That ssh runs with BatchMode, StrictHostKeyChecking=yes and no forwarding, so the host's keys, ssh config, known hosts and Herdr's shared ControlPath sign in to the machine. The phone needs no access to it.
  • native
    • Route has an optional relay. Remote wraps every command through it, so the bridge, the Windows fallback, and Install/Update Herdr all reach the machine.
    • Before bridging, exit 0 is run through the relay. An unreachable machine then reports the host's ssh error (… could not be reached from its jump host: ssh: connect to host … Connection refused) instead of reading as a host without Herdr.
    • machines::list runs herdr machine list --json with the first Herdr the bridge would find, keeping enabled machines with valid targets; it is exposed over JNI as Native.listMachines.
  • Android
    • The drawer gets a Machines section (host first, then its machines), loaded when the drawer opens. Tapping one opens that machine's session; the host stays attached, like Herdr's sidebar.
    • A machine is saved as a node with machine = its SSH target and jumpId = the host. It shows via the host, can't be edited or duplicated, isn't offered as a jump host, and is deleted with its host.
  • README: the feature, and the new live test.

Screenshots

Taken by GlassUiTest.t8_switchesToSavedMachine on an API 35 emulator in CI, against a real sshd with two Herdr sessions.

Host's drawer: Machines After switching: B's own workspaces (on-b) Node list: B via its host

Tests

  • Unit:
    • herdr-client: relay_command quoting and validation (/bin/sh re-parses it), 267 passed locally.
    • native: machine-list parsing and the discovery script, route documents with relay.
    • Kotlin: Routes.sshHops, password hops, Machine parsing, Node JSON with machine.
  • New CI job Saved machine through its host (Ubuntu): starts a local sshd, installs Herdr, and saves the session machine with herdr machine add ssh://runner@127.0.0.1:2222 --remote-session machine. Then it runs two tests:
    • live_ssh::attaches_to_a_saved_machine_through_its_host: lists the machine over SSH, attaches through the host, round-trips echo, checks the machine's own workspace, and checks that an unreachable target reports the host's ssh error.
    • The Android app on an emulator (GlassUiTest.t0 publishes the device key, then t8): drawer, switch, back, and deletion with the host. The job fails if the test was skipped.
  • The bellterm crate cannot be built on this Mac (Zig 0.15.2 against the macOS 27 SDK), so native was built and tested in CI only.

Herdr's own client switches between Local and the SSH machines saved with herdr machine add, each a server of its own; running herdr --remote inside a pane only shows the other server as that pane's terminal. Bellterm now lists a host's saved machines in the session drawer and attaches to one through the host: a route may carry a relay target, and every remote command then runs as ssh with the bridge's policy on the host, so the host's keys, configuration and known hosts sign in. Unreachable targets report the host's ssh error. Each machine is saved as a node via its host.

Refs #29
GlassUiTest.t8 opens the drawer of a host whose Herdr saved a machine, switches to it, checks the machine's own workspace, and switches back. CI runs it on an emulator against the saved-machine job's sshd, after t0 publishes the device key for that host to trust, and keeps the screenshots.
@nimrc
nimrc marked this pull request as ready for review November 16, 2026 15:31
@nimrc
nimrc merged commit a95bd54 into main Nov 16, 2026
4 checks passed
@nimrc
nimrc deleted the feat/saved-machines branch November 16, 2026 15:31
nimrc added a commit to nimrc/bellterm-ios that referenced this pull request Nov 16, 2026
* feat: attach to the machines a host's Herdr saved

Sync native/ and crates/ with Bellterm for Android at nimrc/bellterm#30. The session sidebar lists the host and the SSH machines its Herdr saved with herdr machine add; tapping one attaches to it through the host's own ssh, and the machine is saved as a node via its host. bellterm-ffi exposes list_machines. MachineTests covers routes, storage and parsing, and renders the sidebar with machines.

* test: draw the sidebar snapshot in the host app's scene
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.

通过 herdr remote 连接另一台服务器后,工作区列表未正确加载

1 participant