feat(twitch): truncate messages to 500-char limit instead of splitting#118
Open
PyRo1121 wants to merge 1 commit intospacedriveapp:mainfrom
Open
feat(twitch): truncate messages to 500-char limit instead of splitting#118PyRo1121 wants to merge 1 commit intospacedriveapp:mainfrom
PyRo1121 wants to merge 1 commit intospacedriveapp:mainfrom
Conversation
…plitting into chunks Replace split_message() with truncate_message() to send a single truncated message rather than flooding chat with multiple chunks when responses exceed Twitch's 500-character limit. Truncation cuts at the last word boundary and appends '…' to indicate content was trimmed. Applies to all 8 outbound code paths: Text, RichMessage, ThreadReply, File, Ephemeral, ScheduledMessage, and both broadcast variants.
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.
Summary
split_message()withtruncate_message()so Twitch responses are a single message capped at 500 characters, instead of flooding chat with multiple chunked messages…to indicate content was trimmedProblem
Long LLM responses were split into multiple sequential Twitch chat messages (each up to 500 chars). This created chat spam — a single response could produce 3-5+ rapid-fire messages, disrupting the channel and making the bot obnoxious.
Solution
Single-message truncation with a clean word-boundary cut:
floor_char_boundary()for safe UTF-8 handling (no panics on multi-byte characters)Scope
All 8 outbound code paths now use truncation:
TextRichMessageThreadReplyFileEphemeralScheduledMessagebroadcast(Text)broadcast(RichMessage)Testing
MAX_MESSAGE_LENGTHconstant (500) is unchanged and used consistently across all paths