diff --git a/src/renderer/components/ai/FloatingChat.tsx b/src/renderer/components/ai/FloatingChat.tsx index 727a301..2794caf 100644 --- a/src/renderer/components/ai/FloatingChat.tsx +++ b/src/renderer/components/ai/FloatingChat.tsx @@ -6,7 +6,7 @@ import { X, ArrowUp } from 'lucide-react'; import { useFloatingChat, computeDualAnchor, - CHAT_WIDTH, + getChatWidth, CHAT_HEIGHT, PADDING, } from '@/context/FloatingChatContext'; @@ -66,7 +66,7 @@ function FloatingChatInner() { if (route === 'project' && state.projectId) { // Navigate to the project page (stay on same project) // Project sections re-register on mount and pendingSection will auto-open - void navigate({ to: '/projects/$projectId', params: { projectId: state.projectId } }); + void navigate({ to: '/projects', search: { projectId: state.projectId } }); } else if (route.startsWith('/')) { void navigate({ to: route }); } @@ -154,7 +154,7 @@ function FloatingChatInner() { if (el) { const rect = el.getBoundingClientRect(); if (rect.right > window.innerWidth || rect.bottom > window.innerHeight) { - el.style.left = `${Math.max(PADDING, Math.min(state.position.x, window.innerWidth - CHAT_WIDTH - PADDING))}px`; + el.style.left = `${Math.max(PADDING, Math.min(state.position.x, window.innerWidth - getChatWidth() - PADDING))}px`; el.style.top = `${Math.max(PADDING, Math.min(state.position.y, window.innerHeight - CHAT_HEIGHT - PADDING))}px`; } } @@ -241,6 +241,10 @@ function FloatingChatInner() { const hasMessages = messages.length > 0 || isStreaming; + // Expand the messages panel upward if there's enough space above the input bar, + // otherwise expand downward. 320px = 300px max-h + 8px gap + 12px buffer. + const expandUp = state.position.y >= 320; + return ( {state.isOpen && ( @@ -260,30 +264,37 @@ function FloatingChatInner() { width: state.position.width, zIndex: 9999, }} - className="flex flex-col gap-2" + className="relative" > - {/* ---- Messages panel (appears when chat has content) ---- */} + {/* ---- Messages panel — floats above or below the input bar ---- */} {hasMessages && (
{messages.map((msg) => { if (msg.role === 'user') { return (
-
-

+

+

{msg.content}

@@ -294,7 +305,7 @@ function FloatingChatInner() { if (msg.error) { return (
-
+

{msg.content}

@@ -305,8 +316,8 @@ function FloatingChatInner() { return (
-
-
+
+
@@ -317,9 +328,9 @@ function FloatingChatInner() { {/* Streaming */} {isStreaming && (
-
+
{streamingContent ? ( -
+
) : ( @@ -338,7 +349,7 @@ function FloatingChatInner() { {/* ---- Floating input bar ---- */} -
+
{/* Close button */}