feat(chatd): persist last_error on chats table#22436
Merged
Conversation
Adds a last_error column to the chats table so that when a chat transitions to error status, the error reason is stored in the database and returned in the Chat API payload. Previously the error was only published as an ephemeral SSE stream event and lost if the client wasn't connected. The UpdateChatStatus query now accepts a last_error parameter. All non-error status transitions pass an empty string, which clears any previous error. The two error paths (panic recovery and runChat failure) capture the error message into lastError before persisting. The SDK Chat struct gains a LastError field (omitted from JSON when empty) and convertChat maps it from the database row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a nullable
last_errorcolumn to thechatstable so error reasons survive page reloads.Backend:
last_error TEXT(nullable) to chatsUpdateChatStatuswrites the error reason when status transitions toerror, clears it (NULL) on recoveryconvertChatmapssql.NullStringto*stringin the SDKFrontend:
chat.last_errorwhen no stream error reason is cachedpersistedErrorReason