← Back to PRs

#20818: feat(telegram): add draftMinInitialChars and initialDraftText config options

by lingzhua77 open 2026-02-19 10:03 View on GitHub →
channel: telegram size: S
## Summary Add two new Telegram channel configuration options to improve user experience by showing immediate feedback when a message is being processed: - `draftMinInitialChars`: Minimum chars before sending initial draft message (default: 30). Set to 0 to send immediately on message receipt. - `initialDraftText`: Initial draft text to show immediately when processing starts (e.g., "收到了 我想一想🤔……") This allows bots to acknowledge message receipt before the AI starts generating a response, improving perceived responsiveness. ## Changes - `src/config/types.telegram.ts`: Add type definitions - `src/config/zod-schema.providers-core.ts`: Add Zod validation schema - `src/telegram/bot-message-dispatch.ts`: Read config and pass to draft stream - `src/telegram/draft-stream.ts`: Support immediate initial text send ## Usage ```json { "channels": { "telegram": { "draftMinInitialChars": 0, "initialDraftText": "收到了 我想一想🤔……" } } } ``" ## Testing - [x] Verified config validation works - [x] Verified hot reload applies config changes - [x] Tested in group chat - initial text appears immediately before AI response <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds two new Telegram configuration options (`draftMinInitialChars` and `initialDraftText`) to allow immediate acknowledgment when messages are received, improving perceived bot responsiveness. - Type definitions and Zod schemas correctly added with appropriate validation (`.int().min(0)` for the numeric field) - Configuration is properly threaded through `bot-message-dispatch.ts` to `draft-stream.ts` - Default value of 30 chars maintained for backward compatibility **Issue found:** - Race condition in `draft-stream.ts` where the initial text send is fire-and-forget, potentially causing the first streaming update to be dropped if it arrives before the initial send completes <h3>Confidence Score: 3/5</h3> - Safe to merge with caution - race condition could cause intermittent initial message drops - Configuration schema and type definitions are solid, and the feature implementation is straightforward. However, the fire-and-forget async pattern for sending initial text creates a timing issue that could cause the first streaming update to be incorrectly debounced. This is a functional bug but not critical - worst case is the initial acknowledgment message gets replaced by the first stream update instead of being edited. - Pay close attention to `src/telegram/draft-stream.ts` - the race condition in initial text sending needs to be addressed <sub>Last reviewed commit: f1ab431</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs