Skip to content

Commit 96661e8

Browse files
committed
fix(telegram): preserve inline buttons when capabilities array is empty
Empty array capabilities should not disable inline buttons. The default inline buttons scope ('allowlist') should still apply when the user has set an empty capabilities array, rather than treating it as an explicit 'off' signal. Fixes #96098
1 parent 2af0604 commit 96661e8

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

extensions/telegram/src/inline-buttons.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ describe("resolveTelegramInlineButtonsScope (#75433 SecretRef tolerance)", () =>
109109
expect(isTelegramInlineButtonsEnabled({ cfg })).toBe(true);
110110
});
111111

112+
it("falls back to default when array capabilities is empty", () => {
113+
const cfg = {
114+
channels: {
115+
telegram: {
116+
botToken: { source: "exec", provider: "default", id: "telegram-token" },
117+
capabilities: [],
118+
},
119+
},
120+
} as unknown as OpenClawConfig;
121+
122+
expect(resolveTelegramInlineButtonsScope({ cfg })).toBe("allowlist");
123+
expect(isTelegramInlineButtonsEnabled({ cfg })).toBe(true);
124+
});
125+
112126
it('preserves configured "off" when botToken is an unresolved SecretRef', () => {
113127
const cfg = {
114128
channels: {

extensions/telegram/src/inline-buttons.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ export function resolveTelegramInlineButtonsScopeFromCapabilities(
4747
return DEFAULT_INLINE_BUTTONS_SCOPE;
4848
}
4949
if (Array.isArray(capabilities)) {
50-
const enabled = capabilities.some(
51-
(entry) => normalizeLowercaseStringOrEmpty(String(entry)) === "inlinebuttons",
52-
);
50+
const normalized = capabilities
51+
.map((entry) => normalizeLowercaseStringOrEmpty(String(entry)))
52+
.filter(Boolean);
53+
if (normalized.length === 0) {
54+
return DEFAULT_INLINE_BUTTONS_SCOPE;
55+
}
56+
const enabled = normalized.includes("inlinebuttons");
5357
return enabled ? "all" : "off";
5458
}
5559
if (typeof capabilities === "object") {

0 commit comments

Comments
 (0)