diff --git a/components/header.tsx b/components/header.tsx
index 0a370612..e139e8e6 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -1,5 +1,6 @@
import React from 'react'
import Image from 'next/image'
+import { useIsLoading } from './is-loading-provider'
import { ModeToggle } from './mode-toggle'
import { cn } from '@/lib/utils'
import HistoryContainer from './history-container'
@@ -15,6 +16,8 @@ import { MapToggle } from './map-toggle'
import { ProfileToggle } from './profile-toggle'
export const Header = () => {
+ const { isLoading } = useIsLoading()
+
return (
@@ -25,7 +28,15 @@ export const Header = () => {
diff --git a/components/is-loading-provider.tsx b/components/is-loading-provider.tsx
new file mode 100644
index 00000000..93b9d17f
--- /dev/null
+++ b/components/is-loading-provider.tsx
@@ -0,0 +1,30 @@
+'use client'
+
+import { createContext, useContext, useState, ReactNode } from 'react'
+
+interface IsLoadingContextType {
+ isLoading: boolean
+ setIsLoading: (isLoading: boolean) => void
+}
+
+const IsLoadingContext = createContext(
+ undefined
+)
+
+export function IsLoadingProvider({ children }: { children: ReactNode }) {
+ const [isLoading, setIsLoading] = useState(false)
+
+ return (
+
+ {children}
+
+ )
+}
+
+export function useIsLoading() {
+ const context = useContext(IsLoadingContext)
+ if (context === undefined) {
+ throw new Error('useIsLoading must be used within an IsLoadingProvider')
+ }
+ return context
+}
\ No newline at end of file
From e8fa0ba3813ef2b2503e6f3625d1ed8b88ecbef7 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Tue, 30 Sep 2025 17:16:57 +0000
Subject: [PATCH 2/2] feat: Add spinning loader for AI token generation
This commit introduces a spinning loader on the top-left plant icon to indicate when the AI is generating tokens. A new `IsLoadingProvider` is created to manage the loading state, which is updated from the `Chat` component based on the `isGenerating` streamable value. The `Header` component consumes this state to conditionally apply a counter-clockwise spinning animation.
---
components/header.tsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/components/header.tsx b/components/header.tsx
index e139e8e6..a7b48aed 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -1,3 +1,5 @@
+'use client'
+
import React from 'react'
import Image from 'next/image'
import { useIsLoading } from './is-loading-provider'