From cdf2f5d772014db5ce803295f80c38fbfc7cf100 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 26 May 2025 11:51:00 -0700 Subject: [PATCH] Show a loading bar when checkout is happening (#249) --- src/components/chat/ChatHeader.tsx | 9 ++++++++- src/components/ui/LoadingBar.tsx | 20 ++++++++++++++++++++ src/hooks/useCheckoutVersion.ts | 10 +++++++++- src/store/appAtoms.ts | 15 +++++++++++++++ src/styles/globals.css | 13 +++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/components/ui/LoadingBar.tsx create mode 100644 src/store/appAtoms.ts diff --git a/src/components/chat/ChatHeader.tsx b/src/components/chat/ChatHeader.tsx index 7a75080..2c8d806 100644 --- a/src/components/chat/ChatHeader.tsx +++ b/src/components/chat/ChatHeader.tsx @@ -26,6 +26,8 @@ import { useStreamChat } from "@/hooks/useStreamChat"; import { useCurrentBranch } from "@/hooks/useCurrentBranch"; import { useCheckoutVersion } from "@/hooks/useCheckoutVersion"; import { useRenameBranch } from "@/hooks/useRenameBranch"; +import { isAnyCheckoutVersionInProgressAtom } from "@/store/appAtoms"; +import { LoadingBar } from "../ui/LoadingBar"; interface ChatHeaderProps { isVersionPaneOpen: boolean; @@ -46,6 +48,9 @@ export function ChatHeader({ const [selectedChatId, setSelectedChatId] = useAtom(selectedChatIdAtom); const { refreshChats } = useChats(appId); const { isStreaming } = useStreamChat(); + const isAnyCheckoutVersionInProgress = useAtomValue( + isAnyCheckoutVersionInProgressAtom, + ); const { branchInfo, @@ -102,6 +107,7 @@ export function ChatHeader({ return (
+ {/* If the version pane is open, it's expected to not always be on the main branch. */} {isNotMainBranch && !isVersionPaneOpen && (
@@ -161,7 +167,8 @@ export function ChatHeader({
)} -
+ {/* Why is this pt-0.5? Because the loading bar is h-1 (it always takes space) and we want the vertical spacing to be consistent.*/} +