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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: treat moving a just-added widget as a reorder too (#4132)
[._.]/ Adam Eivy6e0856913c4e
diff --git a/client/src/components/dashboard/DashboardGrid.test.jsx b/client/src/components/dashboard/DashboardGrid.test.jsxindex 22f50bd5e0..c19f06344f 100644--- a/client/src/components/dashboard/DashboardGrid.test.jsx+++ b/client/src/components/dashboard/DashboardGrid.test.jsx@@ -258,6 +258,9 @@ describe('reconcileGrid', () => {it('leaves an arranged grid alone when the save is not a reorder', () => {expect(reconcileGrid(ARRANGED, ['a', 'b', 'c'])).toEqual(ARRANGED);+ expect(reconcileGrid(ARRANGED, ['a', 'b', 'c'], {})).toEqual(ARRANGED);+ // A caller forwarding a `reordered` it never received must not re-flow.+ expect(reconcileGrid(ARRANGED, ['a', 'b', 'c'], { reorder: undefined })).toEqual(ARRANGED);expect(reconcileGrid(ARRANGED, ['a', 'b', 'c'], { reorder: false })).toEqual(ARRANGED);});diff --git a/client/src/components/dashboard/LayoutEditor.jsx b/client/src/components/dashboard/LayoutEditor.jsxindex 7a21493145..b8b6ae032f 100644--- a/client/src/components/dashboard/LayoutEditor.jsx+++ b/client/src/components/dashboard/LayoutEditor.jsx@@ -109,15 +109,19 @@ export default function LayoutEditor({ layouts, activeLayoutId, limits, onClose,// save has to say out loud when the widget order IS the edit — otherwise the// grid keeps its old reading order and Move up/down looks inert (#4132).// Derived rather than a sticky flag so moving a widget up and back down again- // nets out to "not a reorder". `add` appends and `remove` filters, both of- // which preserve relative order, so comparing the two lists restricted to the- // widgets they share isolates exactly what `move` did.+ // nets out to "not a reorder". `remove` filters and `add` appends, so the+ // list the draft WOULD have without any `move` is reconstructible exactly:+ // the surviving stored widgets in their stored order, then the newly added+ // ones in the order they were added. Anything else is a reorder — including+ // moving a widget that was added in this same editing session.const isReordered = () => {const stored = editing?.widgets ?? [];const storedIds = new Set(stored);- const draftIds = new Set(widgets);- const shared = stored.filter((id) => draftIds.has(id));- return widgets.filter((id) => storedIds.has(id)).some((id, i) => id !== shared[i]);+ const unmoved = [+ ...stored.filter((id) => widgets.includes(id)),+ ...widgets.filter((id) => !storedIds.has(id)),+ ];+ return widgets.length !== unmoved.length || widgets.some((id, i) => id !== unmoved[i]);};const remove = (id) => {diff --git a/client/src/components/dashboard/LayoutEditor.test.jsx b/client/src/components/dashboard/LayoutEditor.test.jsxindex e49050671f..7d52cf14d7 100644--- a/client/src/components/dashboard/LayoutEditor.test.jsx+++ b/client/src/components/dashboard/LayoutEditor.test.jsx@@ -106,6 +106,19 @@ describe('LayoutEditor reorder signal', () => {}));});+ // `add` appends, so a widget added and then moved up IS a reorder — the grid+ // would otherwise auto-place it at the bottom, ignoring where it was put.+ it('flags a widget that was added and then moved up', async () => {+ const { onSave } = await renderEditor();+ clickButton(/Death Clock/);+ moveUp(3);+ await save();+ expect(onSave).toHaveBeenCalledWith(expect.objectContaining({+ widgets: ['quick-task', 'apps', 'death-clock', 'backup'],+ reordered: true,+ }));+ });+it('nets out a move up followed by a move back down', async () => {const { onSave } = await renderEditor();moveUp(1);