Skip to content

Commit 27bd01e

Browse files
committed
feat: search and image input
1 parent e95b92b commit 27bd01e

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/app/(app)/ask/layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { SidebarToggle } from "@/app/_components/sidebar-toggle";
22
import {
33
SidebarInset,
4-
SidebarTrigger,
5-
useSidebar,
64
} from "@/components/ui/sidebar";
75
import { SelectTheme } from "@/components/ui/theme-toggler";
86
import { UIStructure } from "@/components/ui/ui-structure";

src/components/ui/ui-input.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import SpeechRecognition, {
3131
import { useSpeechSynthesis } from "react-speech-kit";
3232
import { toast } from "sonner";
3333
import { useTheme } from "next-themes";
34-
import { WrapText } from "lucide-react";
34+
import { Earth, EarthIcon, Globe, Paperclip, WrapText } from "lucide-react";
3535
import { atomOneDark } from "react-syntax-highlighter/dist/esm/styles/hljs";
3636

3737
const geistMono = Geist_Mono({
@@ -54,6 +54,8 @@ const UIInput = () => {
5454
"text",
5555
);
5656
const [query, setQuery] = useState<string>("");
57+
const [attachments, setAttachments] = useState<File[]>([]);
58+
const [search, setSearch] = useState<boolean>(false);
5759
const [messages, setMessages] = useState<Message[]>([]);
5860
const [showWelcome, setShowWelcome] = useState(true);
5961
const [copied, setCopied] = useState(false);
@@ -376,6 +378,19 @@ const UIInput = () => {
376378
}
377379
};
378380

381+
const handleFileInput = () => {
382+
const fileInput = document.createElement("input");
383+
fileInput.type = "file";
384+
fileInput.accept = "image/*";
385+
fileInput.onchange = (e) => {
386+
const file = (e.target as HTMLInputElement).files?.[0];
387+
if (file) {
388+
setAttachments((prev) => [...prev, file]);
389+
}
390+
};
391+
fileInput.click();
392+
};
393+
379394
return (
380395
<div className="flex h-[96vh] w-full overflow-hidden">
381396
<div className="relative flex h-full w-full flex-col">
@@ -682,6 +697,16 @@ const UIInput = () => {
682697
onValueChange={setModel}
683698
disabled={isLoading}
684699
/>
700+
{/* Search */}
701+
<Button variant="ghost" size="sm" className={`text-xs ${search ? "bg-primary/60 hover:bg-primary/70" : ""}`} onClick={() => setSearch(!search)}>
702+
<Globe className="size-4" />
703+
Search
704+
</Button>
705+
706+
{/* Attachments */}
707+
<Button variant="ghost" size="sm" className="text-xs" onClick={handleFileInput}>
708+
<Paperclip className="size-4" />
709+
</Button>
685710
</div>
686711
<Button
687712
type="submit"

src/components/ui/ui-structure.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ export function UIStructure() {
6868
}
6969
}, [chatsData]);
7070

71-
console.log(chats);
72-
7371
const handleSaveChat = (chatId: string) => {
7472
try {
7573
saveChat.mutate({ chatId: chatId });

0 commit comments

Comments
 (0)