import { useState } from "react" import { useStorage } from "@plasmohq/storage/hook" function IndexPopup() { // useStorage returns [value, setValue, { remove }] const [apiKey, setApiKey, { remove }] = useStorage("core_api_key") const [inputValue, setInputValue] = useState(apiKey ?? "") const [isLoading, setIsLoading] = useState(false) const [message, setMessage] = useState("") // Keep inputValue in sync with apiKey if apiKey changes externally // (e.g. from another tab) // This is optional, but helps UX if (apiKey !== undefined && inputValue !== apiKey) { setInputValue(apiKey) } const saveApiKey = async () => { if (!inputValue.trim()) { setMessage("Please enter an API key") return } setIsLoading(true) try { await setApiKey(inputValue.trim()) setMessage("API key saved successfully!") setTimeout(() => setMessage(""), 3000) } catch (error) { setMessage("Failed to save API key") console.error("Save error:", error) } finally { setIsLoading(false) } } const clearApiKey = async () => { try { await remove() setInputValue("") setMessage("API key cleared") setTimeout(() => setMessage(""), 3000) } catch (error) { setMessage("Failed to clear API key") console.error("Clear error:", error) } } return (

Core Memory Extension

setInputValue(e.target.value)} placeholder="Enter your Core API key" style={{ width: "100%", padding: "8px 12px", border: "1px solid #ddd", borderRadius: 4, fontSize: 14, marginBottom: 8 }} />
{apiKey && ( )}
{message && (
{message}
)} {apiKey && (
✓ API key configured
)}

How to use:

  • Select text on any page to save to Core
  • Look for red dots in input fields for AI suggestions
) } export default IndexPopup