"use client"; import { useRef, useState, type KeyboardEvent } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { useSubspace } from "@/contexts/subspace-context"; import { useI18n } from "@/i18n/i18n-context"; export function SubspaceGate() { const { setSubspace, history, clearHistory } = useSubspace(); const { t } = useI18n(); const [inputValue, setInputValue] = useState(""); const inputRef = useRef(null); const handleClearHistory = () => { inputRef.current?.focus(); clearHistory(); }; const handleSubmit = () => { const trimmed = inputValue.trim(); if (!trimmed) return; setSubspace(trimmed); setInputValue(""); }; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); handleSubmit(); } }; return (

{t("knowledgeBase.subspace.gateTitle")}

{t("knowledgeBase.subspace.gateDescription")}

{history.length > 0 && (
{t("knowledgeBase.subspace.recentlyUsed")}
{history.map((s, idx) => ( ))}
)}
setInputValue(e.target.value)} onKeyDown={handleKeyDown} className="text-base" />

{t("knowledgeBase.subspace.gateHint")}

); }