In a large frying pan, saute onions in oil over medium heat until softened. Add the chicken, and cook until browned on all sides. Add the mushrooms, and cook until soft. Stir in the thyme and flour, and then add the wine. Dissolve the chicken stock cube in water, and stir into the chicken and vegetables. Simmer uncovered for 15 minutes, then season to taste. Transfer mixture into a deep pie dish, or a 2 litre baking dish, and set aside. Keep any excess sauce separately for gravy.
Preheat the oven to 220 C / Gas 7.
Roll out the puff pastry. Cut a 1cm strip. Brush the rim of the pie plate with water, arrange the pastry strip around the top edge of the pie dish, and press the pastry in position. Brush the pastry edge with water. Roll out remaining pastry, and use to cover the filling. Seal the edges well; trim and crimp the edge. Brush pastry with beaten egg, and make a small hole in the centre of the top. Use the pastry trimmings to make leaves; arrange on top of the pie. Brush pastry leaves with egg.
Bake in preheated oven for 45 minutes, or until crisp and golden.