Skip to content

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

fix(livetext): fix positioning race condition in embedded timeline

Louis Beaumont401370f029f1
diff --git a/apps/screenpipe-app-tauri/components/rewind/hooks/use-live-text.ts b/apps/screenpipe-app-tauri/components/rewind/hooks/use-live-text.ts
index b6a2e92d1..75625442a 100644
--- a/apps/screenpipe-app-tauri/components/rewind/hooks/use-live-text.ts
+++ b/apps/screenpipe-app-tauri/components/rewind/hooks/use-live-text.ts
@@ -34,11 +34,6 @@ export function useLiveText(opts: {
const [nativeLiveTextActive, setNativeLiveTextActive] = useState(false);
const liveTextInitRef = useRef(false);
- // Track whether we have image info via a ref for the analyze effect,
- // and a boolean for dependency tracking.
- const renderedInfoRef = useRef(renderedImageInfo);
- renderedInfoRef.current = renderedImageInfo;
-
const analyzeFailCountRef = useRef(0);
// Get absolute position within the window (accounts for sidebar, titlebar, etc.)
@@ -98,14 +93,8 @@ export function useLiveText(opts: {
? debouncedFrame.filePath
: `http://localhost:3030/frames/${debouncedFrame.frameId}`;
- // Use last known position for analyze call, or a default.
- // Position will be corrected by the update_position effect once layout is ready.
- const info = renderedInfoRef.current;
- const pos = info
- ? getAbsolutePosition(info)
- : { x: 0, y: 0, w: 800, h: 600 };
- const { x, y, w, h } = pos;
-
+ // Position is managed exclusively by livetext_update_position.
+ // The analyze call only sets the analysis + shows the overlay.
// Debounce: 150ms — short enough to feel responsive, long enough to skip
// intermediate frames during fast scroll. Generation counter in Swift
// handles cancellation of stale in-flight requests.
@@ -114,7 +103,7 @@ export function useLiveText(opts: {
if (cancelled) return;
invoke("livetext_analyze", {
imagePath,
- x, y, w, h,
+ x: 0, y: 0, w: 0, h: 0,
}).then(() => {
analyzeFailCountRef.current = 0;
}).catch((e: unknown) => {
@@ -161,17 +150,13 @@ export function useLiveText(opts: {
if (isSearchModalOpen) {
invoke("livetext_hide").catch(() => {});
} else if (debouncedFrame?.frameId) {
- // Re-analyze to show overlay again
- const info = renderedInfoRef.current;
- const pos = info
- ? getAbsolutePosition(info)
- : { x: 0, y: 0, w: 800, h: 600 };
+ // Re-analyze to show overlay again (position managed by update_position)
const imagePath = isSnapshotFrame && debouncedFrame.filePath
? debouncedFrame.filePath
: `http://localhost:3030/frames/${debouncedFrame.frameId}`;
invoke("livetext_analyze", {
imagePath,
- ...pos,
+ x: 0, y: 0, w: 0, h: 0,
}).catch(() => {});
}
}, [nativeLiveTextActive, isSearchModalOpen]);
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 847c76298..ba6b34d71 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.2.78"
+version = "2.2.79"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift b/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift
index 3c25b3270..7e2e68d76 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift
@@ -118,7 +118,7 @@ public func ltInit(_ windowPtr: UInt64) -> Int32 {
// hiding the overlay when the search modal is open.
overlay.preferredInteractionTypes = [.textSelection, .dataDetectors]
overlay.isHidden = true
- overlay.frame = NSRect(x: 0, y: 0, width: 100, height: 100)
+ overlay.frame = NSRect.zero
overlay.autoresizingMask = [] // we manage position manually
contentView.addSubview(overlay)
mgr.overlayView = overlay
@@ -235,13 +235,12 @@ public func ltAnalyzeImage(
mgr.currentAnalysis = analysis
- // Position overlay (flip y for AppKit coordinates)
- let contentHeight = contentView.frame.height
- let appKitY = contentHeight - (y + h)
-
+ // Show the overlay with the new analysis.
+ // Position is managed exclusively by lt_update_position — we don't set
+ // overlay.frame here to avoid a race where stale coordinates from the
+ // analyze call overwrite a correct position set by update_position.
mainThreadPreservingFocus(contentView) {
MainActor.assumeIsolated {
- overlay.frame = NSRect(x: x, y: appKitY, width: w, height: h)
overlay.analysis = analysis
overlay.preferredInteractionTypes = [.textSelection, .dataDetectors]
overlay.isHidden = false