Skip to content

Commit b2d26e0

Browse files
committed
fix: prevent session message auto-scroll from pushing dialog content out of view
Replace scrollIntoView (which scrolls all ancestor containers) with direct scrollTop manipulation on the ScrollArea viewport. This keeps the scroll contained within the messages panel only.
1 parent 58a1215 commit b2d26e0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/app/home/bots/components/bot-session/BotSessionMonitor.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function BotSessionMonitor({ botId }: BotSessionMonitorProps) {
6060
const [messages, setMessages] = useState<SessionMessage[]>([]);
6161
const [loadingSessions, setLoadingSessions] = useState(false);
6262
const [loadingMessages, setLoadingMessages] = useState(false);
63-
const messagesEndRef = useRef<HTMLDivElement>(null);
63+
const messagesContainerRef = useRef<HTMLDivElement>(null);
6464

6565
const loadSessions = useCallback(async () => {
6666
setLoadingSessions(true);
@@ -103,8 +103,16 @@ export default function BotSessionMonitor({ botId }: BotSessionMonitorProps) {
103103
}
104104
}, [selectedSessionId, loadMessages]);
105105

106+
106107
useEffect(() => {
107-
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
108+
// Scroll within the messages container only, without affecting parent containers
109+
const container = messagesContainerRef.current;
110+
if (container) {
111+
// ScrollArea renders a viewport div as [data-radix-scroll-area-viewport]
112+
const viewport = container.querySelector('[data-radix-scroll-area-viewport]');
113+
const scrollTarget = viewport || container;
114+
scrollTarget.scrollTop = scrollTarget.scrollHeight;
115+
}
108116
}, [messages]);
109117

110118
const parseMessageChain = (content: string): MessageChainComponent[] => {
@@ -418,7 +426,7 @@ export default function BotSessionMonitor({ botId }: BotSessionMonitorProps) {
418426
</div>
419427

420428
{/* Messages - Chat Bubble Style (like DebugDialog) */}
421-
<ScrollArea className="flex-1 min-h-0 p-4 bg-white dark:bg-black">
429+
<ScrollArea ref={messagesContainerRef} className="flex-1 min-h-0 p-4 bg-white dark:bg-black">
422430
<div className="space-y-4">
423431
{loadingMessages ? (
424432
<div className="text-center text-muted-foreground py-12 text-sm">
@@ -475,7 +483,6 @@ export default function BotSessionMonitor({ botId }: BotSessionMonitorProps) {
475483
);
476484
})
477485
)}
478-
<div ref={messagesEndRef} />
479486
</div>
480487
</ScrollArea>
481488
</>

0 commit comments

Comments
 (0)