Answer a question again by forking at its answer's snapshot
This commit is contained in:
@@ -61,6 +61,7 @@ private final class CardModel {
|
||||
let context: [MDBlock]
|
||||
let firstChoice: [String: Int]
|
||||
var busy = false
|
||||
var again = false
|
||||
@ObservationIgnored var shown: Set<String> = []
|
||||
|
||||
init(_ item: InboxItem, _ store: Store, _ overlays: Overlays) {
|
||||
@@ -95,7 +96,11 @@ private final class CardModel {
|
||||
}
|
||||
|
||||
var answered: Bool {
|
||||
item.state != .open
|
||||
item.state != .open && !again
|
||||
}
|
||||
|
||||
var canAnswerAgain: Bool {
|
||||
item.state == .answered
|
||||
}
|
||||
|
||||
var chosen: [String] {
|
||||
@@ -148,6 +153,15 @@ private final class CardModel {
|
||||
do {
|
||||
var r = response
|
||||
r.images = try await uploadImages(store.api, imgs)
|
||||
if again {
|
||||
let task = try await store.api.client.answerAgain(body: .json(r)).created.body.json
|
||||
store.drafts?.clearAnswer(item.id)
|
||||
store.paneFocus.setDraft(key, false)
|
||||
again = false
|
||||
busy = false
|
||||
store.focusTask(task.id)
|
||||
return
|
||||
}
|
||||
_ = try await store.api.client.respondInbox(body: .json(.init(responses: [r]))).ok
|
||||
store.drafts?.clearAnswer(item.id)
|
||||
store.paneFocus.setDraft(key, false)
|
||||
@@ -251,6 +265,15 @@ struct QuestionDetails: View {
|
||||
if let model {
|
||||
CardBody(model: model, focus: $focus, question: false)
|
||||
Thread(item: item)
|
||||
if model.again {
|
||||
CardActions(model: model, focus: $focus)
|
||||
} else if model.canAnswerAgain {
|
||||
Button("Answer again") {
|
||||
model.again = true
|
||||
}
|
||||
.buttonStyle(WebButtonStyle())
|
||||
.help("Fork this task from the snapshot taken just before this answer reached the agent, and give the fork a different answer; this task carries on untouched")
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -447,11 +470,18 @@ private struct CardActions: View {
|
||||
model.submit(InboxResponseCreate(itemId: model.item.id, _type: .other, text: delegateText))
|
||||
}
|
||||
.buttonStyle(WebButtonStyle())
|
||||
Button("Ignore") {
|
||||
model.dismiss()
|
||||
if model.again {
|
||||
Button("Cancel") {
|
||||
model.again = false
|
||||
}
|
||||
.buttonStyle(WebButtonStyle())
|
||||
} else {
|
||||
Button("Ignore") {
|
||||
model.dismiss()
|
||||
}
|
||||
.buttonStyle(WebButtonStyle())
|
||||
.help("Dismiss this question without answering it; the agent is not told")
|
||||
}
|
||||
.buttonStyle(WebButtonStyle())
|
||||
.help("Dismiss this question without answering it; the agent is not told")
|
||||
Spacer()
|
||||
Button("Submit") {
|
||||
model.submitQuestion()
|
||||
|
||||
Reference in New Issue
Block a user