mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 03:33:53 +00:00
fix: stable node group sorting in dashboard for duplicate hostnames
addresses #479 when displaying grouped guests in the dashboard, node groups with the same hostname were being sorted inconsistently, causing the groups to swap positions on each data refresh. fixed by adding instance ID as a secondary sort key when node names are equal. this ensures stable, consistent ordering even when multiple nodes share the same hostname.
This commit is contained in:
@@ -917,10 +917,13 @@ export function Dashboard(props: DashboardProps) {
|
||||
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
||||
<For
|
||||
each={Object.entries(groupedGuests()).sort(([instanceIdA], [instanceIdB]) => {
|
||||
// Sort by node name for display, not instance ID
|
||||
// Sort by node name for display, with instance ID as tiebreaker for duplicate hostnames
|
||||
const nodeA = nodeByInstance()[instanceIdA];
|
||||
const nodeB = nodeByInstance()[instanceIdB];
|
||||
return (nodeA?.name || '').localeCompare(nodeB?.name || '');
|
||||
const nameCompare = (nodeA?.name || '').localeCompare(nodeB?.name || '');
|
||||
if (nameCompare !== 0) return nameCompare;
|
||||
// If names are equal (duplicate hostnames), sort by instance ID for stability
|
||||
return instanceIdA.localeCompare(instanceIdB);
|
||||
})}
|
||||
fallback={<></>}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user