If it’s the Patellofemoral thing as linked above then that seems to be an exact match for what I had, after being hit by a car.
The injuries caused by the crash took (are taking!) longer to heal because of the underlying weakness of my quads vs the muscles on the outside of the leg. My physio showed me how much my kneecap moved to one side as a result of this. If you sit on a bed with your legs straight, then tense your leg up as if you’re trying to press down with your knee. When you tense up, your kneecap should move straight ‘up’ towards your body, mine moved diagonally, up and ‘out’. Essentially, this is what was happening with each pedal stroke which causes irritation to the cartilage under the kneecap (which was already angry as a result of the crash).
Exercise wise, I was told to do squats and leg presses, being very careful to keep your knee in line with your big toes. Leg extensions, and a ‘body weight’ version of these where you lie down and then raise your leg up to around 30-45 degrees, and move it out to the side then hold it there for 30 seconds, you should feel it working the quads on the inside of your legs.
My knee is still not right, but these seem to be making a difference.