Heat 1 tablespoon of the olive oil in a 12-inch skillet that is safe for broiling, setting the pan over medium heat.
Add one package of potato gnocchi in an even layer. Leave the gnocchi undisturbed for 3 to 5 minutes, or until the undersides develop a rich golden-brown crust.
Transfer the browned gnocchi to a baking sheet. Pour the remaining tablespoon of olive oil into the skillet and repeat the searing process with the second package. Move the second batch to the baking sheet and reserve all of the gnocchi.
Add the unsalted butter to the same skillet and allow it to melt over medium heat.
Place the thinly sliced onions in the pan along with half of the fresh thyme, reserving the remainder for the final garnish. Season with the kosher salt and 1/2 teaspoon black pepper.
Cook the onions for approximately 30 minutes, stirring from time to time, until they become exceptionally soft, deeply golden, and reduced to roughly half their original volume. If the onions begin adhering to the skillet before they are fully caramelized, a small splash of water may be added to loosen them from the pan.
Pour the dry white wine into the skillet. Using a wooden spoon, scrape the browned caramelized residue from the bottom of the pan so it incorporates into the onions.
Continue cooking for about 1 minute, until the wine has reduced and is nearly evaporated. Stir in the balsamic vinegar or sherry vinegar until evenly incorporated.
Return the reserved seared gnocchi to the skillet with the caramelized onion mixture. Fold everything together gently, then arrange the mixture in an even layer.
Scatter the shredded Gruyère uniformly over the surface, ensuring the gnocchi and onions are well covered.
Transfer the skillet beneath the broiler and cook for 4 to 6 minutes, watching carefully, until the Gruyère is fully melted, bubbling, and golden-brown across the top.
Remove the skillet from the broiler. Finish with the reserved fresh thyme and additional freshly ground black pepper before serving.