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
This commit is contained in:
parent
d2dd506a94
commit
ebad2c42d0
@ -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)
|
||||
|
||||
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user