Let the human comment on each decision in the ready-for-merge card
This commit is contained in:
@@ -8,36 +8,13 @@ typealias InboxResponseCreate = Components.Schemas.InboxResponseCreate
|
||||
private let delegateText = "Use your judgment for this decision and continue within the existing task instructions."
|
||||
private let httpURL = Re(#"^https?://"#, caseless: true)
|
||||
|
||||
private func numberChoices(_ blocks: [MDBlock], _ next: inout Int) -> [MDBlock] {
|
||||
blocks.map { block in
|
||||
switch block {
|
||||
case .list(let ordered, let start, let items, let grid):
|
||||
return .list(ordered: ordered, start: start, items: items.map { item in
|
||||
var out = item
|
||||
if item.choice != nil {
|
||||
out.choiceIndex = next
|
||||
next += 1
|
||||
}
|
||||
out.blocks = numberChoices(item.blocks, &next)
|
||||
return out
|
||||
}, grid: grid)
|
||||
case .quote(let inner):
|
||||
return .quote(numberChoices(inner, &next))
|
||||
case .details(let summary, let body):
|
||||
return .details(summary: summary, body: numberChoices(body, &next))
|
||||
default:
|
||||
return block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func firstChoices(_ blocks: [MDBlock], _ out: inout [String: Int]) {
|
||||
for block in blocks {
|
||||
switch block {
|
||||
case .list(_, _, let items, _):
|
||||
for item in items {
|
||||
if let c = item.choice, out[c] == nil {
|
||||
out[c] = item.choiceIndex
|
||||
out[c] = item.index
|
||||
}
|
||||
firstChoices(item.blocks, &out)
|
||||
}
|
||||
@@ -68,7 +45,7 @@ private final class CardModel {
|
||||
self.store = store
|
||||
self.overlays = overlays
|
||||
var next = 0
|
||||
context = numberChoices(parseMarkdown(jsString(item.payload.value["context"] ?? ""), choices: true), &next)
|
||||
context = numberMarked(parseMarkdown(jsString(item.payload.value["context"] ?? ""), choices: true), &next)
|
||||
var first: [String: Int] = [:]
|
||||
firstChoices(context, &first)
|
||||
firstChoice = first
|
||||
@@ -340,7 +317,7 @@ private struct ChoiceBox: View {
|
||||
|
||||
var body: some View {
|
||||
let text = item.choice ?? ""
|
||||
if model.options.contains(text) && model.firstChoice[text] == item.choiceIndex {
|
||||
if model.options.contains(text) && model.firstChoice[text] == item.index {
|
||||
box(text)
|
||||
} else {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 6) {
|
||||
|
||||
Reference in New Issue
Block a user