fix: thread rerender due to thread scrolling padding subscription (#6629)
This commit is contained in:
parent
b422970369
commit
311b79fe13
19
web-app/src/containers/ThreadPadding.tsx
Normal file
19
web-app/src/containers/ThreadPadding.tsx
Normal 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"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -21,7 +21,7 @@ import { PlatformFeatures } from '@/lib/platform/const'
|
|||||||
import { PlatformFeature } from '@/lib/platform/types'
|
import { PlatformFeature } from '@/lib/platform/types'
|
||||||
import ScrollToBottom from '@/containers/ScrollToBottom'
|
import ScrollToBottom from '@/containers/ScrollToBottom'
|
||||||
import { PromptProgress } from '@/components/PromptProgress'
|
import { PromptProgress } from '@/components/PromptProgress'
|
||||||
import { useThreadScrolling } from '@/hooks/useThreadScrolling'
|
import { ThreadPadding } from '@/containers/ThreadPadding'
|
||||||
|
|
||||||
// as route.threadsDetail
|
// as route.threadsDetail
|
||||||
export const Route = createFileRoute('/threads/$threadId')({
|
export const Route = createFileRoute('/threads/$threadId')({
|
||||||
@ -49,9 +49,6 @@ function ThreadDetail() {
|
|||||||
const thread = useThreads(useShallow((state) => state.threads[threadId]))
|
const thread = useThreads(useShallow((state) => state.threads[threadId]))
|
||||||
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
// Get padding height for ChatGPT-style message positioning
|
|
||||||
const { paddingHeight } = useThreadScrolling(threadId, scrollContainerRef)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentThreadId(threadId)
|
setCurrentThreadId(threadId)
|
||||||
const assistant = assistants.find(
|
const assistant = assistants.find(
|
||||||
@ -191,11 +188,7 @@ function ThreadDetail() {
|
|||||||
data-test-id="thread-content-text"
|
data-test-id="thread-content-text"
|
||||||
/>
|
/>
|
||||||
{/* Persistent padding element for ChatGPT-style message positioning */}
|
{/* Persistent padding element for ChatGPT-style message positioning */}
|
||||||
<div
|
<ThreadPadding threadId={threadId} scrollContainerRef={scrollContainerRef} />
|
||||||
style={{ height: paddingHeight }}
|
|
||||||
className="flex-shrink-0"
|
|
||||||
data-testid="chat-padding"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user