Save a default model per user, set from Settings

This commit is contained in:
Ian Gulliver
2026-10-18 00:57:51 -07:00
parent 17f09ecb7c
commit 10c6c84f74
10 changed files with 395 additions and 257 deletions
+41
View File
@@ -25,6 +25,11 @@ struct SettingsView: View {
heading("Notifications")
DeviceNotifications()
PrefsBox()
heading("Default model")
Text("New tasks you start from byre run on this model.")
.foregroundStyle(Palette.muted)
.fixedSize(horizontal: false, vertical: true)
DefaultModelMenu()
heading("What your lead has learned")
Text("Your lead notes your priorities and preferences as it works with you, and starts every session with them.")
.foregroundStyle(Palette.muted)
@@ -132,6 +137,42 @@ private struct PrefsBox: View {
}
}
private struct DefaultModelMenu: View {
@Environment(Store.self) private var store
@Environment(Overlays.self) private var overlays
var body: some View {
Menu {
ForEach(models, id: \.self) { m in
Button(m) {
Task {
do {
store.me = try await store.api.client.updateDefaultModel(body: .json(.init(model: m))).ok.body.json
} catch {
overlays.showAlert(errorText(error))
}
}
}
}
} label: {
HStack(spacing: 8) {
Text(store.defaultModel)
Image(systemName: "chevron.up.chevron.down")
.font(.system(size: 9, weight: .semibold))
}
.foregroundStyle(Palette.text)
.modifier(FieldStyle())
.contentShape(Rectangle())
}
.menuStyle(.button)
.buttonStyle(.plain)
.menuIndicator(.hidden)
.fixedSize()
.help("Model for new tasks")
.padding(.top, 8)
}
}
private struct LeadNotes: View {
@Environment(Store.self) private var store
@Environment(Overlays.self) private var overlays