Configurable recap templates (categories per meeting type, in Settings)

Takeaways categories are no longer hardcoded — they're editable templates. A
template = the always-on TLDR + an ordered list of sections, each with a title, a
type (attributed items / bulleted list / paragraph), and an instruction (the prompt
text for that category). The analyzer assembles the LLM prompt FROM the template
and parses generically, so adding/removing/renaming a category needs zero code and
the output always renders.

- RecapTemplate / TemplateSection / SectionKind + TopicGranularity; built-in
  defaults (Internal Meeting, 1:1, Company/Sales Call), all editable.
- Generic extras: RecapExtras{tldr, primarySpeakers, sections:[RenderedSection]} +
  RecapItem{text,who,when,note} replaces the fixed MeetingExtras. Analyzer builds
  per-section sec_N fields + parses by kind; renderer + remap are generic.
- Topic granularity (coarse/auto/fine) answers 'should chunking be configurable' —
  it scales the target topic count; raw window sizes stay as tuned defaults.
- AppSettings persists templates + defaultTemplateId (seeded once). Settings gets a
  default-template picker + 'Manage…' → TemplatesView (CRUD, edit sections/
  instructions, set default, **Preview prompt** for full transparency).
- Recap editor gains a template picker; Regenerate uses the chosen template. Auto
  recap uses the default template.

