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/ai preset toasts (#7266)
Manas Raghuwanshi0691a03fd280
diff --git a/apps/screenpipe-app-tauri/bun.lock b/apps/screenpipe-app-tauri/bun.lockindex cbc62c273..7e9f73b0a 100644--- a/apps/screenpipe-app-tauri/bun.lock+++ b/apps/screenpipe-app-tauri/bun.lock@@ -72,7 +72,6 @@"remark-gfm": "^4.0.1","remark-math": "^6.0.0","remark-parse": "^11.0.0",- "sonner": "^2.0.7","tailwind-merge": "^2.6.1","tailwindcss-animate": "^1.0.7","tauri-plugin-sentry-api": "^0.5.0",@@ -2770,8 +2769,6 @@"sonic-boom": ["[email protected]", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q=="],- "sonner": ["[email protected]", "", { "peerDependencies": { "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" } }, "sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w=="],-"source-map": ["[email protected]", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],"source-map-js": ["[email protected]", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.test.tsxindex d1ad423a2..8f0033bc0 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.test.tsx@@ -19,6 +19,7 @@ import {waitFor,} from "@testing-library/react";import { AcpConfigSelector } from "./acp-config-selector";+import { Toaster } from "@/components/ui/toaster";import { useAcpSessionConfig } from "@/lib/stores/acp-session-config";import type { AIPreset } from "@/lib/utils/tauri";@@ -419,6 +420,30 @@ describe("ACP config trigger", () => {);});+ it("shows an error toast when the live session rejects a change", async () => {+ seedSession([modelOption("sonnet")]);+ mocks.setConfigOption.mockResolvedValue({+ status: "error",+ error: "adapter rejected model",+ });++ render(+ <>+ <AcpConfigSelector sessionId={SESSION} agentId="claude-acp" />+ <Toaster />+ </>,+ );++ fireEvent.click(screen.getByTestId("acp-config-trigger"));+ fireEvent.change(screen.getByLabelText("Model"), {+ target: { value: "opus" },+ });++ const toast = await screen.findByTestId("toast-error");+ expect(toast).toHaveTextContent("Could not change model");+ expect(toast).toHaveTextContent("adapter rejected model");+ });+it("keeps a two-value effort axis visible as a select", () => {seedSession([modelOption("sonnet"),diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.tsxindex 656fc3565..9a4bad05a 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/acp-config-selector.tsx@@ -5,7 +5,7 @@import { useState } from "react";import { Loader2, SlidersHorizontal } from "lucide-react";-import { toast } from "sonner";+import { toast } from "@/components/ui/use-toast";import { Switch } from "@/components/ui/switch";import {ComposerSettingsPopover,@@ -244,8 +244,10 @@ export function AcpConfigSelector({try {await action();} catch (error) {- toast.error(ui("Could not change {value1}", { value1: label.toLowerCase() }), {+ toast({+ title: ui("Could not change {value1}", { value1: label.toLowerCase() }),description: String(error),+ variant: "destructive",});} finally {setPendingId(null);diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.test.tsxindex 1d355d7ce..af1a2ca72 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.test.tsx@@ -29,6 +29,7 @@ vi.mock("@/lib/utils/tauri", () => ({}));import { AcpPermissionSelector } from "./acp-permission-selector";+import { Toaster } from "@/components/ui/toaster";const SESSION = "chat-1";const codexModeOption = {@@ -173,6 +174,27 @@ describe("AcpPermissionSelector", () => {expect(mocks.setMode).not.toHaveBeenCalled();});+ it("shows an error toast when the live session rejects a permission change", async () => {+ seedLive();+ mocks.setConfigOption.mockResolvedValue({+ status: "error",+ error: "adapter rejected mode",+ });+ render(+ <>+ <AcpPermissionSelector sessionId={SESSION} agentId="codex-acp" />+ <Toaster />+ </>,+ );++ fireEvent.click(screen.getByTestId("acp-permission-trigger"));+ fireEvent.click(screen.getByTestId("acp-permission-option-agent"));++ const toast = await screen.findByTestId("toast-error");+ expect(toast).toHaveTextContent("Could not change codex permissions");+ expect(toast).toHaveTextContent("adapter rejected mode");+ });+it("uses the saved preset before a live Codex session exists", () => {useAcpSessionConfig.setState({sessions: {},diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.tsxindex ddce5b29a..f9584ff92 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/acp-permission-selector.tsx@@ -13,7 +13,7 @@ import {ShieldCheck,type LucideProps,} from "lucide-react";-import { toast } from "sonner";+import { toast } from "@/components/ui/use-toast";import { Button } from "@/components/ui/button";import {Popover,@@ -349,8 +349,10 @@ export function AcpPermissionSelector({}setOpen(false);} catch (error) {- toast.error(ui("Could not change {value1} permissions", { value1: agentName.toLowerCase() }), {+ toast({+ title: ui("Could not change {value1} permissions", { value1: agentName.toLowerCase() }),description: String(error),+ variant: "destructive",});} finally {setPendingValue(null);diff --git a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.test.tsx b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.test.tsxindex 1f661437c..6c1916905 100644--- a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.test.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.test.tsx@@ -118,11 +118,8 @@ vi.mock("@/lib/utils/tauri", () => ({chatgptOauthLogout: vi.fn(async () => ({ status: "ok", data: true })),},}));-vi.mock("sonner", () => ({- toast: { success: vi.fn(), error: vi.fn() },-}));-import { AIProviderConfig, AIPresetsSelector } from "./ai-presets-selector";+import { Toaster } from "@/components/ui/toaster";import { commands } from "@/lib/utils/tauri";import { tauriFetchWithDeadline } from "@/lib/http/tauri-fetch";@@ -536,6 +533,49 @@ describe("AIPresetsSelector preset deletion", () => {});});+ it("shows the app toast after removing a preset", async () => {+ mocks.settings.current = {+ aiPresets: [originalPreset, localPreset],+ user: { token: "test-token", cloud_subscribed: true },+ };+ render(+ <>+ <AIPresetsSelector compact showModelOnly />+ <Toaster />+ </>,+ );++ fireEvent.click(screen.getByRole("combobox"));+ fireEvent.click(screen.getByRole("button", { name: "Delete original" }));++ expect(await screen.findByTestId("toast-success")).toHaveTextContent(+ "Preset removed",+ );+ });++ it("shows a destructive app toast when removal cannot be saved", async () => {+ mocks.settings.current = {+ aiPresets: [originalPreset, localPreset],+ user: { token: "test-token", cloud_subscribed: true },+ };+ mocks.updateSettings.mockImplementationOnce(() => {+ throw new Error("disk full");+ });+ render(+ <>+ <AIPresetsSelector compact showModelOnly />+ <Toaster />+ </>,+ );++ fireEvent.click(screen.getByRole("combobox"));+ fireEvent.click(screen.getByRole("button", { name: "Delete original" }));++ const toast = await screen.findByTestId("toast-error");+ expect(toast).toHaveTextContent("Cannot delete preset");+ expect(toast).toHaveTextContent("disk full");+ });+it("does not offer deletion for the sole remaining preset", () => {mocks.settings.current = {aiPresets: [originalPreset],diff --git a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsxindex 5f189bd6c..f56c09b13 100644--- a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx@@ -74,7 +74,7 @@ import {AlertTriangle,} from "lucide-react";import { cn } from "@/lib/utils";-import { toast } from "sonner";+import { toast } from "@/components/ui/use-toast";import {Tooltip,TooltipContent,@@ -614,7 +614,7 @@ export function AIProviderConfig({e.preventDefault();if (!selectedProvider) {- toast.error(ui("Choose an AI before continuing"));+ toast({ title: ui("Choose an AI before continuing"), variant: "destructive" });return;}@@ -623,14 +623,16 @@ export function AIProviderConfig({}if (Object.keys(connectionFieldErrors).length > 0) {- toast.error(ui("Fix the connection fields"), {+ toast({+ title: ui("Fix the connection fields"),description: Object.values(connectionFieldErrors)[0],+ variant: "destructive",});return;}if (connectionTestRequired && !connectionTestPassed) {- toast.error(ui("Test the connection before saving"));+ toast({ title: ui("Test the connection before saving"), variant: "destructive" });return;}@@ -1554,7 +1556,8 @@ export const AIPresetsSelector = ({onPresetSaved?.(nextPreset);}- toast.success(ui("Preset changed"), {+ toast({+ title: ui("Preset changed"),description: ui("Switched to {value1} ({value2})", { value1: nextPreset.id, value2: nextPreset.model }),});}@@ -1566,22 +1569,28 @@ export const AIPresetsSelector = ({const handleSavePreset = (preset: Partial<AIPreset>) => {if (!canManageEmployeePresets) {- toast.error(ui("Managed by your organization"), {+ toast({+ title: ui("Managed by your organization"),description: ui("Your admin controls which AI presets are available"),+ variant: "destructive",});return;}if (!preset.id) {- toast.error(ui("Please enter a name for this preset"), {+ toast({+ title: ui("Please enter a name for this preset"),description: ui("Name is required"),+ variant: "destructive",});return;}if (!settings?.aiPresets) {- toast.error(ui("Error"), {+ toast({+ title: ui("Error"),description: ui("Settings not initialized"),+ variant: "destructive",});return;}@@ -1601,8 +1610,10 @@ export const AIPresetsSelector = ({);if (existingPreset) {- toast.error(ui("Name already exists"), {+ toast({+ title: ui("Name already exists"),description: ui("Please choose a different name"),+ variant: "destructive",});return;}@@ -1618,7 +1629,8 @@ export const AIPresetsSelector = ({],});- toast.success(ui("Preset copied"), {+ toast({+ title: ui("Preset copied"),description: ui("New preset has been created from copy"),});} else {@@ -1641,7 +1653,8 @@ export const AIPresetsSelector = ({});}- toast.success(ui("Preset updated"), {+ toast({+ title: ui("Preset updated"),description: ui("Your changes have been saved"),});}@@ -1652,8 +1665,10 @@ export const AIPresetsSelector = ({);if (existingPreset) {- toast.error(ui("Name already exists"), {+ toast({+ title: ui("Name already exists"),description: ui("Please choose a different name"),+ variant: "destructive",});return;}@@ -1683,7 +1698,8 @@ export const AIPresetsSelector = ({});}- toast.success(ui("Preset created"), {+ toast({+ title: ui("Preset created"),description: ui("New preset has been added"),});}@@ -1715,8 +1731,10 @@ export const AIPresetsSelector = ({const handleDuplicatePreset = (preset: AIPreset) => {if (!canManageEmployeePresets || isEnterpriseManagedPreset(preset)) {- toast.error(ui("Managed by your organization"), {+ toast({+ title: ui("Managed by your organization"),description: ui("Your admin controls which AI presets are available"),+ variant: "destructive",});return;}@@ -1738,8 +1756,10 @@ export const AIPresetsSelector = ({const handleEditPreset = (preset: AIPreset) => {if (!canManageEmployeePresets || isEnterpriseManagedPreset(preset)) {- toast.error(ui("Managed by your organization"), {+ toast({+ title: ui("Managed by your organization"),description: ui("Your admin controls which AI presets are available"),+ variant: "destructive",});return;}@@ -1752,8 +1772,10 @@ export const AIPresetsSelector = ({if (!settings?.aiPresets) return;if (preset.defaultPreset) return;if (isManagedDeployment && aiPresetPolicy.lock_default_preset) {- toast.error(ui("Default preset is locked"), {+ toast({+ title: ui("Default preset is locked"),description: ui("Your admin controls the default AI preset"),+ variant: "destructive",});return;}@@ -1772,7 +1794,8 @@ export const AIPresetsSelector = ({onPresetSaved(preset);}- toast.success(ui("Default preset updated"), {+ toast({+ title: ui("Default preset updated"),description: ui("{value1} is now the default preset", { value1: preset.id }),});};@@ -1780,15 +1803,19 @@ export const AIPresetsSelector = ({const handleRemovePreset = async (preset: AIPreset) => {if (!settings?.aiPresets) return;if (!canManageEmployeePresets || isEnterpriseManagedPreset(preset)) {- toast.error(ui("Managed by your organization"), {+ toast({+ title: ui("Managed by your organization"),description: ui("Your admin controls which AI presets are available"),+ variant: "destructive",});return;}if (settings.aiPresets.length <= 1) {- toast.error(ui("Cannot delete preset"), {+ toast({+ title: ui("Cannot delete preset"),description: ui("At least one AI preset is required"),+ variant: "destructive",});return;}@@ -1801,12 +1828,15 @@ export const AIPresetsSelector = ({}try {await updateSettings({ aiPresets: updatedPresets });- toast.success(ui("Preset removed"), {+ toast({+ title: ui("Preset removed"),description: ui("{value1} has been removed", { value1: preset.id }),});} catch (error) {- toast.error(ui("Cannot delete preset"), {+ toast({+ title: ui("Cannot delete preset"),description: error instanceof Error ? error.message : ui("Preset changes could not be saved"),+ variant: "destructive",});}};@@ -2119,7 +2149,8 @@ export const AIPresetsSelector = ({onPresetSaved?.(preset);- toast.success(ui("Preset selected"), {+ toast({+ title: ui("Preset selected"),description: ui("{value1} is now active", { value1: preset.id }),});}diff --git a/apps/screenpipe-app-tauri/package.json b/apps/screenpipe-app-tauri/package.jsonindex 7ae852f85..9b31ae751 100644--- a/apps/screenpipe-app-tauri/package.json+++ b/apps/screenpipe-app-tauri/package.json@@ -153,7 +153,6 @@"remark-gfm": "^4.0.1","remark-math": "^6.0.0","remark-parse": "^11.0.0",- "sonner": "^2.0.7","tailwind-merge": "^2.6.1","tailwindcss-animate": "^1.0.7","tauri-plugin-sentry-api": "^0.5.0",