Skip to content

docs: workaround for bb pr diff | delta scroll break#19

Merged
b2l merged 1 commit into
mainfrom
docs/diff-pipe-workaround
Apr 22, 2026
Merged

docs: workaround for bb pr diff | delta scroll break#19
b2l merged 1 commit into
mainfrom
docs/diff-pipe-workaround

Conversation

@b2l
Copy link
Copy Markdown
Owner

@b2l b2l commented Apr 15, 2026

Summary

Documents a Bun-runtime quirk: bb pr diff <id> | delta (or any pipe to a less-using pager) breaks scrolling on subsequent invocations. Workaround: redirect both stdin and stderr away from the terminal.

Root cause (diagnosed via strace)

Bun's runtime calls TCSETS2 on both stdin and stderr at process exit, restoring whichever terminal state it captured at startup. When the captured c_lflag includes ICANON|ECHO, the terminal ends up in cooked mode for downstream less, which can't get raw keystrokes.

Strace evidence (relevant flag in c_lflag):

  • Working run: ISIG|IEXTEN|ECHOCTL|ECHOKE (raw)
  • Broken run: ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE (cooked)

Verified: </dev/null 2>/dev/null works; either alone doesn't. So both fds matter.

Out of scope

The fix belongs upstream in Bun. Will file a bug there with the strace as a minimal reproducer; this PR is just documentation so users aren't blocked.

Bun's runtime issues TCSETS2 on stdin and stderr at exit, restoring the
terminal to whatever state it captured at startup. When that state has
ICANON|ECHO set, downstream pagers (delta -> less) end up reading from
a cooked-mode terminal — keystrokes get echoed, require Enter to act.

Root cause is upstream in Bun. Documented the redirect-both workaround
until they fix it.
@b2l b2l merged commit 9a83e0f into main Apr 22, 2026
1 check passed
@b2l b2l deleted the docs/diff-pipe-workaround branch April 22, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant