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

add search page, fix esc shortcut

shaik-zeeshan9c7e47c5866b
diff --git a/openrewind/app/page.tsx b/openrewind/app/page.tsx
index 19da99e61..f828b9456 100644
--- a/openrewind/app/page.tsx
+++ b/openrewind/app/page.tsx
@@ -29,6 +29,7 @@ import SplashScreen from "@/components/splash-screen";
import { openSettingsWindow } from "@/lib/utils/window";
import HealthStatus from "@/components/screenpipe-status";
import { ShareLogsButton } from "@/components/share-logs-button";
+import { SearchCommand } from "@/components/rewind/search-command";
export default function Home() {
const { settings, updateSettings, loadUser, reloadStore, isSettingsLoaded, loadingError } = useSettings();
@@ -59,6 +60,18 @@ export default function Home() {
};
}, []);
+ useEffect(() => {
+ // add a shortcut to hide main window when pressed esc
+ const handleEscape = (e: KeyboardEvent) => {
+ if (e.key === "Escape") {
+ commands.closeWindow("Main");
+ }
+ };
+
+ window.addEventListener("keydown", handleEscape);
+ return () => window.removeEventListener("keydown", handleEscape);
+ }, []);
+
useEffect(() => {
const checkScreenPermissionRestart = async () => {
const restartPending = await localforage.getItem(
@@ -126,7 +139,7 @@ export default function Home() {
return (
<div className="flex flex-col items-center flex-1 mx-auto relative scrollbar-hide">
{/* Transparent titlebar area */}
- <div className="h-8 bg-gradient-to-b from-black/15 to-transparent w-full fixed top-0 left-0 z-50" data-tauri-drag-region>
+ <div className="h-8 bg-gradient-to-b from-black/15 to-transparent w-full fixed top-0 left-0 z-[1000]" data-tauri-drag-region>
<div className="flex items-center justify-between gap-2">
<div/>
<h1 className="text-xs font-bold"></h1>
@@ -161,8 +174,9 @@ export default function Home() {
<LoginDialog />
<ModelDownloadTracker />
{!isServerDown ? (
- <div className="w-full scrollbar-hide bg-background">
+ <div className="w-full scrollbar-hide bg-background relative">
<Timeline />
+ <SearchCommand />
</div>
) : (
<div className="flex items-center justify-center h-screen p-4 bg-background w-full">
diff --git a/openrewind/app/search/page.tsx b/openrewind/app/search/page.tsx
new file mode 100644
index 000000000..9d0c11702
--- /dev/null
+++ b/openrewind/app/search/page.tsx
@@ -0,0 +1,155 @@
+"use client";
+
+import { DatePickerWithRange } from "@/components/rewind/date-range-picker";
+import { ImageGrid, MainImage, SkeletonCard } from "@/components/rewind/image-card";
+import { SearchBar } from "@/components/rewind/search-bar";
+import { Button } from "@/components/ui/button";
+import { useDebounce } from "@/lib/hooks/use-debounce";
+import { useKeywordSearchStore } from "@/lib/hooks/use-keyword-search-store";
+import { endOfDay, startOfDay } from "date-fns";
+import { useCallback, useEffect, useRef, Suspense } from "react";
+import { parser } from "@/lib/keyword-parser";
+import { CurrentFrame } from "@/components/rewind/current-frame-search";
+import { useKeywordParams } from "@/lib/hooks/use-keyword-params";
+import { AppSelect } from "@/components/rewind/search-command";
+import { ArrowLeft } from "lucide-react";
+
+function SearchPage() {
+ const [querys, setQuerys] = useKeywordParams();
+ const debounceQuerys = useDebounce(querys, 300);
+ const {
+ searchKeywords,
+ isSearching,
+ searchResults,
+ currentResultIndex,
+ setCurrentResultIndex,
+ } = useKeywordSearchStore();
+ const pageRef = useRef<HTMLDivElement>(null);
+
+ const handleSearch = useCallback(
+ async (
+ query: string,
+ start: Date | undefined,
+ end: Date | undefined,
+ app_names: string[] | undefined,
+ ) => {
+ await searchKeywords(query, {
+ limit: 20,
+ offset: 0,
+ start_time: start,
+ end_time: end,
+ app_names,
+ });
+ },
+ [searchResults],
+ );
+
+ useEffect(() => {
+ if (!debounceQuerys.query || debounceQuerys.query.length === 0) {
+ setCurrentResultIndex(-1);
+ return;
+ }
+
+ const keywords = parser.parse(debounceQuerys.query);
+ if (keywords.keywords.length === 0) return;
+
+ console.log(keywords.keywords);
+
+ handleSearch(
+ keywords.keywords.join(" "),
+ debounceQuerys.start_time ?? undefined,
+ debounceQuerys.end_time ?? undefined,
+ debounceQuerys.apps?.length ? debounceQuerys.apps : undefined,
+ );
+ }, [debounceQuerys]);
+
+ useEffect(() => {
+ console.log(currentResultIndex);
+ }, [currentResultIndex]);
+
+ return (
+ <div
+ ref={pageRef}
+ className="mx-auto flex flex-col justify-between space-y-4 animate-fade-in p-4 min-h-screen overflow-hidden"
+ >
+ <div className="space-y-4 ">
+ <div className="flex items-center gap-4 justify-center">
+ <div className="grid grid-cols-3 gap-4 items-center h-10">
+ <SearchBar
+ search={querys.query}
+ onSearchChange={(query) => {
+ setQuerys((prev) => ({
+ ...prev,
+ query,
+ }));
+ }}
+ />
+ <DatePickerWithRange
+ start_time={querys.start_time}
+ end_time={querys.end_time}
+ setDateRange={(dates) => {
+ setQuerys((prev) => ({
+ ...prev,
+ start_time: dates?.from ? startOfDay(dates?.from) : null,
+ end_time: dates?.to ? endOfDay(dates?.to) : null,
+ }));
+ }}
+ />
+ <AppSelect
+ apps={querys.apps ?? []}
+ setApps={(values) => {
+ setQuerys((prev) => ({
+ ...prev,
+ apps: values,
+ }));
+ }}
+ />
+ </div>
+ </div>
+ <CurrentFrame />
+ </div>
+ {!querys.query && (
+ <div className="h-64 w-96 flex mx-auto items-center justify-center">
+ <p className="text-sm text-gray-500">
+ Please provide query for searching
+ </p>
+ </div>
+ )}
+
+ {!isSearching && searchResults.length === 0 && querys.query ? (
+ <div className="h-64 w-96 flex mx-auto items-center justify-center whitespace-nowrap">
+ <p className="text-sm text-gray-500">
+ No results found for &quot;{querys.query}&quot;
+ </p>
+ </div>
+ ) : null}
+
+ {isSearching && searchResults.length === 0 && (
+ <div
+ className="flex flex-row gap-4 p-8 overflow-hidden"
+ style={{ direction: "rtl" }}
+ >
+ {Array.from({ length: 8 }).map((_, index) => (
+ <SkeletonCard key={`skeleton-${index}`} />
+ ))}
+ </div>
+ )}
+
+ {querys.query && !(searchResults.length === 0) ? (
+ <div className="h-64 flex items-end">
+ <ImageGrid searchResult={searchResults} pageRef={pageRef} />
+ </div>
+ ) : (
+ <div></div>
+ )}
+ </div>
+ );
+}
+
+export default function Page() {
+ return (
+ <Suspense fallback={<div>Loading...</div>}>
+ <SearchPage />
+ </Suspense>
+ );
+}
diff --git a/openrewind/bun.lockb b/openrewind/bun.lockb
index 05138fa35..6fd318c24 100755
Binary files a/openrewind/bun.lockb and b/openrewind/bun.lockb differ
diff --git a/openrewind/components/rewind/search-command.tsx b/openrewind/components/rewind/search-command.tsx
index c086c6b34..28255d81b 100644
--- a/openrewind/components/rewind/search-command.tsx
+++ b/openrewind/components/rewind/search-command.tsx
@@ -19,6 +19,7 @@ import { CustomDialogContent } from "./custom-dialog-content";
import { ArrowRight, XIcon } from "lucide-react";
import { useQueryStates } from "nuqs";
import { CommandShortcut } from "./ui/command";
+import { commands } from "@/lib/utils/tauri";
export function SearchCommand() {
const [open, setOpen] = React.useState(false);
@@ -49,7 +50,8 @@ export function SearchCommand() {
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter") {
e.preventDefault();
- window.location.href = `/search${querySerializer(options)}`;
+ //window.location.href = `/search${querySerializer(options)}`;
+ commands.openSearchWindow(querySerializer(options));
}
};
diff --git a/openrewind/components/settings/recording-settings.tsx b/openrewind/components/settings/recording-settings.tsx
index 4860bde2d..530c84030 100644
--- a/openrewind/components/settings/recording-settings.tsx
+++ b/openrewind/components/settings/recording-settings.tsx
@@ -1371,6 +1371,43 @@ export function RecordingSettings() {
</TooltipProvider>
</Label>
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
+ {/* Default Monitor Option */}
+ <div
+ className={cn(
+ "flex items-center space-x-3 rounded-lg border p-3 cursor-pointer transition-colors",
+ settings.monitorIds.includes("default")
+ ? "border-primary bg-primary/5"
+ : "border-border hover:bg-accent"
+ )}
+ onClick={() => {
+ const isDefaultSelected = settings.monitorIds.includes("default");
+ if (isDefaultSelected) {
+ // Remove default selection
+ handleSettingsChange({
+ monitorIds: settings.monitorIds.filter(id => id !== "default")
+ }, true);
+ } else {
+ // Select default (clear other selections and add default)
+ handleSettingsChange({ monitorIds: ["default"] }, true);
+ }
+ }}
+ >
+ <div className="flex-1">
+ <p className="font-medium">Default Monitor</p>
+ <p className="text-sm text-muted-foreground">
+ Automatically use the system&apos;s default monitor
+ </p>
+ </div>
+ <Check
+ className={cn(
+ "h-4 w-4",
+ settings.monitorIds.includes("default")
+ ? "opacity-100"
+ : "opacity-0"
+ )}
+ />
+ </div>
+
{availableMonitors.map((monitor) => (
<div
key={monitor.id}
@@ -1381,7 +1418,7 @@ export function RecordingSettings() {
: "border-border hover:bg-accent"
)}
onClick={() => {
- const currentIds = settings.monitorIds;
+ const currentIds = settings.monitorIds.filter(id => id !== "default"); // Remove default when selecting specific monitors
const monitorId = monitor.id.toString();
const updatedIds = currentIds.includes(monitorId)
? currentIds.filter(id => id !== monitorId)
diff --git a/openrewind/lib/keyword-parser.ts b/openrewind/lib/keyword-parser.ts
new file mode 100644
index 000000000..ecc4c2612
--- /dev/null
+++ b/openrewind/lib/keyword-parser.ts
@@ -0,0 +1,236 @@
+import { removeStopwords, eng } from "stopword";
+
+interface KeywordResult {
+ keywords: string[];
+}
+
+class KeywordParser {
+ private additionalStopWords: Set<string>;
+
+ constructor() {
+ // Additional stop words that might be missed by the library
+ this.additionalStopWords = new Set([
+ // Question words and related terms
+ "when",
+ "where",
+ "what",
+ "which",
+ "who",
+ "whom",
+ "whose",
+ "why",
+ "how",
+
+ // Negations and quantities
+ "not",
+ "none",
+ "no",
+ "nothing",
+ "never",
+ "neither",
+ "nor",
+
+ // Common verbs and auxiliaries
+ "am",
+ "is",
+ "are",
+ "was",
+ "were",
+ "be",
+ "being",
+ "been",
+ "have",
+ "has",
+ "had",
+ "having",
+ "do",
+ "does",
+ "did",
+ "doing",
+ "can",
+ "could",
+ "will",
+ "would",
+ "shall",
+ "should",
+ "may",
+ "might",
+ "must",
+
+ // Prepositions and articles
+ "in",
+ "on",
+ "at",
+ "to",
+ "for",
+ "with",
+ "by",
+ "from",
+ "up",
+ "down",
+ "into",
+ "onto",
+ "upon",
+ "under",
+ "below",
+ "above",
+ "over",
+ "through",
+ "after",
+ "before",
+ "during",
+ "within",
+ "throughout",
+
+ // Conjunctions
+ "and",
+ "or",
+ "but",
+ "nor",
+ "yet",
+ "so",
+ "although",
+ "though",
+ "while",
+ "if",
+ "unless",
+ "until",
+ "because",
+
+ // Pronouns
+ "i",
+ "me",
+ "my",
+ "mine",
+ "myself",
+ "you",
+ "your",
+ "yours",
+ "yourself",
+ "he",
+ "him",
+ "his",
+ "himself",
+ "she",
+ "her",
+ "hers",
+ "herself",
+ "it",
+ "its",
+ "itself",
+ "we",
+ "us",
+ "our",
+ "ours",
+ "ourselves",
+ "they",
+ "them",
+ "their",
+ "theirs",
+ "themselves",
+
+ // Common adverbs
+ "very",
+ "really",
+ "quite",
+ "rather",
+ "somewhat",
+ "just",
+ "only",
+ "even",
+ "still",
+ "again",
+ "too",
+ "also",
+ "perhaps",
+ "maybe",
+ "here",
+ "there",
+ "now",
+ "then",
+ "always",
+ "never",
+
+ // Others
+ "like",
+ "want",
+ "wanted",
+ "wants",
+ "need",
+ "needs",
+ "needed",
+ "get",
+ "gets",
+ "got",
+ "getting",
+ "make",
+ "makes",
+ "made",
+ "making",
+ "use",
+ "uses",
+ "used",
+ "using",
+ "way",
+ "ways",
+ "thing",
+ "things",
+ "etc",
+ "etc.",
+ "yeah",
+ "yes",
+ "no",
+ "ok",
+ "okay",
+ "would",
+ "could",
+ "should",
+ "shall",
+ "able",
+ "unable",
+ "lot",
+ "lots",
+ "much",
+ "many",
+ "several",
+ "few",
+ "little",
+ "every",
+ "each",
+ "any",
+ "some",
+ "all",
+ ]);
+ }
+
+ private cleanText(text: string): string {
+ // Convert to lowercase and remove special characters
+ return text.toLowerCase().replace(/[^\w\s]/g, "");
+ }
+
+ private tokenize(text: string): string[] {
+ // Split text into words
+ return text.split(/\s+/).filter((word) => word.length > 0);
+ }
+
+ public parse(text: string): KeywordResult {
+ const cleanedText = this.cleanText(text);
+ const tokens = this.tokenize(cleanedText);
+
+ // First remove library stopwords
+ let keywords = removeStopwords(tokens, [
+ ...eng,
+ ...this.additionalStopWords,
+ ]);
+
+ // Filter out single characters only
+ keywords = keywords.filter((word) => word.length > 1);
+
+ // Remove duplicates
+ const uniqueKeywords = Array.from(new Set(keywords));
+
+ return { keywords: uniqueKeywords };
+ }
+}
+
+export const parser = new KeywordParser();
\ No newline at end of file
diff --git a/openrewind/lib/utils/tauri.ts b/openrewind/lib/utils/tauri.ts
index e18d23e83..8ef58d1d2 100644
--- a/openrewind/lib/utils/tauri.ts
+++ b/openrewind/lib/utils/tauri.ts
@@ -145,6 +145,14 @@ async showOnboardingWindow() : Promise<Result<null, string>> {
else return { status: "error", error: e as any };
}
},
+async openSearchWindow(query: string | null) : Promise<Result<null, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("open_search_window", { query }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
async setTrayUnhealthIcon() : Promise<void> {
await TAURI_INVOKE("set_tray_unhealth_icon");
},
@@ -175,7 +183,7 @@ export type OSPermissionsCheck = { screenRecording: OSPermissionStatus; micropho
export type OnboardingStore = { isCompleted: boolean; completedAt: string | null }
export type Pipe = { id: string; name: string; description: string; version: string; author: string; authorLink: string; repository: string; lastUpdate: string; fullDescription: string; downloads: number; mainFile: string; config: { [key in string]: string } }
export type SettingsStore = { aiPresets: AIPreset[]; deepgramApiKey: string; isLoading: boolean; installedPipes: Pipe[]; userId: string; devMode: boolean; audioTranscriptionEngine: string; ocrEngine: string; monitorIds: string[]; audioDevices: string[]; usePiiRemoval: boolean; restartInterval: number; port: number; dataDir: string; disableAudio: boolean; ignoredWindows: string[]; includedWindows: string[]; fps: number; vadSensitivity: string; analyticsEnabled: boolean; audioChunkDuration: number; useChineseMirror: boolean; languages: string[]; embeddedLLM: EmbeddedLLM; enableBeta: boolean; isFirstTimeUser: boolean; autoStartEnabled: boolean; enableFrameCache: boolean; enableUiMonitoring: boolean; platform: string; disabledShortcuts: string[]; user: User; showScreenpipeShortcut: string; startRecordingShortcut: string; stopRecordingShortcut: string; startAudioShortcut: string; stopAudioShortcut: string; pipeShortcuts: { [key in string]: string }; enableRealtimeAudioTranscription: boolean; realtimeAudioTranscriptionEngine: string; disableVision: boolean; useAllMonitors: boolean; enableRealtimeVision: boolean }
-export type ShowRewindWindow = "Main" | { Settings: { page: string | null } } | "Search" | "Onboarding"
+export type ShowRewindWindow = "Main" | { Settings: { page: string | null } } | { Search: { query: string | null } } | "Onboarding"
export type User = { id: string | null; name: string | null; email: string | null; image: string | null; token: string | null; clerk_id: string | null; api_key: string | null; credits: Credits | null; stripe_connected: boolean | null; stripe_account_status: string | null; github_username: string | null; bio: string | null; website: string | null; contact: string | null; cloud_subscribed: boolean | null }
/** tauri-specta globals **/
diff --git a/openrewind/lib/utils/window.ts b/openrewind/lib/utils/window.ts
index 21d2c4416..ad86978bb 100644
--- a/openrewind/lib/utils/window.ts
+++ b/openrewind/lib/utils/window.ts
@@ -4,11 +4,6 @@ import { commands } from "./tauri";
export async function openSettingsWindow(section?: string) {
await commands.showWindow({ Settings: { page: section ?? null } });
}
-
-export async function openSearchWindow() {
- await commands.showWindow("Search");
-}
-
export async function openMainWindow() {
await commands.showWindow("Main");
}
\ No newline at end of file
diff --git a/openrewind/package.json b/openrewind/package.json
index 757c006af..2808e2c5d 100644
--- a/openrewind/package.json
+++ b/openrewind/package.json
@@ -76,6 +76,7 @@
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"sonner": "^2.0.3",
+ "stopword": "^3.1.5",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"tauri-plugin-sentry-api": "^0.4.1",
@@ -92,6 +93,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-syntax-highlighter": "^15.5.13",
+ "@types/stopword": "^2.0.3",
"@wdio/cli": "^8.39.1",
"@wdio/globals": "^8.39.1",
"@wdio/local-runner": "^8.39.1",
diff --git a/openrewind/src-tauri/src/commands.rs b/openrewind/src-tauri/src/commands.rs
index 63b75961c..437abe2c1 100644
--- a/openrewind/src-tauri/src/commands.rs
+++ b/openrewind/src-tauri/src/commands.rs
@@ -299,4 +299,12 @@ pub async fn show_onboarding_window(app_handle: tauri::AppHandle) -> Result<(),
pub async fn set_window_size(app_handle: tauri::AppHandle, window: ShowRewindWindow, width: f64, height: f64) -> Result<(), String> {
window.set_size(&app_handle, width, height).map_err(|e| e.to_string())?;
Ok(())
+}
+
+#[tauri::command]
+#[specta::specta]
+pub async fn open_search_window(app_handle: tauri::AppHandle, query: Option<String>) -> Result<(), String> {
+ ShowRewindWindow::Main.close(&app_handle).map_err(|e| e.to_string())?;
+ ShowRewindWindow::Search { query }.show(&app_handle).map_err(|e| e.to_string())?;
+ Ok(())
}
\ No newline at end of file
diff --git a/openrewind/src-tauri/src/main.rs b/openrewind/src-tauri/src/main.rs
index d1ec82311..0ed532adf 100755
--- a/openrewind/src-tauri/src/main.rs
+++ b/openrewind/src-tauri/src/main.rs
@@ -194,12 +194,7 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),
})
.await?;
- // register esc button to hide main window
- register_shortcut(app, "Escape", false, |app| {
- hide_main_window(app);
- })
- .await?;
-
+
// Register start shortcut
register_shortcut(
app,
@@ -615,6 +610,7 @@ async fn main() {
commands::complete_onboarding,
commands::reset_onboarding,
commands::show_onboarding_window,
+ commands::open_search_window,
// Commands from tray.rs
set_tray_unhealth_icon,
set_tray_health_icon,
@@ -694,6 +690,7 @@ async fn main() {
commands::complete_onboarding,
commands::reset_onboarding,
commands::show_onboarding_window,
+ commands::open_search_window,
get_log_files,
get_media_file,
upload_file_to_s3,
diff --git a/openrewind/src-tauri/src/sidecar.rs b/openrewind/src-tauri/src/sidecar.rs
index 641977643..ec351f253 100644
--- a/openrewind/src-tauri/src/sidecar.rs
+++ b/openrewind/src-tauri/src/sidecar.rs
@@ -41,6 +41,15 @@ pub struct User {
pub cloud_subscribed: Option<bool>,
}
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct MonitorDevice {
+ pub id: u32,
+ pub name: String,
+ pub is_default: bool,
+ pub width: u32,
+ pub height: u32,
+}
+
impl User {
pub fn from_store(store: &SettingsStore) -> Self {
Self {
@@ -59,6 +68,62 @@ impl User {
}
}
+/// Get all available monitors connected to the device
+pub async fn get_available_monitors(app: &tauri::AppHandle) -> Result<Vec<MonitorDevice>, String> {
+ debug!("Getting available monitors");
+
+ let sidecar = app.shell().sidecar("screenpipe")
+ .map_err(|e| format!("Failed to create sidecar command: {}", e))?;
+
+ let output = sidecar
+ .args(&["vision", "list", "-o", "json"])
+ .output()
+ .await
+ .map_err(|e| format!("Failed to execute monitor listing command: {}", e))?;
+
+ if !output.status.success() {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ error!("Failed to get monitors: {}", stderr);
+ return Err(format!("Failed to get monitors: {}", stderr));
+ }
+
+ let stdout = String::from_utf8(output.stdout)
+ .map_err(|e| format!("Failed to parse monitor output as UTF-8: {}", e))?;
+
+ debug!("Monitor command output: {}", stdout);
+
+ // Parse the JSON response which might be in {data: [...], success: true} format
+ let json_value: serde_json::Value = serde_json::from_str(&stdout)
+ .map_err(|e| format!("Failed to parse monitor JSON: {}", e))?;
+
+ let monitors_array = if let Some(data) = json_value.get("data") {
+ data.as_array()
+ } else {
+ json_value.as_array()
+ }.ok_or("Monitor response is not an array")?;
+
+
+ let monitors: Vec<MonitorDevice> = monitors_array
+ .iter()
+ .filter_map(|monitor| {
+ serde_json::from_value(monitor.clone()).ok()
+ })
+ .collect();
+
+ if monitors.is_empty() {
+ return Err("No monitors found".to_string());
+ }
+
+ debug!("Found {} monitors", monitors.len());
+ Ok(monitors)
+}
+
+#[tauri::command]
+#[specta::specta]
+pub async fn get_monitors(app: tauri::AppHandle) -> Result<Vec<MonitorDevice>, String> {
+ get_available_monitors(&app).await
+}
+
#[tauri::command]
#[specta::specta]
pub async fn stop_screenpipe(
@@ -164,7 +229,7 @@ pub async fn spawn_screenpipe(
}
}
-fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<CommandChild, String> {
+async fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<CommandChild, String> {
let store = app.state::<SettingsStore>();
let audio_transcription_engine = store.audio_transcription_engine.clone();
@@ -173,6 +238,8 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
let monitor_ids = store.monitor_ids.clone();
+
+
let audio_devices = store.audio_devices.clone();
let use_pii_removal = store.use_pii_removal;
@@ -232,6 +299,7 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
let port_str = port.to_string();
let mut args = vec!["--port", port_str.as_str()];
let fps_str = fps.to_string();
+ let mut monitor_id_str = String::new(); // Store monitor ID string
if fps != 0.2 {
args.push("--fps");
args.push(fps_str.as_str());
@@ -252,11 +320,33 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
let model = ocr_engine.as_str();
args.push(model);
}
-
- if !monitor_ids.is_empty() && monitor_ids[0] != Value::String("default".to_string()) {
- for monitor in &monitor_ids {
- args.push("--monitor-id");
- args.push(monitor.as_str());
+ if !monitor_ids.is_empty() {
+ if monitor_ids.contains(&"default".to_string()) {
+ // Get the default monitor and use its ID
+ match get_available_monitors(app).await {
+ Ok(monitors) => {
+ if let Some(default_monitor) = monitors.iter().find(|m| m.is_default) {
+ monitor_id_str = default_monitor.id.to_string();
+ args.push("--monitor-id");
+ args.push(&monitor_id_str);
+ } else if let Some(first_monitor) = monitors.first() {
+ // Fallback to first monitor if no default is found
+ monitor_id_str = first_monitor.id.to_string();
+ args.push("--monitor-id");
+ args.push(&monitor_id_str);
+ }
+ }
+ Err(e) => {
+ error!("Failed to get default monitor: {}", e);
+ // Continue without monitor specification
+ }
+ }
+ } else {
+ // Use specific monitor IDs
+ for monitor in &monitor_ids {
+ args.push("--monitor-id");
+ args.push(monitor.as_str());
+ }
}
}
@@ -491,7 +581,7 @@ impl SidecarManager {
self.update_settings(app).await?;
// Spawn the sidecar
- let child = spawn_sidecar(app, override_args)?;
+ let child = spawn_sidecar(app, override_args).await?;
self.child = Some(child);
Ok(())
diff --git a/openrewind/src-tauri/src/window_api.rs b/openrewind/src-tauri/src/window_api.rs
index 7739f77bf..04f96f5fa 100644
--- a/openrewind/src-tauri/src/window_api.rs
+++ b/openrewind/src-tauri/src/window_api.rs
@@ -215,7 +215,7 @@ impl RewindWindowId {
pub enum ShowRewindWindow {
Main,
Settings { page: Option<String> },
- Search,
+ Search { query: Option<String> },
Onboarding,
}
@@ -260,11 +260,20 @@ impl ShowRewindWindow {
match self {
ShowRewindWindow::Main => RewindWindowId::Main,
ShowRewindWindow::Settings { page: _ } => RewindWindowId::Settings,
- ShowRewindWindow::Search => RewindWindowId::Search,
+ ShowRewindWindow::Search { query: _ } => RewindWindowId::Search,
ShowRewindWindow::Onboarding => RewindWindowId::Onboarding,
}
}
+ pub fn metadata(&self) -> Option<String> {
+ match self {
+ ShowRewindWindow::Main => None,
+ ShowRewindWindow::Settings { page: _ } => None,
+ ShowRewindWindow::Search { query } => Some(query.clone().unwrap_or_default().to_string()),
+ ShowRewindWindow::Onboarding => None,
+ }
+ }
+
pub fn show(&self, app: &AppHandle) -> tauri::Result<WebviewWindow> {
let id = self.id();
let onboarding_store = OnboardingStore::get(app)
@@ -291,6 +300,14 @@ impl ShowRewindWindow {
}
}
+ if id.label() == RewindWindowId::Search.label() {
+ if let Some(query) = self.metadata() {
+ let _ = window.eval(&format!("window.location.replace(`/search/{}`);", query)).ok();
+ }
+ window.show().ok();
+ return Ok(window);
+ }
+
info!("showing window: {:?}", id.label());
@@ -310,7 +327,7 @@ impl ShowRewindWindow {
let monitor = app.primary_monitor().unwrap().unwrap();
let size = monitor.size();
- let builder = self.window_builder(app, "/").hidden_title(true).visible_on_all_workspaces(true).always_on_top(true).decorations(false).skip_taskbar(true).focused(true).transparent(true).inner_size(size.width as f64, size.height as f64);
+ let builder = self.window_builder(app, "/").hidden_title(true).visible_on_all_workspaces(true).always_on_top(true).decorations(false).skip_taskbar(true).focused(false).transparent(true).inner_size(size.width as f64, size.height as f64);
let window = builder.build()?;
#[cfg(target_os = "macos")]
@@ -372,18 +389,6 @@ impl ShowRewindWindow {
}
});
- // #[cfg(target_os = "macos")]
- // {
- // use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial};
- // apply_vibrancy(&window, NSVisualEffectMaterial::ContentBackground, None, None).ok();
- // }
-
- // #[cfg(target_os = "windows")]
- // {
- // use window_vibrancy::apply_blur;
- // apply_blur(&window, Some((18, 18, 18, 125))).ok();
- // }
-
window
}
ShowRewindWindow::Settings { page: _ } => {
@@ -391,8 +396,16 @@ impl ShowRewindWindow {
let window = builder.build()?;
window
}
- ShowRewindWindow::Search => {
- let builder = self.window_builder(app, "/search");
+ ShowRewindWindow::Search { query } => {
+ let mut url = "/search".to_string();
+ info!("query: {:?}", query);
+ if let Some(q) = query {
+ // Simple URL encoding for the query parameter
+ // let encoded_query = q.replace(' ', "%20").replace('#', "%23").replace('&', "%26");
+ url.push_str(&format!("{}", q));
+ }
+ let builder = self.window_builder(app, url).hidden_title(true).focused(true);
+
let window = builder.build()?;
window
}