Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions HOW_TO_RUN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to Run OpenSuperWhisper with Cleanup Feature

## Method 1: Run attached to terminal (requires keeping terminal open)
```bash
cd /Users/brandoncharleson/Documents/DeveloperProjects/OpenSuperWhisper
./run.sh run
```

## Method 2: Run independently (can close terminal after launch)
```bash
cd /Users/brandoncharleson/Documents/DeveloperProjects/OpenSuperWhisper
nohup ./build/Build/Products/Debug/OpenSuperWhisper.app/Contents/MacOS/OpenSuperWhisper > /dev/null 2>&1 &
```

## Method 3: Launch as macOS app (simplest)
```bash
cd /Users/brandoncharleson/Documents/DeveloperProjects/OpenSuperWhisper
open ./build/Build/Products/Debug/OpenSuperWhisper.app
```

## To stop the app
```bash
killall OpenSuperWhisper
```

## Features Added
- ✅ Automatic Recording Cleanup
- ✅ Storage Usage Display
- ✅ Manual Cleanup with "Clean Now" button
- ✅ Configurable cleanup intervals
- ✅ Safety confirmations and progress indicators
8 changes: 8 additions & 0 deletions OpenSuperWhisper/Models/Recording.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class RecordingStore: ObservableObject {
do {
try await insertRecording(recording)
await loadRecordings()
notifyRecordingsChanged()
} catch {
print("Failed to add recording: \(error)")
}
Expand All @@ -121,6 +122,7 @@ class RecordingStore: ObservableObject {
try await deleteRecordingFromDB(recording)
try FileManager.default.removeItem(at: recording.url)
await loadRecordings()
notifyRecordingsChanged()
} catch {
print("Failed to delete recording: \(error)")
await loadRecordings()
Expand All @@ -145,6 +147,7 @@ class RecordingStore: ObservableObject {
// Then clear the database
try await deleteAllRecordingsFromDB()
await loadRecordings()
notifyRecordingsChanged()
} catch {
print("Failed to delete all recordings: \(error)")
}
Expand All @@ -157,6 +160,11 @@ class RecordingStore: ObservableObject {
}
}

/// Notify observers that recordings have changed
private func notifyRecordingsChanged() {
NotificationCenter.default.post(name: NSNotification.Name("RecordingsChanged"), object: nil)
}

func searchRecordings(query: String) -> [Recording] {
// For search, we'll keep it synchronous since it's used directly in UI
// and we want immediate results
Expand Down
26 changes: 23 additions & 3 deletions OpenSuperWhisper/OpenSuperWhisperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,35 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
private var mainWindow: NSWindow?

func applicationDidFinishLaunching(_ notification: Notification) {

setupStatusBarItem()


// Delayed cleanup check to avoid blocking startup
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
Task {
_ = await RecordingCleanupService.shared.performCleanup()
}
}

if let window = NSApplication.shared.windows.first {
self.mainWindow = window

window.delegate = self
}
}

func applicationWillTerminate(_ notification: Notification) {
// Quick cleanup check on termination (with timeout)
let semaphore = DispatchSemaphore(value: 0)

Task {
_ = await RecordingCleanupService.shared.performCleanup()
semaphore.signal()
}

// Wait up to 2 seconds for cleanup to complete
_ = semaphore.wait(timeout: .now() + 2.0)
}

private func setupStatusBarItem() {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
Expand Down
Loading
Loading