mirror of
https://github.com/coder/coder.git
synced 2026-06-05 14:08:20 +00:00
41bd7acf66
## Summary This PR removes two redundant chat rereads in `chatd`. ### Archive / unarchive - `archiveChat` and `unarchiveChat` already come through `httpmw.ChatParam`, so the handlers already have the `database.Chat` row. - Pass that row into `chatd.ArchiveChat` / `chatd.UnarchiveChat` instead of rereading by ID before publishing the sidebar events. ### End-of-turn cleanup - `processChat` no longer calls `GetChatByID` after the cleanup transaction just to refresh the chat snapshot. - Title generation already persists the generated title and emits its own `title_change` event. - To preserve best-effort title freshness for the cleanup path, the async title-generation goroutine stores the generated title in per-turn shared state and cleanup overlays it if available before publishing the `status_change` event and dispatching push notifications. ## Why - removes one DB read from archive / unarchive requests - removes one DB read from completed turns, which is the larger hot-path win - keeps the existing pubsub/event contract intact instead of broadening this into a larger event-model redesign ## Notes - `title_change` remains the authoritative title update for clients - cleanup does not wait for title generation; it uses the generated title only when it is already available