@@ -9,6 +9,7 @@ import { showToast } from "@opencode-ai/ui/toast"
99import { LineComment as LineCommentView , LineCommentEditor } from "@opencode-ai/ui/line-comment"
1010import { Mark } from "@opencode-ai/ui/logo"
1111import { Tabs } from "@opencode-ai/ui/tabs"
12+ import { ScrollView } from "@opencode-ai/ui/scroll-view"
1213import { useLayout } from "@/context/layout"
1314import { selectionFromLines , useFile , type FileSelection , type SelectedLineRange } from "@/context/file"
1415import { useComments } from "@/context/comments"
@@ -509,51 +510,52 @@ export function FileTabContent(props: { tab: string }) {
509510 )
510511
511512 return (
512- < Tabs . Content
513- value = { props . tab }
514- class = "mt-3 relative"
515- ref = { ( el : HTMLDivElement ) => {
516- scroll = el
517- restoreScroll ( )
518- } }
519- onScroll = { handleScroll }
520- >
521- < Switch >
522- < Match when = { state ( ) ?. loaded && isImage ( ) } >
523- < div class = "px-6 py-4 pb-40" >
524- < img
525- src = { imageDataUrl ( ) }
526- alt = { path ( ) }
527- class = "max-w-full"
528- onLoad = { ( ) => requestAnimationFrame ( restoreScroll ) }
529- />
530- </ div >
531- </ Match >
532- < Match when = { state ( ) ?. loaded && isSvg ( ) } >
533- < div class = "flex flex-col gap-4 px-6 py-4" >
534- { renderCode ( svgContent ( ) ?? "" , "" ) }
535- < Show when = { svgPreviewUrl ( ) } >
536- < div class = "flex justify-center pb-40" >
537- < img src = { svgPreviewUrl ( ) } alt = { path ( ) } class = "max-w-full max-h-96" />
513+ < Tabs . Content value = { props . tab } class = "mt-3 relative h-full" >
514+ < ScrollView
515+ class = "h-full"
516+ viewportRef = { ( el : HTMLDivElement ) => {
517+ scroll = el
518+ restoreScroll ( )
519+ } }
520+ onScroll = { handleScroll as any }
521+ >
522+ < Switch >
523+ < Match when = { state ( ) ?. loaded && isImage ( ) } >
524+ < div class = "px-6 py-4 pb-40" >
525+ < img
526+ src = { imageDataUrl ( ) }
527+ alt = { path ( ) }
528+ class = "max-w-full"
529+ onLoad = { ( ) => requestAnimationFrame ( restoreScroll ) }
530+ />
531+ </ div >
532+ </ Match >
533+ < Match when = { state ( ) ?. loaded && isSvg ( ) } >
534+ < div class = "flex flex-col gap-4 px-6 py-4" >
535+ { renderCode ( svgContent ( ) ?? "" , "" ) }
536+ < Show when = { svgPreviewUrl ( ) } >
537+ < div class = "flex justify-center pb-40" >
538+ < img src = { svgPreviewUrl ( ) } alt = { path ( ) } class = "max-w-full max-h-96" />
539+ </ div >
540+ </ Show >
541+ </ div >
542+ </ Match >
543+ < Match when = { state ( ) ?. loaded && isBinary ( ) } >
544+ < div class = "h-full px-6 pb-42 flex flex-col items-center justify-center text-center gap-6" >
545+ < Mark class = "w-14 opacity-10" />
546+ < div class = "flex flex-col gap-2 max-w-md" >
547+ < div class = "text-14-semibold text-text-strong truncate" > { path ( ) ?. split ( "/" ) . pop ( ) } </ div >
548+ < div class = "text-14-regular text-text-weak" > { language . t ( "session.files.binaryContent" ) } </ div >
538549 </ div >
539- </ Show >
540- </ div >
541- </ Match >
542- < Match when = { state ( ) ?. loaded && isBinary ( ) } >
543- < div class = "h-full px-6 pb-42 flex flex-col items-center justify-center text-center gap-6" >
544- < Mark class = "w-14 opacity-10" />
545- < div class = "flex flex-col gap-2 max-w-md" >
546- < div class = "text-14-semibold text-text-strong truncate" > { path ( ) ?. split ( "/" ) . pop ( ) } </ div >
547- < div class = "text-14-regular text-text-weak" > { language . t ( "session.files.binaryContent" ) } </ div >
548550 </ div >
549- </ div >
550- </ Match >
551- < Match when = { state ( ) ?. loaded } > { renderCode ( contents ( ) , "pb-40" ) } </ Match >
552- < Match when = { state ( ) ? .loading } >
553- < div class = "px-6 py-4 text-text-weak" > { language . t ( "common.loading" ) } ... </ div >
554- </ Match >
555- < Match when = { state ( ) ?. error } > { ( err ) => < div class = "px-6 py-4 text-text-weak" > { err ( ) } </ div > } </ Match >
556- </ Switch >
551+ </ Match >
552+ < Match when = { state ( ) ?. loaded } > { renderCode ( contents ( ) , "pb-40" ) } </ Match >
553+ < Match when = { state ( ) ?. loading } >
554+ < div class = "px-6 py-4 text-text-weak" > { language . t ( "common .loading" ) } ... </ div >
555+ </ Match >
556+ < Match when = { state ( ) ?. error } > { ( err ) => < div class = "px-6 py-4 text-text-weak" > { err ( ) } </ div > } </ Match >
557+ </ Switch >
558+ </ ScrollView >
557559 </ Tabs . Content >
558560 )
559561}
0 commit comments