Files
museion/Museion/ResearchKeepSheet.swift
T
AlexKucera b02d36bb5d
CI / ci (push) Canceled after 0s
feat(mentor): research & library-light (S8) (#29)
The mentor researches mid-pass and its findings arrive as candidate
source-notes with provenance inside their Session. A third museion-
tools tool, submit_research_notes, is the typed rail (ADR-0006
posture): decode-validate only, reply {"received": N}, write NOTHING
— the session is the holding area, and keeping is the writer's act.

Candidates ride the transcript as first-class rows (researchNote):
parsed from the tool call's rawInput by payload shape — the notes
array routes before the fix-card parse, titles are display text —
one row per note, all-or-nothing per batch, the wire's whitespace
rule mirrored so both boundaries agree. Resume re-materializes them
for free: replays re-run the same parse; dispositions reset honestly
(they were never persisted — engine-owned cargo, ADR-0007).

The writer curates in place (full cards in the shared transcript, no
palette — a handful curates where it lands): Keep opens the
ask-before sheet (G9; PromoteAskSheet posture — inline refusal,
buttons kept) and ONE confirm lands one plain markdown note with
provenance into the piece's research/ via writeResearchNote — the
one folder(of:) id lookup anchors it inside this Home, a symlinked
research/ refuses, collision -2; Reject vanishes, recording nothing.
The pass stub names the rail and forbids the engine writing
candidates itself; kept notes flip hasResearch, so every later pass
sees the research/ path (S8.3 at v1 depth).

Finish-audit (three reviewers) drove the whitespace-parity and
shape-routing fixes, the ResearchNoteContent dedup, and a poll-loop
fix for the debounce rig's sidecar half that the larger suite's load
had pushed past its fixed sleep — full suite green (373 tests).

Closes #29
2026-10-22 14:06:16 +02:00

72 lines
1.9 KiB
Swift

//
// 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
}
}
}