fix(telegram): post stale/missed as new messages instead of editing bubble - #41
Conversation
…ubble Previously TelegramStaleCheckWork edited the existing bubble in-place for stale and missed transitions. This caused the last valid glucose reading to be overwritten with "⚠️ Stale" text. When combined with the suppress-delta logic (which suppresses flat-glucose readings from re-editing the bubble back to a glucose value), the bubble would get stuck showing "⚠️ Stale" indefinitely — appearing to the user as "no telegram message". Now stale and missed alerts are posted as new sendMessage calls. The original bubble retains the last reading, and each stale/missed event appears as a distinct, timestamped message in the chat timeline. This is also more robust: postSend cannot return "not modified" and does not require messageId manipulation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| Common/src/main/java/tk/glucodata/TelegramStaleCheckWork.kt | Minimal, well-scoped change: postEdit → postSend, URL rewriting removed, message_id body field dropped, messageId guard renamed to hasActiveBubble. Throttle, retry, and scheduling logic are preserved and correct. |
Sequence Diagram
sequenceDiagram
participant CGM as CGM Reading
participant OA as OutboundApi
participant TG as Telegram API
participant SW as TelegramStaleCheckWork
CGM->>OA: sendTelegram(reading)
OA->>TG: sendMessage or editMessageText (bubble)
TG-->>OA: ok + message_id
OA->>SW: schedule(destinationId, staleDelayMs)
Note over SW: stale threshold elapsed
SW->>SW: hasActiveBubble check
SW->>TG: sendMessage(Stale) - NEW message
TG-->>SW: 2xx
SW->>SW: recordStaleAt, reschedule for missed threshold
Note over SW: missed threshold elapsed
SW->>TG: sendMessage(Missed reading) - NEW message
TG-->>SW: 2xx
SW->>SW: recordStaleAt, no further reschedule
Note over OA: next CGM reading arrives
CGM->>OA: sendTelegram(reading)
OA->>TG: editMessageText(bubble) - bubble still intact
TG-->>OA: ok
Reviews (1): Last reviewed commit: "fix(telegram): post stale/missed as new ..." | Re-trigger Greptile
Root cause
TelegramStaleCheckWorkusededitMessageTextto overwrite the glucose bubble with "suppressDeltaBelowMgdl = 1) would suppress flat-glucose readings from re-editing it back to a glucose value — leaving the bubble stuck at "Fix
Replace
postEdit(editMessageText) withpostSend(sendMessage). Stale/missed alerts now appear as new messages rather than overwriting the glucose bubble. The original bubble retains the last valid reading at all times.Changes:
postEdit→postSend; dropeditMessageTextURL rewriting andmessage_idbody fieldmessageIdguard tohasActiveBubbleto reflect that the ID is used only as a sentinel, not passed to the APISTALE_THROTTLE_MS = 70s,TRANSIENT_RETRY_DELAY_MS = 60sand retry scheduling from the previous PRTest plan
🤖 Generated with Claude Code