bug(tasklist): task detail view silently fails when prompt exceeds ~3 870 chars (Telegram 4 096-byte editMessageText limit)
Summary
When a scheduled task's prompt is long (≥ ~3 870 characters), tapping the task in /tasklist does nothing. The bot calls ctx.editMessageText() with a payload that exceeds Telegram's hard 4 096-byte limit, the API returns an error, and the interaction silently crashes.
Root cause
formatTaskDetails() in src/bot/commands/tasklist.ts passes the raw, untruncated task.prompt directly into the t("tasklist.details", { prompt: task.prompt, … }) i18n template.
The surrounding chrome added by that template (header line, schedule, model string, timezone, next/last run timestamps, run count) consumes roughly 230 bytes. That leaves only ~3 866 characters of budget for the prompt before the total message hits Telegram's limit.
// src/bot/commands/tasklist.ts (current — broken)
function formatTaskDetails(task: ScheduledTask): string {
…
return t("tasklist.details", {
prompt: task.prompt, // ← no length guard
…
});
}
User-visible impact
- User taps a task whose prompt is longer than ~3 870 characters.
- The detail panel never opens — the message is not updated and no error is shown.
- The interaction state is never cleared, so subsequent taps on the same task also fail until the session expires.
Reproduction
- Create a scheduled task with a prompt of 4 000+ characters.
- Open
/tasklistand tap the task. - Observe: the message does not update (silent failure).
Fix
truncateText(text, maxLength) is already defined in the same file (line 88). One-line change:
- prompt: task.prompt,
+ prompt: truncateText(task.prompt, 3800),
Why 3 800?
4 096 (Telegram limit) − 230 (template chrome) − 66 (safety margin) = 3 800
This keeps the full message safely under the limit while showing as much of the prompt as possible, appending … only when necessary.
Proposed branch
fix/tasklist-prompt-truncation
I plan to submit a PR with the fix and a new unit test covering the truncation case.
This is now fixed in #172
Root cause: formatTaskDetails() passed the raw prompt directly into the i18n template. Prompts longer than ~3870 chars exceeded Telegram's 4096-byte editMessageText limit.
Fix: Added truncatePromptForDetails() to truncate the prompt to 3800 chars before sending to Telegram. The full prompt is preserved in storage — only the display is truncated.
Thanks for the detailed report!