New release v2.3.9
- Jarvis integration: manage oAI-Web agents and usage from inside the app (/jarvis command, Settings tab 11) - Model category filter: keyword-based categorisation with popover picker in model selector - Categories shown in ModelInfoView with coloured chips; dot indicators on model rows Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,11 +38,17 @@ struct ModelSelectorView: View {
|
||||
@State private var filterImageGen = false
|
||||
@State private var filterThinking = false
|
||||
@State private var filterFavorites = false
|
||||
@State private var selectedCategory: ModelCategory? = nil
|
||||
@State private var showCategoryPicker = false
|
||||
@State private var keyboardIndex: Int = -1
|
||||
@State private var sortOrder: ModelSortOrder = .default
|
||||
@State private var selectedInfoModel: ModelInfo? = nil
|
||||
@Bindable private var settings = SettingsService.shared
|
||||
|
||||
private var categoriesWithModels: Set<ModelCategory> {
|
||||
Set(models.flatMap(\.categories))
|
||||
}
|
||||
|
||||
private var filteredModels: [ModelInfo] {
|
||||
let q = searchText.lowercased()
|
||||
let filtered = models.filter { model in
|
||||
@@ -57,8 +63,9 @@ struct ModelSelectorView: View {
|
||||
let matchesImageGen = !filterImageGen || model.capabilities.imageGeneration
|
||||
let matchesThinking = !filterThinking || model.capabilities.thinking
|
||||
let matchesFavorites = !filterFavorites || settings.favoriteModelIds.contains(model.id)
|
||||
let matchesCategory = selectedCategory == nil || model.categories.contains(selectedCategory!)
|
||||
|
||||
return matchesSearch && matchesVision && matchesTools && matchesOnline && matchesImageGen && matchesThinking && matchesFavorites
|
||||
return matchesSearch && matchesVision && matchesTools && matchesOnline && matchesImageGen && matchesThinking && matchesFavorites && matchesCategory
|
||||
}
|
||||
|
||||
let favIds = settings.favoriteModelIds
|
||||
@@ -100,6 +107,40 @@ struct ModelSelectorView: View {
|
||||
|
||||
Spacer()
|
||||
|
||||
// Category picker (only shown when at least one category has models)
|
||||
if !categoriesWithModels.isEmpty {
|
||||
Button(action: { showCategoryPicker.toggle() }) {
|
||||
HStack(spacing: 4) {
|
||||
if let cat = selectedCategory {
|
||||
Circle().fill(cat.color).frame(width: 7, height: 7)
|
||||
Text(LocalizedStringKey(cat.rawValue))
|
||||
} else {
|
||||
Image(systemName: "tag")
|
||||
Text("Category")
|
||||
}
|
||||
}
|
||||
.font(.caption)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(selectedCategory != nil ? selectedCategory!.color.opacity(0.18) : Color.gray.opacity(0.1))
|
||||
.foregroundColor(selectedCategory != nil ? selectedCategory!.color : .secondary)
|
||||
.cornerRadius(6)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(selectedCategory != nil ? selectedCategory!.color.opacity(0.4) : Color.clear, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("Filter by category")
|
||||
.popover(isPresented: $showCategoryPicker, arrowEdge: .bottom) {
|
||||
CategoryPickerPopover(
|
||||
categoriesWithModels: categoriesWithModels,
|
||||
selectedCategory: $selectedCategory,
|
||||
onSelect: { keyboardIndex = -1 }
|
||||
)
|
||||
}
|
||||
} // end if !categoriesWithModels.isEmpty
|
||||
|
||||
// Favorites filter star
|
||||
Button(action: { filterFavorites.toggle(); keyboardIndex = -1 }) {
|
||||
Image(systemName: filterFavorites ? "star.fill" : "star")
|
||||
@@ -180,7 +221,7 @@ struct ModelSelectorView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(minWidth: 600, minHeight: 500)
|
||||
.frame(minWidth: 740, minHeight: 500)
|
||||
.navigationTitle("Select Model")
|
||||
#if os(macOS)
|
||||
.onKeyPress(.downArrow) {
|
||||
@@ -255,6 +296,7 @@ struct FilterToggle: View {
|
||||
HStack(spacing: 4) {
|
||||
Text(icon)
|
||||
Text(label)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.font(.caption)
|
||||
.padding(.horizontal, 10)
|
||||
@@ -264,6 +306,68 @@ struct FilterToggle: View {
|
||||
.cornerRadius(6)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.fixedSize()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Category Picker Popover
|
||||
|
||||
struct CategoryPickerPopover: View {
|
||||
let categoriesWithModels: Set<ModelCategory>
|
||||
@Binding var selectedCategory: ModelCategory?
|
||||
let onSelect: () -> Void
|
||||
|
||||
private let columns = [GridItem(.adaptive(minimum: 130), spacing: 8)]
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack {
|
||||
Text("Filter by Category")
|
||||
.font(.caption.weight(.semibold))
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
if selectedCategory != nil {
|
||||
Button("Clear") {
|
||||
selectedCategory = nil
|
||||
onSelect()
|
||||
}
|
||||
.font(.caption)
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
LazyVGrid(columns: columns, spacing: 8) {
|
||||
ForEach(ModelCategory.allCases.filter { categoriesWithModels.contains($0) }, id: \.rawValue) { cat in
|
||||
let isSelected = selectedCategory == cat
|
||||
Button {
|
||||
selectedCategory = isSelected ? nil : cat
|
||||
onSelect()
|
||||
} label: {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: cat.systemImage)
|
||||
.font(.caption)
|
||||
.frame(width: 14)
|
||||
Text(LocalizedStringKey(cat.rawValue))
|
||||
.font(.caption)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 7)
|
||||
.background(isSelected ? cat.color.opacity(0.18) : Color.gray.opacity(0.08))
|
||||
.foregroundColor(isSelected ? cat.color : .primary)
|
||||
.cornerRadius(6)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(isSelected ? cat.color.opacity(0.45) : Color.clear, lineWidth: 1)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(14)
|
||||
.frame(minWidth: 360)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +428,7 @@ struct ModelRowView: View {
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { onSelect() }
|
||||
|
||||
// Right side: capabilities + info button
|
||||
// Right side: capabilities + category dots + info button
|
||||
VStack(alignment: .trailing, spacing: 6) {
|
||||
// Capability icons
|
||||
HStack(spacing: 4) {
|
||||
@@ -335,6 +439,18 @@ struct ModelRowView: View {
|
||||
if model.capabilities.thinking { Text("\u{1F9E0}").font(.caption) }
|
||||
}
|
||||
|
||||
// Category dots
|
||||
if !model.categories.isEmpty {
|
||||
HStack(spacing: 3) {
|
||||
ForEach(model.categories, id: \.rawValue) { cat in
|
||||
Circle()
|
||||
.fill(cat.color)
|
||||
.frame(width: 7, height: 7)
|
||||
.help(cat.rawValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Info button
|
||||
Button(action: onInfo) {
|
||||
Image(systemName: "info.circle")
|
||||
|
||||
Reference in New Issue
Block a user