Improve scroll-to-bottom UI and session status handling

- Replace ChevronDown with ArrowDown icon for scroll button
- Adjust scroll threshold to 150px for better UX
- Add prompt overlay height tracking for proper message container padding
- Include compact status in active session check
This commit is contained in:
Chris Scott committed 2026-03-24 14:00:35 -04:00
1 parent e451c28675
commit 4ad6c5fd25
3 files changed
+32 -11

No files matched your search

@@ -13,7 +13,7 @@ import { useSessionAgentStore } from '@/stores/sessionAgentStore'
import { useMobile } from '@/hooks/useMobile'
import { usePermissions } from '@/contexts/EventContext'
import { ChevronDown, Upload, X, Mic, MicOff } from 'lucide-react'
import { ArrowDown, Upload, X, Mic, MicOff } from 'lucide-react'
import { SquareFill } from '@/components/ui/square-fill'
@@ -856,10 +856,10 @@ return (
<div className="flex items-center gap-1.5 md:gap-2 flex-shrink-0">
<button
onClick={onScrollToBottom}
className={`p-1.5 md:p-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-all duration-200 active:scale-95 hover:scale-105 shadow-md shadow-blue-500/20 hover:shadow-blue-500/30 border border-blue-500/30 hover:border-blue-500 dark:border-blue-400/30 dark:hover:border-blue-400 ring-1 ring-blue-500/20 hover:ring-blue-500/30 ${showScrollButton ? 'visible' : 'invisible'}`}
className={`p-2.5 md:p-2 rounded-lg bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground transition-all duration-200 active:scale-95 hover:scale-105 shadow-md ${showScrollButton ? 'visible' : 'invisible'}`}
title="Scroll to bottom"
>
<ChevronDown className="w-5 h-5" />
<ArrowDown className="w-6 h-6" />
</button>
{showStopButton && (
<button
+7 -6
View File
@@ -53,7 +53,6 @@ export function useAutoScroll({
const markDisengaged = () => {
userScrolledAtRef.current = Date.now()
userDisengagedRef.current = true
onScrollStateChangeRef.current?.(true)
}
const handlePointerDown = (e: PointerEvent) => {
@@ -85,7 +84,7 @@ export function useAutoScroll({
const handleScroll = () => {
const { scrollTop, scrollHeight, clientHeight } = container
const isAtBottom = scrollHeight - scrollTop - clientHeight < 50
const isAtBottom = scrollHeight - scrollTop - clientHeight < 150
if (isAtBottom) {
if (userDisengagedRef.current) {
@@ -93,10 +92,12 @@ export function useAutoScroll({
userDisengagedRef.current = false
onScrollStateChangeRef.current?.(false)
}
} else if (!userDisengagedRef.current) {
userScrolledAtRef.current = Date.now()
userDisengagedRef.current = true
onScrollStateChangeRef.current?.(true)
} else {
if (!userDisengagedRef.current) {
userScrolledAtRef.current = Date.now()
userDisengagedRef.current = true
onScrollStateChangeRef.current?.(true)
}
}
}
+22 -2
View File
@@ -88,11 +88,30 @@ export function SessionDetail() {
const isMobile = useMobile();
const { keyboardHeight } = useVisualViewport();
const inputBottomOffset = isMobile ? keyboardHeight : 0;
const promptOverlayRef = useRef<HTMLDivElement>(null);
const [promptOverlayHeight, setPromptOverlayHeight] = useState(112);
useEffect(() => {
return bindSwipe(pageRef.current);
}, [bindSwipe]);
useEffect(() => {
const el = promptOverlayRef.current;
if (!el) return;
let mounted = true;
const observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry && mounted) {
setPromptOverlayHeight(entry.contentRect.height);
}
});
observer.observe(el);
return () => {
mounted = false;
observer.disconnect();
};
}, []);
const { data: repo, isLoading: repoLoading } = useQuery({
queryKey: ["repo", repoId],
queryFn: () => getRepo(repoId),
@@ -141,7 +160,7 @@ export function SessionDetail() {
const { current: currentQuestion, reply: replyToQuestion, reject: rejectQuestion } = useQuestions();
const sessionStatus = useSessionStatusForSession(sessionId);
const isSessionActive = sessionStatus.type === 'busy' || sessionStatus.type === 'retry';
const isSessionActive = sessionStatus.type === 'busy' || sessionStatus.type === 'compact' || sessionStatus.type === 'retry';
const lastAssistantMessage = messages?.filter(m => m.info.role === 'assistant').at(-1);
const lastAssistantText = (lastAssistantMessage?.parts ?? []).filter(p => p.type === 'text').map(p => p.text).join('\n\n') || '';
const hasIncompleteMessages = lastAssistantMessage ? !('completed' in lastAssistantMessage.info.time && lastAssistantMessage.info.time.completed) : false;
@@ -488,7 +507,7 @@ export function SessionDetail() {
<SessionTodoDisplay sessionID={sessionId} />
<div className="flex-1 overflow-hidden flex flex-col relative">
<div key={sessionId} ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden pb-28 overscroll-contain [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]">
<div key={sessionId} ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]" style={{ paddingBottom: promptOverlayHeight + inputBottomOffset + 16 }}>
{repoLoading || sessionLoading || messagesLoading ? (
<MessageSkeleton />
) : opcodeUrl && repoDirectory ? (
@@ -506,6 +525,7 @@ export function SessionDetail() {
</div>
{opcodeUrl && repoDirectory && !isEditingMessage && (
<div
ref={promptOverlayRef}
className="absolute left-0 right-0 flex justify-center"
style={{ bottom: inputBottomOffset }}
>