Skip to content

Commit c19a864

Browse files
committed
Fix incorrect message buffering for images
Previously (for quite some time already), an image would not allow any subsequent input to be displayed. Probably, support for multiple images was broken since about two years. The current change should cover all known cases without breaking anything else.
1 parent 1674c48 commit c19a864

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/runner/connection/buffer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ def buffering_required_for?(message)
102102

103103
invalid_json = !valid_json?(message)
104104
# Second, if we have the beginning of a valid command but an invalid JSON
105-
return true if invalid_json && message.start_with?(/\s*{"cmd/)
106-
# Third, buffer the message if it contains long messages (e.g., an image or turtle batch commands)
107-
return true if invalid_json && (message.start_with?('<img') || message.include?('"turtlebatch"'))
105+
return true if invalid_json && (message.start_with?(/\s*{"cmd/) || message.include?('"turtlebatch"'))
106+
# Third, buffer the message if it contains an incomplete image message tag not followed by `\r`
107+
return true if invalid_json && message.start_with?('<img') && !message.end_with?(">\r")
108108
# Fourth, if we have an odd number of quotes and no `\r` at the end, we might have an incomplete message
109109
return true if (message.count('"').odd? || message.count("'").odd?) && !message.end_with?("\r")
110110

0 commit comments

Comments
 (0)