From 5ea436e2be6615f0496d5256cd5f6f8252ab97dd Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 23 Jun 2025 10:15:55 -0700 Subject: [PATCH 1/6] added provider for workspace permissions, 85% reduction in API calls to get user permissions and improved performance for invitations --- apps/sim/app/w/[id]/workflow.tsx | 35 ++++++++++--------- apps/sim/app/w/components/sidebar/sidebar.tsx | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/sim/app/w/[id]/workflow.tsx b/apps/sim/app/w/[id]/workflow.tsx index 2dae7a2b38f..e5a492e05e1 100644 --- a/apps/sim/app/w/[id]/workflow.tsx +++ b/apps/sim/app/w/[id]/workflow.tsx @@ -187,22 +187,25 @@ const WorkflowContent = React.memo(() => { const detectedOrientation = detectHandleOrientation(blocks) // Optimize spacing based on handle orientation - const orientationConfig = - detectedOrientation === 'vertical' - ? { - // Vertical handles: optimize for top-to-bottom flow - horizontalSpacing: 400, - verticalSpacing: 300, - startX: 200, - startY: 200, - } - : { - // Horizontal handles: optimize for left-to-right flow - horizontalSpacing: 600, - verticalSpacing: 200, - startX: 150, - startY: 300, - } + const orientationConfig = useMemo( + () => + detectedOrientation === 'vertical' + ? { + // Vertical handles: optimize for top-to-bottom flow + horizontalSpacing: 400, + verticalSpacing: 300, + startX: 200, + startY: 200, + } + : { + // Horizontal handles: optimize for left-to-right flow + horizontalSpacing: 600, + verticalSpacing: 200, + startX: 150, + startY: 300, + }, + [detectedOrientation] + ) applyAutoLayoutSmooth(blocks, edges, updateBlockPosition, fitView, resizeLoopNodesWrapper, { ...orientationConfig, diff --git a/apps/sim/app/w/components/sidebar/sidebar.tsx b/apps/sim/app/w/components/sidebar/sidebar.tsx index e8485572e82..b1f365e4d5e 100644 --- a/apps/sim/app/w/components/sidebar/sidebar.tsx +++ b/apps/sim/app/w/components/sidebar/sidebar.tsx @@ -25,7 +25,7 @@ import { WorkspaceHeader } from './components/workspace-header/workspace-header' const logger = createLogger('Sidebar') -const IS_DEV = process.env.NODE_ENV === 'development' +const IS_DEV = false export function Sidebar() { useRegistryLoading() From 01bd0b711c8dbee7a4969295f7f1fc6b5bf1d91a Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 23 Jun 2025 10:34:59 -0700 Subject: [PATCH 2/6] parallelized more tests, fixed test warnings --- apps/sim/app/(auth)/login/login-form.test.tsx | 22 +- apps/sim/app/(auth)/login/login-form.tsx | 14 +- .../app/(auth)/signup/signup-form.test.tsx | 22 +- apps/sim/app/api/chat/utils.test.ts | 20 +- apps/sim/app/api/knowledge/utils.test.ts | 268 ++++++++++-------- apps/sim/tools/utils.test.ts | 50 ++-- apps/sim/vitest.setup.ts | 20 +- 7 files changed, 226 insertions(+), 190 deletions(-) diff --git a/apps/sim/app/(auth)/login/login-form.test.tsx b/apps/sim/app/(auth)/login/login-form.test.tsx index 481d546333b..adfc08a5935 100644 --- a/apps/sim/app/(auth)/login/login-form.test.tsx +++ b/apps/sim/app/(auth)/login/login-form.test.tsx @@ -2,7 +2,7 @@ * @vitest-environment jsdom */ -import { fireEvent, render, screen, waitFor } from '@testing-library/react' +import { act, fireEvent, render, screen, waitFor } from '@testing-library/react' import { useRouter, useSearchParams } from 'next/navigation' import { beforeEach, describe, expect, it, vi } from 'vitest' import { client } from '@/lib/auth-client' @@ -104,7 +104,10 @@ describe('LoginPage', () => { it('should show loading state during form submission', async () => { const mockSignIn = vi.mocked(client.signIn.email) mockSignIn.mockImplementation( - () => new Promise((resolve) => resolve({ data: { user: { id: '1' } }, error: null })) + () => + new Promise((resolve) => + setTimeout(() => resolve({ data: { user: { id: '1' } }, error: null }), 100) + ) ) render() @@ -113,12 +116,17 @@ describe('LoginPage', () => { const passwordInput = screen.getByPlaceholderText(/enter your password/i) const submitButton = screen.getByRole('button', { name: /sign in/i }) - fireEvent.change(emailInput, { target: { value: 'test@example.com' } }) - fireEvent.change(passwordInput, { target: { value: 'password123' } }) - fireEvent.click(submitButton) + await act(async () => { + fireEvent.change(emailInput, { target: { value: 'test@example.com' } }) + fireEvent.change(passwordInput, { target: { value: 'password123' } }) + fireEvent.click(submitButton) + }) - expect(screen.getByText('Signing in...')).toBeInTheDocument() - expect(submitButton).toBeDisabled() + // Check for loading state immediately after form submission + await waitFor(() => { + expect(screen.getByText('Signing in...')).toBeInTheDocument() + expect(submitButton).toBeDisabled() + }) }) }) diff --git a/apps/sim/app/(auth)/login/login-form.tsx b/apps/sim/app/(auth)/login/login-form.tsx index 548d20b0508..566aa18cd01 100644 --- a/apps/sim/app/(auth)/login/login-form.tsx +++ b/apps/sim/app/(auth)/login/login-form.tsx @@ -5,7 +5,13 @@ import { Eye, EyeOff } from 'lucide-react' import Link from 'next/link' import { useRouter, useSearchParams } from 'next/navigation' import { Button } from '@/components/ui/button' -import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { client } from '@/lib/auth-client' @@ -494,11 +500,11 @@ export default function LoginPage({ Reset Password + + Enter your email address and we'll send you a link to reset your password. +
-
- Enter your email address and we'll send you a link to reset your password. -