File filter loses keyboard focus in `hunk pager` after going from no matches back to results
What happened?
When Hunk runs as the Git pager (core.pager = hunk pager), filtering down to zero files and then pressing Backspace until files reappear leaves the filter without keyboard input: typed characters no longer reach it and the text stays as it was. Focus seems to return to the main view, but no key works except Tab. q doesn't quit and Esc doesn't clear or close the filter. Clicking the filter with the mouse, or pressing Tab, gets out of this state.
The same steps work correctly with hunk diff, so this is specific to hunk pager.
Likely cause
Reading the 0.22.0 bundle, in DiffPane.tsx the diff <scrollbox> is only rendered while files.length > 0, and it gets focused: pagerMode:
- Filtering down to zero files unmounts the scrollbox (the empty state renders instead).
- When Backspace brings files back, the scrollbox mounts again with
focused: true, and OpenTUI'sfocusRenderable()blurs the previously focused renderable: the filter<input>. focusAreais still"filter", sohandleFocusedInputShortcutkeeps returning"focused"for every key exceptTab. Global shortcuts (q) are skipped, and the input doesn't get the keys either, soEscand typing do nothing.
Outside pager mode focused is false, so the remount doesn't steal focus, which matches hunk diff working.
A possible fix is to not claim focus while another area owns it, e.g. focused: pagerMode && focusArea === "files", or to keep the scrollbox mounted when the filter has no matches.
Steps to reproduce
git config core.pager "hunk pager", then rungit diffin a repo with more than one changed file.- Press
/to focus the file filter. - Type characters until no files match.
- Press Backspace until files match again.
- Type more characters, or press
Escorq: nothing happens.
Expected behavior
The filter keeps keyboard focus while you edit it, so typing, Esc (clear, then close) and, after leaving the filter, q work as usual.
Version
hunk 0.22.0 (Homebrew), macOS 26, Ghostty 1.3.1
Source: modem-dev/hunk