Preheat your oven to 375°F, placing a rack in the center position. Lightly coat a 13" x 9" baking dish with cooking spray. In a large skillet over medium heat, melt the butter. Add the sliced onions and season with 1 teaspoon of salt. Lower the heat to medium-low and cook, stirring occasionally, ensuring the onions do not burn by reducing heat further or adding a splash of water if necessary. Continue until the onions are deeply caramelized, about 30 minutes.
Step 2:
While the onions cook, bring a large pot of salted water to a boil. Cook the pasta shells until they are al dente, following the instructions on the package. Drain the shells, then return them to the pot. Drizzle with a bit of olive oil and gently toss to prevent sticking.
Step 3:
Add the red wine to the caramelized onions in the skillet. Increase the heat to medium-high, scraping up any browned bits from the bottom. Stir in the garlic and thyme, cooking until the liquid reduces, about 1 to 2 minutes.
Step 4:
In a mixing bowl, whisk together the egg, ricotta, 1 cup of shredded Gruyère, and 1/2 cup of grated Parmesan. Season with salt and black pepper to taste. Gently fold in half of the caramelized onions, blending well.
Step 5:
Carefully spoon a few tablespoons of the ricotta mixture into each shell, then arrange the filled shells in neat rows within the prepared baking dish.
Step 6:
Sprinkle the flour over the remaining caramelized onions in the skillet. Stir constantly over medium-low heat until the flour becomes fragrant and pasty, roughly 1 minute. Gradually pour in the beef broth, stirring continuously until the mixture reaches a boil and slightly thickens, approximately 5 minutes.
Step 7:
Pour the onion sauce over the stuffed shells, ensuring the onions are evenly distributed. In a separate bowl, combine the panko bread crumbs, the remaining 1/2 cup of shredded Gruyère, and 1 tablespoon of olive oil. Evenly sprinkle this mixture over the shells.
Step 8:
Cover the baking dish with foil and bake for 20 minutes. Remove the foil and continue baking for another 10 minutes or until the bread crumbs are golden and the cheese has melted. Allow the dish to rest for 5 to 10 minutes before serving. Garnish with additional thyme if desired.