fix: thread rerender due to thread scrolling padding subscription (#6629)

This commit is contained in:
Louis 2025-09-28 22:36:05 +07:00 committed by GitHub
parent b422970369
commit 311b79fe13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 9 deletions

View File

@ -0,0 +1,19 @@
import { useThreadScrolling } from '@/hooks/useThreadScrolling'
export const ThreadPadding = ({
threadId,
scrollContainerRef,
}: {
threadId: string
scrollContainerRef: React.RefObject<HTMLDivElement | null>
}) => {
// Get padding height for ChatGPT-style message positioning
const { paddingHeight } = useThreadScrolling(threadId, scrollContainerRef)
return (
<div
style={{ height: paddingHeight }}
className="flex-shrink-0"
data-testid="chat-padding"
/>
)
}

View File

@ -21,7 +21,7 @@ import { PlatformFeatures } from '@/lib/platform/const'
import { PlatformFeature } from '@/lib/platform/types'
import ScrollToBottom from '@/containers/ScrollToBottom'
import { PromptProgress } from '@/components/PromptProgress'
import { useThreadScrolling } from '@/hooks/useThreadScrolling'
import { ThreadPadding } from '@/containers/ThreadPadding'
// as route.threadsDetail
export const Route = createFileRoute('/threads/$threadId')({
@ -49,9 +49,6 @@ function ThreadDetail() {
const thread = useThreads(useShallow((state) => state.threads[threadId]))
const scrollContainerRef = useRef<HTMLDivElement>(null)
// Get padding height for ChatGPT-style message positioning
const { paddingHeight } = useThreadScrolling(threadId, scrollContainerRef)
useEffect(() => {
setCurrentThreadId(threadId)
const assistant = assistants.find(
@ -191,11 +188,7 @@ function ThreadDetail() {
data-test-id="thread-content-text"
/>
{/* Persistent padding element for ChatGPT-style message positioning */}
<div
style={{ height: paddingHeight }}
className="flex-shrink-0"
data-testid="chat-padding"
/>
<ThreadPadding threadId={threadId} scrollContainerRef={scrollContainerRef} />
</div>
</div>
<div