fix: preserve explicit Telegram topic targets on replies (#59634) (thanks @dashhuang)

This commit is contained in:
Ayaan Zaidi
2026-04-03 08:36:29 +05:30
parent c001c090b9
commit a5d6e519eb
4 changed files with 28 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ Docs: https://docs.openclaw.ai
- Matrix/crypto persistence: capture and write the IndexedDB snapshot while holding the snapshot file lock so concurrent gateway and CLI persists cannot overwrite newer crypto state. (#59851) Thanks @al3mart.
- Telegram/media: keep inbound image attachments readable on upgraded installs where legacy state roots still differ from the managed config-dir media cache. (#59971) Thanks @neeravmakwana.
- Telegram/local Bot API: thread `channels.telegram.apiRoot` through buffered reply-media and album downloads so self-hosted Bot API file paths stop falling back to `api.telegram.org` and 404ing. (#59544) Thanks @SARAMALI15792.
- Telegram/replies: preserve explicit topic targets when `replyTo` is present while still inheriting the current topic for same-chat replies without an explicit topic. (#59634) Thanks @dashhuang.
## 2026.4.2

View File

@@ -17,7 +17,7 @@ describe("resolveTelegramAutoThreadId", () => {
it("matches chats across Telegram target formats", () => {
expect(
resolveTelegramAutoThreadId({
to: "telegram:group:-100123:topic:77",
to: "telegram:group:-100123",
toolContext: createToolContext(),
}),
).toBe("thread-1");
@@ -36,4 +36,13 @@ describe("resolveTelegramAutoThreadId", () => {
}),
).toBeUndefined();
});
it("does not override an explicit target topic", () => {
expect(
resolveTelegramAutoThreadId({
to: "telegram:group:-100123:topic:77",
toolContext: createToolContext(),
}),
).toBeUndefined();
});
});

View File

@@ -9,6 +9,9 @@ export function resolveTelegramAutoThreadId(params: {
return undefined;
}
const parsedTo = parseTelegramTarget(params.to);
if (parsedTo.messageThreadId != null) {
return undefined;
}
const parsedChannel = parseTelegramTarget(context.currentChannelId);
if (parsedTo.chatId.toLowerCase() !== parsedChannel.chatId.toLowerCase()) {
return undefined;

View File

@@ -268,6 +268,20 @@ describe("telegramPlugin threading", () => {
expect(resolved).toBe("533274");
});
it("does not override an explicit target topic when replyToId is present", () => {
const resolved = telegramPlugin.threading?.resolveAutoThreadId?.({
cfg: createCfg(),
to: "telegram:-1001:topic:99",
replyToId: "4103",
toolContext: {
currentChannelId: "telegram:-1001:topic:77",
currentThreadTs: "77",
},
});
expect(resolved).toBeUndefined();
});
});
describe("telegramPlugin bindings", () => {