Skip to content

Commit e2ded16

Browse files
authored
fix(snapshot): stop markdown preview auto-scroll during patch streams + snapshot styling (#4333)
* fix(files): stop markdown preview auto-scrolling during copilot patch streams fix(snapshot): use surface-4 background for input/output code blocks in light mode * fix(files): separate auto-scroll gate from streaming render mode in MarkdownPreview
1 parent 7b55e60 commit e2ded16

4 files changed

Lines changed: 96 additions & 90 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ export const TextEditor = memo(function TextEditor({
678678
mimeType={file.type}
679679
filename={file.name}
680680
isStreaming={isStreaming}
681+
disableAutoScroll={disableStreamingAutoScroll}
681682
onCheckboxToggle={canEdit && !isStreaming ? handleCheckboxToggle : undefined}
682683
/>
683684
</div>

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-editor/preview-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ function PreviewEditorContent({
12501250
<Code.Viewer
12511251
code={formatValueAsJson(executionData.input)}
12521252
language='json'
1253-
className='!bg-[var(--surface-3)] max-h-[300px] min-h-0 max-w-full rounded-md border-0 [word-break:break-all]'
1253+
className='!bg-[var(--surface-4)] dark:!bg-[var(--surface-3)] max-h-[300px] min-h-0 max-w-full rounded-md border-0 [word-break:break-all]'
12541254
wrapText={wrapText}
12551255
searchQuery={isSearchActive ? searchQuery : undefined}
12561256
currentMatchIndex={currentMatchIndex}
@@ -1320,7 +1320,7 @@ function PreviewEditorContent({
13201320
code={formatValueAsJson(executionData.output)}
13211321
language='json'
13221322
className={cn(
1323-
'!bg-[var(--surface-3)] max-h-[300px] min-h-0 max-w-full rounded-md border-0 [word-break:break-all]',
1323+
'!bg-[var(--surface-4)] dark:!bg-[var(--surface-3)] max-h-[300px] min-h-0 max-w-full rounded-md border-0 [word-break:break-all]',
13241324
executionData.status === 'error' && 'text-[var(--text-error)]'
13251325
)}
13261326
wrapText={wrapText}

0 commit comments

Comments
 (0)