adds search support with exa

This commit is contained in:
2026-02-13 23:49:55 -08:00
parent 5340c55aa6
commit 393dac37a7
14 changed files with 948 additions and 155 deletions

View File

@@ -1,25 +1,38 @@
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { LogOut, MessageSquare, Plus, SendHorizontal, ShieldCheck } from "lucide-preact";
import { Globe2, LogOut, MessageSquare, Plus, Search, SendHorizontal, ShieldCheck } from "lucide-preact";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Separator } from "@/components/ui/separator";
import {
createChat,
createSearch,
getChat,
getConfiguredToken,
getSearch,
listChats,
listSearches,
runCompletion,
runSearch,
setAuthToken,
verifySession,
type ChatDetail,
type ChatSummary,
type CompletionRequestMessage,
type SearchDetail,
type SearchResultItem,
type SearchSummary,
} from "@/lib/api";
import { cn } from "@/lib/utils";
type Provider = "openai" | "anthropic" | "xai";
type AuthMode = "open" | "token";
type SidebarSelection = { kind: "chat" | "search"; id: string };
type SidebarItem = SidebarSelection & {
title: string;
updatedAt: string;
createdAt: string;
};
const PROVIDER_DEFAULT_MODELS: Record<Provider, string> = {
openai: "gpt-4.1-mini",
@@ -35,6 +48,33 @@ function getChatTitle(chat: Pick<ChatSummary, "title">, messages?: ChatDetail["m
return "New chat";
}
function getSearchTitle(search: Pick<SearchSummary, "title" | "query">) {
if (search.title?.trim()) return search.title.trim();
if (search.query?.trim()) return search.query.trim().slice(0, 64);
return "New search";
}
function buildSidebarItems(chats: ChatSummary[], searches: SearchSummary[]): SidebarItem[] {
const items: SidebarItem[] = [
...chats.map((chat) => ({
kind: "chat" as const,
id: chat.id,
title: getChatTitle(chat),
updatedAt: chat.updatedAt,
createdAt: chat.createdAt,
})),
...searches.map((search) => ({
kind: "search" as const,
id: search.id,
title: getSearchTitle(search),
updatedAt: search.updatedAt,
createdAt: search.createdAt,
})),
];
return items.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
}
function formatDate(value: string) {
return new Intl.DateTimeFormat(undefined, {
month: "short",
@@ -63,6 +103,20 @@ function normalizeAuthError(message: string) {
return message;
}
function summarizeResult(result: SearchResultItem) {
const highlights = Array.isArray(result.highlights) ? result.highlights.filter(Boolean) : [];
if (highlights.length) return highlights.join(" ").slice(0, 420);
return (result.text ?? "").slice(0, 420);
}
function formatHost(url: string) {
try {
return new URL(url).hostname.replace(/^www\./, "");
} catch {
return url;
}
}
export default function App() {
const initialToken = readStoredToken() ?? getConfiguredToken() ?? "";
@@ -74,10 +128,12 @@ export default function App() {
const [authError, setAuthError] = useState<string | null>(null);
const [chats, setChats] = useState<ChatSummary[]>([]);
const [selectedChatId, setSelectedChatId] = useState<string | null>(null);
const [searches, setSearches] = useState<SearchSummary[]>([]);
const [selectedItem, setSelectedItem] = useState<SidebarSelection | null>(null);
const [selectedChat, setSelectedChat] = useState<ChatDetail | null>(null);
const [isLoadingChats, setIsLoadingChats] = useState(false);
const [isLoadingChat, setIsLoadingChat] = useState(false);
const [selectedSearch, setSelectedSearch] = useState<SearchDetail | null>(null);
const [isLoadingCollections, setIsLoadingCollections] = useState(false);
const [isLoadingSelection, setIsLoadingSelection] = useState(false);
const [isSending, setIsSending] = useState(false);
const [composer, setComposer] = useState("");
const [provider, setProvider] = useState<Provider>("openai");
@@ -85,6 +141,8 @@ export default function App() {
const [error, setError] = useState<string | null>(null);
const transcriptEndRef = useRef<HTMLDivElement>(null);
const sidebarItems = useMemo(() => buildSidebarItems(chats, searches), [chats, searches]);
const completeSessionCheck = async (tokenCandidate: string | null) => {
setAuthToken(tokenCandidate);
const session = await verifySession();
@@ -101,24 +159,34 @@ export default function App() {
setAuthToken(null);
persistToken(null);
setChats([]);
setSelectedChatId(null);
setSearches([]);
setSelectedItem(null);
setSelectedChat(null);
setSelectedSearch(null);
};
const refreshChats = async (preferredChatId?: string) => {
setIsLoadingChats(true);
const refreshCollections = async (preferredSelection?: SidebarSelection) => {
setIsLoadingCollections(true);
try {
const nextChats = await listChats();
const [nextChats, nextSearches] = await Promise.all([listChats(), listSearches()]);
const nextItems = buildSidebarItems(nextChats, nextSearches);
setChats(nextChats);
setSearches(nextSearches);
setSelectedChatId((current) => {
if (preferredChatId && nextChats.some((chat) => chat.id === preferredChatId)) {
return preferredChatId;
setSelectedItem((current) => {
const hasItem = (candidate: SidebarSelection | null) => {
if (!candidate) return false;
return nextItems.some((item) => item.kind === candidate.kind && item.id === candidate.id);
};
if (preferredSelection && hasItem(preferredSelection)) {
return preferredSelection;
}
if (current && nextChats.some((chat) => chat.id === current)) {
if (hasItem(current)) {
return current;
}
return nextChats[0]?.id ?? null;
const first = nextItems[0];
return first ? { kind: first.kind, id: first.id } : null;
});
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
@@ -128,15 +196,16 @@ export default function App() {
setError(message);
}
} finally {
setIsLoadingChats(false);
setIsLoadingCollections(false);
}
};
const refreshChat = async (chatId: string) => {
setIsLoadingChat(true);
setIsLoadingSelection(true);
try {
const chat = await getChat(chatId);
setSelectedChat(chat);
setSelectedSearch(null);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
if (message.includes("bearer token")) {
@@ -145,7 +214,25 @@ export default function App() {
setError(message);
}
} finally {
setIsLoadingChat(false);
setIsLoadingSelection(false);
}
};
const refreshSearch = async (searchId: string) => {
setIsLoadingSelection(true);
try {
const search = await getSearch(searchId);
setSelectedSearch(search);
setSelectedChat(null);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
if (message.includes("bearer token")) {
handleAuthFailure(message);
} else {
setError(message);
}
} finally {
setIsLoadingSelection(false);
}
};
@@ -165,37 +252,65 @@ export default function App() {
useEffect(() => {
if (!isAuthenticated) return;
void refreshChats();
void refreshCollections();
}, [isAuthenticated]);
const selectedKey = selectedItem ? `${selectedItem.kind}:${selectedItem.id}` : null;
useEffect(() => {
if (!isAuthenticated) {
setSelectedChat(null);
setSelectedSearch(null);
return;
}
if (!selectedChatId) {
if (!selectedItem) {
setSelectedChat(null);
setSelectedSearch(null);
return;
}
void refreshChat(selectedChatId);
}, [isAuthenticated, selectedChatId]);
if (selectedItem.kind === "chat") {
void refreshChat(selectedItem.id);
return;
}
void refreshSearch(selectedItem.id);
}, [isAuthenticated, selectedKey]);
useEffect(() => {
transcriptEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
}, [selectedChat?.messages.length, isSending]);
}, [selectedChat?.messages.length, selectedSearch?.results.length, isSending]);
const messages = selectedChat?.messages ?? [];
const selectedChatTitle = useMemo(() => {
if (!selectedChat) return "Sybil";
return getChatTitle(selectedChat, selectedChat.messages);
}, [selectedChat]);
const selectedChatSummary = useMemo(() => {
if (!selectedItem || selectedItem.kind !== "chat") return null;
return chats.find((chat) => chat.id === selectedItem.id) ?? null;
}, [chats, selectedItem]);
const selectedSearchSummary = useMemo(() => {
if (!selectedItem || selectedItem.kind !== "search") return null;
return searches.find((search) => search.id === selectedItem.id) ?? null;
}, [searches, selectedItem]);
const selectedTitle = useMemo(() => {
if (!selectedItem) return "Sybil";
if (selectedItem.kind === "chat") {
if (selectedChat) return getChatTitle(selectedChat, selectedChat.messages);
if (selectedChatSummary) return getChatTitle(selectedChatSummary);
return "New chat";
}
if (selectedSearch) return getSearchTitle(selectedSearch);
if (selectedSearchSummary) return getSearchTitle(selectedSearchSummary);
return "New search";
}, [selectedChat, selectedChatSummary, selectedItem, selectedSearch, selectedSearchSummary]);
const isSearchMode = selectedItem?.kind === "search";
const handleCreateChat = async () => {
setError(null);
try {
const chat = await createChat();
setSelectedChatId(chat.id);
setSelectedItem({ kind: "chat", id: chat.id });
setSelectedChat({
id: chat.id,
title: chat.title,
@@ -203,7 +318,8 @@ export default function App() {
updatedAt: chat.updatedAt,
messages: [],
});
await refreshChats(chat.id);
setSelectedSearch(null);
await refreshCollections({ kind: "chat", id: chat.id });
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
if (message.includes("bearer token")) {
@@ -214,6 +330,142 @@ export default function App() {
}
};
const handleCreateSearch = async () => {
setError(null);
try {
const search = await createSearch();
setSelectedItem({ kind: "search", id: search.id });
setSelectedSearch({
id: search.id,
title: search.title,
query: search.query,
createdAt: search.createdAt,
updatedAt: search.updatedAt,
requestId: null,
latencyMs: null,
error: null,
results: [],
});
setSelectedChat(null);
await refreshCollections({ kind: "search", id: search.id });
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
if (message.includes("bearer token")) {
handleAuthFailure(message);
} else {
setError(message);
}
}
};
const handleSendChat = async (content: string) => {
let chatId = selectedItem?.kind === "chat" ? selectedItem.id : null;
if (!chatId) {
const chat = await createChat();
chatId = chat.id;
setSelectedItem({ kind: "chat", id: chatId });
setSelectedChat({
id: chat.id,
title: chat.title,
createdAt: chat.createdAt,
updatedAt: chat.updatedAt,
messages: [],
});
setSelectedSearch(null);
}
if (!chatId) {
throw new Error("Unable to initialize chat");
}
let baseChat = selectedChat;
if (!baseChat || baseChat.id !== chatId) {
baseChat = await getChat(chatId);
}
const optimisticUserMessage = {
id: `temp-user-${Date.now()}`,
createdAt: new Date().toISOString(),
role: "user" as const,
content,
name: null,
};
const optimisticAssistantMessage = {
id: `temp-assistant-${Date.now()}`,
createdAt: new Date().toISOString(),
role: "assistant" as const,
content: "",
name: null,
};
setSelectedChat((current) => {
if (!current || current.id !== chatId) return current;
return {
...current,
messages: [...current.messages, optimisticUserMessage, optimisticAssistantMessage],
};
});
const requestMessages: CompletionRequestMessage[] = [
...baseChat.messages.map((message) => ({
role: message.role,
content: message.content,
...(message.name ? { name: message.name } : {}),
})),
{
role: "user",
content,
},
];
await runCompletion({
chatId,
provider,
model: model.trim(),
messages: requestMessages,
});
await Promise.all([refreshCollections({ kind: "chat", id: chatId }), refreshChat(chatId)]);
};
const handleSendSearch = async (query: string) => {
let searchId = selectedItem?.kind === "search" ? selectedItem.id : null;
if (!searchId) {
const search = await createSearch();
searchId = search.id;
setSelectedItem({ kind: "search", id: searchId });
}
if (!searchId) {
throw new Error("Unable to initialize search");
}
setSelectedSearch((current) => {
if (!current || current.id !== searchId) return current;
return {
...current,
title: query.slice(0, 80),
query,
error: null,
results: [],
};
});
const search = await runSearch(searchId, {
query,
title: query.slice(0, 80),
type: "auto",
numResults: 10,
});
setSelectedSearch(search);
setSelectedChat(null);
await refreshCollections({ kind: "search", id: searchId });
};
const handleSend = async () => {
const content = composer.trim();
if (!content || isSending) return;
@@ -222,68 +474,12 @@ export default function App() {
setError(null);
setIsSending(true);
let chatId = selectedChatId;
try {
if (!chatId) {
const chat = await createChat();
chatId = chat.id;
setSelectedChatId(chatId);
if (isSearchMode) {
await handleSendSearch(content);
} else {
await handleSendChat(content);
}
if (!chatId) {
throw new Error("Unable to initialize chat");
}
let baseChat = selectedChat;
if (!baseChat || baseChat.id !== chatId) {
baseChat = await getChat(chatId);
}
const optimisticUserMessage = {
id: `temp-user-${Date.now()}`,
createdAt: new Date().toISOString(),
role: "user" as const,
content,
name: null,
};
const optimisticAssistantMessage = {
id: `temp-assistant-${Date.now()}`,
createdAt: new Date().toISOString(),
role: "assistant" as const,
content: "",
name: null,
};
setSelectedChat((current) => {
if (!current || current.id !== chatId) return current;
return {
...current,
messages: [...current.messages, optimisticUserMessage, optimisticAssistantMessage],
};
});
const requestMessages: CompletionRequestMessage[] = [
...baseChat.messages.map((message) => ({
role: message.role,
content: message.content,
...(message.name ? { name: message.name } : {}),
})),
{
role: "user",
content,
},
];
await runCompletion({
chatId,
provider,
model: model.trim(),
messages: requestMessages,
});
await Promise.all([refreshChats(chatId), refreshChat(chatId)]);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
if (message.includes("bearer token")) {
@@ -291,8 +487,12 @@ export default function App() {
} else {
setError(message);
}
if (chatId) {
await refreshChat(chatId);
if (selectedItem?.kind === "chat") {
await refreshChat(selectedItem.id);
}
if (selectedItem?.kind === "search") {
await refreshSearch(selectedItem.id);
}
} finally {
setIsSending(false);
@@ -304,7 +504,7 @@ export default function App() {
setAuthError(null);
try {
await completeSessionCheck(tokenCandidate);
await refreshChats();
await refreshCollections();
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
setAuthError(normalizeAuthError(message));
@@ -322,8 +522,10 @@ export default function App() {
setAuthMode(null);
setAuthError(null);
setChats([]);
setSelectedChatId(null);
setSearches([]);
setSelectedItem(null);
setSelectedChat(null);
setSelectedSearch(null);
setComposer("");
setError(null);
};
@@ -390,35 +592,44 @@ export default function App() {
<div className="h-full p-3 md:p-5">
<div className="mx-auto flex h-full w-full max-w-[1560px] overflow-hidden rounded-2xl border bg-background shadow-xl shadow-black/40">
<aside className="flex w-80 shrink-0 flex-col border-r bg-[#111827]">
<div className="p-3">
<Button className="w-full justify-start gap-2" onClick={handleCreateChat}>
<div className="grid grid-cols-2 gap-2 p-3">
<Button className="justify-start gap-2" onClick={handleCreateChat}>
<Plus className="h-4 w-4" />
New chat
</Button>
<Button className="justify-start gap-2" variant="secondary" onClick={handleCreateSearch}>
<Search className="h-4 w-4" />
New search
</Button>
</div>
<Separator />
<div className="flex-1 overflow-y-auto p-2">
{isLoadingChats && chats.length === 0 ? <p className="px-2 py-3 text-sm text-muted-foreground">Loading chats...</p> : null}
{!isLoadingChats && chats.length === 0 ? (
{isLoadingCollections && sidebarItems.length === 0 ? (
<p className="px-2 py-3 text-sm text-muted-foreground">Loading conversations...</p>
) : null}
{!isLoadingCollections && sidebarItems.length === 0 ? (
<div className="flex h-full flex-col items-center justify-center gap-2 p-5 text-center text-sm text-muted-foreground">
<MessageSquare className="h-5 w-5" />
Start your first conversation.
Start a chat or run your first search.
</div>
) : null}
{chats.map((chat) => {
const active = chat.id === selectedChatId;
{sidebarItems.map((item) => {
const active = selectedItem?.kind === item.kind && selectedItem.id === item.id;
return (
<button
key={chat.id}
key={`${item.kind}-${item.id}`}
className={cn(
"mb-1 w-full rounded-lg px-3 py-2 text-left transition",
active ? "bg-slate-700 text-slate-50" : "text-slate-200 hover:bg-slate-800"
)}
onClick={() => setSelectedChatId(chat.id)}
onClick={() => setSelectedItem({ kind: item.kind, id: item.id })}
type="button"
>
<p className="truncate text-sm font-medium">{getChatTitle(chat)}</p>
<p className={cn("mt-1 text-xs", active ? "text-slate-200" : "text-slate-400")}>{formatDate(chat.updatedAt)}</p>
<div className="flex items-center gap-2">
{item.kind === "chat" ? <MessageSquare className="h-3.5 w-3.5" /> : <Search className="h-3.5 w-3.5" />}
<p className="truncate text-sm font-medium">{item.title}</p>
</div>
<p className={cn("mt-1 text-xs", active ? "text-slate-200" : "text-slate-400")}>{formatDate(item.updatedAt)}</p>
</button>
);
})}
@@ -428,32 +639,42 @@ export default function App() {
<main className="flex min-w-0 flex-1 flex-col">
<header className="flex flex-wrap items-center justify-between gap-3 border-b px-4 py-3">
<div>
<h1 className="text-sm font-semibold md:text-base">{selectedChatTitle}</h1>
<h1 className="text-sm font-semibold md:text-base">{selectedTitle}</h1>
<p className="text-xs text-muted-foreground">
Sybil Web{authMode ? ` (${authMode === "open" ? "open mode" : "token mode"})` : ""}
{isSearchMode ? " • Exa Search" : ""}
</p>
</div>
<div className="flex w-full max-w-xl items-center gap-2 md:w-auto">
<select
className="h-9 rounded-md border border-input bg-background px-2 text-sm"
value={provider}
onChange={(event) => {
const nextProvider = event.currentTarget.value as Provider;
setProvider(nextProvider);
setModel(PROVIDER_DEFAULT_MODELS[nextProvider]);
}}
disabled={isSending}
>
<option value="openai">OpenAI</option>
<option value="anthropic">Anthropic</option>
<option value="xai">xAI</option>
</select>
<Input
value={model}
onInput={(event) => setModel(event.currentTarget.value)}
placeholder="Model"
disabled={isSending}
/>
{!isSearchMode ? (
<>
<select
className="h-9 rounded-md border border-input bg-background px-2 text-sm"
value={provider}
onChange={(event) => {
const nextProvider = event.currentTarget.value as Provider;
setProvider(nextProvider);
setModel(PROVIDER_DEFAULT_MODELS[nextProvider]);
}}
disabled={isSending}
>
<option value="openai">OpenAI</option>
<option value="anthropic">Anthropic</option>
<option value="xai">xAI</option>
</select>
<Input
value={model}
onInput={(event) => setModel(event.currentTarget.value)}
placeholder="Model"
disabled={isSending}
/>
</>
) : (
<div className="flex h-9 items-center rounded-md border border-input px-3 text-sm text-muted-foreground">
<Globe2 className="mr-2 h-4 w-4" />
Search mode
</div>
)}
<Button variant="outline" size="sm" onClick={handleLogout}>
<LogOut className="mr-1 h-4 w-4" />
Logout
@@ -462,31 +683,91 @@ export default function App() {
</header>
<div className="flex-1 overflow-y-auto px-3 py-6 md:px-10">
{isLoadingChat && messages.length === 0 ? <p className="text-sm text-muted-foreground">Loading messages...</p> : null}
{!isLoadingChat && messages.length === 0 ? (
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 rounded-xl border border-dashed p-8 text-center">
<h2 className="text-lg font-semibold">How can I help today?</h2>
<p className="text-sm text-muted-foreground">Ask a question to begin this conversation.</p>
</div>
) : null}
<div className="mx-auto max-w-3xl space-y-6">
{messages.map((message) => {
const isUser = message.role === "user";
const isPendingAssistant = message.id.startsWith("temp-assistant-") && isSending;
return (
<div key={message.id} className={cn("flex", isUser ? "justify-end" : "justify-start")}>
<div
className={cn(
"max-w-[85%] whitespace-pre-wrap rounded-2xl px-4 py-3 text-sm leading-6",
isUser ? "bg-slate-200 text-slate-900" : "bg-slate-800 text-slate-100"
)}
>
{isPendingAssistant ? "Thinking..." : message.content}
</div>
{!isSearchMode ? (
<>
{isLoadingSelection && messages.length === 0 ? <p className="text-sm text-muted-foreground">Loading messages...</p> : null}
{!isLoadingSelection && messages.length === 0 ? (
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 rounded-xl border border-dashed p-8 text-center">
<h2 className="text-lg font-semibold">How can I help today?</h2>
<p className="text-sm text-muted-foreground">Ask a question to begin this conversation.</p>
</div>
);
})}
</div>
) : null}
<div className="mx-auto max-w-3xl space-y-6">
{messages.map((message) => {
const isUser = message.role === "user";
const isPendingAssistant = message.id.startsWith("temp-assistant-") && isSending;
return (
<div key={message.id} className={cn("flex", isUser ? "justify-end" : "justify-start")}>
<div
className={cn(
"max-w-[85%] whitespace-pre-wrap rounded-2xl px-4 py-3 text-sm leading-6",
isUser ? "bg-slate-200 text-slate-900" : "bg-slate-800 text-slate-100"
)}
>
{isPendingAssistant ? "Thinking..." : message.content}
</div>
</div>
);
})}
</div>
</>
) : (
<div className="mx-auto w-full max-w-4xl">
{selectedSearch?.query ? (
<div className="mb-5">
<p className="text-sm text-muted-foreground">Results for</p>
<h2 className="mt-1 text-xl font-semibold">{selectedSearch.query}</h2>
<p className="mt-1 text-xs text-muted-foreground">
{selectedSearch.results.length} result{selectedSearch.results.length === 1 ? "" : "s"}
{selectedSearch.latencyMs ? `${selectedSearch.latencyMs} ms` : ""}
</p>
</div>
) : null}
{isLoadingSelection && !selectedSearch?.results.length ? (
<p className="text-sm text-muted-foreground">Loading search...</p>
) : null}
{!isLoadingSelection && !selectedSearch?.query ? (
<div className="flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed p-8 text-center">
<Search className="h-6 w-6 text-muted-foreground" />
<h2 className="text-lg font-semibold">Search the web</h2>
<p className="text-sm text-muted-foreground">Use the composer below to run a new Exa search.</p>
</div>
) : null}
{!isLoadingSelection && !!selectedSearch?.query && selectedSearch.results.length === 0 ? (
<p className="text-sm text-muted-foreground">No results found.</p>
) : null}
<div className="space-y-6">
{selectedSearch?.results.map((result) => {
const summary = summarizeResult(result);
return (
<article key={result.id} className="rounded-lg border border-border bg-[#0d1322] px-4 py-4 shadow-sm">
<p className="text-xs text-emerald-300/85">{formatHost(result.url)}</p>
<a
href={result.url}
target="_blank"
rel="noreferrer"
className="mt-1 block text-lg font-medium text-sky-300 hover:underline"
>
{result.title || result.url}
</a>
{(result.publishedDate || result.author) && (
<p className="mt-1 text-xs text-muted-foreground">
{[result.publishedDate, result.author].filter(Boolean).join(" • ")}
</p>
)}
{summary ? <p className="mt-2 whitespace-pre-wrap text-sm leading-6 text-slate-200">{summary}</p> : null}
</article>
);
})}
</div>
{selectedSearch?.error ? <p className="mt-4 text-sm text-red-600">{selectedSearch.error}</p> : null}
</div>
)}
<div ref={transcriptEndRef} />
</div>
@@ -502,14 +783,18 @@ export default function App() {
void handleSend();
}
}}
placeholder="Message Sybil"
placeholder={isSearchMode ? "Search the web" : "Message Sybil"}
className="resize-none border-0 shadow-none focus-visible:ring-0"
disabled={isSending}
/>
<div className="flex items-center justify-between px-2 pb-1">
{error ? <p className="text-xs text-red-600">{error}</p> : <span className="text-xs text-muted-foreground">Enter to send</span>}
{error ? (
<p className="text-xs text-red-600">{error}</p>
) : (
<span className="text-xs text-muted-foreground">{isSearchMode ? "Enter to search" : "Enter to send"}</span>
)}
<Button onClick={() => void handleSend()} size="icon" disabled={isSending || !composer.trim()}>
<SendHorizontal className="h-4 w-4" />
{isSearchMode ? <Search className="h-4 w-4" /> : <SendHorizontal className="h-4 w-4" />}
</Button>
</div>
</div>