From a5da7863438ded571023ae5e270adcf30b84362a Mon Sep 17 00:00:00 2001 From: iliya Date: Wed, 25 Feb 2026 19:35:00 +0200 Subject: [PATCH] feat: add initial file path support and scrolling behavior in ChangeReviewDialog - Introduced an `initialFilePath` prop to facilitate scrolling to a specific file upon loading. - Implemented a mechanism to reset the scroll flag when `initialFilePath` changes. - Enhanced the scrolling functionality to automatically scroll to the specified file once the data is loaded, improving user navigation during reviews. --- .../team/review/ChangeReviewDialog.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/renderer/components/team/review/ChangeReviewDialog.tsx b/src/renderer/components/team/review/ChangeReviewDialog.tsx index 425c2e43..3091e718 100644 --- a/src/renderer/components/team/review/ChangeReviewDialog.tsx +++ b/src/renderer/components/team/review/ChangeReviewDialog.tsx @@ -29,6 +29,7 @@ interface ChangeReviewDialogProps { mode: 'agent' | 'task'; memberName?: string; taskId?: string; + initialFilePath?: string; } function isTaskChangeSetV2(cs: { teamName: string }): cs is TaskChangeSetV2 { @@ -42,6 +43,7 @@ export const ChangeReviewDialog = ({ mode, memberName, taskId, + initialFilePath, }: ChangeReviewDialogProps): React.ReactElement | null => { const { activeChangeSet, @@ -92,6 +94,9 @@ export const ChangeReviewDialog = ({ : null; }, [activeFilePath]); + // One-shot scroll-to-file ref (for initialFilePath) + const initialScrollDoneRef = useRef(false); + // Continuous scroll navigation const { scrollToFile, isProgrammaticScroll } = useContinuousScrollNav({ scrollContainerRef, @@ -255,6 +260,22 @@ export const ChangeReviewDialog = ({ clearChangeReview, ]); + // Reset initial scroll flag when initialFilePath changes + useEffect(() => { + initialScrollDoneRef.current = false; + }, [initialFilePath]); + + // Scroll to initialFilePath once data is loaded + useEffect(() => { + if (!activeChangeSet || !initialFilePath || initialScrollDoneRef.current) return; + const hasFile = activeChangeSet.files.some((f) => f.filePath === initialFilePath); + if (!hasFile) return; + initialScrollDoneRef.current = true; + requestAnimationFrame(() => { + requestAnimationFrame(() => scrollToFile(initialFilePath)); + }); + }, [activeChangeSet, initialFilePath, scrollToFile]); + // Escape to close useEffect(() => { if (!open) return;