Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

iPhone Ask keeps its chat until New chat is tapped, and a source from a meeting's notes opens the transcript where it was said

christianmat782703bf783a
diff --git a/ios/Yogurt.xcodeproj/project.pbxproj b/ios/Yogurt.xcodeproj/project.pbxproj
index 67fd7886..95b37927 100644
--- a/ios/Yogurt.xcodeproj/project.pbxproj
+++ b/ios/Yogurt.xcodeproj/project.pbxproj
@@ -400,7 +400,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 8;
+ CURRENT_PROJECT_VERSION = 9;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 2JNSQVN3N8;
ENABLE_NS_ASSERTIONS = NO;
@@ -460,7 +460,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 8;
+ CURRENT_PROJECT_VERSION = 9;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 2JNSQVN3N8;
ENABLE_STRICT_OBJC_MSGSEND = YES;
diff --git a/ios/Yogurt/Ask/AskSession.swift b/ios/Yogurt/Ask/AskSession.swift
index 49a5a66b..e074fb5e 100644
--- a/ios/Yogurt/Ask/AskSession.swift
+++ b/ios/Yogurt/Ask/AskSession.swift
@@ -26,10 +26,11 @@ actor AskReader {
}
}
-/// Questions asked this session and their answers. Kept in memory only: they go when Yogurt quits.
+/// Questions asked and their answers. Saved beside the meetings, so they stay until New chat (or Unpair) clears them:
+/// iOS restarting Yogurt in the background never takes them away.
@MainActor @Observable
final class AskSession {
- static let shared = AskSession()
+ static let shared = AskSession(file: URL.applicationSupportDirectory.appending(path: "Yogurt/ask.json"))
enum Where: Equatable {
/// on the same Wi-Fi as the computer, which answers
@@ -40,9 +41,9 @@ final class AskSession {
case nowhere
}
- struct Turn: Identifiable {
- enum State { case answering, answered(AskAnswer), failed }
- let id = UUID()
+ struct Turn: Identifiable, Codable {
+ enum State: Codable { case answering, answered(AskAnswer), failed }
+ var id = UUID()
let question: String
let scope: AskScope?
/// "All meetings", a folder's name, "This meeting"
@@ -51,13 +52,36 @@ final class AskSession {
}
/// each conversation's turns: Home's, and one per meeting asked about from its note
- private var conversations: [String: [Turn]] = [:]
+ private var conversations: [String: [Turn]] = [:] { didSet { save() } }
@ObservationIgnored private var reader: AskReader?
+ @ObservationIgnored private let file: URL
+
+ init(file: URL) {
+ self.file = file
+ let saved = (try? Data(contentsOf: file)).flatMap { try? JSONDecoder().decode([String: [Turn]].self, from: $0) } ?? [:]
+ // a question still being answered when Yogurt stopped can be asked again
+ conversations = saved.mapValues { $0.map { t in
+ var t = t
+ if case .answering = t.state { t.state = .failed }
+ return t
+ } }
+ }
func turns(_ key: String) -> [Turn] { conversations[key] ?? [] }
- /// Unpaired: the computer's answers and excerpts don't stay on screen.
- func clear() { conversations = [:] }
+ /// New chat: this conversation starts over. Only ever from a tap.
+ func newChat(_ key: String) { conversations[key] = nil }
+
+ /// Unpaired: the computer's answers and excerpts don't stay on screen, or on this iPhone.
+ func clear() {
+ conversations = [:]
+ try? FileManager.default.removeItem(at: file)
+ }
+
+ private func save() {
+ guard !conversations.isEmpty else { try? FileManager.default.removeItem(at: file); return }
+ try? JSONEncoder().encode(conversations).write(to: file, options: [.atomic, .completeFileProtectionUnlessOpen])
+ }
var busy: Bool { conversations.values.contains { $0.contains { if case .answering = $0.state { true } else { false } } } }
diff --git a/ios/Yogurt/Ask/AskStrings.swift b/ios/Yogurt/Ask/AskStrings.swift
index 78e3e6bb..e6760a27 100644
--- a/ios/Yogurt/Ask/AskStrings.swift
+++ b/ios/Yogurt/Ask/AskStrings.swift
@@ -23,7 +23,7 @@ extension S {
static let askSearchInstead = String(localized: "You can still search your meetings.")
static let searchMeetings = String(localized: "Search your meetings")
static let askSources = String(localized: "Sources")
- static let openNote = String(localized: "Open note")
+ static let newChat = String(localized: "New chat")
static let openInTranscript = String(localized: "Open in transcript")
static let notesSource = String(localized: "The meeting notes")
static let untitled = String(localized: "Untitled")
diff --git a/ios/Yogurt/Localizable.xcstrings b/ios/Yogurt/Localizable.xcstrings
index 33c4b325..9e3817c8 100644
--- a/ios/Yogurt/Localizable.xcstrings
+++ b/ios/Yogurt/Localizable.xcstrings
@@ -19532,6 +19532,202 @@
}
}
},
+ "New chat" : {
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "New chat"
+ }
+ },
+ "ar" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "محادثة جديدة"
+ }
+ },
+ "bn" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "নতুন কথোপকথন"
+ }
+ },
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nová konverzace"
+ }
+ },
+ "da" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ny samtale"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neue Unterhaltung"
+ }
+ },
+ "el" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Νέα συνομιλία"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nueva conversación"
+ }
+ },
+ "fi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uusi keskustelu"
+ }
+ },
+ "fil" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bagong pag-uusap"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nouvelle conversation"
+ }
+ },
+ "he" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "שיחה חדשה"
+ }
+ },
+ "hi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "नई बातचीत"
+ }
+ },
+ "hu" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Új beszélgetés"
+ }
+ },
+ "id" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Percakapan baru"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nuova conversazione"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "新しい会話"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "새 대화"
+ }
+ },
+ "ms" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Perbualan baharu"
+ }
+ },
+ "nb" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ny samtale"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nieuw gesprek"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nowa rozmowa"
+ }
+ },
+ "pt-BR" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nova conversa"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Conversație nouă"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Новая беседа"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nytt samtal"
+ }
+ },
+ "th" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "บทสนทนาใหม่"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yeni sohbet"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Нова розмова"
+ }
+ },
+ "vi" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cuộc trò chuyện mới"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "新对话"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "新對話"
+ }
+ }
+ }
+ },
"No folders yet. Make them on your computer." : {
"localizations" : {
"en" : {
@@ -23849,202 +24045,6 @@
}
}
},
- "Open note" : {
- "localizations" : {
- "en" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Open note"
- }
- },
- "ar" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "فتح الملاحظة"
- }
- },
- "bn" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "নোট খুলুন"
- }
- },
- "cs" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Otevřít poznámku"
- }
- },
- "da" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Åbn note"
- }
- },
- "de" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Notiz öffnen"
- }
- },
- "el" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Άνοιγμα σημείωσης"
- }
- },
- "es" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Abrir nota"
- }
- },
- "fi" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Avaa muistiinpano"
- }
- },
- "fil" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Buksan ang note"
- }
- },
- "fr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Ouvrir la note"
- }
- },
- "he" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "פתיחת ההערה"
- }
- },
- "hi" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "नोट खोलें"
- }
- },
- "hu" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Jegyzet megnyitása"
- }
- },
- "id" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Buka catatan"
- }
- },
- "it" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Apri nota"
- }
- },
- "ja" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "ノートを開く"
- }
- },
- "ko" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "노트 열기"
- }
- },
- "ms" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Buka nota"
- }
- },
- "nb" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Åpne notat"
- }
- },
- "nl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Notitie openen"
- }
- },
- "pl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Otwórz notatkę"
- }
- },
- "pt-BR" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Abrir nota"
- }
- },
- "ro" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Deschideți notița"
- }
- },
- "ru" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Открыть заметку"
- }
- },
- "sv" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Öppna anteckning"
- }
- },
- "th" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "เปิดโน้ต"
- }
- },
- "tr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Notu aç"
- }
- },
- "uk" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Відкрити нотатку"
- }
- },
- "vi" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Mở ghi chú"
- }
- },
- "zh-Hans" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "打开笔记"
- }
- },
- "zh-Hant" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "打開筆記"
- }
- }
- }
- },
"Pairing code" : {
"localizations" : {
"en" : {
diff --git a/ios/Yogurt/Views/AskView.swift b/ios/Yogurt/Views/AskView.swift
index 99e1da5d..8661deff 100644
--- a/ios/Yogurt/Views/AskView.swift
+++ b/ios/Yogurt/Views/AskView.swift
@@ -43,6 +43,16 @@ struct AskView: View {
.background(Theme.bg)
.navigationTitle(turns.isEmpty ? "" : S.ask)
.navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ if !turns.isEmpty {
+ ToolbarItem(placement: .topBarTrailing) {
+ Button { withAnimation(.easeOut(duration: 0.2)) { session.newChat(key) }; text = "" } label: {
+ Label(S.newChat, systemImage: "square.and.pencil")
+ }
+ .accessibilityIdentifier("ask-new-chat")
+ }
+ }
+ }
.safeAreaInset(edge: .bottom, spacing: 0) {
if answerer == .nowhere {
NavigationLink(value: Route.search) { Label(S.searchMeetings, systemImage: "magnifyingglass") }
@@ -245,7 +255,7 @@ private struct TurnView: View {
}
.font(.caption).foregroundStyle(Theme.muted)
.accessibilityElement(children: .combine)
- if !a.sources.isEmpty { SourcesView(sources: a.sources) }
+ if !a.sources.isEmpty { SourcesView(sources: a.sources, answer: a.text) }
}
}
}
@@ -295,20 +305,23 @@ private struct AnswerBody: View {
}
}
-/// The numbered sources; each opens its meeting, in the transcript at the moment when there is one.
+/// The numbered sources; each opens its meeting's transcript at the moment. The notes have no moment of their own:
+/// they open the transcript where it says what the answer took from them, else the notes.
private struct SourcesView: View {
let sources: [AskSource]
+ let answer: String
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(S.askSources).font(.footnote.weight(.medium)).foregroundStyle(Theme.muted).padding(.bottom, 4)
ForEach(sources) { s in
- NavigationLink(value: s.atMs.map { Route.transcript(s.meetingId, $0) } ?? Route.meeting(s.meetingId)) {
+ NavigationLink(value: s.atMs.map { Route.transcript(s.meetingId, $0) }
+ ?? Route.cited(s.meetingId, CitedMoment.claim(for: s.n, in: answer))) {
row(s)
}
.buttonStyle(RowButtonStyle())
.padding(.horizontal, -8)
- .accessibilityHint(s.atMs == nil ? S.openNote : S.openInTranscript)
+ .accessibilityHint(S.openInTranscript)
}
}
.padding(.top, 4)
diff --git a/ios/Yogurt/Views/HomeView.swift b/ios/Yogurt/Views/HomeView.swift
index c95fe36b..c180ed83 100644
--- a/ios/Yogurt/Views/HomeView.swift
+++ b/ios/Yogurt/Views/HomeView.swift
@@ -5,6 +5,8 @@ enum Route: Hashable {
case meeting(String)
/// a meeting's transcript, scrolled to this moment (ms)
case transcript(String, Int)
+ /// a meeting's transcript where it says this (an Ask answer's claim from the notes); the notes when it doesn't
+ case cited(String, String)
case search
/// Ask across meetings; with a meeting id, about that meeting first
case ask(String?)
@@ -28,6 +30,7 @@ struct HomeView: View {
switch route {
case .meeting(let id): NoteView(meetingId: id)
case .transcript(let id, let atMs): NoteView(meetingId: id, atMs: atMs)
+ case .cited(let id, let claim): NoteView(meetingId: id, claim: claim)
case .search: SearchView(open: { path.append(.meeting($0)) })
case .ask(let id): AskView(meetingId: id)
}
diff --git a/ios/Yogurt/Views/NoteView.swift b/ios/Yogurt/Views/NoteView.swift
index e17e2939..8fe73d09 100644
--- a/ios/Yogurt/Views/NoteView.swift
+++ b/ios/Yogurt/Views/NoteView.swift
@@ -9,6 +9,10 @@ struct NoteView: View {
let meetingId: String
/// opened from an Ask source: the transcript, at this moment (ms)
var atMs: Int? = nil
+ /// opened from an Ask source that is the notes: the transcript where it says this, else the notes
+ var claim: String? = nil
+ /// where the transcript says the claim; looked up before the note shows, so it opens there without a flash
+ @State private var found: Int?
@Environment(AppModel.self) private var model
@Environment(\.dismiss) private var dismiss
@State private var tab: Tab?
@@ -42,8 +46,15 @@ struct NoteView: View {
.background(Theme.bg)
.navigationBarTitleDisplayMode(.inline)
.overlay(alignment: .bottom) { toastView }
- .task(id: revision) { loaded = await model.reader.note(meetingId) }
- .task(id: connected) { player.load(meetingId: meetingId, model: model, startAt: atMs) }
+ .task(id: revision) {
+ let note = await model.reader.note(meetingId)
+ if loaded == nil, let claim { found = await model.reader.moment(meetingId, claim: claim) }
+ loaded = note
+ }
+ // once the note is read, so a moment found for an Ask source is where the audio starts
+ .task(id: [connected, loaded != nil]) {
+ if loaded != nil { player.load(meetingId: meetingId, model: model, startAt: moment) }
+ }
// leaving the note ends its audio. Going to the background doesn't pause what is playing (the audio mode is on);
// what isn't playing never starts.
.onDisappear { player.stop() }
@@ -58,6 +69,8 @@ struct NoteView: View {
}
}
+ private var moment: Int? { atMs ?? found }
+
private func content(_ meeting: Meeting, _ loaded: StoreReader.Note) -> some View {
let notes = loaded.notes
let folders = loaded.folders
@@ -73,7 +86,7 @@ struct NoteView: View {
case .summary: SummaryPane(notes: notes)
case .mine: MyNotesPane(meetingId: meetingId, latest: notes?.mine ?? "")
case .transcript: TranscriptPane(meetingId: meetingId, oneMic: meeting.oneMic,
- atMs: tab == nil ? atMs : nil, proxy: proxy, player: player)
+ atMs: tab == nil ? moment : nil, proxy: proxy, player: player)
}
}
.padding(.top, 24)
@@ -170,7 +183,7 @@ struct NoteView: View {
}
private func defaultTab(_ notes: Notes?) -> Tab {
- if atMs != nil { return .transcript }
+ if moment != nil { return .transcript }
// a phone recording opens on its notes being written
if notes?.summary?.isEmpty == false || notes?.summarySource == .phoneDraft { return .summary }
return .mine
diff --git a/ios/Yogurt/YogurtApp.swift b/ios/Yogurt/YogurtApp.swift
index f80cfed2..9063de6e 100644
--- a/ios/Yogurt/YogurtApp.swift
+++ b/ios/Yogurt/YogurtApp.swift
@@ -75,6 +75,9 @@ actor StoreReader {
func segments(_ id: String) -> [Segment] { store.segments(id) }
+ /// where a meeting's transcript says what an Ask answer took from its notes
+ func moment(_ id: String, claim: String) -> Int? { CitedMoment.atMs(claim: claim, segments: store.segments(id)) }
+
func search(_ query: String, limit: Int) -> [Found] {
store.search(query, limit: limit).map { Found(hit: $0, startedAt: store.meeting($0.meetingId)?.startedAt) }
}
diff --git a/ios/YogurtKit/Sources/YogurtKit/Ask/CitedMoment.swift b/ios/YogurtKit/Sources/YogurtKit/Ask/CitedMoment.swift
new file mode 100644
index 00000000..4e81525b
--- /dev/null
+++ b/ios/YogurtKit/Sources/YogurtKit/Ask/CitedMoment.swift
@@ -0,0 +1,35 @@
+import Foundation
+
+/// Where in the transcript an answer's claim was said, for a source that is a meeting's notes: the notes have no
+/// moment of their own, so tapping one opens the transcript at the line that says the same thing.
+public enum CitedMoment {
+ /// The answer's sentences that cite [n], without their citations or bold marks.
+ public static func claim(for n: Int, in answer: String) -> String {
+ let lines = answer.components(separatedBy: "\n").map { $0.trimmingCharacters(in: .whitespaces).replacing(/^([-*]|\d+\.)\s+/, with: "") }
+ // a sentence ends at . ! or ? and the space after it
+ let sentences: [String] = lines.flatMap { $0.replacing(/([.!?])\s+/) { "\($0.output.1)\n" }.components(separatedBy: "\n") }
+ return sentences.filter { citedNumbers($0).contains(n) }.map(plain).filter { !$0.isEmpty }.joined(separator: " ")
+ }
+
+ private static func plain(_ sentence: String) -> String {
+ sentence.replacing(/\[\d+(?:\s*,\s*\d+)*\]/, with: "").replacingOccurrences(of: "**", with: "")
+ .replacing(/\s+([.,;:!?])/) { String($0.output.1) }
+ .trimmingCharacters(in: .whitespaces)
+ }
+
+ /// The start of the line sharing the most of the claim's words, its neighbours breaking ties. Nil when no line
+ /// and its neighbours share at least two of them: a guess that far off would be worse than the notes.
+ public static func atMs(claim: String, segments: [Segment]) -> Int? {
+ let terms = LocalAsk.searchTerms(claim)
+ guard terms.count >= 2 else { return nil }
+ let found = segments.map { s in Set(terms.filter { s.text.lowercased().contains($0) }) }
+ var best: (i: Int, score: Double)?
+ for i in found.indices where !found[i].isEmpty {
+ let around = (i > 0 ? found[i - 1] : []).union(i + 1 < found.count ? found[i + 1] : []).subtracting(found[i])
+ guard found[i].count + around.count >= 2 else { continue }
+ let score = Double(found[i].count) + 0.5 * Double(around.count)
+ if score > best?.score ?? 0 { best = (i, score) }
+ }
+ return best.map { segments[$0.i].startMs }
+ }
+}
diff --git a/ios/YogurtKit/Sources/YogurtKit/Ask/LocalAsk.swift b/ios/YogurtKit/Sources/YogurtKit/Ask/LocalAsk.swift
index 5ed83223..834392c9 100644
--- a/ios/YogurtKit/Sources/YogurtKit/Ask/LocalAsk.swift
+++ b/ios/YogurtKit/Sources/YogurtKit/Ask/LocalAsk.swift
@@ -13,7 +13,7 @@ public struct AskPassage: Sendable, Hashable {
}
/// What a [n] in an answer points at.
-public struct AskSource: Sendable, Hashable, Identifiable {
+public struct AskSource: Sendable, Hashable, Identifiable, Codable {
public var n: Int
public var meetingId: String
public var title: String
@@ -24,8 +24,8 @@ public struct AskSource: Sendable, Hashable, Identifiable {
}
/// An answer across meetings, its citations numbered 1, 2… in the order they first show, each matching a source.
-public struct AskAnswer: Sendable, Hashable {
- public enum By: Sendable, Hashable { case phone, computer }
+public struct AskAnswer: Sendable, Hashable, Codable {
+ public enum By: Sendable, Hashable, Codable { case phone, computer }
public var text: String
public var sources: [AskSource]
public var by: By
diff --git a/ios/YogurtKit/Tests/YogurtKitTests/CitedMomentTests.swift b/ios/YogurtKit/Tests/YogurtKitTests/CitedMomentTests.swift
new file mode 100644
index 00000000..6472c5f7
--- /dev/null
+++ b/ios/YogurtKit/Tests/YogurtKitTests/CitedMomentTests.swift
@@ -0,0 +1,39 @@
+import Foundation
+import Testing
+@testable import YogurtKit
+
+private func line(_ i: Int, _ text: String) -> Segment {
+ Segment(index: i, startMs: i * 30_000, endMs: i * 30_000 + 25_000, speaker: nil, text: text)
+}
+
+@Suite struct CitedMomentTests {
+ @Test func theClaimIsTheSentencesThatCiteTheNumber() {
+ let answer = "Acme pays **40 dollars a seat** [1]. Two engineers start in March [2].\n- The renewal is due in May [1, 2]"
+ #expect(CitedMoment.claim(for: 1, in: answer) == "Acme pays 40 dollars a seat. The renewal is due in May")
+ #expect(CitedMoment.claim(for: 2, in: answer) == "Two engineers start in March. The renewal is due in May")
+ #expect(CitedMoment.claim(for: 3, in: answer) == "")
+ }
+
+ @Test func findsWhereTheClaimWasSaid() {
+ let lines = [
+ line(0, "Hello everyone, thanks for joining."),
+ line(1, "Let's talk about the hiring plan first."),
+ line(2, "Acme asked for a discount on the renewal."),
+ line(3, "We agreed on forty dollars a seat for Acme."),
+ line(4, "Great, see you next week."),
+ ]
+ #expect(CitedMoment.atMs(claim: "Acme pays forty dollars a seat for the renewal", segments: lines) == 90_000)
+ }
+
+ @Test func nothingWhenTheTranscriptDoesNotSayIt() {
+ let lines = [line(0, "Hello everyone."), line(1, "The tacos were great.")]
+ #expect(CitedMoment.atMs(claim: "Acme pays forty dollars a seat", segments: lines) == nil)
+ #expect(CitedMoment.atMs(claim: "Acme pays forty dollars a seat", segments: []) == nil)
+ #expect(CitedMoment.atMs(claim: "", segments: lines) == nil)
+ }
+
+ @Test func oneSharedWordIsNotEnough() {
+ let lines = [line(0, "Acme called."), line(1, "Lunch was late.")]
+ #expect(CitedMoment.atMs(claim: "Acme pays forty dollars a seat", segments: lines) == nil)
+ }
+}
diff --git a/ios/project.yml b/ios/project.yml
index 56d89fbb..88ec56ac 100644
--- a/ios/project.yml
+++ b/ios/project.yml
@@ -15,7 +15,7 @@ settings:
DEVELOPMENT_TEAM: 2JNSQVN3N8
CODE_SIGN_STYLE: Automatic
MARKETING_VERSION: "0.1.0"
- CURRENT_PROJECT_VERSION: "8"
+ CURRENT_PROJECT_VERSION: "9"
targets:
Yogurt:
type: application