From ebad2c42d00bab692b1c1c2aefda85a1de213ef0 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Sun, 28 Dec 2025 18:47:23 +0545 Subject: [PATCH] Fix retranscribe functionality in history window - Pass WhisperState to HistoryWindowController for transcription services - Update MenuBarManager to store and pass WhisperState reference - Ensure all transcription providers work in separate history window --- VoiceInk/HistoryWindowController.swift | 7 ++++--- VoiceInk/MenuBarManager.swift | 14 ++++++++++---- VoiceInk/Views/ContentView.swift | 9 ++++----- VoiceInk/VoiceInk.swift | 4 +--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/VoiceInk/HistoryWindowController.swift b/VoiceInk/HistoryWindowController.swift index 845f385..457155b 100644 --- a/VoiceInk/HistoryWindowController.swift +++ b/VoiceInk/HistoryWindowController.swift @@ -13,22 +13,23 @@ class HistoryWindowController: NSObject, NSWindowDelegate { super.init() } - func showHistoryWindow(modelContainer: ModelContainer) { + func showHistoryWindow(modelContainer: ModelContainer, whisperState: WhisperState) { if let existingWindow = historyWindow, existingWindow.isVisible { existingWindow.makeKeyAndOrderFront(nil) NSApplication.shared.activate(ignoringOtherApps: true) return } - let window = createHistoryWindow(modelContainer: modelContainer) + let window = createHistoryWindow(modelContainer: modelContainer, whisperState: whisperState) historyWindow = window window.makeKeyAndOrderFront(nil) NSApplication.shared.activate(ignoringOtherApps: true) } - private func createHistoryWindow(modelContainer: ModelContainer) -> NSWindow { + private func createHistoryWindow(modelContainer: ModelContainer, whisperState: WhisperState) -> NSWindow { let historyView = TranscriptionHistoryView() .modelContainer(modelContainer) + .environmentObject(whisperState) .frame(minWidth: 800, minHeight: 600) let hostingController = NSHostingController(rootView: historyView) diff --git a/VoiceInk/MenuBarManager.swift b/VoiceInk/MenuBarManager.swift index ce51475..56d9ea2 100644 --- a/VoiceInk/MenuBarManager.swift +++ b/VoiceInk/MenuBarManager.swift @@ -11,14 +11,16 @@ class MenuBarManager: ObservableObject { } private var modelContainer: ModelContainer? + private var whisperState: WhisperState? init() { self.isMenuBarOnly = UserDefaults.standard.bool(forKey: "IsMenuBarOnly") updateAppActivationPolicy() } - func configure(modelContainer: ModelContainer) { + func configure(modelContainer: ModelContainer, whisperState: WhisperState) { self.modelContainer = modelContainer + self.whisperState = whisperState } func toggleMenuBarOnly() { @@ -84,10 +86,14 @@ class MenuBarManager: ObservableObject { } func openHistoryWindow() { - guard let modelContainer = modelContainer else { - print("MenuBarManager: ModelContainer not configured") + guard let modelContainer = modelContainer, + let whisperState = whisperState else { + print("MenuBarManager: Dependencies not configured") return } - HistoryWindowController.shared.showHistoryWindow(modelContainer: modelContainer) + HistoryWindowController.shared.showHistoryWindow( + modelContainer: modelContainer, + whisperState: whisperState + ) } } diff --git a/VoiceInk/Views/ContentView.swift b/VoiceInk/Views/ContentView.swift index ea3a3e7..be1a8b8 100644 --- a/VoiceInk/Views/ContentView.swift +++ b/VoiceInk/Views/ContentView.swift @@ -107,10 +107,10 @@ struct ContentView: View { ForEach(visibleViewTypes) { viewType in Section { if viewType == .history { - // History opens in separate window instead of inline Button(action: { HistoryWindowController.shared.showHistoryWindow( - modelContainer: modelContext.container + modelContainer: modelContext.container, + whisperState: whisperState ) }) { HStack(spacing: 12) { @@ -175,9 +175,9 @@ struct ContentView: View { case "VoiceInk Pro": selectedView = .license case "History": - // Open History in separate window instead of inline HistoryWindowController.shared.showHistoryWindow( - modelContainer: modelContext.container + modelContainer: modelContext.container, + whisperState: whisperState ) case "Permissions": selectedView = .permissions @@ -206,7 +206,6 @@ struct ContentView: View { case .transcribeAudio: AudioTranscribeView() case .history: - // History now opens in separate window, not shown inline Text("History") .foregroundColor(.secondary) case .audioInput: diff --git a/VoiceInk/VoiceInk.swift b/VoiceInk/VoiceInk.swift index 71dacac..ff32b05 100644 --- a/VoiceInk/VoiceInk.swift +++ b/VoiceInk/VoiceInk.swift @@ -108,9 +108,7 @@ struct VoiceInkApp: App { let menuBarManager = MenuBarManager() _menuBarManager = StateObject(wrappedValue: menuBarManager) - - // Configure MenuBarManager with ModelContainer for window management - menuBarManager.configure(modelContainer: container) + menuBarManager.configure(modelContainer: container, whisperState: whisperState) let activeWindowService = ActiveWindowService.shared activeWindowService.configure(with: enhancementService)