From 7637a97ad50d24144f91aae7287194736e73ca5a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 5 Aug 2026 17:49:17 -0500 Subject: fix(triage): pass a callback to telega--loadChats so scans stop printing 404s telega--loadChats sends fire-and-forget when its callback is nil. The reply then matches no :@extra and falls through to telega--on-error, a catch-all whose whole body prints the message. TDLib returns 404 here to mean every chat is already loaded, so the line was noise we generated ourselves. It printed twice a scan with nothing actually wrong. Passing #'ignore consumes the reply. The call stays asynchronous, since the block-and-wait path is reachable only with a nil callback. --- .ai/workflows/triage-intake.telegram.org | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to '.ai') diff --git a/.ai/workflows/triage-intake.telegram.org b/.ai/workflows/triage-intake.telegram.org index 1319da5..6ec9d66 100644 --- a/.ai/workflows/triage-intake.telegram.org +++ b/.ai/workflows/triage-intake.telegram.org @@ -50,8 +50,10 @@ server never disables the source. The setq is mandatory defense: tdlib crashed in native mode when this was set up (2026-06-09) — a separate matter from the SEGFAULT gotcha, which is about the loadChats argument — and Craig's daemon defaults to nil. - Wait ~2s for Ready, then (telega--loadChats '(:@type "chatListMain")) until telega--chats - is populated. + Wait ~2s for Ready, then (telega--loadChats '(:@type "chatListMain") #'ignore) + until telega--chats is populated. The #'ignore callback is mandatory, not + decoration: without it every call prints a spurious "Telega error 404" (see + Step 1's comment). 3. Check messages: the maphash unread scan in ** Scan Step 2 (filters the messageContactRegistered join-notice noise). 4. Send (needs the server live; /voice personal first — Telegram @@ -135,7 +137,25 @@ emacsclient -e "(progn # The `fboundp' guard matches Step 0: if the launch failed outright telega is not # loaded, and that should read as 'server-died like any other failure rather than # signalling void-function. -emacsclient -e "(progn (ignore-errors (telega--loadChats '(:@type \"chatListMain\"))) (ignore-errors (telega--loadChats '(:@type \"chatListMain\"))) (if (and (fboundp 'telega-server-live-p) (telega-server-live-p)) 'loaded 'server-died))" +# +# The `#'ignore' callback is what keeps this quiet, and it is a THIRD separate +# concern from the two above — it touches the callback, not the argument and not +# docker mode. Without it each call printed `Telega error 404: Not Found' into the +# echo area and *Messages* of Craig's daemon, two lines per scan from whichever +# project ran it. The 404 is TDLib's end-of-list marker ("Return error if all chats are +# loaded"), not a fault: `telega--loadChats' hands the callback to +# `telega-server--send-or-call', which sends fire-and-forget when it is nil, so the +# reply matches no `:@extra', falls through to `telega--on-error' — a bare catch-all +# whose whole body is that message — and gets printed. telega's own startup call +# (telega.el:290) passes a callback and is silent for exactly this reason. +# Passing a callback keeps the call asynchronous: the block-and-wait path in +# `telega-server--call' is reachable only when the callback is nil. +# +# The macro's docstring reads "Use this macro instead of `(or callback 'ignore)' +# pattern." That is guidance for whoever writes a tdlib wrapper — don't hardcode a +# callback inside the wrapper — not a bar on the caller choosing one. We are the +# caller. +emacsclient -e "(progn (ignore-errors (telega--loadChats '(:@type \"chatListMain\") #'ignore)) (ignore-errors (telega--loadChats '(:@type \"chatListMain\") #'ignore)) (if (and (fboundp 'telega-server-live-p) (telega-server-live-p)) 'loaded 'server-died))" #+end_src On a persisted session telega reaches status "Ready" within ~2s; the chat list -- cgit v1.2.3