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): resolve store.bin via backend base dir (honors SCREENPIPE_DATA_DIR) (#4779)

Ezra Ellettead49fb529970
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 4bc20cb95..e1e429fe5 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -721,12 +721,30 @@ let _store: Promise<Store> | undefined;
export const getStore = async () => {
if (!_store) {
- // Use homeDir to match Rust backend's get_base_dir which uses $HOME/.screenpipe
- const dir = await homeDir();
- _store = Store.load(`${dir}/.screenpipe/store.bin`, {
- autoSave: false,
- defaults: {},
- });
+ _store = (async () => {
+ // Resolve the base dir via the backend so the webview opens the same
+ // store.bin as Rust (get_base_dir honors SCREENPIPE_DATA_DIR); a
+ // hardcoded ~/.screenpipe here splits the settings store in two
+ // whenever that override is set.
+ let baseDir: string | null = null;
+ try {
+ const res = await commands.getScreenpipeBaseDir();
+ if (res.status === "ok") {
+ baseDir = res.data;
+ } else {
+ console.warn("get_screenpipe_base_dir failed, using ~/.screenpipe:", res.error);
+ }
+ } catch (e) {
+ console.warn("get_screenpipe_base_dir unavailable, using ~/.screenpipe:", e);
+ }
+ if (!baseDir) {
+ baseDir = `${await homeDir()}/.screenpipe`;
+ }
+ return Store.load(`${baseDir}/store.bin`, {
+ autoSave: false,
+ defaults: {},
+ });
+ })();
}
return _store;
};
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index b6fd56584..b834b7cc8 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -553,6 +553,18 @@ async getCachedSuggestions() : Promise<Result<CachedSuggestions, string>> {
else return { status: "error", error: e as any };
}
},
+/**
+ * Resolve the chat-conversations directory under the *active* screenpipe data
+ * dir (honors `SCREENPIPE_DATA_DIR` / a relocated data dir), creating it if
+ * needed. The frontend previously hardcoded `~/.screenpipe/chats` via
+ * `homeDir()`, which (a) ignored a relocated data dir and (b) leaked the
+ * developer's real chats into isolated e2e runs.
+ *
+ * One-time migration: for a relocated data dir whose `chats/` is still empty,
+ * copy conversations from the legacy `~/.screenpipe/chats` so history isn't
+ * orphaned. Skipped under e2e (`SCREENPIPE_E2E_SEED` set) so isolated runs
+ * stay empty.
+ */
async getChatsDir() : Promise<Result<string, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("get_chats_dir") };
@@ -703,6 +715,20 @@ async getPendingUpdate() : Promise<Result<PendingUpdateSnapshot | null, null>> {
else return { status: "error", error: e as any };
}
},
+/**
+ * Tauri command: absolute path of the screenpipe base dir (where store.bin
+ * lives). Honors SCREENPIPE_DATA_DIR; the webview must use this instead of
+ * hardcoding ~/.screenpipe, or it reads/writes a different settings file
+ * than the Rust side whenever the override is set.
+ */
+async getScreenpipeBaseDir() : Promise<Result<string, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("get_screenpipe_base_dir") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
/**
* Get sync configuration.
*/
@@ -2668,7 +2694,7 @@ macosInputVpioEnabled?: boolean;
*/
screenpipeAecEnabled?: boolean;
/**
- * Durable AEC engine choice. Missing legacy values intentionally migrate to Screenpipe AEC.
+ * Durable AEC engine choice. Missing values default to off so AEC remains opt-in.
*/
aecMode?: AecMode;
/**
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/config.rs b/apps/screenpipe-app-tauri/src-tauri/src/config.rs
index 06dd0cf03..05cfa7754 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/config.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/config.rs
@@ -24,6 +24,18 @@ pub fn get_base_dir(
Ok(local_data_dir)
}
+/// Tauri command: absolute path of the screenpipe base dir (where store.bin
+/// lives). Honors SCREENPIPE_DATA_DIR; the webview must use this instead of
+/// hardcoding ~/.screenpipe, or it reads/writes a different settings file
+/// than the Rust side whenever the override is set.
+#[tauri::command]
+#[specta::specta]
+pub async fn get_screenpipe_base_dir(app: tauri::AppHandle) -> Result<String, String> {
+ get_base_dir(&app, None)
+ .map(|p| p.to_string_lossy().into_owned())
+ .map_err(|e| e.to_string())
+}
+
/// Resolve the recording data directory from the store's `data_dir` setting.
///
/// Returns `(resolved_path, fell_back)` where `fell_back` is true when the