Skip to content

Commit 912ff3b

Browse files
authored
Merge pull request #34 from tijosh/save-on-call-finish
Option to save calls without waiting for speaker attribution
2 parents 7f01bc9 + 42b1f9d commit 912ff3b

15 files changed

Lines changed: 642 additions & 59 deletions

‎README.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ them all to the Trash.
178178
it as mixed ("Several people"). Unnamed voices are saved as "Voice 1", "Voice 2"… The
179179
transcript beside it updates as you name voices. Confirmed voices with 30+ seconds of
180180
speech are saved, so they're recognised next time.
181+
182+
**Or skip it.** Settings › General › **After a call** can save each call as soon as it's
183+
processed, instead of waiting here: **Save with a summary**, or **Save the transcript only**
184+
(no summary or to-dos). Voices Oatcake is sure it recognises from before keep their names
185+
(a closer match than this screen asks for, since nobody is looking), and every other voice
186+
is "Voice 1", "Voice 2"…, whatever the model guessed from the conversation: a guess, or a
187+
match that wasn't sure enough, waits on the voice's card as a suggestion. No voice is
188+
remembered from names nobody checked. The meeting says it was saved without checking who's who: **Name voices…** opens
189+
this screen for it, and **Update meeting** writes its transcript and `meeting.json` again in
190+
place, puts the new names where the old ones were in its summary and to-dos (as whole words:
191+
each "Voice N" stands for one voice, so it's an exact swap wherever the model wrote it that
192+
way), and leaves your notes and its title as they are. Name them while the summary is still
193+
being written and it's written again from the named transcript. **Keep as is** keeps the
194+
names it has. If a call can't be saved by itself, it waits here as usual.
181195
4. **Save.** The meeting is a folder in the folder you picked:
182196
`2026-11-05 1400 Weekly sync/` with `summary.md`, `todo.md` (action items, as
183197
`- [ ] Task — Owner — due Fri, Oct 30 — [12:34]`), `transcript.md`, `notes.md` (your own
@@ -514,6 +528,8 @@ Settings in the app (stored in `~/Library/Application Support/Oatcake/config.jso
514528
`audio.m4a`.
515529
- **Live transcript**, **Offer to record when a call starts**, **Stop recording when the call
516530
ends:** all on by default (Settings › General); see Record above.
531+
- **After a call** (Settings › General): wait for you to check who's who (the default), or save
532+
each call once it's processed, with a summary or with the transcript only; see Review above.
517533
- **Jargon** (Settings › Summaries): names, products and acronyms, separated by commas. The
518534
summary model is told to spell them as written, in summaries, to-dos, name suggestions and Ask's
519535
answers. Transcripts keep what the speech model heard.
@@ -600,7 +616,10 @@ Settings in the app (stored in `~/Library/Application Support/Oatcake/config.jso
600616
- Once a meeting is saved, the recording's working folder in Oatcake's own data folder is
601617
deleted: the audio, the analysis with its voice fingerprints, and the working copy of your
602618
notes. With **Keep call audio** on, the audio goes into the meeting's own folder as
603-
`audio.m4a` first, so it's in one place and goes to the Trash with the meeting.
619+
`audio.m4a` first, so it's in one place and goes to the Trash with the meeting. A meeting saved
620+
without checking who's who (After a call) keeps its analysis and voice clips there, but not the
621+
call's full tracks, until its voices are named, you choose Keep as is, or the meeting itself
622+
goes (to the Trash, or deleted in Finder; that's noticed at launch and after the next save).
604623
- Recording one call at a time is enforced by the app. If Oatcake crashes mid-call, the recorder
605624
carries on for up to ten minutes; opening Oatcake again in that time picks the recording up,
606625
and after it the recorder finishes by itself. A recorder that has gone is noticed within a

‎Sources/Oatcake/AppModel.swift‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ final class AppModel {
116116
downloads.app = app
117117
calendar.app = app
118118
library.whenMoved = { [unowned self] from, to in self.moved(from: from, to: to) }
119+
// A meeting saved without checking who's who keeps voice clips in Oatcake's own folder: they go with it.
120+
library.whenTrashed = { [unowned self] in self.jobs.tidySavedRecordings() }
119121
calendar.changed = { [unowned self] in self.recording.updateMenuBar() }
120122
recording.folderForEvent = { [unowned self] title, recurring in try self.library.meetings.folderForEvent(title: title, recurring: recurring) }
121123
recording.ended = { [unowned self] rec in self.jobs.progress[rec.id] = JobProgress() }
@@ -162,6 +164,7 @@ final class AppModel {
162164
library.tree = library.meetings.tree()
163165
if let tree = library.tree { library.setTodos(library.meetings.allTodos(in: tree)) }
164166
jobs.pending = Recordings.list().filter { $0.state == .recorded || $0.state == .processed }
167+
jobs.unchecked = Recordings.unchecked()
165168
openLastMeeting()
166169
refresh()
167170
calendar.start()
@@ -198,10 +201,11 @@ final class AppModel {
198201
refreshing = true
199202
let meetings = library.meetings
200203
Task {
201-
let (tree, pending, todos) = await Task.detached {
204+
let (tree, pending, unchecked, todos) = await Task.detached {
202205
// The folder is walked once: the to-dos are read from the tree just built.
203206
let tree = meetings.tree()
204-
return (tree, Recordings.list().filter { $0.state == .recorded || $0.state == .processed }, meetings.allTodos(in: tree))
207+
return (tree, Recordings.list().filter { $0.state == .recorded || $0.state == .processed }, Recordings.unchecked(),
208+
meetings.allTodos(in: tree))
205209
}.value
206210
refreshing = false
207211
defer {
@@ -219,6 +223,7 @@ final class AppModel {
219223
withTransaction(quiet) {
220224
self.library.tree = tree
221225
self.jobs.pending = pending
226+
self.jobs.unchecked = unchecked
222227
self.library.setTodos(todos)
223228
self.library.diskVersion += 1
224229
}

‎Sources/Oatcake/Jobs.swift‎

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ final class Jobs {
4242
private func refresh() { app.refresh() }
4343

4444
var pending: [Recording] = []
45+
/// Recordings saved as meetings without checking who's who, whose voices can still be named.
46+
var unchecked: [Recording] = []
4547
var progress: [String: JobProgress] = [:]
4648
/// Meetings whose summary is being written now, and why the last attempt failed, by path.
4749
var summarising = Set<String>()
@@ -50,6 +52,11 @@ final class Jobs {
5052
var regenerating: [String: SummaryPart] = [:]
5153
/// Where each meeting being summarised lives now: it can be renamed or moved while the model writes.
5254
private var summaryJobs: [UUID: String] = [:]
55+
/// Summaries being written of a transcript that has since had its voices named (a meeting saved
56+
/// without checking who's who): what the model is writing has the old names, so it's asked again.
57+
private var staleSummaries = Set<UUID>()
58+
/// Jobs regenerating a meeting's to-dos that are followed by its summary: a voice was left out meanwhile.
59+
private var summaryAgain = Set<UUID>()
5360
var reviewDrafts: [String: ReviewDraft] = [:]
5461
/// Meetings whose to-dos couldn't be read from the model's reply, and why, by path.
5562
var todoProblems: [String: String] = [:]
@@ -128,6 +135,71 @@ final class Jobs {
128135
return
129136
}
130137
if let outcome { apply(id, outcome) }
138+
// Settings › General › After a call: saved now, rather than waiting under Needs review.
139+
if outcome?.done == true, config.afterCall != .review { autoSave(id) }
140+
}
141+
}
142+
143+
/// Saves a processed recording as a meeting without stopping at who's who: a voice Oatcake
144+
/// recognised under that person's name, the rest as "Voice 1"… They can be named later from the
145+
/// meeting. If it can't be saved, it waits under Needs review as usual.
146+
private func autoSave(_ id: String) {
147+
guard let rec = Recordings.get(id), rec.state == .processed, let analysis = try? loadAnalysis(rec) else { return }
148+
let folder = rec.folder ?? ""
149+
let withSummary = config.afterCall == .saveWithSummary
150+
do {
151+
let path = try saveMeeting(config, rec, decisions: suggestedDecisions(analysis), folder: folder, title: rec.title, unchecked: true)
152+
reviewDrafts.removeValue(forKey: id)
153+
if withSummary { writeSummary(path) }
154+
tidySavedRecordings()
155+
toast("“\(rec.title)” saved to \(folderPath(folder))")
156+
refresh()
157+
// Watching it being processed: on to the meeting.
158+
if app.selection() == .job(id) { app.select(.meeting(path, jump: Jump(tab: withSummary ? .summary : .transcript))) }
159+
} catch {
160+
toast("Couldn’t save “\(rec.title)” by itself: \(error.localizedDescription) It’s waiting under Needs review.", isError: true)
161+
}
162+
}
163+
164+
/// Names the voices of a meeting saved without checking: its transcript and meeting.json are
165+
/// written again in place, and the new names are put into its summary and to-dos. Returns its path.
166+
func updateMeeting(_ rec: Recording, decisions: [String: Decision]) throws -> String {
167+
guard let path = Recordings.meetingPath(rec, meetingsRoot: config.meetingsRoot) else {
168+
throw OatcakeError("The meeting saved from this recording couldn’t be found. It may have been deleted.")
169+
}
170+
// Asked before saving: after it, what the voices were saved as is no longer on record.
171+
let leftOut = leavesOutSavedVoice(rec, decisions)
172+
let saved = try saveMeeting(config, rec, decisions: decisions, folder: "", into: path)
173+
// A summary of it that's still being written was asked for with the old names.
174+
let writing = summaryJobs.filter { $0.value == saved }.map(\.key)
175+
staleSummaries.formUnion(writing)
176+
// A voice left out of a meeting that has its summary already: putting new names in can't take
177+
// out what the summary says of that voice, so the summary is written again from the transcript
178+
// as it is now. One being written is read again anyway; a job that's only regenerating the
179+
// to-dos is followed by the summary.
180+
if leftOut, (try? Meetings(root: config.meetingsRoot).read(saved).summary.trimmed.isEmpty) == false {
181+
if writing.isEmpty {
182+
writeSummary(saved, only: .summary)
183+
} else if regenerating[saved] == .todos {
184+
summaryAgain.formUnion(writing)
185+
}
186+
}
187+
reviewDrafts.removeValue(forKey: rec.id)
188+
tidySavedRecordings()
189+
return saved
190+
}
191+
192+
/// Keep as is: the meeting stays with the names it was saved with, and the recording's working
193+
/// folder (its analysis, voice fingerprints and clips) is cleared away.
194+
func keepAsIs(_ id: String) {
195+
guard let rec = unchecked.first(where: { $0.id == id }) else { return }
196+
do {
197+
try Recordings.markChecked(rec)
198+
reviewDrafts.removeValue(forKey: id)
199+
tidySavedRecordings()
200+
refresh()
201+
} catch {
202+
toast(error.localizedDescription, isError: true)
131203
}
132204
}
133205

@@ -211,15 +283,25 @@ final class Jobs {
211283
summaryJobs[job] = path
212284
let config = config
213285
Task {
286+
defer { staleSummaries.remove(job) }
214287
do {
215288
// What's there now: if it's changed by the time the model is done, it isn't replaced.
216-
let previous = try part.map { part in
217-
let files = try Meetings(root: config.meetingsRoot).read(path)
218-
return part == .summary ? files.summary : files.todo
289+
@MainActor func partNow() throws -> String? {
290+
try part.map { part in
291+
let files = try Meetings(root: config.meetingsRoot).read(summaryJobs[job] ?? path)
292+
return part == .summary ? files.summary : files.todo
293+
}
219294
}
295+
var previous = try partNow()
220296
try await downloads.ensureModel()
221-
// Where the meeting is now: it may have been renamed or moved while the model downloaded.
222-
let draft = try await OatcakeCore.draftSummary(config, meeting: summaryJobs[job] ?? path, only: part)
297+
var draft: SummaryDraft
298+
repeat {
299+
// The meeting's voices were named meanwhile: the transcript is read again with its new
300+
// names, and what's there now is what they were just put into.
301+
if staleSummaries.remove(job) != nil { previous = try partNow() }
302+
// Where the meeting is now: it may have been renamed or moved while the model downloaded.
303+
draft = try await OatcakeCore.draftSummary(config, meeting: summaryJobs[job] ?? path, only: part)
304+
} while staleSummaries.contains(job)
223305
if let part, let previous {
224306
try OatcakeCore.writeRegenerated(part, draft, config: config, meeting: summaryJobs[job] ?? path, previous: previous)
225307
regenerating.removeValue(forKey: summaryJobs[job] ?? path)
@@ -231,8 +313,10 @@ final class Jobs {
231313
} catch {
232314
summaryErrors[summaryJobs[job] ?? path] = error.localizedDescription
233315
}
234-
summarising.remove(summaryJobs[job] ?? path)
316+
let meeting = summaryJobs[job] ?? path
317+
summarising.remove(meeting)
235318
summaryJobs.removeValue(forKey: job)
319+
if summaryAgain.remove(job) != nil { writeSummary(meeting, only: .summary) }
236320
refresh()
237321
}
238322
}

‎Sources/Oatcake/Library.swift‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ final class Library {
1212
var app = AppServices()
1313
/// A folder or meeting now lives somewhere else: whatever knew it by its old path follows it.
1414
var whenMoved: @MainActor (_ from: String, _ to: String) -> Void = { _, _ in }
15+
/// Meetings have gone to the Trash: what was kept for them elsewhere can go too.
16+
var whenTrashed: @MainActor () -> Void = {}
1517
private var config: Config { app.config() }
1618
private func toast(_ text: String, isError: Bool = false) { app.toast(text, isError) }
1719
private func refresh() { app.refresh() }
@@ -91,7 +93,10 @@ final class Library {
9193
/// Moves meetings or folders to the Trash. One that can't be moved stops the rest, and the toast
9294
/// says how many went before it and why.
9395
func trash(_ nodes: [TreeNode]) {
94-
defer { refresh() }
96+
defer {
97+
whenTrashed()
98+
refresh()
99+
}
95100
var moved = 0
96101
do {
97102
for node in nodes {

‎Sources/Oatcake/MeetingView.swift‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ struct MeetingView: View {
336336
if granola {
337337
Notice(tone: .grey) { Text(granolaNotice(files)) }.padding(.top, 14)
338338
}
339+
if let id = meta.recording, model.jobs.unchecked.contains(where: { $0.id == id }) {
340+
uncheckedNotice(id, unnamed: (meta.participants ?? []).contains { $0.range(of: #"^Voice \d+$"#, options: .regularExpression) != nil })
341+
.padding(.top, 14)
342+
}
339343
Spacer().frame(height: 22)
340344
if tab == .summary, let part = model.jobs.regenerating[path] {
341345
let what = part == .summary ? "summary" : "to-dos"
@@ -408,6 +412,27 @@ struct MeetingView: View {
408412
.compactMap { $0 }.joined(separator: " · ")
409413
}
410414

415+
/// Saved straight after the call, without anyone checking who's who (Settings › General › After a call).
416+
/// `unnamed`: some of its voices weren't recognised, so they're "Voice 1", "Voice 2"… for now.
417+
private func uncheckedNotice(_ id: String, unnamed: Bool) -> some View {
418+
// Amber, not blue: blue notices carry a spinner, for work in progress.
419+
Notice(tone: .amber) {
420+
Text("Saved without checking who’s who").fontWeight(.semibold)
421+
Text(unnamed
422+
? "Voices Oatcake didn’t recognise are “Voice 1”, “Voice 2”… Name them and this meeting’s transcript, summary and to-dos are updated."
423+
: "Oatcake recognised every voice from before and used those names. Change one and this meeting’s transcript, summary and to-dos are updated.")
424+
HStack(spacing: 10) {
425+
Button("Name voices…") {
426+
flush()
427+
model.selection = .job(id)
428+
}
429+
Button("Keep as is") { model.jobs.keepAsIs(id) }
430+
.help("Keep these names. The recording’s voice clips are deleted, so its voices can’t be named later.")
431+
}
432+
.padding(.top, 6)
433+
}
434+
}
435+
411436
private func granolaNotice(_ files: [FileKey: String]) -> String {
412437
let transcript = files[.transcript] ?? ""
413438
let plain = transcriptLines.isEmpty && !transcript.trimmed.isEmpty

‎Sources/Oatcake/OatcakeApp.swift‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ struct DetailView: View {
272272
} else {
273273
ProcessingView(rec: rec).id(rec.id)
274274
}
275+
} else if let rec = model.jobs.unchecked.first(where: { $0.id == id }) {
276+
// A meeting saved without checking who's who, having its voices named.
277+
ReviewView(rec: rec).id(rec.id)
275278
} else {
276279
blank
277280
}

0 commit comments

Comments
 (0)