Think of a person, now deceased, who you loved more than anyone else in your life.
Think of all the things you wish you had done for her or said to him. All the times you wish you had been more patient, more attuned to their unspoken needs and wishes, more concerned with their happiness and what would have brought it about, more aware of their sadness and how you could have done more to ease it.
Think of all the things you did right, but failed to do often enough.
Feeling the love and the regret, look around you. In our uncountable lifetimes, all beings have been someone we loved just as much. Someone we missed just as intensely. Someone we wish with our all heart we had done more for.
Our loved one we are thinking of is no longer with us. But the others are still here. The next time negative thoughts of the person you are with arise, feel your love for the one no longer here and remember the pain of regret.
And act toward the person with you as you wish you had with the one who is gone.