MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / renderConfirmationStep

Method renderConfirmationStep

tui/modify.go:769–827  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

767}
768
769func (m modifyModel) renderConfirmationStep() string {
770 var s strings.Builder
771
772 s.WriteString("Review your configuration changes:\n")
773
774 // Build change summary using panel style like create.go
775 var panel strings.Builder
776
777 if m.config.GPUChanged {
778 currentGPU := m.formatGPUType(m.currentInstance.GPUType)
779 newGPU := m.formatGPUType(m.config.GPUType)
780 panel.WriteString(m.styles.Label.Render("GPU Type: ") + fmt.Sprintf("%s → %s", currentGPU, newGPU) + "\n")
781 }
782
783 if m.config.ComputeChanged {
784 currentNumGPUs, _ := strconv.Atoi(m.currentInstance.NumGPUs)
785 if m.config.NumGPUs != currentNumGPUs {
786 panel.WriteString(m.styles.Label.Render("GPUs: ") + fmt.Sprintf("%d → %d", currentNumGPUs, m.config.NumGPUs) + "\n")
787 }
788 currentRamPerVCPU := m.specs.RamPerVCPU(strings.ToLower(m.currentInstance.GPUType), currentNumGPUs)
789 newRamPerVCPU := m.specs.RamPerVCPU(m.config.GPUType, m.config.NumGPUs)
790 currentVCPUs, _ := strconv.Atoi(m.currentInstance.CPUCores)
791 currentRAM := currentVCPUs * currentRamPerVCPU
792 newRAM := m.config.VCPUs * newRamPerVCPU
793 panel.WriteString(m.styles.Label.Render("vCPUs: ") + fmt.Sprintf("%s → %d", m.currentInstance.CPUCores, m.config.VCPUs) + "\n")
794 panel.WriteString(m.styles.Label.Render("RAM: ") + fmt.Sprintf("%d GB → %d GB", currentRAM, newRAM) + "\n")
795 }
796
797 if m.config.DiskChanged {
798 panel.WriteString(m.styles.Label.Render("Disk Size: ") + fmt.Sprintf("%d GB → %d GB", m.currentInstance.Storage, m.config.DiskSizeGB) + "\n")
799 }
800
801 panelStr := panel.String()
802 if panelStr == "" {
803 s.WriteString(warningStyleTUI.Render("⚠ Warning: No changes detected"))
804 s.WriteString("\n\n")
805 } else {
806 // Trim trailing newline for consistent panel rendering
807 panelStr = strings.TrimSuffix(panelStr, "\n")
808 s.WriteString(m.styles.Panel.Render(panelStr))
809 }
810
811 s.WriteString(warningStyleTUI.Render("⚠ Warning: Modifying will restart the instance, running processes will be interrupted."))
812 s.WriteString("\n")
813
814 s.WriteString("Confirm modification?\n\n")
815
816 options := []string{"✓ Apply Changes", "✗ Cancel"}
817 for i, option := range options {
818 cursor := " "
819 if m.cursor == i {
820 cursor = m.styles.Cursor.Render("▶ ")
821 option = m.styles.Selected.Render(option)
822 }
823 s.WriteString(fmt.Sprintf("%s%s\n", cursor, option))
824 }
825
826 return s.String()

Callers 1

ViewMethod · 0.95

Calls 2

formatGPUTypeMethod · 0.95
RamPerVCPUMethod · 0.80

Tested by

no test coverage detected