Skip to content

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

refactor(dashboard): compare the restart block as one section (PIN-358)

Luigi Agostied8fa7476943
diff --git a/internal/dashboard/config_changes.go b/internal/dashboard/config_changes.go
index 5207d7b8..2ec31095 100644
--- a/internal/dashboard/config_changes.go
+++ b/internal/dashboard/config_changes.go
@@ -2,7 +2,9 @@ package dashboard
import (
"encoding/json"
+ "maps"
"path/filepath"
+ "slices"
"strings"
"github.com/pinchtab/pinchtab/internal/config"
@@ -64,21 +66,15 @@ func sensitiveConfigChanges(current, next *config.FileConfig) sensitiveConfigCha
}
func changedTargetProxyNames(current, next config.BrowserTargetsConfig) []string {
- seen := make(map[string]struct{}, len(current)+len(next))
- names := make([]string, 0, len(current)+len(next))
+ union := make(map[string]struct{}, len(current)+len(next))
for name := range current {
- if _, ok := seen[name]; !ok {
- seen[name] = struct{}{}
- names = append(names, name)
- }
+ union[name] = struct{}{}
}
for name := range next {
- if _, ok := seen[name]; !ok {
- seen[name] = struct{}{}
- names = append(names, name)
- }
+ union[name] = struct{}{}
}
- var changed []string
+ names := slices.Sorted(maps.Keys(union))
+ changed := names[:0]
for _, name := range names {
if !sameConfigSection(current[name].Proxy, next[name].Proxy) {
changed = append(changed, name)
@@ -90,11 +86,6 @@ func changedTargetProxyNames(current, next config.BrowserTargetsConfig) []string
func (c *ConfigAPI) restartReasonsFor(next config.FileConfig) []string {
reasons := make([]string, 0, 8)
- // The IDPI guard, allowlist, and sensitive-endpoint policy are snapshotted
- // from the boot config when the server starts and are not rebuilt on a config
- // edit, so any change to the security block only takes effect after a restart.
- // Surfacing it here is what lets `pinchtab security`/`health` warn that the
- // running server is enforcing stale policy instead of silently diverging.
if !sameConfigSection(c.boot.Security, next.Security) {
reasons = append(reasons, "Security policy")
}
@@ -113,19 +104,10 @@ func (c *ConfigAPI) restartReasonsFor(next config.FileConfig) []string {
if c.boot.InstanceDefaults.StealthLevel != next.InstanceDefaults.StealthLevel {
reasons = append(reasons, "Stealth level")
}
- // The sessions.agent block applies live in every direction but one: whether
- // the session API and its route family exist at all is decided at boot, so a
- // process that booted with agent sessions off cannot serve them until it
- // restarts. Turning them off needs no restart — both request-time consumers
- // read the store live — and claiming otherwise about an authentication
- // control would be the same defect one direction over.
if !c.boot.Sessions.AgentEnabled() && next.Sessions.AgentEnabled() {
reasons = append(reasons, "Agent sessions")
}
- if !sameIntPtr(c.boot.MultiInstance.Restart.MaxRestarts, next.MultiInstance.Restart.MaxRestarts) ||
- !sameIntPtr(c.boot.MultiInstance.Restart.InitBackoffSec, next.MultiInstance.Restart.InitBackoffSec) ||
- !sameIntPtr(c.boot.MultiInstance.Restart.MaxBackoffSec, next.MultiInstance.Restart.MaxBackoffSec) ||
- !sameIntPtr(c.boot.MultiInstance.Restart.StableAfterSec, next.MultiInstance.Restart.StableAfterSec) {
+ if !sameConfigSection(c.boot.MultiInstance.Restart, next.MultiInstance.Restart) {
reasons = append(reasons, "Restart policy")
}
@@ -138,10 +120,3 @@ func effectiveProfilesDir(fc config.FileConfig) string {
}
return filepath.Join(strings.TrimSpace(fc.Server.StateDir), "profiles")
}
-
-func sameIntPtr(a, b *int) bool {
- if a == nil || b == nil {
- return a == b
- }
- return *a == *b
-}