-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(mobile): stop the changed files widget from crashing #7867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,7 +398,11 @@ export function ReviewSheet(props: ReviewSheetProps) { | |
| selectedSection, | ||
| draftMessage, | ||
| }); | ||
| const NativeReviewDiffView = resolveNativeReviewDiffView()!; | ||
| // Resolution returns null while Expo registers the native view (or forever | ||
| // when the binary lacks it). Rendering a null component type crashes the | ||
| // app, so callers must fall back — ThreadFeed's ReviewCommentCard does the | ||
| // same check. | ||
| const NativeReviewDiffView = resolveNativeReviewDiffView(); | ||
| const nativeReviewDiffViewRef = useRef<NativeReviewDiffViewHandle>(null); | ||
| const showcasedReviewDrawRef = useRef<string | null>(null); | ||
| // Native pull-to-refresh on the diff surface (replaces the old Refresh menu item). | ||
|
|
@@ -780,7 +784,7 @@ export function ReviewSheet(props: ReviewSheetProps) { | |
| onRetry={handleRetryEnvironment} | ||
| /> | ||
| </View> | ||
| ) : selectedSection && parsedDiff.kind === "files" ? ( | ||
| ) : selectedSection && parsedDiff.kind === "files" && NativeReviewDiffView ? ( | ||
| <View | ||
| className="flex-1" | ||
| style={{ | ||
|
|
@@ -866,6 +870,19 @@ export function ReviewSheet(props: ReviewSheetProps) { | |
| </Text> | ||
| </ScrollView> | ||
| </View> | ||
| ) : parsedDiff.kind === "files" ? ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On iOS when the native view is unavailable, this branch renders a plain Useful? React with 👍 / 👎. |
||
| // The native diff surface could not be resolved on this binary; | ||
| // degrade to the raw patch instead of crashing the app. | ||
| <View className="gap-3 border-b border-border bg-card px-4 py-4"> | ||
| <Text className="text-xs leading-normal text-foreground-muted"> | ||
| Native diff view unavailable. Showing the raw patch. | ||
| </Text> | ||
| <ScrollView horizontal showsHorizontalScrollIndicator={false} bounces={false}> | ||
| <Text selectable className="font-mono text-xs leading-relaxed text-foreground"> | ||
| {selectedSection?.diff ?? ""} | ||
| </Text> | ||
| </ScrollView> | ||
| </View> | ||
| ) : null} | ||
| </ScrollView> | ||
| )} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
resolveNativeReviewDiffView()returns null for an older or incompletely registered binary,showChangedFilesPanestill registersReviewFileNavigator. Selecting a file updates the row's selected state, buthandleSelectFileonly callsnativeReviewDiffViewRef.current?.scrollToFile(...); the ref is necessarily null in this branch, and the raw patch is neither scrolled nor filtered. The navigator therefore presents working controls that cannot navigate, so either hide it when the native view is unavailable or connect it to the fallback renderer.Useful? React with 👍 / 👎.