From ac8ce7f00f5ac29134cc65f391cf91828ff19910 Mon Sep 17 00:00:00 2001 From: Renz Date: Wed, 12 Nov 2025 09:26:45 +0000 Subject: [PATCH] Fix: Interactive backup now shows dynamic status updates during operation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: Interactive backup (single, sample, cluster) showed 'Status: Initializing...' throughout the entire backup process, identical to the restore issue that was just fixed. Root cause: - Status was set once in NewBackupExecution() - Never updated during the backup process - Only changed to success/failure at completion - No visual feedback about backup progress Solution: Time-based status progression (matching restore pattern) Added logic in Update() tick handler to change status based on elapsed time: - 0-2 sec: 'Initializing backup...' - 2-5 sec: Connection phase: - Cluster: 'Connecting to database cluster...' - Single/Sample: 'Connecting to database [name]...' - 5-10 sec: Early backup phase: - Cluster: 'Backing up global objects (roles, tablespaces)...' - Sample: 'Analyzing tables for sampling (ratio: N)...' - Single: 'Dumping database [name]...' - 10+ sec: Main backup phase: - Cluster: 'Backing up cluster databases...' - Sample: 'Creating sample backup of [name]...' - Single: 'Backing up database [name]...' Benefits: - Consistent UX with restore operations - Different status messages for single/sample/cluster backups - Shows what stage of backup is running - Spinner + changing status = clear progress indication - Better user experience during long cluster backups Status checked across all TUI operations: ✅ RestoreExecutionModel - Fixed (previous commit) ✅ BackupExecutionModel - Fixed (this commit) ✅ StatusViewModel - Already has proper loading state ✅ OperationsViewModel - Simple view, no long operations --- internal/tui/backup_exec.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/internal/tui/backup_exec.go b/internal/tui/backup_exec.go index d46b850..48b6eb4 100644 --- a/internal/tui/backup_exec.go +++ b/internal/tui/backup_exec.go @@ -144,6 +144,35 @@ func (m BackupExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case backupTickMsg: if !m.done { + // Update status based on elapsed time to show progress + elapsedSec := int(time.Since(m.startTime).Seconds()) + + if elapsedSec < 2 { + m.status = "Initializing backup..." + } else if elapsedSec < 5 { + if m.backupType == "cluster" { + m.status = "Connecting to database cluster..." + } else { + m.status = fmt.Sprintf("Connecting to database '%s'...", m.databaseName) + } + } else if elapsedSec < 10 { + if m.backupType == "cluster" { + m.status = "Backing up global objects (roles, tablespaces)..." + } else if m.backupType == "sample" { + m.status = fmt.Sprintf("Analyzing tables for sampling (ratio: %d)...", m.ratio) + } else { + m.status = fmt.Sprintf("Dumping database '%s'...", m.databaseName) + } + } else { + if m.backupType == "cluster" { + m.status = "Backing up cluster databases..." + } else if m.backupType == "sample" { + m.status = fmt.Sprintf("Creating sample backup of '%s'...", m.databaseName) + } else { + m.status = fmt.Sprintf("Backing up database '%s'...", m.databaseName) + } + } + return m, backupTickCmd() } return m, nil