54/54 XCTest (template prompt build, generic parse/remap/render updated).
This commit is contained in:
Grant Gilliam
2026-06-06 19:26:03 -05:00
parent 10ddf9992a
commit c539b78a58
14 changed files with 580 additions and 227 deletions
+55 -24
View File
@@ -23,30 +23,61 @@ final class RecapTests: XCTestCase {
XCTAssertEqual(RecapAnalyzer.parseSections(json).count, 1)
}
func testParseExtras() {
let json = #"""
{"tldr":{"summary":"They discussed the roadmap.","primary_speakers":["Grant","Caitlyn"]},
"decisions":[{"statement":"Ship dual-channel","agreed_by":["Grant"],"supporting_offset":72}],
"action_items":[{"description":"Send the doc","owner":"Caitlyn","due_hint":"by Friday","supporting_offset":120}],
"open_questions":[{"question":"What about Teams?","raised_by":"Grant","answered":false}],
"key_quotes":[{"speaker":"Caitlyn","offset":73,"quote":"Go Bitcoin","why_notable":"sets the tone"}]}
"""#
let x = RecapAnalyzer.parseExtras(json)
private var sampleTemplate: RecapTemplate {
RecapTemplate(id: "t", name: "T", includeTLDR: true, sections: [
.init(id: "a", title: "Decisions", kind: .items, instruction: ""),
.init(id: "b", title: "Takeaways", kind: .bullets, instruction: ""),
])
}
func testParseExtrasGeneric() {
let json = #"{"tldr":"They discussed the roadmap.","primary_speakers":["Grant","Caitlyn"],"sec_0":[{"text":"Ship dual-channel","who":"Grant","when":72,"note":null}],"sec_1":["faster","cheaper"]}"#
let x = RecapAnalyzer.parseExtras(json, template: sampleTemplate)
XCTAssertNotNil(x)
XCTAssertEqual(x?.tldr.primarySpeakers, ["Grant", "Caitlyn"])
XCTAssertEqual(x?.decisions.first?.supportingOffset, 72)
XCTAssertEqual(x?.actionItems.first?.owner, "Caitlyn")
XCTAssertEqual(x?.actionItems.first?.dueHint, "by Friday")
XCTAssertEqual(x?.openQuestions.first?.question, "What about Teams?")
XCTAssertEqual(x?.keyQuotes.first?.quote, "Go Bitcoin")
XCTAssertEqual(x?.tldr, "They discussed the roadmap.")
XCTAssertEqual(x?.primarySpeakers, ["Grant", "Caitlyn"])
XCTAssertEqual(x?.sections.count, 2)
XCTAssertEqual(x?.sections[0].kind, .items)
XCTAssertEqual(x?.sections[0].items.first?.text, "Ship dual-channel")
XCTAssertEqual(x?.sections[0].items.first?.who, "Grant")
XCTAssertEqual(x?.sections[0].items.first?.when, 72)
XCTAssertEqual(x?.sections[1].kind, .bullets)
XCTAssertEqual(x?.sections[1].bullets, ["faster", "cheaper"])
}
func testParseExtrasDropsNullStrings() {
// owner/raised_by "null" or empty must become nil, not a literal "null".
let json = #"{"tldr":{"summary":"s","primary_speakers":[]},"action_items":[{"description":"do it","owner":"null","due_hint":""}],"decisions":[],"open_questions":[],"key_quotes":[]}"#
let x = RecapAnalyzer.parseExtras(json)
XCTAssertNil(x?.actionItems.first?.owner)
XCTAssertNil(x?.actionItems.first?.dueHint)
let template = RecapTemplate(id: "t", name: "T", sections: [.init(id: "a", title: "Actions", kind: .items, instruction: "")])
let json = #"{"tldr":"s","primary_speakers":[],"sec_0":[{"text":"do it","who":"null","note":""}]}"#
let x = RecapAnalyzer.parseExtras(json, template: template)
XCTAssertNil(x?.sections.first?.items.first?.who)
XCTAssertNil(x?.sections.first?.items.first?.note)
XCTAssertEqual(x?.sections.first?.items.first?.text, "do it")
}
func testExtrasPromptBuildsFromTemplate() {
let template = RecapTemplate(id: "t", name: "T", includeTLDR: true, sections: [
.init(id: "a", title: "Risks", kind: .bullets, instruction: "List the risks."),
.init(id: "b", title: "Decisions", kind: .items, instruction: "List decisions."),
])
let file = SpeakersFile(sessionId: "s", app: "meet", durationSec: 60, speakers: [],
segments: [.init(start: 0, end: 2, speaker: "A", text: "hi")], models: [:])
let prompt = RecapAnalyzer.extrasPrompt(file: file, entries: RecapAnalyzer.entries(from: file),
sections: [], template: template)
XCTAssertTrue(prompt.contains("sec_0"))
XCTAssertTrue(prompt.contains("sec_1"))
XCTAssertTrue(prompt.contains("Risks"))
XCTAssertTrue(prompt.contains("List the risks."))
XCTAssertTrue(prompt.contains("tldr"))
}
func testExtrasPromptOmitsTLDRWhenDisabled() {
let template = RecapTemplate(id: "t", name: "T", includeTLDR: false,
sections: [.init(id: "a", title: "X", kind: .paragraph, instruction: "y")])
let file = SpeakersFile(sessionId: "s", app: "meet", durationSec: 60, speakers: [],
segments: [.init(start: 0, end: 2, speaker: "A", text: "hi")], models: [:])
let prompt = RecapAnalyzer.extrasPrompt(file: file, entries: RecapAnalyzer.entries(from: file),
sections: [], template: template)
XCTAssertFalse(prompt.contains("\"tldr\""))
}
// MARK: - Stitch / windows
@@ -108,10 +139,10 @@ final class RecapTests: XCTestCase {
.init(start: 0, end: 4, speaker: "Grant", text: "Now we got a call going on."),
.init(start: 72, end: 74, speaker: "Caitlyn", text: "Go Bitcoin."),
], models: [:])
let extras = MeetingExtras(
tldr: .init(summary: "A quick test call.", primarySpeakers: ["Grant"]),
decisions: [], actionItems: [.init(description: "Ship it", owner: "Grant", dueHint: nil, supportingOffset: 3)],
openQuestions: [], keyQuotes: [.init(speaker: "Caitlyn", offset: 72, quote: "Go Bitcoin", whyNotable: "tone")])
let extras = RecapExtras(tldr: "A quick test call.", primarySpeakers: ["Grant"], sections: [
RenderedSection(title: "Action Items", kind: .items, items: [RecapItem(text: "Ship it", who: "Grant", when: 3, note: nil)]),
RenderedSection(title: "Key Quotes", kind: .items, items: [RecapItem(text: "Go Bitcoin", who: "Caitlyn", when: 72, note: "tone")]),
])
let result = RecapResult(sections: [TopicSection(title: "Call start", summary: "Grant opens.", startIndex: 0, endIndex: 1)], extras: extras)
let entries = RecapAnalyzer.entries(from: file)
let md = RecapRenderer.markdown(file: file, result: result, title: "Meet call", entries: entries)