Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { useEffect, useMemo, useRef } from 'react'
import { ScrollView, Text } from 'react-native'
import { MobileSyntaxSegments } from '../components/MobileSyntaxSegments'
import { formatPreviewByteLength } from './mobile-file-preview-request'
import { scrollOffsetForPreviewLine } from './mobile-file-preview-line-column'
import { buildMobileFilePreviewSyntax } from './mobile-file-preview-syntax'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { filePreviewStyles as styles } from './mobile-file-preview-styles'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
export function MobileFilePreviewSourceText({
relativePath,
content,
truncated,
byteLength,
initialLine
}: {
relativePath: string
content: string
truncated?: boolean
byteLength?: number
initialLine?: number
}) {
useMobileColorScheme()
const t = useMobileTranslation()
const scrollRef = useRef<ScrollView>(null)
const revealedRef = useRef(false)
const syntax = useMemo(
() => buildMobileFilePreviewSyntax(relativePath, content),
[content, relativePath]
)
useEffect(() => {
revealedRef.current = false
}, [content, initialLine, relativePath])
const revealInitialLine = () => {
if (!initialLine || revealedRef.current) {
return
}
revealedRef.current = true
scrollRef.current?.scrollTo({
y: scrollOffsetForPreviewLine(initialLine),
animated: false
})
}
return (
<ScrollView
ref={scrollRef}
style={styles.scroll}
contentContainerStyle={styles.textContent}
onContentSizeChange={revealInitialLine}
>
{truncated ? (
<MobileFilePreviewTruncatedNote byteLength={byteLength ?? content.length} />
) : null}
<Text
selectable
style={styles.textPreview}
accessibilityLabel={t('files.filePreviewSourceText.previewLabel', 'File preview')}
>
<MobileSyntaxSegments segments={syntax.segments} />
</Text>
</ScrollView>
)
}
export function MobileFilePreviewTruncatedNote({ byteLength }: { byteLength: number }) {
useMobileColorScheme()
const t = useMobileTranslation()
return (
<Text style={styles.truncatedNote}>
{t('files.filePreviewSourceText.truncatedNote', 'Preview truncated. File size: {{size}}.', {
size: formatPreviewByteLength(byteLength)
})}
</Text>
)
}