From 4bff0cd0aba459f36068d99a4392b4935aec462c Mon Sep 17 00:00:00 2001 From: "E.G" <146701565+GlobalStar117@users.noreply.github.com> Date: Fri, 16 Jan 2026 14:34:42 +1100 Subject: [PATCH] fix: resolve 'Expand all chunks' button not working (#31074) Co-authored-by: GlobalStar117 Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> --- .../documents/detail/completed/index.tsx | 23 +++++++++++-------- .../completed/segment-card/chunk-content.tsx | 5 +++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/web/app/components/datasets/documents/detail/completed/index.tsx b/web/app/components/datasets/documents/detail/completed/index.tsx index 40c70e34f6..78cf0e1178 100644 --- a/web/app/components/datasets/documents/detail/completed/index.tsx +++ b/web/app/components/datasets/documents/detail/completed/index.tsx @@ -442,6 +442,10 @@ const Completed: FC = ({ setFullScreen(!fullScreen) }, [fullScreen]) + const toggleCollapsed = useCallback(() => { + setIsCollapsed(prev => !prev) + }, []) + const viewNewlyAddedChunk = useCallback(async () => { const totalPages = segmentListData?.total_pages || 0 const total = segmentListData?.total || 0 @@ -578,15 +582,16 @@ const Completed: FC = ({ return selectedStatus ? 1 : 0 }, [selectedStatus]) + const contextValue = useMemo(() => ({ + isCollapsed, + fullScreen, + toggleFullScreen, + currSegment, + currChildChunk, + }), [isCollapsed, fullScreen, toggleFullScreen, currSegment, currChildChunk]) + return ( - + {/* Menu Bar */} {!isFullDocMode && (
@@ -618,7 +623,7 @@ const Completed: FC = ({ onClear={() => handleInputChange('')} /> - setIsCollapsed(!isCollapsed)} /> +
)} {/* Segment list */} diff --git a/web/app/components/datasets/documents/detail/completed/segment-card/chunk-content.tsx b/web/app/components/datasets/documents/detail/completed/segment-card/chunk-content.tsx index dda2d9bf80..cd329345a1 100644 --- a/web/app/components/datasets/documents/detail/completed/segment-card/chunk-content.tsx +++ b/web/app/components/datasets/documents/detail/completed/segment-card/chunk-content.tsx @@ -1,4 +1,5 @@ import type { FC } from 'react' +import type { SegmentListContextValue } from '..' import * as React from 'react' import { Markdown } from '@/app/components/base/markdown' import { cn } from '@/utils/classnames' @@ -14,13 +15,15 @@ type ChunkContentProps = { className?: string } +const selectIsCollapsed = (s: SegmentListContextValue) => s.isCollapsed + const ChunkContent: FC = ({ detail, isFullDocMode, className, }) => { const { answer, content, sign_content } = detail - const isCollapsed = useSegmentListContext(s => s.isCollapsed) + const isCollapsed = useSegmentListContext(selectIsCollapsed) if (answer) { return (