#1132·hunk

File filter loses keyboard focus in `hunk pager` after going from no matches back to results

Author: lucamarra-beeCreated Sep 29, 2026Updated Sep 29, 2026

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:

  1. Filtering down to zero files unmounts the scrollbox (the empty state renders instead).
  2. When Backspace brings files back, the scrollbox mounts again with focused: true, and OpenTUI's focusRenderable() blurs the previously focused renderable: the filter <input>.
  3. focusArea is still "filter", so handleFocusedInputShortcut keeps returning "focused" for every key except Tab. Global shortcuts (q) are skipped, and the input doesn't get the keys either, so Esc and 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

  1. git config core.pager "hunk pager", then run git diff in a repo with more than one changed file.
  2. Press / to focus the file filter.
  3. Type characters until no files match.
  4. Press Backspace until files match again.
  5. Type more characters, or press Esc or q: 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