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
feat: cursor like context in obsidian pipe
Louis Beaumont83ee88f44875
diff --git a/pipes/obsidian/bun.lockb b/pipes/obsidian/bun.lockbindex 0b87f14cb..e883617bf 100755Binary files a/pipes/obsidian/bun.lockb and b/pipes/obsidian/bun.lockb differdiff --git a/pipes/obsidian/package.json b/pipes/obsidian/package.jsonindex 91eb9829b..894ef9548 100644--- a/pipes/obsidian/package.json+++ b/pipes/obsidian/package.json@@ -23,7 +23,7 @@"@radix-ui/react-tabs": "^1.1.2","@radix-ui/react-toast": "^1.2.4","@radix-ui/react-tooltip": "^1.1.5",- "@screenpipe/browser": "0.1.17",+ "@screenpipe/browser": "0.1.21","@screenpipe/js": "1.0.0","@shadcn/ui": "^0.0.4","@tanstack/react-query": "^5.62.7",diff --git a/pipes/obsidian/src/app/api/files/route.ts b/pipes/obsidian/src/app/api/files/route.tsnew file mode 100644index 000000000..fe356fa3f--- /dev/null+++ b/pipes/obsidian/src/app/api/files/route.ts@@ -0,0 +1,159 @@+import { NextResponse } from "next/server";+import path from "path";+import fs from "fs/promises";+import { pipe } from "@screenpipe/js";++// Force Node.js runtime+export const runtime = "nodejs";+export const dynamic = "force-dynamic";++// Cache for vault files - invalidated every 5 minutes+let filesCache: {+ files: string[];+ vaultPath: string;+ timestamp: number;+} | null = null;++const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes++async function findObsidianRoot(startPath: string): Promise<string | null> {+ let currentPath = startPath;++ while (currentPath !== path.parse(currentPath).root) {+ try {+ const hasObsidianDir = await fs+ .access(path.join(currentPath, ".obsidian"))+ .then(() => true)+ .catch(() => false);++ if (hasObsidianDir) {+ return currentPath;+ }++ currentPath = path.dirname(currentPath);+ } catch (error) {+ return null;+ }+ }+ return null;+}++async function getAllFiles(vaultPath: string): Promise<string[]> {+ // Check cache first+ if (+ filesCache &&+ filesCache.vaultPath === vaultPath &&+ Date.now() - filesCache.timestamp < CACHE_DURATION+ ) {+ return filesCache.files;+ }++ async function getFiles(dir: string): Promise<string[]> {+ const entries = await fs.readdir(dir, { withFileTypes: true });+ const files = await Promise.all(+ entries.map(async (entry) => {+ const res = path.resolve(dir, entry.name);+ // Skip .obsidian directory+ if (entry.isDirectory() && entry.name !== ".obsidian") {+ return getFiles(res);+ }+ return entry.isFile() && entry.name.endsWith(".md") ? res : [];+ })+ );+ return files.flat();+ }++ const allFiles = await getFiles(vaultPath);+ const relativeFiles = allFiles.map((file) => path.relative(vaultPath, file));++ // Update cache+ filesCache = {+ files: relativeFiles,+ vaultPath,+ timestamp: Date.now(),+ };++ return relativeFiles;+}++function getSearchScore(file: string, searchTerms: string[]): number {+ const lowerFile = file.toLowerCase();+ const fileName = path.basename(file).toLowerCase();+ let score = 0;++ // Exact filename match gets highest score+ if (fileName === searchTerms.join(" ").toLowerCase()) {+ score += 1000;+ }++ // Filename contains all terms in order+ if (fileName.includes(searchTerms.join(" ").toLowerCase())) {+ score += 500;+ }++ // Individual term matches in filename+ for (const term of searchTerms) {+ if (fileName.includes(term)) {+ score += 100;+ }+ }++ // Path matches+ for (const term of searchTerms) {+ if (lowerFile.includes(term)) {+ score += 10;+ }+ }++ return score;+}++export async function GET(request: Request) {+ try {+ const { searchParams } = new URL(request.url);+ const search = searchParams.get("search") || "";+ console.log("search term:", search);++ const settingsManager = pipe.settings;+ if (!settingsManager) {+ throw new Error("settingsManager not found");+ }++ const settings = await settingsManager.getAll();+ const initialPath = settings.customSettings?.obsidian?.path;++ if (!initialPath) {+ return NextResponse.json({ files: [] });+ }++ const vaultPath = await findObsidianRoot(initialPath);+ console.log("vault root path:", vaultPath);++ if (!vaultPath) {+ return NextResponse.json({ files: [] });+ }++ const allFiles = await getAllFiles(vaultPath);++ // Optimize search with lowercase and pre-split search terms+ const searchTerms = search.toLowerCase().split(/\s+/);++ const matchingFiles = allFiles+ .filter((file) => {+ const lowerFile = file.toLowerCase();+ return searchTerms.every((term) => lowerFile.includes(term));+ })+ .map((file) => ({+ file,+ score: getSearchScore(file, searchTerms),+ }))+ .sort((a, b) => b.score - a.score) // Sort by score descending+ .map(({ file }) => file) // Extract just the filename+ .slice(0, 50); // Limit results to 50 files++ return NextResponse.json({ files: matchingFiles });+ } catch (error) {+ console.error("Error fetching files:", error);+ return NextResponse.json({ files: [] });+ }+}diff --git a/pipes/obsidian/src/app/api/log/route.ts b/pipes/obsidian/src/app/api/log/route.tsindex 61471c0d3..cd3b3fc9d 100644--- a/pipes/obsidian/src/app/api/log/route.ts+++ b/pipes/obsidian/src/app/api/log/route.ts@@ -18,19 +18,95 @@ type WorkLog = z.infer<typeof workLog> & {endTime: string;};+async function readObsidianFile(filePath: string): Promise<string> {+ try {+ const content = await fs.readFile(filePath, "utf8");+ return content;+ } catch (err) {+ console.error(`failed to read file ${filePath}:`, err);+ return "";+ }+}++async function findVaultRoot(startPath: string): Promise<string> {+ let currentPath = startPath;++ while (currentPath !== "/" && currentPath !== ".") {+ try {+ // Check if .obsidian exists in current directory+ await fs.access(path.join(currentPath, ".obsidian"));+ return currentPath; // Found the vault root+ } catch {+ // Move up one directory+ currentPath = path.dirname(currentPath);+ }+ }+ throw new Error("could not find obsidian vault root (.obsidian folder)");+}++async function extractLinkedContent(+ prompt: string,+ basePath: string+): Promise<string> {+ try {+ // Find the vault root first+ const vaultRoot = await findVaultRoot(basePath);++ // Match [[file]] or [[folder/file]] patterns+ const linkRegex = /\[\[(.*?)\]\]/g;+ const matches = [...prompt.matchAll(linkRegex)];++ let enrichedPrompt = prompt;++ for (const match of matches) {+ const relativePath = match[1];+ // Handle .md extension if not present+ const fullPath = path.join(+ vaultRoot,+ relativePath.endsWith(".md") ? relativePath : `${relativePath}.md`+ );++ try {+ const content = await readObsidianFile(fullPath);+ // Replace the [[link]] with actual content+ enrichedPrompt = enrichedPrompt.replace(+ match[0],+ `\n--- Content of ${relativePath} ---\n${content}\n---\n`+ );+ } catch (err) {+ console.error(`failed to process link ${relativePath}:`, err);+ }+ }++ return enrichedPrompt;+ } catch (err) {+ console.error("failed to find vault root:", err);+ return prompt; // Return original prompt if we can't process links+ }+}+async function generateWorkLog(screenData: ContentItem[],model: string,startTime: Date,endTime: Date,- customPrompt?: string+ customPrompt?: string,+ obsidianPath?: string): Promise<WorkLog> {+ let enrichedPrompt = customPrompt || "";++ if (customPrompt && obsidianPath) {+ enrichedPrompt = await extractLinkedContent(customPrompt, obsidianPath);+ }+const defaultPrompt = `Based on the following screen data, generate a concise work activity log entry.Rules:- use the screen data to generate the log entry- focus on describing the activity and tags-- User custom prompt: ${customPrompt}+ - use the following context to better understand the user's goals and priorities:++ ${enrichedPrompt}+Screen data: ${JSON.stringify(screenData)}Return a JSON object with:@@ -40,6 +116,8 @@ async function generateWorkLog("tags": ["#tag1", "#tag2", "#tag3"]}`;+ console.log("enrichedPrompt prompt:", enrichedPrompt);+const provider = ollama(model);const response = await generateObject({model: provider,@@ -134,7 +212,8 @@ export async function GET() {model,oneHourAgo,now,- customPrompt+ customPrompt,+ obsidianPath);const _ = await syncLogToObsidian(logEntry, obsidianPath);diff --git a/pipes/obsidian/src/app/api/settings/route.ts b/pipes/obsidian/src/app/api/settings/route.tsindex 0946bea6d..9664a1784 100644--- a/pipes/obsidian/src/app/api/settings/route.ts+++ b/pipes/obsidian/src/app/api/settings/route.ts@@ -86,6 +86,7 @@ export async function GET() {// Merge with current settingsconst rawSettings = await settingsManager.getAll();+ console.log("rawSettings", rawSettings);return NextResponse.json({...rawSettings,customSettings: {diff --git a/pipes/obsidian/src/components/file-suggest-textarea.tsx b/pipes/obsidian/src/components/file-suggest-textarea.tsxnew file mode 100644index 000000000..79f4c6003--- /dev/null+++ b/pipes/obsidian/src/components/file-suggest-textarea.tsx@@ -0,0 +1,235 @@+"use client";++import { useState, useRef, useCallback, useEffect } from "react";+import { Command } from "cmdk";+import React from "react";++interface FileSuggestTextareaProps {+ value: string;+ setValue: (value: string) => void;+ className?: string;+ placeholder?: string;+ disabled?: boolean;+}++function highlightMatch(text: string, search: string) {+ if (!search) return text;+ const index = text.toLowerCase().indexOf(search.toLowerCase());+ if (index === -1) return text;++ return (+ <>+ {text.slice(0, index)}+ <span className="bg-yellow-200 dark:bg-yellow-800">+ {text.slice(index, index + search.length)}+ </span>+ {text.slice(index + search.length)}+ </>+ );+}++function getDisplayName(fullPath: string): { dir: string; file: string } {+ const parts = fullPath.split("/");+ const file = parts.pop() || "";+ const dir = parts.join("/");+ return { dir, file };+}++export function FileSuggestTextarea({+ value,+ setValue,+ className = "",+ placeholder,+ disabled = false,+}: FileSuggestTextareaProps) {+ const [showSuggestions, setShowSuggestions] = useState(false);+ const [searchTerm, setSearchTerm] = useState("");+ const [cursorCoords, setCursorCoords] = useState({ x: 0, y: 0 });+ const [files, setFiles] = useState<string[]>([]);+ const textareaRef = useRef<HTMLTextAreaElement>(null);+ const searchTimeout = useRef<NodeJS.Timeout | undefined>(undefined);+ const cursorPosRef = useRef<number | null>(null);++ // Optimized debounce with cleanup+ const debouncedFetch = useCallback((search: string) => {+ if (searchTimeout.current) {+ clearTimeout(searchTimeout.current);+ }++ if (search.length < 2) {+ setFiles([]);+ return;+ }++ searchTimeout.current = setTimeout(async () => {+ try {+ const res = await fetch(+ `/api/files?search=${encodeURIComponent(search)}`+ );+ const data = await res.json();+ setFiles(data.files);+ } catch (err) {+ console.error("failed to fetch files:", err);+ setFiles([]);+ }+ }, 150); // Reduced debounce time+ }, []);++ const getCursorCoordinates = () => {+ const textarea = textareaRef.current;+ if (!textarea) return;++ const { selectionStart, value } = textarea;+ const textBeforeCursor = value.slice(0, selectionStart);++ const div = document.createElement("div");+ div.style.position = "absolute";+ div.style.visibility = "hidden";+ div.style.whiteSpace = "pre-wrap";+ div.style.wordWrap = "break-word";+ div.style.width = getComputedStyle(textarea).width;+ div.style.font = getComputedStyle(textarea).font;+ div.style.padding = getComputedStyle(textarea).padding;+ div.style.border = getComputedStyle(textarea).border;++ div.innerHTML = textBeforeCursor.replace(/\n/g, "<br>");+ document.body.appendChild(div);++ const rect = textarea.getBoundingClientRect();+ const divRect = div.getBoundingClientRect();+ const scrollTop = textarea.scrollTop;++ document.body.removeChild(div);++ return {+ x: rect.left + (divRect.width % rect.width),+ y: rect.top + divRect.height - scrollTop,+ };+ };++ const handleTextareaChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {+ if (disabled) return;+ const newValue = e.target.value;+ const cursorPos = e.target.selectionStart;++ // Update value first+ setValue(newValue);++ const textBeforeCursor = newValue.slice(0, cursorPos);+ const match = textBeforeCursor.match(/@([^@\n\[\](){}<>]*?)$/);++ if (match) {+ const newSearchTerm = match[1].trim();+ setSearchTerm(newSearchTerm);+ setShowSuggestions(true);+ const coords = getCursorCoordinates();+ if (coords) {+ setCursorCoords(coords);+ }+ debouncedFetch(newSearchTerm);+ } else {+ setShowSuggestions(false);+ setFiles([]);+ }+ };++ const handleSuggestionSelect = (file: string) => {+ if (!textareaRef.current) return;++ const cursorPos = textareaRef.current.selectionStart;+ const textBeforeCursor = value.slice(0, cursorPos);+ const textAfterCursor = value.slice(cursorPos);+ const lastAtPos = textBeforeCursor.lastIndexOf("@");++ const insertText = `@[[${file}]] `;+ const newValue =+ textBeforeCursor.slice(0, lastAtPos) + insertText + textAfterCursor;++ // Calculate new cursor position after the inserted text+ const newCursorPos = lastAtPos + insertText.length;+ cursorPosRef.current = newCursorPos;++ setValue(newValue);+ setShowSuggestions(false);++ // Ensure focus remains on textarea+ setTimeout(() => {+ if (textareaRef.current) {+ textareaRef.current.focus();+ textareaRef.current.selectionStart = newCursorPos;+ textareaRef.current.selectionEnd = newCursorPos;+ }+ }, 0);+ };++ // Cleanup on unmount+ useEffect(() => {+ return () => {+ if (searchTimeout.current) {+ clearTimeout(searchTimeout.current);+ }+ };+ }, []);++ // Remove the cursor position effect as it's causing the double typing+ useEffect(() => {+ if (textareaRef.current) {+ textareaRef.current.focus();+ }+ }, [value]);++ return (+ <div className="relative">+ <textarea+ ref={textareaRef}+ value={value}+ onChange={handleTextareaChange}+ className={`w-full min-h-[100px] p-2 rounded-md border bg-background ${+ disabled ? "opacity-50 cursor-not-allowed" : ""+ } ${className}`}+ placeholder={placeholder}+ rows={10}+ disabled={disabled}+ />++ {showSuggestions && !disabled && (+ <div+ className="fixed z-50 w-[400px] max-h-48 overflow-y-auto bg-background border rounded-md shadow-lg"+ style={{+ top: `${cursorCoords.y + 5}px`,+ left: `${cursorCoords.x}px`,+ }}+ >+ <Command>+ <Command.List>+ {files.map((file) => {+ const { dir, file: fileName } = getDisplayName(file);+ return (+ <Command.Item+ key={file}+ onSelect={() => handleSuggestionSelect(file)}+ className="px-2 py-1 hover:bg-accent cursor-pointer flex flex-col gap-0.5"+ >+ <span className="text-sm text-blue-500 font-medium">+ {highlightMatch(fileName, searchTerm)}+ </span>+ {dir && (+ <span className="text-xs text-muted-foreground opacity-60">+ {dir}+ </span>+ )}+ </Command.Item>+ );+ })}+ {files.length === 0 && (+ <div className="px-2 py-1 text-muted-foreground">+ no matching files+ </div>+ )}+ </Command.List>+ </Command>+ </div>+ )}+ </div>+ );+}diff --git a/pipes/obsidian/src/components/obsidian-settings.tsx b/pipes/obsidian/src/components/obsidian-settings.tsxindex 09e9424f2..2199f5e98 100644--- a/pipes/obsidian/src/components/obsidian-settings.tsx+++ b/pipes/obsidian/src/components/obsidian-settings.tsx@@ -1,6 +1,6 @@"use client";-import { useState } from "react";+import { useState, useEffect } from "react";import { useSettings } from "@/lib/hooks/use-settings";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";@@ -22,12 +22,21 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import path from "path";-import { pipe } from "@screenpipe/browser";+import { FileSuggestTextarea } from "./file-suggest-textarea";+import { Skeleton } from "@/components/ui/skeleton";++// This interface represents the shape of obsidian settings+interface ObsidianSettings {+ path: string;+ interval: number;+ pageSize: number;+ aiModel: string;+ prompt: string | null;+}export function ObsidianSettings() {- const { settings, updateSettings } = useSettings();+ const { settings, updateSettings, loading } = useSettings();const [lastLog, setLastLog] = useState<any>(null);- const [loading, setLoading] = useState(false);const { toast } = useToast();const [intelligence, setIntelligence] = useState<any>(null);const [intelligenceLoading, setIntelligenceLoading] = useState(false);@@ -35,6 +44,15 @@ export function ObsidianSettings() {const [intelligenceDeepLink, setIntelligenceDeepLink] = useState<string | null>(null);+ console.log("settings", settings);+ const [customPrompt, setCustomPrompt] = useState<string | null>(null);+ const [testLogLoading, setTestLogLoading] = useState(false);++ useEffect(() => {+ if (settings?.customSettings?.obsidian?.prompt) {+ setCustomPrompt(settings.customSettings.obsidian.prompt);+ }+ }, [settings]);const handleSave = async (e: React.FormEvent) => {e.preventDefault();@@ -50,7 +68,6 @@ export function ObsidianSettings() {return;}- // show loading toastconst loadingToast = toast({title: "saving settings...",description: (@@ -63,19 +80,20 @@ export function ObsidianSettings() {});try {- await updateSettings(- {- // @ts-ignore- path: formData.get("path") as string,- interval: parseInt(formData.get("interval") as string) * 60000,- pageSize: parseInt(formData.get("pageSize") as string),- aiModel: formData.get("aiModel") as string,- prompt: formData.get("prompt") as string,+ const obsidianSettings: ObsidianSettings = {+ path: formData.get("path") as string,+ interval: parseInt(formData.get("interval") as string) * 60000,+ pageSize: parseInt(formData.get("pageSize") as string),+ aiModel: formData.get("aiModel") as string,+ prompt: customPrompt,+ };++ await updateSettings({+ customSettings: {+ obsidian: obsidianSettings,},- "obsidian"- );+ });- // dismiss loading toast and show successloadingToast.update({id: loadingToast.id,title: "settings saved",@@ -92,16 +110,39 @@ export function ObsidianSettings() {};const testLog = async () => {- setLoading(true);+ setTestLogLoading(true);try {+ const formData = new FormData(+ document.querySelector("form") as HTMLFormElement+ );+ const obsidianSettings: ObsidianSettings = {+ path: formData.get("path") as string,+ interval: parseInt(formData.get("interval") as string) * 60000,+ pageSize: parseInt(formData.get("pageSize") as string),+ aiModel: formData.get("aiModel") as string,+ prompt: customPrompt,+ };++ await updateSettings({+ customSettings: {+ obsidian: obsidianSettings,+ },+ });++ // Then test log generationconst res = await fetch("/api/log");const data = await res.json();setLastLog(data);setLogDeepLink(data.deepLink);} catch (err) {console.error("error testing log:", err);+ toast({+ variant: "destructive",+ title: "error",+ description: "failed to test log generation",+ });} finally {- setLoading(false);+ setTestLogLoading(false);}};@@ -130,8 +171,12 @@ export function ObsidianSettings() {await updateSettings({- ...settings.customSettings?.obsidian,- path,+ customSettings: {+ obsidian: {+ ...settings.customSettings?.obsidian,+ path,+ },+ },},"obsidian");@@ -240,6 +285,57 @@ export function ObsidianSettings() {}};+ // Helper function to check if vault path is set+ const isVaultPathSet = () => {+ return Boolean(settings.customSettings?.obsidian?.path?.trim());+ };++ if (loading) {+ return (+ <div className="w-full max-w-4xl mx-auto space-y-8">+ <Tabs defaultValue="logs">+ <TabsList className="grid w-full grid-cols-2">+ <TabsTrigger value="logs">logs</TabsTrigger>+ <TabsTrigger value="intelligence">intelligence (beta)</TabsTrigger>+ </TabsList>++ <TabsContent value="logs" className="space-y-4 w-full my-2">+ <div className="space-y-2">+ <Skeleton className="h-4 w-24" />+ <div className="flex gap-2">+ <Skeleton className="h-10 flex-1" />+ <Skeleton className="h-10 w-10" />+ <Skeleton className="h-10 w-10" />+ </div>+ </div>++ <div className="space-y-2">+ <Skeleton className="h-4 w-32" />+ <Skeleton className="h-10 w-full" />+ </div>++ <div className="space-y-2">+ <Skeleton className="h-4 w-20" />+ <Skeleton className="h-10 w-full" />+ </div>++ <div className="space-y-2">+ <Skeleton className="h-4 w-36" />+ <Skeleton className="h-10 w-full" />+ </div>++ <div className="space-y-2">+ <Skeleton className="h-4 w-24" />+ <Skeleton className="h-32 w-full" />+ </div>++ <Skeleton className="h-10 w-full" />+ </TabsContent>+ </Tabs>+ </div>+ );+ }+return (<div className="w-full max-w-4xl mx-auto space-y-8"><Tabs defaultValue="logs">@@ -275,6 +371,7 @@ export function ObsidianSettings() {onClick={openObsidianVault}className="px-3"title="open in obsidian"+ disabled={!isVaultPathSet()}><ExternalLink className="h-4 w-4" /></Button>@@ -284,6 +381,7 @@ export function ObsidianSettings() {<div className="space-y-2"><Label htmlFor="interval">sync interval (minutes)</Label><Input+ disabled={!isVaultPathSet()}id="interval"name="interval"type="number"@@ -301,6 +399,7 @@ export function ObsidianSettings() {<div className="space-y-2"><Label htmlFor="pageSize">page size</Label><Input+ disabled={!isVaultPathSet()}id="pageSize"name="pageSize"type="number"@@ -313,6 +412,7 @@ export function ObsidianSettings() {<div className="space-y-2"><Label htmlFor="aiModel">ollama/embedded ai model</Label><OllamaModelsList+ disabled={!isVaultPathSet()}defaultValue={settings.customSettings?.obsidian?.aiModel ||"llama3.2:3b-instruct-q4_K_M"@@ -333,38 +433,23 @@ export function ObsidianSettings() {<div className="space-y-2"><Label htmlFor="prompt">custom prompt</Label>- <textarea- id="prompt"- name="prompt"- className="w-full min-h-[100px] p-2 rounded-md border bg-background"- defaultValue={- settings.customSettings?.obsidian?.prompt ||- `yo, you're my personal data detective! 🕵️♂️--rules for the investigation:-- extract names of people i interact with and what we discussed-- identify recurring topics/themes in my convos-- spot any promises or commitments made (by me or others)-- catch interesting ideas or insights dropped in casual chat-- note emotional vibes and energy levels in conversations-- highlight potential opportunities or connections-- track project progress and blockers mentioned--style rules:-- keep it real and conversational-- use bullet points for clarity-- include relevant timestamps-- group related info together-- max 4 lines per insight-- no corporate speak, keep it human-- for tags use hyphen between words, no spaces, eg: #my-tag not #my tag nor #myTag nor #my_tag--remember: you're analyzing screen ocr text & audio, etc. from my computer, so focus on actual interactions and content!`- }+ <FileSuggestTextarea+ value={customPrompt || ""}+ setValue={setCustomPrompt}+ disabled={!isVaultPathSet()}/>+ <p className="text-xs text-muted-foreground">+ make sure to keep the prompt within llm context window size.+ <br />+ protip: use the @mention feature to link to files in your vault as context.+ </p></div>- <Button className="w-full" type="submit">+ <Button+ className="w-full"+ type="submit"+ disabled={!isVaultPathSet()}+ ><FileCheck className="mr-2 h-4 w-4" />save settings</Button>@@ -374,10 +459,17 @@ remember: you're analyzing screen ocr text & audio, etc. from my computer, so fo<ButtononClick={testLog}variant="outline"- disabled={loading}+ disabled={testLogLoading || !isVaultPathSet()}className="w-full">- {loading ? "testing..." : "test log generation"}+ {testLogLoading ? (+ <>+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />+ testing...+ </>+ ) : (+ "test log generation"+ )}</Button>{lastLog && (@@ -535,7 +627,7 @@ remember: you're analyzing screen ocr text & audio, etc. from my computer, so foopen in obsidian</Button>)}- <div className="my-4 h-16"/>+ <div className="my-4 h-16" /></TabsContent></Tabs></div>diff --git a/pipes/obsidian/src/components/ollama-models-list.tsx b/pipes/obsidian/src/components/ollama-models-list.tsxindex a3436e140..7311f95a6 100644--- a/pipes/obsidian/src/components/ollama-models-list.tsx+++ b/pipes/obsidian/src/components/ollama-models-list.tsx@@ -25,9 +25,10 @@ interface OllamaModel {interface Props {defaultValue: string;onChange?: (value: string) => void;+ disabled?: boolean;}-export function OllamaModelsList({ defaultValue, onChange }: Props) {+export function OllamaModelsList({ defaultValue, onChange, disabled }: Props) {const [open, setOpen] = useState(false);const [ollamaModels, setOllamaModels] = useState<OllamaModel[]>([]);const [loading, setLoading] = useState(true);@@ -72,12 +73,20 @@ export function OllamaModelsList({ defaultValue, onChange }: Props) {}return (- <Popover open={open} onOpenChange={setOpen}>+ <Popover+ open={open}+ onOpenChange={(isOpen) => {+ if (!disabled) {+ setOpen(isOpen);+ }+ }}+ ><PopoverTrigger asChild><Buttonvariant="outline"role="combobox"className="w-full justify-between"+ disabled={disabled}><input type="hidden" name="aiModel" value={value} />{value || "select model..."}diff --git a/pipes/obsidian/src/lib/hooks/use-settings.tsx b/pipes/obsidian/src/lib/hooks/use-settings.tsxindex bb5034311..2a4d7a485 100644--- a/pipes/obsidian/src/lib/hooks/use-settings.tsx+++ b/pipes/obsidian/src/lib/hooks/use-settings.tsx@@ -1,36 +1,40 @@"use client";import { useState, useEffect } from "react";-import type { Settings } from "@screenpipe/browser";+import { getDefaultSettings, type Settings } from "@screenpipe/browser";export function useSettings() {- 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,- user: {- token: "",+ const defaultSettings = getDefaultSettings();++ defaultSettings.customSettings = {+ ...(defaultSettings.customSettings || {}),+ obsidian: {+ prompt: `yo, you're my personal data detective! 🕵️♂️++rules for the investigation:+- extract names of people i interact with and what we discussed+- identify recurring topics/themes in my convos+- spot any promises or commitments made (by me or others)+- catch interesting ideas or insights dropped in casual chat+- note emotional vibes and energy levels in conversations+- highlight potential opportunities or connections+- track project progress and blockers mentioned++style rules:+- keep it real and conversational+- use bullet points for clarity+- include relevant timestamps+- group related info together+- max 4 lines per insight+- no corporate speak, keep it human+- for tags use hyphen between words, no spaces, eg: #my-tag not #my tag nor #myTag nor #my_tag++remember: you're analyzing screen ocr text & audio, etc. from my computer, so focus on actual interactions and content!`,},- analyticsEnabled: true,};const [settings, setSettings] = useState<Settings | null>(null);+ console.log("settings", settings);const [loading, setLoading] = useState(true);const [error, setError] = useState<Error | null>(null);