← Back to PRs

#19829: fix(telegram): fall back to default scope for array capabilities without inlinebuttons

by NewdlDewdl open 2026-02-18 06:50 View on GitHub →
channel: telegram size: S
## Problem Fixes #19797 When `channels.telegram.capabilities` is configured as a **legacy array** that does **not** include `"inlinebuttons"`, the `resolveInlineButtonsScopeFromCapabilities` function returned `"off"` — silently disabling all `callback_query` handling. Users would see styled inline buttons in Telegram (buttons were sent correctly) but pressing them had no effect because the callback handler returned early after calling `answerCallbackQuery`. **Affected configurations:** - `capabilities: []` — empty array - `capabilities: ["someOtherFeature"]` — array without `inlinebuttons` The `undefined`-capabilities path already returned the correct default (`"allowlist"`), making this an inconsistency between the two paths. ## Fix Return `DEFAULT_INLINE_BUTTONS_SCOPE` (`"allowlist"`) instead of `"off"` when the capabilities array does not contain `"inlinebuttons"`. **Backward-compatible:** - `capabilities: ["inlineButtons"]` → still maps to `"all"` ✓ - `capabilities: { inlineButtons: "off" }` → still explicit opt-out preserved ✓ - `capabilities: undefined` → still `"allowlist"` ✓ ## Files changed - `src/telegram/inline-buttons.ts`: one-line fix replacing `"off"` with `DEFAULT_INLINE_BUTTONS_SCOPE` - `src/telegram/inline-buttons.test.ts`: added `resolveTelegramInlineButtonsScope` and `isTelegramInlineButtonsEnabled` suites (10 new tests) ## Test evidence ``` ✓ src/telegram/inline-buttons.test.ts (15 tests) 4ms ✓ src/telegram/bot.test.ts (31 tests) 67ms Test Files 2 passed (2) Tests 46 passed (46) ``` Full Telegram suite: ``` Test Files 39 passed (39) Tests 486 passed (486) ``` pnpm build ✅ pnpm check ✅ > [!NOTE] > This fix was authored with AI assistance (OpenClaw autonomous contributor). <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes a regression where legacy array-format `capabilities` without `"inlinebuttons"` (e.g., `[]` or `["otherFeature"]`) resolved to scope `"off"`, silently disabling all Telegram inline button callback handling. Buttons were still rendered but pressing them had no effect. The fix returns `DEFAULT_INLINE_BUTTONS_SCOPE` (`"allowlist"`) instead, matching the existing behavior for `undefined` capabilities. - One-line fix in `resolveInlineButtonsScopeFromCapabilities` replaces `"off"` with `DEFAULT_INLINE_BUTTONS_SCOPE` for the legacy array fallback path - 10 new tests added covering `resolveTelegramInlineButtonsScope` and `isTelegramInlineButtonsEnabled` across all capability formats, including explicit regression cases - Backward-compatible: explicit opt-out via `{ inlineButtons: "off" }` still works; `["inlineButtons"]` still maps to `"all"` <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it's a minimal, well-tested one-line bug fix with no behavioral changes to existing valid configurations. - The change is a single-line fix in a pure function that aligns the legacy array fallback with the existing default behavior. All existing capability formats (explicit opt-out via object, explicit opt-in via array, undefined) retain their behavior. 10 new tests validate the fix and cover regression scenarios. The change is backward-compatible and has clear justification. - No files require special attention. <sub>Last reviewed commit: 7e3cae2</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs