You want ĵus.
Ĵus means a moment before, while tuj means a moment after (or without delay). So tuj cannot be attached to antaŭ; it must refer to the first verb.
Mi komprenis tuj antaŭ ol vi respondis. I understood straightaway, before you replied.
Mi komprenis ĵus antaŭ ol vi respondis. I understood just before you answered.
You could say ekkomprenis but it isn't necessary here because the time sequence is given explicitly.
Tuj can also be used figuratively, but ĵus cannot.
EDIT: This answer turned out to be unexpectedly controversial, but I don't feel I understand the counterarguments well enough yet to revise it, and in any case googling reveals plenty of examples of both being used for just before by competent authors. So, I'm stuck. It seems you just have to be careful about your word order, and use plenty of commas.