Prepare the onions by peeling, halving, and thinly slicing until you have about 10 cups.
Cook the onions in a Dutch oven with butter, thyme, bay leaves, salt, and pepper for 35 to 45 minutes until amber brown, stirring often.
Chop the carrots into 1/4-inch rounds and celery into 1/4-inch pieces. Mince garlic cloves.
Combine the vegetables by adding remaining butter to the onion mixture. Once melted, add carrots and celery, cooking for about 5 minutes until crisp-tender.
Prepare the chicken by seasoning with salt and butterflying if needed for even cooking.
Add sherry to the pot and cook for 2 to 3 minutes until mostly evaporated. Sprinkle in the flour and stir constantly for 1 minute.
Pour in the chicken broth gradually while stirring, then add chicken in a single layer. Increase heat to medium-high and bring to a simmer.
Simmer gently until chicken reaches 165°F, about 10 minutes for thighs or 12 to 20 minutes for breasts.
Make cheesy toasts by broiling baguette slices topped with Gruyère cheese for 30 seconds to 1 minute until melted (optional).
Shred the chicken into bite-sized pieces, return to the pot, and remove bay leaves. Adjust seasoning if needed.
Serve in bowls and top with cheesy toast if desired.
Notes
For a vegetarian version, use vegetable broth and omit the chicken. Feel free to add other vegetables like mushrooms or potatoes for extra flavor and nutrition.