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

refactor: name the sidebar section groups instead of slicing SECTION_ORDER (#5692)

Adam Eivy57fbcd0d23a4
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index b010c3e0b9..7f87fffaf7 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -356,10 +356,19 @@ const SECTION_PRESENTATION = {
POST: { icon: Zap, defaultTo: '/post/launcher' },
};
-const SECTION_ORDER = [
+// Sidebar grouping is declared, never derived from array positions. The first
+// two lists are the alphabetical run of sections, split around the Goals row;
+// the third is the intentionally-last bucket that renders below the "More"
+// divider, so it is NOT alphabetical relative to the other two and can only be
+// declared. Adding a section means putting its name in the list it belongs to —
+// there are no indices to keep in sync.
+export const SECTIONS_BEFORE_GOALS = [
'Brain', 'Calendar', 'Chief of Staff', 'Comms', 'Create', 'Dev Tools',
- 'Health', 'Models', 'Settings', 'Identity', 'POST',
];
+export const SECTIONS_AFTER_GOALS = ['Health', 'Models', 'Settings'];
+export const SECTIONS_BELOW_MORE = ['Identity', 'POST'];
+
+const SECTION_ORDER = [...SECTIONS_BEFORE_GOALS, ...SECTIONS_AFTER_GOALS, ...SECTIONS_BELOW_MORE];
// These rows have no PortOS route, so a NAV_COMMANDS entry would be dishonest.
// Keep them visibly marked as local-only instead of smuggling structural route
@@ -410,11 +419,11 @@ const navItems = [
...mainRows,
{ separator: true, localOnly: true },
{ ...appsCommand, dynamic: 'apps', defaultTo: appsCommand.to, children: [] },
- ...SECTION_ORDER.slice(0, 6).map((section) => sectionRows[section]),
+ ...SECTIONS_BEFORE_GOALS.map((section) => sectionRows[section]),
goalsRow,
- ...SECTION_ORDER.slice(6, 9).map((section) => sectionRows[section]),
+ ...SECTIONS_AFTER_GOALS.map((section) => sectionRows[section]),
{ moreLabel: true, localOnly: true },
- ...SECTION_ORDER.slice(9).map((section) => sectionRows[section]),
+ ...SECTIONS_BELOW_MORE.map((section) => sectionRows[section]),
];
const SIDEBAR_KEY = 'portos-sidebar-collapsed';
diff --git a/client/src/components/Layout.test.jsx b/client/src/components/Layout.test.jsx
index b1255ede7d..38c9a01da7 100644
--- a/client/src/components/Layout.test.jsx
+++ b/client/src/components/Layout.test.jsx
@@ -87,7 +87,13 @@ vi.mock('../services/api', () => ({
import { __resetInstanceFeatureCache } from '../hooks/useInstanceFeatures.js';
import { NAV_COMMANDS } from '../../../server/lib/navManifest.js';
-import Layout, { isFullWidthRoute, NAV_PRESENTATION } from './Layout';
+import Layout, {
+ isFullWidthRoute,
+ NAV_PRESENTATION,
+ SECTIONS_BEFORE_GOALS,
+ SECTIONS_AFTER_GOALS,
+ SECTIONS_BELOW_MORE,
+} from './Layout';
const LocationProbe = () => {
const location = useLocation();
@@ -486,3 +492,38 @@ describe('Layout — isFullWidthRoute classification', () => {
expect(isFullWidthRoute(pathname)).toBe(expected);
});
});
+
+// The sidebar's section grouping used to be three numeric slices into a single
+// flat SECTION_ORDER array, so inserting a section at its alphabetical position
+// silently pushed a real section (e.g. Settings) past the "More" divider with
+// nothing to catch it. The groups are named lists now; this locks the two
+// invariants that made the slices fragile.
+describe('Layout — sidebar section grouping', () => {
+ const alphabetical = (list) => [...list].sort((a, b) => a.localeCompare(b));
+
+ it.each([
+ ['SECTIONS_BEFORE_GOALS', SECTIONS_BEFORE_GOALS],
+ ['SECTIONS_AFTER_GOALS', SECTIONS_AFTER_GOALS],
+ ])('%s stays alphabetical', (_name, list) => {
+ expect(list).toEqual(alphabetical(list));
+ });
+
+ // SECTIONS_BELOW_MORE is deliberately NOT alphabetical relative to the other
+ // two — it is the below-the-fold bucket — so it is exempt from the sort check
+ // but still has to be disjoint and complete.
+ it('groups every presented section exactly once', () => {
+ const grouped = [...SECTIONS_BEFORE_GOALS, ...SECTIONS_AFTER_GOALS, ...SECTIONS_BELOW_MORE];
+ expect(new Set(grouped).size).toBe(grouped.length);
+
+ // `Main` (Dashboard/Review/Eidoverse plus the dynamic Apps row) and `Goals`
+ // render as standalone top-level rows, not as collapsible section groups.
+ const UNGROUPED_SECTIONS = new Set(['Main', 'Goals']);
+ const sectionByPath = new Map(NAV_COMMANDS.map((command) => [command.path, command.section]));
+ const presented = new Set(
+ Object.keys(NAV_PRESENTATION)
+ .map((path) => sectionByPath.get(path))
+ .filter((section) => section && !UNGROUPED_SECTIONS.has(section)),
+ );
+ expect(alphabetical([...presented])).toEqual(alphabetical(grouped));
+ });
+});