feat(sessions): new post from session & drills (S2.7-8) (#30)
CI / ci (push) Canceled after 0s

A freeform Session births a Post. "New Post" in the Sessions pane
opens an ask-before sheet prefilled with the session's last mentor
reply (editable, G9); ONE confirm materializes the piece under
projects/posts/ stamped origin: ai - immutable frontmatter, never
stats-eligible - and opens it in Posts; a failed write keeps the
sheet up with the reason inline and the draft intact. writeNew
gains an origin parameter (additive default .writer, every existing
caller compiles).

"New Brainstorm" is a session started with an opener prompt - no new
machinery (beginBrainstormSession over the normal new+prompt rails).
The freeform composer (input, liveness, Stop) moved from
MentorPaneView into the shared SessionTranscriptView: one
conversation surface, two panes - the Sessions pane stops being a
read-only transcript. Drill offers (S2.8) wire as one pass-persona
section (v1.4): the seeded micro-drill doctrine owns the motivation
moment, the two-minute bound, the single shelf, and the vanish -
session flavor, no machinery beyond S2.3.

Resume now speaks the real adapter wire. Live-probed against the
engine: 0.21.5 answers session/load with the id at
_meta.hermes.sessionProvenance.acpSessionId and NO top-level
sessionId - resumeSession accepts both shapes; every prior
real-engine resume misread as "engine does not know this session".
The fake ACP server answers load in the real shape (a
loadReplayLegacy knob pins the older contract), so the whole resume
suite guards the live wire.

New pins: draft-candidate extraction (last mentor row wins; thought/
card/research/raw lanes and refusal/connection rows never prefill),
ai-stamp write + immutability through overwrite, brainstorm roster +
labeled opener, legacy-shape resume. Finish-audit (three
reviewers, parallel) converged on the confirm() dismissal that
destroyed the edited draft on a failed write - fixed with
sheet-local error state (stale-refusal re-show dies with the
presentation) - and surfaced the missing brainstorm and legacy-shape
pins; the resume fix was flip-verified (removing the provenance
fallback fails the provenance pins). Full suite green (379 tests).

Closes #30
This commit is contained in:
AlexKucera committed 2026-10-22 17:04:12 +02:00
1 parent b02d36bb5d
commit ae234350ef
16 files changed
+521 -128

No files matched your search

+68 -7
View File
@@ -10,10 +10,12 @@
import SwiftUI
/// The shared session transcript — the ACTIVE session's rows + streaming
/// buffers, extracted from MentorPaneView in #28 so the Sessions pane reads
/// the same surface. Writing voice: pass `showsDebugRows: false` (the debug
/// toggle stays the Mentor pane's).
/// The shared session surface — the ACTIVE session's rows + streaming
/// buffers + the freeform input rail (#28, extracted from MentorPaneView so
/// the Sessions pane reads the same surface; **#30: the composer moved here
/// too — a session is a conversation, and every session surface offers
/// one**). Writing voice: pass `showsDebugRows: false` (the debug toggle
/// stays the Mentor pane's).
struct SessionTranscriptView: View {
let model: MentorSessionModel
/// Raw session/tool rows, collapsed thinking, and live thinking render
@@ -26,6 +28,8 @@ struct SessionTranscriptView: View {
/// The ask-before keep (#29 G9): ONE blocking confirm per candidate,
/// presented over the transcript — never inside a lazy row.
@State private var pendingKeep: PendingKeep?
/// The freeform draft (#30: shared input rail).
@State private var draft = ""
private struct PendingKeep: Identifiable {
let rowID: UUID
@@ -36,6 +40,19 @@ struct SessionTranscriptView: View {
}
var body: some View {
VStack(spacing: 0) {
transcript
Divider()
inputBar
}
.sheet(item: $pendingKeep) { pending in
if let home {
ResearchKeepSheet(model: model, rowID: pending.rowID, candidate: pending.candidate, home: home)
}
}
}
private var transcript: some View {
ScrollView {
LazyVStack(alignment: .leading, spacing: 10) {
ForEach(model.rows.filter { showsDebugRows || Self.isWritingRow($0) }) { row in
@@ -61,11 +78,55 @@ struct SessionTranscriptView: View {
// #24 fix: programmatic scrollTo raced the growing lazy rows and
// mislanded at the TOP; the native bottom anchor needs no scroll code.
.defaultScrollAnchor(.bottom)
.sheet(item: $pendingKeep) { pending in
if let home {
ResearchKeepSheet(model: model, rowID: pending.rowID, candidate: pending.candidate, home: home)
}
/// The freeform composer + liveness — the Mentor pane's #23 rail,
/// shared with the Sessions pane (#30).
private var inputBar: some View {
VStack(alignment: .leading, spacing: 8) {
// Liveness: a pass legitimately runs minutes of silent tool work
// (skill loads, learnings) — without this the pane reads as dead
// (dogfood #23: "hard to tell if it is still thinking").
if model.isStreaming {
HStack(spacing: 8) {
ProgressView()
.controlSize(.small)
Text("Mentor is working — Stop to interrupt.")
.font(.caption)
.foregroundStyle(.secondary)
}
}
HStack(spacing: 8) {
TextField("Ask the mentor…", text: $draft, axis: .vertical)
.textFieldStyle(.plain)
.lineLimit(1 ... 4)
.onSubmit { send() }
Button {
send()
} label: {
Image(systemName: "arrow.up.circle.fill")
.font(.title2)
}
.buttonStyle(.plain)
.disabled(draft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || model.isStreaming)
if model.isStreaming {
Button {
model.stopStreaming()
} label: {
Text("Stop")
}
.controlSize(.regular)
}
}
}
.padding(12)
.disabled(model.phase.isReady == false)
}
private func send() {
let text = draft
draft = ""
Task { await model.sendPrompt(text) }
}
/// The writing-session filter: prose + card events stay; raw rows and