import { useEffect } from "react"; import { useNavigate } from "react-router-dom"; /** * Hook for developer keyboard shortcuts * * @param {Object} options - Options for the hook * @param {string} options.sessionId - Current session ID (if available) * @returns {void} */ const useDevShortcuts = ({ sessionId = null } = {}) => { const navigate = useNavigate(); useEffect(() => { const handleKeyDown = (e) => { // Shortcut 'p' - clear authentication data and reload if (e.key === "p") { console.log("Debug key pressed: Clearing auth data and refreshing"); localStorage.removeItem("hf_oauth"); localStorage.removeItem("auth_return_to"); // Show a brief message alert("Auth data cleared. Page will reload."); // Reload the page window.location.reload(); } // Shortcut 'd' - go directly to benchmark display if (e.key === "d" && sessionId) { console.log("Debug key pressed: Showing BenchmarkDisplay"); navigate(`/benchmark-display?session=${sessionId}`); } }; window.addEventListener("keydown", handleKeyDown); return () => { window.removeEventListener("keydown", handleKeyDown); }; }, [sessionId, navigate]); }; export default useDevShortcuts;