fix: Streaming assistant snapshots rewrite FTS rows on every upsert#827
Closed
sam-saffron-jarvis wants to merge 1 commit into
Closed
fix: Streaming assistant snapshots rewrite FTS rows on every upsert#827sam-saffron-jarvis wants to merge 1 commit into
sam-saffron-jarvis wants to merge 1 commit into
Conversation
Owner
|
Implemented directly in main working tree with the same fixes and regression coverage. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
internal/sessionso interim assistant snapshot updates can skip rewritingmessages.text_contentuntil the assistant message is finalized.AFTER UPDATE ON messagestoAFTER UPDATE OF text_content ON messages, plus added a schema migration so existing databases pick up the same behavior.cmd/serve_runtime.goandinternal/tui/chat/streaming.goto:Why this is high-value
This path is hit repeatedly during real streaming turns in both the web runtime and TUI. Before this change, every snapshot update rewrote the entire FTS row because
UpdateMessagealways updatedtext_contentand themessages_autrigger reindexed on every update.The fix reduces work in the hot path from "reindex the growing assistant reply on every snapshot" to "update non-FTS message fields during snapshots, then index the final text once". That cuts SQLite write amplification, reduces lock contention, and improves responsiveness on long assistant replies and tool-heavy turns without changing final search behavior.
Validation
UpdateMessageupdatingtext_contenton every snapshot and the unconditionalmessages_auFTS trigger.TestSQLiteStoreUpdateStreamingMessageDefersFTSRewriteUntilFinalizedto cover the exact regression.gofmt -w cmd/serve_runtime.go internal/session/store.go internal/session/logger.go internal/session/sqlite.go internal/session/update_message_test.go internal/tui/chat/chat.go internal/tui/chat/streaming.gogo build ./...go test ./...git diff --check