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

Method trySkipCurrentStep

tui/modify.go:113–160  ·  view source on GitHub ↗

trySkipCurrentStep loops forward through steps, auto-filling each one from presets if the preset value is valid given the current config state.

()

Source from the content-addressed store, hash-verified

111// trySkipCurrentStep loops forward through steps, auto-filling each one from
112// presets if the preset value is valid given the current config state.
113func (m *modifyModel) trySkipCurrentStep() {
114 for {
115 skipped := false
116 m.skippedSteps[m.step] = false
117
118 switch m.step {
119 case modifyStepGPU:
120 if m.presets != nil && m.presets.GPUType != nil {
121 canonical := strings.ToLower(*m.presets.GPUType)
122 if normalized, ok := m.specs.NormalizeGPUType(canonical); ok {
123 canonical = normalized
124 }
125 if m.specs.IsGPUTypeAvailable(canonical) {
126 m.config.GPUType = canonical
127 m.config.GPUChanged = !strings.EqualFold(canonical, m.currentInstance.GPUType)
128 m.skippedSteps[modifyStepGPU] = true
129 skipped = true
130 }
131 }
132
133 case modifyStepCompute:
134 skipped = m.trySkipModifyCompute()
135
136 case modifyStepDiskSize:
137 if m.presets != nil && m.presets.DiskSizeGB != nil {
138 v := *m.presets.DiskSizeGB
139 m.diskInput.SetValue(fmt.Sprintf("%d", v))
140 minDisk, maxDisk := m.specs.StorageRange(m.config.GPUType, m.config.NumGPUs)
141 if v >= max(m.currentInstance.Storage, minDisk) && v <= maxDisk {
142 m.config.DiskSizeGB = v
143 m.config.DiskChanged = v != m.currentInstance.Storage
144 m.skippedSteps[modifyStepDiskSize] = true
145 skipped = true
146 }
147 }
148
149 case modifyStepConfirmation:
150 return
151 }
152
153 if !skipped {
154 m.initModifyStep()
155 return
156 }
157
158 m.step++
159 }
160}
161
162// trySkipModifyCompute handles the compute step preset logic for modify.
163func (m *modifyModel) trySkipModifyCompute() bool {

Callers 2

handleEnterMethod · 0.95

Calls 5

trySkipModifyComputeMethod · 0.95
initModifyStepMethod · 0.95
NormalizeGPUTypeMethod · 0.80
IsGPUTypeAvailableMethod · 0.80
StorageRangeMethod · 0.80

Tested by

no test coverage detected