Skip to content

Commit 91ac4cc

Browse files
committed
fix(files): separate auto-scroll gate from streaming render mode in MarkdownPreview
1 parent f3d3921 commit 91ac4cc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ interface PreviewPanelProps {
6363
mimeType: string | null
6464
filename: string
6565
isStreaming?: boolean
66+
disableAutoScroll?: boolean
6667
onCheckboxToggle?: (checkboxIndex: number, checked: boolean) => void
6768
}
6869

@@ -71,6 +72,7 @@ export const PreviewPanel = memo(function PreviewPanel({
7172
mimeType,
7273
filename,
7374
isStreaming,
75+
disableAutoScroll,
7476
onCheckboxToggle,
7577
}: PreviewPanelProps) {
7678
const previewType = resolvePreviewType(mimeType, filename)
@@ -80,6 +82,7 @@ export const PreviewPanel = memo(function PreviewPanel({
8082
<MarkdownPreview
8183
content={content}
8284
isStreaming={isStreaming}
85+
disableAutoScroll={disableAutoScroll}
8386
onCheckboxToggle={onCheckboxToggle}
8487
/>
8588
)
@@ -649,14 +652,16 @@ function FrontMatterCard({ data }: { data: Record<string, unknown> }) {
649652
const MarkdownPreview = memo(function MarkdownPreview({
650653
content,
651654
isStreaming = false,
655+
disableAutoScroll = false,
652656
onCheckboxToggle,
653657
}: {
654658
content: string
655659
isStreaming?: boolean
660+
disableAutoScroll?: boolean
656661
onCheckboxToggle?: (checkboxIndex: number, checked: boolean) => void
657662
}) {
658663
const { push: navigate } = useRouter()
659-
const { ref: autoScrollRef } = useAutoScroll(isStreaming)
664+
const { ref: autoScrollRef } = useAutoScroll(isStreaming && !disableAutoScroll)
660665

661666
const contentRef = useRef(content)
662667
contentRef.current = content

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ export const TextEditor = memo(function TextEditor({
589589
)
590590

591591
const isStreaming = isStreamInteractionLocked
592-
const isPreviewFollowingStream = isStreaming && !disableStreamingAutoScroll
593592
const isEditorReadOnly = isStreamInteractionLocked || !canEdit
594593

595594
const previewType = resolvePreviewType(file.type, file.name)
@@ -678,7 +677,8 @@ export const TextEditor = memo(function TextEditor({
678677
content={content}
679678
mimeType={file.type}
680679
filename={file.name}
681-
isStreaming={isPreviewFollowingStream}
680+
isStreaming={isStreaming}
681+
disableAutoScroll={disableStreamingAutoScroll}
682682
onCheckboxToggle={canEdit && !isStreaming ? handleCheckboxToggle : undefined}
683683
/>
684684
</div>

0 commit comments

Comments
 (0)