Center task modals

This commit is contained in:
Ian Gulliver
2026-10-20 22:40:48 -07:00
parent 9af1463507
commit ee73b93a30
4 changed files with 6 additions and 12 deletions
+1 -7
View File
@@ -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
}
}
}
+2 -2
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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)