Skip to content

Self-improving AI Employees for everyone

feat(design-system): Phase 1 - toast migration to sonner

trohitg7ac69feb8356
diff --git a/client/package.json b/client/package.json
index 46b1bab0..5aec3531 100644
--- a/client/package.json
+++ b/client/package.json
@@ -50,6 +50,7 @@
"reactflow": "^11.11.4",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
+ "sonner": "^2.0.7",
"styled-components": "^6.1.19",
"tailwind-merge": "^3.5.0",
"tailwindcss": "^4.1.13",
diff --git a/client/src/App.tsx b/client/src/App.tsx
index 353c3895..1d476158 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -4,6 +4,7 @@ import Dashboard from './Dashboard';
import ProtectedRoute from './components/auth/ProtectedRoute';
import { lightTheme, darkTheme } from './config/antdTheme';
import { useTheme } from './contexts/ThemeContext';
+import { Toaster } from './design-system';
const App: React.FC = () => {
const { isDarkMode } = useTheme();
@@ -20,6 +21,7 @@ const App: React.FC = () => {
<Dashboard />
</div>
</ProtectedRoute>
+ <Toaster />
</ConfigProvider>
);
}
diff --git a/client/src/components/PricingConfigModal.tsx b/client/src/components/PricingConfigModal.tsx
index 8cbb70e9..4c30e0f3 100644
--- a/client/src/components/PricingConfigModal.tsx
+++ b/client/src/components/PricingConfigModal.tsx
@@ -4,7 +4,8 @@
*/
import React, { useState, useEffect, useCallback } from 'react';
-import { Button, Tabs, InputNumber, Collapse, Spin, message } from 'antd';
+import { Button, Tabs, InputNumber, Collapse, Spin } from 'antd';
+import { toast } from '../design-system';
import {
SaveOutlined,
ReloadOutlined,
@@ -165,7 +166,7 @@ const PricingConfigModal: React.FC<Props> = ({ visible, onClose }) => {
setConfig(data);
setIsDirty(false);
} catch (error) {
- message.error('Failed to load pricing config');
+ toast.error('Failed to load pricing config');
} finally {
setLoading(false);
}
@@ -184,13 +185,13 @@ const PricingConfigModal: React.FC<Props> = ({ visible, onClose }) => {
try {
const success = await savePricingConfig(config);
if (success) {
- message.success('Pricing config saved');
+ toast.success('Pricing config saved');
setIsDirty(false);
} else {
- message.error('Failed to save pricing config');
+ toast.error('Failed to save pricing config');
}
} catch (error) {
- message.error('Failed to save pricing config');
+ toast.error('Failed to save pricing config');
} finally {
setSaving(false);
}
diff --git a/client/src/components/parameterPanel/MasterSkillEditor.tsx b/client/src/components/parameterPanel/MasterSkillEditor.tsx
index c0a769a5..fc7ff304 100644
--- a/client/src/components/parameterPanel/MasterSkillEditor.tsx
+++ b/client/src/components/parameterPanel/MasterSkillEditor.tsx
@@ -11,7 +11,8 @@
*/
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
-import { Input, Select, Checkbox, Button, Spin, List, Badge, Empty, Tooltip, Alert, Popconfirm, message } from 'antd';
+import { Input, Select, Checkbox, Button, Spin, List, Badge, Empty, Tooltip, Alert, Popconfirm } from 'antd';
+import { toast } from '../../design-system';
import { SearchOutlined, ReloadOutlined, InfoCircleOutlined, FolderOutlined, PlusOutlined, DeleteOutlined, SaveOutlined, CloseOutlined } from '@ant-design/icons';
import { useAppTheme } from '../../hooks/useAppTheme';
import { useWebSocket } from '../../contexts/WebSocketContext';
@@ -452,11 +453,11 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
// Validate required fields
if (!pendingSkillData.display_name.trim()) {
- message.error('Display name is required');
+ toast.error('Display name is required');
return;
}
if (!pendingSkillData.instructions.trim()) {
- message.error('Instructions are required');
+ toast.error('Instructions are required');
return;
}
@@ -470,7 +471,7 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
.replace(/^-|-$/g, '');
}
if (!skillName || !/^[a-z0-9-]+$/.test(skillName)) {
- message.error('Invalid skill ID. Use lowercase letters, numbers, and hyphens only.');
+ toast.error('Invalid skill ID. Use lowercase letters, numbers, and hyphens only.');
return;
}
}
@@ -492,7 +493,7 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
const result = await sendRequest<{ skill?: UserSkill; success?: boolean; error?: string }>(handler, payload);
if (result.skill || result.success) {
- message.success(isCreatingNew ? 'Skill created' : 'Skill saved');
+ toast.success(isCreatingNew ? 'Skill created' : 'Skill saved');
await fetchUserSkills();
if (isCreatingNew) {
@@ -506,10 +507,10 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
}
setHasUnsavedChanges(false);
} else {
- message.error(result.error || 'Failed to save skill');
+ toast.error(result.error || 'Failed to save skill');
}
} catch (err: any) {
- message.error(err.message || 'Failed to save skill');
+ toast.error(err.message || 'Failed to save skill');
} finally {
setSavingSkill(false);
}
@@ -520,7 +521,7 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
try {
const result = await sendRequest<{ success: boolean; error?: string }>('delete_user_skill', { name: skillName });
if (result.success) {
- message.success('Skill deleted');
+ toast.success('Skill deleted');
// Remove from config
const newConfig = { ...skillsConfig };
delete newConfig[skillName];
@@ -542,10 +543,10 @@ const MasterSkillEditor: React.FC<MasterSkillEditorProps> = ({
// Refresh user skills list from database
await fetchUserSkills();
} else {
- message.error(result.error || 'Failed to delete skill');
+ toast.error(result.error || 'Failed to delete skill');
}
} catch (err: any) {
- message.error(err.message || 'Failed to delete skill');
+ toast.error(err.message || 'Failed to delete skill');
}
}, [sendRequest, fetchUserSkills, skillsConfig, onConfigChange, selectedSkillName, nodeId, skillFolder]);
diff --git a/client/src/components/parameterPanel/MiddleSection.tsx b/client/src/components/parameterPanel/MiddleSection.tsx
index f66d887f..1e712976 100644
--- a/client/src/components/parameterPanel/MiddleSection.tsx
+++ b/client/src/components/parameterPanel/MiddleSection.tsx
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
-import { Collapse, Progress, Statistic, Spin, Row, Col, Typography, InputNumber, Button, message } from 'antd';
+import { Collapse, Progress, Statistic, Spin, Row, Col, Typography, InputNumber, Button } from 'antd';
+import { toast } from '../../design-system';
import { ThunderboltOutlined, EditOutlined, SaveOutlined } from '@ant-design/icons';
import ParameterRenderer from '../ParameterRenderer';
import ToolSchemaEditor from './ToolSchemaEditor';
@@ -848,9 +849,9 @@ const MiddleSection: React.FC<MiddleSectionProps> = ({
updateCompactionStats(currentWorkflow.id, connectedMemorySessionId, { ...compactionStats, threshold: editThresholdValue });
}
setIsEditingThreshold(false);
- message.success('Threshold updated');
+ toast.success('Threshold updated');
} catch (_err) {
- message.error('Failed to update threshold');
+ toast.error('Failed to update threshold');
} finally {
setSavingThreshold(false);
}
diff --git a/client/src/components/ui/SettingsPanel.tsx b/client/src/components/ui/SettingsPanel.tsx
index 2f68c0ad..9e85358b 100644
--- a/client/src/components/ui/SettingsPanel.tsx
+++ b/client/src/components/ui/SettingsPanel.tsx
@@ -1,5 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react';
-import { Switch, InputNumber, Slider, Button, message } from 'antd';
+import { Switch, InputNumber, Slider, Button } from 'antd';
+import { toast } from '../../design-system';
import { QuestionCircleOutlined } from '@ant-design/icons';
import Modal from './Modal';
import { useAppTheme } from '../../hooks/useAppTheme';
@@ -94,13 +95,13 @@ const SettingsPanel: React.FC<SettingsPanelProps> = ({
}
});
if (showMessage) {
- message.success('Settings saved successfully');
+ toast.success('Settings saved successfully');
}
console.log('[SettingsPanel] Settings saved to database');
} catch (error) {
console.error('[SettingsPanel] Failed to save settings:', error);
if (showMessage) {
- message.error('Failed to save settings');
+ toast.error('Failed to save settings');
}
} finally {
setIsSaving(false);
diff --git a/client/src/design-system/index.ts b/client/src/design-system/index.ts
index 81a7bc58..6d611fe5 100644
--- a/client/src/design-system/index.ts
+++ b/client/src/design-system/index.ts
@@ -30,3 +30,7 @@ export type { TextProps } from './primitives/Text';
export { Heading } from './primitives/Heading';
export type { HeadingProps } from './primitives/Heading';
+
+export { Toaster } from './primitives/Toaster';
+export { toast } from './lib/toast';
+export type { Toast } from './lib/toast';
diff --git a/client/src/design-system/lib/toast.ts b/client/src/design-system/lib/toast.ts
new file mode 100644
index 00000000..577c4741
--- /dev/null
+++ b/client/src/design-system/lib/toast.ts
@@ -0,0 +1,23 @@
+/**
+ * Thin adapter over sonner so call sites read like the antd API they replace.
+ *
+ * antd: message.success('Saved', 2)
+ * notification.error({ message, description })
+ * here: toast.success('Saved')
+ * toast.error(message, { description })
+ */
+
+import { toast as sonnerToast, type ExternalToast } from 'sonner';
+
+export const toast = {
+ success: (message: string, options?: ExternalToast) => sonnerToast.success(message, options),
+ error: (message: string, options?: ExternalToast) => sonnerToast.error(message, options),
+ warning: (message: string, options?: ExternalToast) => sonnerToast.warning(message, options),
+ info: (message: string, options?: ExternalToast) => sonnerToast.info(message, options),
+ loading: (message: string, options?: ExternalToast) => sonnerToast.loading(message, options),
+ promise: sonnerToast.promise,
+ dismiss: sonnerToast.dismiss,
+ message: sonnerToast,
+};
+
+export type Toast = typeof toast;
diff --git a/client/src/design-system/primitives/Toaster.tsx b/client/src/design-system/primitives/Toaster.tsx
new file mode 100644
index 00000000..1d61aa02
--- /dev/null
+++ b/client/src/design-system/primitives/Toaster.tsx
@@ -0,0 +1,24 @@
+import { Toaster as SonnerToaster } from 'sonner';
+import { useTheme } from '../../contexts/ThemeContext';
+
+/**
+ * App-wide toast renderer. Mount once near the root (App.tsx).
+ * Drives theme from ThemeContext so tokens come from CSS vars automatically.
+ */
+export function Toaster() {
+ const { isDarkMode } = useTheme();
+ return (
+ <SonnerToaster
+ theme={isDarkMode ? 'dark' : 'light'}
+ position="top-right"
+ richColors
+ closeButton
+ toastOptions={{
+ style: {
+ fontFamily: 'var(--font-sans)',
+ borderRadius: 'var(--radius-md)',
+ },
+ }}
+ />
+ );
+}
diff --git a/client/src/hooks/useApiKeyValidation.ts b/client/src/hooks/useApiKeyValidation.ts
index 175454ba..f9b4c3f2 100644
--- a/client/src/hooks/useApiKeyValidation.ts
+++ b/client/src/hooks/useApiKeyValidation.ts
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from 'react';
-import { notification } from 'antd';
+import { toast } from '../design-system';
import { useApiKeys } from './useApiKeys';
export type ValidationStatus = 'idle' | 'validating' | 'valid' | 'invalid';
@@ -49,7 +49,7 @@ export const useApiKeyValidation = ({ provider, onSuccess }: UseApiKeyValidation
const validate = useCallback(async (apiKey: string) => {
if (!provider || !apiKey.trim()) {
- notification.error({ message: 'Please enter an API key' });
+ toast.error('Please enter an API key');
return;
}
@@ -61,18 +61,18 @@ export const useApiKeyValidation = ({ provider, onSuccess }: UseApiKeyValidation
if (result.isValid) {
setStatus('valid');
setHasStoredKeyState(true);
- notification.success({ message: 'API key validated successfully!' });
+ toast.success('API key validated successfully!');
if (result.models?.length && onSuccess) {
onSuccess(result.models);
}
} else {
setStatus('invalid');
- notification.error({ message: result.error || 'Invalid API key' });
+ toast.error(result.error || 'Invalid API key');
}
} catch (error: any) {
setStatus('invalid');
- notification.error({ message: error.message || 'Validation failed' });
+ toast.error(error.message || 'Validation failed');
}
}, [provider, onSuccess, wsValidateApiKey]);
@@ -83,9 +83,9 @@ export const useApiKeyValidation = ({ provider, onSuccess }: UseApiKeyValidation
await wsRemoveApiKey(provider);
setHasStoredKeyState(false);
setStatus('idle');
- notification.success({ message: 'API key cleared' });
+ toast.success('API key cleared');
} catch (error) {
- notification.error({ message: 'Failed to clear API key' });
+ toast.error('Failed to clear API key');
}
}, [provider, wsRemoveApiKey]);
diff --git a/client/src/utils/formatters.ts b/client/src/utils/formatters.ts
index 71563687..085193e9 100644
--- a/client/src/utils/formatters.ts
+++ b/client/src/utils/formatters.ts
@@ -1,5 +1,5 @@
// Common utility functions for formatting and clipboard operations
-import { message } from 'antd';
+import { toast } from '../design-system';
/**
* Copy text to clipboard with error handling
@@ -9,7 +9,7 @@ export const copyToClipboard = async (data: any, successMessage?: string): Promi
const text = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
await navigator.clipboard.writeText(text);
if (successMessage) {
- message.success(successMessage);
+ toast.success(successMessage);
}
return true;
} catch (error) {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a7228a4c..992c3f8b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -149,6 +149,9 @@ importers:
remark-gfm:
specifier: ^4.0.1
version: 4.0.1
+ sonner:
+ specifier: ^2.0.7
styled-components:
specifier: ^6.1.19
@@ -4237,6 +4240,12 @@ packages:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
+ resolution: {integrity: sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w==}
+ peerDependencies:
+ react: ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+ react-dom: ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'}
@@ -9692,6 +9701,11 @@ snapshots:
+ dependencies:
+ react: 19.2.1
+ react-dom: 19.2.1([email protected])
+