a76aa6198c
compress_context() and /new already flush un-persisted messages before calling end_session() (fixed in #47202), but /resume and /branch still call end_session() directly. When a turn is interrupted mid-flight and the user immediately runs /resume or /branch, messages generated during that turn have not yet been written to state.db and are silently lost on session rotation. Add the same best-effort _flush_messages_to_session_db() call before end_session() in both _handle_resume_command and _handle_branch_command, mirroring the pattern established in cli.py:new_session(). Regression tests verify the flush is called when an agent is present.