1. Melt butter with oil in a heavy pot. Add onions, salt, and sugar; cook over medium heat, stirring often, until deeply caramelized and jammy, 30–40 minutes (lower heat if browning too fast).
2. Stir in garlic; cook 30 seconds. Deglaze with wine (if using); reduce by half.
3. Add broth, thyme, and bay leaf; simmer 15 minutes. Adjust salt/pepper and remove bay leaf.
4. Ladle soup into broiler-safe bowls, top with toasted baguette and Gruyère. Broil until cheese is bubbly and browned. (Or melt under a hot oven 2–3 minutes.)