Skip to content

BlueBubbles: Leading newlines not trimmed from message text #12770

@ThatGuySizemore

Description

@ThatGuySizemore

Problem

Some messages sent via the BlueBubbles extension have leading newlines/blank lines at the top of the iMessage bubble. This only affects iMessage (not Telegram) and only certain messages.

Root Cause

Two sources of leading \n characters:

  1. Model output: LLM responses after tool calls sometimes start with newlines that aren't trimmed
  2. Block reply coalescer: When joining text chunks with \n\n, leading whitespace is prepended to text following tool call blocks

Affected Code

  1. extensionAPI.js (block coalescer) - const nextText = bufferText ? ... doesn't trim text after joiner
  2. extensions/bluebubbles/src/send.ts - const trimmedText = text " doesn't call .trimStart()
  3. extensions/bluebubbles/channel.ts - outbound sendText doesn't trim before calling sendMessageBlueBubbles

Proposed Fix

Add .trimStart() in three locations:

1. Block coalescer

const nextText = bufferText 
  ? `${bufferText}${joiner}${joiner ? text.trimStart() : text}` 
  : text.trimStart();

2. Send layer

const trimmedText = (text ?? "").trimStart();

3. Channel layer

const trimmedText = text.trimStart();
await sendMessageBlueBubbles(serverUrl, password, chatGuid, trimmedText);

Reproduction

  1. Send a message via BlueBubbles that follows a tool call response
  2. Observe leading blank line in the iMessage bubble
  3. Pure text responses (no preceding tool calls) render correctly

Workaround

Manual patching of the compiled dist files, but patches are overwritten on each update.

Environment

  • OpenClaw installed via npm (homebrew)
  • BlueBubbles server on local network
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions