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
feat(chat): move Cmd+L shortcut to Rust level for global access
Louis Beaumontb0d33cb461ee
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsxindex e86bc110f..4bf653f8c 100644--- a/screenpipe-app-tauri/components/global-chat.tsx+++ b/screenpipe-app-tauri/components/global-chat.tsx@@ -3,6 +3,7 @@import * as React from "react";import { useState, useRef, useEffect } from "react";import { usePathname } from "next/navigation";+import { listen } from "@tauri-apps/api/event";import { Dialog, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Button } from "@/components/ui/button";@@ -180,18 +181,17 @@ export function GlobalChat() {};const disabledReason = getDisabledReason();- // Listen for Cmd+L / Ctrl+L shortcut (only on timeline)+ // Listen for Rust-level open-chat event (Cmd+L / Ctrl+L global shortcut)useEffect(() => {if (!isOnTimeline) return;- const handleKeyDown = (e: KeyboardEvent) => {- if ((e.metaKey || e.ctrlKey) && e.key === "l") {- e.preventDefault();- setOpen((prev) => !prev);- }+ const unlisten = listen("open-chat", () => {+ setOpen((prev) => !prev);+ });++ return () => {+ unlisten.then((fn) => fn());};- window.addEventListener("keydown", handleKeyDown);- return () => window.removeEventListener("keydown", handleKeyDown);}, [isOnTimeline]);// Focus input when openingdiff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rsindex 333333dd9..e1489615e 100755--- a/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/screenpipe-app-tauri/src-tauri/src/main.rs@@ -315,6 +315,38 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),warn!("Failed to register search shortcut: {}", e);}+ // Register Cmd+L (macOS) / Ctrl+L (Windows/Linux) to open AI chat when main window is visible+ #[cfg(target_os = "macos")]+ let chat_shortcut = Shortcut::new(Some(Modifiers::SUPER), Code::KeyL);+ #[cfg(not(target_os = "macos"))]+ let chat_shortcut = Shortcut::new(Some(Modifiers::CONTROL), Code::KeyL);++ if let Err(e) = global_shortcut.on_shortcut(chat_shortcut, |app, _, event| {+ if matches!(event.state, ShortcutState::Pressed) {+ // Only open chat if main window is visible+ #[cfg(target_os = "macos")]+ {+ if let Ok(window) = app.get_webview_panel("main") {+ if window.is_visible() {+ info!("Cmd+L pressed, opening AI chat");+ let _ = app.emit("open-chat", ());+ }+ }+ }+ #[cfg(not(target_os = "macos"))]+ {+ if let Some(window) = app.get_webview_window("main") {+ if window.is_visible().unwrap_or(false) {+ info!("Ctrl+L pressed, opening AI chat");+ let _ = app.emit("open-chat", ());+ }+ }+ }+ }+ }) {+ warn!("Failed to register chat shortcut: {}", e);+ }+Ok(())}