The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
'use client';
import { useEffect, type RefObject } from 'react';
/** Closes something open (a menu, a popover) when the reader clicks outside `ref` or presses Escape. */
export function useDismiss(ref: RefObject<HTMLElement | null>, open: boolean, onClose: () => void) {
useEffect(() => {
if (!open) return;
const outside = (event: PointerEvent) => { if (!ref.current?.contains(event.target as Node)) onClose(); };
const escape = (event: KeyboardEvent) => { if (event.key === 'Escape') onClose(); };
document.addEventListener('pointerdown', outside);
document.addEventListener('keydown', escape);
return () => { document.removeEventListener('pointerdown', outside); document.removeEventListener('keydown', escape); };
}, [ref, open, onClose]);
}