YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(timeline): allow returning from pending days
Louis Beaumont36e651887243
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swiftindex 7b53a9f78..e6fc5df4d 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift@@ -228,6 +228,7 @@ final class TimelineViewModel: ObservableObject {private var imageLoadToken = 0private var requestedDays = Set<String>()private var tagFetchInFlight = Set<String>()+ private var navigationGeneration = 0/// Native actions must return to the webview that owns this model. Looking/// up the current key window is racy because the fullscreen overlay is a@@ -747,10 +748,17 @@ final class TimelineViewModel: ObservableObject {func jumpDay(_ delta: Int) {let target = TimelineDateNavigation.jumpDay(from: currentDate, delta: delta)- changeDate(to: target)+ // An older/empty day may never yield a frame batch, so its navigation+ // guard must not trap the user there. Moving forward supersedes that+ // pending request; moving further backward stays guarded to avoid a+ // queue of overlapping historical requests.+ changeDate(to: target, supersedePendingNavigation: delta > 0)}func jumpToNow() {+ // Invalidate any pending historical navigation timeout so it cannot+ // later clear loading state for this current-day request.+ navigationGeneration += 1isNavigating = falsecurrentDate = Date()currentIndex = 0@@ -758,8 +766,10 @@ final class TimelineViewModel: ObservableObject {loadCurrentImage()}- func changeDate(to date: Date) {- guard !isNavigating else { return }+ func changeDate(to date: Date, supersedePendingNavigation: Bool = false) {+ guard !isNavigating || supersedePendingNavigation else { return }+ navigationGeneration += 1+ let generation = navigationGenerationisNavigating = truepause()resetFilters()@@ -771,7 +781,7 @@ final class TimelineViewModel: ObservableObject {requestDay(date)// Never leave the spinner up forever if the day query stalls.DispatchQueue.main.asyncAfter(deadline: .now() + TimelineDateNavigation.navigationTimeout) { [weak self] in- guard let self else { return }+ guard let self, self.navigationGeneration == generation else { return }self.isNavigating = falseself.isLoading = false}diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swiftindex 91c4051a6..5acff9d92 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift@@ -446,7 +446,9 @@ struct TimelineControlBar: View {Image(systemName: "chevron.right")}.buttonStyle(TimelineControlStyle())- .disabled(model.isNavigating || model.isAtToday)+ // Forward navigation is the escape hatch from a slow/empty older+ // day, so it remains clickable while that request is pending.+ .disabled(model.isAtToday).help("Next day")Button { model.jumpToNow() } label: {diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline_render_tests.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline_render_tests.swiftindex 8cdedd042..c663a77e0 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline_render_tests.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline_render_tests.swift@@ -547,11 +547,23 @@ private func testDateNavigation() {expect(model.frames.isEmpty, "changing date clears the previous day's frames")expect(model.isNavigating, "day navigation stays guarded while its batch is pending")+ // A slow or empty older day has no batch to acknowledge the request. The+ // forward arrow must still return to today instead of staying disabled for+ // the navigation timeout.+ model.jumpDay(1)+ expect(model.isAtToday, "next day supersedes a pending previous-day request")+ expect(model.isNavigating, "the replacement current-day request is now pending")++ model.jumpDay(-1)+ expect(model.isAtToday, "backward navigation stays guarded while the replacement is pending")+model.injectForTesting(frames: fixtureFrames(count: 4, base: model.currentDate))expect(!model.isNavigating, "the requested day batch acknowledges navigation")+ model.jumpDay(-1)+ model.injectForTesting(frames: fixtureFrames(count: 4, base: model.currentDate))model.jumpDay(1)- expect(model.isAtToday, "next day works immediately after the previous day loads")+ expect(model.isAtToday, "next day also works after the previous day loads")model.jumpToNow()expect(Calendar.current.isDate(model.currentDate, inSameDayAs: today), "jump to now returns to today")