Toolbar badge: a delivery of N captures recounts every capture N times, and an unreachable Postulo is asked twice every five minutes #53
Labels
No labels
bug
documentation
enhancement
performance
security
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo-chromium#53
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What exists today
On the forge's
main(678114c):src/background.js:13-26,src/lib/waiting.js:62-89): deliberate. postulo-chromium#5 decided it ("A decided capture leaves the list, andupdated_sincecannot report a removal, so the list is read whole each time"; twelve reads an hour of the 600 a token gets).GET /captureslists only the captures waiting for review, so a normal inbox is one request of one page; the 200-page bound only stops a loop. Not a finding; and postulo-chromium#50 (group byposting_key) changes the counting, not the reading.background.js:59-66callsshowUnsentCounton everystorage.onChangedthat touches a capture key.deliver(src/lib/outbox.js:44-110) writes each record at least once (store.update, lines 83 and 100-103), andshowUnsentCount(src/lib/local.js:325-340) reads the index and every record (store.list()), the kept list from Postulo and the connection record, then sets badge text, colours, title and icon. So a delivery of N captures does about N to 2N full recounts, each O(N): quadratic in storage reads inside the service worker, for a value only the last one shows.store.dropPage(store.js:133-141) also reads every record once per sent capture.deliverAndRead(background.js:18-26) callscheckPostulo()and thenreadWaitingList()even when the check just recordedunreachable, so each alarm makes two failing requests. A five-minute alarm is already gentle; the waste is the second request, not the rhythm.What would change
showUnsentCountin the background: a call while one is pending sets a flag and the running one goes once more at the end (or a 100 ms debounce). The last state always wins, so the badge and title end where they do today.deliverAndRead, skipreadWaitingListwhencheckPostulohas just recordedunreachable,noPermissionortokenRefused; the last list stays, aswaiting.jsalready promises ("a Postulo that cannot be reached leaves the number where it was").dropPage: check the siblings from the batch's own records (record.batch) rather than listing every capture.No back-off schedule beyond that: the alarm interval is the grey-icon and badge refresh (#4) as well, and lengthening it while unreachable would make the icon slower to turn back.
What it saves or protects
small: a batch delivery of 40 captures stops making about 80 badge recounts, each reading all 40 records and setting badge, title and icon; an unreachable Postulo gets one request per alarm instead of two
Accessibility
must be checked: the badge text and the button's title (
waitingForReview,tokenRefusedand the other reasons) must still end on the right value after a delivery; the popup's spoken status (say()) is not touched. Guarded by the unit tests ofshowUnsentCount/toolbarForand the badge tests intests/.Decisions
Found by the efficiency and reliability audit of 2026-10-30 (finding PR10; index postulo/postulo#1108). Checked against
mainatdaee30b15(2026-10-30).