fix: refresh mutations and defer busy quit

This commit is contained in:
proxyctl coordinator
2026-07-17 10:28:40 +08:00
parent f6c6ead325
commit eb8932a319
5 changed files with 182 additions and 31 deletions
+12
View File
@@ -153,6 +153,18 @@ func (a *Application) dispatch(intent Intent, publish func(Result)) Result {
}
defer unlock()
}
// A different process may have changed the persisted Active Profile since
// this Application was constructed. Reload only after the global mutation
// lock is held, before selecting a Profile or invoking a Target. Load is
// deliberately separate from Store.Mutate so no Profile-store lock is nested.
fresh, err := a.store.Load()
if err != nil {
return Result{Snapshot: a.Snapshot(), Err: fmt.Errorf("reload Profile state for mutation: %w", err)}
}
a.state = fresh
if intent.Kind == SetTargetDesired || intent.Kind == ActivateProfile {
a.refreshInspections()
}
if intent.Kind == SetTargetDesired {
return a.setTargetDesired(intent)
}