Skip to content

feat: add configurable discord message_limit with code-fence-preserving chunks#140

Open
the3mi wants to merge 1 commit intoopenabdev:mainfrom
the3mi:feat/message-limit-config
Open

feat: add configurable discord message_limit with code-fence-preserving chunks#140
the3mi wants to merge 1 commit intoopenabdev:mainfrom
the3mi:feat/message-limit-config

Conversation

@the3mi
Copy link
Copy Markdown
Contributor

@the3mi the3mi commented Apr 8, 2026

Summary

Implements configurable message_limit per platform, with an extensible config structure. Currently only Discord is wired up. Telegram placeholder is present but not yet implemented.

Config

[platforms.discord]
message_limit = 2000  # default

[platforms.telegram]  # placeholder — not yet implemented
message_limit = 4096  # default

Reference limits for future platforms:

  • Discord = 2000
  • Telegram = 4096
  • Slack = 39000
  • Signal = 8000
  • Matrix = 4000
  • DingTalk = 20000
  • WeCom = 4000

Behavior

  • Streaming edits: message_limit - 100 buffer (Discord edit overhead)
  • Final chunking: full message_limit
  • Streaming uses split_message(..., false) — no (1/N) indicators to avoid live-edit noise
  • Final chunking uses split_message(..., true) — includes (1/N) indicators

Code changes

  • config.rs: PlatformSettings + PlatformsConfig replaces the old flat discord.message_limit field. default_limit_for_platform() centralizes per-platform defaults so PlatformSettings::default() and PlatformsConfig::default() stay consistent.
  • format.rs: split_message(text, limit, add_indicator) — third arg controls indicator injection. split_message_for_streaming() wraps it with add_indicator=false.
  • discord.rs: Both call sites updated to pass the third arg.

Bug fixes in this PR

  1. Streaming indicator bug: split_message_for_streaming() was calling split_message() directly with no indicator flag, so it still added (1/N) markers despite the name implying otherwise. Fixed by making the indicator behavior explicit.
  2. Hardcoded test buffer: test_very_long_line used 2000 + 20 instead of limit + indicator_len. Now uses dynamic values.
  3. Telegram default mismatch: PlatformSettings::default() returned 2000, but PlatformsConfig::default() hardcoded telegram at 4096. Now both use default_limit_for_platform().

Quality checks

  • cargo test: 6/6 passing
  • cargo clippy: warnings only (no errors)

@the3mi the3mi requested a review from thepagent as a code owner April 8, 2026 07:24
@the3mi the3mi force-pushed the feat/message-limit-config branch 2 times, most recently from eff3f0d to 8da5032 Compare April 8, 2026 07:42
- New [platforms] config section; each platform has its own message_limit
  Reference limits: Discord=2000, Telegram=4096, Slack=39000, Signal=8000
- Discord streaming uses limit-100 buffer; final chunking uses full limit
- split_message(text, limit, add_indicator): third param controls (N/N) indicators
- split_message_for_streaming(): calls split_message(..., false) — no indicators
- test_very_long_line: uses dynamic indicator_len instead of hardcoded +20
- PlatformSettings: default_message_limit() consistent with PlatformsConfig defaults
- Discord and Telegram both use their platform-specific defaults (2000 / 4096)
- Fix clippy: remove unnecessary trim() before split_whitespace()
- All 6 tests pass, clippy clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants