Commit Graph
761 Commits
Author SHA1 Message Date
Classic298 4ca96cffc8 fix: deleting a chat while its background sub-agent runs leaves the chat in place on Postgres (#35035)
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
2026-11-25 05:15:01 +04:00
Timothy Jaeryang Baek aceed36114 refac 2026-11-25 05:14:02 +04:00
Timothy Jaeryang Baek b6db862ad9 refac 2026-11-25 05:03:58 +04:00
Classic298 6123360666 fix: admins can read sub-agent chats with ENABLE_ADMIN_CHAT_ACCESS off (#35031)
With ENABLE_ADMIN_CHAT_ACCESS turned off, admins could still open another user's sub-agent, timer and note chats by id. Those chats hold the same conversation content as the parent chat, so they now follow the same setting as every other chat.
2026-11-25 05:00:26 +04:00
Classic298 d8c500a8d2 fix: questions and imported replies show as not done in the admin message analytics (#35010)
Since chats are stored message by message, the admin message analytics and a session's message list return `done: null` for every question and for imported replies that never said whether they finished, where they used to return `true`. They return `true` again, and only a reply that is still running reads as not done.

Fixes #35008
2026-11-25 03:40:02 +04:00
Classic298 5cfbbc3d09 fix: saving a chat without a reply's usage, output or error wipes them (#35009)
A chat save from an API client or an older tab that leaves out a reply's usage, output or error wiped them from the stored reply, so the admin analytics lost the reply's tokens and its failed status. A save now leaves the reply's fields it does not send as they were, usage, output and error included, the way the analytics kept them before chats were stored message by message, and the reopened reply keeps its tool output as well. Sending a field as empty clears it.

Fixes #35007
2026-11-25 03:39:48 +04:00
Classic298 991bb4609f fix: exporting chats, the archived chats list and Unarchive All slow down with many chats (#35005)
Since #34689 stored every message on its own, every action that loads many chats with their messages read them one chat at a time, so exporting chats, a folder's export, the admin's All Chats export and the archived chats list got several times slower, growing with the number of chats. The messages of the listed chats now come in one read per 500 chats. Unarchive All only needs to know which chats are archived and no longer loads any messages.

<table>
<tr><th>1000 chats, 10 messages each</th><th>SQLite before #34689</th><th>SQLite now</th><th>SQLite fix</th><th>PostgreSQL before #34689</th><th>PostgreSQL now</th><th>PostgreSQL fix</th></tr>
<tr><td>Export Chats</td><td>0.26 s</td><td>1.00 s</td><td>0.58 s</td><td>0.27 s</td><td>1.82 s</td><td>0.46 s</td></tr>
<tr><td>Folder export</td><td>0.21 s</td><td>1.86 s</td><td>0.51 s</td><td>0.19 s</td><td>1.09 s</td><td>0.42 s</td></tr>
<tr><td>Archived chats list</td><td>0.25 s</td><td>1.08 s</td><td>0.57 s</td><td>0.21 s</td><td>1.11 s</td><td>0.40 s</td></tr>
<tr><td>Unarchive All</td><td>0.07 s</td><td>1.13 s</td><td>0.02 s</td><td>0.13 s</td><td>0.94 s</td><td>0.05 s</td></tr>
<tr><td>Admin All Chats export</td><td>0.14 s</td><td>1.96 s</td><td>0.79 s</td><td>0.33 s</td><td>1.45 s</td><td>0.59 s</td></tr>
</table>

Fixes #35001
2026-11-25 03:39:28 +04:00
Classic298 27c9bc1dcb refac: lock the knowledge base while moving a directory (#34982)
Moving a directory now locks its knowledge base before checking the new parent.
2026-11-25 03:10:55 +04:00
Timothy Jaeryang Baek bcff000ad7 refac 2026-11-25 03:07:28 +04:00
Classic298 d3e87f8b14 refac: keep membership filter on group share list (#34973)
Listing groups with sharing turned off now only returns groups the caller belongs to.
2026-11-25 03:02:08 +04:00
Classic298 f605c1e4c5 refac: skip auto-join for group and dm channels on message insert (#34977)
Posting a message no longer adds the author as a member of group or direct message channels.
2026-11-25 03:00:47 +04:00
Timothy Jaeryang Baek 72184499b1 refac 2026-11-25 02:52:26 +04:00
Timothy Jaeryang Baek 9d19883f15 chore: format 2026-11-25 02:36:30 +04:00
Classic298 414340682e perf: long chats no longer rewrite the whole conversation on every message (#34689)
Every sent message, finished reply, regenerate, edit and saved follow-up rewrote the whole stored conversation, so long chats got slower with each turn, most of all on PostgreSQL. Messages now live only in the message table the app already keeps, and a change writes only the messages it touches. Chats open, share, export and import as before. API responses no longer carry the flat message list older clients saved next to the conversation, and the answers to pinning, archiving, sharing or moving a chat no longer repeat its messages. Existing chats are converted once during the upgrade, in batches that continue where they stopped if the upgrade is interrupted.

| 130 MB chat, instant test model | SQLite before | SQLite after | PostgreSQL before | PostgreSQL after |
| --- | --- | --- | --- | --- |
| Message accepted | 2.4 s | 0.20 s | 10.9 s | 0.32 s |
| Reply done | 4.9 s | 0.9 s | 22.5 s | 1.4 s |
| Regenerate done | 4.6 s | 0.9 s | 19.6 s | 1.4 s |
| Saving an edit | 3.7 s | 1.8 s | 5.8 s | 1.7 s |
| Opening the chat | 2.3 s | 0.9 s | 1.6 s | 1.2 s |
| Written to the database per message | 533 MB | 2 KB | 533 MB | 2 KB |

Fixes #34688
2026-11-25 02:34:37 +04:00
Timothy Jaeryang Baek a17581475a refac 2026-11-25 02:15:42 +04:00
Timothy Jaeryang Baek e85500e773 refac 2026-11-25 01:48:46 +04:00
Timothy Jaeryang Baek c37725b7a3 refac 2026-11-25 01:07:47 +04:00
G30 c56ba4e759 fix: reject future birth dates in account settings (#34961) 2026-11-24 23:11:24 +04:00
Timothy Jaeryang Baek f10d244d05 refac 2026-11-24 22:26:11 +04:00
Timothy Jaeryang Baek 1fbb42be97 refac 2026-11-24 22:11:32 +04:00
Timothy Jaeryang Baek 0f71ee15a1 refac 2026-11-24 20:58:02 +04:00
Timothy Jaeryang Baek f4a12bbc7f refac 2026-11-23 22:16:20 +04:00
Classic298 4abf416f96 perf: sidebar folder list no longer reads every attached file in full (#34862)
For regular users, opening the app read every file attached to their folders in full, extracted text included, one by one, only to confirm they could still see it. Files the user uploaded themselves are now confirmed with one small lookup per folder. Files shared by others still get the full access check, so files the user lost access to are still removed from the folder as before. The list and what each folder shows are unchanged.

<table>
<tr><th>30 folders x 8 files of 300 KB, SQLite</th><th>Before</th><th>After</th></tr>
<tr><td>Folder list, typical load</td><td>335 ms</td><td>44-61 ms</td></tr>
<tr><td>Database queries per load</td><td>268</td><td>59</td></tr>
</table>

Fixes #34861
2026-11-23 18:40:20 +04:00
Timothy Jaeryang Baek 464e83e414 refac 2026-11-23 16:21:00 +04:00
Timothy Jaeryang Baek 5697a0939a refac 2026-11-23 16:10:09 +04:00
Timothy Jaeryang Baek c3747e8449 refac 2026-11-23 15:06:29 +04:00
Timothy Jaeryang Baek f62d8efc7c refac 2026-11-22 21:25:13 +04:00
Timothy Jaeryang Baek a5058fa562 refac 2026-11-22 20:43:18 +04:00
Timothy Jaeryang Baek df6be8c3a1 refac 2026-11-22 17:13:34 +04:00
Timothy Jaeryang Baek 67863f310c refac 2026-11-22 15:54:36 +04:00
Timothy Jaeryang Baek e72b31f01f refac 2026-11-22 02:51:42 +04:00
Timothy Jaeryang Baek f59a3aff85 refac 2026-11-22 02:10:33 +04:00
Timothy Jaeryang Baek 91344e88f7 refac 2026-11-21 23:58:03 +04:00
Timothy Jaeryang Baek 0ee690e272 refac 2026-11-21 22:27:07 +04:00
Timothy Jaeryang Baek d798367389 refac 2026-11-21 21:41:24 +04:00
Timothy Jaeryang Baek a8e6e5d777 refac 2026-11-21 19:18:19 +04:00
Timothy Jaeryang Baek 679087e7b3 refac 2026-11-21 18:55:53 +04:00
Timothy Jaeryang Baek 3097ac6666 refac 2026-11-21 18:41:47 +04:00
Timothy Jaeryang Baek 916c03829d chore: format 2026-11-17 22:37:26 +09:00
Timothy Jaeryang Baek 0181885a24 refac 2026-11-17 22:15:11 +09:00
Timothy Jaeryang Baek ae35197cee refac 2026-11-17 22:03:13 +09:00
Timothy Jaeryang Baek c68b8a632e refac 2026-11-17 17:02:34 +09:00
Timothy Jaeryang Baek f14dca0eec refac 2026-11-17 00:14:38 +09:00
Timothy Jaeryang Baek 6a0223a882 refac 2026-11-16 22:16:34 +09:00
Classic298 7611074e2a fix: adding the same new tag to several chats at once fails all but one (#34144)
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
2026-11-16 21:59:40 +09:00
Classic298 956ee485f9 fix: concurrent requests stall for 30 seconds and fail with database session sharing on (#34185)
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
2026-11-16 19:15:17 +09:00
Timothy Jaeryang Baek aa394849d8 refac 2026-11-16 17:52:06 +09:00
Timothy Jaeryang Baek a199370769 refac 2026-11-16 15:16:21 +09:00
Timothy Jaeryang Baek 31ef2064da refac 2026-11-15 16:56:45 +09:00
Timothy Jaeryang Baek d7b3d08b4f refac 2026-11-14 14:16:19 +09:00