diff --git a/artifacts/teaboy-os/src/pages/home.tsx b/artifacts/teaboy-os/src/pages/home.tsx index 40ade6fe..ff2cad03 100644 --- a/artifacts/teaboy-os/src/pages/home.tsx +++ b/artifacts/teaboy-os/src/pages/home.tsx @@ -98,7 +98,17 @@ export default function HomePage() { const [orderedApps, setOrderedApps] = useState(null); useEffect(() => { - if (apps) setOrderedApps((prev) => prev ?? apps); + if (!apps) return; + setOrderedApps((prev) => { + if (!prev) return apps; + const byId = new Map(apps.map((a) => [a.id, a])); + const kept = prev + .map((a) => byId.get(a.id)) + .filter((a): a is App => a !== undefined); + const keptIds = new Set(kept.map((a) => a.id)); + const added = apps.filter((a) => !keptIds.has(a.id)); + return [...kept, ...added]; + }); }, [apps]); const sensors = useSensors(