Refocus CLI textbox after command completion. Closes #164.

This commit is contained in:
Jack Kingsman
2026-04-05 11:55:52 -07:00
parent 40c37745b6
commit 3f2b8e2a1f

View File

@@ -13,6 +13,8 @@ export function ConsolePane({
}) {
const [input, setInput] = useState('');
const outputRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const prevLoadingRef = useRef(loading);
// Auto-scroll to bottom on new entries
useEffect(() => {
@@ -21,6 +23,14 @@ export function ConsolePane({
}
}, [history]);
// Refocus input after command completes
useEffect(() => {
if (prevLoadingRef.current && !loading) {
inputRef.current?.focus();
}
prevLoadingRef.current = loading;
}, [loading]);
const handleSubmit = useCallback(
async (e: FormEvent) => {
e.preventDefault();
@@ -59,6 +69,7 @@ export function ConsolePane({
</div>
<form onSubmit={handleSubmit} className="flex gap-2 p-2 border-t border-border">
<Input
ref={inputRef}
type="text"
autoComplete="off"
name="console-input"