Cook the pasta: Bring a large pot of salted water to a boil. Add spaghetti and cook until al dente, about 8-10 minutes. Drain and set aside.
Sauté the vegetables: In a large skillet, melt butter over medium heat. Add diced onion and sauté for 3 minutes until softened. Add mushrooms (if using) and garlic, cooking for 4-5 minutes until mushrooms release their moisture.
Make the sauce: Sprinkle flour over the vegetables and stir for 1 minute to form a roux. Gradually whisk in chicken broth, ensuring no lumps form. Add heavy cream and thyme, then simmer for 5 minutes until thickened. Stir in ½ cup Parmesan cheese and season with salt and pepper.
Combine ingredients: In a large bowl, mix cooked pasta, shredded chicken, and creamy sauce. Add peas or broccoli, if using, and stir gently to coat evenly.
Assemble and bake: Preheat oven to 375°F (190°C). Transfer mixture to a greased 9x13-inch baking dish. Sprinkle mozzarella, remaining Parmesan, and panko breadcrumbs (if using) on top. Bake for 20-25 minutes until bubbly and golden brown.
Serve: Let cool for 5 minutes, then serve warm with a side salad or garlic bread.