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 native timeline arrow focus
Louis Beaumontec097f906efd
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineWindow.swift b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineWindow.swiftindex c72d82957..fd0d0d6a5 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineWindow.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/timeline/TimelineWindow.swift@@ -107,6 +107,41 @@ struct TimelineKeyEvent: Sendable, Equatable {}}+enum TimelineKeyFocusOwner {+ case timeline+ case attachedHost+ case other+}++/// Decides whether a local app key event belongs to the Timeline.+///+/// An attached Timeline is a native child over a Tauri host. Opening that host+/// or returning from Search makes the host key before the child receives a+/// click. Plain arrows still belong to the visible Timeline in that state, but+/// no other shortcut does: Escape, Space and text-entry keys remain with the+/// host. Because this policy is used by a local event monitor, another app's+/// events never enter it.+enum TimelineKeyFocusPolicy {+ static func shouldHandle(+ _ event: TimelineKeyEvent,+ focusOwner: TimelineKeyFocusOwner,+ attachedUnderlay: Bool,+ editingText: Bool+ ) -> Bool {+ guard !editingText else { return false }+ switch focusOwner {+ case .timeline:+ return true+ case .attachedHost:+ guard !attachedUnderlay, !event.command, !event.control else { return false }+ return event.keyCode == TimelineKeyEvent.leftArrow+ || event.keyCode == TimelineKeyEvent.rightArrow+ case .other:+ return false+ }+ }+}+/// The keyboard table from the webview, in one place.@MainActorstruct TimelineKeyHandler {@@ -935,15 +970,33 @@ final class TimelineWindowController: NSObject, NSWindowDelegate {closeOnEscape: closeOnEscape)keyMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in- guard let self, self.window?.isKeyWindow == true else { return event }- // Never steal keys from a text field; the tag input lives in this window.- if self.window?.firstResponder is NSTextView { return event }+ guard let self else { return event }let key = TimelineKeyEvent(event)+ let editingText = event.window?.firstResponder is NSTextView+ || self.window?.firstResponder is NSTextView+ guard TimelineKeyFocusPolicy.shouldHandle(+ key,+ focusOwner: self.keyFocusOwner(for: event),+ attachedUnderlay: self.attachedUnderlay,+ editingText: editingText+ ) else { return event }let consumed = MainActor.assumeIsolated { handler.handle(key) }return consumed ? nil : event}}+ /// Local monitors see events for every screenpipe window. Route only the+ /// key native child, or a key host that owns this attached child. Search,+ /// Chat, another screenpipe window, and external apps remain `.other`.+ private func keyFocusOwner(for event: NSEvent) -> TimelineKeyFocusOwner {+ guard let timeline = window else { return .other }+ if timeline.isKeyWindow { return .timeline }+ guard let host = timeline.parent,+ host.isKeyWindow,+ event.window === host else { return .other }+ return .attachedHost+ }+private func removeKeyMonitor() {if let keyMonitor { NSEvent.removeMonitor(keyMonitor) }keyMonitor = nildiff --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 6b1b00d89..f511c94b6 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@@ -456,6 +456,77 @@ private func testKeyboard() {"overlay escape asks to close its host window")}+private func testAttachedHostArrowFocusPolicy() {+ let left = TimelineKeyEvent(keyCode: TimelineKeyEvent.leftArrow)+ let right = TimelineKeyEvent(keyCode: TimelineKeyEvent.rightArrow)+ let space = TimelineKeyEvent(keyCode: TimelineKeyEvent.space)+ let escape = TimelineKeyEvent(keyCode: TimelineKeyEvent.escape)++ expect(+ TimelineKeyFocusPolicy.shouldHandle(+ left,+ focusOwner: .attachedHost,+ attachedUnderlay: false,+ editingText: false+ ),+ "left arrow works when the attached Timeline host has focus"+ )+ expect(+ TimelineKeyFocusPolicy.shouldHandle(+ right,+ focusOwner: .attachedHost,+ attachedUnderlay: false,+ editingText: false+ ),+ "right arrow works when the attached Timeline host has focus"+ )+ expect(+ !TimelineKeyFocusPolicy.shouldHandle(+ space,+ focusOwner: .attachedHost,+ attachedUnderlay: false,+ editingText: false+ ),+ "parent focus does not capture playback keys"+ )+ expect(+ !TimelineKeyFocusPolicy.shouldHandle(+ escape,+ focusOwner: .attachedHost,+ attachedUnderlay: false,+ editingText: false+ ),+ "parent focus does not capture Escape"+ )+ expect(+ !TimelineKeyFocusPolicy.shouldHandle(+ left,+ focusOwner: .attachedHost,+ attachedUnderlay: true,+ editingText: false+ ),+ "an overlay above the Timeline keeps its arrows"+ )+ expect(+ !TimelineKeyFocusPolicy.shouldHandle(+ left,+ focusOwner: .other,+ attachedUnderlay: false,+ editingText: false+ ),+ "another window or app keeps its arrows"+ )+ expect(+ !TimelineKeyFocusPolicy.shouldHandle(+ left,+ focusOwner: .timeline,+ attachedUnderlay: false,+ editingText: true+ ),+ "text editing keeps its arrows"+ )+}+private func testActionRouting() {let payload = TimelineActionBridge.callbackPayload(action: "open_daily_summary:2026-08-17",@@ -1037,6 +1108,7 @@ struct TimelineRenderTests {("scrubber renders", { testScrubberRenders(shots: shots) }),("scrubber layout", testScrubberLayoutMatchesHitTest),("keyboard", testKeyboard),+ ("attached host arrow focus", testAttachedHostArrowFocusPolicy),("action routing", testActionRouting),("scroll and zoom", testScrollAndZoom),("selection and filters", testSelectionAndFilters),