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(ui): auto-focus search input and reset modals on window close
Louis Beaumont69a916b53c54
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsxindex ab91a31b0..fd01b8028 100644--- a/screenpipe-app-tauri/components/global-chat.tsx+++ b/screenpipe-app-tauri/components/global-chat.tsx@@ -827,6 +827,16 @@ export function GlobalChat() {}}, [isOnTimeline, open]);+ // Close chat when window is hidden (Esc pressed, timeline closed)+ useEffect(() => {+ const unlisten = listen("window-hidden", () => {+ setOpen(false);+ });+ return () => {+ unlisten.then((fn) => fn());+ };+ }, []);+// Scroll to bottom when messages changeuseEffect(() => {messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });diff --git a/screenpipe-app-tauri/components/rewind/search-command.tsx b/screenpipe-app-tauri/components/rewind/search-command.tsxindex b8b548cf6..a653123d4 100644--- a/screenpipe-app-tauri/components/rewind/search-command.tsx+++ b/screenpipe-app-tauri/components/rewind/search-command.tsx@@ -39,6 +39,7 @@ interface SearchResult {export function SearchCommand() {const [open, setOpen] = React.useState(false);const { isMac } = usePlatform();+ const inputRef = React.useRef<HTMLInputElement>(null);const [state] = useQueryStates(queryParser);const [options, setOptions] = useState<QueryParser>(@@ -67,6 +68,14 @@ export function SearchCommand() {};}, []);+ // Focus input when dialog opens+ React.useEffect(() => {+ if (open) {+ // Use setTimeout to ensure the dialog has rendered+ setTimeout(() => inputRef.current?.focus(), 50);+ }+ }, [open]);+// Close dialog when Tauri window loses focusReact.useEffect(() => {const unlisten = listen<boolean>("window-focused", (event) => {@@ -84,9 +93,25 @@ export function SearchCommand() {if (!open) {setResults([]);setHasSearched(false);+ setOptions({+ query: null,+ start_time: null,+ end_time: null,+ apps: [],+ });}}, [open]);+ // Close search when window is hidden+ React.useEffect(() => {+ const unlisten = listen("window-hidden", () => {+ setOpen(false);+ });+ return () => {+ unlisten.then((fn) => fn());+ };+ }, []);+// Execute searchasync function handleSearch() {if (!options.query?.trim()) return;@@ -168,6 +193,7 @@ export function SearchCommand() {<div className="flex items-center gap-2"><Search className="h-4 w-4 text-muted-foreground shrink-0" /><Input+ ref={inputRef}value={options?.query || ""}className="focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 ring-0 outline-none border-0 h-10"placeholder="Search your screen activity..."@@ -175,7 +201,6 @@ export function SearchCommand() {setOptions((prev) => ({ ...prev, query: e.target.value }));}}onKeyDown={handleKeyDown}- autoFocus/>{isSearching && <Loader2 className="h-4 w-4 animate-spin" />}</div>diff --git a/screenpipe-app-tauri/src-tauri/src/commands.rs b/screenpipe-app-tauri/src-tauri/src/commands.rsindex 162d44805..e08f96c5e 100644--- a/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -305,6 +305,8 @@ pub async fn close_window(app_handle: tauri::AppHandle,window: ShowRewindWindow,) -> Result<(), String> {+ // Emit window-hidden event so React components can clean up+ let _ = app_handle.emit("window-hidden", ());window.close(&app_handle).map_err(|e| e.to_string())?;Ok(())}