1) Heat a small skillet with the butter over medium heat. Add the onions, season with salt ground thyme, bay leaf and cook until very soft and sweet and lightly caramelised, 20 minutes. Season with salt and pepper, to taste, and discard the bay leaf.
2) While the onions cook, put the potatoes in a medium pot and cover with water. Bring to the boil, then salt the water and cook to tender, 12 to 15 minutes. Drain and return the potatoes to the hot pot.
3) Mash the potatoes with the cream and Parmesan and season with salt and pepper, to taste.
4) Preheat the oven grill.
5) Arrange the mashed potatoes in individual gratin dishes or 1 shallow casserole. Top the potatoes with the onions and Gruyere cheese. Put them on a sheet pan and brown under a hot grill until bubbly, about 2 minutes. Remove from the oven and serve hot.