When several requests from one account added the same new tag at the same moment, for example an API client tagging a batch of chats in parallel or two chat imports bringing the same tag, only one of them went through. The others failed with a server error, and a chat whose tag request failed stayed without the tag. A tag that another request created in the meantime now counts as already there, so every request succeeds and the tag is stored once.
Fixes#34143
With DATABASE_ENABLE_SESSION_SHARING on (off by default), the chat lists and the inbox held the request's database connection while they opened a second one for a small extra read. A burst of page loads then took every pooled connection, each request waited for a second connection, and they failed after the 30 second pool timeout with "QueuePool limit ... reached". Those extra reads now run on the request's own connection. In a burst of 80 page loads with a pool of 5, 11 failed on SQLite and 58 on PostgreSQL before this change, and none fail now.
Fixes#34184
A window that had missed a turn, for example a laptop that just woke up and has not reconnected yet, saved its own, older idea of where the chat was when it saved an edited message. The chat then reopened on that older turn, and the next message started a new branch there, so the newest reply moved behind the branch switch and the model no longer saw it. A save now keeps the chat on the newest turn of the branch it is on, the same turn the chat already shows once it has caught up.
Fixes#34126
Diffing two versions of a skill, tool, function or prompt now refuses inputs above 5000 lines per version. All four history diff views share the same check.
Every time a chat is opened, the server marks it as read, and to do so it loaded and parsed the full chat, images included, just to save the last-read time. Marking a chat as unread and removing a tag from a chat did the same. These now touch only the few chat fields they change, which makes them 4 to 6 times faster on large chats.
Measured on SQLite, best of 7 runs, sizes are the chat as stored in the database:
| Chat | Action | Before | After |
| --- | --- | --- | --- |
| 7 MB, text only | open (mark read) | 19.8 ms | 3.5 ms |
| 7 MB, text only | mark as unread | 20.7 ms | 3.5 ms |
| 7 MB, text only | remove tag | 21.2 ms | 3.4 ms |
| 49 MB, with images | open (mark read) | 122.2 ms | 30.0 ms |
| 49 MB, with images | mark as unread | 124.2 ms | 29.1 ms |
| 49 MB, with images | remove tag | 120.5 ms | 28.6 ms |