Start by heating 1 tablespoon of olive oil in a large skillet over medium heat. Add half of the gnocchi in a single layer and let them cook undisturbed for 3–5 minutes until golden on the bottom. Transfer them to a baking sheet, then repeat with the remaining gnocchi.
Melt the butter in the same skillet and add the sliced onions, half the thyme, salt, and pepper. Cook slowly, stirring frequently, for 28–30 minutes until the onions turn a rich golden brown. Patience here is key—the longer you go, the deeper the flavor.
Pour the white wine over the caramelized onions and scrape up any browned bits from the pan. Let it cook for about a minute until the wine evaporates, then stir in the balsamic or sherry vinegar for a bright finishing touch.
Return the crisped gnocchi to the skillet, gently mixing with the onions. Spread everything evenly and sprinkle the grated Gruyere over the top. Check seasoning and adjust salt if necessary.
Place the skillet 6–8 inches from the broiler and cook for 4–6 minutes until the cheese is bubbly and golden brown. Keep a close eye to prevent burning.
Finish with the remaining thyme leaves and a few cracks of black pepper. Serve immediately while hot for the ultimate comfort experience.