Repository navigation
feat(desktop/fleet): run a command/script locally (a 'this machine' fleet target) - #49
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
localhostconnection (reserved idlocal) is added to the fleet server list. It runs through a newLocalSessionthat implements the exact slice ofSshSessionthe runner uses —execStream(cmd, opts) → ExecHandle— backed bychild_process. SorunFleettargets the local host with zero fleet-core changes:connectFleet()returns aLocalSessionfor thelocalid and a pooledSshSessionfor every other host.Everything else is identical — interpreter, hazard check, live streaming, run history, saved commands. Only the transport differs.
FleetViewlists servers dynamically, solocalhostappears as a tickable target and streams output like any host.LocalSessionspawns 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