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, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { Check, Search } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
import type { GitHubAssignableUser } from '../../../../src/shared/github/pull-request-types'
import type { RpcClient } from '../../transport/rpc-client'
import { fetchAssignableUsers } from '../../session/github-pr-rpc'
import { BottomDrawer } from '../BottomDrawer'
import { TextField } from '../composer-input/TextField'
import { mobilePrSidebarStyles as styles } from './mobile-pr-sidebar-styles'
type Props = {
visible: boolean
onClose: () => void
client: RpcClient | null
worktreeId: string
// Logins already requested/reviewing (+ author) — surfaced at the top of the list.
seededLogins: string[]
// Resolves the optimistic requested-state for a login (so a just-toggled row reflects it).
isRequested: (login: string) => boolean
onToggle: (login: string) => void
}
type LoadState =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'error'; message: string | null }
| { status: 'loaded'; users: GitHubAssignableUser[] }
// Use mapped rows: VirtualizedList nested in PR ScrollView throws and can blank section. Seed reviewers/author first for easy unrequest.
export function ReviewerPickerDrawer({
visible,
onClose,
client,
worktreeId,
seededLogins,
isRequested,
onToggle
}: Props) {
useMobileColorScheme()
const t = useMobileTranslation()
const [load, setLoad] = useState<LoadState>({ status: 'idle' })
const [query, setQuery] = useState('')
useEffect(() => {
if (!visible || !client) {
return
}
let cancelled = false
setLoad({ status: 'loading' })
void fetchAssignableUsers(client, worktreeId)
.then((outcome) => {
if (cancelled) {
return
}
setLoad(
outcome.ok
? { status: 'loaded', users: outcome.result }
: { status: 'error', message: outcome.error }
)
})
.catch(() => {
if (!cancelled) {
setLoad({ status: 'error', message: null })
}
})
return () => {
cancelled = true
}
}, [visible, client, worktreeId])
const ordered = useMemo(() => {
if (load.status !== 'loaded') {
return []
}
const seed = new Set(seededLogins.map((l) => l.toLowerCase()))
const sorted = [...load.users].sort((a, b) => {
const aSeed = seed.has(a.login.toLowerCase()) ? 0 : 1
const bSeed = seed.has(b.login.toLowerCase()) ? 0 : 1
return aSeed - bSeed || a.login.localeCompare(b.login)
})
const q = query.trim().toLowerCase()
if (!q) {
return sorted
}
return sorted.filter(
(u) => u.login.toLowerCase().includes(q) || (u.name ?? '').toLowerCase().includes(q)
)
}, [load, seededLogins, query])
return (
<BottomDrawer visible={visible} onClose={onClose} dragContentToDismiss={false}>
<Text style={styles.pickerTitle}>
{t('pullRequest.reviewerPickerDrawer.title', 'Reviewers')}
</Text>
<TextField
style={styles.pickerSearch}
leading={<Search size={16} color={colors.textMuted} />}
value={query}
onChangeText={setQuery}
placeholder={t('pullRequest.reviewerPickerDrawer.searchPeople', 'Search people')}
autoCapitalize="none"
autoCorrect={false}
/>
{load.status === 'loading' ? (
<View style={styles.pickerStateArea}>
<ActivityIndicator color={colors.textSecondary} />
</View>
) : load.status === 'error' ? (
<View style={styles.pickerStateArea}>
<Text style={styles.emptyText}>
{load.message ??
t('pullRequest.reviewerPickerDrawer.loadFailed', 'Failed to load people')}
</Text>
</View>
) : ordered.length === 0 ? (
<View style={styles.pickerStateArea}>
<Text style={styles.emptyText}>
{t('pullRequest.reviewerPickerDrawer.noMatches', 'No matching people')}
</Text>
</View>
) : (
<View style={styles.pickerList}>
{ordered.map((item) => {
const requested = isRequested(item.login)
return (
<Pressable
key={item.login}
style={styles.pickerRow}
onPress={() => onToggle(item.login)}
accessibilityRole="button"
accessibilityState={{ selected: requested }}
accessibilityLabel={
requested
? t('pullRequest.reviewerPickerDrawer.removeReviewer', 'Remove {{login}}', {
login: item.login
})
: t('pullRequest.reviewerPickerDrawer.requestReviewer', 'Request {{login}}', {
login: item.login
})
}
>
<View style={styles.rowTrailing}>
{requested ? (
<Check size={16} color={colors.textPrimary} strokeWidth={2.4} />
) : null}
</View>
<View style={styles.pickerRowMain}>
<Text style={styles.rowTitle} numberOfLines={1}>
{item.name ? `${item.name} (${item.login})` : item.login}
</Text>
</View>
</Pressable>
)
})}
</View>
)}
</BottomDrawer>
)
}