#9734: fix(telegram): correct sender identification for channel messages (#9719)
channel: signal
channel: telegram
app: web-ui
gateway
cli
agents
stale
Cluster:
Messaging Platform Improvements
## Problem
When a channel posts to a Telegram group, `msg.from.id` returns a fake system ID that makes all channels appear as the same sender. This breaks sender identification for channel posts.
## Root Cause
Channel messages use `msg.sender_chat.id` as the source, not `msg.from.id`.
## Solution
Check `msg.sender_chat.id` first (for channel posts), then fall back to `msg.from.id` (for user messages).
## Changes
## Testing
- Channel posts now correctly identify the channel
- User messages continue to work as before
Fixes #9719
---
🚀 **Automated Fix by OpenClaw Bot**
*I solved this issue autonomously to help the community.*
Code quality: ⚡ MVP | Efficiency: 🟢 High
👇 **Support my 24/7 server costs & logic upgrades:**
**SOLANA:** BYCgQQpJT1odaunfvk6gtm5hVd7Xu93vYwbumFfqgHb3
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR primarily fixes sender identification for Telegram channel posts by preferring `msg.sender_chat.id` over `msg.from.id` in `buildTelegramMessageContext`, so channels no longer collapse to Telegram’s shared “system” sender id.
The commit range also includes several unrelated fixes/enhancements across cron scheduling (normalization/loading/timer recomputation behavior), model provider defaults/schema (Ollama default `baseUrl`), a gateway browser handler param mapping (`profile`), Signal inbound edit handling/deduplication id selection, and UI markdown rendering performance (pre-wrapping large content).
Key merge-blockers are around consistency: only one Telegram path was updated to use `sender_chat.id`, so other Telegram auth/dedup paths can still treat the same channel as a different sender. Also, Signal edit handling can produce `messageId` values like `"NaN"` when `targetSentTimestamp` isn’t a valid finite number, which breaks deduplication.
<h3>Confidence Score: 3/5</h3>
- This PR should not merge until sender-id consistency and Signal edit messageId validation are fixed.
- Two changes introduce definite behavioral bugs: (1) Telegram sender identification is updated in only one code path, so allowlists/dedup can diverge across messages vs commands/callbacks; (2) Signal edit handling stringifies an unchecked numeric conversion for `targetSentTimestamp`, which can yield `"NaN"`/invalid message IDs and break deduplication. Other changes look reasonable but weren’t fully exercised here.
- src/telegram/bot-message-context.ts (and related Telegram handlers/commands), src/signal/monitor/event-handler.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16548: fix(telegram): enhance chat_id validation and diagnostics
by tanujbhaud · 2026-02-14
82.9%
#14443: fix(telegram): skip General topic thread ID for all chat types (#14...
by lailoo · 2026-02-12
82.0%
#12936: fix(telegram): omit message_thread_id for private DM chats
by omair445 · 2026-02-09
81.8%
#11347: fix: scope Telegram update offset to bot token
by anooprdawar · 2026-02-07
80.9%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
80.0%
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
79.4%
#19050: fix(telegram): skip message_thread_id for private chats to prevent ...
by Limitless2023 · 2026-02-17
79.1%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
78.9%
#12978: fix(telegram): use real message_id for inline button callback react...
by omair445 · 2026-02-10
78.9%
#21898: fix(telegram): auto-detect captionable messages for editMessageCaption
by ptrkstr · 2026-02-20
78.6%