I got this answer straight from chatgpt. It is a very good answer to your question.
In this dialogue, when person A says, "I feel terrible," they are expressing a strong sense of guilt and remorse for accidentally spilling coffee on person B. This phrase indicates that A is not only apologetic but also emotionally affected by the incident, feeling responsible for the inconvenience or discomfort caused to B. A's desire to make amends by offering to buy a new shirt further emphasizes their regret and intention to rectify the situation. Overall, "I feel terrible" conveys a deep sense of empathy and concern for the impact of their actions on another person.