charmbracelet / charmbracelet/bubbletea
Terminal settings not restored after panics/crashes
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When the application exits abnormally (crashes or panics) the terminal is left in a broken state. Basic shell interactivity is lost: typed commands are not echoed (reflected as I type), line alignment is completely chaotic, and the general usability of the terminal is severely degraded. This persists until I explicitly run `stty sane` or a similar to restore the expected settings. Abrupt interruptions have to be handled by the user.
For the sake of documentation these are all the options that are off after exectution:
`stty brkint ignpar icrnl ixon opost isig icanon iexten echo`
I am using Bash via terminator emulator on manjaro. Also applies to xfce terminal.
**To Reproduce**
set up a crash or a panic during the tea program execution. out-of-range Index work well.
**Source Code**
I noticed that the panics are handled with tea.program.recoverFromPanic() [link](https://github.com/charmbracelet/bubbletea/blob/c30088fd4e8f3983ecf556983893716ac452035f/tea.go#L803). I count not find a execution route from there into restoreTerminal(); perhaps the solution would be to add it to panic handling. https://github.com/charmbracelet/bubbletea/blob/c30088fd4e8f3983ecf556983893716ac452035f/tea.go#L848
**Additional Context**
I know... I know... it would be more logical to not have my program crash or panic. I'm trying, ok?
Contributor guide
Research direction
Start in tea.go at program.recoverFromPanic() and restoreTerminal(), then reproduce the issue with an out-of-range index panic during tea program execution. Trace the panic-handling path and verify that the terminal settings are restored so shell input is echoed and aligned afterward, without requiring stty sane.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100