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: Live Text hit regions, Windows overlay shortcut, vault lock detection

Louis Beaumontcdb6b0f6b11f
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 75625442a..dadc718b9 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
@@ -106,6 +106,12 @@ export function useLiveText(opts: {
x: 0, y: 0, w: 0, h: 0,
}).then(() => {
analyzeFailCountRef.current = 0;
+ // Analysis is stored as pending in Swift — send position update
+ // to apply it with correct geometry for hit-region computation.
+ if (!cancelled && renderedImageInfo) {
+ const pos = getAbsolutePosition(renderedImageInfo);
+ invoke("livetext_update_position", pos).catch(() => {});
+ }
}).catch((e: unknown) => {
if (cancelled) return;
const msg = String(e);
@@ -150,13 +156,19 @@ export function useLiveText(opts: {
if (isSearchModalOpen) {
invoke("livetext_hide").catch(() => {});
} else if (debouncedFrame?.frameId) {
- // Re-analyze to show overlay again (position managed by update_position)
+ // Re-analyze to show overlay again, then send position update
+ // to apply the pending analysis with correct geometry.
const imagePath = isSnapshotFrame && debouncedFrame.filePath
? debouncedFrame.filePath
: `http://localhost:3030/frames/${debouncedFrame.frameId}`;
invoke("livetext_analyze", {
imagePath,
x: 0, y: 0, w: 0, h: 0,
+ }).then(() => {
+ if (renderedImageInfo) {
+ const pos = getAbsolutePosition(renderedImageInfo);
+ invoke("livetext_update_position", pos).catch(() => {});
+ }
}).catch(() => {});
}
}, [nativeLiveTextActive, isSearchModalOpen]);
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index cda8108c4..aabc84cf1 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -79,14 +79,8 @@ pub fn set_tray_health_icon(app_handle: tauri::AppHandle) {
#[tauri::command]
#[specta::specta]
pub fn show_main_window(app_handle: &tauri::AppHandle, _overlay: bool) {
- // macOS: show the overlay panel (NSPanel) on top of fullscreen apps
- // Windows: show the settings/home window (no overlay support)
- #[cfg(target_os = "macos")]
- let window_to_show = ShowRewindWindow::Main;
- #[cfg(not(target_os = "macos"))]
- let window_to_show = ShowRewindWindow::Settings { page: None };
-
info!("show_main_window called");
+ let window_to_show = ShowRewindWindow::Main;
match window_to_show.show(app_handle) {
Ok(window) => {
@@ -125,11 +119,7 @@ pub fn hide_main_window(app_handle: &tauri::AppHandle) {
// handler in window_api.rs. Do NOT also unregister them here — doing
// so races with the focus handler and causes duplicate unregister calls.
- // macOS: close the overlay panel; Windows: close the settings window
- #[cfg(target_os = "macos")]
let window_to_close = ShowRewindWindow::Main;
- #[cfg(not(target_os = "macos"))]
- let window_to_close = ShowRewindWindow::Settings { page: None };
if let Err(e) = window_to_close.close(app_handle) {
error!("failed to close window: {}", e);
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 7e2e68d76..27aba1af8 100644
--- a/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift
+++ b/apps/screenpipe-app-tauri/src-tauri/swift/livetext_bridge.swift
@@ -46,6 +46,10 @@ private class LiveTextManager {
var analyzer: ImageAnalyzer?
var overlayView: ImageAnalysisOverlayView?
var currentAnalysis: ImageAnalysis?
+ /// Analysis waiting to be applied — only set on the overlay when
+ /// lt_update_position provides correct geometry. This prevents
+ /// VisionKit from computing hit regions against a zero/stale frame.
+ var pendingAnalysis: ImageAnalysis?
var hostContentView: NSView?
/// Reusable URLSession for fetching frame images (avoid per-call session alloc).
@@ -116,7 +120,7 @@ public func ltInit(_ windowPtr: UInt64) -> Int32 {
// native overlay (Look Up, Translate, copy, data detectors).
// Focus stealing is managed by mainThreadPreservingFocus() and by
// hiding the overlay when the search modal is open.
- overlay.preferredInteractionTypes = [.textSelection, .dataDetectors]
+ overlay.preferredInteractionTypes = [.textSelection]
overlay.isHidden = true
overlay.frame = NSRect.zero
overlay.autoresizingMask = [] // we manage position manually
@@ -234,18 +238,10 @@ public func ltAnalyzeImage(
}
mgr.currentAnalysis = analysis
-
- // 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.analysis = analysis
- overlay.preferredInteractionTypes = [.textSelection, .dataDetectors]
- overlay.isHidden = false
- }
- }
+ // Don't apply to overlay yet — store as pending. The analysis will be
+ // applied in lt_update_position once the correct frame geometry is set.
+ // This ensures VisionKit computes hit regions against the right rect.
+ mgr.pendingAnalysis = analysis
// Return recognized text from the analysis transcript (macOS 13+)
outText.pointee = makeCString(analysis.transcript)
@@ -269,8 +265,20 @@ public func ltUpdatePosition(_ x: Double, _ y: Double, _ w: Double, _ h: Double)
let contentHeight = contentView.frame.height
let appKitY = contentHeight - (y + h)
+ // Apply pending analysis AFTER setting the frame so VisionKit
+ // computes hit regions against the correct geometry.
+ let pending = mgr.pendingAnalysis
+ mgr.pendingAnalysis = nil
+
mainThreadPreservingFocus(contentView) {
- overlay.frame = NSRect(x: x, y: appKitY, width: w, height: h)
+ MainActor.assumeIsolated {
+ overlay.frame = NSRect(x: x, y: appKitY, width: w, height: h)
+ if let analysis = pending {
+ overlay.analysis = analysis
+ overlay.preferredInteractionTypes = [.textSelection]
+ overlay.isHidden = false
+ }
+ }
}
return 0
}
@@ -358,6 +366,7 @@ public func ltHide() -> Int32 {
}
}
mgr.currentAnalysis = nil
+ mgr.pendingAnalysis = nil
return 0
}
#endif
@@ -377,6 +386,7 @@ public func ltDestroy() -> Int32 {
mgr.overlayView = nil
mgr.analyzer = nil
mgr.currentAnalysis = nil
+ mgr.pendingAnalysis = nil
mgr.hostContentView = nil
mgr.urlSession.invalidateAndCancel()
return 0
diff --git a/crates/screenpipe-vault/src/manager.rs b/crates/screenpipe-vault/src/manager.rs
index 1a9ad1c4e..03a6778c6 100644
--- a/crates/screenpipe-vault/src/manager.rs
+++ b/crates/screenpipe-vault/src/manager.rs
@@ -48,9 +48,20 @@ impl VaultManager {
pub fn new(screenpipe_dir: PathBuf) -> Self {
let initial_state = if !screenpipe_dir.join("vault.meta").exists() {
VaultState::None
- } else {
- // Vault was set up. Key not in memory → effectively locked.
+ } else if screenpipe_dir.join(".vault_locked").exists() {
+ // Sentinel file present → vault is locked
VaultState::Locked
+ } else {
+ // Vault set up but no lock sentinel — check if DB is actually encrypted
+ let db_path = screenpipe_dir.join("db.sqlite");
+ if db_path.exists() && crypto::is_encrypted_file(&db_path).unwrap_or(false) {
+ // DB encrypted but sentinel missing (crash during lock) → locked
+ VaultState::Locked
+ } else {
+ // Vault set up, data not encrypted → unlocked (key not in memory,
+ // but data is accessible so server should not block requests)
+ VaultState::Unlocked
+ }
};
Self {