fix: focus terminal on mount so keyboard input works immediately
Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Has been cancelled

The watch on isActive never fired on initial mount because the value
starts as true (Vue watch only triggers on changes). Added explicit
focus + fit in onMounted with a short delay for DOM readiness.
Also added @click handler on container as fallback focus mechanism.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-24 17:47:16 -04:00
parent 76c5ddbfb5
commit 2dfe4f9d7a

View File

@ -49,6 +49,7 @@
<div <div
ref="containerRef" ref="containerRef"
class="terminal-container flex-1" class="terminal-container flex-1"
@click="handleFocus"
@focus="handleFocus" @focus="handleFocus"
/> />
</div> </div>
@ -136,9 +137,15 @@ onMounted(() => {
terminal.onResize(({ cols, rows }) => { terminal.onResize(({ cols, rows }) => {
sessionStore.setTerminalDimensions(props.sessionId, cols, rows); sessionStore.setTerminalDimensions(props.sessionId, cols, rows);
}); });
// Focus the terminal after mount so keyboard input works immediately
setTimeout(() => {
fit();
terminal.focus();
}, 50);
}); });
// Re-fit and focus terminal when this tab becomes active // Re-fit and focus terminal when switching back to this tab
watch( watch(
() => props.isActive, () => props.isActive,
(active) => { (active) => {