Cook the Pasta:
Bring a large pot of salted water to a boil. Cook pasta according to package instructions until al dente. Reserve ½ cup of pasta water, then drain the pasta and set aside.
Sauté the Mushrooms:
In a large skillet, heat olive oil or butter over medium heat. Add the garlic and onion, cooking until fragrant and softened, about 2-3 minutes.
Add the sliced mushrooms and cook, stirring occasionally, until they release their moisture and start to brown, about 6-8 minutes.
Deglaze and Add Cream:
If using, pour in the white wine or vegetable broth to deglaze the pan, scraping up any browned bits. Let it simmer for 1-2 minutes until slightly reduced.
Stir in the heavy cream and thyme, allowing the sauce to simmer gently for 3-4 minutes.
Combine and Finish:
Add the cooked pasta to the skillet, tossing to coat in the sauce. Stir in Parmesan cheese and mix until melted and creamy. Adjust the sauce consistency with reserved pasta water if needed.
Season with salt and black pepper to taste.
Serve:
Divide the pasta into bowls and garnish with fresh parsley and extra Parmesan cheese if desired.