fix(genui): swallow the closing stream_done event instead of materializing it - #34
Merged
Merged
Conversation
…izing it A connector's terminating `stream_done` event (mekik PROTOCOL.md 4.1) is stream lifecycle, not content. ChatEngine treated it like any other chunk, so a text-only stream got a phantom empty genui bubble opened for an event that has nowhere to live, and a genui stream got the closing event appended to its chunk list. _handleGenUIChunk now finishes the stream and returns early. Also makes AIChunkEvent.payload optional, matching schemas/genui/ai-chunk.schema.json, which already lists only type/name/id as required. Signal-only events such as stream_done carry no payload. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
A connector''s terminating
stream_doneevent (mekikPROTOCOL.md4.1) is stream lifecycle, not content, butChatEngine._handleGenUIChunktreated it like any other chunk:chunkslistFix
_handleGenUIChunknow finishes the stream and returns early when it seestype: event/name: stream_done.genui_stream_completedstill fires andstreamingCompleteis still set.Also makes
AIChunkEvent.payloadoptional.schemas/genui/ai-chunk.schema.jsonalready lists onlytype/name/idas required, so the TS type was stricter than the contract — signal-only events likestream_donecarry no payload. Bothstreaming.mddoc trees updated to match.Verification
pnpm --filter @chativa/core exec tsc --noEmitcleanpnpm --filter @chativa/core test— 296 passed (2 new regression tests, one per stream shape)🤖 Generated with Claude Code