On Postgres with Redis, deleting a chat whose background sub-agent was still working often failed without an error. The sub-agent stopped and its thread went away, but the chat stayed in the sidebar. Stopping the sub-agent makes it post its result into that same chat, and that write and the delete blocked each other until the database cancelled one of them, usually the delete. Deleting a chat now locks the chat first, like every other write to a chat, so the two run one after the other. Deleting all chats or a folder's chats could clash the same way and gets the same change.
Fixes#35034