Skip to content

fix(tui): graceful exit on Ctrl+C and resolve multiline paste corruption#14440

Closed
n24q02m wants to merge 2 commits intoanomalyco:devfrom
n24q02m:fix/tui-bugs
Closed

fix(tui): graceful exit on Ctrl+C and resolve multiline paste corruption#14440
n24q02m wants to merge 2 commits intoanomalyco:devfrom
n24q02m:fix/tui-bugs

Conversation

@n24q02m
Copy link

@n24q02m n24q02m commented Feb 20, 2026

Issue for this PR

Closes #11826
Closes #10975
Closes #12767

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  1. Graceful Exit: Resolves the zombie process issue when closing the TUI. By adding a SIGHUP handler in src/index.ts and a fallback process.exit(0) after standard renderer and event loop cleanup, the application will forcefully exit if background processes (like file watchers or MCP servers) are blocking a clean exit.
  2. Double Ctrl+C: Instead of exiting immediately upon hitting Ctrl+C on an empty prompt (which was frustrating), users now receive a warning toast first. Pressing it again within 2 seconds confirms the exit.
  3. Multiline Paste: Fixes UI corruption and data loss that occurred when pasting large text. Previously, the system generated an extmark [Pasted ~X lines] but didn't actually insert the text into the internal buffer. Now, the raw text is directly inserted via input.insertText().

How did you verify your code works?

Pasted >150 lines of text successfully without UI corruption. Pressed Ctrl+C twice and confirmed the terminal exits immediately. Ran kill -HUP on the process and verified that all child LSP processes were also cleaned up instead of being orphaned.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 20, 2026
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

#13848 - fix(tui): add signal handlers to prevent orphaned processes on terminal close

This PR appears to address a similar issue with graceful process cleanup and preventing orphaned/zombie processes on terminal close. It may overlap with the Ctrl+C graceful exit handling in PR #14440.

All other search results either returned PR #14440 itself or addressed different concerns (MCP server processes, ANSI color codes, memory leaks, etc.).

@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Feb 20, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@n24q02m
Copy link
Author

n24q02m commented Mar 6, 2026

Closing this PR -- it has merge conflicts, 2 CI failures (e2e windows + test linux), and a similar PR #13848 was already closed without merge. The effort to fix and rebase is not justified given these signals. The underlying issues (#11826, #10975, #12767) remain open for others to tackle with a fresh approach.

@n24q02m n24q02m closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant