initStep sets up step-specific state (cursor, focus, sub-phases) when arriving at a visible step.
()
| 337 | |
| 338 | // initStep sets up step-specific state (cursor, focus, sub-phases) when arriving at a visible step. |
| 339 | func (m *createModel) initStep() { |
| 340 | m.cursor = 0 |
| 341 | switch m.step { |
| 342 | case stepGPU: |
| 343 | gpus := m.getGPUOptions() |
| 344 | for i, gpu := range gpus { |
| 345 | if m.specs.IsGPUTypeAvailable(gpu) { |
| 346 | m.cursor = i |
| 347 | break |
| 348 | } |
| 349 | } |
| 350 | case stepCompute: |
| 351 | if m.specs.NeedsGPUCountPhase(m.config.GPUType) && m.config.NumGPUs == 0 { |
| 352 | m.gpuCountPhase = true |
| 353 | for i, count := range m.specs.GPUCounts(m.config.GPUType) { |
| 354 | if m.specs.IsSpecAvailable(m.config.GPUType, count) { |
| 355 | m.cursor = i |
| 356 | break |
| 357 | } |
| 358 | } |
| 359 | } else if !m.specs.NeedsGPUCountPhase(m.config.GPUType) { |
| 360 | m.config.NumGPUs = 1 |
| 361 | m.setDefaultDiskSize() |
| 362 | m.gpuCountPhase = false |
| 363 | } |
| 364 | case stepDiskSize: |
| 365 | m.diskInput.SetValue(fmt.Sprintf("%d", m.config.DiskSizeGB)) |
| 366 | m.diskInput.Focus() |
| 367 | m.diskInputTouched = false |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | // prevVisibleStep returns the previous non-skipped step. Returns -1 if none. |
| 372 | func (m *createModel) prevVisibleStep(from createStep) createStep { |