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): isolate summaries and anchor previews
Louis Beaumont1dcff8ed99dd
diff --git a/apps/screenpipe-app-tauri/components/rewind/native-timeline.test.tsx b/apps/screenpipe-app-tauri/components/rewind/native-timeline.test.tsxindex fce12bb2b..9c80c8826 100644--- a/apps/screenpipe-app-tauri/components/rewind/native-timeline.test.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/native-timeline.test.tsx@@ -7,6 +7,7 @@ import { describe, expect, it } from "vitest";import {buildNativeSelectionChatPrefill,nativeTimelineOcclusionMode,+ parseTimelineDailySummaryRequest,parseTimelineDay,} from "./native-timeline";@@ -20,6 +21,24 @@ describe("native timeline bridge payloads", () => {expect(parseTimelineDay("2026-02-30")).toBeNull();});+ it("keeps a daily summary request in the native timeline window that produced it", () => {+ expect(+ parseTimelineDailySummaryRequest(+ { date: "2026-08-16", windowLabel: "main" },+ "main"+ )+ ).not.toBeNull();+ expect(+ parseTimelineDailySummaryRequest(+ { date: "2026-08-16", windowLabel: "main" },+ "home"+ )+ ).toBeNull();+ expect(+ parseTimelineDailySummaryRequest("2026-08-16", "main")+ ).not.toBeNull();+ });+it("turns native selection context into the existing chat prefill shape", () => {const prefill = buildNativeSelectionChatPrefill({start: "2026-08-16T22:00:00.000Z",diff --git a/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsxindex d36af83f1..414bf5b91 100644--- a/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx@@ -46,6 +46,11 @@ export interface NativeTimelineExportSelection {end: string;}+export interface NativeTimelineDailySummaryRequest {+ date: string;+ windowLabel?: string;+}+export type NativeTimelineOcclusionMode = "above" | "underlay" | "detached";export function nativeTimelineOcclusionMode(@@ -108,6 +113,17 @@ export function parseTimelineDay(day: string): Date | null {return parsed;}+export function parseTimelineDailySummaryRequest(+ payload: string | NativeTimelineDailySummaryRequest,+ currentWindowLabel: string+): Date | null {+ if (typeof payload === "string") return parseTimelineDay(payload);+ if (payload.windowLabel && payload.windowLabel !== currentWindowLabel) {+ return null;+ }+ return parseTimelineDay(payload.date);+}+/*** Routes the actions the Swift window cannot perform on its own. Mount once,* high enough that it outlives navigation.@@ -123,6 +139,7 @@ export function NativeTimelineBridge() {} | null>(null);useEffect(() => {+ const currentWindowLabel = getCurrentWindow().label;const subscriptions = [listen("timeline-open-search", () => {void commands.openSearchWindow(null, getCurrentWindow().label);@@ -130,8 +147,11 @@ export function NativeTimelineBridge() {listen("timeline-open-chat", () => {void commands.showWindow("Chat");}),- listen<string>("timeline-open-daily-summary", (event) => {- const date = parseTimelineDay(event.payload);+ listen<string | NativeTimelineDailySummaryRequest>("timeline-open-daily-summary", (event) => {+ const date = parseTimelineDailySummaryRequest(+ event.payload,+ currentWindowLabel+ );if (!date) return;setDailySummaryRequest((request) => ({date,diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands/native_actions.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands/native_actions.rsindex ba407f6fc..fcb81e7b7 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands/native_actions.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands/native_actions.rs@@ -198,7 +198,7 @@ fn native_timeline_action_callback_inner(action_ptr: *const std::os::raw::c_charemit_timeline_event(&app, target.as_deref(), "timeline-open-search", ());}TimelineAction::OpenDailySummary { date } => {- emit_timeline_event(&app, target.as_deref(), "timeline-open-daily-summary", date);+ emit_timeline_daily_summary(&app, target.as_deref(), date);}TimelineAction::OpenChat => {emit_timeline_event(&app, target.as_deref(), "timeline-open-chat", ());@@ -259,6 +259,54 @@ fn emit_timeline_event<T: serde::Serialize + Clone>(}}+fn resolve_timeline_event_target<F>(+ explicit_label: Option<&str>,+ mut window_state: F,+) -> Option<String>+where+ F: FnMut(&str) -> Option<bool>,+{+ if let Some(label) = explicit_label.filter(|label| !label.is_empty()) {+ return Some(label.to_string());+ }++ // A legacy native callback has no host label. Prefer the visible overlay:+ // it is the only surface the user can be clicking while it covers Home.+ for label in ["main", "main-window", "home"] {+ if window_state(label) == Some(true) {+ return Some(label.to_string());+ }+ }++ // If every surface is hidden, still choose exactly one loaded webview.+ // Broadcasting leaves a Daily Summary open in both windows, which appears+ // in Home as soon as the user dismisses the overlay.+ for label in ["home", "main", "main-window"] {+ if window_state(label).is_some() {+ return Some(label.to_string());+ }+ }+ None+}++fn emit_timeline_daily_summary(app: &tauri::AppHandle, window_label: Option<&str>, date: String) {+ let target = resolve_timeline_event_target(window_label, |label| {+ app.get_webview_window(label)+ .map(|window| window.is_visible().unwrap_or(false))+ });+ let Some(label) = target else {+ tracing::warn!("dropped native daily summary action without a timeline host");+ return;+ };+ let payload = serde_json::json!({+ "date": date,+ "windowLabel": label,+ });+ if let Err(error) = app.emit_to(&label, "timeline-open-daily-summary", payload) {+ tracing::warn!(%error, %label, "failed to route native daily summary action");+ }+}+fn notification_copy_value(action: &serde_json::Value) -> Option<String> {action.get("value")@@ -1086,7 +1134,8 @@ fn native_shortcut_action_callback_inner(action_ptr: *const std::os::raw::c_charmod tests {use super::{native_overlay_meeting_note_id, notification_copy_value, notification_source_url,- parse_meeting_deeplink, parse_overlay_anchor, SHORTCUT_OVERLAY_ANCHORS,+ parse_meeting_deeplink, parse_overlay_anchor, resolve_timeline_event_target,+ SHORTCUT_OVERLAY_ANCHORS,};use serde_json::json;@@ -1110,6 +1159,34 @@ mod tests {assert_eq!(parse_overlay_anchor("open_timeline"), None);}+ #[test]+ fn legacy_timeline_events_choose_one_visible_surface() {+ let state = |label: &str| match label {+ "main" => Some(true),+ "home" => Some(true),+ _ => None,+ };+ assert_eq!(+ resolve_timeline_event_target(None, state),+ Some("main".to_string()),+ );++ let hidden_overlay = |label: &str| match label {+ "main" => Some(false),+ "home" => Some(true),+ _ => None,+ };+ assert_eq!(+ resolve_timeline_event_target(None, hidden_overlay),+ Some("home".to_string()),+ );++ assert_eq!(+ resolve_timeline_event_target(Some("home"), |_| None),+ Some("home".to_string()),+ );+ }+#[test]fn parses_meeting_deeplink_path_id() {assert_eq!(diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineCore.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineCore.swiftindex 6b36be3de..61f3caa2c 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineCore.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineCore.swift@@ -466,6 +466,30 @@ enum TimelineHoverMetadata {}}+enum TimelineHoverLayout {+ static let previewWidth: CGFloat = 272+ static let edgeInset: CGFloat = 8++ /// Keep the preview centred over the pointer while clamping its card to+ /// the timeline edges. On a window narrower than the card, the honest best+ /// placement is the left edge rather than a negative origin.+ static func previewLeadingX(+ cursorX: CGFloat,+ containerWidth: CGFloat,+ width: CGFloat = previewWidth,+ inset: CGFloat = edgeInset+ ) -> CGFloat {+ let containerWidth = max(0, containerWidth)+ let width = max(0, width)+ let inset = max(0, inset)+ guard containerWidth >= width + inset * 2 else { return 0 }+ return min(+ max(cursorX - width / 2, inset),+ containerWidth - width - inset+ )+ }+}+enum TimelineGrouping {/// Bidirectional carry-forward of `browser_url`, so a browser run keeps its/// site through frames where the URL was not captured. Returns one entry perdiff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineScrubberView.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineScrubberView.swiftindex 936ec95f8..442ae85a2 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineScrubberView.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineScrubberView.swift@@ -106,8 +106,10 @@ struct TimelineScrubberView: View {case .active(let point):let index = layout.globalIndex(atX: point.x - offset)model.hoveredIndex = index+ model.hoveredScrubberX = point.xcase .ended:model.hoveredIndex = nil+ model.hoveredScrubberX = nil}}}diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swiftindex 36bcb2ea8..9fe05449c 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViewModel.swift@@ -201,6 +201,7 @@ final class TimelineViewModel: ObservableObject {@Published var showSubtitles = true@Published var activePopoverGroupIndex: Int?@Published var hoveredIndex: Int?+ @Published var hoveredScrubberX: CGFloat?// Playback@Published private(set) var isPlaying = falsediff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swiftindex 5acff9d92..f19076eb8 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineViews.swift@@ -105,7 +105,14 @@ struct TimelineRootView: View {}?.topDomains.first,loader: thumbnailLoader)- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)+ .padding(+ .leading,+ TimelineHoverLayout.previewLeadingX(+ cursorX: model.hoveredScrubberX ?? model.containerWidth / 2,+ containerWidth: model.containerWidth+ )+ )+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomLeading).padding(.bottom, 120).allowsHitTesting(false).onAppear { loadHoverThumbnail(hovered) }diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline_tests.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline_tests.swiftindex 80e98cbda..2c66650c0 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline_tests.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline_tests.swift@@ -1127,6 +1127,31 @@ private func testFrameAccessors() {expect(!TimelineFrames.hasAudio(emptyAudio), "a blank transcription is not audio")}+// MARK: - Hover preview placement++private func testHoverPreviewPlacement() {+ expectClose(+ TimelineHoverLayout.previewLeadingX(cursorX: 500, containerWidth: 1_000),+ 364,+ "preview centres above the pointer"+ )+ expectClose(+ TimelineHoverLayout.previewLeadingX(cursorX: 10, containerWidth: 1_000),+ 8,+ "preview clamps to the left edge"+ )+ expectClose(+ TimelineHoverLayout.previewLeadingX(cursorX: 990, containerWidth: 1_000),+ 720,+ "preview clamps to the right edge"+ )+ expectClose(+ TimelineHoverLayout.previewLeadingX(cursorX: 120, containerWidth: 240),+ 0,+ "preview avoids a negative origin in a narrow host"+ )+}+// MARK: - Runnerprivate let allTests: [(String, () -> Void)] = [@@ -1162,6 +1187,7 @@ private let allTests: [(String, () -> Void)] = [("search review", testSearchReview),("date navigation", testDateNavigation),("frame accessors", testFrameAccessors),+ ("hover preview placement", testHoverPreviewPlacement),]@main