Slice your onions into ¼-inch moons and set aside. Mince your garlic finely so it distributes evenly throughout the soup. Toast your baguette slices in a 450°F oven for about 5 minutes until golden and crispy, then set aside.
Heat 7 tablespoons of olive oil in a large heavy-bottomed pot over medium heat until shimmering. Add the sliced onions and sea salt, stirring to coat everything evenly.
Reduce heat to medium-low and cook the onions for 40 minutes, stirring occasionally every 8-10 minutes until golden.
Increase heat to medium and continue cooking for 15-20 minutes, stirring more frequently until the onions develop a rich, deep brown color.
Add the balsamic vinegar, tamari, thyme leaves, and minced garlic to the caramelized onions, stirring constantly for about 1 minute.
Sprinkle the flour over the mixture and stir vigorously for 2 minutes.
Pour in the dry white wine, stirring constantly and scraping the bottom of the pot to release all the flavorful browned bits, then cook for another 2 minutes.
Add the vegetable broth and bay leaf, bringing to a gentle simmer and cooking for 30 minutes.
Taste and adjust seasoning with black pepper and red pepper flakes if desired.
Ladle the hot soup into oven-safe bowls and top each bowl with a toasted baguette slice.
Pile freshly shredded gruyère cheese generously on top of the bread and bake at 450°F for 8-10 minutes.