diff --git a/packages/core/src/cache/lru-ttl-cache.test.ts b/packages/core/src/cache/lru-ttl-cache.test.ts index 259c0c09..330a62b7 100644 --- a/packages/core/src/cache/lru-ttl-cache.test.ts +++ b/packages/core/src/cache/lru-ttl-cache.test.ts @@ -26,13 +26,13 @@ describe('LruTtlCache', () => { const cache = new LruTtlCache(2) cache.set('key1', 'value1', 1000) cache.set('key2', 'value2', 1000) - + // Access key1 to make it most recently used cache.get('key1') - + // Add key3, which should evict key2 (the least recently used) cache.set('key3', 'value3', 1000) - + expect(cache.get('key1')).toBe('value1') expect(cache.get('key2')).toBeUndefined() expect(cache.get('key3')).toBe('value3') @@ -41,9 +41,9 @@ describe('LruTtlCache', () => { it('should return undefined for expired items', () => { const cache = new LruTtlCache(10) cache.set('key1', 'value1', 1000) - + vi.advanceTimersByTime(1001) - + expect(cache.get('key1')).toBeUndefined() expect(cache.size).toBe(0) }) @@ -51,28 +51,28 @@ describe('LruTtlCache', () => { it('should proactively evict expired items on get', () => { const sampleSize = 5 const cache = new LruTtlCache(100, sampleSize) - + // Set 10 items, all will expire for (let i = 0; i < 10; i++) { cache.set(`key${i}`, `value${i}`, 1000) } - + // Add one item that stays valid cache.set('valid', 'validValue', 5000) - + // Advance time so the 10 items expire vi.advanceTimersByTime(1001) - + // Total size should still be 11 (lazy eviction) expect(cache.size).toBe(11) - + // Call get on the valid item once. It should trigger one evictSample call. // evictSample will check 5 items. cache.get('valid') - + // Size should now be 11 - 5 = 6 expect(cache.size).toBe(6) - + // Call get again, it should evict the remaining 5 expired items cache.get('valid') expect(cache.size).toBe(1) @@ -82,23 +82,23 @@ describe('LruTtlCache', () => { it('should loop through the cache with proactive eviction', () => { // sampleSize = 3 to make sure we cover all items in one go or skip k3 correctly const cache = new LruTtlCache(10, 3) - + cache.set('k1', 'v1', 1000) cache.set('k2', 'v2', 1000) cache.set('k3', 'v3', 5000) - + vi.advanceTimersByTime(1001) - + // First get: evicts k1, k2. Checks k3 (not expired). cache.get('k3') expect(cache.size).toBe(1) - + // Add more items cache.set('k4', 'v4', 1000) cache.set('k5', 'v5', 1000) - + vi.advanceTimersByTime(1001) - + // Second get: evicts k4, k5. cache.get('k3') expect(cache.size).toBe(1) @@ -127,25 +127,25 @@ describe('LruTtlCache', () => { // This test addresses the user's specific request: // "add 100 keys to cache, do a evictSample, and remove 99 keys manually, and do evictSample again, see what happen" const cache = new LruTtlCache(200, 10) - + // Add 100 keys for (let i = 0; i < 100; i++) { cache.set(i, i, 10000) } - + // Initial get to trigger evictSample and initialize the iterator - cache.get(999) - + cache.get(999) + // Remove 99 keys manually (leaving key 99) for (let i = 0; i < 99; i++) { cache.delete(i) } expect(cache.size).toBe(1) - + // Advance time so the remaining key 99 would expire if it was checked vi.advanceTimersByTime(20000) - - // Call get. evictSample should run. + + // Call get. evictSample should run. // The iterator was pointing to something that was deleted. // It should proceed to the next available element (key 99) and evict it. cache.get(999) diff --git a/packages/webui/api/client.ts b/packages/webui/api/client.ts index 278e4c8d..da2da7c1 100644 --- a/packages/webui/api/client.ts +++ b/packages/webui/api/client.ts @@ -11,6 +11,7 @@ const customFetch = async (input: RequestInfo | URL, init?: RequestInit) => { // Don't redirect if we are already on login page, it's an auth request, or we are on a public share page if ( !window.location.pathname.includes('/login') && + !window.location.pathname.includes('/signup') && !window.location.pathname.startsWith('/share/') && !url.includes('/api/authn') ) { diff --git a/packages/webui/components/auth-layout.tsx b/packages/webui/components/auth-layout.tsx new file mode 100644 index 00000000..3a60e4eb --- /dev/null +++ b/packages/webui/components/auth-layout.tsx @@ -0,0 +1,74 @@ +import { ShumaiLogo } from '@/ui/components/ui/icons' +import { CheckCircle2 } from 'lucide-react' +import { ReactNode } from 'react' + +export function AuthLayout({ children }: { children: ReactNode }) { + return ( +
+ {/* Drifting Background Mesh Blobs */} +
+
+ + {/* Main Glassmorphic Split-Pane Card */} +
+ {/* Left Pane (Brand Showcase) */} +
+ {/* Subtle Grid Overlay */} +
+ + {/* Logo & Brand */} +
+ + + Shumai + +
+ + {/* Marketing Copy / Feature Points */} +
+

+ One workspace +
+ for all your +
+ + creative assets. + +

+

+ Upload and index your files, enrich them with custom metadata schemas, draw + annotations directly on media, and gather instant feedback — all in one modern + workspace built for creators. +

+ +
    + {[ + 'Instant asset uploads & high-fidelity media players', + 'Custom metadata schemas & drawing canvas reviews', + 'Frictionless team workspaces & secure sharing', + ].map((text, i) => ( +
  • + + {text} +
  • + ))} +
+
+ + {/* Footer Label */} +
+

+ Join our community of developers and designers. +

+
+
+ + {/* Right Pane (Form Container) */} +
{children}
+
+
+ ) +} diff --git a/packages/webui/routes/login.tsx b/packages/webui/routes/login.tsx index e1ecfadf..e9e58551 100644 --- a/packages/webui/routes/login.tsx +++ b/packages/webui/routes/login.tsx @@ -10,8 +10,9 @@ import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import { z } from 'zod' import { signIn } from '@/ui/lib/auth-client' -import { Loader2, Mail, Lock, ArrowRight, LogIn, CheckCircle2 } from 'lucide-react' +import { Loader2, Mail, Lock, ArrowRight, LogIn } from 'lucide-react' import { ShumaiLogo } from '@/ui/components/ui/icons' +import { AuthLayout } from '@/ui/components/auth-layout' const loginSchema = z.object({ email: z.string().email('Invalid email address'), @@ -77,165 +78,100 @@ function LoginPage() { } return ( -
- {/* Drifting Background Mesh Blobs */} -
-
- - {/* Main Glassmorphic Split-Pane Card */} -
- {/* Left Pane (Brand Showcase) */} -
- {/* Subtle Grid Overlay */} -
- - {/* Logo & Brand */} -
- - - Shumai - -
- - {/* Marketing Copy / Feature Points */} -
-

- One workspace -
- for all your -
- - creative assets. - -

-

- Upload and index your files, enrich them with custom metadata schemas, draw - annotations directly on media, and gather instant feedback — all in one modern - workspace built for creators. -

- -
    - {[ - 'Instant asset uploads & high-fidelity media players', - 'Custom metadata schemas & drawing canvas reviews', - 'Frictionless team workspaces & secure sharing', - ].map((text, i) => ( -
  • - - {text} -
  • - ))} -
-
- - {/* Footer Label */} -
-

- Join our community of developers and designers. -

-
-
- - {/* Right Pane (Form Container) */} -
-
-

- Welcome Back -

-

- Enter your credentials to access your account. -

-
- - {error && ( -
- {error} -
- )} - -
-
- -
- - -
- {form.formState.errors.email && ( -

- {form.formState.errors.email.message} -

- )} -
- -
- -
- - -
- {form.formState.errors.password && ( -

- {form.formState.errors.password.message} -

- )} -
- - -
- -
- Don't have an account? - - Sign up - -
-
+ +
+

+ Welcome Back +

+

+ Enter your credentials to access your account. +

-
+ + {error && ( +
+ {error} +
+ )} + +
+
+ +
+ + +
+ {form.formState.errors.email && ( +

+ {form.formState.errors.email.message} +

+ )} +
+ +
+ +
+ + +
+ {form.formState.errors.password && ( +

+ {form.formState.errors.password.message} +

+ )} +
+ + +
+ +
+ Don't have an account? + + Sign up + +
+ ) } diff --git a/packages/webui/routes/signup.tsx b/packages/webui/routes/signup.tsx index 4edc0dd1..44e3ddd3 100644 --- a/packages/webui/routes/signup.tsx +++ b/packages/webui/routes/signup.tsx @@ -4,7 +4,7 @@ import { Button } from '@/ui/components/ui/button' import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from '@/ui/components/ui/card' import { Input } from '@/ui/components/ui/input' import { Label } from '@/ui/components/ui/label' -import { Loader2, Mail, Lock, CheckCircle2, ArrowRight, UserPlus } from 'lucide-react' +import { Loader2, Mail, Lock, ArrowRight, UserPlus } from 'lucide-react' import { useAuthStore } from '@/ui/stores/auth' import { zodResolver } from '@hookform/resolvers/zod' import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router' @@ -13,6 +13,7 @@ import { z } from 'zod' import { signUp } from '@/ui/lib/auth-client' import { useState } from 'react' import { ShumaiLogo } from '@/ui/components/ui/icons' +import { AuthLayout } from '@/ui/components/auth-layout' const signupSchema = z.object({ email: z.string().email('Invalid email address'), @@ -135,183 +136,118 @@ function SignupPage() { } return ( -
- {/* Drifting Background Mesh Blobs */} -
-
+ +
+

+ Create Account +

+

+ Start building and organizing your space. +

- {/* Main Glassmorphic Split-Pane Card */} -
- {/* Left Pane (Brand Showcase) */} -
- {/* Subtle Grid Overlay */} -
- - {/* Logo & Brand */} -
- - - Shumai + {/* Context Banners (First User / Invite Info) */} + {isFirstUser && ( +
+ 🎉 + You will be the owner of the default workspace as the first user! +
+ )} + {inviteInfo && !('error' in inviteInfo) && ( +
+ 👋 + + {inviteInfo.inviterName} invited you to join{' '} + {inviteInfo.teamName || inviteInfo.projectName} as a{' '} + {inviteInfo.role}.
- - {/* Marketing Copy / Feature Points */} -
-

- One workspace -
- for all your -
- - creative assets. - -

-

- Upload and index your files, enrich them with custom metadata schemas, draw - annotations directly on media, and gather instant feedback — all in one modern - workspace built for creators. -

- -
    - {[ - 'Instant asset uploads & high-fidelity media players', - 'Custom metadata schemas & drawing canvas reviews', - 'Frictionless team workspaces & secure sharing', - ].map((text, i) => ( -
  • - - {text} -
  • - ))} -
-
- - {/* Context Banners (First User / Invite Info) */} -
- {isFirstUser && ( -
- 🎉 - You will be the owner of the default workspace as the first user! -
- )} - {inviteInfo && !('error' in inviteInfo) && ( -
- 👋 - - {inviteInfo.inviterName} invited you to join{' '} - {inviteInfo.teamName || inviteInfo.projectName} as a{' '} - {inviteInfo.role}. - -
- )} - {!isFirstUser && !inviteInfo && ( -

- Join our community of developers and designers. -

- )} -
-
- - {/* Right Pane (Form Container) */} -
-
-

- Create Account -

-

- Start building and organizing your space. -

-
- - {error && ( -
- {error} -
- )} - -
-
- -
- - -
- {form.formState.errors.email && ( -

- {form.formState.errors.email.message} -

- )} -
- -
- -
- - -
- {form.formState.errors.password && ( -

- {form.formState.errors.password.message} -

- )} -
- - -
- -
- Already have an account? - - Login - -
-
+ )}
-
+ + {error && ( +
+ {error} +
+ )} + +
+
+ +
+ + +
+ {form.formState.errors.email && ( +

+ {form.formState.errors.email.message} +

+ )} +
+ +
+ +
+ + +
+ {form.formState.errors.password && ( +

+ {form.formState.errors.password.message} +

+ )} +
+ + +
+ +
+ Already have an account? + + Login + +
+ ) }