Skip to content

SLOP-144: Guard history merge against messages missing from local state - #16

Open
tosfos wants to merge 1 commit into
masterfrom
SLOP-144-fix-followup-crash-tool-messages
Open

tosfos wants to merge 1 commit into
masterfrom
SLOP-144-fix-followup-crash-tool-messages

Conversation

@tosfos

@tosfos tosfos commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes SLOP-144

Summary

  • chatCompletedHandler() in src/lib/components/chat/Chat.svelte dereferenced _existing.content without a null check when merging server-echoed messages back into history.messages.
  • The fork's tool-call replay sends role: \"tool\" messages (built by expandContentBlocks()) that carry no content field; if such a message is not present in local history, the merge throws TypeError: Cannot read properties of undefined (reading 'content'), aborting the follow-up turn before updateChatById() persists the chat (losing the just-completed exchange).
  • Adds optional chaining on both reads of _existing, matching the _existing?.content_blocks guard already on the next line.

Test plan

  • Static verification (py_compile for backend counterpart; minimal 2-line frontend diff re-read)
  • Follow-up turn after an assistant message containing tool calls (no content_blocks) completes without console errors
  • Regression test covering merge of server-echoed messages that lack a content field

Work performed by AI / Cursor Agent under direction of Ike.

chatCompletedHandler() dereferenced _existing.content without a null
check; server-echoed tool-role messages (sent by expandContentBlocks()
without a content field) could be absent from history.messages,
throwing TypeError and aborting the follow-up turn before the chat was
persisted. Aligns with the optional chaining already used for
_existing?.content_blocks on the next line.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

🐳 The image has been built and pushed with the following tags: ghcr.io/wikiteq/maition-web-ui:pr-16, ghcr.io/wikiteq/maition-web-ui:fc0a35b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant