From 8917a4d1a589b1cf181cb98fe9adcca216fdb096 Mon Sep 17 00:00:00 2001 From: JK-le-dev Date: Sun, 19 Oct 2025 07:52:13 -0500 Subject: [PATCH] feat(filelist): added file list ui Drop down menu that shows it all --- .../src/components/ui/button/down-button.jsx | 2 +- .../components/ui/button/schematic-button.jsx | 78 +++++------------ .../src/components/ui/chat/chat-header.jsx | 44 +++++----- .../src/components/ui/chat/message-input.jsx | 7 +- web-app/src/components/ui/file/file-list.jsx | 83 +++++++++++++++++++ 5 files changed, 127 insertions(+), 87 deletions(-) create mode 100644 web-app/src/components/ui/file/file-list.jsx diff --git a/web-app/src/components/ui/button/down-button.jsx b/web-app/src/components/ui/button/down-button.jsx index b51dc3f..2995d20 100644 --- a/web-app/src/components/ui/button/down-button.jsx +++ b/web-app/src/components/ui/button/down-button.jsx @@ -6,7 +6,7 @@ export default function DownButton({ onClick }) { return ( diff --git a/web-app/src/components/ui/button/schematic-button.jsx b/web-app/src/components/ui/button/schematic-button.jsx index c7e3c00..5067565 100644 --- a/web-app/src/components/ui/button/schematic-button.jsx +++ b/web-app/src/components/ui/button/schematic-button.jsx @@ -1,71 +1,33 @@ -import React, { useState, useRef } from "react"; -import { X } from "lucide-react"; +import React, { forwardRef, useRef } from "react"; import { motion } from "motion/react"; -import { FilePlus2 } from "lucide-react"; -export default function SchematicButton({ onFiles }) { - const [filesList, setFilesList] = useState([]); +// Hidden file input that exposes an open() method via ref +const SchematicButton = forwardRef(function SchematicButton({ onFiles }, ref) { const inputRef = useRef(null); + React.useImperativeHandle(ref, () => ({ + open: () => inputRef.current && inputRef.current.click(), + })); + function handleFiles(e) { const files = Array.from(e.target.files || []); if (files.length === 0) return; - - setFilesList((s) => [...s, ...files]); if (onFiles) onFiles(files); if (inputRef.current) inputRef.current.value = null; } - function removeFile(index) { - setFilesList((s) => { - const copy = [...s]; - copy.splice(index, 1); - return copy; - }); - } - return ( -
- - - {filesList.length > 0 && ( -
- {filesList.map((f, i) => ( -
- {f.name} - -
- ))} -
- )} -
+ ); -} +}); + +export default SchematicButton; diff --git a/web-app/src/components/ui/chat/chat-header.jsx b/web-app/src/components/ui/chat/chat-header.jsx index fbda3f2..b342761 100644 --- a/web-app/src/components/ui/chat/chat-header.jsx +++ b/web-app/src/components/ui/chat/chat-header.jsx @@ -2,9 +2,9 @@ import React, { useMemo, useState } from "react"; import { motion } from "motion/react"; import { Rocket } from "lucide-react"; import DeleteButton from "src/components/ui/button/delete-button"; -import SchematicButton from "../button/schematic-button"; +import FileList from "src/components/ui/file/file-list"; -export default function ChatHeader({ title = "Title of Chat" }) { +export default function ChatHeader({ title = "Schematic Spelunker" }) { const isDebug = useMemo(() => { const p = new URLSearchParams(window.location.search); return p.get("debug") === "1"; @@ -17,7 +17,9 @@ export default function ChatHeader({ title = "Title of Chat" }) { setIngesting(true); const res = await fetch("/api/files/import-demo", { method: "POST" }); const json = await res.json().catch(() => ({})); - setToast(`Imported: ${json.imported ?? "?"}, Skipped: ${json.skipped ?? "?"}`); + setToast( + `Imported: ${json.imported ?? "?"}, Skipped: ${json.skipped ?? "?"}` + ); setTimeout(() => setToast(""), 4000); } catch (e) { setToast("Import failed"); @@ -31,25 +33,23 @@ export default function ChatHeader({ title = "Title of Chat" }) {
- -
-

- {title} -

- - {isDebug && ( - - - {ingesting ? "Seeding…" : "Seed Demo Data"} - - )} -
+ +

+ {title} +

+ + {isDebug && ( + + + {ingesting ? "Seeding…" : "Seed Demo Data"} + + )}
{toast && (
diff --git a/web-app/src/components/ui/chat/message-input.jsx b/web-app/src/components/ui/chat/message-input.jsx index 8e48f34..d8af1b9 100644 --- a/web-app/src/components/ui/chat/message-input.jsx +++ b/web-app/src/components/ui/chat/message-input.jsx @@ -1,5 +1,4 @@ import React, { useState, useRef, useEffect } from "react"; -import DeleteButton from "src/components/ui/button/delete-button"; import DownButton from "src/components/ui/button/down-button"; import { motion } from "motion/react"; import { BotMessageSquare } from "lucide-react"; @@ -24,11 +23,7 @@ export default function MessageInput({ onSend }) {