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

fix([codex5-dashboard-intent-layouts]): client-side FIFO at the API layer (codex iter-3)

[._.]/ Adam Eivy1de35ffbe232
diff --git a/client/src/services/apiDashboard.js b/client/src/services/apiDashboard.js
index e4176252a2..92a88cd389 100644
--- a/client/src/services/apiDashboard.js
+++ b/client/src/services/apiDashboard.js
@@ -2,11 +2,26 @@ import { request } from './apiCore.js';
export const getDashboardLayouts = () => request('/dashboard/layouts');
+// All mutations of dashboard-layouts.json are serialized through a single
+// module-level promise tail so concurrent callers (Dashboard auto-window,
+// Dashboard manual pick, ⌘K palette pick, LayoutEditor save) hit the server
+// in client-issuance order. Without this, HTTP/2 multiplexing can reorder
+// requests at the network so an auto-fired PUT lands at the server AFTER a
+// later manual PUT — the server's write tail would then queue them in the
+// wrong order. The server tail still matters for cross-tab safety; this is
+// the per-tab FIFO complement.
+let mutationTail = Promise.resolve();
+const queueMutation = (fn) => {
+ const tail = mutationTail.then(fn, fn); // run even after a prior rejection
+ mutationTail = tail.then(() => null, () => null); // keep the chain alive
+ return tail;
+};
+
export const setActiveDashboardLayout = (id) =>
- request('/dashboard/layouts/active', {
+ queueMutation(() => request('/dashboard/layouts/active', {
method: 'PUT',
body: JSON.stringify({ id }),
- });
+ }));
// `activateWindow` is partial-aware: omit to preserve the existing value,
// pass `null` to clear, pass `{ start, end }` to set. Mirrors the merge in
@@ -14,11 +29,11 @@ export const setActiveDashboardLayout = (id) =>
export const saveDashboardLayout = (id, { name, widgets, grid, activateWindow }) => {
const body = { name, widgets, grid: grid ?? [] };
if (activateWindow !== undefined) body.activateWindow = activateWindow;
- return request(`/dashboard/layouts/${encodeURIComponent(id)}`, {
+ return queueMutation(() => request(`/dashboard/layouts/${encodeURIComponent(id)}`, {
method: 'PUT',
body: JSON.stringify(body),
- });
+ }));
};
export const deleteDashboardLayout = (id) =>
- request(`/dashboard/layouts/${encodeURIComponent(id)}`, { method: 'DELETE' });
+ queueMutation(() => request(`/dashboard/layouts/${encodeURIComponent(id)}`, { method: 'DELETE' }));