diff --git a/mac/Sources/Byre/Chat.swift b/mac/Sources/Byre/Chat.swift index 4c1d797..065b3b9 100644 --- a/mac/Sources/Byre/Chat.swift +++ b/mac/Sources/Byre/Chat.swift @@ -688,12 +688,11 @@ private struct DiscardButton: View { var small = false @Environment(Store.self) private var store @Environment(Overlays.self) private var overlays - @ViewState private var frame: CGRect = .zero var body: some View { let button = Button("Discard") { Task { - await confirmDiscard(task, store, overlays, anchor: frame) + await confirmDiscard(task, store, overlays) } } Group { @@ -705,11 +704,6 @@ private struct DiscardButton: View { } .disabled(busy) .help("The agent writes the task summary, then byre deletes the worktree and branch without merging") - .onGeometryChange(for: CGRect.self) { g in - g.frame(in: .named("window")) - } action: { f in - frame = f - } } } diff --git a/mac/Sources/Byre/Dialogs.swift b/mac/Sources/Byre/Dialogs.swift index 66cfc6a..77453eb 100644 --- a/mac/Sources/Byre/Dialogs.swift +++ b/mac/Sources/Byre/Dialogs.swift @@ -88,13 +88,13 @@ final class Overlays { } } - func showConfirm(_ paragraphs: [String], action: String, danger: Bool = false, anchor: CGRect? = nil) async -> Bool { + func showConfirm(_ paragraphs: [String], action: String, danger: Bool = false, anchor: CGRect? = nil, inPane: Bool = false) async -> Bool { let content = VStack(alignment: .leading, spacing: 12) { ForEach(Array(paragraphs.enumerated()), id: \.offset) { _, p in ModalText(text: p) } } - return await showModal(content, [ModalButton(label: "Cancel", value: "cancel"), ModalButton(label: action, value: "ok", primary: true, danger: danger)], anchor: anchor) == "ok" + return await showModal(content, [ModalButton(label: "Cancel", value: "cancel"), ModalButton(label: action, value: "ok", primary: true, danger: danger)], anchor: anchor, inPane: inPane) == "ok" } func showChoice(_ content: some View, _ choices: [ModalButton], anchor: CGRect? = nil) async -> String { diff --git a/mac/Sources/Byre/MergeDialog.swift b/mac/Sources/Byre/MergeDialog.swift index b6fc37d..6285a93 100644 --- a/mac/Sources/Byre/MergeDialog.swift +++ b/mac/Sources/Byre/MergeDialog.swift @@ -354,8 +354,8 @@ private struct MergeContent: View { } @MainActor -func confirmDiscard(_ task: ByreTask, _ store: Store, _ overlays: Overlays, anchor: CGRect?) async { - if !(await overlays.showConfirm(["Discard \"\(task.name)\"?"], action: "Discard", danger: true, anchor: anchor)) { +func confirmDiscard(_ task: ByreTask, _ store: Store, _ overlays: Overlays) async { + if !(await overlays.showConfirm(["Discard \"\(task.name)\"?"], action: "Discard", danger: true, inPane: true)) { return } do { diff --git a/mac/Sources/Byre/Switcher.swift b/mac/Sources/Byre/Switcher.swift index 5904a7d..4f50944 100644 --- a/mac/Sources/Byre/Switcher.swift +++ b/mac/Sources/Byre/Switcher.swift @@ -29,7 +29,7 @@ func runGo(_ key: String, _ store: Store, _ overlays: Overlays) { } Task { if let task = store.findTask(taskId), task.state == .discardSuggested { - await confirmDiscard(task, store, overlays, anchor: nil) + await confirmDiscard(task, store, overlays) return } await confirmMerge(taskId, store, overlays)