Skip to content

Discord: implement stream preview mode#22111

Merged
thewilloftheshadow merged 4 commits intomainfrom
shadow/discord-streaming
Feb 20, 2026
Merged

Discord: implement stream preview mode#22111
thewilloftheshadow merged 4 commits intomainfrom
shadow/discord-streaming

Conversation

@thewilloftheshadow
Copy link
Member

@thewilloftheshadow thewilloftheshadow commented Feb 20, 2026

Greptile Summary

Implements live stream preview mode for Discord replies with partial and block streaming options, mirroring the existing Telegram implementation.

  • Added streamMode config (off | partial | block) with draft chunking support
  • Implemented edit-based preview streaming via createDiscordDraftStream
  • Automatically suppresses block streaming when preview streaming is enabled to avoid double-streaming
  • Handles message finalization via preview edit when content fits in one chunk
  • Includes comprehensive test coverage for partial mode, block mode chunking, and assistant message boundaries
  • Documentation updated with configuration examples and behavior notes

Confidence Score: 4/5

  • Safe to merge with one minor logic inefficiency that doesn't affect correctness
  • Implementation follows established patterns from Telegram, has comprehensive tests, proper config schema, and documentation. One redundant stop() call found but doesn't impact functionality.
  • src/discord/monitor/message-handler.process.ts contains redundant stop() calls that could be refactored

Last reviewed commit: 7e366a5

@thewilloftheshadow thewilloftheshadow merged commit 09e6970 into main Feb 20, 2026
9 checks passed
@thewilloftheshadow thewilloftheshadow deleted the shadow/discord-streaming branch February 20, 2026 18:37
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation channel: discord Channel integration: discord size: L maintainer Maintainer-authored PR labels Feb 20, 2026
Copy link
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.

10 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +774 to +795
if (canFinalizeViaPreviewEdit) {
await draftStream.stop();
try {
await editMessageDiscord(
deliverChannelId,
previewMessageId,
{ content: previewFinalText },
{ rest: client.rest },
);
finalizedViaPreviewMessage = true;
replyReference.markSent();
return;
} catch (err) {
logVerbose(
`discord: preview final edit failed; falling back to standard send (${String(err)})`,
);
}
}

// Check if stop() flushed a message we can edit
if (!finalizedViaPreviewMessage) {
await draftStream.stop();
Copy link
Contributor

Choose a reason for hiding this comment

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

stop() called twice in sequence

The first attempt calls await draftStream.stop() on line 775. If that attempt fails to edit, the code calls await draftStream.stop() again on line 795. Since stop() sets isFinal = true and flushes, the second call would be a no-op (stopped is already true from first stop). Consider restructuring to only call stop() once before attempting edits.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/discord/monitor/message-handler.process.ts
Line: 774-795

Comment:
`stop()` called twice in sequence

The first attempt calls `await draftStream.stop()` on line 775. If that attempt fails to edit, the code calls `await draftStream.stop()` again on line 795. Since `stop()` sets `isFinal = true` and flushes, the second call would be a no-op (stopped is already true from first stop). Consider restructuring to only call `stop()` once before attempting edits.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

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

rodrigogs pushed a commit to rodrigogs/openclaw that referenced this pull request Feb 20, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
Hansen1018 added a commit to Hansen1018/openclaw that referenced this pull request Feb 21, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
vincentkoc pushed a commit that referenced this pull request Feb 21, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
dgarson pushed a commit to dgarson/clawdbot that referenced this pull request Feb 21, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
mmyyfirstb pushed a commit to mmyyfirstb/openclaw that referenced this pull request Feb 21, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
obviyus pushed a commit to guirguispierre/openclaw that referenced this pull request Feb 22, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
* Discord: implement stream preview mode

* Changelog: note Discord stream preview mode

* Tests: type discord draft stream mocks

* Docs: document Discord stream preview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant