What the agent does
The agent clones the repository into its own cloud sandbox and reads how data flows before adding anything. In an app like obytes/react-native-template-obytes (version 9.0.0, Expo SDK 54, React Native 0.81.5, Expo Router 6, pnpm), src/lib/api/provider.tsx creates a bare new QueryClient() and wraps the app in QueryClientProvider; src/features/feed/api.ts defines usePosts, usePost and useAddPost with react-query-kit over an axios client whose base URL comes from env.ts; src/features/feed/feed-screen.tsx shows a plain Error Loading data text whenever isError is true and an empty-list placeholder while pending; add-post-screen.tsx fires addPost and shows a flash message on success or error. Storage is already react-native-mmkv 4 through src/lib/storage.tsx, which exposes getItem, setItem and removeItem over one createMMKV() instance, and the auth store in src/features/auth/use-auth-store.tsx hydrates its token from it. No NetInfo, no persister and no networkMode appear anywhere, so a cold start without a network shows an error screen even if the feed was loaded a minute ago.
The agent installs @react-native-community/netinfo with npx expo install so the version matches SDK 54, plus @tanstack/react-query-persist-client and @tanstack/query-sync-storage-persister. In src/lib/api/provider.tsx it builds a synchronous persister over the existing MMKV instance (getString, set, remove), gives the client a gcTime of 24 hours so persisted queries are not thrown away on restore, and swaps QueryClientProvider for PersistQueryClientProvider with maxAge of 24 hours and buster set to the app version from env.ts, so a release that changes the API shape starts with an empty cache. A new src/lib/network.ts wires onlineManager.setEventListener to NetInfo's addEventListener, treating the device as online only when isConnected is true and isInternetReachable is not false, and sets focusManager from AppState so refetches happen when the app returns to the foreground. The React Query devtools plugin the provider already calls keeps working.
For writes, useAddPost keeps the default networkMode of online, which means a mutation fired without a network is paused rather than failed. To survive an app restart, the agent registers the mutation's function as a default for its key with queryClient.setMutationDefaults, and in the provider's onSuccess restore callback calls resumePausedMutations() followed by an invalidation of the posts query. add-post-screen.tsx gets a different flash message for the paused case so the user sees the post is queued rather than failed. A small OfflineBanner component, driven by NetInfo's useNetInfo hook, is mounted above the tabs in src/app/(app)/_layout.tsx, and feed-screen.tsx shows the error text only when there is no cached data to show, so a stale list with the banner replaces the error screen.
Tests follow the project's setup: Jest with the jest-expo preset and the testing-library helpers in src/lib/test-utils.tsx. The agent adds a test for the persister's read and write against a mocked MMKV, a render test of the feed with a prefilled cache and the online manager set to offline that expects the list and the banner rather than the error text, and a test that a mutation fired offline is paused and resumes when the manager goes online. It adds a mock for NetInfo under __mocks__/ next to the existing ones and runs pnpm check-all, which is lint, type-check, translation lint and Jest, in the sandbox. Maestro flows in .maestro/ need a device and are not run; the pull request says so.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add offline support to this React Native app. Read the API provider, the feed feature's queries and mutations, the MMKV storage module and the root layouts first. Persist the React Query cache to the existing MMKV instance with a persister and PersistQueryClientProvider, drive React Query's online manager from NetInfo and its focus manager from AppState, show an offline banner above the tabs, show cached data instead of the error screen when offline, and make the add-post mutation resume after a restart with mutation defaults. Add Jest tests for the persister, the offline feed render and the paused mutation, run lint, type-check and tests, and open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch that adds src/lib/network.ts, src/components/ui/offline-banner.tsx, a NetInfo mock and three test files, and changes src/lib/api/provider.tsx, src/features/feed/api.ts, feed-screen.tsx, add-post-screen.tsx, src/app/(app)/_layout.tsx, package.json and pnpm-lock.yaml. The description explains each behaviour change with the file it lives in and includes the pnpm check-all output from the sandbox.
The run's record keeps the install, the lint, the type check and the Jest run with every test name, so a reviewer can see what was covered without pulling the branch. The description also lists the one thing not done in the sandbox: a Maestro flow on a device with the network toggled, which the reviewer can run locally.
Before merging, a reviewer decides whether 24 hours is the right maxAge for this data, whether every query should persist or only the feed, and how the API treats a queued post that is sent twice after a flaky reconnect, since resuming paused mutations retries a request the server may already have received.
Run it on every Linear issue labelled offline
For a feature a product manager files rather than one you start yourself, add an automation in the Project with a linear trigger on linear.issue.labeled for the label offline and this prompt. When someone labels an issue, a run starts with the issue appended after the prompt, so the agent reads the acceptance criteria in the ticket before changing the provider, and the pull request links back to it. Linear is connected once under Settings → Connections; a label applied by another app integration never fires the trigger.
To start the same job from a script instead, send POST /o/{org}/sessions with this body and the issue's URL added to resources, which puts the issue in the prompt through your Linear connection. A request_id, a UUID v5 of the issue id, makes a repeated call return the run it already started.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Offline support touches the data layer, the navigation shell, two screens and the test setup at once, and the subtle part is in the details: a gcTime shorter than maxAge silently drops the restored cache, a paused mutation without a registered default never resumes after a restart, and isInternetReachable starts as null on some devices. The agent reads the library behaviour for the versions in your lockfile and gets those right the first time.
The sandbox runs the real pnpm check-all and keeps the output in the run's record, so the pull request shows lint, types and tests passing. Several apps, or several feature branches, can run at once in separate sandboxes.
Frequently asked questions
Does this queue a post written while offline?
Yes. The mutation is paused by React Query's online manager, shown to the user as queued, and sent when NetInfo reports the network back; because the mutation function is registered as a default for its key, a paused mutation restored from MMKV after a restart resumes too. Whether the server deduplicates a request that arrives twice is for the API to decide, and the pull request raises it.
Why MMKV and not AsyncStorage?
The app already uses MMKV for everything it stores, including the auth token, and MMKV is synchronous, so the persister can be the sync variant and the cache is available on the first render with no loading state. Adding AsyncStorage would add a second storage engine for no gain.
How long is cached data kept?
24 hours by default, set in one place as both maxAge on the persister and gcTime on the client, with the app version as the cache buster so a new release starts clean. Both numbers are in src/lib/api/provider.tsx and the pull request points at them.
Will the React Query devtools still work?
Yes. The provider keeps the @dev-plugins/react-query hook on the same client, so the Expo dev tools show the persisted queries, their restore state and any paused mutation.
More React Native jobs
The same job on other stacks
- Add Offline Support to a TanStack Query React App (TanStack Query)