Toast the walnuts in a large frying pan over a medium heat for 1-2 mins until golden and starting to pop. Transfer to a bowl; set aside to cool.
Heat 2 tbsp oil in the frying pan over a medium heat and fry the onion for 10 mins until lightly golden. Stir in the peppers and cook for another 3-4 mins until soft, then add the mushrooms and increase the heat to high. Fry for 10-15 mins, stirring frequently, until the mushrooms are golden and any liquid from them has evaporated. Stir in the garlic and thyme, fry for 2 mins, then transfer to a plate and set aside to cool completely.
Meanwhile, make the pesto. Tip all but 1 tsp of the toasted seeds into a food processor with the lemon juice, basil, parmesan, and 2 tbsp olive oil; season. Blend to a semi-smooth paste, adding 1 tbsp water to bring it together if necessary.Transfer to a bowl.
Preheat the oven to 400°F. Line a work surface with a rectangle of nonstick baking paper and place a filo sheet on top with a long edge closest to you. Brush all over with butter, then place another filo sheet on top. Repeat with 5 more sheets, but don’t butter the top layer.
Pile the mushroom mix into the middle of the pastry in a sausage shape, leaving a 10 cm border around the long edges and 5 cm around the short edges. Spoon over the pesto, smoothing with the back of a spoon for an even layer. Fold both shorter ends over the filling, then roll up from a long side to make a sausage shape with the seal facing down (make sure the ends are tightly sealed so it doesn’t burst open when cooking). Transfer to a baking sheet, still on the baking paper. Brush with more butter and scatter over the reserved seeds. Bake for 30-35 mins until golden and crisp.
Cut into chunky slices with a serrated knife to serve. Leftovers will keep for up to 3 days in the fridge