💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add floating friend circles and refine Space navigation
Anand Baburajan89d305f88a0a
diff --git a/web/apps/space/src/components/AppNavigation.tsx b/web/apps/space/src/components/AppNavigation.tsxindex 6307c035a6..def28548c1 100644--- a/web/apps/space/src/components/AppNavigation.tsx+++ b/web/apps/space/src/components/AppNavigation.tsx@@ -60,7 +60,6 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {let cancelled = false;let sequence = 0;const refresh = () => {- if (document.visibilityState == "hidden") return;const request = ++sequence;void loadCurrentUnreadStatus(spaceID).then((status) => {@@ -72,14 +71,10 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {);};refresh();- window.addEventListener("focus", refresh);window.addEventListener(spaceUnreadStatusChangedEvent, refresh);- document.addEventListener("visibilitychange", refresh);return () => {cancelled = true;- window.removeEventListener("focus", refresh);window.removeEventListener(spaceUnreadStatusChangedEvent, refresh);- document.removeEventListener("visibilitychange", refresh);};}, [spaceID, path]);@@ -263,6 +258,7 @@ export const SpaceAppLayout = ({ children }: { children: React.ReactNode }) => {unreadStatus.messagesUnread && (<Boxaria-hidden+ className="space-unread-indicator"sx={{bgcolor: "#F63A3A",border: `2.5px solid ${spaceAppBackgroundColor}`,diff --git a/web/apps/space/src/components/ConfirmationActionSheet.tsx b/web/apps/space/src/components/ConfirmationActionSheet.tsxindex 2ebbb23bb3..147862c058 100644--- a/web/apps/space/src/components/ConfirmationActionSheet.tsx+++ b/web/apps/space/src/components/ConfirmationActionSheet.tsx@@ -118,6 +118,7 @@ export const ConfirmationActionSheet: React.FC<m: 0,px: "20px",textAlign: "center",+ textWrap: "balance",}}>{title}@@ -132,6 +133,7 @@ export const ConfirmationActionSheet: React.FC<mt: "8px",px: "20px",textAlign: "center",+ textWrap: "balance",}}>{description}diff --git a/web/apps/space/src/components/FriendOrbit.tsx b/web/apps/space/src/components/FriendOrbit.tsxnew file mode 100644index 0000000000..d4db862c73--- /dev/null+++ b/web/apps/space/src/components/FriendOrbit.tsx@@ -0,0 +1,267 @@+import { Box, useMediaQuery } from "@mui/material";+import type { FriendProfile } from "data/friends";+import React from "react";+import {+ arrangeFriendOrbit,+ createFriendOrbitCircle,+ friendOrbitCircleSize,+ stepFriendOrbit,+ type FriendOrbitBounds,+ type FriendOrbitCircle,+} from "utils/friend-orbit";++interface FriendOrbitProps {+ friends: FriendProfile[];+ renderFriend: (friend: FriendProfile) => React.ReactNode;+}++interface OrbitDrag {+ pointerID: number;+ circle: FriendOrbitCircle;+ startX: number;+ startY: number;+ originX: number;+ originY: number;+ moved: boolean;+}++export const FriendOrbit: React.FC<FriendOrbitProps> = ({+ friends,+ renderFriend,+}) => {+ const fieldRef = React.useRef<HTMLUListElement>(null);+ const elements = React.useRef(new Map<string, HTMLLIElement>());+ const circles = React.useRef<FriendOrbitCircle[]>([]);+ const bounds = React.useRef<FriendOrbitBounds>({+ width: 0,+ height: 0,+ scale: 1,+ });+ const elapsed = React.useRef(0);+ const drag = React.useRef<OrbitDrag | null>(null);+ const suppressClick = React.useRef(false);+ const [heldFriendID, setHeldFriendID] = React.useState<string>();+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");++ const paintCircle = React.useCallback((circle: FriendOrbitCircle) => {+ const { width, height, scale } = bounds.current;+ const element = elements.current.get(circle.id);+ if (!element) return;+ const size = circle.size * scale;+ element.style.transform = `translate3d(${width / 2 + circle.x * scale - size / 2}px, ${height / 2 + circle.y * scale - size / 2}px, 0)`;+ }, []);+ const paint = React.useCallback(+ () => circles.current.forEach(paintCircle),+ [paintCircle],+ );++ React.useLayoutEffect(() => {+ const current = new Map(+ circles.current.map((circle) => [circle.id, circle]),+ );+ let friendsChanged =+ friends.length != current.size ||+ friends.some((friend) => !current.has(friend.id));+ circles.current = friends.map(+ (friend, index) =>+ current.get(friend.id) ??+ createFriendOrbitCircle(friend.id, index),+ );+ const field = fieldRef.current!;+ const resize = () => {+ const width = field.clientWidth;+ const scale =+ width <= 430+ ? 0.84+ : width <= 560+ ? 0.98+ : width <= 700+ ? 1.176+ : 1.4;+ field.style.minHeight = "0px";+ const availableBounds = {+ width,+ height: field.clientHeight,+ scale,+ };+ circles.current.forEach((circle, index) => {+ circle.size = friendOrbitCircleSize(+ index,+ friends.length,+ availableBounds,+ );+ });+ const area = circles.current.reduce(+ (total, circle) =>+ total + Math.PI * ((circle.size * scale) / 2 + 10) ** 2,+ 0,+ );+ field.style.minHeight = `${Math.ceil(area / (width * 0.52))}px`;+ const height = field.clientHeight;+ const layoutChanged =+ friendsChanged ||+ width != bounds.current.width ||+ height != bounds.current.height;+ bounds.current = { width, height, scale };+ circles.current.forEach((circle) => {+ const element = elements.current.get(circle.id)!;+ element.style.width = `${circle.size * scale}px`;+ element.style.height = `${circle.size * scale}px`;+ });+ if (layoutChanged)+ arrangeFriendOrbit(+ circles.current,+ bounds.current,+ elapsed.current,+ );+ friendsChanged = false;+ paint();+ field.style.opacity = "1";+ };+ const observer = new ResizeObserver(resize);+ observer.observe(field);+ resize();+ return () => observer.disconnect();+ }, [friends, paint]);++ React.useEffect(() => {+ if (reducedMotion) return;+ let frameID = 0;+ let previous = performance.now();+ const animate = (now: number) => {+ const delta = Math.min(now - previous, 33.334);+ previous = now;+ elapsed.current += delta;+ stepFriendOrbit(+ circles.current,+ bounds.current,+ elapsed.current,+ delta,+ drag.current?.circle.id,+ );+ paint();+ frameID = requestAnimationFrame(animate);+ };+ frameID = requestAnimationFrame(animate);+ return () => cancelAnimationFrame(frameID);+ }, [paint, reducedMotion]);++ const startDrag = (+ event: React.PointerEvent<HTMLLIElement>,+ friendID: string,+ ) => {+ if (event.button != 0 || !event.isPrimary) return;+ event.stopPropagation();+ const circle = circles.current.find((circle) => circle.id == friendID)!;+ const button = event.currentTarget.querySelector("button")!;+ button.setPointerCapture(event.pointerId);+ drag.current = {+ pointerID: event.pointerId,+ circle,+ startX: event.clientX,+ startY: event.clientY,+ originX: circle.x,+ originY: circle.y,+ moved: false,+ };+ circle.vx = 0;+ circle.vy = 0;+ suppressClick.current = false;+ setHeldFriendID(friendID);+ };++ const moveDrag = (event: React.PointerEvent<HTMLLIElement>) => {+ const active = drag.current;+ if (active?.pointerID != event.pointerId) return;+ const dx = event.clientX - active.startX;+ const dy = event.clientY - active.startY;+ if (!active.moved && Math.hypot(dx, dy) < 3) return;+ active.moved = true;+ suppressClick.current = true;+ active.circle.x = active.originX + dx / bounds.current.scale;+ active.circle.y = active.originY + dy / bounds.current.scale;+ paintCircle(active.circle);+ };++ const endDrag = (event: React.PointerEvent<HTMLLIElement>) => {+ const active = drag.current;+ if (active?.pointerID != event.pointerId) return;+ drag.current = null;+ setHeldFriendID(undefined);+ if (reducedMotion) {+ active.circle.x = active.originX;+ active.circle.y = active.originY;+ stepFriendOrbit(+ circles.current,+ bounds.current,+ 0,+ 0,+ undefined,+ true,+ );+ paint();+ }+ };++ return (+ <Box+ component="ul"+ ref={fieldRef}+ aria-label="Your friends"+ onDragStart={(event) => event.preventDefault()}+ onClickCapture={(event) => {+ if (!suppressClick.current) return;+ event.preventDefault();+ event.stopPropagation();+ suppressClick.current = false;+ }}+ sx={{+ height: "calc(var(--space-page-height, 100svh) - 56px)",+ listStyle: "none",+ m: 0,+ overflow: "hidden",+ opacity: 0,+ p: 0,+ position: "relative",+ userSelect: "none",+ width: "100%",+ }}+ >+ {friends.map((friend) => (+ <Box+ component="li"+ key={friend.id}+ ref={(element: HTMLLIElement | null) => {+ if (element) elements.current.set(friend.id, element);+ else elements.current.delete(friend.id);+ }}+ onPointerDown={(event) => startDrag(event, friend.id)}+ onPointerMove={moveDrag}+ onPointerUp={endDrag}+ onPointerCancel={endDrag}+ onLostPointerCapture={endDrag}+ onContextMenu={(event) => event.preventDefault()}+ sx={{+ borderRadius: "50%",+ left: 0,+ position: "absolute",+ top: 0,+ touchAction: "none",+ WebkitTouchCallout: "none",+ willChange: "transform",+ zIndex: heldFriendID == friend.id ? 2 : undefined,+ "&:hover, &:focus-within": { zIndex: 1 },+ "& button": {+ cursor:+ heldFriendID == friend.id ? "grabbing" : "grab",+ ...(heldFriendID == friend.id && { scale: "1.06" }),+ },+ "& img": { pointerEvents: "none" },+ }}+ >+ {renderFriend(friend)}+ </Box>+ ))}+ </Box>+ );+};diff --git a/web/apps/space/src/components/FriendQuickActionsDialog.tsx b/web/apps/space/src/components/FriendQuickActionsDialog.tsxindex 6e072450a8..5378b15c01 100644--- a/web/apps/space/src/components/FriendQuickActionsDialog.tsx+++ b/web/apps/space/src/components/FriendQuickActionsDialog.tsx@@ -2,6 +2,7 @@ import {BubbleChatIcon,HandPointingRightIcon,UserIcon,+ UserRemove01Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box, Dialog, useMediaQuery } from "@mui/material";@@ -28,9 +29,10 @@ interface FriendQuickActionsDialogProps {avatarUrl?: string | null;friend: FriendProfile;onClose: () => void;- onMessage: () => void;- onPoke: () => Promise<void>;- onProfile: () => void;+ onMessage?: () => void;+ onPoke?: () => Promise<void>;+ onProfile?: () => void;+ onUnfriend?: () => void;}export const FriendQuickActionsDialog: React.FC<@@ -43,6 +45,7 @@ export const FriendQuickActionsDialog: React.FC<onMessage,onPoke,onProfile,+ onUnfriend,}) => {const [open, setOpen] = React.useState(true);const [pokePhase, setPokePhase] = React.useState<"busy" | "done" | null>(@@ -74,7 +77,7 @@ export const FriendQuickActionsDialog: React.FC<};const poke = async () => {- if (pokePhase) return;+ if (!onPoke || pokePhase) return;setPokePhase("busy");setPokeFailed(false);try {@@ -90,6 +93,7 @@ export const FriendQuickActionsDialog: React.FC<const actions = [{label: "Poke",+ available: Boolean(onPoke),icon: HandPointingRightIcon,active: pokePhase !== null,done: pokePhase == "done",@@ -99,15 +103,23 @@ export const FriendQuickActionsDialog: React.FC<},{label: "Message",+ available: Boolean(onMessage),icon: BubbleChatIcon,- onClick: () => void navigate(onMessage),+ onClick: () => onMessage && void navigate(onMessage),},{label: "Profile",+ available: Boolean(onProfile),icon: UserIcon,- onClick: () => void navigate(onProfile),+ onClick: () => onProfile && void navigate(onProfile),},- ];+ {+ label: "Unfriend",+ available: Boolean(onUnfriend),+ icon: UserRemove01Icon,+ onClick: () => onUnfriend && void navigate(onUnfriend),+ },+ ].filter((action) => action.available);return (<Dialog@@ -122,6 +134,7 @@ export const FriendQuickActionsDialog: React.FC<ref: paperRef,sx: {bgcolor: spaceSurface,+ border: "1px solid #383838",boxShadow: "0 24px 64px rgba(0, 0, 0, 0.48)",borderRadius: `${dialogRadius}px`,boxSizing: "border-box",@@ -244,7 +257,7 @@ export const FriendQuickActionsDialog: React.FC<sx={{display: "grid",gap: "6px",- gridTemplateColumns: "repeat(3, minmax(0, 1fr))",+ gridTemplateColumns: `repeat(${actions.length}, minmax(0, 1fr))`,p: `${dialogPadding}px`,}}>@@ -256,6 +269,7 @@ export const FriendQuickActionsDialog: React.FC<disabled={action.disabled}aria-busy={action.busy}aria-label={action.done ? "Poke sent" : action.label}+ title={action.done ? "Poke sent" : action.label}aria-live={action.done !== undefined ? "polite" : undefined}@@ -268,7 +282,7 @@ export const FriendQuickActionsDialog: React.FC<borderRadius: `${innerRadius}px`,color: action.active? "color(display-p3 0.0314 0.7608 0.1451)"- : spaceText,+ : "#D8D8D8",cursor: action.disabled ? "default" : "pointer",display: "grid",justifyItems: "center",diff --git a/web/apps/space/src/components/HomeHeader.tsx b/web/apps/space/src/components/HomeHeader.tsxindex 5147a8e51f..bb746af352 100644--- a/web/apps/space/src/components/HomeHeader.tsx+++ b/web/apps/space/src/components/HomeHeader.tsx@@ -128,6 +128,7 @@ export const SpaceHomeHeader: React.FC = () => {{notificationsUnread && (<Boxaria-hidden+ className="space-unread-indicator"sx={{bgcolor: "#F63A3A",border: `2.5px solid ${spaceAppBackgroundColor}`,diff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsxindex b366a12cbc..b52923da2c 100644--- a/web/apps/space/src/screens/FriendsScreen.tsx+++ b/web/apps/space/src/screens/FriendsScreen.tsx@@ -1,15 +1,10 @@import {ArrowLeft02Icon,- BubbleChatIcon,Cancel01Icon,- HandPointingRightIcon,- MoreVerticalIcon,- Search01Icon,UserAdd02Icon,- UserRemove01Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import { Box, Menu, MenuItem, Skeleton } from "@mui/material";+import { Box, Skeleton } from "@mui/material";import {spaceActionDoneDurationMs,SpaceActionFeedbackIcon,@@ -18,6 +13,8 @@ import {import { SpaceAddFriendDialog } from "components/AddFriendDialog";import { SpaceAvatarImage } from "components/AvatarImage";import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";+import { FriendOrbit } from "components/FriendOrbit";+import { FriendQuickActionsDialog } from "components/FriendQuickActionsDialog";import { SpaceLoadingSpinner } from "components/RouteFallback";import { SpaceShareInviteButton } from "components/ShareInviteButton";import { SpaceSkipLink } from "components/SkipLink";@@ -27,7 +24,6 @@ import React, { useState } from "react";import type { SpaceFriendRequest } from "services/space";import {spaceAppBackground,- spaceDialogBackground,spaceOnAccent,spaceSurface,spaceSurfaceHover,@@ -41,7 +37,6 @@ const avatarSkeletonBackground = spaceSurface;const textBase = spaceText;const textStrong = spaceText;const textSoft = spaceTextMuted;-const dangerColor = "#F63A3A";const friendAvatarLoadRootMargin = "800px 0px";const friendAvatarCacheKey = (friend: FriendProfile) =>@@ -74,7 +69,8 @@ interface FriendIdentityProps {avatarUrl?: string | null;friend: FriendProfile;onLoadAvatar?: () => Promise<string | null | undefined>;- onOpen?: () => void;+ onOpen?: (event: React.MouseEvent<HTMLButtonElement>) => void;+ floating?: boolean;primaryText?: string;secondaryText?: string;}@@ -82,6 +78,7 @@ interface FriendIdentityProps {const FriendIdentity: React.FC<FriendIdentityProps> = ({avatarUrl,friend,+ floating = false,onLoadAvatar,onOpen,primaryText,@@ -134,19 +131,28 @@ const FriendIdentity: React.FC<FriendIdentityProps> = ({component={onOpen ? "button" : "div"}type={onOpen ? "button" : undefined}onClick={onOpen}+ aria-label={floating ? `Actions for ${displayName}` : undefined}+ aria-haspopup={floating ? "dialog" : undefined}sx={{alignItems: "center",bgcolor: "transparent",border: 0,- borderRadius: "12px",+ borderRadius: floating ? "50%" : "12px",cursor: onOpen ? "pointer" : "default",display: "flex",- gap: "12px",+ flexDirection: floating ? "column" : "row",+ gap: floating ? "10px" : "12px",maxWidth: "100%",minWidth: 0,p: 0,- textAlign: "left",- width: "fit-content",+ textAlign: floating ? "center" : "left",+ width: floating ? "100%" : "fit-content",+ position: "relative",+ transition: "scale 180ms ease",+ "&:hover": floating ? { scale: "1.06" } : undefined,+ "@media (prefers-reduced-motion: reduce)": {+ transition: "none",+ },"&:focus-visible": {outline: `2px solid ${green}`,outlineOffset: 2,@@ -158,13 +164,18 @@ const FriendIdentity: React.FC<FriendIdentityProps> = ({sx={{alignItems: "center",bgcolor: avatarSkeletonBackground,+ border: floating ? "1px solid #454545" : undefined,borderRadius: "50%",display: "flex",flexShrink: 0,- height: 44,+ height: floating ? "auto" : 44,+ aspectRatio: "1",justifyContent: "center",overflow: "hidden",- width: 44,+ width: floating ? "100%" : 44,+ boxShadow: floating+ ? "0 8px 28px rgba(0, 0, 0, 0.2)"+ : undefined,}}>{avatarUrl || !friend.avatarObjectID ? (@@ -181,338 +192,48 @@ const FriendIdentity: React.FC<FriendIdentityProps> = ({/>)}</Box>- <Box- sx={{- display: "flex",- flex: "0 1 auto",- flexDirection: "column",- justifyContent: "center",- minWidth: 0,- }}- >- <Box- sx={{- color: textStrong,- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 14,- fontWeight: 700,- lineHeight: "20px",- minWidth: 0,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {primaryText ?? displayName}- </Box>+ {!floating && (<Boxsx={{- color: textSoft,- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 13,- fontWeight: 500,- lineHeight: "18px",+ display: "flex",+ flex: "0 1 auto",+ flexDirection: "column",+ justifyContent: "center",minWidth: 0,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",}}>- {secondaryText}- </Box>- </Box>- </Box>- );-};--interface FriendRowProps {- avatarUrl?: string | null;- friend: FriendProfile;- onLoadAvatar?: () => Promise<string | null | undefined>;- onMessage?: (friendID: string) => void;- onPoke?: (friendID: string, requestID: string) => Promise<void>;- onOpenFriend?: (friendID: string) => void;- onUnfriend?: (friendID: string) => void;-}--const FriendRow: React.FC<FriendRowProps> = ({- avatarUrl,- friend,- onLoadAvatar,- onMessage,- onPoke,- onOpenFriend,- onUnfriend,-}) => {- const [actionsAnchor, setActionsAnchor] = useState<HTMLElement | null>(- null,- );- const [pokePhase, setPokePhase] = useState<"busy" | "done">();- const [pokeFailed, setPokeFailed] = useState(false);- const pokeRequestID = React.useRef<string | undefined>(undefined);-- React.useEffect(() => {- if (pokePhase != "done") return;-- const timeoutID = window.setTimeout(() => {- setActionsAnchor(null);- }, spaceActionDoneDurationMs);-- return () => window.clearTimeout(timeoutID);- }, [pokePhase]);-- const poke = async () => {- if (!onPoke || pokePhase) return;- setPokePhase("busy");- setPokeFailed(false);- pokeRequestID.current ??= crypto.randomUUID();- try {- await onPoke(friend.id, pokeRequestID.current);- pokeRequestID.current = undefined;- setPokePhase("done");- } catch (error) {- log.error("Failed to send poke", error);- setPokeFailed(true);- setPokePhase(undefined);- }- };- const isActionsOpen = Boolean(actionsAnchor);- const actionsMenuID = `friend-actions-menu-${friend.id}`;- const actionsButtonID = `friend-actions-button-${friend.id}`;- const displayName = friend.fullName.trim() || friend.username.trim();-- const closeActions = () => {- setActionsAnchor(null);- };-- const message = () => {- closeActions();- onMessage?.(friend.id);- };-- const unfriend = () => {- closeActions();- onUnfriend?.(friend.id);- };-- return (- <Box- component="li"- sx={{- alignItems: "center",- display: "grid",- gridTemplateColumns: `minmax(0, 1fr) ${spaceTouchTargetSize}px`,- gap: "12px",- listStyle: "none",- minHeight: 72,- px: "18px",- py: "12px",- width: "100%",- }}- >- <FriendIdentity- avatarUrl={avatarUrl}- friend={friend}- onLoadAvatar={onLoadAvatar}- onOpen={- onOpenFriend ? () => onOpenFriend(friend.id) : undefined- }- />- <Box- component="button"- id={actionsButtonID}- type="button"- aria-label={`Actions for ${displayName}`}- aria-controls={isActionsOpen ? actionsMenuID : undefined}- aria-expanded={isActionsOpen ? "true" : undefined}- aria-haspopup="menu"- onClick={(event) => {- if (pokePhase == "done") setPokePhase(undefined);- setActionsAnchor(event.currentTarget);- }}- sx={{- alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textBase,- cursor: "pointer",- display: "flex",- height: spaceTouchTargetSize,- justifyContent: "flex-end",- justifySelf: "flex-end",- p: 0,- width: spaceTouchTargetSize,- "&:focus-visible": {- outline: `2px solid ${green}`,- outlineOffset: 2,- },- }}- >- <HugeiconsIcon- icon={MoreVerticalIcon}- size={20}- strokeWidth={1.8}- />- </Box>- <Menu- id={actionsMenuID}- anchorEl={actionsAnchor}- open={isActionsOpen}- onClose={closeActions}- anchorOrigin={{ horizontal: "right", vertical: "bottom" }}- transformOrigin={{ horizontal: "right", vertical: "top" }}- slotProps={{- paper: {- sx: {- bgcolor: spaceDialogBackground,- borderRadius: "14px",- boxShadow: "0 14px 40px rgba(0, 0, 0, 0.16)",- mt: "6px",- minWidth: 0,- p: "4px",- width: "max-content",- },- },- list: { "aria-labelledby": actionsButtonID, sx: { p: 0 } },- }}- >- {onMessage && (- <MenuItem- dense- disableRipple- onClick={message}- sx={{- borderRadius: "10px",- color: textBase,- gap: "8px",- minHeight: 36,- px: "9px",- py: "4px",- whiteSpace: "nowrap",- "&.Mui-focusVisible": {- bgcolor: "rgba(255, 255, 255, 0.08)",- },- "&:active": {- bgcolor: "rgba(255, 255, 255, 0.08)",- },- "&:hover": { bgcolor: "rgba(255, 255, 255, 0.08)" },- }}- >- <HugeiconsIcon- icon={BubbleChatIcon}- size={18}- strokeWidth={1.8}- />- <Box- sx={{- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 13,- fontWeight: 650,- lineHeight: "18px",- }}- >- Message- </Box>- </MenuItem>- )}- {onPoke && (- <MenuItem- dense- disableRipple- onClick={() => void poke()}- disabled={pokePhase !== undefined}- sx={{- borderRadius: "10px",- color: textBase,- gap: "8px",- minHeight: 36,- px: "9px",- py: "4px",- whiteSpace: "nowrap",- "&.Mui-disabled": { color: textBase, opacity: 1 },- "&.Mui-focusVisible": {- bgcolor: "rgba(255, 255, 255, 0.08)",- },- "&:active": {- bgcolor: "rgba(255, 255, 255, 0.08)",- },- "&:hover": { bgcolor: "rgba(255, 255, 255, 0.08)" },- }}- >- <SpaceActionFeedbackIcon- phase={pokePhase ?? null}- size={18}- idleIcon={- <HugeiconsIcon- icon={HandPointingRightIcon}- size={18}- strokeWidth={1.8}- />- }- />- <Box- sx={{- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 13,- fontWeight: 650,- lineHeight: "18px",- }}- >- {pokePhase == "done" ? "Poked" : "Poke"}- </Box>- </MenuItem>- )}- {pokeFailed && (<Box- role="alert"sx={{- color: textSoft,- fontSize: 12,- px: "9px",- py: "4px",+ color: textStrong,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 700,+ lineHeight: "20px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",}}>- Couldn't send poke. Try again.+ {primaryText ?? displayName}</Box>- )}- <MenuItem- dense- disableRipple- onClick={unfriend}- sx={{- borderRadius: "10px",- color: dangerColor,- gap: "8px",- minHeight: 36,- px: "9px",- py: "4px",- whiteSpace: "nowrap",- "&.Mui-focusVisible": {- bgcolor: "rgba(246, 58, 58, 0.14)",- },- "&:active": { bgcolor: "rgba(246, 58, 58, 0.14)" },- "&:hover": { bgcolor: "rgba(246, 58, 58, 0.14)" },- }}- >- <HugeiconsIcon- icon={UserRemove01Icon}- size={18}- strokeWidth={1.8}- /><Boxsx={{+ color: textSoft,fontFamily: '"Inter Variable", Inter, sans-serif',fontSize: 13,- fontWeight: 650,+ fontWeight: 500,lineHeight: "18px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",}}>- Unfriend+ {secondaryText}</Box>- </MenuItem>- </Menu>+ </Box>+ )}</Box>);};@@ -724,9 +445,14 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({onUnfriend,}) => {const [isAddFriendOpen, setIsAddFriendOpen] = React.useState(false);- const [searchQuery, setSearchQuery] = React.useState("");+ const [selectedFriend, setSelectedFriend] = React.useState<{+ friend: FriendProfile;+ anchorRect: DOMRect;+ } | null>(null);+ const pokeRequestIDs = React.useRef(new Map<string, string>());const [friendToUnfriend, setFriendToUnfriend] =React.useState<FriendProfile | null>(null);+ const [isUnfriendOpen, setIsUnfriendOpen] = React.useState(false);const [unfriendActionPhase, setUnfriendActionPhase] =React.useState<SpaceActionPhase | null>(null);const [unfriendErrorMessage, setUnfriendErrorMessage] = React.useState<@@ -740,15 +466,6 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({Map<string, Promise<string | null | undefined>>>(new Map());const isUnfriendActionRunning = unfriendActionPhase != null;- const searchTerm = searchQuery.trim().toLowerCase();- const matchesSearch = (friend: FriendProfile) =>- friend.fullName.toLowerCase().includes(searchTerm) ||- `@${friend.username}`.toLowerCase().includes(searchTerm);- const visibleFriendRequests = searchTerm- ? friendRequests.filter((request) => matchesSearch(request.friend))- : friendRequests;- const visibleFriends = searchTerm ? friends.filter(matchesSearch) : friends;-const loadedAvatarURLFor = React.useCallback((friend: FriendProfile) =>friend.avatarUrl ??@@ -795,7 +512,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({const cancelUnfriend = () => {if (isUnfriendActionRunning) return;setUnfriendErrorMessage(null);- setFriendToUnfriend(null);+ setIsUnfriendOpen(false);};const confirmUnfriend = () => {@@ -818,13 +535,14 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({if (unfriendActionPhase != "done") return;const timeoutID = window.setTimeout(() => {- setFriendToUnfriend(null);+ setIsUnfriendOpen(false);}, spaceActionDoneDurationMs);return () => window.clearTimeout(timeoutID);}, [unfriendActionPhase]);const handleUnfriendSheetExited = () => {+ setFriendToUnfriend(null);setUnfriendActionPhase(null);setUnfriendErrorMessage(null);};@@ -851,7 +569,6 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({mx: "auto",position: "relative",width: "100%",- "@media (min-width: 600px)": { maxWidth: 390 },}}><Box@@ -861,6 +578,8 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({display: "grid",gridTemplateColumns: `${spaceTouchTargetSize}px 1fr ${spaceTouchTargetSize}px`,height: 56,+ maxWidth: 390,+ mx: "auto",px: 2,width: "100%",}}@@ -959,91 +678,6 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({aria-label="Friends"tabIndex={-1}>- {!isLoading &&- (friendRequests.length > 0 ||- friends.length > 0 ||- Boolean(searchTerm)) && (- <Box- sx={{- alignItems: "center",- bgcolor: spaceSurface,- borderRadius: "14px",- display: "flex",- height: 48,- mx: "18px",- mt: "12px",- px: "14px",- "&:focus-within": {- outline: `2px solid ${green}`,- },- }}- >- <HugeiconsIcon- icon={Search01Icon}- size={20}- color={textSoft}- strokeWidth={1.8}- />- <Box- component="input"- type="text"- inputMode="search"- aria-label="Search your friends"- autoComplete="off"- onChange={(event) =>- setSearchQuery(event.target.value)- }- placeholder="Search your friends"- value={searchQuery}- sx={{- bgcolor: "transparent",- border: 0,- color: textBase,- flex: 1,- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 14,- fontWeight: 500,- height: "100%",- minWidth: 0,- ml: "10px",- outline: 0,- p: 0,- "&::placeholder": {- color: textSoft,- opacity: 1,- },- }}- />- {searchQuery && (- <Box- component="button"- type="button"- aria-label="Clear search"- onClick={() => setSearchQuery("")}- sx={{- alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textSoft,- cursor: "pointer",- display: "flex",- height: spaceTouchTargetSize,- justifyContent: "center",- mr: "-14px",- p: 0,- width: spaceTouchTargetSize,- }}- >- <HugeiconsIcon- icon={Cancel01Icon}- size={18}- strokeWidth={1.8}- />- </Box>- )}- </Box>- )}{isLoading ? (<Boxsx={{@@ -1056,64 +690,65 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({><SpaceLoadingSpinner ariaLabel="Loading friends" /></Box>- ) : visibleFriendRequests.length > 0 ||- visibleFriends.length > 0 ? (- <Box- component="ul"- sx={{- display: "flex",- flexDirection: "column",- gap: "4px",- m: 0,- mt: "18px",- p: 0,- width: "100%",- }}- >- {visibleFriendRequests.map((request) => (- <FriendRequestRow- key={`request-${request.requestId}`}- request={request}- onAccept={onAcceptFriendRequest}- onDelete={onDeleteFriendRequest}+ ) : friends.length > 0 || friendRequests.length > 0 ? (+ <>+ {friends.length > 0 && (+ <FriendOrbit+ friends={friends}+ renderFriend={(friend) => (+ <FriendIdentity+ floating+ avatarUrl={loadedAvatarURLFor(+ friend,+ )}+ friend={friend}+ onLoadAvatar={() =>+ loadFriendAvatar(friend)+ }+ onOpen={(event) =>+ setSelectedFriend({+ friend,+ anchorRect:+ event.currentTarget.getBoundingClientRect(),+ })+ }+ />+ )}/>- ))}- {visibleFriends.map((friend) => (- <FriendRow- key={friend.id}- avatarUrl={loadedAvatarURLFor(friend)}- friend={friend}- onLoadAvatar={() =>- loadFriendAvatar(friend)- }- onMessage={onMessage}- onPoke={onPoke}- onOpenFriend={onOpenFriend}- onUnfriend={() => {- setUnfriendErrorMessage(null);- setFriendToUnfriend(friend);+ )}+ {friendRequests.length > 0 && (+ <Box+ sx={{+ maxWidth: 390,+ mx: "auto",+ py: "24px",}}- />- ))}- </Box>- ) : searchTerm ? (- <Box- role="status"- sx={{- color: textSoft,- display: "grid",- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 14,- lineHeight: "20px",- minHeight:- "max(0px, calc(var(--space-page-height, 100svh) - 116px))",- placeItems: "center",- textAlign: "center",- }}- >- No results found.- </Box>+ >+ <Box+ component="h2"+ sx={{+ fontSize: 14,+ fontWeight: 600,+ m: 0,+ px: "18px",+ pb: "8px",+ }}+ >+ Friend requests+ </Box>+ <Box component="ul" sx={{ m: 0, p: 0 }}>+ {friendRequests.map((request) => (+ <FriendRequestRow+ key={request.requestId}+ request={request}+ onAccept={onAcceptFriendRequest}+ onDelete={onDeleteFriendRequest}+ />+ ))}+ </Box>+ </Box>+ )}+ </>) : (<Boxsx={{@@ -1154,10 +789,54 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({)}</Box></Box>+ {selectedFriend && (+ <FriendQuickActionsDialog+ anchorRect={selectedFriend.anchorRect}+ avatarUrl={loadedAvatarURLFor(selectedFriend.friend)}+ friend={selectedFriend.friend}+ onClose={() => setSelectedFriend(null)}+ onMessage={+ onMessage+ ? () => onMessage(selectedFriend.friend.id)+ : undefined+ }+ onPoke={+ onPoke+ ? async () => {+ const friendID = selectedFriend.friend.id;+ const requestID =+ pokeRequestIDs.current.get(friendID) ??+ crypto.randomUUID();+ pokeRequestIDs.current.set(+ friendID,+ requestID,+ );+ await onPoke(friendID, requestID);+ pokeRequestIDs.current.delete(friendID);+ }+ : undefined+ }+ onProfile={+ onOpenFriend+ ? () => onOpenFriend(selectedFriend.friend.id)+ : undefined+ }+ onUnfriend={+ onUnfriend+ ? () => {+ setUnfriendErrorMessage(null);+ setFriendToUnfriend(selectedFriend.friend);+ setIsUnfriendOpen(true);+ }+ : undefined+ }+ />+ )}<ConfirmationActionSheet- open={Boolean(friendToUnfriend)}- title="Are you sure you want to unfriend?"- confirmLabel="Yes, unfriend"+ open={isUnfriendOpen}+ title={`Unfriend ${friendToUnfriend?.fullName.trim().split(/\s+/)[0] || friendToUnfriend?.username}?`}+ description="You’ll no longer see each other’s posts or message each other."+ confirmLabel="Unfriend"confirmActionPhase={unfriendActionPhase}confirmDisabled={isUnfriendActionRunning}errorMessage={unfriendErrorMessage}diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsxindex 21aced2fb1..c1eb5c1ec2 100644--- a/web/apps/space/src/screens/ProfileScreen.tsx+++ b/web/apps/space/src/screens/ProfileScreen.tsx@@ -1555,8 +1555,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({)}<ConfirmationActionSheetopen={isUnfriendSheetOpen}- title="Are you sure you want to unfriend?"- confirmLabel="Yes, unfriend"+ title={`Unfriend ${profile.fullName.trim().split(/\s+/)[0] || profile.username}?`}+ description="You’ll no longer see each other’s posts or message each other."+ confirmLabel="Unfriend"confirmActionPhase={unfriendActionPhase}confirmDisabled={isUnfriendActionRunning}errorMessage={unfriendErrorMessage}diff --git a/web/apps/space/src/styles/globals.css b/web/apps/space/src/styles/globals.cssindex 252880fecc..2274a8b709 100644--- a/web/apps/space/src/styles/globals.css+++ b/web/apps/space/src/styles/globals.css@@ -16,6 +16,36 @@padding-bottom: var(--space-bottom-nav-height);}+.space-unread-indicator {+ z-index: 1;+}++.space-unread-indicator::after {+ animation: spaceUnreadBadgePing 1.25s cubic-bezier(0, 0, 0.2, 1) 1 forwards;+ background-color: inherit;+ border-radius: 50%;+ content: "";+ inset: 0;+ opacity: 0.75;+ pointer-events: none;+ position: absolute;+ z-index: -1;+}++@keyframes spaceUnreadBadgePing {+ 75%,+ 100% {+ opacity: 0;+ transform: scale(2.5);+ }+}++@media (prefers-reduced-motion: reduce) {+ .space-unread-indicator::after {+ display: none;+ }+}+::view-transition-group(space-bottom-nav) {z-index: 1;animation: none;diff --git a/web/apps/space/src/utils/friend-orbit.ts b/web/apps/space/src/utils/friend-orbit.tsnew file mode 100644index 0000000000..ae68231f3d--- /dev/null+++ b/web/apps/space/src/utils/friend-orbit.ts@@ -0,0 +1,167 @@+export interface FriendOrbitCircle {+ id: string;+ homeX: number;+ homeY: number;+ x: number;+ y: number;+ vx: number;+ vy: number;+ size: number;+}++export interface FriendOrbitBounds {+ width: number;+ height: number;+ scale: number;+}++const circleSizes = [144, 64, 88, 68, 136, 112, 148, 72, 64];++export const createFriendOrbitCircle = (+ id: string,+ index: number,+): FriendOrbitCircle => {+ const angle = index * 2.399963229728653;+ const radius = 22 * Math.sqrt(index);+ const homeX = Math.cos(angle) * radius;+ const homeY = Math.sin(angle) * radius;+ return {+ id,+ homeX,+ homeY,+ x: homeX,+ y: homeY,+ vx: 0,+ vy: 0,+ size: circleSizes[index % circleSizes.length]!,+ };+};++export const friendOrbitCircleSize = (+ index: number,+ count: number,+ bounds: FriendOrbitBounds,+) => {+ const diameter =+ circleSizes[index % circleSizes.length]! *+ bounds.scale *+ Math.sqrt(9 / count);+ const maximum = Math.min(280, bounds.width * 0.68, bounds.height * 0.5);+ return Math.max(48, Math.min(maximum, diameter)) / bounds.scale;+};++export const friendOrbitAngle = (elapsed: number) =>+ (elapsed / 240000) * Math.PI * 2;++export const stepFriendOrbit = (+ circles: FriendOrbitCircle[],+ bounds: FriendOrbitBounds,+ elapsed: number,+ delta: number,+ draggedID?: string,+ reducedMotion = false,+) => {+ const angle = friendOrbitAngle(elapsed);+ const cos = Math.cos(angle);+ const sin = Math.sin(angle);+ const frame = Math.min(delta / 16.667, 2);+ const damping = 0.87 ** frame;+ circles.forEach((circle, index) => {+ if (circle.id == draggedID) return;+ const driftX = reducedMotion+ ? 0+ : Math.sin(elapsed * 0.00034 + index * 1.71) * 3.5;+ const driftY = reducedMotion+ ? 0+ : Math.cos(elapsed * 0.00029 + index * 2.03) * 3.5;+ const x = circle.homeX + driftX;+ const y = circle.homeY + driftY;+ circle.vx =+ (circle.vx + (x * cos - y * sin - circle.x) * 0.018 * frame) *+ damping;+ circle.vy =+ (circle.vy + (x * sin + y * cos - circle.y) * 0.018 * frame) *+ damping;+ circle.x += circle.vx * frame;+ circle.y += circle.vy * frame;+ });++ for (+ let pass = 0;+ pass < Math.max(7, Math.ceil(circles.length / 2));+ pass+++ ) {+ for (let i = 0; i < circles.length; i++) {+ const first = circles[i]!;+ for (let j = i + 1; j < circles.length; j++) {+ const second = circles[j]!;+ const dx = second.x - first.x;+ const dy = second.y - first.y;+ const separation = (first.size + second.size) / 2 + 10;+ if (Math.abs(dx) >= separation || Math.abs(dy) >= separation)+ continue;+ const distance = Math.hypot(dx, dy);+ if (distance >= separation) continue;+ const nx = distance < 0.001 ? Math.cos(i + j) : dx / distance;+ const ny = distance < 0.001 ? Math.sin(i + j) : dy / distance;+ const push = separation - distance;+ const firstShare =+ first.id == draggedID+ ? 0+ : second.id == draggedID+ ? 1+ : 0.505;+ const secondShare =+ second.id == draggedID+ ? 0+ : first.id == draggedID+ ? 1+ : 0.505;+ first.x -= nx * push * firstShare;+ first.y -= ny * push * firstShare;+ second.x += nx * push * secondShare;+ second.y += ny * push * secondShare;+ }+ }+ circles.forEach((circle) => {+ if (circle.id == draggedID) return;+ const radius = circle.size / 2 + 12 / bounds.scale;+ const halfWidth = bounds.width / (2 * bounds.scale);+ const halfHeight = bounds.height / (2 * bounds.scale);+ circle.x = Math.max(+ -halfWidth + radius,+ Math.min(halfWidth - radius, circle.x),+ );+ circle.y = Math.max(+ -halfHeight + radius,+ Math.min(halfHeight - radius, circle.y),+ );+ });+ }+};++export const arrangeFriendOrbit = (+ circles: FriendOrbitCircle[],+ bounds: FriendOrbitBounds,+ elapsed: number,+) => {+ circles.forEach((circle, index) => {+ const initial = createFriendOrbitCircle(circle.id, index);+ Object.assign(circle, initial, { size: circle.size });+ });+ for (let frame = 0; frame < 90; frame++) {+ stepFriendOrbit(circles, bounds, 0, 16.667, undefined, true);+ }+ const angle = friendOrbitAngle(elapsed);+ circles.forEach((circle) => {+ circle.homeX = circle.x;+ circle.homeY = circle.y;+ circle.vx = 0;+ circle.vy = 0;+ circle.x =+ circle.homeX * Math.cos(angle) - circle.homeY * Math.sin(angle);+ circle.y =+ circle.homeX * Math.sin(angle) + circle.homeY * Math.cos(angle);+ });+ stepFriendOrbit(circles, bounds, elapsed, 0);+};diff --git a/web/apps/space/tests/friend-orbit.test.ts b/web/apps/space/tests/friend-orbit.test.tsnew file mode 100644index 0000000000..04fa96927b--- /dev/null+++ b/web/apps/space/tests/friend-orbit.test.ts@@ -0,0 +1,153 @@+import { describe, expect, it } from "vitest";+import {+ arrangeFriendOrbit,+ createFriendOrbitCircle,+ friendOrbitAngle,+ friendOrbitCircleSize,+ stepFriendOrbit,+} from "../src/utils/friend-orbit";++describe("friend orbit", () => {+ it("completes the reference orbit in four minutes", () => {+ expect(friendOrbitAngle(60000)).toBeCloseTo(Math.PI / 2);+ expect(friendOrbitAngle(240000)).toBeCloseTo(Math.PI * 2);+ });++ for (const [width, height, scale, count] of [+ [1280, 664, 1.4, 9],+ [390, 728, 0.84, 1],+ [390, 728, 0.84, 3],+ [390, 728, 0.84, 9],+ [320, 452, 0.84, 9],+ [390, 728, 0.84, 36],+ ] as const) {+ it(`keeps ${count} friends separated and in bounds at ${width}px`, () => {+ const bounds = { width, height, scale };+ const circles = Array.from({ length: count }, (_, index) => ({+ ...createFriendOrbitCircle(String(index), index),+ size: friendOrbitCircleSize(index, count, bounds),+ }));+ arrangeFriendOrbit(circles, bounds, 0);+ for (let frame = 0; frame < 600; frame++) {+ stepFriendOrbit(circles, bounds, frame * 16.667, 16.667);+ for (const circle of circles) {+ const radius = circle.size / 2;+ expect(Math.abs(circle.x) + radius).toBeLessThanOrEqual(+ width / (2 * scale) + 0.01,+ );+ expect(Math.abs(circle.y) + radius).toBeLessThanOrEqual(+ height / (2 * scale) + 0.01,+ );+ }+ }+ for (let i = 0; i < circles.length; i++) {+ for (let j = i + 1; j < circles.length; j++) {+ const first = circles[i]!;+ const second = circles[j]!;+ expect(+ Math.hypot(first.x - second.x, first.y - second.y),+ ).toBeGreaterThanOrEqual((first.size + second.size) / 2);+ }+ }+ });+ }++ it("starts settled and keeps moving smoothly after the page appears", () => {+ const bounds = { width: 390, height: 728, scale: 0.84 };+ const circles = Array.from({ length: 9 }, (_, index) => ({+ ...createFriendOrbitCircle(String(index), index),+ size: friendOrbitCircleSize(index, 9, bounds),+ }));+ arrangeFriendOrbit(circles, bounds, 0);+ const initial = circles.map(({ x, y }) => ({ x, y }));+ for (let frame = 1; frame <= 180; frame++) {+ const previous = circles.map(({ x, y }) => ({ x, y }));+ stepFriendOrbit(circles, bounds, frame * 16.667, 16.667);+ circles.forEach((circle, index) => {+ expect(+ Math.hypot(+ circle.x - previous[index]!.x,+ circle.y - previous[index]!.y,+ ),+ ).toBeLessThan(2);+ });+ }+ circles.forEach((circle, index) => {+ expect(+ Math.hypot(+ circle.x - initial[index]!.x,+ circle.y - initial[index]!.y,+ ),+ ).toBeGreaterThan(0.5);+ });+ });++ it("makes small groups larger and crowded groups smaller without tiny targets", () => {+ const bounds = { width: 390, height: 728, scale: 0.84 };+ for (let index = 0; index < 3; index++) {+ expect(friendOrbitCircleSize(index, 3, bounds)).toBeGreaterThan(+ friendOrbitCircleSize(index, 9, bounds),+ );+ expect(friendOrbitCircleSize(index, 9, bounds)).toBeGreaterThan(+ friendOrbitCircleSize(index, 36, bounds),+ );+ }+ for (let index = 0; index < 100; index++) {+ expect(+ friendOrbitCircleSize(index, 100, bounds) * bounds.scale,+ ).toBeGreaterThanOrEqual(48);+ }+ expect(friendOrbitCircleSize(0, 1, bounds) * bounds.scale).toBeLessThan(+ bounds.width - 24,+ );+ });++ it("keeps a held circle under the pointer and moves neighbors aside", () => {+ const first = createFriendOrbitCircle("first", 0);+ const second = createFriendOrbitCircle("second", 1);+ first.x = second.x = 0;+ first.y = second.y = 0;+ stepFriendOrbit(+ [first, second],+ { width: 1280, height: 720, scale: 1.4 },+ 0,+ 16.667,+ first.id,+ );+ expect(first.x).toBe(0);+ expect(first.y).toBe(0);+ expect(Math.hypot(second.x, second.y)).toBeGreaterThanOrEqual(+ (first.size + second.size) / 2,+ );+ });++ it("eases a released circle back without saving the dragged position", () => {+ const circle = createFriendOrbitCircle("friend", 0);+ circle.x = 160;+ circle.y = 90;+ const bounds = { width: 1280, height: 720, scale: 1.4 };+ stepFriendOrbit([circle], bounds, 0, 16.667, undefined, true);+ expect(circle.x).toBeLessThan(160);+ expect(circle.x).toBeGreaterThan(circle.homeX);+ for (let i = 0; i < 300; i++)+ stepFriendOrbit([circle], bounds, 0, 16.667, undefined, true);+ expect(circle.x).toBeCloseTo(circle.homeX);+ expect(circle.y).toBeCloseTo(circle.homeY);+ });++ it("does not drift when reduced motion is enabled", () => {+ const circle = createFriendOrbitCircle("friend", 0);+ for (let i = 0; i < 60; i++) {+ stepFriendOrbit(+ [circle],+ { width: 1280, height: 720, scale: 1.4 },+ 0,+ 16.667,+ undefined,+ true,+ );+ }+ expect(circle.x).toBe(circle.homeX);+ expect(circle.y).toBe(circle.homeY);+ });+});