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(app): suppress native context menu in packaged builds (#6899)

Ezra Ellette483669d04f83
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsx
index b25b4001f..dc29313d5 100644
--- a/apps/screenpipe-app-tauri/app/layout.tsx
+++ b/apps/screenpipe-app-tauri/app/layout.tsx
@@ -103,6 +103,16 @@ export default function RootLayout({
const uninstallBrowserLogBridge = installBrowserLogBridge();
+ // Packaged builds should not expose WKWebView's browser context menu.
+ // Listen during bubbling so app-owned context-menu handlers still run;
+ // preventing the default here only suppresses the native webview menu.
+ const preventNativeContextMenu = (event: MouseEvent) => {
+ event.preventDefault();
+ };
+ if (process.env.NODE_ENV === "production") {
+ document.addEventListener("contextmenu", preventNativeContextMenu);
+ }
+
// A native foreground watchdog requires a heartbeat from WebKit's main
// event loop. When paint submission wedges in the GPU-process IPC path,
// the page cannot run this callback; the shell then rebuilds the stale UI
@@ -234,6 +244,7 @@ export default function RootLayout({
return () => {
uninstallBrowserLogBridge();
+ document.removeEventListener("contextmenu", preventNativeContextMenu);
window.removeEventListener("focus", handleWindowFocus);
window.removeEventListener("mousedown", handlePointerRecovery, true);
window.removeEventListener("keydown", markKeyActivity, true);