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 { useRef, useState } from 'react'
import { Alert, Modal, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'
import { Copy, TextSelect, X } from 'lucide-react-native'
import type { NativeChatMessage } from '../../../../../src/shared/native-chat-types'
import { ActionSheetContent } from '../../../components/ActionSheetModal'
import { BottomDrawer } from '../../../components/BottomDrawer'
import { useClipboardWriter } from '../../../platform/clipboard'
import { useWindowSafeAreaInsets } from '../../../layout/side-safe-area'
import { colors, spacing, typography } from '../../../theme/mobile-theme'
import { themedStyleSheet } from '../../../theme/themed-styles'
import { useMobileColorScheme } from '../../../theme/use-mobile-color-scheme'
import { translate } from '../../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../../i18n/use-mobile-translation'
import { nativeChatMessageCopyText } from '../../../../../src/shared/native-chat-message-copy-text'
type Props = {
message: NativeChatMessage
onClose: () => void
}
export function MobileNativeChatMessageActionsSheet({
message,
onClose
}: Props): React.JSX.Element {
const t = useMobileTranslation()
const clipboard = useClipboardWriter()
const [sheetVisible, setSheetVisible] = useState(true)
const [selecting, setSelecting] = useState(false)
// Wait for the drawer to unmount before presenting another native modal.
const selectRequested = useRef(false)
// Streaming updates must not reset an active native text selection.
const [text] = useState(() => nativeChatMessageCopyText(message))
const closeSheet = () => setSheetVisible(false)
return (
<>
<BottomDrawer
visible={sheetVisible}
onClose={closeSheet}
onAfterClose={() => (selectRequested.current ? setSelecting(true) : onClose())}
dragContentToDismiss
>
<ActionSheetContent
onClose={closeSheet}
actions={[
{
id: 'copyMessage',
label: t('chat.messageActionsSheet.copyMessage', 'Copy message'),
icon: Copy,
disabled: text.length === 0,
onPress: () => {
void clipboard.writeText(text).catch((error: unknown) => {
Alert.alert(
translate('chat.messageActionsSheet.copyFailed', 'Copy failed'),
error instanceof Error
? error.message
: translate(
'chat.messageActionsSheet.clipboardRejected',
'The clipboard rejected the text.'
)
)
})
}
},
{
id: 'selectText',
label: t('chat.messageActionsSheet.selectText', 'Select text'),
icon: TextSelect,
disabled: text.length === 0,
onPress: () => {
selectRequested.current = true
}
}
]}
/>
</BottomDrawer>
{selecting ? <SelectTextScreen text={text} onClose={onClose} /> : null}
</>
)
}
function SelectTextScreen({
text,
onClose
}: {
text: string
onClose: () => void
}): React.JSX.Element {
useMobileColorScheme()
const t = useMobileTranslation()
const insets = useWindowSafeAreaInsets()
return (
<Modal visible animationType="slide" onRequestClose={onClose}>
<View
style={[
styles.screen,
{
paddingTop: insets.top,
paddingRight: insets.right,
paddingBottom: insets.bottom,
paddingLeft: insets.left
}
]}
>
<View style={styles.header}>
<Text style={styles.title}>
{t('chat.messageActionsSheet.selectText', 'Select text')}
</Text>
<Pressable
onPress={onClose}
hitSlop={12}
accessibilityLabel={t('common.close', 'Close')}
accessibilityRole="button"
style={styles.close}
>
<X size={20} color={colors.textSecondary} />
</Pressable>
</View>
<ScrollView contentContainerStyle={styles.body}>
<Text selectable style={styles.text}>
{text}
</Text>
</ScrollView>
</View>
</Modal>
)
}
const styles = themedStyleSheet(() => ({
screen: { flex: 1, backgroundColor: colors.bgBase },
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: colors.borderSubtle
},
title: { color: colors.textPrimary, fontSize: typography.titleSize, fontWeight: '600' },
close: { padding: spacing.xs },
body: { padding: spacing.lg },
text: { color: colors.textPrimary, fontSize: typography.bodySize, lineHeight: 22 }
}))