Skip to content

fix(tty): restore cursor visibility on process exit#26643

Open
robobun wants to merge 1 commit intomainfrom
claude/fix-cursor-visibility-on-exit
Open

fix(tty): restore cursor visibility on process exit#26643
robobun wants to merge 1 commit intomainfrom
claude/fix-cursor-visibility-on-exit

Conversation

@robobun
Copy link
Collaborator

@robobun robobun commented Jan 31, 2026

Summary

  • When stdout is a TTY, write the cursor-show escape sequence (\x1b[?25h) before restoring termios settings on process exit
  • This ensures the terminal cursor is always visible after Bun exits, fixing the issue where cursor remains hidden after running Ink applications on macOS

Test plan

  • Added regression test test/regression/issue/26642.test.ts (runs on macOS only due to PTY requirements)
  • Manual verification: run an Ink app that hides cursor, confirm cursor is visible after exit

🤖 Generated with Claude Code

When stdout is a TTY, write the cursor-show escape sequence (\x1b[?25h)
in bun_restore_stdio() before restoring termios settings.

Many CLI applications (like Ink) hide the cursor during operation and
rely on cleanup handlers to restore it. On macOS, if the process exits
before the cursor-show sequence is flushed, the cursor remains invisible
in the terminal. This fix ensures the cursor is always visible after Bun
exits, regardless of how the process terminates.

Fixes #26642

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@robobun
Copy link
Collaborator Author

robobun commented Jan 31, 2026

Updated 3:07 PM PT - Jan 31st, 2026

❌ Your commit 7b848af6 has 5 failures in Build #36307 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 26643

That installs a local version of the PR into your bun-26643 executable, so you can run:

bun-26643 --bun

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 31, 2026

Walkthrough

Adds terminal cursor visibility restoration to Bun's exit cleanup process for TTY outputs, ensuring the cursor is shown on exit. Includes a regression test verifying this behavior on non-Windows platforms.

Changes

Cohort / File(s) Summary
Terminal Cursor Visibility
src/bun.js/bindings/c-bindings.cpp
Implements cursor visibility restoration in the exit cleanup handler by writing the CSI escape sequence for showing cursor when stdout is a TTY, with retry logic for signal interruptions.
Regression Test
test/regression/issue/26642.test.ts
Adds test verifying cursor-show escape sequence is output when a process exits with stdout attached to a TTY, skipped on Windows and non-macOS platforms.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: restoring cursor visibility on TTY process exit, which is the primary objective of this changeset.
Description check ✅ Passed The description covers both required sections with clear details: it explains what the PR does (cursor visibility fix), how it works (escape sequence), and describes the test plan with manual verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant