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

feat: add support for using screenpipe in china without vpn

Louis Beaumonte4d26ed9ea59
diff --git a/screenpipe-app-tauri/app/providers.tsx b/screenpipe-app-tauri/app/providers.tsx
index 67a266349..d33cc9c53 100644
--- a/screenpipe-app-tauri/app/providers.tsx
+++ b/screenpipe-app-tauri/app/providers.tsx
@@ -5,17 +5,16 @@ import { PostHogProvider } from "posthog-js/react";
import { useEffect } from "react";
import { initOpenTelemetry } from "@/lib/opentelemetry";
-if (typeof window !== "undefined") {
- posthog.init("phc_Bt8GoTBPgkCpDrbaIZzJIEYt0CrJjhBiuLaBck1clce", {
- api_host: "https://eu.i.posthog.com",
- person_profiles: "identified_only",
- capture_pageview: false, // Disable automatic pageview capture, as we capture manually
- });
-}
-
export function Providers({ children }: { children: React.ReactNode }) {
useEffect(() => {
if (typeof window !== "undefined") {
+ const isDebug = process.env.TAURI_ENV_DEBUG === "true";
+ if (isDebug) return;
+ posthog.init("phc_Bt8GoTBPgkCpDrbaIZzJIEYt0CrJjhBiuLaBck1clce", {
+ api_host: "https://eu.i.posthog.com",
+ person_profiles: "identified_only",
+ capture_pageview: false, // Disable automatic pageview capture, as we capture manually
+ });
initOpenTelemetry("82688", new Date().toISOString());
}
}, []);
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsx
index 20c1002ea..994910232 100644
--- a/screenpipe-app-tauri/components/recording-settings.tsx
+++ b/screenpipe-app-tauri/components/recording-settings.tsx
@@ -62,6 +62,7 @@ import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";
import { platform } from "@tauri-apps/plugin-os";
import posthog from "posthog-js";
import { trace } from "@opentelemetry/api";
+import { initOpenTelemetry } from "@/lib/opentelemetry";
interface AudioDevice {
name: string;
@@ -206,6 +207,7 @@ export function RecordingSettings({
vadSensitivity: localSettings.vadSensitivity,
audioChunkDuration: localSettings.audioChunkDuration,
analyticsEnabled: localSettings.analyticsEnabled,
+ useChineseMirror: localSettings.useChineseMirror,
};
console.log("Settings to update:", settingsToUpdate);
await updateSettings(settingsToUpdate);
@@ -219,12 +221,17 @@ export function RecordingSettings({
posthog.opt_out_capturing();
console.log("telemetry disabled");
} else {
- posthog.opt_in_capturing();
- posthog.capture("telemetry", {
- enabled: true,
- });
- // enable opentelemetry
- console.log("telemetry enabled");
+ const isDebug = process.env.TAURI_ENV_DEBUG === "true";
+ if (!isDebug) {
+ posthog.opt_in_capturing();
+ posthog.capture("telemetry", {
+ enabled: true,
+ });
+ initOpenTelemetry("82688", new Date().toISOString());
+
+ // enable opentelemetry
+ console.log("telemetry enabled");
+ }
}
await invoke("kill_all_sreenpipes");
@@ -443,6 +450,10 @@ export function RecordingSettings({
setLocalSettings({ ...localSettings, analyticsEnabled: newValue });
};
+ const handleChineseMirrorToggle = (checked: boolean) => {
+ setLocalSettings({ ...localSettings, useChineseMirror: checked });
+ };
+
return (
<>
<div className="relative">
@@ -1075,6 +1086,37 @@ export function RecordingSettings({
</TooltipProvider>
</Label>
</div>
+ <div className="flex items-center space-x-2">
+ <Switch
+ id="chinese-mirror-toggle"
+ checked={localSettings.useChineseMirror}
+ onCheckedChange={handleChineseMirrorToggle}
+ />
+ <Label
+ htmlFor="chinese-mirror-toggle"
+ className="flex items-center space-x-2"
+ >
+ <span>use chinese mirror for model downloads</span>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger>
+ <HelpCircle className="h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="right">
+ <p>
+ enable this option to use a chinese mirror for
+ <br />
+ downloading Hugging Face models
+ <br />
+ (e.g. Whisper, embedded Llama, etc.)
+ <br />
+ which are blocked in mainland China.
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </Label>
+ </div>
</CardContent>
</Card>
</div>
diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 8058090d3..dcdb53a7e 100644
--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -37,6 +37,7 @@ const defaultSettings: Settings = {
vadSensitivity: "high",
analyticsEnabled: true,
audioChunkDuration: 30, // default to 10 seconds
+ useChineseMirror: false, // Add this line
};
export type VadSensitivity = "low" | "medium" | "high";
@@ -66,6 +67,7 @@ export interface Settings {
vadSensitivity: VadSensitivity;
analyticsEnabled: boolean;
audioChunkDuration: number; // new field
+ useChineseMirror: boolean; // Add this line
}
let store: Awaited<ReturnType<typeof createStore>> | null = null;
@@ -159,6 +161,8 @@ export function useSettings() {
(await store!.get<boolean>("analyticsEnabled")) || true;
const savedAudioChunkDuration =
(await store!.get<number>("audioChunkDuration")) || 30;
+ const savedUseChineseMirror =
+ (await store!.get<boolean>("useChineseMirror")) || false;
setSettings({
openaiApiKey: savedKey,
deepgramApiKey: savedDeepgramKey,
@@ -185,6 +189,7 @@ export function useSettings() {
vadSensitivity: savedVadSensitivity,
analyticsEnabled: savedAnalyticsEnabled,
audioChunkDuration: savedAudioChunkDuration,
+ useChineseMirror: savedUseChineseMirror,
});
} catch (error) {
console.error("failed to load settings:", error);
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index d0c0ee426..e27db6357 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.2.96"
+version = "0.2.97"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index cda9bbfe1..267ca408f 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -157,6 +157,11 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
.and_then(|v| v.as_bool())
.unwrap_or(true);
+ let use_chinese_mirror = store
+ .get("useChineseMirror")
+ .and_then(|v| v.as_bool())
+ .unwrap_or(false);
+
println!("audio_chunk_duration: {}", audio_chunk_duration);
let port_str = port.to_string();
@@ -249,6 +254,8 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
args.push("--disable-telemetry");
}
+
+
// args.push("--debug");
if cfg!(windows) {
@@ -258,12 +265,17 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
.expect("Failed to get parent directory of executable")
.to_path_buf();
let tessdata_path = exe_dir.join("tessdata");
- let c = app
+ let mut c = app
.shell()
.sidecar("screenpipe")
.unwrap()
- .env("TESSDATA_PREFIX", tessdata_path)
- .args(&args);
+ .env("TESSDATA_PREFIX", tessdata_path);
+
+ if use_chinese_mirror {
+ c = c.env("HF_ENDPOINT", "https://hf-mirror.com");
+ }
+
+ let c = c.args(&args);
let (_, child) = c.spawn().map_err(|e| {
error!("Failed to spawn sidecar: {}", e);
@@ -275,7 +287,13 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
return Ok(child);
}
- let command = app.shell().sidecar("screenpipe").unwrap().args(&args);
+ let mut command = app.shell().sidecar("screenpipe").unwrap();
+
+ if use_chinese_mirror {
+ command = command.env("HF_ENDPOINT", "https://hf-mirror.com");
+ }
+
+ let command = command.args(&args);
let result = command.spawn();
if let Err(e) = result {