Skip to content

feat(desktop/fleet): run a command/script locally (a 'this machine' fleet target) - #49

Merged
ralyodio merged 1 commit into
mainfrom
feat/local-fleet-runner
Sep 26, 2026
Merged

ralyodio merged 1 commit into
mainfrom
feat/local-fleet-runner

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

The desktop Fleet view could only run a script over SSH on selected servers. This adds a localhost (this machine) target so you can run a command/script on the local machine — including one that itself fans out to the fleet (an ssh loop, an rsync push, the threatcrush rollout).

How

A synthetic localhost connection (reserved id local) is added to the fleet server list. It runs through a new LocalSession that implements the exact slice of SshSession the runner uses — execStream(cmd, opts) → ExecHandle — backed by child_process. So runFleet targets the local host with zero fleet-core changes: connectFleet() returns a LocalSession for the local id and a pooled SshSession for every other host.

Everything else is identical — interpreter, hazard check, live streaming, run history, saved commands. Only the transport differs.

  • No new trust boundary: local runs go through the same fleet path, gated by the same hazard-check + confirmation the renderer already can't bypass. The fleet feature already accepts renderer-supplied script text by design.
  • No renderer change needed: FleetView lists servers dynamically, so localhost appears as a tickable target and streams output like any host.
  • LocalSession spawns detached and kills the whole process group on timeout/cancel, so a script that spawned its own children is stopped as a group.

Tests

local-session.test.ts — stdout/stderr line streaming, exit codes, stdin (sudo -S path), timeout→timedOut, cancel. Desktop suite 162 pass; renderer + electron typecheck clean.

🤖 Generated with Claude Code

…ust servers

The Fleet view could only run a script over SSH on selected servers; there was
no way to run something LOCALLY — e.g. a script that itself fans out to the fleet
(an ssh loop, an rsync push, the threatcrush rollout).

Add a synthetic "localhost (this machine)" target to the fleet server list. It
runs through a LocalSession that implements the exact slice of SshSession the
runner uses (execStream → ExecHandle), backed by child_process, so runFleet
targets the local host with zero fleet-core changes: connectFleet() hands back a
LocalSession for the reserved `local` connection id and a pooled SshSession for
every other host. The interpreter, hazard check, streaming, run history and saved
commands are all identical — only the transport differs.

Because it flows through the existing fleet path, local runs are gated by the same
hazard-check + confirmation the renderer already can't bypass; this adds no new
trust boundary (the fleet feature already accepts renderer-supplied script text).
The renderer needs no change: FleetView lists servers dynamically, so localhost
shows up as a tickable target and its output streams like any host.

LocalSession spawns detached and kills the whole process group on timeout/cancel,
so a script that spawned its own children is stopped as a group.

Tests: local-session.test.ts (stdout/stderr line streaming, exit codes, stdin,
timeout→timedOut, cancel). Desktop suite 162 pass; renderer + electron typecheck
clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio
ralyodio merged commit da0a20b into main Sep 26, 2026
4 checks passed
@ralyodio
ralyodio deleted the feat/local-fleet-runner branch September 26, 2026 20:53
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