diff --git a/src/components/frontend/blocks/AppSidebar.tsx b/src/components/frontend/blocks/AppSidebar.tsx
index cce1e75e..00827772 100644
--- a/src/components/frontend/blocks/AppSidebar.tsx
+++ b/src/components/frontend/blocks/AppSidebar.tsx
@@ -13,6 +13,7 @@ import {
SparkleIcon,
CheckIcon,
GripVerticalIcon,
+ PinIcon,
RotateCcwIcon,
SlidersHorizontalIcon,
} from "lucide-react";
@@ -63,6 +64,7 @@ import { sidebarData } from "@/components/frontend/blocks/sidebarData";
import type { RegistryGame } from "@/lib/minigames/registry";
import {
DEFAULT_SIDEBAR_ORDER,
+ PINNED_SIDEBAR_SECTION_IDS,
SIDEBAR_SECTION_LABELS,
normalizeSidebarOrder,
type SidebarSectionId,
@@ -217,6 +219,13 @@ export function AppSidebar({
// Feature-flagged-off sections skip their slot entirely; hidden ids keep
// their stored positions so re-enabling a flag restores the user's layout.
const visibleOrder = sectionOrder.filter((id) => sectionNodes[id] !== null);
+ // Pinned sections (Platform) always render first and are not draggable.
+ const pinnedVisible = visibleOrder.filter((id) =>
+ PINNED_SIDEBAR_SECTION_IDS.includes(id),
+ );
+ const sortableOrder = visibleOrder.filter(
+ (id) => !PINNED_SIDEBAR_SECTION_IDS.includes(id),
+ );
const persistOrder = React.useCallback(
async (order: SidebarSectionId[] | null) => {
@@ -235,13 +244,14 @@ export function AppSidebar({
(event: DragEndEvent) => {
const { active, over } = event;
if (!over || active.id === over.id) return;
- const from = visibleOrder.indexOf(active.id as SidebarSectionId);
- const to = visibleOrder.indexOf(over.id as SidebarSectionId);
+ const from = sortableOrder.indexOf(active.id as SidebarSectionId);
+ const to = sortableOrder.indexOf(over.id as SidebarSectionId);
if (from < 0 || to < 0) return;
- const reorderedVisible = arrayMove(visibleOrder, from, to);
- // Re-insert hidden (feature-flagged) sections at their original indices.
- const merged = [...reorderedVisible];
+ const reorderedSortable = arrayMove(sortableOrder, from, to);
+ // Pinned sections stay on top; hidden (feature-flagged) sections are
+ // re-inserted at their original indices.
+ const merged: SidebarSectionId[] = [...pinnedVisible, ...reorderedSortable];
const hiddenIds = sectionOrder.filter((id) => !visibleOrder.includes(id));
hiddenIds.forEach((id) => {
const originalIndex = sectionOrder.indexOf(id);
@@ -251,7 +261,7 @@ export function AppSidebar({
setSectionOrder(merged);
void persistOrder(merged);
},
- [persistOrder, sectionOrder, visibleOrder],
+ [persistOrder, pinnedVisible, sectionOrder, sortableOrder, visibleOrder],
);
const handleResetOrder = React.useCallback(() => {
@@ -327,19 +337,33 @@ export function AppSidebar({
{isReordering ? (
-
-
- {visibleOrder.map((id) => (
-
- {sectionNodes[id]}
-
- ))}
-
-
+ <>
+ {pinnedVisible.map((id) => (
+
+
+
+
+ {sectionNodes[id]}
+
+ ))}
+
+
+ {sortableOrder.map((id) => (
+
+ {sectionNodes[id]}
+
+ ))}
+
+
+ >
) : (
visibleOrder.map((id) =>
{sectionNodes[id]})
)}
diff --git a/src/lib/sidebar/order.ts b/src/lib/sidebar/order.ts
index a01de4a7..c1184595 100644
--- a/src/lib/sidebar/order.ts
+++ b/src/lib/sidebar/order.ts
@@ -40,11 +40,14 @@ export function isSidebarSectionId(value: unknown): value is SidebarSectionId {
);
}
+/** Sections that always render first and cannot be reordered by users. */
+export const PINNED_SIDEBAR_SECTION_IDS: readonly SidebarSectionId[] = ["platform"];
+
/**
* Sanitizes an arbitrary stored order into a valid full section list: drops
- * unknown/duplicate ids, keeps known ones in the user's order, and appends any
- * missing sections at the end in default order. Non-array input falls back to
- * the default order.
+ * unknown/duplicate ids, keeps known ones in the user's order, appends any
+ * missing sections at the end in default order, and moves pinned sections
+ * (Platform) to the front. Non-array input falls back to the default order.
*/
export function normalizeSidebarOrder(raw: unknown): SidebarSectionId[] {
if (!Array.isArray(raw)) {
@@ -64,5 +67,8 @@ export function normalizeSidebarOrder(raw: unknown): SidebarSectionId[] {
ordered.push(id);
}
}
- return ordered;
+
+ const pinned = PINNED_SIDEBAR_SECTION_IDS.filter((id) => ordered.includes(id));
+ const rest = ordered.filter((id) => !PINNED_SIDEBAR_SECTION_IDS.includes(id));
+ return [...pinned, ...rest];
}
diff --git a/tests/int/sidebar-order.int.spec.ts b/tests/int/sidebar-order.int.spec.ts
index 2708cf95..0fad31c2 100644
--- a/tests/int/sidebar-order.int.spec.ts
+++ b/tests/int/sidebar-order.int.spec.ts
@@ -20,10 +20,16 @@ describe("normalizeSidebarOrder", () => {
expect(normalizeSidebarOrder({ 0: "platform" })).toEqual([...DEFAULT_SIDEBAR_ORDER]);
});
- it("keeps known ids in the user's order", () => {
- const custom = ["personal", "platform", "map"];
+ it("keeps known ids in the user's order (after the pinned Platform section)", () => {
+ const custom = ["personal", "platform", "commerce", "map"];
const result = normalizeSidebarOrder(custom);
- expect(result.slice(0, 3)).toEqual(["personal", "platform", "map"]);
+ expect(result.slice(0, 4)).toEqual(["platform", "personal", "commerce", "map"]);
+ });
+
+ it("pins Platform to the front even when stored elsewhere or missing", () => {
+ expect(normalizeSidebarOrder(["personal", "platform", "map"])[0]).toBe("platform");
+ expect(normalizeSidebarOrder([...DEFAULT_SIDEBAR_ORDER].reverse())[0]).toBe("platform");
+ expect(normalizeSidebarOrder(["commerce", "map"])[0]).toBe("platform");
});
it("drops unknown and duplicate ids", () => {
@@ -42,8 +48,10 @@ describe("normalizeSidebarOrder", () => {
it("appends missing sections in default order so the list is always complete", () => {
const result = normalizeSidebarOrder(["personal"]);
- expect(result[0]).toBe("personal");
- expect(result.slice(1)).toEqual(DEFAULT_SIDEBAR_ORDER.filter((id) => id !== "personal"));
+ expect(result.slice(0, 2)).toEqual(["platform", "personal"]);
+ expect(result.slice(2)).toEqual(
+ DEFAULT_SIDEBAR_ORDER.filter((id) => id !== "platform" && id !== "personal"),
+ );
});
it("always returns every section id exactly once", () => {