Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): serialize round-setting writes to prevent lost updates

[._.]/ Adam Eivy7fa7e6a8c768
diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsx
index 576f8a746b..4794baadeb 100644
--- a/client/src/components/pipeline/AutopilotPanel.jsx
+++ b/client/src/components/pipeline/AutopilotPanel.jsx
@@ -163,10 +163,19 @@ export default function AutopilotPanel({ series, onSeriesUpdate, onIssuesUpdate
}, []);
// Persist a round setting (clamped) so a later Resume picks it up server-side.
- // Returns the promise so start() can await it (close the persist→read race).
- const persistRounds = useCallback((patch) => (
- patchSettingsSlice('pipelineEditorialChecks', patch, { silent: true }).catch(() => null)
- ), []);
+ // patchSettingsSlice is a GET-merge-PUT, so two overlapping calls (a blur save
+ // racing start()'s save) can lose an update — a slow earlier PUT lands after a
+ // newer one and clobbers it. Serialize every write onto one tail promise so the
+ // cycles can't interleave; start() awaiting its own enqueued write transitively
+ // awaits any in-flight blur save. Returns the promise so start() can await it.
+ const persistTailRef = useRef(Promise.resolve());
+ const persistRounds = useCallback((patch) => {
+ const next = persistTailRef.current
+ .catch(() => {})
+ .then(() => patchSettingsSlice('pipelineEditorialChecks', patch, { silent: true }).catch(() => null));
+ persistTailRef.current = next;
+ return next;
+ }, []);
// User edited an input — mark the values as real so a late settings load can't
// overwrite them and so start() knows they're worth persisting.