()
| 588 | } |
| 589 | |
| 590 | func (m *statusModel) renderRestoringSection() string { |
| 591 | // Filter instances with RESTORING status |
| 592 | var restoringInstances []api.Instance |
| 593 | for _, instance := range m.instances { |
| 594 | if instance.Status == "RESTORING" && !instance.ProgressStartedAt.IsZero() { |
| 595 | restoringInstances = append(restoringInstances, instance) |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | if len(restoringInstances) == 0 { |
| 600 | return "" |
| 601 | } |
| 602 | |
| 603 | var b strings.Builder |
| 604 | b.WriteString("\n") |
| 605 | b.WriteString(primaryStyle.Bold(true).Render("Restoring Instances:")) |
| 606 | b.WriteString("\n\n") |
| 607 | |
| 608 | for _, instance := range restoringInstances { |
| 609 | // Use instance ID for restoring progress bars (each instance gets its own) |
| 610 | progressBarKey := "restoring-" + instance.ID |
| 611 | m.ensureProgressBar(progressBarKey) |
| 612 | progressBar := m.progressBars[progressBarKey] |
| 613 | |
| 614 | // Calculate progress using the GetProgress method |
| 615 | restoringExpectedDuration := restorationExpectedDuration(instance) |
| 616 | progressPercent := utils.GetProgress(instance.ProgressStartedAt, restoringExpectedDuration) |
| 617 | |
| 618 | // Calculate time remaining |
| 619 | elapsed := time.Since(instance.ProgressStartedAt) |
| 620 | remaining := restoringExpectedDuration - elapsed |
| 621 | if remaining < 0 { |
| 622 | remaining = 0 |
| 623 | } |
| 624 | remainingMinutes := int(remaining.Minutes()) |
| 625 | if remainingMinutes < 1 { |
| 626 | remainingMinutes = 1 |
| 627 | } |
| 628 | |
| 629 | // Render instance name (grey, unbolded) |
| 630 | b.WriteString(fmt.Sprintf(" %s\n", SubtleTextStyle().Render(instance.Name))) |
| 631 | |
| 632 | // Render progress bar |
| 633 | b.WriteString(fmt.Sprintf(" %s\n", progressBar.ViewAs(progressPercent))) |
| 634 | |
| 635 | // Render message (compressed) |
| 636 | message := fmt.Sprintf(" ~%d min total, ~%d min remaining", |
| 637 | int(restoringExpectedDuration.Minutes()), |
| 638 | remainingMinutes, |
| 639 | ) |
| 640 | b.WriteString(m.styles.timestamp.Render(message)) |
| 641 | b.WriteString("\n\n") |
| 642 | } |
| 643 | |
| 644 | return b.String() |
| 645 | } |
| 646 | |
| 647 | func (m *statusModel) renderMigratingSection() string { |
no test coverage detected