]> git.giacomolli.uk - onechat/commit
Wait for the WhatsApp catch-up before a turn
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Sun, 8 Nov 2026 15:03:17 +0000 (12:03 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Sun, 8 Nov 2026 15:03:17 +0000 (12:03 -0300)
commit0da1ef837bbd190cc5787214187d1b29d62b9410
treecced24fe48da0c4862d81a6d35119cceb92729fe
parent56d959f2d573eef1be5c04d0bf1659fa30d36e7c
Wait for the WhatsApp catch-up before a turn

After each connection, the WhatsApp servers send the messages that came
while the daemon was away, and then the event OfflineSyncCompleted.
Until that event, or one minute at the most, the daemon keeps the closed
batches in the state file and logs none. At the end it closes all
batches, logs them in order, and wakes the turn loop once with the
batches that need the user, so the whole catch-up gives one turn and not
one turn for each chat. The batches that the state file holds at the
start wait for the first catch-up in the same way.

TurnLoop.Work now only logs and notifies, and the new TurnLoop.Wake adds
several logged messages to the waiting messages at once. A report of a
subagent uses both, and the WhatsApp batches of one delivery join one
turn through one Wake.

Issue: 6f69ca1
README.rst
turn.go
whatsapp.go
whatsapp_test.go