Hi Yoak,
As Stephen suggested, this sounds like an issue with the speed sensor, and possible a "sticky" reed switch inside of it. Generally, an impact from something like a crash, or even a derailleur breakage might shake something free, but I suppose it could also cause something to hang up.
I suggest this, because generally when we see issues related to speed readout, the problem is sporadic "misses" (the magnet does not consistently activate the switch), or zero response from sensor/switch. This results in lower than actual speed readout.
If your speed is inconsistent, and sometimes jumps to faster than you are actually going, the only thing I can think of is that the speed sensor is being falsely activated, independent of the magnet passing by on a spinning disc rotor. Maybe the switch is sticking, or maybe something else is going on.
If the Drive Unit thinks you are going 28 km/h, and that is above the legal cut-off for your eBike, then it makes sense that assistance would abruptly stop.
If it seems normal up to 20km/h, it could mean that the magnet is not tripping the sensor because it spends less time next to it when you are going at faster speeds. We see this sometimes... a partially defective sensor is OK until the eBike goes faster, and then it becomes an issue. This could be caused by a "bent" rear end, or a rear wheel not fully seated in drop-outs, or any other number of things that could have been affected by whatever caused your derailleur to break.
How did your derailleur break? Was anything else moved or adjusted when you made the repair? Example: was rear wheel removed for any reason? Is rear of frame still straight?
What is the make and model of your eBike? 25km or 45km Drive Unit?
If nothing else works out, may be worth it to have a Certified Bosch Dealer take a look, and do a Diagnostic Report. If there is an issue with the Drive Unit itself, the report might show that.