Skip to content

Commit 92e5065

Browse files
Feat optimzation render speed (#39)
- optimiztion speed - prevent see anything in auth provider https://github.com/user-attachments/assets/d3f4e2e5-1147-43e3-9b04-1af703979aed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced `LoadingPage` component for a full-screen loading overlay with theme adaptability. - Added `SideBarItem` component for managing chat functionalities in the sidebar. - New `ScrollArea` and `ScrollBar` components for customizable scroll areas. - Introduced `Separator` component for rendering horizontal and vertical separators. - Added `AuthProvider` for managing user authentication state. - New `BaseProviders` component to wrap essential context providers. - **Enhancements** - Improved `ChatList` component with message editing capabilities. - Enhanced `ChatTopbar` for a simplified model selection interface. - Refactored `Sidebar` to utilize props for chat management, improving performance. - **Bug Fixes** - Fixed styling and transition effects on the `LoginPage` component. - **Chores** - Updated various package dependencies for improved functionality and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 7a120f1 commit 92e5065

37 files changed

+1567
-1387
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dist
33
coverage
44
.github
55
.husky
6-
*.config.js
6+
*.config.js

backend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "",
66
"private": true,
77
"license": "UNLICENSED",
8-
"packageManager": "pnpm@9.1.2",
8+
"packageManager": "pnpm@9.1.0",
99
"scripts": {
1010
"build": "nest build",
1111
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",

frontend/.eslintrc.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"extends": "next/core-web-vitals",
3-
"ignorePatterns": ["src/graphql/type.ts", "src/graphql/**/*"]
3+
"ignorePatterns": [
4+
"src/graphql/type.ts",
5+
"src/graphql/**/*",
6+
"src/components/ui/**/*"
7+
]
48
}

frontend/next.config.mjs

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
output: 'standalone',
4+
reactStrictMode: true,
45
webpack: (config, { isServer }) => {
5-
// Fixes npm packages that depend on `fs` module
6-
if (!isServer) {
7-
config.resolve.fallback = {
8-
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
9-
// by next.js will be dropped. Doesn't make much sense, but how it is
10-
fs: false, // the solution
11-
module: false,
12-
perf_hooks: false,
13-
};
14-
}
15-
16-
return config
17-
},
18-
typescript: {
19-
// !! WARN !!
20-
// Dangerously allow production builds to successfully complete even if
21-
// your project has type errors.
22-
// !! WARN !!
23-
ignoreBuildErrors: true,
24-
},
25-
};
26-
6+
// Fixes npm packages that depend on `fs` module
7+
if (!isServer) {
8+
config.resolve.fallback = {
9+
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
10+
// by next.js will be dropped. Doesn't make much sense, but how it is
11+
fs: false, // the solution
12+
module: false,
13+
perf_hooks: false,
14+
};
15+
}
2716

17+
return config;
18+
},
19+
typescript: {
20+
// !! WARN !!
21+
// Dangerously allow production builds to successfully complete even if
22+
// your project has type errors.
23+
// !! WARN !!
24+
ignoreBuildErrors: true,
25+
},
26+
};
2827

2928
export default nextConfig;

frontend/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
"@radix-ui/react-icons": "^1.3.0",
2828
"@radix-ui/react-label": "^2.1.0",
2929
"@radix-ui/react-popover": "^1.1.1",
30-
"@radix-ui/react-scroll-area": "^1.1.0",
30+
"@radix-ui/react-scroll-area": "^1.2.0",
3131
"@radix-ui/react-select": "^2.1.1",
32+
"@radix-ui/react-separator": "^1.1.0",
3233
"@radix-ui/react-slot": "^1.1.0",
3334
"@radix-ui/react-tooltip": "^1.1.2",
3435
"@types/dom-speech-recognition": "^0.0.4",

frontend/public/codefox.png

420 KB
Loading

frontend/public/codefox.svg

+120
Loading

frontend/public/ollama.png

-7.31 KB
Binary file not shown.

frontend/src/app/login/page.tsx frontend/src/app/(auth)/login/page.tsx

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use client';
2+
23
import React, { useState, useEffect } from 'react';
34
import { Button } from '@/components/ui/button';
45
import { Input } from '@/components/ui/input';
@@ -18,6 +19,12 @@ const LoginPage = () => {
1819
password: '',
1920
});
2021
const [error, setError] = useState<string | null>(null);
22+
const [mounted, setMounted] = useState(false);
23+
const router = useRouter();
24+
25+
useEffect(() => {
26+
setMounted(true);
27+
}, []);
2128

2229
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
2330
const { name, value } = e.target;
@@ -27,7 +34,6 @@ const LoginPage = () => {
2734
}));
2835
};
2936

