diff --git a/web/app/components/workflow/header/header-in-normal.tsx b/web/app/components/workflow/header/header-in-normal.tsx index 5768e6bc06..bfce06aca9 100644 --- a/web/app/components/workflow/header/header-in-normal.tsx +++ b/web/app/components/workflow/header/header-in-normal.tsx @@ -17,6 +17,7 @@ import RunAndHistory from './run-and-history' import EditingTitle from './editing-title' import EnvButton from './env-button' import VersionHistoryButton from './version-history-button' +import OnlineUsers from './online-users' export type HeaderInNormalProps = { components?: { @@ -60,6 +61,8 @@ const HeaderInNormal = ({
{components?.left} + + diff --git a/web/app/components/workflow/header/online-users.tsx b/web/app/components/workflow/header/online-users.tsx new file mode 100644 index 0000000000..4d868cf57f --- /dev/null +++ b/web/app/components/workflow/header/online-users.tsx @@ -0,0 +1,50 @@ +'use client' +import Avatar from '@/app/components/base/avatar' +import { useCollaboration } from '../collaboration/hooks/use-collaboration' +import { useStore } from '../store' +import cn from '@/utils/classnames' + +const OnlineUsers = () => { + const appId = useStore(s => s.appId) + const { onlineUsers } = useCollaboration(appId) + + if (!onlineUsers || onlineUsers.length === 0) + return null + + // Show max 2 avatars directly, rest as count + const visibleUsers = onlineUsers.slice(0, 2) + const remainingCount = onlineUsers.length - 2 + + return ( +
+ {visibleUsers.map((user, index) => ( +
+ +
+ ))} + {remainingCount > 0 && ( +
+ +{remainingCount} +
+ )} +
+ ) +} + +export default OnlineUsers