Fix: Interactive backup now shows dynamic status updates during operation

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
This commit is contained in:
2025-11-12 09:26:45 +00:00
parent 23a87625dc
commit ac8ce7f00f

View File

@@ -144,6 +144,35 @@ func (m BackupExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) { switch msg := msg.(type) {
case backupTickMsg: case backupTickMsg:
if !m.done { 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, backupTickCmd()
} }
return m, nil return m, nil