mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
A transition that left a chat runnable and unowned published a chat:ownership hint, and every replica's worker then queued on the chat row lock while one acquired it. ChatMachine and CreateChatWithID now take an optional LocalAcquirer. When a top-level transition leaves the chat runnable and unowned, the acquirer may acquire it in the same transaction; the update then publishes the owned row, skips the hint, and spawns the runner once after commit. Updates nested inside another Update never acquire, because the outer transaction owns the commit. The chat worker implements it for chatd API transitions and chat creation, and declines when it is not running, when capacity is capped, or when admission refuses, which keeps the hint path. Callers that return a row they reloaded inside their Update callback, such as SendMessage, return it as it was before the acquire. Generated by Coder Agents on behalf of @cstyan.