In a large pot, melt butter and olive oil over medium heat.
Add onions, garlic, and sugar. Cook slowly, stirring often, until onions are deeply caramelized. [Timer: 25–30 minutes]
Deglaze with wine (if using), scraping up browned bits. [Timer: 2 minutes]
Add beef broth (or chicken broth), thyme, and bay leaf. Simmer gently. [Timer: 30 minutes]
Season with salt and pepper. Remove thyme and bay leaf.
Toast baguette slices until crisp. [Timer: 5 minutes]
Ladle soup into oven-safe bowls, top with toasted bread, and cover with cheese. Broil until cheese is melted and bubbly. [Timer: 2–3 minutes]