diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml index 8ece14b..3898939 100644 --- a/.github/workflows/desktop.yml +++ b/.github/workflows/desktop.yml @@ -271,7 +271,7 @@ jobs: - platform: ubuntu-22.04 # Verbose so a linuxdeploy (AppImage) failure shows its cause. args: '--verbose' - - platform: macos-14 + - platform: macos-15 args: '--target universal-apple-darwin' - platform: windows-latest args: '' @@ -307,7 +307,7 @@ jobs: # `xcrun` is preinstalled on macOS runners, hence placement before the # toolchain steps rather than next to "Configure Apple signing". - name: Preflight Apple notarization credentials - if: matrix.platform == 'macos-14' + if: matrix.platform == 'macos-15' env: CERT: ${{ secrets.APPLE_CERTIFICATE }} A_ID: ${{ secrets.APPLE_ID }} @@ -411,7 +411,7 @@ jobs: with: # macOS builds a universal app; Windows ARM64 also builds the x64 # locus_rust wheel for its emulated Python backend. - targets: ${{ matrix.platform == 'macos-14' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.platform == 'windows-11-arm' && 'x86_64-pc-windows-msvc' || '' }} + targets: ${{ matrix.platform == 'macos-15' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.platform == 'windows-11-arm' && 'x86_64-pc-windows-msvc' || '' }} - name: Rust cache uses: swatinem/rust-cache@v2 @@ -444,7 +444,7 @@ jobs: OLLAMA_TARGET: ${{ matrix.target }} run: | cd frontend/src-tauri/scripts && chmod +x download-ollama.sh - if [[ "${{ matrix.platform }}" == "macos-14" ]]; then + if [[ "${{ matrix.platform }}" == "macos-15" ]]; then # Tauri builds each architecture first, then bundles the universal # app. Ollama's darwin archive already contains both slices, so # download it once and supply all three names Tauri looks for. @@ -473,7 +473,7 @@ jobs: run: | cd frontend/src-tauri/scripts case "${{ matrix.platform }}" in - macos-14) + macos-15) ./download-uv.sh universal-apple-darwin for arch in aarch64 x86_64; do cp ../binaries/uv-universal-apple-darwin "../binaries/uv-${arch}-apple-darwin" diff --git a/.github/workflows/installer-integration.yml b/.github/workflows/installer-integration.yml index 515fffc..741a30e 100644 --- a/.github/workflows/installer-integration.yml +++ b/.github/workflows/installer-integration.yml @@ -85,7 +85,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-14, macos-15] + os: [macos-15] steps: - uses: actions/checkout@v7 diff --git a/README.md b/README.md index f62c5d0..5b251ac 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Locus is that stack. It is a framework for local-first personal AI, built around ## What Locus can do - **Chat on your PC:** talk to a local AI model in the desktop app, your browser, or the terminal, by typing or by voice. +- **Attach files and images:** drop documents (PDF, Word, Excel, PowerPoint, OpenDocument, EPUB, HTML, CSV, code, plain text and more) or images into a chat and ask about them. Images need a vision model such as `qwen3.5` or `gemma3`. +- **Search the web:** turn on **Web search** and Locus looks up your question online first, reads the top pages, and answers with numbered links to its sources. It's off until you turn it on, since it sends your question to a search engine. - **Work with your files:** read and write files and PDFs, search your own documents, run code in a sandbox, and remember facts between conversations. - **Connect your apps:** Gmail, Outlook, Google Calendar, Google Drive, Dropbox, Notion, Obsidian, GitHub, Slack and more, each only after you sign in. - **Reply on messaging apps:** run it as a bot on Telegram, Slack, Discord, WhatsApp, Teams, Signal, email, SMS and about 25 other channels. @@ -188,6 +190,7 @@ Full documentation—including Docker deployment, cloud engines, development set - **Local by default:** models run on your machine through Ollama or another local engine. Nothing goes to a cloud model unless you add your own API key. - **No analytics:** Locus ships with no analytics destination, so no usage data is sent anywhere. See [telemetry](https://aryanjsx.github.io/Locus/telemetry/) for details. +- **Attachments stay local:** attached files are read by Locus on your machine and kept in the app's own storage. Web search is off by default; when you turn it on, only your question goes to the search engine, never your files. - **Opt-in connections:** email, calendar, messaging and other services only work after you connect them, and the data you index stays on your machine. - **Approval for risky actions:** shell commands and similar tools go through an approval step first. diff --git a/docs/leaderboard.md b/docs/leaderboard.md index d8b7d49..9cb0b5a 100644 --- a/docs/leaderboard.md +++ b/docs/leaderboard.md @@ -7,8 +7,8 @@ hide: See how the Locus community saves money, energy, and compute by running AI locally instead of using cloud providers. -!!! info "Win a Mac Mini!" - Opt in to share your savings from the Locus browser app or desktop app for a chance to win a Mac Mini. Your data is fully anonymous — no email, no IP, no hardware info. +!!! info "Sharing is opt-in" + You can choose to share your savings from the Locus browser app or desktop app. Nothing is shared unless you opt in.
diff --git a/docs/telemetry.md b/docs/telemetry.md index 937b612..ee89943 100644 --- a/docs/telemetry.md +++ b/docs/telemetry.md @@ -49,22 +49,16 @@ changed. Configurations without an analytics setting now default to off. Local performance telemetry and Savings Leaderboard participation remain separate settings. -In the browser and desktop apps, the existing **Share Your Savings** dialog -offers explicit buttons without a checkbox. Displaying or closing the dialog -does not enable analytics. Confirm with **Enable analytics only** or -**Enable analytics & enter giveaway**, or use **Continue without sharing** -to turn analytics off. A saved UI choice takes effect immediately in both -the frontend and the running backend. - -Joining the leaderboard requires a display name and contact email submitted -with savings to the configured Supabase leaderboard. Analytics preferences -send only the on/off choice to the local server; names and emails are not -attached to PostHog usage events by this form. The existing Mac mini -promotion concerns leaderboard participation, not analytics consent. -Use **Enter giveaway only** to join with analytics off; submitting the -name/email form with Enter also uses that option. Stopping leaderboard -updates and disabling usage analytics are separate actions. Stopping updates -does not delete previously submitted entries from Supabase. +The browser and desktop apps don't ask about analytics on first launch. +The first-launch dialog only asks for your name, so Locus knows what to call +you; it's saved on your computer in `~/.locus/USER.md` and never sent +anywhere. + +Joining the Savings Leaderboard, from the Savings dashboard, requires a +display name and contact email submitted with savings to the configured +Supabase leaderboard. It's separate from usage analytics, and names and +emails are never attached to analytics events. Stopping leaderboard updates +doesn't delete previously submitted entries from Supabase. ## What we collect diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index caf7f55..c2d9acc 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,10 +13,10 @@ import { SetupScreen } from './components/SetupScreen'; import { Toaster } from './components/ui/sonner'; import { useAppStore } from './lib/store'; import { fetchModels, fetchServerInfo, fetchSavings, submitSavings, isTauri } from './lib/api'; -import { OptInModal } from './components/OptInModal'; +import { ProfileModal } from './components/ProfileModal'; import { UpdateChecker } from './components/Desktop/UpdateChecker'; import { track, hashId } from './lib/analytics'; -import { offerAnalyticsChoice } from './lib/analytics-invitation'; +import { fetchProfile, offerProfilePrompt } from './lib/profile'; export default function App() { const [setupDone, setSetupDone] = useState(!isTauri()); @@ -42,10 +42,9 @@ export default function App() { const optInDisplayName = useAppStore((s) => s.optInDisplayName); const optInEmail = useAppStore((s) => s.optInEmail); const optInAnonId = useAppStore((s) => s.optInAnonId); - const optInModalSeen = useAppStore((s) => s.optInModalSeen); - const optInModalOpen = useAppStore((s) => s.optInModalOpen); - const setOptInModalOpen = useAppStore((s) => s.setOptInModalOpen); - const markOptInModalSeen = useAppStore((s) => s.markOptInModalSeen); + const profileModalOpen = useAppStore((s) => s.profileModalOpen); + const setProfileModalOpen = useAppStore((s) => s.setProfileModalOpen); + const setProfile = useAppStore((s) => s.setProfile); const savings = useAppStore((s) => s.savings); // Apply theme class to @@ -118,13 +117,12 @@ export default function App() { return () => clearInterval(interval); }, [optInEnabled, optInDisplayName, optInEmail, optInAnonId]); // eslint-disable-line react-hooks/exhaustive-deps - // Wait for desktop setup before fetching identity or marking the dialog seen. - useEffect(() => offerAnalyticsChoice({ - ready: setupDone, - sharingModalSeen: optInModalSeen, - open: () => setOptInModalOpen(true), - markSharingModalSeen: markOptInModalSeen, - }), [setupDone, optInModalSeen, setOptInModalOpen, markOptInModalSeen]); + // Once the backend is up, load the user's name and ask for it once. + useEffect(() => { + if (!setupDone) return; + fetchProfile().then(setProfile).catch(() => {}); + offerProfilePrompt({ ready: setupDone, open: () => setProfileModalOpen(true) }); + }, [setupDone, setProfile, setProfileModalOpen]); // Fire model_changed when the user switches models. First mount is // not a "change" — only emit when both prev and current are real and @@ -195,8 +193,8 @@ export default function App() { {commandPaletteOpen && } - {optInModalOpen && ( - setOptInModalOpen(false)} /> + {profileModalOpen && ( + setProfileModalOpen(false)} /> )} ); diff --git a/frontend/src/components/Chat/AttachmentChip.tsx b/frontend/src/components/Chat/AttachmentChip.tsx new file mode 100644 index 0000000..b4bf301 --- /dev/null +++ b/frontend/src/components/Chat/AttachmentChip.tsx @@ -0,0 +1,77 @@ +import { AlertCircle, FileText, Loader2, X } from 'lucide-react'; +import { formatBytes } from '../../lib/attachments'; +import type { AttachmentMeta } from '../../types'; + +interface Props { + name: string; + meta?: AttachmentMeta; + status?: 'reading' | 'ready' | 'error'; + error?: string; + onRemove?: () => void; +} + +/** One attached file: a thumbnail or file icon, its name, and what it is. */ +export function AttachmentChip({ name, meta, status = 'ready', error, onRemove }: Props) { + const problem = status === 'error' ? error : meta?.kind === 'unsupported' ? meta.note : undefined; + const detail = + status === 'reading' + ? 'Reading...' + : status === 'error' + ? "Couldn't read" + : meta + ? [meta.format, formatBytes(meta.size), meta.truncated ? 'long, will be shortened' : ''] + .filter(Boolean) + .join(' · ') + : ''; + + return ( +
+ {meta?.thumbnail ? ( + + ) : ( + + {status === 'reading' ? ( + + ) : problem ? ( + + ) : ( + + )} + + )} + + + {name} + + + {detail} + + + {onRemove && ( + + )} +
+ ); +} diff --git a/frontend/src/components/Chat/InputArea.tsx b/frontend/src/components/Chat/InputArea.tsx index d0b2855..541f5c0 100644 --- a/frontend/src/components/Chat/InputArea.tsx +++ b/frontend/src/components/Chat/InputArea.tsx @@ -1,5 +1,5 @@ import { useState, useRef, useCallback, useEffect } from 'react'; -import { Send, Square, Paperclip, Search } from 'lucide-react'; +import { Send, Square, Paperclip, Search, Globe } from 'lucide-react'; import { toast } from 'sonner'; import { useAppStore, generateId } from '../../lib/store'; import { streamChat, streamResearch } from '../../lib/sse'; @@ -11,8 +11,18 @@ import { resolveChatEngine, } from '../../lib/chat-telemetry'; import { MicButton } from './MicButton'; +import { AttachmentChip } from './AttachmentChip'; import { useSpeech } from '../../hooks/useSpeech'; +import { + apiAttachmentFields, + deletePayloads, + MAX_FILE_BYTES, + MAX_FILES_PER_MESSAGE, + readAttachments, + savePayload, +} from '../../lib/attachments'; import type { + AttachmentMeta, ChatMessage, MessageTelemetry, ResearchSearchTrace, @@ -21,6 +31,15 @@ import type { ToolCallInfo, } from '../../types'; +/** A file in the input box: being read by the server, ready, or failed. */ +interface PendingAttachment { + key: string; + name: string; + status: 'reading' | 'ready' | 'error'; + meta?: AttachmentMeta; + error?: string; +} + // While Deep Research is toggled on, poll connected sources for sync // progress so we can surface "Searching over N items — sync in progress" // next to the toggle. Polling is gated on `enabled` so toggling DR off @@ -100,7 +119,76 @@ export function InputArea() { const modelLoading = useAppStore((s) => s.modelLoading); const deepResearch = useAppStore((s) => s.deepResearch); const setDeepResearch = useAppStore((s) => s.setDeepResearch); + const webSearch = useAppStore((s) => s.webSearch); + const setWebSearch = useAppStore((s) => s.setWebSearch); + const setLastAssistantWebSearch = useAppStore((s) => s.setLastAssistantWebSearch); const corpusSync = useResearchCorpusSync(deepResearch); + + const [pending, setPending] = useState([]); + const [dragging, setDragging] = useState(false); + const fileInputRef = useRef(null); + const readyAttachments = pending.filter((p) => p.status === 'ready' && p.meta); + const attachmentsReading = pending.some((p) => p.status === 'reading'); + + const addFiles = useCallback(async (incoming: File[]) => { + let files = incoming; + if (files.length === 0) return; + const room = MAX_FILES_PER_MESSAGE - pending.filter((p) => p.status !== 'error').length; + if (room <= 0) { + toast.error(`Attach at most ${MAX_FILES_PER_MESSAGE} files per message.`); + return; + } + if (files.length > room) { + toast.error(`Only the first ${room} file(s) were added (${MAX_FILES_PER_MESSAGE} per message).`); + files = files.slice(0, room); + } + for (const f of files.filter((f) => f.size > MAX_FILE_BYTES)) { + toast.error(`${f.name} is larger than 25 MB.`); + } + files = files.filter((f) => f.size <= MAX_FILE_BYTES); + if (files.length === 0) return; + + const keys = files.map(() => generateId()); + setPending((prev) => [ + ...prev, + ...files.map((f, i) => ({ key: keys[i], name: f.name, status: 'reading' as const })), + ]); + try { + const results = await readAttachments(files); + await Promise.all(results.map((res) => savePayload(res.meta.id, res.payload))); + setPending((prev) => + prev.map((p) => { + const i = keys.indexOf(p.key); + return i === -1 ? p : { ...p, status: 'ready', meta: results[i]?.meta }; + }), + ); + } catch (err: any) { + const message = err?.message || 'Could not read the file.'; + toast.error(message); + setPending((prev) => + prev.map((p) => (keys.includes(p.key) ? { ...p, status: 'error', error: message } : p)), + ); + } + }, [pending]); + + const removePending = useCallback((key: string) => { + setPending((prev) => { + const item = prev.find((p) => p.key === key); + if (item?.meta) void deletePayloads([item.meta.id]); + return prev.filter((p) => p.key !== key); + }); + }, []); + + // Web search and Deep Research are separate modes; turning one on turns + // the other off. + const toggleWebSearch = () => { + setWebSearch(!webSearch); + if (!webSearch && deepResearch) setDeepResearch(false); + }; + const toggleDeepResearch = () => { + setDeepResearch(!deepResearch); + if (!deepResearch && webSearch) setWebSearch(false); + }; const isCurrentChatStreaming = streamState.isStreaming && streamState.conversationId === activeId; const { @@ -173,13 +261,24 @@ export function InputArea() { const sendMessage = useCallback(async () => { const content = input.trim(); - if (!content || streamState.isStreaming) return; + const attachments = readyAttachments.map((p) => p.meta!); + if ((!content && attachments.length === 0) || streamState.isStreaming) return; + if (attachmentsReading) { + toast.error('Wait for the attached files to finish reading.'); + return; + } if (!selectedModel) { toast.error('Pick a model first (⌘K)'); return; } + if (deepResearch && attachments.length > 0) { + toast.error("Deep Research can't use attached files. Turn it off to ask about them."); + return; + } + const searchWeb = webSearch && !deepResearch; setInput(''); + setPending([]); let convId = activeId; if (!convId) { @@ -191,15 +290,20 @@ export function InputArea() { role: 'user', content, timestamp: Date.now(), + ...(attachments.length > 0 ? { attachments } : {}), }; addMessage(convId, userMsg); - // Build API messages before adding assistant placeholder + // Build API messages before adding assistant placeholder. Attachment + // content is read back from IndexedDB for every message that has some. const currentMessages = useAppStore.getState().messages; - const apiMessages = currentMessages.map((m) => ({ - role: m.role, - content: m.content, - })); + const apiMessages = await Promise.all( + currentMessages.map(async (m) => ({ + role: m.role, + content: m.content, + ...(m.role === 'user' ? await apiAttachmentFields(m.attachments) : {}), + })), + ); const assistantMsg: ChatMessage = { id: generateId(), @@ -235,7 +339,7 @@ export function InputArea() { setStreamState({ conversationId: convId, isStreaming: true, - phase: deepResearch ? 'Researching...' : 'Generating...', + phase: deepResearch ? 'Researching...' : searchWeb ? 'Searching the web...' : 'Generating...', elapsedMs: 0, activeToolCalls: [], content: '', @@ -376,12 +480,44 @@ export function InputArea() { } } else { for await (const sseEvent of streamChat( - { model: selectedModel, messages: apiMessages, stream: true, temperature, max_tokens: maxTokens }, + { + model: selectedModel, + messages: apiMessages, + stream: true, + temperature, + max_tokens: maxTokens, + ...(searchWeb ? { web_search: true } : {}), + }, controller.signal, )) { const eventName = sseEvent.event; - if (eventName === 'agent_turn_start') { + if (eventName === 'web_search') { + try { + const data = JSON.parse(sseEvent.data); + const sources: ResearchSource[] = (data.sources ?? []).map((src: any) => ({ + ref: src.ref, + title: src.title, + url: src.url, + })); + setLastAssistantWebSearch( + convId, + { query: data.query, engine: data.engine || undefined, error: data.error || undefined }, + sources, + ); + setStreamState({ + phase: data.error ? 'Web search failed, answering without it...' : 'Generating...', + }); + useAppStore.getState().addLogEntry({ + timestamp: Date.now(), + level: data.error ? 'warn' : 'info', + category: 'chat', + message: data.error + ? `Web search failed: ${data.error}` + : `Web search found ${sources.length} source(s)`, + }); + } catch {} + } else if (eventName === 'agent_turn_start') { setStreamState({ phase: 'Agent thinking...' }); } else if (eventName === 'inference_start') { setStreamState({ phase: 'Generating...' }); @@ -552,6 +688,10 @@ export function InputArea() { deepResearch, temperature, maxTokens, + readyAttachments, + attachmentsReading, + webSearch, + setLastAssistantWebSearch, ]); const handleKeyDown = (e: React.KeyboardEvent) => { @@ -567,7 +707,27 @@ export function InputArea() {
+