In a large pot, melt butter and olive oil over medium heat. Add the thinly sliced onions and cook, stirring occasionally, until they are deeply caramelized and golden brown. Sprinkle sugar over the onions to aid in caramelization.
Stir in minced garlic and cook for an additional 1-2 minutes. Pour in the white wine to deglaze the pot, scraping up any browned bits from the bottom.
Pour in the beef broth, add bay leaves, and season with salt and pepper. Bring the soup to a simmer and let it cook for about 30-40 minutes to allow the flavors to meld.
While the soup simmers, preheat the oven broiler. Arrange baguette slices on a baking sheet and toast them under the broiler until golden.
Ladle the soup into oven-safe bowls. Place a slice of toasted baguette on top of each bowl and generously sprinkle with grated Gruyre cheese.
Place the bowls under the broiler until the cheese is melted and golden brown, creating a delightful crust.
Remove from the oven, garnish with fresh thyme if desired, and serve immediately.