in the line that comes out of the diesel filter.
Which way should the diesel filter be oriented? The fuel line that carries fuel from the tank towards the engine (the supply line) must not contain any air bubbles. Air bubbles in the return line, on the other hand, are not a problem.
If you have air bubbles in the fuel line, then your fuel line is (somewhere) leaking slightly.

This would cause the engine to inject air instead of diesel...

Assuming that air has a lower calorific value than diesel, this could be the reason for your loss of power. }
Regards,
Private.