Skip to content

feat(mattermost): add block streaming edit-in-place support#25635

Closed
Luna2026-a11y wants to merge 2 commits intoopenclaw:mainfrom
Luna2026-a11y:feat/mattermost-block-streaming
Closed

feat(mattermost): add block streaming edit-in-place support#25635
Luna2026-a11y wants to merge 2 commits intoopenclaw:mainfrom
Luna2026-a11y:feat/mattermost-block-streaming

Conversation

@Luna2026-a11y
Copy link
Copy Markdown

@Luna2026-a11y Luna2026-a11y commented Feb 24, 2026

Summary

Enable progressive message rendering (block streaming) for Mattermost by editing a single message in-place as the model generates text, instead of sending multiple separate messages.

How it works

  1. First block → send a new message, track its post id
  2. Subsequent blocks → accumulate text and PATCH /api/v4/posts/{id}/patch the existing message
  3. Final reply → edit the message with the complete text
  4. Fallback → if edit fails, gracefully falls back to sending new messages

This is the same pattern used by the Telegram and Discord plugins.

User experience

Before: User asks question → 10s silence → wall of text appears

After: User asks question → text starts appearing after ~1-2s and writes progressively

Files changed

  • extensions/mattermost/src/channel.ts — declare blockStreaming: true in capabilities
  • extensions/mattermost/src/mattermost/monitor.ts — implement block streaming logic in deliver function
  • extensions/mattermost/src/mattermost/client.tspatchMattermostPost() (from feat(mattermost): add edit and delete message actions #25295)

Dependencies

Builds on #25295 (edit/delete message actions) which adds patchMattermostPost().

Testing

  • Tested patchMattermostPost against live Mattermost 10.x instance
  • Block streaming config already exists in schema (blockStreaming, blockStreamingCoalesce)
  • Graceful fallback to new messages if edit fails

Configuration

Block streaming is enabled by default. Users can disable it per-account:

channels:
  mattermost:
    blockStreaming: false  # disable edit-in-place
    blockStreamingCoalesce:
      minChars: 1500
      idleMs: 1000

Greptile Summary

This PR adds block streaming (progressive message rendering) to Mattermost by editing a single message in-place as text generates, matching the pattern used by Telegram and Discord plugins.

Key changes:

  • Enabled blockStreaming: true capability in channel configuration
  • Added edit/delete message actions to ChannelMessageActionAdapter
  • Implemented block streaming logic in deliver function with state tracking (blockStreamMessageId, blockStreamAccumulatedText)
  • Graceful fallback to new messages if edit operations fail

How it works:

  1. First block → sends new message, tracks post ID
  2. Subsequent blocks → accumulates text and patches existing message via PATCH /api/v4/posts/{id}/patch
  3. Final reply → edits message with complete text
  4. Error handling → falls back to sending new messages on edit failures

The implementation is clean and follows established patterns in the codebase. Block streaming defaults to enabled but can be disabled per-account via config.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - implements a well-tested pattern from other channels
  • The block streaming implementation follows the established pattern from Discord/Telegram, includes proper error handling with graceful fallbacks, and has clear state management. The only minor consideration is the accumulation reset on fallback, which is intentional design. Dependencies are properly added from PR feat(mattermost): add edit and delete message actions #25295.
  • No files require special attention

Last reviewed commit: 4a062d5

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Luna added 2 commits February 24, 2026 09:58
Add patchMattermostPost() and deleteMattermostPost() to the Mattermost
client, and wire them as 'edit' and 'delete' actions in the channel
plugin's message action adapter.

This enables:
- Editing bot messages via the message tool (action=edit)
- Deleting bot messages via the message tool (action=delete)
- Foundation for block-streaming edit-in-place (progressive message
  rendering like Telegram/Discord)

Uses PATCH /api/v4/posts/{post_id}/patch for edits and
DELETE /api/v4/posts/{post_id} for deletions.

Tested against a live Mattermost 10.x instance.
Enable progressive message rendering (block streaming) for Mattermost
by editing a single message in-place as the model generates text,
instead of sending multiple messages.

How it works:
- First block: send a new message, track its post id
- Subsequent blocks: accumulate text and PATCH the existing message
- Final reply: edit the message with the complete text
- Fallback: if edit fails, gracefully fall back to sending new messages

Changes:
- channel.ts: declare blockStreaming: true in capabilities
- monitor.ts: implement block streaming logic in the deliver function
  using patchMattermostPost for edit-in-place
- client.ts: patchMattermostPost (from previous commit)

This brings Mattermost closer to feature parity with Telegram and
Discord, which already support block streaming.
@openclaw-barnacle openclaw-barnacle bot added channel: mattermost Channel integration: mattermost size: M labels Feb 24, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

if ((isBlock || isFinal) && blockStreamingClient && mediaUrls.length === 0 && text) {
if (isBlock && blockStreamMessageId) {
// Subsequent block: accumulate and edit the existing message
blockStreamAccumulatedText += (blockStreamAccumulatedText ? "\n" : "") + text;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accumulated text with newline separator for multiple blocks

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/mattermost/monitor.ts
Line: 793

Comment:
accumulated text with newline separator for multiple blocks

How can I resolve this? If you propose a fix, please make it concise.

@teconomix
Copy link
Copy Markdown
Contributor

Use case: Mattermost as primary channel

We use Mattermost as our primary channel for multiple agents (including a coach, a knowledge-base agent, and a PA). The lack of progressive rendering makes the UX feel sluggish compared to Telegram — users just see a long pause followed by a wall of text.

Streaming edit-in-place would be a significant UX improvement for Mattermost deployments and bring it on par with Telegram/Discord.

Setup context:

Looking forward to this — happy to test once a branch is available.

@mukhtharcm
Copy link
Copy Markdown
Member

Closing this out in favor of #33506.

The in-place Mattermost streaming work is still not in main, but #33506 is the rebased continuation of this line of work against current upstream state, so I don't want to keep both open.

@mukhtharcm mukhtharcm closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants