// // ResearchKeepSheet.swift // Museion // // #29 (S8.3): the keep ask — ONE blocking confirm lands ONE plain markdown // research note in the piece's research/ folder (the store's // writeResearchNote rail). PromoteAskSheet pattern: own-file ask sheet, // Cancel writes nothing, a failure shows its reason inline with the // buttons kept. // import SwiftUI struct ResearchKeepSheet: View { let model: MentorSessionModel let rowID: UUID let candidate: ResearchCandidate let home: URL @Environment(\.dismiss) private var dismiss @State private var refusal: String? var body: some View { VStack(alignment: .leading, spacing: 12) { ScrollView { VStack(alignment: .leading, spacing: 12) { Text("Keep this research note?") .font(.headline) Text("Plain markdown into the piece's research/ folder — nothing saves until you keep it.") .font(.callout) // The note preview: the file the confirm writes. ResearchNoteContent(candidate: candidate) .padding(8) .background(.quaternary.opacity(0.3), in: RoundedRectangle(cornerRadius: 6)) if let refusal { Text(refusal) .font(.callout) .foregroundStyle(.orange) } } .frame(maxWidth: .infinity, alignment: .leading) } HStack(spacing: 8) { Button("Keep") { keep() } .buttonStyle(.borderedProminent) Button("Cancel") { dismiss() } .buttonStyle(.bordered) } .frame(maxWidth: .infinity, alignment: .trailing) } .padding(16) .frame(width: 320, alignment: .leading) } private func keep() { do { let fileName = try PostStore.writeResearchNote( piecePath: candidate.piecePath, title: candidate.title, url: candidate.url, quote: candidate.quote, note: candidate.note, home: home, ) model.setResearchDisposition(rowID: rowID, .kept(fileName: fileName)) dismiss() } catch { refusal = error.localizedDescription } } }