Commit d036624920

d0366249200d5fab1f6d8440062f7af4313bf135

parent: 91fe479290

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-07 03:14 UTC

Pick the body markup when writing

Layout: unified · split

gitbay/Views/Issues/IssueListView.swift +5 −1
@@ -8,6 +8,7 @@ struct IssueListView: View {
88 @State private var filtering = false
99 @State private var draftTitle = ""
1010 @State private var draftBody = ""
11 @State private var draftFormat = "md"
1112
1213 init(client: GitbayClient, repo: String) {
1314 _model = State(initialValue: IssueListViewModel(client: client, repoPath: repo))
@@ -83,12 +84,15 @@ struct IssueListView: View {
8384 working: createModel.working,
8485 errorMessage: createModel.errorMessage,
8586 title: $draftTitle,
86 bodyText: $draftBody
87 bodyText: $draftBody,
88 format: $draftFormat
8789 ) {
90 createModel.format = draftFormat
8891 Task {
8992 if await createModel.create(title: draftTitle, body: draftBody) != nil {
9093 draftTitle = ""
9194 draftBody = ""
95 draftFormat = "md"
9296 composing = false
9397 await model.load()
9498 }
gitbay/Views/Issues/IssueView.swift +15 −3
@@ -4,11 +4,13 @@ struct IssueView: View {
44
55 @State private var model: IssueDetailViewModel
66 @State private var commentText = ""
7 @State private var commentFormat = "md"
78 @State private var editingLabel = ""
89 @State private var editingAssignee = ""
910 @State private var editing = false
1011 @State private var draftTitle = ""
1112 @State private var draftBody = ""
13 @State private var draftFormat = "md"
1214
1315 init(client: GitbayClient, repo: String, number: Int64) {
1416 _model = State(initialValue: IssueDetailViewModel(
@@ -49,10 +51,11 @@ struct IssueView: View {
4951 working: model.working,
5052 errorMessage: model.actionError,
5153 title: $draftTitle,
52 bodyText: $draftBody
54 bodyText: $draftBody,
55 format: $draftFormat
5356 ) {
5457 Task {
55 await model.edit(title: draftTitle, body: draftBody)
58 await model.edit(title: draftTitle, body: draftBody, format: draftFormat)
5659 if model.actionError == nil { editing = false }
5760 }
5861 }
@@ -200,10 +203,18 @@ struct IssueView: View {
200203 HStack {
201204 TextField("Comment", text: $commentText, axis: .vertical)
202205 .lineLimit(1...5)
206 Picker("Format", selection: $commentFormat) {
207 Text("Markdown").tag("md")
208 Text("Org").tag("org")
209 }
210 .pickerStyle(.segmented)
211 .labelsHidden()
212 .fixedSize()
213 .accessibilityIdentifier("issue-comment-format")
203214 Button {
204215 let text = commentText
205216 commentText = ""
206 Task { await model.comment(text) }
217 Task { await model.comment(text, format: commentFormat) }
207218 } label: {
208219 Image(systemName: "arrow.up.circle.fill")
209220 }
@@ -221,6 +232,7 @@ struct IssueView: View {
221232 Button {
222233 draftTitle = issue.title
223234 draftBody = issue.body ?? ""
235 draftFormat = issue.bodyFormat ?? "md"
224236 editing = true
225237 } label: {
226238 Label("Edit", systemImage: "pencil")
gitbay/Views/MRs/MRListView.swift +8
@@ -90,6 +90,7 @@ private struct MRCreateSheet: View {
9090 @State private var target = ""
9191 @State private var title = ""
9292 @State private var bodyText = ""
93 @State private var format = "md"
9394
9495 var body: some View {
9596 NavigationStack {
@@ -115,6 +116,12 @@ private struct MRCreateSheet: View {
115116 .frame(minHeight: 120)
116117 .autocorrectionDisabled()
117118 .accessibilityIdentifier("mr-body")
119 Picker("Format", selection: $format) {
120 Text("Markdown").tag("md")
121 Text("Org").tag("org")
122 }
123 .pickerStyle(.segmented)
124 .accessibilityIdentifier("mr-format")
118125 }
119126 Section {
120127 Toggle("Draft", isOn: Bindable(model).draft)
@@ -139,6 +146,7 @@ private struct MRCreateSheet: View {
139146 ProgressView()
140147 } else {
141148 Button("Create") {
149 model.format = format
142150 Task {
143151 if await model.create(
144152 source: source, target: target,
gitbay/Views/MRs/MRView.swift +15 −3
@@ -4,11 +4,13 @@ struct MRView: View {
44
55 @State private var model: MRDetailViewModel
66 @State private var commentText = ""
7 @State private var commentFormat = "md"
78 @State private var confirmingMerge = false
89 @State private var confirmingClose = false
910 @State private var editing = false
1011 @State private var draftTitle = ""
1112 @State private var draftBody = ""
13 @State private var draftFormat = "md"
1214 @State private var editingReviewer = ""
1315 @State private var retargeting = false
1416 @State private var pendingRetarget: String?
@@ -115,10 +117,11 @@ struct MRView: View {
115117 working: model.working,
116118 errorMessage: model.actionError,
117119 title: $draftTitle,
118 bodyText: $draftBody
120 bodyText: $draftBody,
121 format: $draftFormat
119122 ) {
120123 Task {
121 await model.edit(title: draftTitle, body: draftBody)
124 await model.edit(title: draftTitle, body: draftBody, format: draftFormat)
122125 if model.actionError == nil { editing = false }
123126 }
124127 }
@@ -403,10 +406,18 @@ struct MRView: View {
403406 HStack {
404407 TextField("Comment", text: $commentText, axis: .vertical)
405408 .lineLimit(1...5)
409 Picker("Format", selection: $commentFormat) {
410 Text("Markdown").tag("md")
411 Text("Org").tag("org")
412 }
413 .pickerStyle(.segmented)
414 .labelsHidden()
415 .fixedSize()
416 .accessibilityIdentifier("mr-comment-format")
406417 Button {
407418 let text = commentText
408419 commentText = ""
409 Task { await model.comment(text) }
420 Task { await model.comment(text, format: commentFormat) }
410421 } label: {
411422 Image(systemName: "arrow.up.circle.fill")
412423 }
@@ -424,6 +435,7 @@ struct MRView: View {
424435 Button {
425436 draftTitle = mr.title
426437 draftBody = mr.body ?? ""
438 draftFormat = mr.bodyFormat ?? "md"
427439 editing = true
428440 } label: {
429441 Label("Edit", systemImage: "pencil")
gitbay/Views/Shared/ComposeSheet.swift +11
@@ -9,6 +9,9 @@ struct ComposeSheet: View {
99 let errorMessage: String?
1010 @Binding var title: String
1111 @Binding var bodyText: String
12 /// nil hides the picker entirely — the release editor has no parity
13 /// row and passes nothing, leaving that call site untouched.
14 var format: Binding<String>? = nil
1215 let onSubmit: () -> Void
1316
1417 @Environment(\.dismiss) private var dismiss
@@ -30,6 +33,14 @@ struct ComposeSheet: View {
3033 .font(.gbSans(.body))
3134 .autocorrectionDisabled()
3235 .accessibilityIdentifier("compose-body")
36 if let format {
37 Picker("Format", selection: format) {
38 Text("Markdown").tag("md")
39 Text("Org").tag("org")
40 }
41 .pickerStyle(.segmented)
42 .accessibilityIdentifier("compose-format")
43 }
3344 }
3445 if let errorMessage {
3546 Section {