In the case that ghiba becomes halal for one who commits sins publicly. What time of ghiba is this? And after it being halal for how long is it halal? What if the person repented the at the night after committing that sin? How should we know when to stop doing ghiba on this person?

When a person commits a sin publicly, it is permissible to talk about with the intention of standing up to such sins. There is no limit on the time. However, if you know the person repented you can no longer expose him for it, since he repented.