What happened?
On Windows, hunk does not accept keyboard input when fed data via stdin, such as a patch like so:
Steps to reproduce
On Windows, in a repository with a working-tree diff:
npm install -g hunkdiff
git diff | hunk patch -
or from source:
git diff | bun run path\to\hunk\src\main.tsx -- patch -
Then try to interact with the TUI, e.g. arrow keys / scrolling / quit.
Expected behavior
Piped patch input should behave like normal interactive Hunk sessions on Windows (e.g. hunk diff). Instead, keys don't work.
Version
Current main / npm hunkdiff@0.15.1.
Solution explored
Hunk should be able to consume patch text from stdin while separately reading interactive input from the Windows console, ideally by opening:
fs.openSync("\\\\.\\CONIN$", "r+")
and wrapping that fd in new tty.ReadStream(fd). This is the Windows analog of opening /dev/tty as Hunk currently does, and it works on Node; see nodejs/node#63856
Unfortunately, this doesn't currently work in Bun: setRawMode fails. I wrote oven-sh/bun#32153 to fix it. If merged, I'll submit a PR to Hunk. Until then, even a correct Hunk-side CONIN$ implementation may still fail under Bun when enabling raw mode on the reopened non-stdin TTY.
What happened?
On Windows,
hunkdoes not accept keyboard input when fed data via stdin, such as a patch like so:Steps to reproduce
On Windows, in a repository with a working-tree diff:
or from source:
Then try to interact with the TUI, e.g. arrow keys / scrolling / quit.
Expected behavior
Piped patch input should behave like normal interactive Hunk sessions on Windows (e.g.
hunk diff). Instead, keys don't work.Version
Current main / npm
hunkdiff@0.15.1.Solution explored
Hunk should be able to consume patch text from stdin while separately reading interactive input from the Windows console, ideally by opening:
and wrapping that fd in
new tty.ReadStream(fd). This is the Windows analog of opening/dev/ttyas Hunk currently does, and it works on Node; see nodejs/node#63856Unfortunately, this doesn't currently work in Bun:
setRawModefails. I wrote oven-sh/bun#32153 to fix it. If merged, I'll submit a PR to Hunk. Until then, even a correct Hunk-sideCONIN$implementation may still fail under Bun when enabling raw mode on the reopened non-stdin TTY.