Remove CPU workload selector from main menu - keep only in Configuration Settings

- Removed workloadOption struct and workload-related fields from MenuModel
- Removed workload initialization and cursor tracking
- Removed keyboard handlers (Shift+←/→, 'w') for workload switching
- Removed workload selector display from main menu view
- Removed applyWorkloadSelection() function
- CPU workload type now only configurable via Configuration Settings
- Cleaner main menu focused on actions rather than configuration
This commit is contained in:
2025-11-12 14:45:58 +00:00
parent 879e7575ff
commit 093470ee66

View File

@@ -48,12 +48,6 @@ type dbTypeOption struct {
value string
}
type workloadOption struct {
label string
value string
desc string
}
// MenuModel represents the simple menu state
type MenuModel struct {
choices []string
@@ -64,8 +58,6 @@ type MenuModel struct {
message string
dbTypes []dbTypeOption
dbTypeCursor int
workloads []workloadOption
workloadCursor int
// Background operations
ctx context.Context
@@ -81,12 +73,6 @@ func NewMenuModel(cfg *config.Config, log logger.Logger) MenuModel {
{label: "MariaDB", value: "mariadb"},
}
workloads := []workloadOption{
{label: "Balanced", value: "balanced", desc: "General purpose"},
{label: "CPU-Intensive", value: "cpu-intensive", desc: "More parallelism"},
{label: "I/O-Intensive", value: "io-intensive", desc: "Less parallelism"},
}
dbCursor := 0
if cfg.DatabaseType == "mysql" {
dbCursor = 1
@@ -94,13 +80,6 @@ func NewMenuModel(cfg *config.Config, log logger.Logger) MenuModel {
dbCursor = 2
}
workloadCursor := 0
if cfg.CPUWorkloadType == "cpu-intensive" {
workloadCursor = 1
} else if cfg.CPUWorkloadType == "io-intensive" {
workloadCursor = 2
}
model := MenuModel{
choices: []string{
"Single Database Backup",
@@ -124,8 +103,6 @@ func NewMenuModel(cfg *config.Config, log logger.Logger) MenuModel {
cancel: cancel,
dbTypes: dbTypes,
dbTypeCursor: dbCursor,
workloads: workloads,
workloadCursor: workloadCursor,
}
return model
@@ -166,24 +143,6 @@ func (m MenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.applyDatabaseSelection()
}
case "shift+left", "H":
if m.workloadCursor > 0 {
m.workloadCursor--
m.applyWorkloadSelection()
}
case "shift+right", "L":
if m.workloadCursor < len(m.workloads)-1 {
m.workloadCursor++
m.applyWorkloadSelection()
}
case "w":
if len(m.workloads) > 0 {
m.workloadCursor = (m.workloadCursor + 1) % len(m.workloads)
m.applyWorkloadSelection()
}
case "up", "k":
if m.cursor > 0 {
m.cursor--
@@ -262,21 +221,6 @@ func (m MenuModel) View() string {
s += hint + "\n"
}
if len(m.workloads) > 0 {
options := make([]string, len(m.workloads))
for i, opt := range m.workloads {
if m.workloadCursor == i {
options[i] = menuSelectedStyle.Render(fmt.Sprintf("%s (%s)", opt.label, opt.desc))
} else {
options[i] = menuStyle.Render(opt.label)
}
}
selector := fmt.Sprintf("CPU Workload: %s", strings.Join(options, menuStyle.Render(" | ")))
s += dbSelectorLabelStyle.Render(selector) + "\n"
hint := infoStyle.Render("Switch with Shift+←/→ or w • Affects parallelism and compression")
s += hint + "\n\n"
}
// Database info
dbInfo := infoStyle.Render(fmt.Sprintf("Database: %s@%s:%d (%s)",
m.config.User, m.config.Host, m.config.Port, m.config.DisplayDatabaseType()))
@@ -406,52 +350,6 @@ func (m *MenuModel) applyDatabaseSelection() {
}
}
// applyWorkloadSelection updates the config with the selected workload type
func (m *MenuModel) applyWorkloadSelection() {
if m.config == nil {
return
}
if m.workloadCursor < 0 || m.workloadCursor >= len(m.workloads) {
return
}
selection := m.workloads[m.workloadCursor]
m.config.CPUWorkloadType = selection.value
// Recalculate optimal settings based on workload type
if m.config.CPUInfo != nil && m.config.AutoDetectCores {
// Recalculate Jobs and DumpJobs based on new workload type
switch selection.value {
case "cpu-intensive":
// More parallelism for CPU-bound tasks
m.config.Jobs = m.config.CPUInfo.PhysicalCores * 2
m.config.DumpJobs = m.config.CPUInfo.PhysicalCores
case "io-intensive":
// Less parallelism to avoid I/O contention
m.config.Jobs = m.config.CPUInfo.PhysicalCores / 2
if m.config.Jobs < 1 {
m.config.Jobs = 1
}
m.config.DumpJobs = 2
default: // balanced
m.config.Jobs = m.config.CPUInfo.PhysicalCores
m.config.DumpJobs = m.config.CPUInfo.PhysicalCores / 2
if m.config.DumpJobs < 2 {
m.config.DumpJobs = 2
}
}
}
m.message = successStyle.Render(fmt.Sprintf("⚡ CPU workload set to %s (Jobs: %d, DumpJobs: %d)",
selection.label, m.config.Jobs, m.config.DumpJobs))
if m.logger != nil {
m.logger.Info("updated CPU workload type",
"type", m.config.CPUWorkloadType,
"jobs", m.config.Jobs,
"dump_jobs", m.config.DumpJobs)
}
}
// RunInteractiveMenu starts the simple TUI
func RunInteractiveMenu(cfg *config.Config, log logger.Logger) error {
m := NewMenuModel(cfg, log)