Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
import React, { useEffect, useRef } from 'react';
import { Users } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
export interface MentionItem {
type: 'kwant' | 'team';
id: string;
name: string;
title?: string;
/** One-line "good at" phrases (same source as the bot home chips); shown instead of the title. */
goodAt?: string[];
avatar_sprite?: string;
memberCount?: number;
}
export interface MentionPopoverProps {
items: MentionItem[];
selectedIndex: number;
onSelect: (item: MentionItem) => void;
position?: { top: number; left: number };
}
export const MentionPopover: React.FC<MentionPopoverProps> = ({
items,
selectedIndex,
onSelect,
position,
}) => {
const itemRefs = useRef<(HTMLButtonElement | null)[]>([]);
useEffect(() => {
if (itemRefs.current[selectedIndex]) {
itemRefs.current[selectedIndex]?.scrollIntoView({
block: 'nearest',
});
}
}, [selectedIndex]);
if (items.length === 0) {
return null;
}
return (
<div
role="listbox"
aria-label="Mention a bot"
id="kw-mention-list"
className="kw-fade-in absolute bottom-full left-0 right-0 sm:right-auto mb-2 bg-surface-overlay border border-hairline-strong rounded-xl shadow-raised p-1.5 min-w-[260px] sm:w-[min(22rem,calc(100vw-2rem))] max-h-72 overflow-y-auto z-50"
style={
position
? { top: `${position.top}px`, left: `${position.left}px`, bottom: 'auto' }
: undefined
}
>
<div className="space-y-0.5">
{items.map((item, index) => {
const isSelected = index === selectedIndex;
const showSectionHeader =
index === 0 || items[index - 1].type !== item.type;
return (
<React.Fragment key={`${item.type}-${item.id}`}>
{showSectionHeader && (
<div className="text-2xs font-semibold text-zinc-400 uppercase tracking-wider px-2.5 py-1 select-none">
{item.type === 'kwant' ? 'Bots' : 'Teams'}
</div>
)}
<button
type="button"
role="option"
id={`kw-mention-${index}`}
aria-selected={isSelected}
ref={(el) => (itemRefs.current[index] = el)}
onClick={() => onSelect(item)}
onMouseDown={(e) => {
// Prevent input blur before click event fires
e.preventDefault();
}}
className={`w-full flex items-center justify-between gap-3 px-2.5 py-2 min-h-[44px] sm:min-h-0 sm:py-1.5 rounded-lg text-left transition-colors text-xs focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 ${
isSelected
? 'bg-white/[0.1] text-zinc-50 ring-1 ring-inset ring-sky-400/40'
: 'text-zinc-200 hover:bg-white/[0.06] hover:text-zinc-50'
}`}
>
<div className="flex items-center gap-2.5 min-w-0">
{item.type === 'kwant' ? (
<ModernAvatar
role={item.avatar_sprite || item.title || item.name}
name={item.name}
size={32}
kwantId={item.id}
/>
) : (
<div className="w-6 h-6 rounded-lg bg-sky-500/10 border border-sky-500/20 text-sky-400 flex items-center justify-center flex-shrink-0">
<Users size={13} />
</div>
)}
<div className="min-w-0 truncate">
<div className="font-semibold text-body truncate text-zinc-50">
@{item.name}
</div>
{(item.goodAt?.length || item.title) && (
<div className="text-meta text-zinc-300 truncate" data-good-at>
{item.goodAt?.length ? `Good at ${item.goodAt.slice(0, 3).join(' · ')}` : item.title}
</div>
)}
</div>
</div>
{item.type === 'team' && item.memberCount !== undefined && (
<span className="flex-shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-zinc-800/80 text-zinc-400 border border-zinc-700/50">
{item.memberCount} {item.memberCount === 1 ? 'member' : 'members'}
</span>
)}
</button>
</React.Fragment>
);
})}
</div>
</div>
);
};