You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sending non-image documents (PDF, DOCX, TXT, ZIP, etc.) to a CodePilot
Telegram bot produces inconsistent, broken behavior. Although CodePilot's
main chat UI input supports file attachments (per #11, implemented via
the @file/@directory mention feature in #508), the Telegram bridge
adapter is a separate code path that has not been updated — it still
only handles photos and image-MIME documents.
isDocumentImage() (line 624-632) accepts only image/jpeg|png|gif|webp. PDF / DOCX / TXT / ZIP all return false.
Scenario B (silent drop) — confirmed by code reading. A standalone document with no caption hits the else branch at line 597-600: // Unhandled message type — skip → markUpdateProcessed() returns without enqueue. No turn, no reply.
Scenario A ("unexpected error") — likely path.flushMediaGroup (line 791-805) similarly skips non-image documents in albums without adding to the rejections list. The exact source of the "unexpected error" message is not pinned down by code reading alone (the catch-all comes from error-classifier.ts:413); it appears to come from a downstream code path that does not gracefully handle the unhandled-document case during mixed-media processing.
The download infrastructure (downloadFileById in telegram-media.ts:193+) already supports arbitrary file types — only the dispatch gates filter them out.
Why it matters
claude-client.ts:1037-1048 already has full end-to-end support for non-image attachments — it persists them to disk and prompts Claude to read via the Read tool:
constnonImageFiles=files.filter(f=>!isImageFile(f.type));if(nonImageFiles.length>0){constsavedPaths=getUploadedFilePaths(nonImageFiles,workDir);// Tells Claude to read attached file via Read tool}
The Feishu adapter handles generic file msg_type via inbound.ts:117-148. The Telegram bridge is the outlier on this code path. The symptom is also more confusing than a silent drop because mixed-media albums emit an error reply instead of just skipping.
Proposed fix / 修复方案
Single-document path: add a m.document && !isDocumentImage(m.document) && isDocumentEnabled() branch in the dispatch that downloads via downloadFileById and enqueues with FileAttachment carrying doc.file_name + doc.mime_type.
Album path: in flushMediaGroup, handle non-image documents in the same loop instead of silently skipping them.
Settings (mirror existing image_ pattern)*:
bridge_telegram_document_enabled (default true)
bridge_telegram_max_document_size (default 20 MB — Telegram Bot API ceiling)
PR incoming.
Workaround / 临时方案
Use the Feishu bridge for documents — Feishu's inbound.ts correctly handles generic file msg_type.
Related / 相关
什么时候支持图片、视频、文件? #11 — original "when will images/video/files be supported?" request, resolved for the main chat UI input but not the Telegram bridge.
The Discord bridge adapter (src/lib/bridge/adapters/discord-adapter.ts:509) has the same limitation — only accepts image/* attachments. Out of scope for this issue; can be filed separately if desired.
Problem / 问题
Sending non-image documents (PDF, DOCX, TXT, ZIP, etc.) to a CodePilot
Telegram bot produces inconsistent, broken behavior. Although CodePilot's
main chat UI input supports file attachments (per #11, implemented via
the
@file/@directorymention feature in #508), the Telegram bridgeadapter is a separate code path that has not been updated — it still
only handles photos and image-MIME documents.
向 CodePilot Telegram bot 发送非图片类型文档时(PDF、DOCX、TXT、ZIP 等),
观察到两种不一致的失败模式。需要说明的是,CodePilot 主聊天界面的输入框
是支持文件附件的(见 #11 的回复,由 #508 实现的
@file功能),但Telegram 桥的 adapter 走的是另一条独立代码路径,没有同步更新。
Reproduction / 复现
Steps:
Root cause / 根因
src/lib/bridge/adapters/telegram-adapter.ts:551-600— inbound dispatch only recognizes images:isDocumentImage()(line 624-632) accepts onlyimage/jpeg|png|gif|webp. PDF / DOCX / TXT / ZIP all return false.// Unhandled message type — skip→markUpdateProcessed()returns without enqueue. No turn, no reply.flushMediaGroup(line 791-805) similarly skips non-image documents in albums without adding to the rejections list. The exact source of the "unexpected error" message is not pinned down by code reading alone (the catch-all comes fromerror-classifier.ts:413); it appears to come from a downstream code path that does not gracefully handle the unhandled-document case during mixed-media processing.The download infrastructure (
downloadFileByIdintelegram-media.ts:193+) already supports arbitrary file types — only the dispatch gates filter them out.Why it matters
claude-client.ts:1037-1048already has full end-to-end support for non-image attachments — it persists them to disk and prompts Claude to read via the Read tool:The Feishu adapter handles generic
filemsg_type viainbound.ts:117-148. The Telegram bridge is the outlier on this code path. The symptom is also more confusing than a silent drop because mixed-media albums emit an error reply instead of just skipping.Proposed fix / 修复方案
m.document && !isDocumentImage(m.document) && isDocumentEnabled()branch in the dispatch that downloads viadownloadFileByIdand enqueues withFileAttachmentcarryingdoc.file_name+doc.mime_type.flushMediaGroup, handle non-image documents in the same loop instead of silently skipping them.bridge_telegram_document_enabled(defaulttrue)bridge_telegram_max_document_size(default 20 MB — Telegram Bot API ceiling)PR incoming.
Workaround / 临时方案
Use the Feishu bridge for documents — Feishu's
inbound.tscorrectly handles genericfilemsg_type.Related / 相关
src/lib/bridge/adapters/discord-adapter.ts:509) has the same limitation — only acceptsimage/*attachments. Out of scope for this issue; can be filed separately if desired.Environment
mainHEAD)@BotFatherflow