diff --git a/app/components/Input.tsx b/app/components/Input.tsx index 51b0c981..d314fe8e 100644 --- a/app/components/Input.tsx +++ b/app/components/Input.tsx @@ -24,6 +24,7 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon, const [options, setOptions] = useState([]) const [selectedOption, setSelectedOption] = useState(0) const inputRef = useRef(null) + const containerRef = useRef(null) useEffect(() => { setSelectedOption(0) @@ -37,7 +38,7 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon, const timeout = setTimeout(async () => { if (!value || node?.id) { - if (!value) { + if (!value) { setOptions([]) } setOpen(false) @@ -59,7 +60,7 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon, const json = await result.json() const { completions } = json.result - + setOptions(completions || []) if (completions?.length > 0) { @@ -89,12 +90,18 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon, } case "ArrowUp": { e.preventDefault() - setSelectedOption(prev => prev <= 0 ? options.length - 1 : prev - 1) + setSelectedOption(prev => { + containerRef.current?.scrollTo({ behavior: 'smooth', top: (prev <= 0 ? options.length - 1 : prev - 1) * 64 }) + return prev <= 0 ? options.length - 1 : prev - 1 + }) return } case "ArrowDown": { e.preventDefault() - setSelectedOption(prev => (prev + 1) % options.length) + setSelectedOption(prev => { + containerRef.current?.scrollTo({ behavior: 'smooth', top: ((prev + 1) % options.length) * 64 }) + return (prev + 1) % options.length + }) return } case "Space": { @@ -125,10 +132,16 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon, onValueChange({ name: newVal }) }} {...props} + onBlur={(e) => { + if (!containerRef.current?.contains(e.relatedTarget as Node)) { + setOpen(false) + } + }} /> { open &&
[...messages, { text: q, type: MessageTypes.Query }, { type: MessageTypes.Pending }]); - + const result = await fetch(`/api/chat/${repo}?msg=${encodeURIComponent(q)}`, { method: 'POST' }) @@ -495,7 +495,7 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP { repo &&
-
diff --git a/repositories/GraphRAG-SDK b/repositories/GraphRAG-SDK deleted file mode 160000 index 52e3042b..00000000 --- a/repositories/GraphRAG-SDK +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 52e3042ba79d83489d4ceff6108973f0f2e43442