Repository navigation
fix: Telegram inline-button taps are timestamped with the card's send date instead of the tap time - #170957
fix: Telegram inline-button taps are timestamped with the card's send date instead of the tap time#170957Irish-Joseph wants to merge 2 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR timestamps generic callback-generated messages from recorded update receipt time instead of the attached card’s send time. Example: A card sent at 15:09 is tapped at 15:31, and the queued callback is dispatched at 15:40.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 3 items remain This PR addresses a current-main Telegram timestamp bug and merits continued review, but both previously reported defects remain. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherTelegram polling and webhooks persist updates with receipt timestamps; the ingress drain delivers them to the callback router, whose synthetic messages supply agent-context timestamps. flowchart LR
A[Telegram callback update] --> B[Durable ingress queue]
B --> C[Ingress drain]
C --> D[Callback router]
D --> E[Synthetic inbound message]
E --> F[Agent context]
Technical reviewBest possible solution: Carry receipt time in an update-keyed WeakMap and use it consistently for callback-generated agent messages. Do we have a high-confidence way to reproduce the issue? Current-main source establishes card-date inheritance into agent timestamps, and the canonical report identifies an affected official release; no target code was executed. Is this the best way to solve the issue? Reusing the existing durable receipt timestamp handles delayed dispatch correctly, but enumerable metadata changes raw updates and sibling interactive submissions still inherit the card date. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7840eae2df25. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +37, Tests +139. Total +176 across 4 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 13, 2026, 3:56 PM ET / 19:56 UTC (Revision 5). |
…rd date A callback_query carries no timestamp of its own; the model-callback path synthesized its inbound message from the card that carries the button and passed no date, so the tap was recorded with the card's send time. A tap made long after the card was sent then appeared to predate the card it answers, breaking freshness and ordering reasoning over taps. Pass the tap time into the synthetic message, the same way the poll path already does; buildSyntheticTextMessage already honors a supplied date, so no other callback behavior changes. Proof: new callback-router test drives the model-command path through the live router with a card dated ~20 minutes before the (faked) tap and asserts the inbound message carries the tap time. Without the fix the same test fails with the card date (1786404800 vs 1786406000). model-callback loopback, ingress-callback, and callback-question suites pass. oxfmt --check and oxlint are clean on the touched files. Fixes openclaw#169881.
…penclaw#169881) Date.now() at dispatch time mis-stamps callbacks that were durably queued before processing: a tap received at 15:31 but drained after a blocked handler or restart at 15:40 was recorded as 15:40, keeping false event times in freshness and ordering consumers. The ingress spool already persists receivedAt per claim; deserialize now stamps the in-memory update with it (in-memory marker, never persisted), and the model-callback path prefers that receipt time over the processing time, falling back to Date.now() for live (unspooled) callbacks. Proof: new regression stamps the update with an admission time 30 minutes before the (faked) processing time and asserts the inbound message keeps the receipt time; reverting only the router change fails it with the processing time. The card-date regression, spool ordering suite, and ingress-callback integration suite pass. oxfmt and oxlint clean.
c6e31d3 to
572b9be
Compare
…d time instead of the tap (#170210) fix(telegram): stamp callback turns with the button-press time A Telegram inline-button click produced a turn timestamped with the original card message's time, not the time the user pressed the button. Callback updates now carry their receipt time, keyed by update, so generic, single-select and multiselect callbacks report when the press happened. Raw updates and ordinary message timestamps are unchanged. Proof: Telegram Test Server with a real TDLib user clicking generic, single-select and multiselect buttons on a built Gateway. On main, generic and multiselect callbacks kept the card's old time; with this change the provider timestamp matches the click receipt time. Thanks @maliv2, and @Irish-Joseph for the parallel fix in #170957. Co-authored-by: Muhammet Ali Aydın <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @Irish-Joseph. This fixes the same callback timestamp bug as #170210, which landed in d2261ea with a smaller update-keyed change, so I'm closing this as a duplicate. Your PR is credited in the merge commit. |
…d time instead of the tap (openclaw#170210) fix(telegram): stamp callback turns with the button-press time A Telegram inline-button click produced a turn timestamped with the original card message's time, not the time the user pressed the button. Callback updates now carry their receipt time, keyed by update, so generic, single-select and multiselect callbacks report when the press happened. Raw updates and ordinary message timestamps are unchanged. Proof: Telegram Test Server with a real TDLib user clicking generic, single-select and multiselect buttons on a built Gateway. On main, generic and multiselect callbacks kept the card's old time; with this change the provider timestamp matches the click receipt time. Thanks @maliv2, and @Irish-Joseph for the parallel fix in openclaw#170957. Co-authored-by: Muhammet Ali Aydın <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #169881
What Problem This Solves
Fixes: inline-button taps (
callback_query) being recorded with the timestamp of the message that carries the button, so a tap made long after a confirmation card was sent appears to predate the card it answers.User Impact
Any consumer that reasons about a tap by timestamp — freshness checks ("is this tap newer than the message it answers?"), dedupe/supersede logic, audit ordering — now sees the actual tap time. In the reported flow, a Send tap on a 22-minute-old card no longer looked older than that card.
Why This Change Was Made
A Telegram
callback_querycarries no timestamp of its own. The model-callback path synthesized the inbound message from the card and passed nodate, so the canonical inbound builder derivedProviderMessageTimestampfrom the card'sdate. The fix passes the tap time (Math.floor(Date.now() / 1000)) intobuildSyntheticTextMessage, which already honors a supplieddate— the same pattern the poll-response path already uses. All other callback behavior is untouched (the interactive/plugin callback path is intentionally out of scope; see #133267 for plugin-handler date exposure).Evidence
bot-handlers.callback-router.tap-timestamp.test.tsdrives the live callback router through the model-command path with a card dated ~20 minutes before the (fake-timer) tap and asserts the inbound message carries the tap time, not the card date.expected 1786404800 to be 1786406000(card date vs tap time); with the fix it passes.model-callback.loopback.integration.test.ts,telegram-ingress-callback.integration.test.ts, andbot-handlers.callback-questions.runtime.test.tsall pass.oxfmt --checkandoxlintclean on the touched files.Review response (2026-10-15)
Addressed the receipt-time defect in commit
c6e31d3ca38:receivedAtper claim (telegram-ingress-drain.tsserialize);deserializenow stamps the in-memory update with it (withTelegramUpdateReceivedAt, an in-memory marker that is never persisted), and the model-callback path reads that receipt time first, falling back toDate.now()for live (unspooled) callbacks. A tap admitted at 15:31 and drained at 15:40 after a blocked handler or restart is now recorded as 15:31.bot-handlers.callback-router.tap-timestamp.test.ts, second case): the update is stamped with an admission time 30 minutes before the faked processing time; the inbound message keeps the receipt time and not the processing time. Red/green: reverting only the router change fails it with the processing time.Real-behavior proof (2026-10-15, rebased on current main)
A real grammY bot talking to a real HTTP Bot API loopback (same harness style as
model-callback.loopback.integration.test.ts) driving the production callback router. The card is sent through the production send path;answerCallbackQueryandeditMessageReplyMarkup(routed-button clear) went over real HTTP. The only instrumented point is theprocessMessageWithReplyChainboundary, which records the actual inbound message the real router builds:Branch rebased on main (no conflicts; tap-timestamp, spool, ingress-callback, and model-callback loopback suites re-run green on the new base). The Telegram servers themselves are not involved; this is a loopback Bot API.