Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: review feedback on always-on strategy

Bosch6eb20a68a9a0
diff --git a/dashboard/src/pages/SettingsPage.tsx b/dashboard/src/pages/SettingsPage.tsx
index bf9849fb..e35c29ec 100644
--- a/dashboard/src/pages/SettingsPage.tsx
+++ b/dashboard/src/pages/SettingsPage.tsx
@@ -791,82 +791,96 @@ export default function SettingsPage() {
className={fieldClass}
/>
</SettingRow>
- <SettingRow
- label="Max restarts"
- description="Maximum restart attempts for restart-managed strategies. Use -1 for unlimited."
- >
- <input
- type="number"
- min={-1}
- value={backendConfig.multiInstance.restart.maxRestarts}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- maxRestarts: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Initial backoff"
- description="Delay in seconds before the first restart attempt."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.multiInstance.restart.initBackoffSec}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- initBackoffSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Max backoff"
- description="Upper bound in seconds for exponential restart backoff."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.multiInstance.restart.maxBackoffSec}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- maxBackoffSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
- <SettingRow
- label="Stable after"
- description="Seconds the instance must stay healthy before the restart counter resets."
- >
- <input
- type="number"
- min={1}
- value={backendConfig.multiInstance.restart.stableAfterSec}
- onChange={(e) =>
- updateBackendSection("multiInstance", {
- restart: {
- ...backendConfig.multiInstance.restart,
- stableAfterSec: Number(e.target.value),
- },
- })
- }
- className={fieldClass}
- />
- </SettingRow>
+ {(backendConfig.multiInstance.strategy === "always-on" ||
+ backendConfig.multiInstance.strategy ===
+ "simple-autorestart") && (
+ <>
+ <SettingRow
+ label="Max restarts"
+ description="Maximum restart attempts. Use -1 for unlimited, 0 for no restarts."
+ >
+ <input
+ type="number"
+ min={-1}
+ value={
+ backendConfig.multiInstance.restart.maxRestarts
+ }
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ maxRestarts: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Initial backoff"
+ description="Delay in seconds before the first restart attempt."
+ >
+ <input
+ type="number"
+ min={1}
+ value={
+ backendConfig.multiInstance.restart.initBackoffSec
+ }
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ initBackoffSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Max backoff"
+ description="Upper bound in seconds for exponential restart backoff."
+ >
+ <input
+ type="number"
+ min={1}
+ value={
+ backendConfig.multiInstance.restart.maxBackoffSec
+ }
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ maxBackoffSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ <SettingRow
+ label="Stable after"
+ description="Seconds the instance must stay healthy before the restart counter resets."
+ >
+ <input
+ type="number"
+ min={1}
+ value={
+ backendConfig.multiInstance.restart.stableAfterSec
+ }
+ onChange={(e) =>
+ updateBackendSection("multiInstance", {
+ restart: {
+ ...backendConfig.multiInstance.restart,
+ stableAfterSec: Number(e.target.value),
+ },
+ })
+ }
+ className={fieldClass}
+ />
+ </SettingRow>
+ </>
+ )}
</SectionCard>
)}
diff --git a/internal/config/validate.go b/internal/config/validate.go
index a43d2a5e..5ba9ee3d 100644
--- a/internal/config/validate.go
+++ b/internal/config/validate.go
@@ -40,10 +40,10 @@ func ValidateFileConfig(fc *FileConfig) []error {
}
}
if fc.MultiInstance.Restart.MaxRestarts != nil {
- if *fc.MultiInstance.Restart.MaxRestarts != -1 && *fc.MultiInstance.Restart.MaxRestarts < 1 {
+ if *fc.MultiInstance.Restart.MaxRestarts < -1 {
errs = append(errs, ValidationError{
Field: "multiInstance.restart.maxRestarts",
- Message: fmt.Sprintf("must be >= 1 or -1 for unlimited (got %d)", *fc.MultiInstance.Restart.MaxRestarts),
+ Message: fmt.Sprintf("must be >= 0 or -1 for unlimited (got %d)", *fc.MultiInstance.Restart.MaxRestarts),
})
}
}
diff --git a/internal/config/validate_test.go b/internal/config/validate_test.go
index 0bef0f52..30d5ddc5 100644
--- a/internal/config/validate_test.go
+++ b/internal/config/validate_test.go
@@ -67,10 +67,17 @@ func TestValidateFileConfig_RestartPolicy(t *testing.T) {
wantErr: false,
},
{
- name: "zero max restarts invalid",
+ name: "zero max restarts valid (no restarts)",
restart: MultiInstanceRestartConfig{
MaxRestarts: intPtr(0),
},
+ wantErr: false,
+ },
+ {
+ name: "negative max restarts invalid (except -1)",
+ restart: MultiInstanceRestartConfig{
+ MaxRestarts: intPtr(-2),
+ },
wantErr: true,
},
{
diff --git a/internal/strategy/alwayson/alwayson.go b/internal/strategy/alwayson/alwayson.go
index 56516ae9..aea56045 100644
--- a/internal/strategy/alwayson/alwayson.go
+++ b/internal/strategy/alwayson/alwayson.go
@@ -6,9 +6,11 @@ import (
)
func init() {
+ // Defaults here are used if SetRuntimeConfig is not called.
+ // In dashboard mode, SetRuntimeConfig overrides these from config file.
strategy.MustRegister("always-on", func() strategy.Strategy {
return autorestart.New(autorestart.AutorestartConfig{
- MaxRestarts: 20,
+ MaxRestarts: -1,
StrategyName: "always-on",
StatusPath: "/always-on/status",
})
diff --git a/internal/strategy/autorestart/autorestart.go b/internal/strategy/autorestart/autorestart.go
index a9b5023d..579bd99a 100644
--- a/internal/strategy/autorestart/autorestart.go
+++ b/internal/strategy/autorestart/autorestart.go
@@ -37,6 +37,9 @@ const (
)
func init() {
+ // simple-autorestart uses autorestart defaults (MaxRestarts=3).
+ // Both simple-autorestart and always-on implement HandlesLaunch()
+ // via the shared Strategy type, suppressing dashboard auto-launch.
strategy.MustRegister("simple-autorestart", func() strategy.Strategy {
return New(AutorestartConfig{})
})