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

Merge remote-tracking branch 'origin/main' into claim/issue-4133

Adam Eivyc2da7e7e7e32
diff --cc client/src/components/dashboard/DashboardGrid.jsx
index f4938962bc,122d624a6e..2e18e74e30
--- a/client/src/components/dashboard/DashboardGrid.jsx
+++ b/client/src/components/dashboard/DashboardGrid.jsx
@@@ -357,9 -331,7 +365,11 @@@ export function reconcileGrid(grid, vis
if (present.has(id)) continue;
kept = placeNewWidget(kept, id);
}
- // Dropping entries leaves gaps in the sequence and appending can duplicate
- // the last index; hand back a dense one so callers never have to care.
- return resequence(kept);
- return reorder ? reflowToOrder(kept, visibleIds) : kept;
++ // Either way the sequence comes back dense — `reflowToOrder` renumbers from
++ // the list, and `resequence` closes the gaps that dropping entries leaves
++ // (appending can also duplicate the last index) — so callers never have to
++ // care.
++ return reorder ? reflowToOrder(kept, visibleIds) : resequence(kept);
}
// Reading order of a grid — what the mobile stack shows, and what a layout's
diff --cc client/src/components/dashboard/DashboardGrid.test.jsx
index a6879e4db4,c19f06344f..0af98cb3e7
--- a/client/src/components/dashboard/DashboardGrid.test.jsx
+++ b/client/src/components/dashboard/DashboardGrid.test.jsx
@@@ -257,13 -247,33 +257,41 @@@ describe('reconcileGrid', () =>
expect(reconcileGrid(THREE, ['a', 'c']).map((it) => it.id)).toEqual(['a', 'c']);
});
+ // Dropping the middle entry leaves a hole at order 1; a hand-back with gaps
+ // would drift further on every add/remove cycle.
+ it('hands back a dense sequence after dropping and appending', () => {
+ const next = reconcileGrid(THREE, ['a', 'c', 'apps']);
+ expect(next.map((it) => it.id)).toEqual(['a', 'c', 'apps']);
+ expect(next.map((it) => it.order)).toEqual([0, 1, 2]);
+ });
++
+ // The arranged layout below deliberately disagrees with its widget list: `b`
- // sits above `a` in the grid while the list still says `['a','b','c']`, which
- // is exactly the pre-`saveGridEdit` state #4132 warns about.
++ // leads the sequence while the list still says `['a','b','c']`, which is
++ // exactly the pre-`saveGridEdit` state #4132 warns about.
+ const ARRANGED = [
- { id: 'b', x: 0, y: 0, w: 6, h: 3 },
- { id: 'a', x: 6, y: 0, w: 6, h: 2 },
- { id: 'c', x: 0, y: 3, w: 12, h: 2 },
++ { id: 'b', x: 0, w: 6, order: 0, h: 3 },
++ { id: 'a', x: 6, w: 6, order: 1, h: 2 },
++ { id: 'c', x: 0, w: 12, order: 2, h: 2 },
+ ];
+
+ 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);
+ });
+
+ it('re-flows to the widget order when the caller says the save IS a reorder', () => {
+ const next = reconcileGrid(THREE, ['b', 'a', 'c'], { reorder: true });
+ expect(readingOrderIds(next)).toEqual(['b', 'a', 'c']);
+ expect(next.map((it) => it.h)).toEqual([2, 2, 2]);
+ });
+
+ it('re-flows a widget added in the same reorder save', () => {
+ const next = reconcileGrid(THREE, ['c', 'a', 'apps', 'b'], { reorder: true });
+ expect(readingOrderIds(next)).toEqual(['c', 'a', 'apps', 'b']);
+ });
});
describe('DashboardGrid mobile reorder', () => {