Fix: Error page on second trip edit attempt (Android)#1898
Fix: Error page on second trip edit attempt (Android)#1898
Conversation
Replace assertDefined(trip) with loading state in EditTripScreen to prevent crash when trip is briefly undefined during syncedCrud background sync. Also initialize tripLocationStore with trip's current location on mount to prevent location data loss and clean up on unmount to avoid stale state. Co-authored-by: andrew-bierman <94939237+andrew-bierman@users.noreply.github.com>
|
@coderabbitai Please review this PR for code quality, best practices, and potential issues. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 5006 🏁 Script executed: Length of output: 10103
✅ What's done well
|
|
@copilot CodeRabbit has reviewed this PR and provided feedback. Please address the review comments and push updates. Once you've made the changes, the monitor will ask CodeRabbit to re-review. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified EditTripScreen to synchronize trip location data with a store via useEffect, added loading state handling with ActivityIndicator, and improved lifecycle management by clearing store state on component cleanup or trip changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/expo/features/trips/screens/EditTripScreen.tsx (1)
5-5: Use the Expo app UI wrappers for this loading state.This screen is under
apps/expo/**, but the loading UI is built from rawreact-nativeprimitives. Please switch this branch to the app’s@packrat-ai/nativewinduicomponents for consistency with the rest of the Expo surface. As per coding guidelines,apps/expo/**/*.ts{,x}: Use@packrat-ai/nativewinduicomponents for consistent cross-platform UI in the Expo app.Also applies to: 28-30
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/expo/features/trips/screens/EditTripScreen.tsx` at line 5, Replace raw react-native UI primitives in EditTripScreen.tsx with the Expo app's UI wrappers: remove imports of ActivityIndicator and SafeAreaView from 'react-native' and instead import and use the equivalent components from '@packrat-ai/nativewindui' (replace usages of ActivityIndicator and SafeAreaView in the file and specifically the loading block around lines 28-30). Update the JSX to use the nativewindui equivalents wherever ActivityIndicator and SafeAreaView are referenced so the screen uses the consistent Expo app UI components.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/expo/features/trips/screens/EditTripScreen.tsx`:
- Around line 26-32: The current early return treats any falsy trip as loading;
instead detect a stale/missing trip by checking that effectiveId exists but the
fetch is not loading/has errored and trip is null, then replace the spinner
block in EditTripScreen with a non-loading fallback UI: show a user-friendly
message that the trip was not found and provide actions (e.g., a Back button or
Create New Trip) wired to the existing navigation methods, while keeping the
ActivityIndicator for the true loading state (when isLoading/isFetching is
true). Ensure you reference and use the same variables used in this component
(trip and effectiveId and the component's navigation handlers) so the fallback
only appears for deleted/stale IDs and not during actual loading.
- Around line 17-24: The current useEffect with dependency [trip?.id] sets
tripLocationStore but its cleanup runs on every dependency change; change this
by removing the cleanup from that effect (keep only the logic that calls
tripLocationStore.set(trip.location ?? null) inside the effect keyed by
trip?.id) and add a second useEffect with an empty dependency array whose sole
purpose is to return a cleanup that clears tripLocationStore
(tripLocationStore.set(null)) on unmount; reference the useEffect that currently
touches tripLocationStore, the trip variable, and tripLocationStore to locate
and split the logic in EditTripScreen.
---
Nitpick comments:
In `@apps/expo/features/trips/screens/EditTripScreen.tsx`:
- Line 5: Replace raw react-native UI primitives in EditTripScreen.tsx with the
Expo app's UI wrappers: remove imports of ActivityIndicator and SafeAreaView
from 'react-native' and instead import and use the equivalent components from
'@packrat-ai/nativewindui' (replace usages of ActivityIndicator and SafeAreaView
in the file and specifically the loading block around lines 28-30). Update the
JSX to use the nativewindui equivalents wherever ActivityIndicator and
SafeAreaView are referenced so the screen uses the consistent Expo app UI
components.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f984bf39-4cf0-448e-8907-543fce142902
📒 Files selected for processing (1)
apps/expo/features/trips/screens/EditTripScreen.tsx
|
@copilot Please address the CodeRabbit review feedback on this PR (2 inline comments). |
|
@copilot Reminder: please address the CodeRabbit review feedback on this PR. |
Split the combined useEffect into two: - [trip?.id] effect only seeds tripLocationStore (no cleanup risk on re-runs) - Empty-deps effect cleans up tripLocationStore on unmount only Add isLoaded check using tripsSyncState to distinguish loading from a genuinely missing/deleted trip, showing a Back button fallback instead of an infinite spinner for stale trip IDs. Co-authored-by: andrew-bierman <94939237+andrew-bierman@users.noreply.github.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
EditTripScreenby replacingassertDefined(trip)with a loading state (same pattern asTripDetailScreen)tripLocationStorewith the trip's current location on edit screen mount to prevent stale location data and fix location data loss buguseEffect— cleanup now runs in its own empty-deps effect (unmount only), preventing any risk of clearing in-progress location edits on sync-induced re-runstripsSyncState.isLoaded— shows Back button for stale/deleted trip IDs instead of an infinite spinnerOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Summary by CodeRabbit