Put macOS model and effort in a menu; take_snapshot commits the branch

This commit is contained in:
Ian Gulliver
2026-10-23 15:17:27 -07:00
parent 2cfd408bc5
commit ff8d4fb4be
4 changed files with 47 additions and 42 deletions
+37 -38
View File
@@ -401,7 +401,6 @@ extension View {
}
}
#if os(iOS)
struct ComposerMenu: View {
let key: String
let photos: Bool
@@ -412,11 +411,35 @@ struct ComposerMenu: View {
var chooseEffort: @MainActor @Sendable (String) -> Void = { _ in }
@Environment(Store.self) private var store
@Environment(Overlays.self) private var overlays
#if os(iOS)
@ViewState private var picking = false
@ViewState private var picked: [PhotosPickerItem] = []
#endif
var body: some View {
menu
#if os(iOS)
.photosPicker(isPresented: $picking, selection: $picked, matching: .images)
.onChange(of: picked) {
let items = picked
if items.isEmpty {
return
}
picked = []
Task {
for item in items {
if let data = try? await item.loadTransferable(type: Data.self) {
store.images.add(key, data, name: nil, overlays)
}
}
}
}
#endif
}
private var menu: some View {
Menu {
#if os(iOS)
if photos {
Button {
picking = true
@@ -429,6 +452,7 @@ struct ComposerMenu: View {
Label("Paste image", systemImage: "doc.on.clipboard")
}
}
#endif
if !models.isEmpty {
Picker("Model for the next turn", selection: Binding(get: { selected }, set: choose)) {
ForEach(models, id: \.self) { option in
@@ -447,25 +471,12 @@ struct ComposerMenu: View {
Image(systemName: "ellipsis")
.frame(height: 14)
}
.menuStyle(.button)
.menuIndicator(.hidden)
.buttonStyle(WebButtonStyle())
.photosPicker(isPresented: $picking, selection: $picked, matching: .images)
.onChange(of: picked) {
let items = picked
if items.isEmpty {
return
}
picked = []
Task {
for item in items {
if let data = try? await item.loadTransferable(type: Data.self) {
store.images.add(key, data, name: nil, overlays)
}
}
}
}
.fixedSize()
}
}
#endif
struct Thumbnails: View {
let key: String
@@ -638,33 +649,21 @@ private struct ComposerBar: View, Equatable {
}
.buttonStyle(WebButtonStyle())
.help(shown ? "Hide the message box" : "Show the message box")
#if os(iOS)
ComposerMenu(key: draftKey, photos: shown, models: chat.team ? [] : options, selected: selected, effort: selectedEffort, choose: choose, chooseEffort: chooseEffort)
#else
#if os(macOS)
if !chat.team {
Picker("", selection: Binding(get: { selected }, set: choose)) {
ForEach(options, id: \.self) { option in
Text(option).tag(option)
}
}
.labelsHidden()
.pickerStyle(.menu)
.fixedSize()
.help("Model for the next turn")
Picker("", selection: Binding(get: { selectedEffort }, set: chooseEffort)) {
ForEach(efforts(selected), id: \.self) { option in
Text(effortLabel(option)).tag(option)
}
}
.labelsHidden()
.pickerStyle(.menu)
.fixedSize()
.help("Effort for the next turn")
menu
.help("Model and effort for the next turn")
}
#else
menu
#endif
}
}
private var menu: some View {
ComposerMenu(key: draftKey, photos: shown, models: chat.team ? [] : options, selected: selected, effort: selectedEffort, choose: choose, chooseEffort: chooseEffort)
}
private var actions: some View {
HStack(spacing: 8) {
Button {