Repository navigation
Web app: read again on the server's change hints instead of polling - #2665
Conversation
ea8fef2 to
239ca86
Compare
The server already says on the conversation events socket when something the person sees outside their conversations changed (dataChanged), but the app never asked for it and polled instead: about 120 requests a minute from one idle conversation tab, all day in OpenBot Desktop, with several polls reading lists that only grow to their last page. - The socket asks for data-changed, and each hint marks stale the reads of its kind (lib/live/apply-hints.ts); one about one Bot reaches only that Bot's reads. Hint-fed reads keep their answer for five minutes and poll only for a kind the server does not say it sends (deployment.dataChanged), slowly (60 s) and never while the page is hidden. A reopened socket or a resync marks every hint-fed read stale. - Approvals: the inbox's seven lists become the live queue (approvals and questions, hint-fed), the settings (preferences, rules, organization settings: read once, refreshed by their writes) and the conversation grants. Carry-on after a decision is read from the hint-fed queue, with a timer for its ten-minute limit, instead of a 2 s/10 s poll. An approval card no longer reads seven lists on mount. - Computer control: read on the computers hint, not every second, and the conversation reads it only while the Computer is open as a sheet over it. A server without the hint keeps the old 1 s read while someone watches. - Run histories (a routine's, a goal's) read their newest page of 20, with Show more for older runs, instead of every page every 5 or 10 seconds. - Routines, goals, memory, check-ins, deliveries, shared-use and app access requests, a Bot's activity and attention, and a Bot's components are hint-fed. Components lists ask for view=summary or view=published, and the browser revalidates them by ETag. - Tasks: waiting on the person no longer counts as moving, so a task that needs input does not keep the list on a 3 s poll. Group chats poll only while a reply streams, up to ten minutes.
… only where shown, components asked with their ETag, grants left out of a reconnect's re-read
…h runs only on the server's hint where the server sends one
b2ebf4a to
9b0159c
Compare
…he spread-out read Main now waits a random 0 to 2 s before a reconnected or resynced socket reads its lists again (#2668). The hint-fed reads join that read instead of going out the moment the socket opens, so a deploy that drops every tab doesn't bring their hint-fed reads back together. The first opening reads only the lists, as before.
|
Merged main in (merge commit, no rebase) after #2668, #2646, #2661 and #2664. Two files conflicted.
Kept both, in one read. New test in
Also checked: Local: app typecheck, biome lint and format, and the 33 app test files this PR and #2668 touch (381 pass). Real-browser routine page, needs-you board and section strip pass in Chromium and WebKit. |
# Conflicts: # app/src/components/routines/routine-page.tsx # app/src/lib/channels/use-channel-events.ts # app/src/lib/computers/use-control.ts
# Conflicts: # app/src/components/channels/channel-chat.tsx
# Conflicts: # app/src/components/approvals/settings.tsx
The web app stops polling and reads again on the server's change hints (the conversation events socket's
dataChanged). Builds on #2652 (merged: four new hint kinds,deployment.dataChanged, the components list'sviewand ETag).Why. One signed-in person with one conversation open made about 120 requests a minute while doing nothing, all day in OpenBot Desktop, and several polls read lists that only grow (run history, tasks) to their last page, so load grew with the account's age.
What changes
data-changed. Each hint marks stale the reads of its kind (lib/live/apply-hints.ts); a hint about one Bot reaches only that Bot's per-Bot reads, and one about another organization is dropped. A hint-fed read keeps its answer for five minutes and has no timer while the server says it sends that kind (deployment.dataChanged). A server that doesn't say gets a slow fallback poll (60 s), paused while the page is hidden. A reopened socket or a resync marks every hint-fed read stale.workfield does not say an approval carry-on is going: the server lists only a turn on its own carried-turn queue, which an approval's carry-on joins only when it is handed on (channels/working.ts,turns/carry.ts afterApproval). So carry-on is read from the approval queue as the hints keep it, which costs no requests.computershint (a take-over, a hand-back, a secret asked for, the computer starting or sleeping), not every second. A read that fails is tried again each second until it answers. A server that doesn't send the hint keeps the old 1 s read. (Reading it only while the sheet is open broke the take-over card and the password prompt opening the Computer by itself; with the hint, nothing runs on a timer anyway.)routineshint.grantshint), a Bot's activity and attention, and a Bot's components. The components lists ask forview=summary(the screens) orview=published(a conversation), and the app asks again with the ETag it holds (If-None-Match,lib/api/revalidated.ts), so an unchanged page is a 304. A reopened socket re-reads every hint-fed list except a Bot's grants, which every tab re-reading at once after a deploy is what slowed Cloud on 2026-11-30.needsYouhint.Tests
data-changed-hints.test.tsx: through the real socket hook, factories and screen, with a month of runs (8,640): one page read, no timers, a hint about another organization or another kind reads nothing, theroutineshint brings a new run onto the screen, Show more reads one more page, and a server without hints only polls at 60 s or slower. Forty approval cards drawn one after another read the queue once and never the settings. Red when the hint isn't applied.waiting-is-not-moving.test.ts: 300 tasks with a hundred waiting on the person poll nothing; a group reply past its deadline isn't polled.computer-control-store.test.tsx: the wheel is read on its own hint and not every second.components-etag.test.ts: 60 published components with large sources; read again unchanged, each page is asked with its ETag and answered 304; published again, read whole.The idle-tab request budget on an aged account is pinned in an end-to-end journey in the server's suite, which needs this and the server's side of the hints.
Screens changed: a routine's page and a goal's page (Runs: Show more), the routine row's run history.
Changelog
The web app.