When she decides to withdraw from buprenorphine or methadone she'll have had the baby and the primary danger will have passed.
Yes bupe does require being in withdrawal, but it doesn't take long to get to that point on a heroin habit. And it's probably lot safer than a full withdrawal while pregnant.
This is not a hypothetical, this has actually be studied. There are good reasons the majority of medical practice encourages maintenance for pregnant women. The risks are less than the alternatives of continued use or withdrawal.
Even if withdrawal doesn't risk a miscarriage and there's decent evidence it does. It also carries a risk that the mother will relapse and that that will put her and her child at risk.
Maintenance has been found to be the safest option. It doesn't carry a risk of miscarriage above the general population, it has the highest rate of success at keeping people stable, which is important for the pregnancy. It reduces the drive to do dangerous stuff to get drugs. And when the baby is delivered it can be weened off and evidence strongly indicates it'll be no worse for the experience than any other child.
With a good doctor I think it's very likely that that's what will be recommended.
The goal right now isn't to get her sober. It's to protect her and her babies health for the duration of the pregnancy. After that her and her doctors can decide if she wants to stay on maintenance or try and get completely clean. If she wants to get clean her and her baby can probably ween off it together.