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(owned-browser): rust-side screen-coord math + parent-window plumb
Louis Beaumont43c7c249e7b8
diff --git a/apps/screenpipe-app-tauri/components/browser-sidebar.tsx b/apps/screenpipe-app-tauri/components/browser-sidebar.tsxindex eef4aa390..2e2e00e0e 100644--- a/apps/screenpipe-app-tauri/components/browser-sidebar.tsx+++ b/apps/screenpipe-app-tauri/components/browser-sidebar.tsx@@ -54,16 +54,12 @@ export function BrowserSidebar({ conversationId }: BrowserSidebarProps) {[conversationId],);- // Push the current placeholder rect to Tauri so the top-level webview- // window lines up. The Rust side positions a *top-level* WebviewWindow,- // so the bounds must be in **screen coordinates** (origin = primary- // display top-left), not viewport-relative.- //- // Translation: screen = active-window-inner-position + placeholder- // viewport rect. `innerPosition()` returns physical pixels; divide by- // scaleFactor() to get logical CSS pixels (which is what- // `getBoundingClientRect()` returns and what Tauri's- // LogicalPosition/LogicalSize expects).+ // Push the current placeholder rect to Tauri. The Rust side positions+ // a *top-level* WebviewWindow over the placeholder; we send+ // viewport-relative bounds (CSS pixels, what `getBoundingClientRect()`+ // gives us) plus the label of the host window so Rust can resolve the+ // screen position from its own `inner_position()` — keeping all+ // coordinate-space math on one side.const pushBounds = useCallback(async () => {const el = placeholderRef.current;if (!el) return;@@ -74,15 +70,10 @@ export function BrowserSidebar({ conversationId }: BrowserSidebarProps) {}try {const w = getCurrentWindow();- const [innerPos, scale] = await Promise.all([- w.innerPosition(),- w.scaleFactor(),- ]);- const logicalInnerX = innerPos.x / scale;- const logicalInnerY = innerPos.y / scale;await invoke("owned_browser_set_bounds", {- x: logicalInnerX + r.left,- y: logicalInnerY + r.top,+ parent: w.label,+ x: r.left,+ y: r.top,width: r.width,height: r.height,});diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 957a019b1..96be6a3fb 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9726,7 +9726,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.113"+version = "2.4.114"dependencies = ["anyhow","arboard",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex a7c663243..747e83b63 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.4.114"+version = "2.4.115"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs b/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rsindex 16d33692a..379e0fd98 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/owned_browser.rs@@ -349,14 +349,18 @@ pub async fn install(// Tauri commands — sidebar controls (frontend → child webview)// ----------------------------------------------------------------------------/// Position and size the embedded webview window in **screen-/// coordinates** (logical pixels, origin = top-left of the primary-/// display). The frontend computes these from the active window's-/// inner-position + the placeholder's viewport rect; see-/// `<BrowserSidebar />`. Call with width/height = 0 to hide.+/// Position and size the embedded webview window. The frontend sends+/// viewport-relative coords (the placeholder's `getBoundingClientRect()`)+/// plus the label of the parent window that hosts the placeholder. Rust+/// resolves the parent's screen position and adds the rect offsets — this+/// keeps the conversion logic on one side (Rust's `inner_position()` is+/// the authoritative source) and avoids JS↔Rust unit-mismatch bugs that+/// caused the webview to land off-screen on monitors where JS-side math+/// disagreed with the OS. Call with width/height = 0 to hide.#[tauri::command]pub async fn owned_browser_set_bounds(app: AppHandle,+ parent: String,x: f64,y: f64,width: f64,@@ -371,8 +375,24 @@ pub async fn owned_browser_set_bounds(return Ok(());}+ let parent_w = app+ .get_webview_window(&parent)+ .ok_or_else(|| format!("parent window {parent:?} not found"))?;+ let scale = parent_w.scale_factor().map_err(|e| e.to_string())?;+ let inner_pos_phys = parent_w.inner_position().map_err(|e| e.to_string())?;+ let inner_pos = inner_pos_phys.to_logical::<f64>(scale);++ let screen_x = inner_pos.x + x;+ let screen_y = inner_pos.y + y;++ tracing::debug!(+ "owned-browser set_bounds: parent={parent} inner=({:.0},{:.0}) rect=({x:.0},{y:.0},{width:.0}x{height:.0}) -> screen=({screen_x:.0},{screen_y:.0})",+ inner_pos.x,+ inner_pos.y+ );+webview_window- .set_position(LogicalPosition::new(x, y))+ .set_position(LogicalPosition::new(screen_x, screen_y)).map_err(|e| e.to_string())?;webview_window.set_size(LogicalSize::new(width, height))