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 search

Louis Beaumont975cbf129c34
diff --git a/pipes/search/src/lib/actions/settings-actions.ts b/pipes/search/src/lib/actions/settings-actions.ts
index 359387511..eda613e15 100644
--- a/pipes/search/src/lib/actions/settings-actions.ts
+++ b/pipes/search/src/lib/actions/settings-actions.ts
@@ -1,76 +1,80 @@
-'use server';
+"use server";
-import type { Settings } from '@screenpipe/js';
-const { pipe } = await import('@screenpipe/js');
+import type { Settings } from "@screenpipe/js";
+const { pipe } = await import("@screenpipe/js");
export async function getSettings(): Promise<Settings> {
- return {} as Settings;
- // try {
- // const settingsManager = pipe.settings;
- // const rawSettings = await settingsManager.getAll();
-
- // // Create a new plain object with the default settings
- // const defaultSettings: Settings = {
- // openaiApiKey: "",
- // deepgramApiKey: "",
- // aiModel: "gpt-4",
- // aiUrl: "https://api.openai.com/v1",
- // customPrompt: "",
- // port: 3030,
- // dataDir: "default",
- // disableAudio: false,
- // ignoredWindows: [],
- // includedWindows: [],
- // aiProviderType: "openai",
- // embeddedLLM: {
- // enabled: false,
- // model: "llama3.2:1b-instruct-q4_K_M",
- // port: 11438,
- // },
- // enableFrameCache: true,
- // enableUiMonitoring: false,
- // aiMaxContextChars: 128000,
- // };
+ // Create a new plain object with the default settings
+ const defaultSettings: Settings = {
+ openaiApiKey: "",
+ deepgramApiKey: "",
+ aiModel: "gpt-4",
+ aiUrl: "https://api.openai.com/v1",
+ customPrompt: "",
+ port: 3030,
+ dataDir: "default",
+ disableAudio: false,
+ ignoredWindows: [],
+ includedWindows: [],
+ aiProviderType: "openai",
+ embeddedLLM: {
+ enabled: false,
+ model: "llama3.2:1b-instruct-q4_K_M",
+ port: 11438,
+ },
+ enableFrameCache: true,
+ enableUiMonitoring: false,
+ aiMaxContextChars: 128000,
+ };
+ try {
+ const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
+ const rawSettings = await settingsManager.getAll();
- // // Deep clone function that ensures plain objects
- // function deepClone<T>(obj: T): T {
- // if (obj === null || typeof obj !== 'object') {
- // return obj;
- // }
+ // Deep clone function that ensures plain objects
+ function deepClone<T>(obj: T): T {
+ if (obj === null || typeof obj !== "object") {
+ return obj;
+ }
- // if (Array.isArray(obj)) {
- // return obj.map(deepClone) as any;
- // }
+ if (Array.isArray(obj)) {
+ return obj.map(deepClone) as any;
+ }
- // const plainObj = Object.create(null);
- // Object.setPrototypeOf(plainObj, Object.prototype);
+ const plainObj = Object.create(null);
+ Object.setPrototypeOf(plainObj, Object.prototype);
- // for (const [key, value] of Object.entries(obj)) {
- // plainObj[key] = deepClone(value);
- // }
+ for (const [key, value] of Object.entries(obj)) {
+ plainObj[key] = deepClone(value);
+ }
- // return plainObj as T;
- // }
+ return plainObj as T;
+ }
- // // Create a completely new plain object
- // const sanitizedSettings = deepClone({
- // ...defaultSettings,
- // ...rawSettings,
- // });
+ // Create a completely new plain object
+ const sanitizedSettings = deepClone({
+ ...defaultSettings,
+ ...rawSettings,
+ });
- // return sanitizedSettings;
- // } catch (error) {
- // console.error('failed to get settings:', error);
- // // Return a new plain object with default settings on error
- // return { ...defaultSettings };
- // }
+ return sanitizedSettings;
+ } catch (error) {
+ console.error("failed to get settings:", error);
+ // Return a new plain object with default settings on error
+ return { ...defaultSettings };
+ }
}
export async function updateSettingServer<T extends keyof Settings>(
- key: T,
+ key: T,
value: Settings[T]
): Promise<void> {
const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
// Ensure the value is serializable
const serializedValue = JSON.parse(JSON.stringify(value));
await settingsManager.set(key, serializedValue);
@@ -80,6 +84,9 @@ export async function updateSettingsServer(
newSettings: Partial<Settings>
): Promise<void> {
const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
// Ensure the settings are serializable
const serializedSettings = JSON.parse(JSON.stringify(newSettings));
await settingsManager.update(serializedSettings);
@@ -89,6 +96,9 @@ export async function resetSettingsServer(
settingKey?: keyof Settings
): Promise<void> {
const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
if (settingKey) {
await settingsManager.resetKey(settingKey);
} else {