Skip to content

Commit 5ff6e30

Browse files
Address C10: scope BenchmarkDashboardView models section to visible categories
The Models section was gated by `!availableModels.isEmpty` while its rows were gated by `selectedCategories`, so an empty section could render when those sets didn't overlap. Additionally, the All/None header actions mutated hidden categories via the view model's selectAllModels/deselectAllModels helpers. Compute a single `visibleModelCategories` list that intersects `selectedCategories` with non-empty `availableModels` entries, and use it for both the section guard, the ForEach iteration, and the All/None actions (which now collect IDs from visible categories only and mutate via Set formUnion/subtract).
1 parent d707a0d commit 5ff6e30

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

examples/ios/RunAnywhereAI/RunAnywhereAI/Features/Benchmarks/Views/BenchmarkDashboardView.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ struct BenchmarkDashboardView: View {
1313
@StateObject private var deviceService = DeviceInfoService.shared
1414

1515
var body: some View {
16+
let visibleModelCategories = BenchmarkCategory.allCases.filter {
17+
viewModel.selectedCategories.contains($0) && !(viewModel.availableModels[$0]?.isEmpty ?? true)
18+
}
19+
1620
List {
1721
// Device Info Header
1822
if let info = deviceService.deviceInfo {
@@ -63,9 +67,9 @@ struct BenchmarkDashboardView: View {
6367
}
6468

6569
// Model Selection
66-
if !viewModel.availableModels.isEmpty {
70+
if !visibleModelCategories.isEmpty {
6771
Section {
68-
ForEach(BenchmarkCategory.allCases.filter { viewModel.availableModels[$0] != nil && viewModel.selectedCategories.contains($0) }) { category in
72+
ForEach(visibleModelCategories) { category in
6973
if let models = viewModel.availableModels[category] {
7074
DisclosureGroup {
7175
ForEach(models, id: \.id) { model in
@@ -94,10 +98,20 @@ struct BenchmarkDashboardView: View {
9498
HStack {
9599
Text("Models")
96100
Spacer()
97-
Button("All") { viewModel.selectAllModels() }
101+
Button("All") {
102+
let ids = visibleModelCategories
103+
.flatMap { viewModel.availableModels[$0] ?? [] }
104+
.map(\.id)
105+
viewModel.selectedModelIds.formUnion(ids)
106+
}
98107
.font(AppTypography.caption)
99108
Text("·").foregroundColor(AppColors.textTertiary)
100-
Button("None") { viewModel.deselectAllModels() }
109+
Button("None") {
110+
let ids = visibleModelCategories
111+
.flatMap { viewModel.availableModels[$0] ?? [] }
112+
.map(\.id)
113+
viewModel.selectedModelIds.subtract(ids)
114+
}
101115
.font(AppTypography.caption)
102116
}
103117
}

0 commit comments

Comments
 (0)