Preheat the oven to 400°F. Grease a 10×16-inch baking dish with butter or nonstick spray.
Melt the butter in a large skillet over medium heat. Add the onions, thyme, and salt. Cook, stirring occasionally, for 25–30 minutes, until the onions are deeply golden and caramelized. Deglaze with the white wine, if using, and cook until the liquid has reduced. Remove and discard thyme sprigs.
In a medium saucepan over low heat, warm the beef stock. Whisk in the chive & onion cream cheese until smooth and fully melted. Season with black pepper.
Arrange half of the sliced potatoes evenly in the prepared baking dish. Spoon over half of the caramelized onions, sprinkle with half of the shredded cheese, and pour over half of the warm cream cheese sauce. Repeat with the remaining potatoes, onions, cheese, and sauce. Sprinkle the Parmesan evenly over the top.
Cover tightly with foil and bake for 35–40 minutes. Uncover and continue baking for 20–25 minutes, until the top is golden, bubbling, and the potatoes are fork-tender.
Let rest for 10–15 minutes before slicing. Garnish with fresh thyme and serve warm.