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 chat history disappearing: preserve frontend-only fields in Rust store, fix stale state race
Louis Beaumont14de341671e3
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex c63586f03..2c34c3377 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -372,7 +372,7 @@ function MessageContent({ message }: { message: Message }) {}export function StandaloneChat() {- const { settings, updateSettings, isSettingsLoaded } = useSettings();+ const { settings, updateSettings, isSettingsLoaded, reloadStore } = useSettings();const { isMac } = usePlatform();const { items: appItems } = useSqlAutocomplete("app");@@ -541,13 +541,24 @@ export function StandaloneChat() {setConversationId(conv.id);setShowHistory(false);- if (settings.chatHistory) {- updateSettings({- chatHistory: {- ...settings.chatHistory,- activeConversationId: conv.id,- }- });+ // Update activeConversationId directly in the store (read fresh to avoid+ // overwriting conversations with stale React state)+ try {+ const { getStore } = await import("@/lib/hooks/use-settings");+ const store = await getStore();+ const freshSettings = await store.get<any>("settings");+ if (freshSettings?.chatHistory) {+ await store.set("settings", {+ ...freshSettings,+ chatHistory: {+ ...freshSettings.chatHistory,+ activeConversationId: conv.id,+ }+ });+ await store.save();+ }+ } catch (e) {+ console.warn("Failed to update active conversation:", e);}};@@ -1858,8 +1869,12 @@ export function StandaloneChat() {<Buttonvariant={showHistory ? "secondary" : "ghost"}size="sm"- onClick={(e) => {+ onClick={async (e) => {e.stopPropagation();+ if (!showHistory) {+ // Refresh settings from store to ensure we have latest conversations+ await reloadStore();+ }setShowHistory(!showHistory);}}className="h-7 px-2 gap-1 text-xs"diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rsindex c531c415a..69983dbe7 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs@@ -223,6 +223,12 @@ pub struct SettingsStore {/// Values: "low", "balanced", "high", "max". Default: "balanced".#[serde(rename = "videoQuality", default = "default_video_quality")]pub video_quality: String,++ /// Catch-all for fields added by the frontend (e.g. chatHistory, deviceId)+ /// that the Rust struct doesn't know about. Without this, `save()` would+ /// serialize only known fields and silently wipe frontend-only data.+ #[serde(flatten)]+ pub extra: std::collections::HashMap<String, serde_json::Value>,}fn default_video_quality() -> String {@@ -516,6 +522,7 @@ impl Default for SettingsStore {overlay_mode: "fullscreen".to_string(),show_overlay_in_screen_recording: false,video_quality: "balanced".to_string(),+ extra: std::collections::HashMap::new(),}}}