()
| 628 | } |
| 629 | |
| 630 | func (m createModel) handleEnter() (tea.Model, tea.Cmd) { |
| 631 | switch m.step { |
| 632 | case stepGPU: |
| 633 | if !m.specsLoaded { |
| 634 | return m, nil |
| 635 | } |
| 636 | gpus := m.getGPUOptions() |
| 637 | if !m.specs.IsGPUTypeAvailable(gpus[m.cursor]) { |
| 638 | return m, nil |
| 639 | } |
| 640 | m.config.GPUType = gpus[m.cursor] |
| 641 | m.step = stepCompute |
| 642 | return m, m.trySkipCurrentStep() |
| 643 | |
| 644 | case stepCompute: |
| 645 | if m.gpuCountPhase { |
| 646 | gpuCounts := m.specs.GPUCounts(m.config.GPUType) |
| 647 | if !m.specs.IsSpecAvailable(m.config.GPUType, gpuCounts[m.cursor]) { |
| 648 | return m, nil |
| 649 | } |
| 650 | m.config.NumGPUs = gpuCounts[m.cursor] |
| 651 | m.setDefaultDiskSize() |
| 652 | m.gpuCountPhase = false |
| 653 | m.cursor = 0 |
| 654 | // Check if vCPUs preset can now be applied |
| 655 | if m.presets != nil && m.presets.VCPUs != nil { |
| 656 | if slices.Contains(m.specs.VCPUOptions(m.config.GPUType, m.config.NumGPUs), *m.presets.VCPUs) { |
| 657 | m.config.VCPUs = *m.presets.VCPUs |
| 658 | m.step = stepTemplate |
| 659 | return m, m.trySkipCurrentStep() |
| 660 | } |
| 661 | } |
| 662 | // Stay on stepCompute to show vCPU options next |
| 663 | } else { |
| 664 | vcpuOpts := m.specs.VCPUOptions(m.config.GPUType, m.config.NumGPUs) |
| 665 | if len(vcpuOpts) == 1 { |
| 666 | // Single option: auto-select. |
| 667 | m.config.VCPUs = vcpuOpts[0] |
| 668 | } else { |
| 669 | m.config.VCPUs = vcpuOpts[m.cursor] |
| 670 | } |
| 671 | m.step = stepTemplate |
| 672 | return m, m.trySkipCurrentStep() |
| 673 | } |
| 674 | |
| 675 | case stepTemplate: |
| 676 | if m.templateBrowse { |
| 677 | // Scrolling template list |
| 678 | if m.cursor < len(m.templates) { |
| 679 | m.config.Template = m.templates[m.cursor].Key |
| 680 | m.selectedSnapshot = nil |
| 681 | if m.presets == nil || m.presets.DiskSizeGB == nil { |
| 682 | m.config.DiskSizeGB = m.defaultDiskSizeGB() |
| 683 | } |
| 684 | m.step = stepDiskSize |
| 685 | return m, m.trySkipCurrentStep() |
| 686 | } |
| 687 | } else if m.snapshotBrowse { |
no test coverage detected