Repository navigation
Description
History backfill doesn't run on a real account.
Every refresh, refreshQueues (src/daemon/scheduler.ts) queues a forward catch-up for every sync-enabled chat, at the top priority. The daemon runs at most one job every 3 seconds, so catch-ups always win. On a real account with about 1,860 sync-enabled chats, a daemon run completed 103 forward_catchup jobs and no initial_load or backward_history job. A scheduler simulation with 20+ chats gives the same result over an hour.
Also against docs/sync-strategy.md and AGENTS.md:
- "Large groups and channels sync only on request" has no trigger:
setSyncEnabledhas no callers, and the startup dialog pass overwritessync_enabledevery time (src/db/chat-sync-state.ts). - Groups of 20–100 members: AGENTS.md says the last 10 messages, while the code and
docs/sync-strategy.mduse 100. - A group whose dialog has no member count is treated as small, so it can get a full-history sync.
To do:
- Run forward catch-up on start, on reconnect and for gaps (Daemon loses messages that arrive while it is stopped #15), not as periodic polling.
- Share the job budget between catch-up and backfill, so history makes progress.
- Add
tg chats sync <chat>to opt large groups and channels in, and keep that choice across restarts. - Settle the medium-group rule and make the docs match.
- Recheck rate-limit handling for long backfills (Retry failed sync jobs with backoff #9).
Done when a scheduler test with 500 chats shows backfill progress next to catch-ups, and a live daemon run completes initial_load jobs.
Original note: check what's been done, implement what hasn't, write comprehensive tests, recheck rate limit support.
Activity
[-]Backfill sync[/-][+]Backfill sync doesn't run[/+]fix(messages): ask Telegram for a context side the cache lacks
fix(daemon): start backfill at the newest page without a backward cursor
fix(messages): read history from the cache only where it has no gap
Merge origin/main into feat/messages-list-21
fix(messages): ask Telegram for a context side the cache lacks
fix(daemon): start backfill at the newest page without a backward cursor
fix(messages): read history from the cache only where it has no gap
fix(messages): ask Telegram for a context side the cache lacks
fix(daemon): start backfill at the newest page without a backward cursor
fix(messages): read history from the cache only where it has no gap
test(daemon): keep one owner per sync scheduling contract