Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: a sandbox command that reached the box never runs twice

ogsamrata07e3f2e8d7d
diff --git a/apps/desktop/box/go/cmd/boxsh/main.go b/apps/desktop/box/go/cmd/boxsh/main.go
index 736c4004..51a859da 100644
--- a/apps/desktop/box/go/cmd/boxsh/main.go
+++ b/apps/desktop/box/go/cmd/boxsh/main.go
@@ -120,8 +120,13 @@ func main() {
os.Exit(125)
}
}
+ if err != nil && !isDialError(err) {
+ // The command reached boxd and may have run: never again (a second git commit, a second install).
+ fmt.Fprintln(os.Stderr, retryFailed(err))
+ os.Exit(125)
+ }
if err != nil {
- // boxd is not reachable (restarting, crashed): run it with the runtime's exec instead.
+ // boxd is not reachable (restarting, crashed): nothing started, so the runtime's exec runs it instead.
code = runtimeExec(rec, req)
timing.Fallback = true
}
diff --git a/apps/desktop/box/go/cmd/boxsh/main_test.go b/apps/desktop/box/go/cmd/boxsh/main_test.go
index 54a9222d..7ec1ca73 100644
--- a/apps/desktop/box/go/cmd/boxsh/main_test.go
+++ b/apps/desktop/box/go/cmd/boxsh/main_test.go
@@ -215,3 +215,15 @@ func TestRetryFailedSaysWhatBroke(t *testing.T) {
}
}
}
+
+// A command that reached boxd may have run: only a failed dial (nothing started) may run it another way.
+func TestOnlyADialFailureRunsTheCommandAnotherWay(t *testing.T) {
+ if !isDialError(&net.OpError{Op: "dial", Net: "tcp", Err: errors.New("connect: connection refused")}) {
+ t.Fatal("a refused dial started nothing")
+ }
+ for _, err := range []error{errors.New("EOF"), &net.OpError{Op: "read", Net: "tcp", Err: errors.New("connection reset by peer")}, &net.OpError{Op: "write", Net: "tcp", Err: errors.New("broken pipe")}} {
+ if isDialError(err) {
+ t.Fatalf("%v came after the command started", err)
+ }
+ }
+}