fix(tui): kill program on signal

This commit is contained in:
Vincent Koc 2026-05-03 10:16:33 -07:00
parent 37017c6763
commit 7f6e55b1e5
No known key found for this signature in database

View File

@ -362,7 +362,19 @@ func Run(ctx context.Context, opts Options) error {
tea.WithAltScreen(),
tea.WithMouseAllMotion(),
)
done := make(chan struct{})
go func() {
select {
case <-runCtx.Done():
program.Kill()
case <-done:
}
}()
_, err := program.Run()
close(done)
if errors.Is(err, tea.ErrProgramKilled) && runCtx.Err() != nil {
return nil
}
return err
}