diff --git a/mobile/app/h/[hostId]/source-control/[worktreeId].tsx b/mobile/app/h/[hostId]/source-control/[worktreeId].tsx index 01f362890bb..cce6bf253c2 100644 --- a/mobile/app/h/[hostId]/source-control/[worktreeId].tsx +++ b/mobile/app/h/[hostId]/source-control/[worktreeId].tsx @@ -288,12 +288,16 @@ export default function MobileSourceControlScreen() { currentStatusIdentityRef.current = statusIdentityKey currentBranchCompareIdentityRef.current = statusIdentityKey - useEffect(() => { - return () => { - mountedRef.current = false - loadGenerationRef.current += 1 - branchCompareGenerationRef.current += 1 + const setMobileSourceControlRootRef = useCallback((node: View | null): void => { + if (node !== null) { + mountedRef.current = true + return } + // Why: source-control RPC loads can outlive the route; invalidate pending + // writes when the screen detaches without a passive cleanup-only Effect. + mountedRef.current = false + loadGenerationRef.current += 1 + branchCompareGenerationRef.current += 1 }, []) useEffect(() => { @@ -1336,7 +1340,7 @@ export default function MobileSourceControlScreen() { }, [branchDiffPreview]) return ( - +