diff --git a/app/w/components/sidebar/components/settings-modal/components/general/general.tsx b/app/w/components/sidebar/components/settings-modal/components/general/general.tsx index 0cac2f53fd..cc2884d0a9 100644 --- a/app/w/components/sidebar/components/settings-modal/components/general/general.tsx +++ b/app/w/components/sidebar/components/settings-modal/components/general/general.tsx @@ -1,7 +1,28 @@ +import { useRouter } from 'next/navigation' +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from '@/components/ui/alert-dialog' +import { Button } from '@/components/ui/button' import { Label } from '@/components/ui/label' import { Switch } from '@/components/ui/switch' +import { resetAllStores } from '@/stores' export function General() { + const router = useRouter() + + const handleResetData = () => { + resetAllStores() + router.push('/w/1') // Redirect to home page after reset + } + return (
@@ -21,6 +42,38 @@ export function General() {
+ + {/* Danger Zone Section */} +
+
+ + + + + + + + Are you absolutely sure? + + This action cannot be undone. This will permanently delete all your workflows, + settings, and stored data. + + + + Cancel + + Reset All Data + + + + +
+
) } diff --git a/app/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx b/app/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx index 714369b182..0e70706598 100644 --- a/app/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx +++ b/app/w/components/sidebar/components/settings-modal/components/settings-navigation/settings-navigation.tsx @@ -28,10 +28,10 @@ export function SettingsNavigation({ activeSection, onSectionChange }: SettingsN onClick={() => onSectionChange(item.id)} className={cn( 'w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors', - 'hover:bg-accent/50', + 'hover:bg-muted/50', activeSection === item.id - ? 'bg-accent/50 text-foreground font-medium' - : 'text-muted-foreground' + ? 'bg-muted/50 text-foreground font-medium' + : 'text-muted-foreground hover:text-foreground' )} > diff --git a/stores/index.ts b/stores/index.ts new file mode 100644 index 0000000000..21b61dcb34 --- /dev/null +++ b/stores/index.ts @@ -0,0 +1,68 @@ +import { useChatStore } from './chat/store' +import { useConsoleStore } from './console/store' +import { useEnvironmentStore } from './environment/store' +import { useExecutionStore } from './execution/store' +import { useNotificationStore } from './notifications/store' +import { useWorkflowRegistry } from './workflow/registry/store' +import { useWorkflowStore } from './workflow/store' + +/** + * Reset all application stores to their initial state + */ +export const resetAllStores = () => { + // Clear localStorage first + if (typeof window !== 'undefined') { + localStorage.clear() + } + + // Force immediate state reset for all stores + // This ensures in-memory state is also cleared + useWorkflowStore.getState().clear() + useWorkflowRegistry.setState({ + workflows: {}, + activeWorkflowId: null, + isLoading: false, + error: null, + }) + useNotificationStore.setState({ notifications: [] }) + useEnvironmentStore.setState({ variables: {} }) + useExecutionStore.getState().reset() + useConsoleStore.setState({ entries: [], isOpen: false }) + useChatStore.setState({ messages: [], isProcessing: false, error: null }) +} + +/** + * Log the current state of all stores + */ +export const logAllStores = () => { + const state = { + workflow: useWorkflowStore.getState(), + workflowRegistry: useWorkflowRegistry.getState(), + notifications: useNotificationStore.getState(), + environment: useEnvironmentStore.getState(), + execution: useExecutionStore.getState(), + console: useConsoleStore.getState(), + chat: useChatStore.getState(), + } + + console.group('Application State') + Object.entries(state).forEach(([storeName, storeState]) => { + console.group(storeName) + console.log(storeState) + console.groupEnd() + }) + console.groupEnd() + + return state +} + +// Export all stores for convenience +export { + useWorkflowStore, + useWorkflowRegistry, + useNotificationStore, + useEnvironmentStore, + useExecutionStore, + useConsoleStore, + useChatStore, +}