diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISpline.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISpline.ts index e11c6a37a..bc77396ec 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISpline.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISpline.ts @@ -1,10 +1,11 @@ +import { cn } from "@follow/utils" import { ErrorBoundary } from "@sentry/react" import { createElement, lazy, Suspense } from "react" const AISplineLoader = lazy(() => import("./AISplineLoader").then((res) => ({ default: res.AISplineLoader })), ) -export const AISpline = () => { +export const AISpline = ({ className }: { className?: string }) => { return createElement( ErrorBoundary, { @@ -13,9 +14,9 @@ export const AISpline = () => { createElement( Suspense, { - fallback: createElement("div", { className: "size-16 mx-auto" }), + fallback: createElement("div", { className: cn("size-20 mx-auto", className) }), }, - createElement(AISplineLoader), + createElement(AISplineLoader, { className }), ), ) } diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx index 0df88c5ef..6c2e4849a 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/3d-models/AISplineLoader.tsx @@ -1,12 +1,13 @@ +import { clamp, cn } from "@follow/utils" import Spline from "@splinetool/react-spline" import { useCallback, useRef } from "react" -const resolvedAIIconUrl = "https://cdn.follow.is/ai.splinecode" +// TODO: use folo cdn +const resolvedAIIconUrl = "https://prod.spline.design/n2hjp93nWReC-512/scene.splinecode" -export const AISplineLoader = () => { +export const AISplineLoader = ({ className }: { className?: string }) => { const containerRef = useRef(null) const headRef = useRef(null) - const bodyRef = useRef(null) // Angle conversion function: degrees to radians const degToRad = (degrees: number) => degrees * (Math.PI / 180) @@ -27,10 +28,10 @@ export const AISplineLoader = () => { // Calculate head rotation angle based on relative position // Y-axis rotation (left-right): -70 to 70 degrees - const headRotationY = clampedX * 70 + const headRotationY = clampedX * 20 // X-axis rotation (up-down): -60 to 60 degrees - const headRotationX = clampedY * 60 + const headRotationX = clampedY * 20 return { x: degToRad(headRotationX), @@ -40,101 +41,76 @@ export const AISplineLoader = () => { [], ) - // Calculate body rotation angle (horizontal rotation only) - const calculateBodyRotation = useCallback((mouseX: number, containerRect: DOMRect) => { - const containerCenterX = containerRect.left + containerRect.width / 2 - - // Calculate mouse X position relative to container center (-1 to 1) - const relativeX = (mouseX - containerCenterX) / (window.innerWidth / 2) - const clampedX = Math.max(-1, Math.min(1, relativeX)) - - // Body Y-axis rotation: -30 to 30 degrees (smaller range than head rotation) - const bodyRotationY = clampedX * 30 - - return { - x: 0, // Body doesn't rotate up-down - y: degToRad(bodyRotationY), - } - }, []) - const handleLoad = useCallback( (app: any) => { - const head = app.findObjectByName("Head") - const body = app.findObjectByName("Body") + const head = app.findObjectByName("Folo Character_V3") - if (!head || !body) { + if (!head) { console.warn("Cannot find Head or Body object") return } headRef.current = head - bodyRef.current = body const onMove = (e: MouseEvent) => { - if (!containerRef.current || !headRef.current || !bodyRef.current) return + if (!containerRef.current || !headRef.current) return const containerRect = containerRef.current.getBoundingClientRect() // Calculate head rotation const headRotation = calculateHeadRotation(e.clientX, e.clientY, containerRect) - headRef.current.rotation.x = headRotation.x - headRef.current.rotation.y = headRotation.y - - // Calculate body rotation - const bodyRotation = calculateBodyRotation(e.clientX, containerRect) - bodyRef.current.rotation.x = bodyRotation.x - bodyRef.current.rotation.y = bodyRotation.y + headRef.current.rotation.x = clamp(headRotation.x, -0.5, 0.5) + headRef.current.rotation.y = clamp(headRotation.y, -0.5, 0.5) } // Reset to default position when mouse leaves const onMouseLeave = () => { - if (!headRef.current || !bodyRef.current) return + if (!headRef.current) return // Smooth transition back to default position const resetAnimation = () => { - if (!headRef.current || !bodyRef.current) return + if (!headRef.current) return const currentHeadX = headRef.current.rotation.x const currentHeadY = headRef.current.rotation.y - const currentBodyY = bodyRef.current.rotation.y // Simple linear interpolation to smoothly return rotation to 0 headRef.current.rotation.x = currentHeadX * 0.9 headRef.current.rotation.y = currentHeadY * 0.9 - bodyRef.current.rotation.y = currentBodyY * 0.9 // Continue animation if not fully returned to 0 - if ( - Math.abs(currentHeadX) > 0.01 || - Math.abs(currentHeadY) > 0.01 || - Math.abs(currentBodyY) > 0.01 - ) { + if (Math.abs(currentHeadX) > 0.01 || Math.abs(currentHeadY) > 0.01) { requestAnimationFrame(resetAnimation) } else { // Complete reset to 0 headRef.current.rotation.x = 0 headRef.current.rotation.y = 0 - bodyRef.current.rotation.x = 0 - bodyRef.current.rotation.y = 0 } } resetAnimation() } + const onClick = () => { + app.emitEvent("mouseDown", "Folo Character_V3") + } + onClick() + window.addEventListener("pointermove", onMove) document.addEventListener("mouseleave", onMouseLeave) + window.addEventListener("click", onClick) return () => { window.removeEventListener("pointermove", onMove) document.removeEventListener("mouseleave", onMouseLeave) + window.removeEventListener("click", onClick) } }, - [calculateHeadRotation, calculateBodyRotation], + [calculateHeadRotation], ) return ( -
+
) diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx index a10643b0e..007c0ad80 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/ChatHeader.tsx @@ -7,9 +7,16 @@ import { useTranslation } from "react-i18next" import { AIChatPanelStyle, setAIPanelVisibility, useAIChatPanelStyle } from "~/atoms/settings/ai" import { useTimelineSummaryAutoContext } from "~/modules/ai-chat/hooks/useTimelineSummaryAutoContext" -import { useBlockActions, useChatActions, useCurrentTitle } from "~/modules/ai-chat/store/hooks" +import { + useBlockActions, + useChatActions, + useCurrentTitle, + useHasMessages, +} from "~/modules/ai-chat/store/hooks" +import { useSettingModal } from "~/modules/settings/modal/use-setting-modal-hack" import { useAIRootState } from "../../store/AIChatContext" +import { AISpline } from "../3d-models/AISpline" import { ChatHistoryDropdown } from "./ChatHistoryDropdown" import { ChatMoreDropdown } from "./ChatMoreDropdown" import { AIHeaderTitle } from "./ChatTitle" @@ -25,11 +32,13 @@ const ChatHeaderLayout = ({ displayTitle: string | undefined }) => ReactNode }) => { + const hasMessages = useHasMessages() const currentTitle = useCurrentTitle() const chatActions = useChatActions() const blockActions = useBlockActions() const { t } = useTranslation("ai") const shouldDisableTimelineSummary = useTimelineSummaryAutoContext() + const settingModalPresent = useSettingModal() const displayTitle = currentTitle @@ -72,6 +81,11 @@ const ChatHeaderLayout = ({
+ {hasMessages && ( +
settingModalPresent("ai")}> + +
+ )} diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx index 109e773b1..3d329f18e 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/components/layouts/WelcomeScreen.tsx @@ -62,7 +62,7 @@ const DefaultWelcomeHeader = ({ description }: { description: string }) => ( animate={{ opacity: 1, y: 0 }} className="space-y-6 text-center" > -
+
diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/ai/AISplineButton.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/ai/AISplineButton.tsx index e4e6e8b08..108d367b6 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/ai/AISplineButton.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/ai/AISplineButton.tsx @@ -35,7 +35,7 @@ export const AIIndicator: FC = () => { onClick={handleClick} className={clsx( "fixed bottom-8 right-8 z-40", - "size-16 rounded-2xl", + "rounded-2xl", "hover:scale-105", "active:scale-95", "flex items-center justify-center", diff --git a/apps/desktop/layer/renderer/src/modules/new-user-guide/feeds-selection-list.tsx b/apps/desktop/layer/renderer/src/modules/new-user-guide/feeds-selection-list.tsx index 191e81c2b..fd0989e75 100644 --- a/apps/desktop/layer/renderer/src/modules/new-user-guide/feeds-selection-list.tsx +++ b/apps/desktop/layer/renderer/src/modules/new-user-guide/feeds-selection-list.tsx @@ -198,7 +198,7 @@ function FeedSelectionFirstScreen() { transition={{ delay: 0.1, duration: 0.6, type: "spring" }} className="mb-6" > -
+