Files
orca/mobile/src/source-control/MobileCommitFailurePanel.tsx
T
Jinjing 8a39450b18 refs/heads/handle-mobile-pull-request-issues (#6598)
* feat(mobile): add commit failure recovery panel with AI fix action

- Surfaces a "Commit failed" panel with a one-tap AI fix button when a
  git commit fails in the source control view or PR creation flow
- Detects commit failures specifically during the committing progress
  step and captures staged entries and commit message for context
- Extracts commit failure summary and prompt logic into
  `src/shared/source-control-commit-failure.ts` and PR checks prompt
  into `src/shared/pr-checks-fix-prompt.ts` so both desktop and mobile
  share the same implementations
- Adds auto-find of an available Metro port starting from 8081 and
  extracts expo CLI bootstrap into `mobile-expo-cli.mjs` shared by
  `start-emulator` and a new `start-expo.mjs` wrapper

* Share source-control AI prompts and simplify mobile PR actions

- Extract conflict, check-fixing, and commit-failure prompt builders
  to shared modules for reuse by both desktop and mobile.
- Configure Metro in the mobile package to watch and bundle modules
  from the repository-root shared directory.
- Remove the desktop-style merge method picker from the mobile PR
  actions panel, opting to use repository defaults automatically.
- Refactor mobile hosted review creation and git preparation logic
  into dedicated helper files.
2026-06-28 00:58:17 -07:00

74 lines
2.8 KiB
TypeScript

import { useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { ChevronDown, ChevronRight, Sparkles } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import type { MobileCommitFailureRecovery } from './mobile-commit-failure-recovery'
import type { MobileCommitFailureRecoveryAction } from './use-mobile-commit-failure-recovery'
import { styles } from './mobile-source-control-styles'
type Props = {
failure: MobileCommitFailureRecovery
action: MobileCommitFailureRecoveryAction
}
export function MobileCommitFailurePanel({ failure, action }: Props) {
const [expanded, setExpanded] = useState(false)
const Chevron = expanded ? ChevronDown : ChevronRight
const detailsText = failure.error.trim()
return (
<View style={styles.commitFailurePanel}>
<View style={styles.commitFailureHeader}>
<View style={styles.commitFailureTextBlock}>
<Text style={styles.commitFailureTitle}>Commit failed</Text>
<Text style={styles.commitFailureSummary} numberOfLines={2}>
{action.summary ?? 'Commit failed.'}
</Text>
</View>
<Pressable
style={({ pressed }) => [
styles.commitFailureFixButton,
action.launching && styles.commitFailureFixButtonDisabled,
pressed && styles.commitFailureFixButtonPressed
]}
onPress={() => void action.launch()}
disabled={action.launching}
accessibilityRole="button"
accessibilityLabel="Fix commit failure with AI"
>
{action.launching ? (
<ActivityIndicator color={colors.bgBase} />
) : (
<Sparkles size={14} color={colors.bgBase} strokeWidth={2.2} />
)}
<Text style={styles.commitFailureFixButtonText}>Fix</Text>
</Pressable>
</View>
{action.hasDetails && detailsText ? (
<>
<Pressable
style={({ pressed }) => [
styles.commitFailureDetailsButton,
pressed && styles.commitFailureDetailsButtonPressed
]}
onPress={() => setExpanded((current) => !current)}
accessibilityRole="button"
accessibilityLabel={
expanded ? 'Hide commit failure details' : 'Show commit failure details'
}
>
<Chevron size={14} color={colors.textSecondary} strokeWidth={2.2} />
<Text style={styles.commitFailureDetailsButtonText}>
{expanded ? 'Hide details' : 'Show details'}
</Text>
</Pressable>
{expanded ? <Text style={styles.commitFailureDetailsText}>{detailsText}</Text> : null}
</>
) : null}
{action.launchError ? (
<Text style={styles.commitFailureLaunchError}>{action.launchError}</Text>
) : null}
</View>
)
}