30-
const router = useRouter();
3137
const handleSubmit = async (e: React.FormEvent) => {
3238
e.preventDefault();
3339
setError(null);
@@ -57,16 +63,21 @@ const LoginPage = () => {
5763

5864
return (
5965
<div className="flex items-center justify-center min-h-screen bg-light-background dark:bg-dark-background">
60-
<div className="w-full max-w-md px-8">
66+
<div
67+
className={`w-full max-w-md px-8 transition-all duration-1000 ease-in-out
68+
${mounted ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}
69+
>
6170
<div className="space-y-2 mb-8">
62-
<h1 className="text-2xl font-semibold">Sign In</h1>
71+
<h1 className="text-2xl font-semibold text-light-text-primary dark:text-dark-text-primary">
72+
Sign In
73+
</h1>
6374
<p className="text-gray-500">
6475
Enter credentials to login to your account
6576
</p>
6677
</div>
6778

6879
{error && (
69-
<div className="mb-4 p-3 text-sm text-red-500 bg-red-50 rounded-lg">
80+
<div className="mb-4 p-3 text-sm text-red-500 bg-red-50 dark:bg-red-900/20 rounded-lg">
7081
{error}
7182
</div>
7283
)}
@@ -83,7 +94,10 @@ const LoginPage = () => {
8394
value={formData.username}
8495
onChange={handleChange}
8596
required
86-
className="h-12 rounded-lg border-gray-200 focus:border-gray-300 focus:ring-0"
97+
className="h-12 rounded-lg border-light-border dark:border-dark-border
98+
bg-light-surface dark:bg-dark-surface
99+
text-light-text-primary dark:text-dark-text-primary
100+
focus:outline-none focus:ring-2 focus:ring-primary-400 dark:focus:ring-primary-500 focus:border-transparent"
87101
placeholder="Enter your username"
88102
disabled={isLoading}
89103
/>
@@ -100,15 +114,19 @@ const LoginPage = () => {
100114
value={formData.password}
101115
onChange={handleChange}
102116
required
103-
className="h-12 rounded-lg border-gray-200 focus:border-gray-300 focus:ring-0"
117+
className="h-12 rounded-lg border-light-border dark:border-dark-border
118+
bg-light-surface dark:bg-dark-surface
119+
text-light-text-primary dark:text-dark-text-primary
120+
focus:outline-none focus:ring-2 focus:ring-primary-400 dark:focus:ring-primary-500 focus:border-transparent"
104121
placeholder="Enter your password"
105122
disabled={isLoading}
106123
/>
107124
</div>
108125

109126
<Button
110127
type="submit"
111-
className="w-full h-12 bg-primary-500 hover:bg-primary-600 text-white rounded-lg font-medium"
128+
className="w-full h-12 bg-primary-500 hover:bg-primary-600 dark:bg-primary-600 dark:hover:bg-primary-700
129+
text-white rounded-lg font-medium"
112130
disabled={isLoading}
113131
>
114132
{isLoading ? 'Signing In...' : 'Sign In'}
File renamed without changes.
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
'use client';
2+
3+
import React, { useEffect, useState } from 'react';
4+
import {
5+
ResizableHandle,
6+
ResizablePanel,
7+
ResizablePanelGroup,
8+
} from '@/components/ui/resizable';
9+
import { cn } from '@/lib/utils';
10+
import { usePathname } from 'next/navigation';
11+
import Sidebar from '@/components/sidebar';
12+
import { useChatList } from '../hooks/useChatList';
13+
14+
export default function MainLayout({
15+
children,
16+
}: {
17+
children: React.ReactNode;
18+
}) {
19+
const [isCollapsed, setIsCollapsed] = useState(false);
20+
const [isMobile, setIsMobile] = useState(false);
21+
const defaultLayout = [30, 160];
22+
const navCollapsedSize = 10;
23+
24+
const pathname = usePathname();
25+
const currentChatId = pathname.split('/')[1] || '';
26+
27+
const {
28+
chats,
29+
loading,
30+
error,
31+
chatListUpdated,
32+
setChatListUpdated,
33+
refetchChats,
34+
} = useChatList();
35+
36+
useEffect(() => {
37+
const checkScreenWidth = () => {
38+
setIsMobile(window.innerWidth <= 1023);
39+
};
40+
checkScreenWidth();
41+
window.addEventListener('resize', checkScreenWidth);
42+
return () => {
43+
window.removeEventListener('resize', checkScreenWidth);
44+
};
45+
}, []);
46+
47+
return (
48+
<main className="flex h-[calc(100dvh)] flex-col items-center">
49+
<ResizablePanelGroup
50+
direction="horizontal"
51+
onLayout={(sizes: number[]) => {
52+
document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`;
53+
}}
54+
className="h-screen items-stretch"
55+
>
56+
<ResizablePanel
57+
defaultSize={defaultLayout[0]}
58+
collapsedSize={navCollapsedSize}
59+
collapsible={true}
60+
minSize={isMobile ? 0 : 12}
61+
maxSize={isMobile ? 0 : 16}
62+
onCollapse={() => {
63+
setIsCollapsed(true);
64+
document.cookie = `react-resizable-panels:collapsed=${JSON.stringify(true)}`;
65+
}}
66+
onExpand={() => {
67+
setIsCollapsed(false);
68+
document.cookie = `react-resizable-panels:collapsed=${JSON.stringify(false)}`;
69+
}}
70+
className={cn(
71+
isCollapsed
72+
? 'min-w-[50px] md:min-w-[70px] transition-all duration-300 ease-in-out'
73+
: 'hidden md:block'
74+
)}
75+
>
76+
<Sidebar
77+
isCollapsed={isCollapsed}
78+
isMobile={isMobile}
79+
currentChatId={currentChatId}
80+
chatListUpdated={chatListUpdated}
81+
setChatListUpdated={setChatListUpdated}
82+
chats={chats}
83+
loading={loading}
84+
error={error}
85+
onRefetch={refetchChats}
86+
/>
87+
</ResizablePanel>
88+
<ResizableHandle className={cn('hidden md:flex')} withHandle />
89+
<ResizablePanel
90+
className="h-full w-full flex justify-center"
91+
defaultSize={defaultLayout[1]}
92+
>
93+
{children}
94+
</ResizablePanel>
95+
</ResizablePanelGroup>
96+
</main>
97+
);
98+
}

0 commit comments

Comments
 (0)