4c086251d9
Native editor to fix speaker-ID errors after transcription (modeled on recap-relay's correction UX): rename a speaker in the legend, merge two speakers, or reassign an individual transcript line. Saving rewrites speakers.json, re-renders transcript.md + recap.html, and updates the voiceprint memory — so a correction compounds: naming an "Unknown" speaker teaches that voice for future calls. - SpeakerEditing (pure, tested): replaceSpeaker (rename = merge-onto-existing), reassign, netNameMap (compose ops), and remap (apply a name map to a recap's structured fields + whole-word free text, so summaries/extras update without re-LLM). - RecapEditModel (@MainActor): loads speakers.json (+ optional recap.json + cluster_fingerprints.json); on save writes the resolved speakers.json, re-renders, and reconciles voiceprints — merge keeps the survivor's print; rename/name-an-Unknown enrolls the cluster's fingerprint under the new name. - TranscriptEditorView (SwiftUI) + EditorWindow (AppKit window for the LSUIElement app); menu gains "Edit speakers". - Pipeline now persists cluster_fingerprints.json (every cluster incl. Unknown) and recap.json (RecapFile) so the editor can learn voices + re-render offline. - RecapModels made Codable; TranscriptAssembler exposes allFingerprints; VoiceprintStore gains enroll() + merge(). 52/52 XCTest (6 new, incl. a full rename→artifacts→voiceprint round-trip on disk).
33 lines
1.2 KiB
Swift
33 lines
1.2 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// Hosts the speaker-correction editor in a standalone resizable window. A
|
|
/// menu-bar (LSUIElement) app has no normal window scene, so we open one via
|
|
/// AppKit and activate the app so it comes to the front.
|
|
@MainActor
|
|
final class EditorWindow {
|
|
static let shared = EditorWindow()
|
|
private var window: NSWindow?
|
|
|
|
func show(model: RecapEditModel) {
|
|
if let window {
|
|
window.contentViewController = NSHostingController(rootView: TranscriptEditorView(model: model))
|
|
window.title = model.title
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
window.makeKeyAndOrderFront(nil)
|
|
return
|
|
}
|
|
let w = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 640, height: 560),
|
|
styleMask: [.titled, .closable, .resizable, .miniaturizable],
|
|
backing: .buffered, defer: false)
|
|
w.title = model.title
|
|
w.isReleasedWhenClosed = false
|
|
w.center()
|
|
w.contentViewController = NSHostingController(rootView: TranscriptEditorView(model: model))
|
|
window = w
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
w.makeKeyAndOrderFront(nil)
|
|
}
|
|
}
|