Wiktionary
l'esprit de l'escalier
n. (context idiomatic English) A conversational remark or rejoinder that only occurs to someone after the opportunity to make it has passed.
Wikipedia
L'esprit de l'escalier
or ("staircase wit") is a French term used in English for the predicament of thinking of the perfect reply too late.