fix(tui): handle tea.InterruptMsg for proper Ctrl+C cancellation
Some checks failed
CI/CD / Lint (push) Successful in 1m30s
CI/CD / Build & Release (push) Has been skipped
CI/CD / Test (push) Failing after 1m16s

Bubbletea v1.3+ sends InterruptMsg for SIGINT signals instead of
KeyMsg with 'ctrl+c', causing cancellation to not work properly.

- Add tea.InterruptMsg handling to restore_exec.go
- Add tea.InterruptMsg handling to backup_exec.go
- Add tea.InterruptMsg handling to menu.go
- Call cleanup.KillOrphanedProcesses on all interrupt paths
- No zombie pg_dump/pg_restore/gzip processes left behind

Fixes Ctrl+C not working during cluster restore/backup operations.

v3.42.50
This commit is contained in:
2026-01-16 15:53:39 +01:00
parent bfe99e959c
commit 5728b465e6
6 changed files with 63 additions and 4 deletions

View File

@@ -5,6 +5,21 @@ All notable changes to dbbackup will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.42.50] - 2026-01-16 "Ctrl+C Signal Handling Fix"
### Fixed - Proper Ctrl+C/SIGINT Handling in TUI
- **Added tea.InterruptMsg handling** - Bubbletea v1.3+ sends `InterruptMsg` for SIGINT signals
instead of a `KeyMsg` with "ctrl+c", causing cancellation to not work
- **Fixed cluster restore cancellation** - Ctrl+C now properly cancels running restore operations
- **Fixed cluster backup cancellation** - Ctrl+C now properly cancels running backup operations
- **Added interrupt handling to main menu** - Proper cleanup on SIGINT from menu
- **Orphaned process cleanup** - `cleanup.KillOrphanedProcesses()` called on all interrupt paths
### Changed
- All TUI execution views now handle both `tea.KeyMsg` ("ctrl+c") and `tea.InterruptMsg`
- Context cancellation properly propagates to child processes via `exec.CommandContext`
- No zombie pg_dump/pg_restore/gzip processes left behind on cancellation
## [3.42.49] - 2026-01-16 "Unified Cluster Backup Progress" ## [3.42.49] - 2026-01-16 "Unified Cluster Backup Progress"
### Added - Unified Progress Display for Cluster Backup ### Added - Unified Progress Display for Cluster Backup

View File

@@ -3,9 +3,9 @@
This directory contains pre-compiled binaries for the DB Backup Tool across multiple platforms and architectures. This directory contains pre-compiled binaries for the DB Backup Tool across multiple platforms and architectures.
## Build Information ## Build Information
- **Version**: 3.42.48 - **Version**: 3.42.49
- **Build Time**: 2026-01-16_14:32:45_UTC - **Build Time**: 2026-01-16_14:37:18_UTC
- **Git Commit**: 780beaa - **Git Commit**: bfe99e9
## Recent Updates (v1.1.0) ## Recent Updates (v1.1.0)
- ✅ Fixed TUI progress display with line-by-line output - ✅ Fixed TUI progress display with line-by-line output

View File

@@ -295,6 +295,20 @@ func (m BackupExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
return m, nil return m, nil
case tea.InterruptMsg:
// Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this instead of KeyMsg for ctrl+c
if !m.done && !m.cancelling {
m.cancelling = true
m.status = "[STOP] Cancelling backup... (please wait)"
if m.cancel != nil {
m.cancel()
}
return m, nil
} else if m.done {
return m.parent, tea.Quit
}
return m, nil
case tea.KeyMsg: case tea.KeyMsg:
switch msg.String() { switch msg.String() {
case "ctrl+c", "esc": case "ctrl+c", "esc":

View File

@@ -188,6 +188,21 @@ func (m *MenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
return m, nil return m, nil
case tea.InterruptMsg:
// Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this
if m.cancel != nil {
m.cancel()
}
// Clean up any orphaned processes before exit
m.logger.Info("Cleaning up processes before exit (SIGINT)")
if err := cleanup.KillOrphanedProcesses(m.logger); err != nil {
m.logger.Warn("Failed to clean up all processes", "error", err)
}
m.quitting = true
return m, tea.Quit
case tea.KeyMsg: case tea.KeyMsg:
switch msg.String() { switch msg.String() {
case "ctrl+c", "q": case "ctrl+c", "q":

View File

@@ -536,6 +536,21 @@ func (m RestoreExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
return m, nil return m, nil
case tea.InterruptMsg:
// Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this instead of KeyMsg for ctrl+c
if !m.done && !m.cancelling {
m.cancelling = true
m.status = "[STOP] Cancelling restore... (please wait)"
m.phase = "Cancelling"
if m.cancel != nil {
m.cancel()
}
return m, nil
} else if m.done {
return m.parent, tea.Quit
}
return m, nil
case tea.KeyMsg: case tea.KeyMsg:
switch msg.String() { switch msg.String() {
case "ctrl+c", "esc": case "ctrl+c", "esc":

View File

@@ -16,7 +16,7 @@ import (
// Build information (set by ldflags) // Build information (set by ldflags)
var ( var (
version = "3.42.49" version = "3.42.50"
buildTime = "unknown" buildTime = "unknown"
gitCommit = "unknown" gitCommit = "unknown"
) )