Skip to content

Commit 3faab2c

Browse files
authored
improvement(notifications): add option to disable error notifications, remove deprecated autoFillEnvVars field (#2045)
1 parent 02d9fed commit 3faab2c

File tree

11 files changed

+7753
-23
lines changed

11 files changed

+7753
-23
lines changed

apps/sim/app/api/users/me/settings/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const logger = createLogger('UserSettingsAPI')
1313
const SettingsSchema = z.object({
1414
theme: z.enum(['system', 'light', 'dark']).optional(),
1515
autoConnect: z.boolean().optional(),
16-
autoFillEnvVars: z.boolean().optional(), // DEPRECATED: kept for backwards compatibility
1716
autoPan: z.boolean().optional(),
1817
consoleExpandedByDefault: z.boolean().optional(),
1918
telemetryEnabled: z.boolean().optional(),
@@ -29,13 +28,13 @@ const SettingsSchema = z.object({
2928
showFloatingControls: z.boolean().optional(),
3029
showTrainingControls: z.boolean().optional(),
3130
superUserModeEnabled: z.boolean().optional(),
31+
errorNotificationsEnabled: z.boolean().optional(),
3232
})
3333

3434
// Default settings values
3535
const defaultSettings = {
3636
theme: 'system',
3737
autoConnect: true,
38-
autoFillEnvVars: true, // DEPRECATED: kept for backwards compatibility, always true
3938
autoPan: true,
4039
consoleExpandedByDefault: true,
4140
telemetryEnabled: true,
@@ -44,6 +43,7 @@ const defaultSettings = {
4443
showFloatingControls: true,
4544
showTrainingControls: false,
4645
superUserModeEnabled: false,
46+
errorNotificationsEnabled: true,
4747
}
4848

4949
export async function GET() {
@@ -72,7 +72,6 @@ export async function GET() {
7272
data: {
7373
theme: userSettings.theme,
7474
autoConnect: userSettings.autoConnect,
75-
autoFillEnvVars: userSettings.autoFillEnvVars, // DEPRECATED: kept for backwards compatibility
7675
autoPan: userSettings.autoPan,
7776
consoleExpandedByDefault: userSettings.consoleExpandedByDefault,
7877
telemetryEnabled: userSettings.telemetryEnabled,
@@ -81,6 +80,7 @@ export async function GET() {
8180
showFloatingControls: userSettings.showFloatingControls ?? true,
8281
showTrainingControls: userSettings.showTrainingControls ?? false,
8382
superUserModeEnabled: userSettings.superUserModeEnabled ?? true,
83+
errorNotificationsEnabled: userSettings.errorNotificationsEnabled ?? true,
8484
},
8585
},
8686
{ status: 200 }

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ const WorkflowContent = React.memo(() => {
118118
getDragStartPosition,
119119
} = useWorkflowStore()
120120

121-
// (moved) resizeLoopNodesWrapper defined after hooks that provide resizeLoopNodes
122-
123121
// Get copilot cleanup function
124122
const copilotCleanup = useCopilotStore((state) => state.cleanup)
125123

@@ -656,7 +654,6 @@ const WorkflowContent = React.memo(() => {
656654
data.enableTriggerMode === true
657655

658656
if (isTriggerBlock) {
659-
const triggerName = TriggerUtils.getDefaultTriggerName(data.type) || 'trigger'
660657
addNotification({
661658
level: 'error',
662659
message: 'Triggers cannot be placed inside loop or parallel subflows.',

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components-new/settings-modal/components/general/general.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const TOOLTIPS = {
2727
'Show training controls for recording workflow edits to build copilot training datasets.',
2828
superUserMode:
2929
'Toggle super user mode UI. When enabled, you can see and approve pending templates. Your super user status in the database remains unchanged.',
30+
errorNotifications:
31+
'Show error notifications when blocks fail. When disabled, errors will only appear in the console.',
3032
}
3133

3234
export function General() {
@@ -111,6 +113,12 @@ export function General() {
111113
}
112114
}
113115

116+
const handleErrorNotificationsChange = async (checked: boolean) => {
117+
if (checked !== settings?.errorNotificationsEnabled && !updateSetting.isPending) {
118+
await updateSetting.mutateAsync({ key: 'errorNotificationsEnabled', value: checked })
119+
}
120+
}
121+
114122
return (
115123
<div className='px-6 pt-4 pb-2'>
116124
<div className='flex flex-col gap-4'>
@@ -242,6 +250,36 @@ export function General() {
242250
/>
243251
</div>
244252

253+
<div className='flex items-center justify-between'>
254+
<div className='flex items-center gap-2'>
255+
<Label htmlFor='error-notifications' className='font-normal'>
256+
Error notifications
257+
</Label>
258+
<Tooltip.Root>
259+
<Tooltip.Trigger asChild>
260+
<Button
261+
variant='ghost'
262+
size='sm'
263+
className='h-7 p-1 text-gray-500'
264+
aria-label='Learn more about error notifications'
265+
disabled={updateSetting.isPending}
266+
>
267+
<Info className='h-5 w-5' />
268+
</Button>
269+
</Tooltip.Trigger>
270+
<Tooltip.Content side='top' className='max-w-[300px] p-3'>
271+
<p className='text-sm'>{TOOLTIPS.errorNotifications}</p>
272+
</Tooltip.Content>
273+
</Tooltip.Root>
274+
</div>
275+
<Switch
276+
id='error-notifications'
277+
checked={settings?.errorNotificationsEnabled ?? true}
278+
onCheckedChange={handleErrorNotificationsChange}
279+
disabled={updateSetting.isPending}
280+
/>
281+
</div>
282+
245283
{isTrainingEnabled && (
246284
<div className='flex items-center justify-between'>
247285
<div className='flex items-center gap-2'>

apps/sim/hooks/queries/general-settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface GeneralSettings {
2525
theme: 'light' | 'dark' | 'system'
2626
telemetryEnabled: boolean
2727
billingUsageNotificationsEnabled: boolean
28+
errorNotificationsEnabled: boolean
2829
}
2930

3031
/**
@@ -49,6 +50,7 @@ async function fetchGeneralSettings(): Promise<GeneralSettings> {
4950
theme: data.theme || 'system',
5051
telemetryEnabled: data.telemetryEnabled ?? true,
5152
billingUsageNotificationsEnabled: data.billingUsageNotificationsEnabled ?? true,
53+
errorNotificationsEnabled: data.errorNotificationsEnabled ?? true,
5254
}
5355
}
5456

@@ -69,6 +71,7 @@ function syncSettingsToZustand(settings: GeneralSettings) {
6971
theme: settings.theme,
7072
telemetryEnabled: settings.telemetryEnabled,
7173
isBillingUsageNotificationsEnabled: settings.billingUsageNotificationsEnabled,
74+
isErrorNotificationsEnabled: settings.errorNotificationsEnabled,
7275
})
7376
}
7477

apps/sim/stores/settings/general/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const initialState: General = {
1515
theme: 'system',
1616
telemetryEnabled: true,
1717
isBillingUsageNotificationsEnabled: true,
18+
isErrorNotificationsEnabled: true,
1819
}
1920

2021
export const useGeneralStore = create<GeneralStore>()(

apps/sim/stores/settings/general/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface General {
88
theme: 'system' | 'light' | 'dark'
99
telemetryEnabled: boolean
1010
isBillingUsageNotificationsEnabled: boolean
11+
isErrorNotificationsEnabled: boolean
1112
}
1213

1314
export interface GeneralStore extends General {
@@ -25,4 +26,5 @@ export type UserSettings = {
2526
superUserModeEnabled: boolean
2627
telemetryEnabled: boolean
2728
isBillingUsageNotificationsEnabled: boolean
29+
errorNotificationsEnabled: boolean
2830
}

apps/sim/stores/terminal/console/store.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { redactApiKeys } from '@/lib/utils'
55
import type { NormalizedBlockOutput } from '@/executor/types'
66
import { useExecutionStore } from '@/stores/execution/store'
77
import { useNotificationStore } from '@/stores/notifications'
8+
import { useGeneralStore } from '@/stores/settings/general/store'
89
import type { ConsoleEntry, ConsoleStore, ConsoleUpdate } from './types'
910

1011
const logger = createLogger('TerminalConsoleStore')
@@ -102,24 +103,29 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
102103
const newEntry = get().entries[0]
103104

104105
// Surface error notifications immediately when error entries are added
106+
// Only show if error notifications are enabled in settings
105107
if (newEntry?.error) {
106-
try {
107-
const errorMessage = String(newEntry.error)
108-
109-
useNotificationStore.getState().addNotification({
110-
level: 'error',
111-
message: errorMessage,
112-
workflowId: entry.workflowId,
113-
action: {
114-
type: 'copilot',
108+
const { isErrorNotificationsEnabled } = useGeneralStore.getState()
109+
110+
if (isErrorNotificationsEnabled) {
111+
try {
112+
const errorMessage = String(newEntry.error)
113+
114+
useNotificationStore.getState().addNotification({
115+
level: 'error',
115116
message: errorMessage,
116-
},
117-
})
118-
} catch (notificationError) {
119-
logger.error('Failed to create block error notification', {
120-
entryId: newEntry.id,
121-
error: notificationError,
122-
})
117+
workflowId: entry.workflowId,
118+
action: {
119+
type: 'copilot',
120+
message: errorMessage,
121+
},
122+
})
123+
} catch (notificationError) {
124+
logger.error('Failed to create block error notification', {
125+
entryId: newEntry.id,
126+
error: notificationError,
127+
})
128+
}
123129
}
124130
}
125131

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "settings" ADD COLUMN "error_notifications_enabled" boolean DEFAULT true NOT NULL;--> statement-breakpoint
2+
ALTER TABLE "settings" DROP COLUMN "auto_fill_env_vars";

0 commit comments

Comments
 (0)