Files
orca/mobile/src/source-control/MobileSourceControlCreatePrEntry.tsx
T
Brennan Benson c6d2180417 fix(mobile): keep source-control layout steady while Create PR eligibility loads (#11467)
* fix(mobile): keep source-control layout steady while Create PR eligibility loads

The Create PR entry unmounted until the first hostedReview.getCreationEligibility
answer arrived, so on a cold open the changed-files list painted first and then
shifted down 54pt (createPrBlock marginTop 12 + createPrButton minHeight 42)
when the button appeared — while the user was already tapping (#8411).

- buildMobileCreatePrAction: cold loading now reserves the row with a disabled
  placeholder instead of unmounting it.
- useMobileHostedReviewEligibility: a fetch-imminent idle frame renders as an
  in-flight load, so the reservation is present on the first painted frame.
- New per-worktree+branch memory of the last resolved eligibility seeds cold
  loads, so branches whose answer is hidden (existing review, unsupported
  provider) do not get a placeholder that collapses on every reopen.

Fixes #8411

* fix(mobile): harden source-control layout reservation

* fix(mobile): keep review status row footprint fixed

* fix(mobile): derive eligibility state from keyed snapshots
2026-07-31 15:35:56 -07:00

54 lines
1.6 KiB
TypeScript

import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { GitPullRequestArrow } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import type { MobileCreatePrAction } from './mobile-create-pr-action'
import { styles } from './mobile-source-control-styles'
type Props = {
action: MobileCreatePrAction
}
export function MobileSourceControlCreatePrEntry({ action }: Props) {
if (!action.visible) {
return null
}
const enabled = !action.disabled
const copy = action.hint ?? action.label
return (
<View style={styles.createPrBlock}>
<Pressable
style={({ pressed }) => [
styles.createPrButton,
!enabled && styles.createPrButtonDisabled,
pressed && enabled && styles.createPrButtonPressed
]}
disabled={action.disabled}
onPress={action.onPress}
accessibilityRole="button"
accessibilityLabel={action.label}
accessibilityHint={action.hint}
>
{action.loading ? (
<ActivityIndicator size="small" color={enabled ? colors.bgBase : colors.textSecondary} />
) : (
<GitPullRequestArrow
size={16}
color={enabled ? colors.bgBase : colors.textSecondary}
strokeWidth={2.2}
/>
)}
<Text
style={[
styles.createPrButtonText,
!enabled && styles.createPrButtonTextDisabled,
action.hint && styles.createPrButtonHint
]}
numberOfLines={2}
>
{copy}
</Text>
</Pressable>
</View>
)
}