Skip to content

Commit 94735c5

Browse files
committed
refactor: delete unused code
Was poking around the codebase and saw some weird code. This commit cleans it up
1 parent f6a047c commit 94735c5

File tree

12 files changed

+13
-44
lines changed

12 files changed

+13
-44
lines changed

Dayflow/Dayflow/Core/AI/GeminiDirectProvider.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Foundation
77

88
final class GeminiDirectProvider: LLMProvider {
99
private let apiKey: String
10-
private let genEndpoint = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent"
1110
private let fileEndpoint = "https://generativelanguage.googleapis.com/upload/v1beta/files"
1211
private let proModel = "gemini-2.5-pro"
1312
private let flashModel = "gemini-2.5-flash"
@@ -317,7 +316,6 @@ final class GeminiDirectProvider: LLMProvider {
317316
var lastError: Error?
318317
var finalResponse = ""
319318
var finalObservations: [Observation] = []
320-
var finalUsedModel = proModel
321319

322320
// Model state for Flash fallback (persists across retries)
323321
var currentModel = proModel
@@ -387,7 +385,6 @@ final class GeminiDirectProvider: LLMProvider {
387385
print("✅ Video transcription succeeded on attempt \(attempt + 1)")
388386
finalResponse = response
389387
finalObservations = observations
390-
finalUsedModel = usedModel
391388
break
392389

393390
} catch {
@@ -548,8 +545,6 @@ final class GeminiDirectProvider: LLMProvider {
548545
let existingCardsJSON = try encoder.encode(context.existingCards)
549546
let existingCardsString = String(data: existingCardsJSON, encoding: .utf8) ?? "[]"
550547

551-
let exampleCategory = context.categories.first?.name ?? "Work"
552-
553548
let basePrompt = """
554549
You are a digital anthropologist, observing a user's raw activity log. Your goal is to synthesize this log into a high-level, human-readable story of their session, presented as a series of timeline cards.
555550
THE GOLDEN RULE:
@@ -1165,7 +1160,7 @@ private func uploadResumable(data: Data, mimeType: String) async throws -> Strin
11651160
// Prepare logging context
11661161
let responseHeaders: [String:String] = httpResponse.allHeaderFields.reduce(into: [:]) { acc, kv in
11671162
if let k = kv.key as? String, let v = kv.value as? CustomStringConvertible { acc[k] = v.description }
1168-
} ?? [:]
1163+
}
11691164
let modelName: String? = {
11701165
if let u = URL(string: urlWithKey) {
11711166
let last = u.path.split(separator: "/").last.map(String.init)
@@ -1475,7 +1470,7 @@ private func uploadResumable(data: Data, mimeType: String) async throws -> Strin
14751470
// Prepare logging context
14761471
let responseHeaders: [String:String] = httpResponse.allHeaderFields.reduce(into: [:]) { acc, kv in
14771472
if let k = kv.key as? String, let v = kv.value as? CustomStringConvertible { acc[k] = v.description }
1478-
} ?? [:]
1473+
}
14791474
let modelName: String? = {
14801475
if let u = URL(string: urlWithKey) {
14811476
let last = u.path.split(separator: "/").last.map(String.init)

Dayflow/Dayflow/Core/AI/LLMService.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,11 @@ final class LLMService: LLMServicing {
179179
throw NSError(domain: "LLMService", code: 6, userInfo: [NSLocalizedDescriptionKey: "Failed to create composition track"])
180180
}
181181

182-
for (index, filePath) in chunkFiles.enumerated() {
182+
for (_, filePath) in chunkFiles.enumerated() {
183183
let url = URL(fileURLWithPath: filePath)
184184

185185
let asset = AVAsset(url: url)
186186
let duration = try await asset.load(.duration)
187-
let durationSeconds = CMTimeGetSeconds(duration)
188187

189188

190189
if let track = try await asset.loadTracks(withMediaType: .video).first {
@@ -216,7 +215,7 @@ final class LLMService: LLMServicing {
216215
// Get batch start time for timestamp conversion
217216
let batchStartDate = Date(timeIntervalSince1970: TimeInterval(batchStartTs))
218217

219-
let (observations, transcribeLog) = try await provider.transcribeVideo(
218+
let (observations, _) = try await provider.transcribeVideo(
220219
videoData: videoData,
221220
mimeType: mimeType,
222221
prompt: "Transcribe this video", // Provider will use its own prompt
@@ -292,7 +291,7 @@ final class LLMService: LLMServicing {
292291
)
293292

294293
// Generate activity cards using sliding window observations
295-
let (cards, cardsLog) = try await provider.generateActivityCards(
294+
let (cards, _) = try await provider.generateActivityCards(
296295
observations: recentObservations,
297296
context: context,
298297
batchId: batchId

Dayflow/Dayflow/Core/AI/OllamaProvider.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ final class OllamaProvider: LLMProvider {
5757
// Step 1: Extract frames at intervals
5858
let extractionStart = Date()
5959
let frames = try await extractFrames(from: tempURL)
60-
let extractionTime = Date().timeIntervalSince(extractionStart)
6160

6261

6362
// Step 2: Get simple descriptions for each frame
@@ -77,7 +76,6 @@ final class OllamaProvider: LLMProvider {
7776
videoDuration: videoDuration,
7877
batchId: batchId
7978
)
80-
let mergeTime = Date().timeIntervalSince(mergeStart)
8179

8280

8381
let totalTime = Date().timeIntervalSince(callStart)
@@ -428,7 +426,7 @@ final class OllamaProvider: LLMProvider {
428426
}
429427

430428
// Build message content with image and text
431-
var content: [MessageContent] = [
429+
let content: [MessageContent] = [
432430
MessageContent(type: "text", text: prompt, image_url: nil),
433431
MessageContent(type: "image_url", text: nil, image_url: MessageContent.ImageURL(url: "data:image/jpeg;base64,\(base64String)"))
434432
]
@@ -494,7 +492,6 @@ final class OllamaProvider: LLMProvider {
494492
)
495493
ctxForAttempt = ctx
496494
let (data, response) = try await URLSession.shared.data(for: urlRequest)
497-
let apiTime = Date().timeIntervalSince(apiStart)
498495

499496
guard let httpResponse = response as? HTTPURLResponse else {
500497
throw NSError(domain: "OllamaProvider", code: 4, userInfo: [NSLocalizedDescriptionKey: "Invalid response"])

Dayflow/Dayflow/Core/Analysis/AnalysisManager.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ final class AnalysisManager: AnalysisManaging {
113113

114114
// 6. Process each batch sequentially
115115
var processedCount = 0
116-
var hasError = false
116+
let hasError = false
117117

118118
for (index, batchId) in batchIds.enumerated() {
119119
if hasError { break }
@@ -125,9 +125,6 @@ final class AnalysisManager: AnalysisManaging {
125125
progressHandler("Processing batch \(index + 1) of \(batchIds.count)... (Total elapsed: \(self.formatDuration(elapsedTotal)))")
126126
}
127127

128-
// Use a semaphore to wait for each batch to complete
129-
let semaphore = DispatchSemaphore(value: 0)
130-
131128
self.queueGeminiRequest(batchId: batchId)
132129

133130
// Wait for batch to complete (check status periodically)
@@ -245,10 +242,8 @@ final class AnalysisManager: AnalysisManaging {
245242

246243
// Process batches
247244
var processedCount = 0
248-
var hasError = false
249245

250246
for (index, batchId) in batchIds.enumerated() {
251-
if hasError { break }
252247

253248
let batchStartTime = Date()
254249
let elapsedTotal = Date().timeIntervalSince(overallStartTime)
@@ -261,7 +256,7 @@ final class AnalysisManager: AnalysisManaging {
261256

262257
// Wait for batch to complete (check status periodically)
263258
var isCompleted = false
264-
while !isCompleted && !hasError {
259+
while !isCompleted {
265260
Thread.sleep(forTimeInterval: 2.0) // Check every 2 seconds
266261

267262
let allBatches = self.store.allBatches()
@@ -354,14 +349,6 @@ final class AnalysisManager: AnalysisManaging {
354349

355350
updateBatchStatus(batchId: batchId, status: "processing")
356351

357-
// Prepare file URLs for video processing
358-
let chunkFileURLs: [URL] = chunksInBatch.compactMap { chunk in
359-
// Assuming chunk.fileUrl is a String path, convert to URL
360-
// Ensure this path is accessible. If it's a relative path, resolve it.
361-
// For now, assuming it's an absolute file path string.
362-
URL(fileURLWithPath: chunk.fileUrl)
363-
}
364-
365352
llmService.processBatch(batchId) { [weak self] (result: Result<ProcessedBatchResult, Error>) in
366353
guard let self else { return }
367354

Dayflow/Dayflow/Core/Recording/ScreenRecorder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ final class ScreenRecorder: NSObject, SCStreamOutput {
446446
guard type == .screen else { return }
447447
guard CMSampleBufferDataIsReady(sb) else { return }
448448
guard isComplete(sb) else { return }
449-
if let pb = CMSampleBufferGetImageBuffer(sb) {
449+
if CMSampleBufferGetImageBuffer(sb) != nil {
450450
// TEMPORARILY DISABLED to test if this causes corruption
451451
// overlayClock(on: pb) // ← inject the clock into this frame
452452
}
@@ -455,7 +455,7 @@ final class ScreenRecorder: NSObject, SCStreamOutput {
455455

456456
if firstPTS == nil {
457457
firstPTS = sb.presentationTimeStamp
458-
let started = w.startWriting()
458+
assert(w.startWriting())
459459
w.startSession(atSourceTime: firstPTS!)
460460
}
461461

Dayflow/Dayflow/Core/Recording/StorageManager.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,6 @@ final class StorageManager: StorageManaging, @unchecked Sendable {
915915
OR (start_ts >= ? AND start_ts < ?)
916916
""", arguments: [toTs, fromTs, fromTs, toTs])
917917

918-
for card in cardsToDelete {
919-
let id: Int64 = card["id"]
920-
let start: String = card["start"]
921-
let end: String = card["end"]
922-
let title: String = card["title"]
923-
}
924918

925919
// Delete existing cards in the range using timestamp columns
926920
try db.execute(sql: """

Dayflow/Dayflow/Core/Recording/VideoProcessingService.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ actor VideoProcessingService {
271271
let actualSize = naturalSize.applying(preferredTransform)
272272
let width = Int(abs(actualSize.width))
273273
let height = Int(abs(actualSize.height))
274-
let nominalFrameRate = try await assetTrack.load(.nominalFrameRate)
275274

276275
// Create composition with time mapping for speedup
277276
let composition = AVMutableComposition()

Dayflow/Dayflow/Core/Thumbnails/ThumbnailCache.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ final class ThumbnailCache {
5656

5757
queue.addOperation { [weak self] in
5858
guard let self = self else { return }
59-
let t0 = CFAbsoluteTimeGetCurrent()
6059
let image = self.generateThumbnail(urlString: normalizedURL, targetSize: targetSize)
6160

6261
if let image = image {

Dayflow/Dayflow/System/AnalyticsService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final class AnalyticsService {
5151
registerInitialSuperProperties()
5252

5353
// Person properties via $set / $set_once
54-
var set: [String: Any] = [
54+
let set: [String: Any] = [
5555
"analytics_opt_in": isOptedIn
5656
]
5757
var payload: [String: Any] = ["$set": sanitize(set)]

Dayflow/Dayflow/System/SilentUserDriver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class SilentUserDriver: NSObject, SPUUserDriver {
1919
}
2020

2121
func showUpdateFound(with appcastItem: SUAppcastItem, state: SPUUserUpdateState, reply: @escaping (SPUUserUpdateChoice) -> Void) {
22-
print("[Sparkle] Update found: \(appcastItem.displayVersionString ?? appcastItem.versionString)")
22+
print("[Sparkle] Update found: \(appcastItem.displayVersionString)")
2323
// Always proceed to install
2424
reply(.install)
2525
}

0 commit comments

Comments
 (0)