From 450ec09888c1e53e0e0676ca7e5faba7614cedf8 Mon Sep 17 00:00:00 2001 From: pengyu Date: Mon, 3 Mar 2025 00:34:19 -0500 Subject: [PATCH 01/17] fix bug click create button sign in will not able to trigger form --- frontend/src/app/(main)/page.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/(main)/page.tsx b/frontend/src/app/(main)/page.tsx index 1f942a76..11c313fa 100644 --- a/frontend/src/app/(main)/page.tsx +++ b/frontend/src/app/(main)/page.tsx @@ -29,15 +29,10 @@ export default function HomePage() { if (!message.trim()) return; try { - // Create the project const result = await createProjectFromPrompt(message, isPublic, model); - - // If successful, clear the input if (result) { promptFormRef.current.clearMessage(); - - // Note: No need to navigate here as the ProjectContext's onCompleted handler - // in the createProject mutation will handle navigation to the chat page + // No need to navigate here, ProjectContext handles navigation } } catch (error) { console.error('Error creating project:', error); @@ -78,6 +73,7 @@ export default function HomePage() { ref={promptFormRef} isAuthorized={isAuthorized} onSubmit={handleSubmit} + // 💡 If the user isn't authorized, show the AuthChoiceModal onAuthRequired={() => setShowAuthChoice(true)} isLoading={isLoading} /> @@ -93,6 +89,7 @@ export default function HomePage() { isOpen={showAuthChoice} onClose={() => setShowAuthChoice(false)} onSignUpClick={() => { + // 1) Close the AuthChoice setShowAuthChoice(false); setTimeout(() => { setShowSignUp(true); From 1793753a76e19a2ca1b20f79f39549256abd4c16 Mon Sep 17 00:00:00 2001 From: pengyu Date: Mon, 3 Mar 2025 13:03:52 -0500 Subject: [PATCH 02/17] fix the click sidebar codefox and icon will not turn to main page --- frontend/src/app/(main)/page.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/(main)/page.tsx b/frontend/src/app/(main)/page.tsx index 11c313fa..accf5439 100644 --- a/frontend/src/app/(main)/page.tsx +++ b/frontend/src/app/(main)/page.tsx @@ -29,11 +29,8 @@ export default function HomePage() { if (!message.trim()) return; try { - const result = await createProjectFromPrompt(message, isPublic, model); - if (result) { - promptFormRef.current.clearMessage(); - // No need to navigate here, ProjectContext handles navigation - } + await createProjectFromPrompt(message, isPublic, model); + promptFormRef.current.clearMessage(); } catch (error) { console.error('Error creating project:', error); } @@ -73,7 +70,6 @@ export default function HomePage() { ref={promptFormRef} isAuthorized={isAuthorized} onSubmit={handleSubmit} - // 💡 If the user isn't authorized, show the AuthChoiceModal onAuthRequired={() => setShowAuthChoice(true)} isLoading={isLoading} /> @@ -89,7 +85,6 @@ export default function HomePage() { isOpen={showAuthChoice} onClose={() => setShowAuthChoice(false)} onSignUpClick={() => { - // 1) Close the AuthChoice setShowAuthChoice(false); setTimeout(() => { setShowSignUp(true); From df12d22474e6a323d73f7f663bd5236d04b4e7fc Mon Sep 17 00:00:00 2001 From: pengyu Date: Mon, 3 Mar 2025 20:46:33 -0500 Subject: [PATCH 03/17] restore accidentlly modifed handleSubmit --- frontend/src/app/(main)/page.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/(main)/page.tsx b/frontend/src/app/(main)/page.tsx index accf5439..6194ec54 100644 --- a/frontend/src/app/(main)/page.tsx +++ b/frontend/src/app/(main)/page.tsx @@ -29,9 +29,16 @@ export default function HomePage() { if (!message.trim()) return; try { - await createProjectFromPrompt(message, isPublic, model); - promptFormRef.current.clearMessage(); - } catch (error) { + // Create the project + const result = await createProjectFromPrompt(message, isPublic, model); + + // If successful, clear the input + if (result) { + promptFormRef.current.clearMessage(); + + // Note: No need to navigate here as the ProjectContext's onCompleted handler + // in the createProject mutation will handle navigation to the chat page + }} catch (error) { console.error('Error creating project:', error); } }; From dacf084d1696f3260ed5bcf7379bae69400662c7 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 02:00:05 +0000 Subject: [PATCH 04/17] [autofix.ci] apply automated fixes --- frontend/src/app/(main)/page.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/(main)/page.tsx b/frontend/src/app/(main)/page.tsx index 6194ec54..1f942a76 100644 --- a/frontend/src/app/(main)/page.tsx +++ b/frontend/src/app/(main)/page.tsx @@ -29,16 +29,17 @@ export default function HomePage() { if (!message.trim()) return; try { - // Create the project - const result = await createProjectFromPrompt(message, isPublic, model); + // Create the project + const result = await createProjectFromPrompt(message, isPublic, model); - // If successful, clear the input - if (result) { - promptFormRef.current.clearMessage(); + // If successful, clear the input + if (result) { + promptFormRef.current.clearMessage(); - // Note: No need to navigate here as the ProjectContext's onCompleted handler - // in the createProject mutation will handle navigation to the chat page - }} catch (error) { + // Note: No need to navigate here as the ProjectContext's onCompleted handler + // in the createProject mutation will handle navigation to the chat page + } + } catch (error) { console.error('Error creating project:', error); } }; From 4715ece255a1a40f272f9d8c0854e9e518ef03b8 Mon Sep 17 00:00:00 2001 From: pengyu Date: Tue, 4 Mar 2025 00:01:49 -0500 Subject: [PATCH 05/17] fix the error on send request before token stored in local storage --- frontend/src/providers/AuthProvider.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/providers/AuthProvider.tsx b/frontend/src/providers/AuthProvider.tsx index 20b99d25..bbb71ef5 100644 --- a/frontend/src/providers/AuthProvider.tsx +++ b/frontend/src/providers/AuthProvider.tsx @@ -46,6 +46,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { const [refreshTokenMutation] = useMutation(REFRESH_TOKEN_MUTATION); const [getUserInfo] = useLazyQuery<{ me: User }>(GET_USER_INFO); + // 验证本地 token 是否有效 const validateToken = useCallback(async () => { const storedToken = localStorage.getItem(LocalStore.accessToken); if (!storedToken) { @@ -68,6 +69,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { } }, [checkToken]); + // 获取当前用户信息 const fetchUserInfo = useCallback(async () => { try { const { data } = await getUserInfo(); @@ -82,6 +84,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { } }, [getUserInfo]); + // 刷新 token const refreshAccessToken = useCallback(async () => { try { const refreshToken = localStorage.getItem(LocalStore.refreshToken); @@ -114,6 +117,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { } }, [refreshTokenMutation]); + // 登录时写入 token 并获取用户信息 const login = useCallback( (accessToken: string, refreshToken: string) => { localStorage.setItem(LocalStore.accessToken, accessToken); @@ -129,6 +133,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { [fetchUserInfo] ); + // 登出 const logout = useCallback(() => { setToken(null); setIsAuthorized(false); @@ -137,6 +142,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { localStorage.removeItem(LocalStore.refreshToken); }, []); + // 初始化,尝试验证或刷新 token useEffect(() => { async function initAuth() { setIsLoading(true); @@ -152,10 +158,12 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { let isValid = await validateToken(); + // 如果验证失败,再试图刷新 if (!isValid) { isValid = (await refreshAccessToken()) ? true : false; } + // 最终判断 if (isValid) { setIsAuthorized(true); await fetchUserInfo(); From 9657ebf5de07dd7f73956d4fb6d0eac5f7b721e8 Mon Sep 17 00:00:00 2001 From: pengyu Date: Tue, 4 Mar 2025 00:24:10 -0500 Subject: [PATCH 06/17] fix the width not be full in new project in side bar --- frontend/src/components/sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index 3dc97c92..271440df 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -114,7 +114,7 @@ export function ChatSideBar({ onClick={() => setIsModalOpen(true)} size="setting" variant="ghost" - className="flex items-center justify-start w-[85%] h-14 text-xs xl:text-sm font-normal gap-2 pl-4 hover:bg-yellow-50 rounded-md transition-all duration-200 ease-in-out" + className="flex items-center justify-start w-full h-14 text-xs xl:text-sm font-normal gap-2 pl-4 hover:bg-yellow-50 rounded-md transition-all duration-200 ease-in-out" >
Date: Tue, 4 Mar 2025 02:08:24 -0500 Subject: [PATCH 07/17] adjust the icon --- frontend/public/map.svg | 1 + frontend/src/components/sidebar.tsx | 128 ++++++++++++++-------------- 2 files changed, 67 insertions(+), 62 deletions(-) create mode 100644 frontend/public/map.svg diff --git a/frontend/public/map.svg b/frontend/public/map.svg new file mode 100644 index 00000000..6bf7a9b9 --- /dev/null +++ b/frontend/public/map.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index 271440df..4e041c62 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -1,8 +1,8 @@ 'use client'; + import { Button } from '@/components/ui/button'; import Image from 'next/image'; import { memo, useCallback, useContext, useState } from 'react'; -import { SquarePen } from 'lucide-react'; import SidebarSkeleton from './sidebar-skeleton'; import UserSettings from './user-settings'; import { SideBarItem } from './sidebar-item'; @@ -22,9 +22,9 @@ import { import { ProjectContext } from './chat/code-engine/project-context'; interface SidebarProps { - setIsModalOpen: (value: boolean) => void; // Parent setter to update collapse state + setIsModalOpen: (value: boolean) => void; isCollapsed: boolean; - setIsCollapsed: (value: boolean) => void; // Parent setter to update collapse state + setIsCollapsed: (value: boolean) => void; isMobile: boolean; currentChatId?: string; chatListUpdated: boolean; @@ -44,11 +44,10 @@ export function ChatSideBar({ error, onRefetch, }: SidebarProps) { - // Use a local state only for the currently selected chat. const router = useRouter(); const [currentChatid, setCurrentChatid] = useState(''); const { setCurProject, pollChatProject } = useContext(ProjectContext); - // Handler for starting a new chat. + const handleNewChat = useCallback(() => { window.history.replaceState({}, '', '/'); setCurrentChatid(''); @@ -64,86 +63,91 @@ export function ChatSideBar({ return (
- {/* Toggle button: Clicking this will toggle the collapse state */} - setIsCollapsed(!isCollapsed)} - /> + {/* Header Row: Fox Logo (clickable) on the left, SidebarTrigger on the right */} +
+ {/* 只包裹图标与文字,让点击区域正好等于这两个元素 */} + + + {/* 折叠/展开图标放右侧 */} + setIsCollapsed(!isCollapsed)} + /> +
+ + {/* Divider Line */} +
+ + {/* New Project 按钮 - 依然占据整行 */} - - {/* Divider Line */} -
- - + {/* 聊天列表 */} @@ -171,12 +175,12 @@ export function ChatSideBar({ + {/* 底部设置 */} setIsCollapsed(!isCollapsed)} isSimple={false} /> From e91f0076ad28fff4388a7215f34a8defcf9a17be Mon Sep 17 00:00:00 2001 From: pengyu Date: Tue, 4 Mar 2025 17:38:39 -0500 Subject: [PATCH 08/17] change icon for add new project and move 3 dots to the end --- frontend/src/components/sidebar-item.tsx | 6 +++--- frontend/src/components/sidebar.tsx | 26 +++++++++--------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/sidebar-item.tsx b/frontend/src/components/sidebar-item.tsx index 91b1897a..654d5ca6 100644 --- a/frontend/src/components/sidebar-item.tsx +++ b/frontend/src/components/sidebar-item.tsx @@ -104,11 +104,11 @@ export function SideBarItem({ buttonVariants({ variant, }), - 'flex justify-between w-full h-14 text-base font-normal items-center group' + 'relative flex w-full h-14 text-base font-normal items-center group px-2' )} onClick={handleChatClick} > -
+
{title || 'New Chat'}
@@ -119,7 +119,7 @@ export function SideBarItem({ + {!isCollapsed && ( +
+ - {/* 折叠/展开图标放右侧 */} - setIsCollapsed(!isCollapsed)} - /> + {/* SidebarTrigger 保证在 CodeFox 按钮的中间 */} + setIsCollapsed(!isCollapsed)} + /> +
+ )} + + {isCollapsed && ( + setIsCollapsed(!isCollapsed)} + /> + )}
{/* Divider Line */}
{/* New Project 按钮 - 依然占据整行 */} - + {!isCollapsed && ( + + New Project + + )} + +
{/* 聊天列表 */} @@ -170,7 +182,9 @@ export function ChatSideBar({ {/* 底部设置 */} - + From d9240cb60a089965b86b0e33028bcc6f3204aba9 Mon Sep 17 00:00:00 2001 From: NarwhalChen <125920907+NarwhalChen@users.noreply.github.com> Date: Tue, 4 Mar 2025 18:40:08 -0600 Subject: [PATCH 10/17] fix: cannot redirect to project page for the first time (#155) - **Refactor** - Improved chat session navigation for smoother transitions and a more integrated user experience. --- frontend/src/components/sidebar.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index 8d22d661..463d6fef 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -20,6 +20,7 @@ import { SidebarFooter, } from './ui/sidebar'; import { ProjectContext } from './chat/code-engine/project-context'; +import { useRouter } from 'next/navigation'; interface SidebarProps { setIsModalOpen: (value: boolean) => void; From be6765075a56427ed0e0d7e693b05f38435beaf1 Mon Sep 17 00:00:00 2001 From: PengyuChen01 <121841974+PengyuChen01@users.noreply.github.com> Date: Tue, 4 Mar 2025 21:36:51 -0500 Subject: [PATCH 11/17] feat(frontend): landing page ui optimization (#149) Co-authored-by: pengyu Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- frontend/src/components/sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index 463d6fef..5566e430 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -20,7 +20,7 @@ import { SidebarFooter, } from './ui/sidebar'; import { ProjectContext } from './chat/code-engine/project-context'; -import { useRouter } from 'next/navigation'; + interface SidebarProps { setIsModalOpen: (value: boolean) => void; From 9ed039eded96dee837f25686b68072a53aa06790 Mon Sep 17 00:00:00 2001 From: pengyu Date: Mon, 3 Mar 2025 00:34:19 -0500 Subject: [PATCH 12/17] fix bug click create button sign in will not able to trigger form --- frontend/src/app/(main)/page.tsx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/(main)/page.tsx b/frontend/src/app/(main)/page.tsx index 1f942a76..edbf78e2 100644 --- a/frontend/src/app/(main)/page.tsx +++ b/frontend/src/app/(main)/page.tsx @@ -8,9 +8,11 @@ import { useAuthContext } from '@/providers/AuthProvider'; import { ProjectsSection } from '@/components/root/projects-section'; import { PromptForm, PromptFormRef } from '@/components/root/prompt-form'; import { ProjectContext } from '@/components/chat/code-engine/project-context'; + +// ✅ Import your SignInModal and SignUpModal import { SignInModal } from '@/components/sign-in-modal'; import { SignUpModal } from '@/components/sign-up-modal'; -import { useRouter } from 'next/navigation'; + export default function HomePage() { // States for AuthChoiceModal const [showAuthChoice, setShowAuthChoice] = useState(false); @@ -18,6 +20,10 @@ export default function HomePage() { const [showSignIn, setShowSignIn] = useState(false); const [showSignUp, setShowSignUp] = useState(false); + // ✅ Add states for sign in / sign up modals + const [showSignIn, setShowSignIn] = useState(false); + const [showSignUp, setShowSignUp] = useState(false); + const promptFormRef = useRef(null); const { isAuthorized } = useAuthContext(); const { createProjectFromPrompt, isLoading } = useContext(ProjectContext); @@ -29,15 +35,10 @@ export default function HomePage() { if (!message.trim()) return; try { - // Create the project const result = await createProjectFromPrompt(message, isPublic, model); - - // If successful, clear the input if (result) { promptFormRef.current.clearMessage(); - - // Note: No need to navigate here as the ProjectContext's onCompleted handler - // in the createProject mutation will handle navigation to the chat page + // No need to navigate here, ProjectContext handles navigation } } catch (error) { console.error('Error creating project:', error); @@ -78,6 +79,7 @@ export default function HomePage() { ref={promptFormRef} isAuthorized={isAuthorized} onSubmit={handleSubmit} + // 💡 If the user isn't authorized, show the AuthChoiceModal onAuthRequired={() => setShowAuthChoice(true)} isLoading={isLoading} /> @@ -93,7 +95,9 @@ export default function HomePage() { isOpen={showAuthChoice} onClose={() => setShowAuthChoice(false)} onSignUpClick={() => { + // 1) Close the AuthChoice setShowAuthChoice(false); + // 2) Then open SignUpModal setTimeout(() => { setShowSignUp(true); }, 100); @@ -107,8 +111,14 @@ export default function HomePage() { /> {/* SignInModal & SignUpModal */} - setShowSignIn(false)} /> - setShowSignUp(false)} /> + setShowSignIn(false)} + /> + setShowSignUp(false)} + />