Add Start and Discuss buttons to lead suggestions
This commit is contained in:
@@ -91,6 +91,34 @@ final class Store {
|
||||
}
|
||||
}
|
||||
|
||||
func startSuggestion(_ projectId: String, _ title: String, brief: String, _ overlays: Overlays) {
|
||||
let key = "\(projectId)\n\(title)"
|
||||
if todoStarting.contains(key) {
|
||||
return
|
||||
}
|
||||
todoStarting.insert(key)
|
||||
Task {
|
||||
do {
|
||||
_ = try await api.client.createTask(path: .init(projectId: projectId), body: .json(.init(title: title, prompt: brief, model: models[0]))).created
|
||||
} catch {
|
||||
overlays.showAlert(errorText(error))
|
||||
}
|
||||
todoStarting.remove(key)
|
||||
}
|
||||
}
|
||||
|
||||
func discussSuggestion(_ title: String, brief: String, _ overlays: Overlays) {
|
||||
let lead = currentLead()
|
||||
let live = lead != nil && lead!.state != .completed
|
||||
Task {
|
||||
do {
|
||||
_ = try await api.client.messageLead(body: .json(.init(text: "Let's discuss your suggestion \"\(title)\" before starting it:\n\n\(brief)", model: live ? nil : models[0]))).accepted
|
||||
} catch {
|
||||
overlays.showAlert(errorText(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var transcript: [ByreEvent] {
|
||||
selectedFeed?.events ?? []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user