Repository navigation
fix(telegram): message_sent plugin hooks lose the session key - #197670
rodricksz4h5 wants to merge 1 commit 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: stale review; fresh review needed. Summary Next step Review history (2 earlier review cycles)
|
|
Added real-behavior proof to the PR body: a source Gateway with only Telegram's Bot API stood in. A DM @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
emitTelegramMessageSentHooks received sessionKeyForInternalHooks from every caller and used it for the internal message:sent hook, but left it out of the canonical context that feeds the plugin message_sent hook, so plugins saw ctx.sessionKey undefined for every Telegram send. Pass the canonical runtime session key through, with no policy-key fallback, as core and Slack already do (see openclaw#73706).
dcd3ad5 to
3e9964d
Compare
Telegram's message_sent plugin hook context dropped the session key it already forwards to the internal message:sent hook. Pass the same canonical runtime key so message_sending and message_sent correlate on one value. Folds in openclaw#197670 and covers both hooks with one delivery regression; the test-line allocation is no longer needed under the 400-line budget. Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]>
…197519) * fix(telegram): pass the runtime session key to message_sending hooks * chore(config): allocate test-line growth for the telegram hook session-key regressions * fix(telegram): pass the runtime session key to message_sent hooks Telegram's message_sent plugin hook context dropped the session key it already forwards to the internal message:sent hook. Pass the same canonical runtime key so message_sending and message_sent correlate on one value. Folds in #197670 and covers both hooks with one delivery regression; the test-line allocation is no longer needed under the 400-line budget. Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: lester076 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]>
|
Thanks for this fix. Your Live proof on Telegram Test Server (real user DM, built Gateway, hook-recording plugin): on Closing as superseded by #197519. |
…penclaw#197519) * fix(telegram): pass the runtime session key to message_sending hooks * chore(config): allocate test-line growth for the telegram hook session-key regressions * fix(telegram): pass the runtime session key to message_sent hooks Telegram's message_sent plugin hook context dropped the session key it already forwards to the internal message:sent hook. Pass the same canonical runtime key so message_sending and message_sent correlate on one value. Folds in openclaw#197670 and covers both hooks with one delivery regression; the test-line allocation is no longer needed under the 400-line budget. Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: lester076 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]>
…197519) * fix(telegram): pass the runtime session key to message_sending hooks * chore(config): allocate test-line growth for the telegram hook session-key regressions * fix(telegram): pass the runtime session key to message_sent hooks Telegram's message_sent plugin hook context dropped the session key it already forwards to the internal message:sent hook. Pass the same canonical runtime key so message_sending and message_sent correlate on one value. Folds in #197670 and covers both hooks with one delivery regression; the test-line allocation is no longer needed under the 400-line budget. Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: lester076 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: rodricksz4h5 <[email protected]> Co-authored-by: obviyus <[email protected]> (cherry picked from commit ec46689) Release adaptation: none. The runtime key, canonical hook context mapper and loopback Bot API fixture are present on this baseline. Both sending and sent hooks use runtime identity, never the acted-on policy key. Companion audit: #197670 is folded into this selected squash, not a separate dependency. No later same-path or PR-number follow-ups through 7bccde6. SDK hook exports and fixture producers are present-equivalent. Proof: git diff --check passed. Focused Vitest/typecheck/lint unavailable: this isolated worktree has no node_modules; no dependencies were installed. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 1c5e22bb5e97a9a00b1fd291e98be14b02b38d02)
Port Telegram callbacks, hook session keys, private-topic approvals and interactive widgets with complete send/edit/route security companions. Include Feishu captioned media, iOS permission Sendable callbacks, WebKit animation/menu retirement and pending automations props handling. Keep Matrix malformed formatted-mention parsing linear-time. Adapt the 11.4 equivalents to the fixed beta baseline where available. Source PRs: #196217, #191585, #196822, #194027, #197519, #198038, #196991, #198380, #198658, #184432. Companion scope: #191647, #192162, #198022, #197271, #194146; #197670 is folded into #197519 equivalent. (cherry picked from commit 928c118) (cherry picked from commit 569ca48) (cherry picked from commit efa744e) (cherry picked from commit c301da9) (cherry picked from commit 641c4d5) (cherry picked from commit b9d3fb4) (cherry picked from commit a213a51) (cherry picked from commit ec46689) (cherry picked from commit 779d22e) (cherry picked from commit 129ccc3) (cherry picked from commit 849c050) (cherry picked from commit b22f35f) (cherry picked from commit 8b414e9) (cherry picked from commit 01ecda4) (cherry picked from commit f978e54) (cherry picked from commit 6e60479) (cherry picked from commit ec7b49a) (cherry picked from commit 1d72ad0) (cherry picked from commit 5e2c66f) (cherry picked from commit dfb6454) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f7c581c7f8bf0e57c7d8799e928a121b24462450) Co-authored-by: vincentkoc <[email protected]>
Closes #197669
Related: #197186
What Problem This Solves
Fixes: plugin
message_senthooks get nosessionKeyfor Telegram sends, so plugins that match a send to its session (alongsideagent_end,llm_outputormessage_sending) cannot correlate Telegram replies.User Impact
User impact: plugins observing
message_sentnow receive the session key for Telegram replies, finalized previews and native plugin command sends, the same as on the core outbound path and Slack. Sends without a session are unchanged.Why This Change Was Made
emitTelegramMessageSentHooksalready receives the session key from every caller and uses it for the internalmessage:senthook, but left it out of the canonical context that feeds the plugin hook. It now passessessionKeyForInternalHooksthrough: the canonical runtime session key, with no policy-key fallback, as established for shared outbound hooks in #73706. It's the same key core and Slack pass tomessage_sent, and the one #197519 forwards tomessage_sending, so both hooks correlate on one value.Evidence
Real Gateway proof (isolated mock-Gateway harness, two runs each). I ran the source Gateway the same way the Telegram e2e runner's
--source-gatewaymode does:node --import ./scripts/tsx.mjs src/entry.ts gateway,plugins.load.paths→extensions/telegram,OPENCLAW_BUNDLED_PLUGINS_DIRset, isolated state, fake bot token. The only stand-in was Telegram's Bot API, a local HTTP server reached throughchannels.telegram.apiRoot. A real plugin loaded from disk registers/plugand amessage_senthook that records what it receives. A DM/plugupdate arrives through the real polling ingress, is dispatched as a native command, and is answered withsendMessage:message_sentctx.sessionKey/event.sessionKeysendMessagechat4242"Choose a deployment", successsendMessagechat4242"Choose a deployment", successagent:main:main/agent:main:mainThe same
/plugcommand was registered throughsetMyCommandsin every run. Removing the one fix line is the only difference between the rows.Redacted after-fix trace (this PR)
On main, the same trace ends with no
sessionKeyin eitherctxorevent. Chat and user ids are synthetic; the token and local ports are omitted.Live gap: the repo's Telegram Test Server userbot proof uses Convex-leased team credentials, which I don't have access to as an outside contributor. Happy for a maintainer to run it if needed.
Regression: the existing native-command delivery test ("settles a progress edit once") now also asserts the plugin hook context's session key. On main it fails (
expected [ undefined ] to deeply equal [ 'agent:main:main' ]); with this change the file passes 19/19. Net 0 test lines.Related Telegram suites pass (96 tests across 7 files): delivery (paragraphs, media resolution), finalized-preview lifecycle, dispatch transcript, native-command concurrency and send recovery.
check:changedratchets pass (line-cap, max-lines, assertion-safety, test-timeout-race, test-mock-exports), plus format and oxlint. Locally on Windows the oxlint wrapper falls back to non-type-aware linting, so type-aware lint is left to CI.Typecheck: the Telegram package and the changed test file (under the extension-test config) report 0 errors.
Local review: autoreview isn't set up here. Reviewed manually instead: traced all four
emitTelegramMessageSentHookscallers, confirmed the internalmessage:senthook is unchanged, and checked the field againstPluginHookMessageContext.sessionKey.